2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-31 06:15:37 +00:00

Add support for multiple Debug lines per program. Callers may

register arbitrary debug facilities or use built-in defaults.  We
now use separate Debug statements for plugins and programs.
This commit is contained in:
Todd C. Miller
2014-10-22 13:23:05 -06:00
parent a7e724b75d
commit 866cfc4fc3
100 changed files with 1509 additions and 949 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 1998-2005, 2007-2013
* Copyright (c) 1996, 1998-2005, 2007-2014
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -101,6 +101,7 @@ extern int (*trace_print)(const char *msg);
*/
struct sudo_user sudo_user;
struct passwd *list_pw;
int sudoers_debug_instance = SUDO_DEBUG_INSTANCE_INITIALIZER;
static char *runas_group, *runas_user;
#if defined(SUDO_DEVEL) && defined(__OpenBSD__)
@@ -123,7 +124,7 @@ main(int argc, char *argv[])
const char *errstr;
int match, host_match, runas_match, cmnd_match;
int ch, dflag, exitcode = 0;
debug_decl(main, SUDO_DEBUG_MAIN)
debug_decl(main, SUDO_DEBUG_MAIN, sudoers_debug_instance)
#if defined(SUDO_DEVEL) && defined(__OpenBSD__)
malloc_options = "AFGJPR";
@@ -348,7 +349,7 @@ static void
set_runaspw(const char *user)
{
struct passwd *pw = NULL;
debug_decl(set_runaspw, SUDO_DEBUG_UTIL)
debug_decl(set_runaspw, SUDO_DEBUG_UTIL, sudoers_debug_instance)
if (*user == '#') {
const char *errstr;
@@ -372,7 +373,7 @@ static void
set_runasgr(const char *group)
{
struct group *gr = NULL;
debug_decl(set_runasgr, SUDO_DEBUG_UTIL)
debug_decl(set_runasgr, SUDO_DEBUG_UTIL, sudoers_debug_instance)
if (*group == '#') {
const char *errstr;
@@ -422,7 +423,7 @@ open_sudoers(const char *sudoers, bool doedit, bool *keepopen)
struct stat sb;
FILE *fp = NULL;
char *sudoers_base;
debug_decl(open_sudoers, SUDO_DEBUG_UTIL)
debug_decl(open_sudoers, SUDO_DEBUG_UTIL, sudoers_debug_instance)
sudoers_base = strrchr(sudoers, '/');
if (sudoers_base != NULL)
@@ -479,7 +480,7 @@ void
print_member(struct member *m)
{
struct sudo_command *c;
debug_decl(print_member, SUDO_DEBUG_UTIL)
debug_decl(print_member, SUDO_DEBUG_UTIL, sudoers_debug_instance)
if (m->negated)
putchar('!');
@@ -501,7 +502,7 @@ print_defaults(void)
{
struct defaults *d;
struct member *m;
debug_decl(print_defaults, SUDO_DEBUG_UTIL)
debug_decl(print_defaults, SUDO_DEBUG_UTIL, sudoers_debug_instance)
TAILQ_FOREACH(d, &defaults, entries) {
(void) fputs("Defaults", stdout);
@@ -540,7 +541,7 @@ print_alias(void *v1, void *v2)
struct alias *a = (struct alias *)v1;
struct member *m;
struct sudo_command *c;
debug_decl(print_alias, SUDO_DEBUG_UTIL)
debug_decl(print_alias, SUDO_DEBUG_UTIL, sudoers_debug_instance)
switch (a->type) {
case HOSTALIAS:
@@ -579,7 +580,7 @@ print_privilege(struct privilege *priv)
struct cmndspec *cs;
struct member *m;
struct cmndtag tags;
debug_decl(print_privilege, SUDO_DEBUG_UTIL)
debug_decl(print_privilege, SUDO_DEBUG_UTIL, sudoers_debug_instance)
TAILQ_FOREACH(m, &priv->hostlist, entries) {
if (m != TAILQ_FIRST(&priv->hostlist))
@@ -643,7 +644,7 @@ print_userspecs(void)
struct member *m;
struct userspec *us;
struct privilege *priv;
debug_decl(print_userspecs, SUDO_DEBUG_UTIL)
debug_decl(print_userspecs, SUDO_DEBUG_UTIL, sudoers_debug_instance)
TAILQ_FOREACH(us, &userspecs, entries) {
TAILQ_FOREACH(m, &us->users, entries) {
@@ -665,7 +666,7 @@ print_userspecs(void)
void
dump_sudoers(void)
{
debug_decl(dump_sudoers, SUDO_DEBUG_UTIL)
debug_decl(dump_sudoers, SUDO_DEBUG_UTIL, sudoers_debug_instance)
print_defaults();