diff options
-rw-r--r-- | bin/autobuild.c | 19 |
1 files changed, 3 insertions, 16 deletions
diff --git a/bin/autobuild.c b/bin/autobuild.c index 07e84e9..bb0de00 100644 --- a/bin/autobuild.c +++ b/bin/autobuild.c @@ -1,3 +1,4 @@ +/* Just a "stupid", secure SUID wrapper around autobuild.sh */ /* Copyright (C) 2014 Luke Shumaker <lukeshu@sbcglobal.net> * * This program is free software; you can redistribute it and/or modify @@ -19,17 +20,9 @@ #include <errno.h> /* for errno */ #include <error.h> /* for error(3) */ #include <pwd.h> /* for getpwuid(3) */ -#include <stdio.h> /* for printf(3) */ #include <stdlib.h> /* for environment functions */ #include <string.h> /* for strlen(3), strcpy(3) */ -#include <unistd.h> /* for dup2(3), geteuid(3), execl(3) */ - -void -usage(const char *cmd) -{ - printf("Usage: %s PACKAGE\n", cmd); - printf("This command should be run from the git directory of the package source.\n"); -} +#include <unistd.h> /* for geteuid(3), execv(3) */ void mysetenv(const char *name, const char *value) @@ -44,12 +37,6 @@ mysetenv(const char *name, const char *value) int main(int argc, char **argv) { - if (argc != 2) { - dup2(2,1); - usage(argv[0]); - return 1; - } - struct passwd *user = getpwuid(geteuid()); setreuid(geteuid(), -1); @@ -81,6 +68,6 @@ main(int argc, char **argv) strcpy(script, user->pw_dir); strcpy(&(script[strlen(user->pw_dir)]), script_suffix); - execl(script, script, argv[1], NULL); + execv(script, argv); error(127, errno, "%s", script); } |