Fixes: 41664054b8b1 ("logd: fix ignored return values in set{gid,uid}")
Signed-off-by: Giovanni Giacobbi <[email protected]>
---
 log/logd.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/log/logd.c b/log/logd.c
index 5d6c458..594b1e0 100644
--- a/log/logd.c
+++ b/log/logd.c
@@ -243,37 +243,37 @@ main(int argc, char **argv)
        struct passwd *p = NULL;
 
        signal(SIGPIPE, SIG_IGN);
        while ((ch = getopt(argc, argv, "S:")) != -1) {
                switch (ch) {
                case 'S':
                        log_size = atoi(optarg);
                        if (log_size < 1)
                                log_size = 16;
                        break;
                }
        }
        log_size *= 1024;
 
        uloop_init();
        log_init(log_size);
        conn.cb = ubus_connect_handler;
        ubus_auto_connect(&conn);
        p = getpwnam("logd");
        if (p) {
-               if (setuid(p->pw_uid) < 0) {
-                       fprintf(stderr, "setuid() failed: %s\n", 
strerror(errno));
+               if (setgid(p->pw_gid) < 0) {
+                       fprintf(stderr, "setgid() failed: %s\n", 
strerror(errno));
                        exit(1);
                }
 
-               if (setgid(p->pw_gid) < 0) {
-                       fprintf(stderr, "setgid() failed: %s\n", 
strerror(errno));
+               if (setuid(p->pw_uid) < 0) {
+                       fprintf(stderr, "setuid() failed: %s\n", 
strerror(errno));
                        exit(1);
                }
        }
        uloop_run();
        log_shutdown();
        uloop_done();
        ubus_auto_shutdown(&conn);
 
        return 0;
 }
-- 
2.17.2


_______________________________________________
openwrt-devel mailing list
[email protected]
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to