sys-utils: use errexec()

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2018-02-01 15:44:25 +01:00
parent 7bc5eeee44
commit fd777151bf
9 changed files with 12 additions and 14 deletions

View file

@ -667,7 +667,7 @@ static void umount_one(const struct eject_control *ctl, const char *name)
else
execl("/bin/umount", "/bin/umount", name, NULL);
errx(EXIT_FAILURE, _("unable to exec /bin/umount of `%s'"), name);
errexec("/bin/umount");
case -1:
warn( _("unable to fork"));

View file

@ -478,7 +478,7 @@ int main(int argc, char *argv[])
if (optind < argc) {
execvp(argv[optind], argv + optind);
err(EXIT_FAILURE, _("failed to execute %s"), argv[optind]);
errexec(argv[optind]);
}
exec_shell();
}

View file

@ -639,7 +639,7 @@ int main(int argc, char **argv)
if (argc > optind) {
/* prlimit [options] COMMAND */
execvp(argv[optind], &argv[optind]);
err(EXIT_FAILURE, _("failed to execute %s"), argv[optind]);
errexec(argv[optind]);
}
return EXIT_SUCCESS;

View file

@ -294,7 +294,7 @@ int main(int argc, char *argv[])
if (set_arch(arch, 0L, 0))
err(EXIT_FAILURE, _("Failed to set personality to %s"), arch);
execl("/bin/bash", "", NULL);
err(EXIT_FAILURE, _("failed to execute %s"), "/bin/bash");
errexec("/bin/bash");
}
#endif
} else {
@ -381,10 +381,9 @@ int main(int argc, char *argv[])
if (!argc) {
execl("/bin/sh", "-sh", NULL);
err(EXIT_FAILURE, _("failed to execute %s"), "/bin/sh");
errexec("/bin/sh");
}
execvp(argv[0], argv);
err(EXIT_FAILURE, "%s", argv[0]);
return EXIT_FAILURE;
errexec(argv[0]);
}

View file

@ -990,6 +990,5 @@ int main(int argc, char **argv)
}
execvp(argv[optind], argv + optind);
err(EXIT_FAILURE, _("cannot execute: %s"), argv[optind]);
errexec(argv[optind]);
}

View file

@ -119,5 +119,5 @@ int main(int argc, char **argv)
if (ctty && ioctl(STDIN_FILENO, TIOCSCTTY, 1))
err(EXIT_FAILURE, _("failed to set the controlling terminal"));
execvp(argv[optind], argv + optind);
err(EXIT_FAILURE, _("failed to execute %s"), argv[optind]);
errexec(argv[optind]);
}

View file

@ -341,7 +341,7 @@ static int swap_reinitialize(struct swap_device *dev)
cmd[idx++] = dev->path;
cmd[idx++] = NULL;
execvp(cmd[0], (char * const *) cmd);
err(EXIT_FAILURE, _("failed to execute %s"), cmd[0]);
errexec(cmd[0]);
default: /* parent */
do {
@ -353,7 +353,7 @@ static int swap_reinitialize(struct swap_device *dev)
return -1;
}
/* mkswap returns: 0=suss, 1=error */
/* mkswap returns: 0=suss, >0 error */
if (WIFEXITED(status) && WEXITSTATUS(status)==0)
return 0; /* ok */
break;

View file

@ -258,6 +258,6 @@ int main(int argc, char *argv[])
warn(_("cannot access %s"), init);
execv(init, initargs);
err(EXIT_FAILURE, _("failed to execute %s"), init);
errexec(init);
}

View file

@ -475,7 +475,7 @@ int main(int argc, char *argv[])
if (optind < argc) {
execvp(argv[optind], argv + optind);
err(EXIT_FAILURE, _("failed to execute %s"), argv[optind]);
errexec(argv[optind]);
}
exec_shell();
}