]> git.armaanb.net Git - opendoas.git/commitdiff
cases should line up with switch, from Dimitris Papastamos
authorTed Unangst <tedu@openbsd.org>
Tue, 21 Jul 2015 16:12:04 +0000 (16:12 +0000)
committerTed Unangst <tedu@openbsd.org>
Tue, 21 Jul 2015 16:12:04 +0000 (16:12 +0000)
doas.1
doas.c
parse.y

diff --git a/doas.1 b/doas.1
index 351d5fd82462f333ab4fc6930a26bb8fbfaf1d6e..3e616198f0ce1e670250ef9f5b866075f9cd6f8a 100644 (file)
--- a/doas.1
+++ b/doas.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: doas.1,v 1.7 2015/07/19 17:00:22 jmc Exp $
+.\" $OpenBSD: doas.1,v 1.8 2015/07/21 11:04:06 zhuk Exp $
 .\"
 .\"Copyright (c) 2015 Ted Unangst <tedu@openbsd.org>
 .\"
@@ -13,7 +13,7 @@
 .\"WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 .\"ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 .\"OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-.Dd $Mdocdate: July 19 2015 $
+.Dd $Mdocdate: July 21 2015 $
 .Dt DOAS 1
 .Os
 .Sh NAME
@@ -21,6 +21,7 @@
 .Nd execute commands as another user
 .Sh SYNOPSIS
 .Nm doas
+.Op Fl C Ar config
 .Op Fl s
 .Op Fl u Ar user
 .Ar command
@@ -32,6 +33,11 @@ utility executes the given command as another user.
 .Pp
 The options are as follows:
 .Bl -tag -width tenletters
+.It Fl C Ar config
+Parse and check the configuration file
+.Ar config ,
+then exit.
+No command is executed.
 .It Fl s
 Execute the shell from
 .Ev SHELL
diff --git a/doas.c b/doas.c
index b77e17f6953eb88faa8bd69f95f5ac8fc7a3f35d..aa2136502969eba879946e9576be5544181a62fe 100644 (file)
--- a/doas.c
+++ b/doas.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: doas.c,v 1.14 2015/07/20 01:04:37 tedu Exp $ */
+/* $OpenBSD: doas.c,v 1.15 2015/07/21 11:04:06 zhuk Exp $ */
 /*
  * Copyright (c) 2015 Ted Unangst <tedu@openbsd.org>
  *
@@ -294,10 +294,12 @@ main(int argc, char **argv, char **envp)
        int i, ch;
        int sflag = 0;
 
-       parseconfig("/etc/doas.conf");
-
-       while ((ch = getopt(argc, argv, "su:")) != -1) {
+       while ((ch = getopt(argc, argv, "C:su:")) != -1) {
                switch (ch) {
+               case 'C':
+                       setuid(getuid());
+                       parseconfig(optarg);
+                       exit(0);
                case 'u':
                        if (parseuid(optarg, &target) != 0)
                                errx(1, "unknown user");
@@ -316,6 +318,8 @@ main(int argc, char **argv, char **envp)
        if ((!sflag && !argc) || (sflag && argc))
                usage();
 
+       parseconfig("/etc/doas.conf");
+
        uid = getuid();
        pw = getpwuid(uid);
        if (!pw)
diff --git a/parse.y b/parse.y
index 7dc18161183081a8091067f927f3b37baf66ec83..eabb939b5e9ec85441dcf26ae6d54e000eb07132 100644 (file)
--- a/parse.y
+++ b/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.6 2015/07/19 22:11:41 benno Exp $ */
+/* $OpenBSD: parse.y,v 1.7 2015/07/21 11:04:06 zhuk Exp $ */
 /*
  * Copyright (c) 2015 Ted Unangst <tedu@openbsd.org>
  *
@@ -198,27 +198,27 @@ yylex(void)
 repeat:
        c = getc(yyfp);
        switch (c) {
-               case ' ':
-               case '\t':
-                       goto repeat; /* skip spaces */
-               case '\\':
-                       next = getc(yyfp);
-                       if (next == '\n')
-                               goto repeat;
-                       else
-                               c = next;
-               case '\n':
-               case '{':
-               case '}':
-                       return c;
-               case '#':
-                       while ((c = getc(yyfp)) != '\n' && c != EOF)
-                               ; /* skip comments */
-                       if (c == EOF)
-                               return 0;
-                       return c;
-               case EOF:
+       case ' ':
+       case '\t':
+               goto repeat; /* skip spaces */
+       case '\\':
+               next = getc(yyfp);
+               if (next == '\n')
+                       goto repeat;
+               else
+                       c = next;
+       case '\n':
+       case '{':
+       case '}':
+               return c;
+       case '#':
+               while ((c = getc(yyfp)) != '\n' && c != EOF)
+                       ; /* skip comments */
+               if (c == EOF)
                        return 0;
+               return c;
+       case EOF:
+               return 0;
        }
        while (1) {
                switch (c) {