Skip to content

Commit

Permalink
Merge pull request #36 from helmat/master
Browse files Browse the repository at this point in the history
Add option for full login
  • Loading branch information
slicer69 authored Jun 21, 2020
2 parents 0a04433 + 4702702 commit d49ac8e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
9 changes: 7 additions & 2 deletions doas.1
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
.Nd execute commands as another user
.Sh SYNOPSIS
.Nm doas
.Op Fl ns
.Op Fl nSs
.Op Fl a Ar style
.Op Fl C Ar config
.Op Fl u Ar user
Expand All @@ -35,7 +35,8 @@ utility executes the given command as another user.
The
.Ar command
argument is mandatory unless
.Fl C
.Fl C ,
.Fl S ,
or
.Fl s
is specified.
Expand Down Expand Up @@ -72,6 +73,10 @@ No command is executed.
Non interactive mode, fail if
.Nm
would prompt for password.
.It Fl S
Same as
.Fl s
but simulates a full login.
.It Fl s
Execute the shell from
.Ev SHELL
Expand Down
11 changes: 9 additions & 2 deletions doas.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static struct pam_conv pamc = { pam_tty_conv, NULL };
static void
usage(void)
{
fprintf(stderr, "usage: doas [-ns] [-a style] [-C config] [-u user]"
fprintf(stderr, "usage: doas [-nSs] [-a style] [-C config] [-u user]"
" command [args]\n");
exit(1);
}
Expand Down Expand Up @@ -286,6 +286,7 @@ main(int argc, char **argv)
gid_t groups[NGROUPS_MAX + 1];
int ngroups;
int i, ch;
int Sflag = 0;
int sflag = 0;
int nflag = 0;
char cwdpath[PATH_MAX];
Expand All @@ -301,7 +302,7 @@ main(int argc, char **argv)

uid = getuid();

while ((ch = getopt(argc, argv, "a:C:nsu:")) != -1) {
while ((ch = getopt(argc, argv, "a:C:nSsu:")) != -1) {
switch (ch) {
#if defined(USE_BSD_AUTH)
case 'a':
Expand All @@ -324,6 +325,8 @@ main(int argc, char **argv)
case 'n':
nflag = 1;
break;
case 'S':
Sflag = 1;
case 's':
sflag = 1;
break;
Expand Down Expand Up @@ -393,6 +396,10 @@ main(int argc, char **argv)
errc(1, EPERM, NULL);
}

if (Sflag) {
argv[0] = "-doas";
}

if (!(rule->options & NOPASS)) {
if (nflag)
errx(1, "Authorization required");
Expand Down

0 comments on commit d49ac8e

Please sign in to comment.