*: make exec failure message more consistent
authorDenys Vlasenko <vda.linux@googlemail.com>
Thu, 24 Jun 2010 23:46:53 +0000 (01:46 +0200)
committerDenys Vlasenko <vda.linux@googlemail.com>
Thu, 24 Jun 2010 23:46:53 +0000 (01:46 +0200)
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
24 files changed:
console-tools/openvt.c
coreutils/chroot.c
coreutils/env.c
coreutils/nice.c
coreutils/nohup.c
debianutils/start_stop_daemon.c
libbb/run_shell.c
libbb/vfork_daemon_rexec.c
mailutils/mail.c
mailutils/mime.c
miscutils/chrt.c
miscutils/ionice.c
miscutils/setsid.c
miscutils/taskset.c
miscutils/time.c
miscutils/timeout.c
networking/httpd.c
networking/ifupdown.c
networking/inetd.c
networking/nc_bloaty.c
networking/tcpudp.c
printutils/lpd.c
runit/chpst.c
selinux/runcon.c

index 7bd6072a4675f4d584e8ca051e218ecfb1361f65..6f58916e7b61c5b3b16b4ff60c91b14d53e71f64 100644 (file)
@@ -98,7 +98,7 @@ static NOINLINE void vfork_child(char **argv)
                //bb_error_msg("VT's sid %d", tcgetsid(0));
                //bb_error_msg("VT's pgrp %d", tcgetpgrp(0));
                BB_EXECVP(argv[0], argv);
-               bb_perror_msg_and_die("exec %s", argv[0]);
+               bb_perror_msg_and_die("can't execute '%s'", argv[0]);
        }
 }
 
index f7228a61ae4ef904d86a30e1aa63b58b35d6089b..bc0b1f82c4a32feb25f2d6891b9f22a6d6e76afb 100644 (file)
@@ -30,6 +30,6 @@ int chroot_main(int argc UNUSED_PARAM, char **argv)
                argv[1] = (char *) "-i";
        }
 
-       BB_EXECVP(*argv, argv);
-       bb_perror_msg_and_die("can't execute '%s'", *argv);
+       BB_EXECVP(argv[0], argv);
+       bb_perror_msg_and_die("can't execute '%s'", argv[0]);
 }
index 9635d2b22aa580b9aaa290b610f582e8ccc35efa..c6ba04d35482544656ce78dab4d86adb05ce9a7e 100644 (file)
@@ -76,11 +76,11 @@ int env_main(int argc UNUSED_PARAM, char **argv)
                ++argv;
        }
 
-       if (*argv) {
-               BB_EXECVP(*argv, argv);
+       if (argv[0]) {
+               BB_EXECVP(argv[0], argv);
                /* SUSv3-mandated exit codes. */
                xfunc_error_retval = (errno == ENOENT) ? 127 : 126;
-               bb_simple_perror_msg_and_die(*argv);
+               bb_perror_msg_and_die("can't execute '%s'", argv[0]);
        }
 
        if (environ) { /* clearenv() may set environ == NULL! */
index d24a95b45f85ed3763b370e47b3bba4c1ca662b3..0f70f1079a4a2d1b87a6428d2a56ce15ffb4751c 100644 (file)
@@ -47,9 +47,8 @@ int nice_main(int argc, char **argv)
                }
        }
 
-       BB_EXECVP(*argv, argv);         /* Now exec the desired program. */
-
+       BB_EXECVP(argv[0], argv);
        /* The exec failed... */
        xfunc_error_retval = (errno == ENOENT) ? 127 : 126; /* SUSv3 */
-       bb_simple_perror_msg_and_die(*argv);
+       bb_perror_msg_and_die("can't execute '%s'", argv[0]);
 }
index 4f6385f8eb2347fef0e0f414a26801e5816467ba..1027ada1c689da32d8469990e8cd716cc9329cb4 100644 (file)
@@ -75,6 +75,7 @@ int nohup_main(int argc UNUSED_PARAM, char **argv)
 
        signal(SIGHUP, SIG_IGN);
 
