|
|
|
@ -87,7 +87,7 @@ struct user_info { |
|
|
|
|
static void *emalloc(size_t); |
|
|
|
|
static char *estrdup(const char *); |
|
|
|
|
void *erealloc(void *, size_t); |
|
|
|
|
static void usage(void); |
|
|
|
|
static void usage(int); |
|
|
|
|
static void die(const char *, ...); |
|
|
|
|
static int perm_set(struct passwd *, struct group *); |
|
|
|
|
static int authenticate(uid_t, int, int); |
|
|
|
@ -106,7 +106,7 @@ int main(int argc, char *argv[]) |
|
|
|
|
struct user_info t_gr_info = {0}, t_pw_info = {0}; |
|
|
|
|
int opt, err; |
|
|
|
|
int shellflag = 0, envflag = 0, askpass = 0; |
|
|
|
|
while ((opt = getopt(argc, argv, "Au:g:C:se")) != -1) { |
|
|
|
|
while ((opt = getopt(argc, argv, "Au:g:C:seh")) != -1) { |
|
|
|
|
switch (opt) { |
|
|
|
|
case 'A': |
|
|
|
|
askpass = 1; |
|
|
|
@ -126,8 +126,12 @@ int main(int argc, char *argv[]) |
|
|
|
|
case 'e': |
|
|
|
|
envflag = 1; |
|
|
|
|
break; |
|
|
|
|
case 'h': |
|
|
|
|
usage(1); |
|
|
|
|
exit(EXIT_SUCCESS); |
|
|
|
|
break; |
|
|
|
|
case '?': |
|
|
|
|
usage(); |
|
|
|
|
usage(0); |
|
|
|
|
exit(EINVAL); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
@ -368,17 +372,18 @@ int main(int argc, char *argv[]) |
|
|
|
|
return errno; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static inline void usage(void) |
|
|
|
|
static inline void usage(int complete) |
|
|
|
|
{ |
|
|
|
|
// TODO: planned options
|
|
|
|
|
// -a [program]: like sudo's askpass
|
|
|
|
|
// -u [user]: change the default user from root to user
|
|
|
|
|
// -g [group]: change the primary group to [gorup]
|
|
|
|
|
// both -a and -g will accept numbers with #[num] like sudo
|
|
|
|
|
// -c [file]: manually select config file
|
|
|
|
|
// something about environment
|
|
|
|
|
// something about non interactiveness
|
|
|
|
|
printf("usage: us [-seA] [-u user] [-g group] [-C config] command [args]\n"); |
|
|
|
|
printf("usage: us [-hseA] [-u user] [-g group] [-C config] command [args]\n"); |
|
|
|
|
if (!complete) |
|
|
|
|
return; |
|
|
|
|
printf("-h print this message\n" |
|
|
|
|
"-s use the user's shell instead of /bin/sh\n" |
|
|
|
|
"-e keep the user's entire environment\n" |
|
|
|
|
"-A use the command in US_ASKPASS as askpass helper\n" |
|
|
|
|
"-u user set new user to 'user' instead of root\n" |
|
|
|
|
"-s group set new group to 'group'\n" |
|
|
|
|
"-C config use specifi config file\n"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int perm_set(struct passwd *pw, struct group *gr) |
|
|
|
|