Set application id when forking
authorJosé Bollo <jose.bollo@iot.bzh>
Mon, 9 Jan 2017 10:32:50 +0000 (11:32 +0100)
committerJosé Bollo <jose.bollo@iot.bzh>
Mon, 9 Jan 2017 12:43:15 +0000 (13:43 +0100)
This improvement should make log message more clear.

Change-Id: Ifc78f7d913a1798a43b54df6b2bf9b52232d328a
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
src/afm-launch.c
src/verbose.c

index bb528e5..9ed5966 100644 (file)
@@ -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);
 
index 2045bde..6d0db01 100644 (file)
@@ -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;
 }