/*
- * Copyright (c) 2004-2005, 2007-2011 Todd C. Miller <Todd.Miller@courtesan.com>
+ * Copyright (c) 2004-2005, 2007-2012 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
*/
extern FILE *yyin;
extern char *errorfile;
-extern int errorlineno, parse_error;
+extern int errorlineno;
+extern bool parse_error;
/*
* Local prototypes.
int
sudo_file_open(struct sudo_nss *nss)
{
+ debug_decl(sudo_file_open, SUDO_DEBUG_NSS)
+
if (def_ignore_local_sudoers)
- return -1;
- nss->handle = open_sudoers(sudoers_file, FALSE, NULL);
- return nss->handle ? 0 : -1;
+ debug_return_int(-1);
+ nss->handle = open_sudoers(sudoers_file, false, NULL);
+ debug_return_int(nss->handle ? 0 : -1);
}
int
sudo_file_close(struct sudo_nss *nss)
{
+ debug_decl(sudo_file_close, SUDO_DEBUG_NSS)
+
/* Free parser data structures and close sudoers file. */
init_parser(NULL, 0);
if (nss->handle != NULL) {
nss->handle = NULL;
yyin = NULL;
}
- return 0;
+ debug_return_int(0);
}
/*
int
sudo_file_parse(struct sudo_nss *nss)
{
+ debug_decl(sudo_file_close, SUDO_DEBUG_NSS)
+
if (nss->handle == NULL)
- return -1;
+ debug_return_int(-1);
init_parser(sudoers_file, 0);
yyin = nss->handle;
if (yyparse() != 0 || parse_error) {
- log_error(NO_EXIT, _("parse error in %s near line %d"),
- errorfile, errorlineno);
- return -1;
+ if (errorlineno != -1) {
+ log_error(NO_EXIT, _("parse error in %s near line %d"),
+ errorfile, errorlineno);
+ } else {
+ log_error(NO_EXIT, _("parse error in %s"), errorfile);
+ }
+ debug_return_int(-1);
}
- return 0;
+ debug_return_int(0);
}
/*
int
sudo_file_setdefs(struct sudo_nss *nss)
{
+ debug_decl(sudo_file_setdefs, SUDO_DEBUG_NSS)
+
if (nss->handle == NULL)
- return -1;
+ debug_return_int(-1);
if (!update_defaults(SETDEF_GENERIC|SETDEF_HOST|SETDEF_USER))
- return -1;
- return 0;
+ debug_return_int(-1);
+ debug_return_int(0);
}
/*
struct cmndtag *tags = NULL;
struct privilege *priv;
struct userspec *us;
+ debug_decl(sudo_file_lookup, SUDO_DEBUG_NSS)
if (nss->handle == NULL)
- return validated;
+ debug_return_int(validated);
/*
* Only check the actual command if pwflag is not set.
enum def_tuple pwcheck;
pwcheck = (pwflag == -1) ? never : sudo_defs_table[pwflag].sd_un.tuple;
- nopass = (pwcheck == all) ? TRUE : FALSE;
+ nopass = (pwcheck == all) ? true : false;
if (list_pw == NULL)
SET(validated, FLAG_NO_CHECK);
user_uid == list_pw->pw_uid ||
cmnd_matches(cs->cmnd) == ALLOW)
match = ALLOW;
- if ((pwcheck == any && cs->tags.nopasswd == TRUE) ||
- (pwcheck == all && cs->tags.nopasswd != TRUE))
+ if ((pwcheck == any && cs->tags.nopasswd == true) ||
+ (pwcheck == all && cs->tags.nopasswd != true))
nopass = cs->tags.nopasswd;
}
}
SET(validated, VALIDATE_NOT_OK);
if (pwcheck == always && def_authenticate)
SET(validated, FLAG_CHECK_USER);
- else if (pwcheck == never || nopass == TRUE)
- def_authenticate = FALSE;
- return validated;
+ else if (pwcheck == never || nopass == true)
+ def_authenticate = false;
+ debug_return_int(validated);
}
/* Need to be runas user while stat'ing things. */
def_authenticate = !tags->nopasswd;
}
restore_perms();
- return validated;
+ debug_return_int(validated);
}
#define TAG_CHANGED(t) \
struct lbuf *lbuf)
{
struct member *m;
+ debug_decl(sudo_file_append_cmnd, SUDO_DEBUG_NSS)
#ifdef HAVE_SELINUX
if (cs->role)
m = cs->cmnd;
print_member(lbuf, m->name, m->type, m->negated,
CMNDALIAS);
+ debug_return;
}
static int
struct privilege *priv;
struct cmndtag tags;
int nfound = 0;
+ debug_decl(sudo_file_display_priv_short, SUDO_DEBUG_NSS)
tq_foreach_fwd(&us->privileges, priv) {
if (hostlist_matches(&priv->hostlist) != ALLOW)
}
lbuf_append(lbuf, "\n");
}
- return nfound;
+ debug_return_int(nfound);
}
static int
struct privilege *priv;
struct cmndtag tags;
int nfound = 0;
+ debug_decl(sudo_file_display_priv_long, SUDO_DEBUG_NSS)
tq_foreach_fwd(&us->privileges, priv) {
if (hostlist_matches(&priv->hostlist) != ALLOW)
nfound++;
}
}
- return nfound;
+ debug_return_int(nfound);
}
int
{
struct userspec *us;
int nfound = 0;
+ debug_decl(sudo_file_display_priv, SUDO_DEBUG_NSS)
if (nss->handle == NULL)
goto done;
nfound += sudo_file_display_priv_short(pw, us, lbuf);
}
done:
- return nfound;
+ debug_return_int(nfound);
}
/*
struct defaults *d;
char *prefix;
int nfound = 0;
+ debug_decl(sudo_file_display_defaults, SUDO_DEBUG_NSS)
if (nss->handle == NULL)
goto done;
lbuf_append_quoted(lbuf, SUDOERS_QUOTED, "%s", d->val);
} else
lbuf_append(lbuf, "%s%s%s", prefix,
- d->op == FALSE ? "!" : "", d->var);
+ d->op == false ? "!" : "", d->var);
prefix = ", ";
nfound++;
}
done:
- return nfound;
+ debug_return_int(nfound);
}
/*
struct lbuf *lbuf)
{
int nfound = 0;
+ debug_decl(sudo_file_display_bound_defaults, SUDO_DEBUG_NSS)
/* XXX - should only print ones that match what the user can do. */
nfound += display_bound_defaults(DEFAULTS_RUNAS, lbuf);
nfound += display_bound_defaults(DEFAULTS_CMND, lbuf);
- return nfound;
+ debug_return_int(nfound);
}
/*
struct member *m, *binding = NULL;
char *dsep;
int atype, nfound = 0;
+ debug_decl(display_bound_defaults, SUDO_DEBUG_NSS)
switch (dtype) {
case DEFAULTS_HOST:
dsep = "!";
break;
default:
- return -1;
+ debug_return_int(-1);
}
tq_foreach_fwd(&defaults, d) {
if (d->type != dtype)
lbuf_append(lbuf, "%s%s%s", d->var, d->op == '+' ? "+=" :
d->op == '-' ? "-=" : "=", d->val);
} else
- lbuf_append(lbuf, "%s%s", d->op == FALSE ? "!" : "", d->var);
+ lbuf_append(lbuf, "%s%s", d->op == false ? "!" : "", d->var);
}
- return nfound;
+ debug_return_int(nfound);
}
int
struct userspec *us;
int rval = 1;
int host_match, runas_match, cmnd_match;
+ debug_decl(sudo_file_display_cmnd, SUDO_DEBUG_NSS)
if (nss->handle == NULL)
goto done;
rval = 0;
}
done:
- return rval;
+ debug_return_int(rval);
}
/*
struct alias *a;
struct member *m;
struct sudo_command *c;
+ debug_decl(_print_member, SUDO_DEBUG_NSS)
switch (type) {
case ALL:
lbuf_append(lbuf, "%s%s", negated ? "!" : "", name);
break;
}
+ debug_return;
}
static void