-       BB_EXECVP(argv[1], argv+1);
-       bb_simple_perror_msg_and_die(argv[1]);
+       argv++;
+       BB_EXECVP(argv[0], argv);
+       bb_perror_msg_and_die("can't execute '%s'", argv[0]);
 }
index 0a0802575e12859fe1658573c63e053a24502ecd..3ded758bf4c24003ef514e9033f6c20ac5f0c14d 100644 (file)
@@ -448,5 +448,5 @@ int start_stop_daemon_main(int argc UNUSED_PARAM, char **argv)
        }
 #endif
        execvp(startas, argv);
-       bb_perror_msg_and_die("can't start %s", startas);
+       bb_perror_msg_and_die("can't execute '%s'", startas);
 }
index 6f98bd695b57e69d8fa75447d86e4c8612edcc84..4608a24a91f73240b4e2a44de58dba92ace1fd0a 100644 (file)
@@ -86,5 +86,5 @@ void FAST_FUNC run_shell(const char *shell, int loginshell, const char *command,
                freecon(current_sid);
 #endif
        execv(shell, (char **) args);
-       bb_perror_msg_and_die("can't run '%s'", shell);
+       bb_perror_msg_and_die("can't execute '%s'", shell);
 }
index 07024f5f07758ea0a1dd02ae7f7d26c16a08dc27..082f0f63edde4a65b13b10f1d342c2d2a109aefc 100644 (file)
@@ -249,7 +249,7 @@ void FAST_FUNC re_exec(char **argv)
         * "we have (already) re-execed, don't do it again" flag */
        argv[0][0] |= 0x80;
        execv(bb_busybox_exec_path, argv);
-       bb_perror_msg_and_die("exec %s", bb_busybox_exec_path);
+       bb_perror_msg_and_die("can't execute '%s'", bb_busybox_exec_path);
 }
 
 pid_t FAST_FUNC fork_or_rexec(char **argv)
index 64a5b996f4f831517bf860380246760740707fe8..49e72c32bff54bbd9037173af9ff0189fc7c9d34 100644 (file)
@@ -67,8 +67,8 @@ void FAST_FUNC launch_helper(const char **argv)
        if (!G.helper_pid) {
                // child: try to execute connection helper
                // NB: SIGCHLD & SIGALRM revert to SIG_DFL on exec
-               BB_EXECVP(*argv, (char **)argv);
-               _exit(127);
+               BB_EXECVP(argv[0], (char **)argv);
+               bb_perror_msg_and_die("can't execute '%s'", argv[0]);
        }
 
        // parent
index ee147802e2b0343b9c9250b843ebdd6b7b71a5ad..654b8731ce12abaca04fdfe003bb7d88454a75f5 100644 (file)
@@ -288,8 +288,8 @@ static int parse(const char *boundary, char **argv)
                                        xsetenv("CHARSET", charset);
                                        xsetenv("ENCODING", encoding);
                                        xsetenv("FILENAME", filename);
-                                       BB_EXECVP(*argv, argv);
-                                       _exit(EXIT_FAILURE);
+                                       BB_EXECVP(argv[0], argv);
+                                       bb_perror_msg_and_die("can't execute '%s'", argv[0]);
                                }
                                // parent dumps to fd[1]
                                close(fd[0]);
index cc5660be7ba215b71affb82c6aaada963f577cad..e2b7f8ae059e57c0bdd30b99da69cea3d059ec9c 100644 (file)
@@ -115,9 +115,9 @@ int chrt_main(int argc UNUSED_PARAM, char **argv)
        if (sched_setscheduler(pid, policy, &sp) < 0)
                bb_perror_msg_and_die("can't %cet pid %d's policy", 's', pid);
 
-       if (!*argv) /* "-p <priority> <pid> [...]" */
+       if (!argv[0]) /* "-p <priority> <pid> [...]" */
                goto print_rt_info;
 
-       BB_EXECVP(*argv, argv);
-       bb_simple_perror_msg_and_die(*argv);
+       BB_EXECVP(argv[0], argv);
+       bb_perror_msg_and_die("can't execute '%s'", argv[0]);
 }
