if (matched == true || user_uid == 0) {
SET(ret, VALIDATE_SUCCESS);
CLR(ret, VALIDATE_FAILURE);
- if (def_authenticate) {
- switch (pwcheck) {
- case always:
- SET(ret, FLAG_CHECK_USER);
- break;
- case all:
- case any:
- if (doauth == false)
- def_authenticate = false;
- break;
- case never:
- def_authenticate = false;
- break;
- default:
- break;
- }
+ switch (pwcheck) {
+ case always:
+ SET(ret, FLAG_CHECK_USER);
+ break;
+ case all:
+ case any:
+ if (doauth == false)
+ SET(ret, FLAG_NOPASSWD);
+ break;
+ default:
+ break;
}
}
goto done;
SET(validated, VALIDATE_FAILURE);
if (pwcheck == always && def_authenticate)
SET(validated, FLAG_CHECK_USER);
- else if (pwcheck == never || nopass == true)
- def_authenticate = false;
+ else if (nopass == true)
+ SET(validated, FLAG_NOPASSWD);
debug_return_int(validated);
}
if (matched == true || user_uid == 0) {
SET(ret, VALIDATE_SUCCESS);
CLR(ret, VALIDATE_FAILURE);
- if (def_authenticate) {
- switch (pwcheck) {
- case always:
- SET(ret, FLAG_CHECK_USER);
- break;
- case all:
- case any:
- if (doauth == false)
- def_authenticate = false;
- break;
- case never:
- def_authenticate = false;
- break;
- default:
- break;
- }
+ switch (pwcheck) {
+ case always:
+ SET(ret, FLAG_CHECK_USER);
+ break;
+ case all:
+ case any:
+ if (doauth == false)
+ SET(ret, FLAG_NOPASSWD);
+ break;
+ default:
+ break;
}
}
goto done;
/*
- * Copyright (c) 1993-1996, 1998-2015 Todd C. Miller <Todd.Miller@courtesan.com>
+ * Copyright (c) 1993-1996, 1998-2016 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
char *iolog_path = NULL;
mode_t cmnd_umask = 0777;
struct sudo_nss *nss;
+ bool nopass = false;
int cmnd_status = -1, oldlocale, validated;
int rval = -1;
debug_decl(sudoers_policy_main, SUDOERS_DEBUG_PLUGIN)
TAILQ_FOREACH(nss, snl, entries) {
validated = nss->lookup(nss, validated, pwflag);
+ /*
+ * The NOPASSWD tag needs special handling among all sources
+ * in -l or -v mode.
+ */
+ if (pwflag) {
+ enum def_tuple pwcheck =
+ (pwflag == -1) ? never : sudo_defs_table[pwflag].sd_un.tuple;
+ switch (pwcheck) {
+ case all:
+ if (!ISSET(validated, FLAG_NOPASSWD))
+ nopass = false;
+ break;
+ case any:
+ if (ISSET(validated, FLAG_NOPASSWD))
+ nopass = true;
+ break;
+ case never:
+ nopass = true;
+ break;
+ case always:
+ nopass = false;
+ break;
+ default:
+ break;
+ }
+ }
+
if (ISSET(validated, VALIDATE_ERROR)) {
/* The lookup function should have printed an error. */
goto done;
break;
}
}
+ if (pwflag && nopass)
+ def_authenticate = false;
/* Restore user's locale. */
sudoers_setlocale(oldlocale, NULL);
#define FLAG_NON_INTERACTIVE 0x100
#define FLAG_BAD_PASSWORD 0x200
#define FLAG_AUTH_ERROR 0x400
+#define FLAG_NOPASSWD 0x800
/*
* find_path()/set_cmnd() return values