chiark / gitweb /
udevadm: do not free node on success
[elogind.git] / src / activate / activate.c
index be40be48a453855d9522ae1f8e6df0ce5ba9625b..3ea2470a1faa93361576095ad3388a1cabd21d21 100644 (file)
@@ -137,6 +137,11 @@ static int open_sockets(int *epoll_fd, bool accept) {
                 count ++;
         }
 
+        /** Note: we leak some fd's on error here. I doesn't matter
+         *  much, since the program will exit immediately anyway, but
+         *  would be a pain to fix.
+         */
+
         STRV_FOREACH(address, arg_listen) {
                 log_info("Opening address %s", *address);
 
@@ -164,9 +169,10 @@ static int open_sockets(int *epoll_fd, bool accept) {
         return count;
 }
 
-static int launch(char* name, char **argv, char **environ, int fds) {
+static int launch(char* name, char **argv, char **env, int fds) {
         unsigned n_env = 0, length;
-        char **envp = NULL, **s;
+        char _cleanup_strv_free_ **envp = NULL;
+        char **s;
         static const char* tocopy[] = {"TERM=", "PATH=", "USER=", "HOME="};
         char _cleanup_free_ *tmp = NULL;
         unsigned i;
@@ -182,14 +188,14 @@ static int launch(char* name, char **argv, char **environ, int fds) {
                         char _cleanup_free_ *p = strappend(*s, "=");
                         if (!p)
                                 return log_oom();
-                        envp[n_env] = strv_find_prefix(environ, p);
+                        envp[n_env] = strv_find_prefix(env, p);
                         if (envp[n_env])
                                 n_env ++;
                 }
         }
 
         for (i = 0; i < ELEMENTSOF(tocopy); i++) {
-                envp[n_env] = strv_find_prefix(environ, tocopy[i]);
+                envp[n_env] = strv_find_prefix(env, tocopy[i]);
                 if (envp[n_env])
                         n_env ++;
         }
@@ -208,7 +214,7 @@ static int launch(char* name, char **argv, char **environ, int fds) {
         return -errno;
 }
 
-static int launch1(const char* child, char** argv, char **environ, int fd) {
+static int launch1(const char* child, char** argv, char **env, int fd) {
         pid_t parent_pid, child_pid;
         int r;