version 1.1.1.5, 2013/10/14 07:56:35
|
version 1.1.1.6, 2014/06/15 16:12:54
|
Line 69 sudo_read_nss(void)
|
Line 69 sudo_read_nss(void)
|
bool saw_files = false; |
bool saw_files = false; |
bool saw_ldap = false; |
bool saw_ldap = false; |
bool got_match = false; |
bool got_match = false; |
static struct sudo_nss_list snl; | static struct sudo_nss_list snl = TAILQ_HEAD_INITIALIZER(snl); |
debug_decl(sudo_read_nss, SUDO_DEBUG_NSS) |
debug_decl(sudo_read_nss, SUDO_DEBUG_NSS) |
|
|
if ((fp = fopen(_PATH_NSSWITCH_CONF, "r")) == NULL) |
if ((fp = fopen(_PATH_NSSWITCH_CONF, "r")) == NULL) |
Line 87 sudo_read_nss(void)
|
Line 87 sudo_read_nss(void)
|
/* Parse line */ |
/* Parse line */ |
for ((cp = strtok(line + 8, " \t")); cp != NULL; (cp = strtok(NULL, " \t"))) { |
for ((cp = strtok(line + 8, " \t")); cp != NULL; (cp = strtok(NULL, " \t"))) { |
if (strcasecmp(cp, "files") == 0 && !saw_files) { |
if (strcasecmp(cp, "files") == 0 && !saw_files) { |
tq_append(&snl, &sudo_nss_file); | TAILQ_INSERT_TAIL(&snl, &sudo_nss_file, entries); |
got_match = true; |
got_match = true; |
#ifdef HAVE_LDAP |
#ifdef HAVE_LDAP |
} else if (strcasecmp(cp, "ldap") == 0 && !saw_ldap) { |
} else if (strcasecmp(cp, "ldap") == 0 && !saw_ldap) { |
tq_append(&snl, &sudo_nss_ldap); | TAILQ_INSERT_TAIL(&snl, &sudo_nss_ldap, entries); |
got_match = true; |
got_match = true; |
#endif |
#endif |
#ifdef HAVE_SSSD |
#ifdef HAVE_SSSD |
} else if (strcasecmp(cp, "sss") == 0 && !saw_sss) { |
} else if (strcasecmp(cp, "sss") == 0 && !saw_sss) { |
tq_append(&snl, &sudo_nss_sss); | TAILQ_INSERT_TAIL(&snl, &sudo_nss_sss, entries); |
got_match = true; |
got_match = true; |
#endif |
#endif |
} else if (strcasecmp(cp, "[NOTFOUND=return]") == 0 && got_match) { |
} else if (strcasecmp(cp, "[NOTFOUND=return]") == 0 && got_match) { |
/* NOTFOUND affects the most recent entry */ |
/* NOTFOUND affects the most recent entry */ |
tq_last(&snl)->ret_if_notfound = true; | TAILQ_LAST(&snl, sudo_nss_list)->ret_if_notfound = true; |
got_match = false; |
got_match = false; |
} else if (strcasecmp(cp, "[SUCCESS=return]") == 0 && got_match) { |
} else if (strcasecmp(cp, "[SUCCESS=return]") == 0 && got_match) { |
/* SUCCESS affects the most recent entry */ |
/* SUCCESS affects the most recent entry */ |
tq_last(&snl)->ret_if_found = true; | TAILQ_LAST(&snl, sudo_nss_list)->ret_if_found = true; |
got_match = false; |
got_match = false; |
} else |
} else |
got_match = false; |
got_match = false; |
Line 118 sudo_read_nss(void)
|
Line 118 sudo_read_nss(void)
|
|
|
nomatch: |
nomatch: |
/* Default to files only if no matches */ |
/* Default to files only if no matches */ |
if (tq_empty(&snl)) | if (TAILQ_EMPTY(&snl)) |
tq_append(&snl, &sudo_nss_file); | TAILQ_INSERT_TAIL(&snl, &sudo_nss_file, entries); |
|
|
debug_return_ptr(&snl); |
debug_return_ptr(&snl); |
} |
} |
Line 137 sudo_read_nss(void)
|
Line 137 sudo_read_nss(void)
|
{ |
{ |
FILE *fp; |
FILE *fp; |
char *cp, *ep, *line = NULL; |
char *cp, *ep, *line = NULL; |
ssize_t linesize = 0; | size_t linesize = 0; |
#ifdef HAVE_SSSD |
#ifdef HAVE_SSSD |
bool saw_sss = false; |
bool saw_sss = false; |
#endif |
#endif |
bool saw_files = false; |
bool saw_files = false; |
bool saw_ldap = false; |
bool saw_ldap = false; |
bool got_match = false; |
bool got_match = false; |
static struct sudo_nss_list snl; | static struct sudo_nss_list snl = TAILQ_HEAD_INITIALIZER(snl); |
debug_decl(sudo_read_nss, SUDO_DEBUG_NSS) |
debug_decl(sudo_read_nss, SUDO_DEBUG_NSS) |
|
|
if ((fp = fopen(_PATH_NETSVC_CONF, "r")) == NULL) |
if ((fp = fopen(_PATH_NETSVC_CONF, "r")) == NULL) |
Line 172 sudo_read_nss(void)
|
Line 172 sudo_read_nss(void)
|
|
|
if (!saw_files && strncasecmp(cp, "files", 5) == 0 && |
if (!saw_files && strncasecmp(cp, "files", 5) == 0 && |
(isspace((unsigned char)cp[5]) || cp[5] == '\0')) { |
(isspace((unsigned char)cp[5]) || cp[5] == '\0')) { |
tq_append(&snl, &sudo_nss_file); | TAILQ_INSERT_TAIL(&snl, &sudo_nss_file, entries); |
got_match = true; |
got_match = true; |
ep = &cp[5]; |
ep = &cp[5]; |
#ifdef HAVE_LDAP |
#ifdef HAVE_LDAP |
} else if (!saw_ldap && strncasecmp(cp, "ldap", 4) == 0 && |
} else if (!saw_ldap && strncasecmp(cp, "ldap", 4) == 0 && |
(isspace((unsigned char)cp[4]) || cp[4] == '\0')) { |
(isspace((unsigned char)cp[4]) || cp[4] == '\0')) { |
tq_append(&snl, &sudo_nss_ldap); | TAILQ_INSERT_TAIL(&snl, &sudo_nss_ldap, entries); |
got_match = true; |
got_match = true; |
ep = &cp[4]; |
ep = &cp[4]; |
#endif |
#endif |
#ifdef HAVE_SSSD |
#ifdef HAVE_SSSD |
} else if (!saw_sss && strncasecmp(cp, "sss", 3) == 0 && |
} else if (!saw_sss && strncasecmp(cp, "sss", 3) == 0 && |
(isspace((unsigned char)cp[3]) || cp[3] == '\0')) { |
(isspace((unsigned char)cp[3]) || cp[3] == '\0')) { |
tq_append(&snl, &sudo_nss_sss); | TAILQ_INSERT_TAIL(&snl, &sudo_nss_sss, entries); |
got_match = true; |
got_match = true; |
ep = &cp[3]; |
ep = &cp[3]; |
#endif |
#endif |
Line 200 sudo_read_nss(void)
|
Line 200 sudo_read_nss(void)
|
cp++; |
cp++; |
if (strncasecmp(cp, "auth", 4) == 0 && |
if (strncasecmp(cp, "auth", 4) == 0 && |
(isspace((unsigned char)cp[4]) || cp[4] == '\0')) { |
(isspace((unsigned char)cp[4]) || cp[4] == '\0')) { |
tq_last(&snl)->ret_if_found = true; | TAILQ_LAST(&snl, sudo_nss_list)->ret_if_found = true; |
} |
} |
} |
} |
} |
} |
Line 211 sudo_read_nss(void)
|
Line 211 sudo_read_nss(void)
|
|
|
nomatch: |
nomatch: |
/* Default to files only if no matches */ |
/* Default to files only if no matches */ |
if (tq_empty(&snl)) | if (TAILQ_EMPTY(&snl)) |
tq_append(&snl, &sudo_nss_file); | TAILQ_INSERT_TAIL(&snl, &sudo_nss_file, entries); |
|
|
debug_return_ptr(&snl); |
debug_return_ptr(&snl); |
} |
} |
Line 225 nomatch:
|
Line 225 nomatch:
|
struct sudo_nss_list * |
struct sudo_nss_list * |
sudo_read_nss(void) |
sudo_read_nss(void) |
{ |
{ |
static struct sudo_nss_list snl; | static struct sudo_nss_list snl = TAILQ_HEAD_INITIALIZER(snl); |
debug_decl(sudo_read_nss, SUDO_DEBUG_NSS) |
debug_decl(sudo_read_nss, SUDO_DEBUG_NSS) |
|
|
# ifdef HAVE_SSSD |
# ifdef HAVE_SSSD |
tq_append(&snl, &sudo_nss_sss); | TAILQ_INSERT_TAIL(&snl, &sudo_nss_sss, entries); |
# endif |
# endif |
# ifdef HAVE_LDAP |
# ifdef HAVE_LDAP |
tq_append(&snl, &sudo_nss_ldap); | TAILQ_INSERT_TAIL(&snl, &sudo_nss_ldap, entries); |
# endif |
# endif |
tq_append(&snl, &sudo_nss_file); | TAILQ_INSERT_TAIL(&snl, &sudo_nss_file, entries); |
|
|
debug_return_ptr(&snl); |
debug_return_ptr(&snl); |
} |
} |
Line 283 display_privs(struct sudo_nss_list *snl, struct passwd
|
Line 283 display_privs(struct sudo_nss_list *snl, struct passwd
|
lbuf_append(&defs, _("Matching Defaults entries for %s on %s:\n"), |
lbuf_append(&defs, _("Matching Defaults entries for %s on %s:\n"), |
pw->pw_name, user_srunhost); |
pw->pw_name, user_srunhost); |
count = 0; |
count = 0; |
tq_foreach_fwd(snl, nss) { | TAILQ_FOREACH(nss, snl, entries) { |
count += nss->display_defaults(nss, pw, &defs); |
count += nss->display_defaults(nss, pw, &defs); |
} |
} |
if (count) |
if (count) |
Line 296 display_privs(struct sudo_nss_list *snl, struct passwd
|
Line 296 display_privs(struct sudo_nss_list *snl, struct passwd
|
lbuf_append(&defs, _("Runas and Command-specific defaults for %s:\n"), |
lbuf_append(&defs, _("Runas and Command-specific defaults for %s:\n"), |
pw->pw_name); |
pw->pw_name); |
count = 0; |
count = 0; |
tq_foreach_fwd(snl, nss) { | TAILQ_FOREACH(nss, snl, entries) { |
count += nss->display_bound_defaults(nss, pw, &defs); |
count += nss->display_bound_defaults(nss, pw, &defs); |
} |
} |
if (count) |
if (count) |
Line 309 display_privs(struct sudo_nss_list *snl, struct passwd
|
Line 309 display_privs(struct sudo_nss_list *snl, struct passwd
|
_("User %s may run the following commands on %s:\n"), |
_("User %s may run the following commands on %s:\n"), |
pw->pw_name, user_srunhost); |
pw->pw_name, user_srunhost); |
count = 0; |
count = 0; |
tq_foreach_fwd(snl, nss) { | TAILQ_FOREACH(nss, snl, entries) { |
count += nss->display_privs(nss, pw, &privs); |
count += nss->display_privs(nss, pw, &privs); |
} |
} |
if (count == 0) { |
if (count == 0) { |
Line 338 display_cmnd(struct sudo_nss_list *snl, struct passwd
|
Line 338 display_cmnd(struct sudo_nss_list *snl, struct passwd
|
struct sudo_nss *nss; |
struct sudo_nss *nss; |
debug_decl(display_cmnd, SUDO_DEBUG_NSS) |
debug_decl(display_cmnd, SUDO_DEBUG_NSS) |
|
|
tq_foreach_fwd(snl, nss) { | TAILQ_FOREACH(nss, snl, entries) { |
if (nss->display_cmnd(nss, pw) == 0) |
if (nss->display_cmnd(nss, pw) == 0) |
debug_return_bool(true); |
debug_return_bool(true); |
} |
} |