index 361c141b82d4859542af304918f77ef4ccdd9244..8393cd8b2830fe696c21b614715dc3e7aecb7f90 100644 (file)
@@ -89,9 +89,9 @@ int ionice_main(int argc UNUSED_PARAM, char **argv)
                pri |= (ioclass << IOPRIO_CLASS_SHIFT);
                if (ioprio_set(IOPRIO_WHO_PROCESS, pid, pri) == -1)
                        bb_perror_msg_and_die("ioprio_%cet", 's');
-               if (*argv) {
-                       BB_EXECVP(*argv, argv);
-                       bb_simple_perror_msg_and_die(*argv);
+               if (argv[0]) {
+                       BB_EXECVP(argv[0], argv);
+                       bb_perror_msg_and_die("can't execute '%s'", argv[0]);
                }
        }
 
index fd3283e30def9d2ae0a98396fab42f62bf7a1505..60ee062e37e4a01880acf6b99ca1e7e8eda6c8f4 100644 (file)
@@ -44,6 +44,7 @@ int setsid_main(int argc UNUSED_PARAM, char **argv)
                setsid();
        }
 
-       BB_EXECVP(argv[1], argv + 1);
-       bb_simple_perror_msg_and_die(argv[1]);
+       argv++;
+       BB_EXECVP(argv[0], argv);
+       bb_perror_msg_and_die("can't execute '%s'", argv[0]);
 }
index a0bbf0aa190e320942b42f4b6d5a0a3b4a8048e3..2891003dfa69ba9b63c2ccb171e85f3c089acaee 100644 (file)
@@ -129,9 +129,9 @@ int taskset_main(int argc UNUSED_PARAM, char **argv)
        if (sched_setaffinity(pid, sizeof(mask), &mask))
                bb_perror_msg_and_die("can't %cet pid %d's affinity", 's', pid);
 
-       if (!*argv) /* "-p <aff> <pid> [...ignored...]" */
+       if (!argv[0]) /* "-p <aff> <pid> [...ignored...]" */
                goto print_aff; /* print new affinity and exit */
 
-       BB_EXECVP(*argv, argv);
-       bb_simple_perror_msg_and_die(*argv);
+       BB_EXECVP(argv[0], argv);
+       bb_perror_msg_and_die("can't execute '%s'", argv[0]);
 }
index 6946c863fb8084d70f6e428400e350293af8705e..f5d1e15fb21f2c5fbf467e531792c4befb145223 100644 (file)
@@ -380,7 +380,7 @@ static void run_command(char *const *cmd, resource_t *resp)
                   versus merely warnings if the cast is left off.  */
                BB_EXECVP(cmd[0], cmd);
                xfunc_error_retval = (errno == ENOENT ? 127 : 126);
-               bb_error_msg_and_die("can't run '%s'", cmd[0]);
+               bb_perror_msg_and_die("can't execute '%s'", cmd[0]);
        }
 
        /* Have signals kill the child but not self (if possible).  */
index 83ae56e69edb333d3d951a01d83de0cc56e017a8..273d26953d76bd5b8508d798a936ecf71a1a6198 100644 (file)
@@ -111,5 +111,5 @@ int timeout_main(int argc UNUSED_PARAM, char **argv)
        argv[1] = sv2;
 #endif
        BB_EXECVP(argv[0], argv);
-       bb_perror_msg_and_die("exec '%s'", argv[0]);
+       bb_perror_msg_and_die("can't execute '%s'", argv[0]);
 }
