procd: get rid of putenv usage.
authorRosen Penev <rosenp@gmail.com>
Tue, 23 Jan 2018 20:30:52 +0000 (12:30 -0800)
committerJohn Crispin <john@phrozen.org>
Mon, 12 Feb 2018 14:03:21 +0000 (15:03 +0100)
setenv is prefered according to POSIX. Also allows staticly allocated strings.

Saves 200 bytes when stripped. 432 without.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
service/instance.c

index 12c2efe2b2cc467d1ff6ac9174d5a3b870a9631d..ecbb6ea41e78523d288d4d38db38885011c671d0 100644 (file)
@@ -279,7 +279,6 @@ instance_run(struct service_instance *in, int _stdout, int _stderr)
        struct blobmsg_list_node *var;
        struct blob_attr *cur;
        char **argv;
-       char *ld_preload;
        int argc = 1; /* NULL terminated */
        int rem, _stdin;
        bool seccomp = !in->trace && !in->has_jail && in->seccomp;
@@ -297,8 +296,8 @@ instance_run(struct service_instance *in, int _stdout, int _stderr)
        if (seccomp)
                setenv("SECCOMP_FILE", in->seccomp, 1);
 
-       if (setlbf && asprintf(&ld_preload, "LD_PRELOAD=/lib/libsetlbf.so") > 0)
-               putenv(ld_preload);
+       if (setlbf)
+               setenv("LD_PRELOAD", "/lib/libsetlbf.so", 1);
 
        blobmsg_list_for_each(&in->limits, var)
                instance_limits(blobmsg_name(var->data), blobmsg_data(var->data));