aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2017-01-09 11:32:50 +0100
committerJosé Bollo <jose.bollo@iot.bzh>2017-01-09 13:43:15 +0100
commit86be207174efcb84f6eb22946724a25a3cd9b56c (patch)
tree568ad543eb2318506357a72e2f2d638d1da26e8d
parentc07d1ea01ae008dc5aa379932b1d2da90d7d291c (diff)
Set application id when forking
This improvement should make log message more clear. Change-Id: Ifc78f7d913a1798a43b54df6b2bf9b52232d328a Signed-off-by: José Bollo <jose.bollo@iot.bzh>
-rw-r--r--src/afm-launch.c3
-rw-r--r--src/verbose.c8
2 files changed, 9 insertions, 2 deletions
diff --git a/src/afm-launch.c b/src/afm-launch.c
index bb528e5..9ed5966 100644
--- a/src/afm-launch.c
+++ b/src/afm-launch.c
@@ -731,6 +731,9 @@ static pid_t launch(
close(rpipe[0]);
+ /* set name by appid */
+ verbose_set_name(desc->appid, 0);
+
/* avoid set-gid effect */
setresgid(groupid, groupid, groupid);
diff --git a/src/verbose.c b/src/verbose.c
index 2045bde..6d0db01 100644
--- a/src/verbose.c
+++ b/src/verbose.c
@@ -43,14 +43,17 @@ void vverbose(int level, const char *file, int line, const char *fmt, va_list ar
void verbose_set_name(const char *name, int authority)
{
+ closelog();
openlog(name, LOG_PERROR, authority ? LOG_AUTH : LOG_USER);
}
#else
+#include <stdlib.h>
+#include <string.h>
#include <unistd.h>
-static const char *appname;
+static char *appname;
static int appauthority;
@@ -79,7 +82,8 @@ void vverbose(int level, const char *file, int line, const char *fmt, va_list ar
void verbose_set_name(const char *name, int authority)
{
- appname = name;
+ free(appname);
+ appname = name ? strdup(name) : NULL;
appauthority = authority;
}