index 6dbc219e746e6ec5545a1d787d7c4964729dca4e..bab7b99cb47ff42100c1bef2b03cdcbef492c7d2 100644 (file)
@@ -1474,7 +1474,7 @@ static void send_cgi_and_exit(
                 * in the current directory */
                execv(argv[0], argv);
                if (verbose)
-                       bb_perror_msg("exec %s", argv[0]);
+                       bb_perror_msg_and_die("can't execute '%s'", argv[0]);
  error_execing_cgi:
                /* send to stdout
                 * (we are CGI here, our stdout is pumped to the net) */
index 2f3dd1d7bed6209d507aafd45fa096c2d29513f7..714d2a1079e6f4e188a99703ab5a61790c9d078b 100644 (file)
@@ -1053,7 +1053,7 @@ static int popen2(FILE **in, FILE **out, char *command, char *param)
                xmove_fd(infd.rd, 0);
                xmove_fd(outfd.wr, 1);
                BB_EXECVP(command, argv);
-               _exit(127);
+               bb_perror_msg_and_die("can't execute '%s'", command);
        }
        /* parent */
        close(infd.rd);
index 7aa6b7b19372fa4d7a2f79f6e6f1037030d9fdfb..6d21e18f52208c858b7d1164efae0da9bca2fda3 100644 (file)
@@ -1380,7 +1380,7 @@ int inetd_main(int argc UNUSED_PARAM, char **argv)
                        sigaction_set(SIGPIPE, &saved_pipe_handler);
                        restore_sigmask(&omask);
                        BB_EXECVP(sep->se_program, sep->se_argv);
-                       bb_perror_msg("exec %s", sep->se_program);
+                       bb_perror_msg_and_die("can't execute '%s'", sep->se_program);
  do_exit1:
                        /* eat packet in udp case */
                        if (sep->se_socktype != SOCK_STREAM)
index e14d512ed1b6e4d7070346a29cee4a62ef2948b3..8d27e968298c42e0621f2bd3d424c897c9c780f1 100644 (file)
@@ -230,7 +230,7 @@ static int doexec(char **proggie)
        /* dup2(0, 2); - do we *really* want this? NO!
         * exec'ed prog can do it yourself, if needed */
        execvp(proggie[0], proggie);
-       bb_perror_msg_and_die("exec");
+       bb_perror_msg_and_die("can't execute '%s'", proggie[0]);
 }
 
 /* connect_w_timeout:
index b32fad624a8a68d0268674f3c96eccfb16853823..4e47567389264e35fdc9482fc9fcefe00b900e46 100644 (file)
@@ -504,7 +504,7 @@ int tcpudpsvd_main(int argc UNUSED_PARAM, char **argv)
 #else
        BB_EXECVP(argv[0], argv);
 #endif
-       bb_perror_msg_and_die("exec '%s'", argv[0]);
+       bb_perror_msg_and_die("can't execute '%s'", argv[0]);
 }
 
 /*
index 43c22948ff868020ced54365edd8df401b348b40..15f1ba20b20e3c0807a92c7e5fd46542efa73125 100644 (file)
@@ -181,8 +181,8 @@ int lpd_main(int argc UNUSED_PARAM, char *argv[])
                        // this call reopens stdio fds to "/dev/null"
                        // (no daemonization is done)
                        bb_daemonize_or_rexec(DAEMON_DEVNULL_STDIO | DAEMON_ONLY_SANITIZE, NULL);
-                       BB_EXECVP(*argv, argv);
-                       exit(127);
+                       BB_EXECVP(argv[0], argv);
+                       bb_perror_msg_and_die("can't execute '%s'", argv[0]);
                }
 
                // validate input.
index 1a68eb755320951efa881cfbeb96cb06adc5dcd5..028a28d6c04d8c736bda092d4d405529db89808c 100644 (file)
@@ -383,5 +383,5 @@ int chpst_main(int argc UNUSED_PARAM, char **argv)
                close(STDERR_FILENO);
 
        BB_EXECVP(argv[0], argv);
-       bb_perror_msg_and_die("exec %s", argv[0]);
+       bb_perror_msg_and_die("can't execute '%s'", argv[0]);
 }
index 4afd1116e5d2a2a089e292901452e28b7dfcca6a..f8ca9a6aa277f0becb67f7f3ffbab0c91e017441 100644 (file)
@@ -133,6 +133,5 @@ int runcon_main(int argc UNUSED_PARAM, char **argv)
                                     context_str(con));
 
        execvp(argv[0], argv);
-
        bb_perror_msg_and_die("can't execute '%s'", argv[0]);
 }