]> git.ipfire.org Git - people/teissler/ipfire-2.x.git/commitdiff
misc-progs: Add path to executable to argv
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 14 Jun 2022 16:14:18 +0000 (16:14 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 14 Jun 2022 18:37:32 +0000 (18:37 +0000)
Otherwise, the first argument would always be swollowed :(

Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/misc-progs/setuid.c

index 831fb1f90b599f227afe95bf3f8c31b61b7a0f1b..17b0e70667540407dcb30bf9084f0641919d743f 100644 (file)
@@ -61,10 +61,8 @@ static int system_core(char* command, char** args, uid_t uid, gid_t gid, char *e
        if(!command)
                return 1;
 
-#if 0
        // Add command as first element to argv
        argv[argc++] = command;
-#endif
 
        // Add all other arguments
        if (args) {
@@ -138,7 +136,7 @@ int safe_system(char* command) {
                NULL,
        };
 
-       return system_core(argv[0], argv, 0, 0, "safe_system");
+       return system_core(argv[0], argv + 1, 0, 0, "safe_system");
 }
 
 /* Much like safe_system but lets you specify a non-root uid and gid to run
@@ -151,7 +149,7 @@ int unpriv_system(char* command, uid_t uid, gid_t gid) {
                NULL,
        };
 
-       return system_core(argv[0], argv, uid, gid, "unpriv_system");
+       return system_core(argv[0], argv + 1, uid, gid, "unpriv_system");
 }
 
 /* General routine to initialise a setuid root program, and put the