-/* $OpenBSD: doas.c,v 1.24 2015/07/26 19:14:46 tedu Exp $ */
+/* $OpenBSD: doas.c,v 1.26 2015/07/26 20:47:01 espie Exp $ */
/*
* Copyright (c) 2015 Ted Unangst <tedu@openbsd.org>
*
exit(1);
}
-static int
+static void __dead
checkconfig(const char *confpath, int argc, char **argv,
uid_t uid, gid_t *groups, int ngroups, uid_t target)
{
int ngroups;
int i, ch;
int sflag = 0;
+ int nflag = 0;
- while ((ch = getopt(argc, argv, "C:su:")) != -1) {
+ uid = getuid();
+ while ((ch = getopt(argc, argv, "C:nsu:")) != -1) {
switch (ch) {
case 'C':
confpath = optarg;
if (parseuid(optarg, &target) != 0)
errx(1, "unknown user");
break;
+ case 'n':
+ nflag = 1;
+ break;
case 's':
sflag = 1;
break;
}
if (!(rule->options & NOPASS)) {
+ if (nflag)
+ errx(1, "Authorization required");
if (!auth_userokay(myname, NULL, NULL, NULL)) {
syslog(LOG_AUTHPRIV | LOG_NOTICE,
"failed password for %s", myname);