-.\" $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>
.\"
.\"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
.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
.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
-/* $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>
*
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");
if ((!sflag && !argc) || (sflag && argc))
usage();
+ parseconfig("/etc/doas.conf");
+
uid = getuid();
pw = getpwuid(uid);
if (!pw)
-/* $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>
*
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) {