Go back to a 2 args debug_decl and just use the "default" instance,

now renamed "active".
This commit is contained in:
Todd C. Miller
2015-02-01 08:24:49 -07:00
parent e71726d0f9
commit 59ab26dbcc
95 changed files with 843 additions and 895 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2011-2015 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
@@ -46,12 +46,11 @@ struct sudo_debug_file {
struct sudo_conf_debug_file_list;
/*
* The priority, instance and subsystem are encoded in a single 32-bit value.
* The first byte holds the priority and flags:
* nybble one is priority, nybble two is flags (errno or lineno).
* The second byte is for the instance index (way more than we need).
* The upper two bytes are the subsystem.
* This allows for 16 priorities, 3 flags, 256 instances, 65535 subsystems.
* The priority and subsystem are encoded in a single 32-bit value.
* The lower 4 bits are the priority and the top 26 bits are the subsystem.
* This allows for 16 priorities and a very large number of subsystems.
* Bit 5 is used as a flag to specify whether to log the errno value.
* Bit 6 specifies whether to log the function, file and line number data.
*/
/*
@@ -79,49 +78,42 @@ struct sudo_conf_debug_file_list;
* This includes subsystems in the sudoers plugin.
* Note: order must match sudo_debug_subsystems[]
*/
#define SUDO_DEBUG_ARGS ( 1<<16) /* command line argument processing */
#define SUDO_DEBUG_CONV ( 2<<16) /* user conversation */
#define SUDO_DEBUG_EDIT ( 3<<16) /* sudoedit */
#define SUDO_DEBUG_EVENT ( 4<<16) /* event handling */
#define SUDO_DEBUG_EXEC ( 5<<16) /* command execution */
#define SUDO_DEBUG_HOOKS ( 6<<16) /* hook functions */
#define SUDO_DEBUG_MAIN ( 7<<16) /* sudo main() */
#define SUDO_DEBUG_NETIF ( 8<<16) /* network interface functions */
#define SUDO_DEBUG_PCOMM ( 9<<16) /* plugin communications */
#define SUDO_DEBUG_PLUGIN (10<<16) /* main plugin functions */
#define SUDO_DEBUG_PTY (11<<16) /* pseudo-tty */
#define SUDO_DEBUG_SELINUX (12<<16) /* selinux */
#define SUDO_DEBUG_UTIL (13<<16) /* utility functions */
#define SUDO_DEBUG_UTMP (14<<16) /* utmp file ops */
#define SUDO_DEBUG_ARGS ( 1<<6) /* command line argument handling */
#define SUDO_DEBUG_CONV ( 2<<6) /* user conversation */
#define SUDO_DEBUG_EDIT ( 3<<6) /* sudoedit */
#define SUDO_DEBUG_EVENT ( 4<<6) /* event handling */
#define SUDO_DEBUG_EXEC ( 5<<6) /* command execution */
#define SUDO_DEBUG_HOOKS ( 6<<6) /* hook functions */
#define SUDO_DEBUG_MAIN ( 7<<6) /* sudo main() */
#define SUDO_DEBUG_NETIF ( 8<<6) /* network interface functions */
#define SUDO_DEBUG_PCOMM ( 9<<6) /* plugin communications */
#define SUDO_DEBUG_PLUGIN (10<<6) /* main plugin functions */
#define SUDO_DEBUG_PTY (11<<6) /* pseudo-tty */
#define SUDO_DEBUG_SELINUX (12<<6) /* selinux */
#define SUDO_DEBUG_UTIL (13<<6) /* utility functions */
#define SUDO_DEBUG_UTMP (14<<6) /* utmp file ops */
#define SUDO_DEBUG_ALL 0xffff0000 /* all subsystems */
/* Initializer for instance index to indicate that debugging is not setup. */
#define SUDO_DEBUG_INSTANCE_INITIALIZER SUDO_DEBUG_MKINSTANCE(-1)
/* The 'default' instance logs to the currently selected debug instance. */
#define SUDO_DEBUG_INSTANCE_DEFAULT SUDO_DEBUG_MKINSTANCE(-2)
#define SUDO_DEBUG_INSTANCE_INITIALIZER -1
/* Extract priority number and convert to an index. */
#define SUDO_DEBUG_PRI(n) (((n) & 0x0f) - 1)
/* Extract instance number and convert to an index. */
#define SUDO_DEBUG_INSTANCE(n) ((((n) & 0xff00) >> 8) - 2)
#define SUDO_DEBUG_MKINSTANCE(n) (((n) + 2) << 8)
/* Extract subsystem number and convert to an index. */
#define SUDO_DEBUG_SUBSYS(n) (((n) >> 16) - 1)
#define SUDO_DEBUG_SUBSYS(n) (((n) >> 6) - 1)
/*
* Wrapper for sudo_debug_enter() that declares __func__ as needed
* and sets sudo_debug_subsys for sudo_debug_exit().
*/
#ifdef HAVE___FUNC__
# define debug_decl(funcname, subsys, instance) \
const int sudo_debug_subsys = (subsys)|(instance); \
# define debug_decl(funcname, subsys) \
const int sudo_debug_subsys = (subsys); \
sudo_debug_enter(__func__, __FILE__, __LINE__, sudo_debug_subsys);
#else
# define debug_decl(funcname, subsys, instance) \
const int sudo_debug_subsys = (subsys)|(instance); \
# define debug_decl(funcname, subsys) \
const int sudo_debug_subsys = (subsys); \
const char __func__[] = #funcname; \
sudo_debug_enter(__func__, __FILE__, __LINE__, sudo_debug_subsys);
#endif
@@ -241,13 +233,13 @@ __dso_public void sudo_debug_exit_size_t_v1(const char *func, const char *file,
__dso_public void sudo_debug_exit_str_v1(const char *func, const char *file, int line, int subsys, const char *rval);
__dso_public void sudo_debug_exit_str_masked_v1(const char *func, const char *file, int line, int subsys, const char *rval);
__dso_public pid_t sudo_debug_fork_v1(void);
__dso_public int sudo_debug_get_default_instance_v1(void);
__dso_public int sudo_debug_get_active_instance_v1(void);
__dso_public int sudo_debug_get_fds_v1(unsigned char **fds);
__dso_public int sudo_debug_get_instance_v1(const char *program);
__dso_public void sudo_debug_printf2_v1(const char *func, const char *file, int line, int level, const char *fmt, ...) __printf0like(5, 6);
__dso_public void sudo_debug_printf_nvm_v1(int pri, const char *fmt, ...) __printf0like(2, 3);
__dso_public int sudo_debug_register_v1(const char *program, const char *const subsystems[], unsigned int ids[], struct sudo_conf_debug_file_list *debug_files);
__dso_public int sudo_debug_set_default_instance_v1(int inst);
__dso_public int sudo_debug_set_active_instance_v1(int inst);
__dso_public void sudo_debug_update_fd_v1(int ofd, int nfd);
__dso_public void sudo_debug_vprintf2_v1(const char *func, const char *file, int line, int level, const char *fmt, va_list ap) __printf0like(5, 0);
__dso_public void sudo_debug_write2_v1(int fd, const char *func, const char *file, int line, const char *str, int len, int errnum);
@@ -264,13 +256,13 @@ __dso_public void sudo_debug_write2_v1(int fd, const char *func, const char *fil
#define sudo_debug_exit_str(_a, _b, _c, _d, _e) sudo_debug_exit_str_v1((_a), (_b), (_c), (_d), (_e))
#define sudo_debug_exit_str_masked(_a, _b, _c, _d, _e) sudo_debug_exit_str_masked_v1((_a), (_b), (_c), (_d), (_e))
#define sudo_debug_fork() sudo_debug_fork_v1()
#define sudo_debug_get_default_instance() sudo_debug_get_default_instance_v1()
#define sudo_debug_get_active_instance() sudo_debug_get_active_instance_v1()
#define sudo_debug_get_fds(_a) sudo_debug_get_fds_v1((_a))
#define sudo_debug_get_instance(_a) sudo_debug_get_instance_v1((_a))
#define sudo_debug_printf2 sudo_debug_printf2_v1
#define sudo_debug_printf_nvm sudo_debug_printf_nvm_v1
#define sudo_debug_register(_a, _b, _c, _d) sudo_debug_register_v1((_a), (_b), (_c), (_d))
#define sudo_debug_set_default_instance(_a) sudo_debug_set_default_instance_v1((_a))
#define sudo_debug_set_active_instance(_a) sudo_debug_set_active_instance_v1((_a))
#define sudo_debug_update_fd(_a, _b) sudo_debug_update_fd_v1((_a), (_b))
#define sudo_debug_vprintf2(_a, _b, _c, _d, _e, _f) sudo_debug_vprintf2_v1((_a), (_b), (_c), (_d), (_e), (_f))
#define sudo_debug_write2(_a, _b, _c, _d, _e, _f, _g) sudo_debug_write2_v1((_a), (_b), (_c), (_d), (_e), (_f), (_g))

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2010-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2008, 2010-2015 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
@@ -73,7 +73,7 @@ static struct aix_limit aix_limits[] = {
static int
aix_getlimit(char *user, char *lim, int *valp)
{
debug_decl(aix_getlimit, SUDO_DEBUG_UTIL, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(aix_getlimit, SUDO_DEBUG_UTIL)
if (getuserattr(user, lim, valp, SEC_INT) != 0)
debug_return_int(-1);
@@ -86,7 +86,7 @@ aix_setlimits(char *user)
struct rlimit64 rlim;
int val;
size_t n;
debug_decl(aix_setlimits, SUDO_DEBUG_UTIL, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(aix_setlimits, SUDO_DEBUG_UTIL)
if (setuserdb(S_READ) != 0) {
sudo_warn(U_("unable to open userdb"));
@@ -144,7 +144,7 @@ int
aix_setauthdb_v1(char *user)
{
char *registry;
debug_decl(aix_setauthdb, SUDO_DEBUG_UTIL, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(aix_setauthdb, SUDO_DEBUG_UTIL)
if (user != NULL) {
if (setuserdb(S_READ) != 0) {
@@ -169,7 +169,7 @@ aix_setauthdb_v1(char *user)
int
aix_restoreauthdb_v1(void)
{
debug_decl(aix_setauthdb, SUDO_DEBUG_UTIL, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(aix_setauthdb, SUDO_DEBUG_UTIL)
if (setauthdb(NULL, NULL) != 0) {
sudo_warn(U_("unable to restore registry"));
@@ -184,7 +184,7 @@ aix_prep_user_v1(char *user, const char *tty)
{
char *info;
int len;
debug_decl(aix_setauthdb, SUDO_DEBUG_UTIL, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(aix_setauthdb, SUDO_DEBUG_UTIL)
/* set usrinfo, like login(1) does */
len = sudo_easprintf(&info, "NAME=%s%cLOGIN=%s%cLOGNAME=%s%cTTY=%s%c",

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2013-2015 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
@@ -88,7 +88,7 @@ struct sudo_event_base *
sudo_ev_base_alloc_v1(void)
{
struct sudo_event_base *base;
debug_decl(sudo_ev_base_alloc, SUDO_DEBUG_EVENT, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_ev_base_alloc, SUDO_DEBUG_EVENT)
base = sudo_ecalloc(1, sizeof(*base));
TAILQ_INIT(&base->events);
@@ -105,7 +105,7 @@ void
sudo_ev_base_free_v1(struct sudo_event_base *base)
{
struct sudo_event *ev, *next;
debug_decl(sudo_ev_base_free, SUDO_DEBUG_EVENT, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_ev_base_free, SUDO_DEBUG_EVENT)
/* Remove any existing events before freeing the base. */
TAILQ_FOREACH_SAFE(ev, &base->events, entries, next) {
@@ -121,7 +121,7 @@ struct sudo_event *
sudo_ev_alloc_v1(int fd, short events, sudo_ev_callback_t callback, void *closure)
{
struct sudo_event *ev;
debug_decl(sudo_ev_alloc, SUDO_DEBUG_EVENT, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_ev_alloc, SUDO_DEBUG_EVENT)
/* XXX - sanity check events value */
@@ -138,7 +138,7 @@ sudo_ev_alloc_v1(int fd, short events, sudo_ev_callback_t callback, void *closur
void
sudo_ev_free_v1(struct sudo_event *ev)
{
debug_decl(sudo_ev_free, SUDO_DEBUG_EVENT, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_ev_free, SUDO_DEBUG_EVENT)
/* Make sure ev is not in use before freeing it. */
if (ISSET(ev->flags, SUDO_EVQ_INSERTED))
@@ -151,7 +151,7 @@ int
sudo_ev_add_v1(struct sudo_event_base *base, struct sudo_event *ev,
struct timeval *timo, bool tohead)
{
debug_decl(sudo_ev_add, SUDO_DEBUG_EVENT, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_ev_add, SUDO_DEBUG_EVENT)
/* If no base specified, use existing one. */
if (base == NULL) {
@@ -216,7 +216,7 @@ sudo_ev_add_v1(struct sudo_event_base *base, struct sudo_event *ev,
int
sudo_ev_del_v1(struct sudo_event_base *base, struct sudo_event *ev)
{
debug_decl(sudo_ev_del, SUDO_DEBUG_EVENT, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_ev_del, SUDO_DEBUG_EVENT)
/* Make sure event is really in the queue. */
if (!ISSET(ev->flags, SUDO_EVQ_INSERTED)) {
@@ -276,7 +276,7 @@ sudo_ev_loop_v1(struct sudo_event_base *base, int flags)
struct timeval now;
struct sudo_event *ev;
int nready, rc = 0;
debug_decl(sudo_ev_loop, SUDO_DEBUG_EVENT, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_ev_loop, SUDO_DEBUG_EVENT)
/*
* If sudo_ev_loopexit() was called when events were not running
@@ -372,7 +372,7 @@ done:
void
sudo_ev_loopexit_v1(struct sudo_event_base *base)
{
debug_decl(sudo_ev_loopexit, SUDO_DEBUG_EVENT, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_ev_loopexit, SUDO_DEBUG_EVENT)
/* SUDO_EVBASE_LOOPBREAK trumps SUDO_EVBASE_LOOPEXIT */
if (!ISSET(base->flags, SUDO_EVBASE_LOOPBREAK)) {
/* SUDO_EVBASE_LOOPEXIT trumps SUDO_EVBASE_LOOPCONT */
@@ -385,7 +385,7 @@ sudo_ev_loopexit_v1(struct sudo_event_base *base)
void
sudo_ev_loopbreak_v1(struct sudo_event_base *base)
{
debug_decl(sudo_ev_loopbreak, SUDO_DEBUG_EVENT, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_ev_loopbreak, SUDO_DEBUG_EVENT)
/* SUDO_EVBASE_LOOPBREAK trumps SUDO_EVBASE_LOOP{CONT,EXIT,ONCE}. */
CLR(base->flags, (SUDO_EVBASE_LOOPCONT|SUDO_EVBASE_LOOPEXIT|SUDO_EVBASE_LOOPONCE));
SET(base->flags, SUDO_EVBASE_LOOPBREAK);
@@ -395,7 +395,7 @@ sudo_ev_loopbreak_v1(struct sudo_event_base *base)
void
sudo_ev_loopcontinue_v1(struct sudo_event_base *base)
{
debug_decl(sudo_ev_loopcontinue, SUDO_DEBUG_EVENT, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_ev_loopcontinue, SUDO_DEBUG_EVENT)
/* SUDO_EVBASE_LOOP{BREAK,EXIT} trumps SUDO_EVBASE_LOOPCONT */
if (!ISSET(base->flags, SUDO_EVBASE_LOOPONCE|SUDO_EVBASE_LOOPBREAK)) {
SET(base->flags, SUDO_EVBASE_LOOPCONT);
@@ -406,14 +406,14 @@ sudo_ev_loopcontinue_v1(struct sudo_event_base *base)
bool
sudo_ev_got_exit_v1(struct sudo_event_base *base)
{
debug_decl(sudo_ev_got_exit, SUDO_DEBUG_EVENT, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_ev_got_exit, SUDO_DEBUG_EVENT)
debug_return_bool(ISSET(base->flags, SUDO_EVBASE_GOT_EXIT));
}
bool
sudo_ev_got_break_v1(struct sudo_event_base *base)
{
debug_decl(sudo_ev_got_break, SUDO_DEBUG_EVENT, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_ev_got_break, SUDO_DEBUG_EVENT)
debug_return_bool(ISSET(base->flags, SUDO_EVBASE_GOT_BREAK));
}
@@ -421,7 +421,7 @@ int
sudo_ev_get_timeleft_v1(struct sudo_event *ev, struct timeval *tv)
{
struct timeval now;
debug_decl(sudo_ev_get_timeleft, SUDO_DEBUG_EVENT, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_ev_get_timeleft, SUDO_DEBUG_EVENT)
if (!ISSET(ev->flags, SUDO_EVQ_TIMEOUTS)) {
sudo_timevalclear(tv);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2013-2015 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
@@ -56,7 +56,7 @@ int
sudo_ev_base_alloc_impl(struct sudo_event_base *base)
{
int i;
debug_decl(sudo_ev_base_alloc_impl, SUDO_DEBUG_EVENT, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_ev_base_alloc_impl, SUDO_DEBUG_EVENT)
base->pfd_high = -1;
base->pfd_max = 32;
@@ -71,7 +71,7 @@ sudo_ev_base_alloc_impl(struct sudo_event_base *base)
void
sudo_ev_base_free_impl(struct sudo_event_base *base)
{
debug_decl(sudo_ev_base_free_impl, SUDO_DEBUG_EVENT, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_ev_base_free_impl, SUDO_DEBUG_EVENT)
sudo_efree(base->pfds);
debug_return;
}
@@ -80,7 +80,7 @@ int
sudo_ev_add_impl(struct sudo_event_base *base, struct sudo_event *ev)
{
struct pollfd *pfd;
debug_decl(sudo_ev_add_impl, SUDO_DEBUG_EVENT, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_ev_add_impl, SUDO_DEBUG_EVENT)
/* If out of space in pfds array, realloc. */
if (base->pfd_free == base->pfd_max) {
@@ -119,7 +119,7 @@ sudo_ev_add_impl(struct sudo_event_base *base, struct sudo_event *ev)
int
sudo_ev_del_impl(struct sudo_event_base *base, struct sudo_event *ev)
{
debug_decl(sudo_ev_del_impl, SUDO_DEBUG_EVENT, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_ev_del_impl, SUDO_DEBUG_EVENT)
/* Mark pfd entry unused, add to free list and adjust high slot. */
base->pfds[ev->pfd_idx].fd = -1;
@@ -137,7 +137,7 @@ sudo_ev_scan_impl(struct sudo_event_base *base, int flags)
struct sudo_event *ev;
int nready, timeout;
struct timeval now;
debug_decl(sudo_ev_scan_impl, SUDO_DEBUG_EVENT, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_ev_scan_impl, SUDO_DEBUG_EVENT)
if ((ev = TAILQ_FIRST(&base->timeouts)) != NULL) {
struct timeval *timo = &ev->timeout;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2013-2015 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
@@ -61,7 +61,7 @@
int
sudo_ev_base_alloc_impl(struct sudo_event_base *base)
{
debug_decl(sudo_ev_base_alloc_impl, SUDO_DEBUG_EVENT, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_ev_base_alloc_impl, SUDO_DEBUG_EVENT)
base->maxfd = NFDBITS - 1;
base->readfds_in = sudo_ecalloc(1, sizeof(fd_mask));
@@ -75,7 +75,7 @@ sudo_ev_base_alloc_impl(struct sudo_event_base *base)
void
sudo_ev_base_free_impl(struct sudo_event_base *base)
{
debug_decl(sudo_ev_base_free_impl, SUDO_DEBUG_EVENT, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_ev_base_free_impl, SUDO_DEBUG_EVENT)
sudo_efree(base->readfds_in);
sudo_efree(base->writefds_in);
sudo_efree(base->readfds_out);
@@ -86,7 +86,7 @@ sudo_ev_base_free_impl(struct sudo_event_base *base)
int
sudo_ev_add_impl(struct sudo_event_base *base, struct sudo_event *ev)
{
debug_decl(sudo_ev_add_impl, SUDO_DEBUG_EVENT, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_ev_add_impl, SUDO_DEBUG_EVENT)
/* If out of space in fd sets, realloc. */
if (ev->fd > base->maxfd) {
@@ -119,7 +119,7 @@ sudo_ev_add_impl(struct sudo_event_base *base, struct sudo_event *ev)
int
sudo_ev_del_impl(struct sudo_event_base *base, struct sudo_event *ev)
{
debug_decl(sudo_ev_del_impl, SUDO_DEBUG_EVENT, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_ev_del_impl, SUDO_DEBUG_EVENT)
/* Remove from readfds and writefds and adjust high fd. */
if (ISSET(ev->events, SUDO_EV_READ)) {
@@ -152,7 +152,7 @@ sudo_ev_scan_impl(struct sudo_event_base *base, int flags)
struct sudo_event *ev;
size_t setsize;
int nready;
debug_decl(sudo_ev_loop, SUDO_DEBUG_EVENT, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_ev_loop, SUDO_DEBUG_EVENT)
if ((ev = TAILQ_FIRST(&base->timeouts)) != NULL) {
gettimeofday(&now, NULL);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2013-2015 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
@@ -52,7 +52,7 @@ sudo_parse_gids_v1(const char *gidstr, const gid_t *basegid, GETGROUPS_T **gidsp
const char *cp = gidstr;
const char *errstr;
char *ep;
debug_decl(sudo_parse_gids, SUDO_DEBUG_UTIL, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_parse_gids, SUDO_DEBUG_UTIL)
/* Count groups. */
if (*cp != '\0') {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2012, 2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2010-2012, 2014-2015 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
@@ -51,7 +51,7 @@ sudo_new_key_val_v1(const char *key, const char *val)
size_t key_len = strlen(key);
size_t val_len = strlen(val);
char *cp, *str;
debug_decl(sudo_new_key_val, SUDO_DEBUG_UTIL, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_new_key_val, SUDO_DEBUG_UTIL)
cp = str = malloc(key_len + 1 + val_len + 1);
if (str != NULL) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2007-2015 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
@@ -51,7 +51,7 @@ void
sudo_lbuf_init_v1(struct sudo_lbuf *lbuf, sudo_lbuf_output_t output,
int indent, const char *continuation, int cols)
{
debug_decl(sudo_lbuf_init, SUDO_DEBUG_UTIL, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_lbuf_init, SUDO_DEBUG_UTIL)
lbuf->output = output;
lbuf->continuation = continuation;
@@ -67,7 +67,7 @@ sudo_lbuf_init_v1(struct sudo_lbuf *lbuf, sudo_lbuf_output_t output,
void
sudo_lbuf_destroy_v1(struct sudo_lbuf *lbuf)
{
debug_decl(sudo_lbuf_destroy, SUDO_DEBUG_UTIL, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_lbuf_destroy, SUDO_DEBUG_UTIL)
sudo_efree(lbuf->buf);
lbuf->buf = NULL;
@@ -96,7 +96,7 @@ sudo_lbuf_append_quoted_v1(struct sudo_lbuf *lbuf, const char *set, const char *
va_list ap;
int len;
char *cp, *s;
debug_decl(sudo_lbuf_append_quoted, SUDO_DEBUG_UTIL, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_lbuf_append_quoted, SUDO_DEBUG_UTIL)
va_start(ap, fmt);
while (*fmt != '\0') {
@@ -143,7 +143,7 @@ sudo_lbuf_append_v1(struct sudo_lbuf *lbuf, const char *fmt, ...)
va_list ap;
int len;
char *s;
debug_decl(sudo_lbuf_append, SUDO_DEBUG_UTIL, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_lbuf_append, SUDO_DEBUG_UTIL)
va_start(ap, fmt);
while (*fmt != '\0') {
@@ -173,7 +173,7 @@ sudo_lbuf_println(struct sudo_lbuf *lbuf, char *line, int len)
{
char *cp, save;
int i, have, contlen;
debug_decl(sudo_lbuf_println, SUDO_DEBUG_UTIL, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_lbuf_println, SUDO_DEBUG_UTIL)
contlen = lbuf->continuation ? strlen(lbuf->continuation) : 0;
@@ -235,7 +235,7 @@ sudo_lbuf_print_v1(struct sudo_lbuf *lbuf)
{
char *cp, *ep;
int len;
debug_decl(sudo_lbuf_print, SUDO_DEBUG_UTIL, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_lbuf_print, SUDO_DEBUG_UTIL)
if (lbuf->buf == NULL || lbuf->len == 0)
goto done;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999-2005, 2007, 2009-2014
* Copyright (c) 1999-2005, 2007, 2009-2015
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -68,7 +68,7 @@ bool
sudo_lock_file_v1(int fd, int lockit)
{
int op = 0;
debug_decl(sudo_lock_file, SUDO_DEBUG_UTIL, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_lock_file, SUDO_DEBUG_UTIL)
switch (lockit) {
case SUDO_LOCK:
@@ -88,7 +88,7 @@ bool
sudo_lock_file_v1(int fd, int lockit)
{
int op = 0;
debug_decl(sudo_lock_file, SUDO_DEBUG_UTIL, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_lock_file, SUDO_DEBUG_UTIL)
switch (lockit) {
case SUDO_LOCK:
@@ -110,7 +110,7 @@ sudo_lock_file_v1(int fd, int lockit)
#ifdef F_SETLK
int func;
struct flock lock;
debug_decl(sudo_lock_file, SUDO_DEBUG_UTIL, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_lock_file, SUDO_DEBUG_UTIL)
lock.l_start = 0;
lock.l_len = 0;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007, 2013-2014
* Copyright (c) 2007, 2013-2015
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -67,7 +67,7 @@ sudo_parseln_v1(char **bufp, size_t *bufsizep, unsigned int *lineno, FILE *fp)
ssize_t len;
char *cp, *line = NULL;
bool continued;
debug_decl(sudo_parseln, SUDO_DEBUG_UTIL, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_parseln, SUDO_DEBUG_UTIL)
do {
continued = false;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012, 2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2012, 2014-2015 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
@@ -42,7 +42,7 @@ sudo_secure_path(const char *path, unsigned int type, uid_t uid, gid_t gid, stru
{
struct stat sb;
int rval = SUDO_PATH_MISSING;
debug_decl(sudo_secure_path, SUDO_DEBUG_UTIL, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_secure_path, SUDO_DEBUG_UTIL)
if (path != NULL && stat(path, &sb) == 0) {
if ((sb.st_mode & _S_IFMT) != type) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2012, 2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2011-2012, 2014-2015 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
@@ -43,7 +43,7 @@ int
sudo_setgroups_v1(int ngids, const GETGROUPS_T *gids)
{
int maxgids, rval;
debug_decl(sudo_setgroups, SUDO_DEBUG_UTIL, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_setgroups, SUDO_DEBUG_UTIL)
rval = setgroups(ngids, (GETGROUPS_T *)gids);
if (rval == -1 && errno == EINVAL) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2010-2015 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
@@ -44,7 +44,7 @@
int
sudo_strtobool_v1(const char *str)
{
debug_decl(sudo_strtobool, SUDO_DEBUG_UTIL, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_strtobool, SUDO_DEBUG_UTIL)
switch (*str) {
case '0':

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2013-2015 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
@@ -61,7 +61,7 @@ sudo_strtoid_v1(const char *p, const char *sep, char **endp, const char **errstr
char *ep;
id_t rval = 0;
bool valid = false;
debug_decl(sudo_strtoid, SUDO_DEBUG_UTIL, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_strtoid, SUDO_DEBUG_UTIL)
/* skip leading space so we can pick up the sign, if any */
while (isspace((unsigned char)*p))

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2013-2015 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
@@ -46,7 +46,7 @@ sudo_strtomode_v1(const char *cp, const char **errstr)
{
char *ep;
long lval;
debug_decl(sudo_strtomode, SUDO_DEBUG_UTIL, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_strtomode, SUDO_DEBUG_UTIL)
errno = 0;
lval = strtol(cp, &ep, 8);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2009-2015 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
@@ -144,7 +144,7 @@ parse_variable(const char *entry, const char *conf_file, unsigned int lineno)
{
struct sudo_conf_table *var;
bool rval;
debug_decl(parse_variable, SUDO_DEBUG_UTIL, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(parse_variable, SUDO_DEBUG_UTIL)
for (var = sudo_conf_var_table; var->name != NULL; var++) {
if (strncmp(entry, var->name, var->namelen) == 0 &&
@@ -172,7 +172,7 @@ parse_path(const char *entry, const char *conf_file, unsigned int lineno)
{
const char *name, *path;
struct sudo_conf_path_table *cur;
debug_decl(parse_path, SUDO_DEBUG_UTIL, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(parse_path, SUDO_DEBUG_UTIL)
/* Parse Path line */
name = entry;
@@ -213,7 +213,7 @@ parse_debug(const char *progname, const char *conf_file, unsigned int lineno)
struct sudo_debug_file *debug_file;
const char *path, *flags, *cp = progname;
size_t pathlen, prognamelen;
debug_decl(parse_debug, SUDO_DEBUG_UTIL, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(parse_debug, SUDO_DEBUG_UTIL)
/* Parse progname. */
while (*cp != '\0' && !isblank((unsigned char)*cp))
@@ -275,7 +275,7 @@ parse_plugin(const char *cp, const char *conf_file, unsigned int lineno)
char **options = NULL;
size_t pathlen, symlen;
unsigned int nopts;
debug_decl(parse_plugin, SUDO_DEBUG_UTIL, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(parse_plugin, SUDO_DEBUG_UTIL)
/* Parse symbol. */
if (*cp == '\0')
@@ -332,7 +332,7 @@ set_var_disable_coredump(const char *strval, const char *conf_file,
unsigned int lineno)
{
int val = sudo_strtobool(strval);
debug_decl(set_var_disable_coredump, SUDO_DEBUG_UTIL, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(set_var_disable_coredump, SUDO_DEBUG_UTIL)
if (val == -1) {
sudo_warnx(U_("invalid value for %s `%s' in %s, line %u"),
@@ -347,7 +347,7 @@ static bool
set_var_group_source(const char *strval, const char *conf_file,
unsigned int lineno)
{
debug_decl(set_var_group_source, SUDO_DEBUG_UTIL, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(set_var_group_source, SUDO_DEBUG_UTIL)
if (strcasecmp(strval, "adaptive") == 0) {
sudo_conf_data.group_source = GROUP_SOURCE_ADAPTIVE;
@@ -368,7 +368,7 @@ set_var_max_groups(const char *strval, const char *conf_file,
unsigned int lineno)
{
int max_groups;
debug_decl(set_var_max_groups, SUDO_DEBUG_UTIL, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(set_var_max_groups, SUDO_DEBUG_UTIL)
max_groups = strtonum(strval, 1, INT_MAX, NULL);
if (max_groups <= 0) {
@@ -385,7 +385,7 @@ set_var_probe_interfaces(const char *strval, const char *conf_file,
unsigned int lineno)
{
int val = sudo_strtobool(strval);
debug_decl(set_var_probe_interfaces, SUDO_DEBUG_UTIL, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(set_var_probe_interfaces, SUDO_DEBUG_UTIL)
if (val == -1) {
sudo_warnx(U_("invalid value for %s `%s' in %s, line %u"),
@@ -455,7 +455,7 @@ sudo_conf_debug_files_v1(const char *progname)
struct sudo_conf_debug *debug_spec;
size_t prognamelen, progbaselen;
const char *progbase = progname;
debug_decl(sudo_conf_debug_files, SUDO_DEBUG_UTIL, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_conf_debug_files, SUDO_DEBUG_UTIL)
/* Determine basename if program is fully qualified (like for plugins). */
prognamelen = progbaselen = strlen(progname);
@@ -508,7 +508,7 @@ sudo_conf_read_v1(const char *conf_file, int conf_types)
char *prev_locale = sudo_estrdup(setlocale(LC_ALL, NULL));
unsigned int conf_lineno = 0;
size_t linesize = 0;
debug_decl(sudo_conf_read, SUDO_DEBUG_UTIL, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_conf_read, SUDO_DEBUG_UTIL)
/* Parse sudo.conf in the "C" locale. */
if (prev_locale[0] != 'C' || prev_locale[1] != '\0')

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2011-2015 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
@@ -131,7 +131,7 @@ static unsigned char *sudo_debug_fds;
static int sudo_debug_max_fd = -1;
/* Default instance index to use for common utility functions. */
static int sudo_debug_default_instance = -1;
static int sudo_debug_active_instance = -1;
/*
* Create a new output file for the specified debug instance.
@@ -219,9 +219,10 @@ sudo_debug_new_output(struct sudo_debug_instance *instance,
/*
* Register a program/plugin with the debug framework,
* parses settings string from sudo.conf and opens debugfile.
* parses settings string from sudo.conf and opens debug_files.
* If subsystem names are specified they override the default values.
* NOTE: subsystems must not be freed by caller unless deregistered.
* Sets the active instance to the newly registered instance.
* Returns instance index on success or SUDO_DEBUG_INSTANCE_INITIALIZER
* on failure.
*/
@@ -271,7 +272,7 @@ sudo_debug_register_v1(const char *program, const char *const subsystems[],
}
if (j == NUM_DEF_SUBSYSTEMS)
j = ++max_id;
ids[i] = ((j + 1) << 16);
ids[i] = ((j + 1) << 6);
}
}
@@ -311,9 +312,8 @@ sudo_debug_register_v1(const char *program, const char *const subsystems[],
SLIST_INSERT_HEAD(&instance->outputs, output, entries);
}
/* Set default instance if not already set. */
if (sudo_debug_default_instance == -1)
sudo_debug_default_instance = idx;
/* Set active instance. */
sudo_debug_active_instance = idx;
/* Stash the pid string so we only have to format it once. */
if (sudo_debug_pidlen == 0) {
@@ -322,8 +322,7 @@ sudo_debug_register_v1(const char *program, const char *const subsystems[],
sudo_debug_pidlen = strlen(sudo_debug_pidstr);
}
/* Convert index to instance. */
return SUDO_DEBUG_MKINSTANCE(idx);
return idx;
}
/*
@@ -331,21 +330,19 @@ sudo_debug_register_v1(const char *program, const char *const subsystems[],
* and free up any associated data structures.
*/
int
sudo_debug_deregister_v1(int instance_id)
sudo_debug_deregister_v1(int idx)
{
struct sudo_debug_instance *instance;
struct sudo_debug_output *output, *next;
int idx;
idx = SUDO_DEBUG_INSTANCE(instance_id);
if (idx < 0 || idx > sudo_debug_last_instance) {
sudo_warnx_nodebug("%s: invalid instance ID %d, max %d",
__func__, idx, sudo_debug_last_instance);
return -1;
}
/* Reset default instance as needed. */
if (sudo_debug_default_instance == idx)
sudo_debug_default_instance = -1;
/* Reset active instance as needed. */
if (sudo_debug_active_instance == idx)
sudo_debug_active_instance = -1;
instance = sudo_debug_instances[idx];
if (instance == NULL)
@@ -377,33 +374,11 @@ sudo_debug_get_instance_v1(const char *program)
if (sudo_debug_instances[idx] == NULL)
continue;
if (strcmp(sudo_debug_instances[idx]->program, program) == 0)
return SUDO_DEBUG_MKINSTANCE(idx);
return idx;
}
return SUDO_DEBUG_INSTANCE_INITIALIZER;
}
int
sudo_debug_set_output_fd_v1(int level, int ofd, int nfd)
{
struct sudo_debug_instance *instance;
struct sudo_debug_output *output;
int idx;
idx = SUDO_DEBUG_INSTANCE(level);
if (idx < 0 || idx > sudo_debug_last_instance) {
sudo_warnx_nodebug("%s: invalid instance ID %d, max %d",
__func__, idx, sudo_debug_last_instance);
return -1;
}
instance = sudo_debug_instances[idx];
SLIST_FOREACH(output, &instance->outputs, entries) {
if (output->fd == ofd)
output->fd = nfd;
}
return 0;
}
pid_t
sudo_debug_fork_v1(void)
{
@@ -581,36 +556,29 @@ void
sudo_debug_vprintf2_v1(const char *func, const char *file, int lineno, int level,
const char *fmt, va_list ap)
{
int buflen, idx, pri, saved_errno = errno;
int buflen, pri, saved_errno = errno;
unsigned int subsys;
char static_buf[1024], *buf = static_buf;
struct sudo_debug_instance *instance;
struct sudo_debug_output *output;
if (sudo_debug_last_instance == -1)
if (sudo_debug_active_instance == -1)
goto out;
/* Extract instance index, priority and subsystem from level. */
idx = SUDO_DEBUG_INSTANCE(level);
/* Extract priority and subsystem from level. */
pri = SUDO_DEBUG_PRI(level);
subsys = SUDO_DEBUG_SUBSYS(level);
/* Find matching instance. */
if (idx < 0) {
/* Check for default instance, else we are not initialized. */
if (sudo_debug_default_instance < 0 ||
SUDO_DEBUG_MKINSTANCE(idx) != SUDO_DEBUG_INSTANCE_DEFAULT) {
goto out;
}
idx = sudo_debug_default_instance;
} else if (idx > sudo_debug_last_instance) {
if (sudo_debug_active_instance > sudo_debug_last_instance) {
sudo_warnx_nodebug("%s: invalid instance ID %d, max %d",
__func__, idx, sudo_debug_last_instance);
__func__, sudo_debug_active_instance, sudo_debug_last_instance);
goto out;
}
instance = sudo_debug_instances[idx];
instance = sudo_debug_instances[sudo_debug_active_instance];
if (instance == NULL) {
sudo_warnx_nodebug("%s: unregistered instance index %d", __func__, idx);
sudo_warnx_nodebug("%s: unregistered instance index %d", __func__,
sudo_debug_active_instance);
goto out;
}
@@ -676,7 +644,7 @@ sudo_debug_printf2_v1(const char *func, const char *file, int lineno, int level,
void
sudo_debug_execve2_v1(int level, const char *path, char *const argv[], char *const envp[])
{
int buflen, idx, pri, saved_errno = errno;
int buflen, pri, saved_errno = errno;
unsigned int subsys;
struct sudo_debug_instance *instance;
struct sudo_debug_output *output;
@@ -684,30 +652,23 @@ sudo_debug_execve2_v1(int level, const char *path, char *const argv[], char *con
char *cp, static_buf[4096], *buf = static_buf;
size_t plen;
if (sudo_debug_last_instance == -1)
if (sudo_debug_active_instance == -1)
goto out;
/* Extract instance index, priority and subsystem from level. */
idx = SUDO_DEBUG_INSTANCE(level);
/* Extract priority and subsystem from level. */
pri = SUDO_DEBUG_PRI(level);
subsys = SUDO_DEBUG_SUBSYS(level);
/* Find matching instance. */
if (idx < 0) {
/* Check for default instance, else we are not initialized. */
if (sudo_debug_default_instance < 0 ||
SUDO_DEBUG_MKINSTANCE(idx) != SUDO_DEBUG_INSTANCE_DEFAULT) {
goto out;
}
idx = sudo_debug_default_instance;
} else if (idx > sudo_debug_last_instance) {
if (sudo_debug_active_instance > sudo_debug_last_instance) {
sudo_warnx_nodebug("%s: invalid instance ID %d, max %d",
__func__, idx, sudo_debug_last_instance);
__func__, sudo_debug_active_instance, sudo_debug_last_instance);
goto out;
}
instance = sudo_debug_instances[idx];
instance = sudo_debug_instances[sudo_debug_active_instance];
if (instance == NULL) {
sudo_warnx_nodebug("%s: unregistered instance index %d", __func__, idx);
sudo_warnx_nodebug("%s: unregistered instance index %d", __func__,
sudo_debug_active_instance);
goto out;
}
if (subsys > instance->max_subsystem)
@@ -789,29 +750,28 @@ out:
}
/*
* Returns the default instance or SUDO_DEBUG_INSTANCE_INITIALIZER
* if no default instance is set.
* Returns the active instance or SUDO_DEBUG_INSTANCE_INITIALIZER
* if no instance is active.
*/
int
sudo_debug_get_default_instance_v1(void)
sudo_debug_get_active_instance_v1(void)
{
return SUDO_DEBUG_MKINSTANCE(sudo_debug_default_instance);
return sudo_debug_active_instance;
}
/*
* Sets a new default instance, returning the old one.
* Sets a new active instance, returning the old one.
* Note that the old instance may be SUDO_DEBUG_INSTANCE_INITIALIZER
* if this is the only instance.
*/
int
sudo_debug_set_default_instance_v1(int inst)
sudo_debug_set_active_instance_v1(int idx)
{
const int idx = SUDO_DEBUG_INSTANCE(inst);
const int old_idx = sudo_debug_default_instance;
const int old_idx = sudo_debug_active_instance;
if (idx >= -1 && idx <= sudo_debug_last_instance)
sudo_debug_default_instance = idx;
return SUDO_DEBUG_MKINSTANCE(old_idx);
sudo_debug_active_instance = idx;
return old_idx;
}
/*

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2011-2015 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
@@ -119,7 +119,7 @@ tcsetattr_nobg(int fd, int flags, struct termios *tp)
bool
sudo_term_restore_v1(int fd, bool flush)
{
debug_decl(term_restore, SUDO_DEBUG_UTIL, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(term_restore, SUDO_DEBUG_UTIL)
if (changed) {
const int flags = flush ? (TCSASOFT|TCSAFLUSH) : (TCSASOFT|TCSADRAIN);
@@ -137,7 +137,7 @@ sudo_term_restore_v1(int fd, bool flush)
bool
sudo_term_noecho_v1(int fd)
{
debug_decl(term_noecho, SUDO_DEBUG_UTIL, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(term_noecho, SUDO_DEBUG_UTIL)
again:
if (!changed && tcgetattr(fd, &oterm) != 0)
@@ -167,7 +167,7 @@ bool
sudo_term_raw_v1(int fd, int isig)
{
struct termios term;
debug_decl(term_raw, SUDO_DEBUG_UTIL, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(term_raw, SUDO_DEBUG_UTIL)
again:
if (!changed && tcgetattr(fd, &oterm) != 0)
@@ -200,7 +200,7 @@ again:
bool
sudo_term_cbreak_v1(int fd)
{
debug_decl(term_cbreak, SUDO_DEBUG_UTIL, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(term_cbreak, SUDO_DEBUG_UTIL)
again:
if (!changed && tcgetattr(fd, &oterm) != 0)
@@ -238,7 +238,7 @@ bool
sudo_term_copy_v1(int src, int dst)
{
struct termios tt;
debug_decl(term_copy, SUDO_DEBUG_UTIL, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(term_copy, SUDO_DEBUG_UTIL)
again:
if (tcgetattr(src, &tt) != 0)

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2012, 2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2010-2012, 2014-2015 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
@@ -52,7 +52,7 @@ static int
get_ttysize_ioctl(int *rowp, int *colp)
{
struct winsize wsize;
debug_decl(get_ttysize_ioctl, SUDO_DEBUG_UTIL, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(get_ttysize_ioctl, SUDO_DEBUG_UTIL)
if (ioctl(STDERR_FILENO, TIOCGWINSZ, &wsize) == 0 &&
wsize.ws_row != 0 && wsize.ws_col != 0) {
@@ -73,7 +73,7 @@ get_ttysize_ioctl(int *rowp, int *colp)
void
sudo_get_ttysize_v1(int *rowp, int *colp)
{
debug_decl(sudo_get_ttysize, SUDO_DEBUG_UTIL, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(sudo_get_ttysize, SUDO_DEBUG_UTIL)
if (get_ttysize_ioctl(rowp, colp) == -1) {
char *p;

View File

@@ -23,12 +23,12 @@ sudo_debug_exit_size_t_v1
sudo_debug_exit_str_v1
sudo_debug_exit_str_masked_v1
sudo_debug_fork_v1
sudo_debug_get_default_instance_v1
sudo_debug_get_active_instance_v1
sudo_debug_get_fds_v1
sudo_debug_get_instance_v1
sudo_debug_printf2_v1
sudo_debug_register_v1
sudo_debug_set_default_instance_v1
sudo_debug_set_active_instance_v1
sudo_debug_update_fd_v1
sudo_debug_vprintf2_v1
sudo_debug_write2_v1

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2005, 2007-2014
* Copyright (c) 2004-2005, 2007-2015
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -60,7 +60,7 @@ alias_compare(const void *v1, const void *v2)
const struct alias *a1 = (const struct alias *)v1;
const struct alias *a2 = (const struct alias *)v2;
int res;
debug_decl(alias_compare, SUDOERS_DEBUG_ALIAS, sudoers_debug_instance)
debug_decl(alias_compare, SUDOERS_DEBUG_ALIAS)
if (a1 == NULL)
res = -1;
@@ -83,7 +83,7 @@ alias_get(char *name, int type)
struct alias key;
struct rbnode *node;
struct alias *a = NULL;
debug_decl(alias_get, SUDOERS_DEBUG_ALIAS, sudoers_debug_instance)
debug_decl(alias_get, SUDOERS_DEBUG_ALIAS)
key.name = name;
key.type = type;
@@ -111,7 +111,7 @@ alias_get(char *name, int type)
void
alias_put(struct alias *a)
{
debug_decl(alias_put, SUDOERS_DEBUG_ALIAS, sudoers_debug_instance)
debug_decl(alias_put, SUDOERS_DEBUG_ALIAS)
a->used = false;
debug_return;
}
@@ -125,7 +125,7 @@ alias_add(char *name, int type, struct member *members)
{
static char errbuf[512];
struct alias *a;
debug_decl(alias_add, SUDOERS_DEBUG_ALIAS, sudoers_debug_instance)
debug_decl(alias_add, SUDOERS_DEBUG_ALIAS)
a = sudo_ecalloc(1, sizeof(*a));
a->name = name;
@@ -146,7 +146,7 @@ alias_add(char *name, int type, struct member *members)
void
alias_apply(int (*func)(void *, void *), void *cookie)
{
debug_decl(alias_apply, SUDOERS_DEBUG_ALIAS, sudoers_debug_instance)
debug_decl(alias_apply, SUDOERS_DEBUG_ALIAS)
rbapply(aliases, func, cookie, inorder);
@@ -159,7 +159,7 @@ alias_apply(int (*func)(void *, void *), void *cookie)
bool
no_aliases(void)
{
debug_decl(no_aliases, SUDOERS_DEBUG_ALIAS, sudoers_debug_instance)
debug_decl(no_aliases, SUDOERS_DEBUG_ALIAS)
debug_return_bool(rbisempty(aliases));
}
@@ -173,7 +173,7 @@ alias_free(void *v)
struct member *m;
struct sudo_command *c;
void *next;
debug_decl(alias_free, SUDOERS_DEBUG_ALIAS, sudoers_debug_instance)
debug_decl(alias_free, SUDOERS_DEBUG_ALIAS)
sudo_efree(a->name);
TAILQ_FOREACH_SAFE(m, &a->members, entries, next) {
@@ -198,7 +198,7 @@ alias_remove(char *name, int type)
{
struct rbnode *node;
struct alias key;
debug_decl(alias_remove, SUDOERS_DEBUG_ALIAS, sudoers_debug_instance)
debug_decl(alias_remove, SUDOERS_DEBUG_ALIAS)
key.name = name;
key.type = type;
@@ -212,7 +212,7 @@ alias_remove(char *name, int type)
void
init_aliases(void)
{
debug_decl(init_aliases, SUDOERS_DEBUG_ALIAS, sudoers_debug_instance)
debug_decl(init_aliases, SUDOERS_DEBUG_ALIAS)
if (aliases != NULL)
rbdestroy(aliases, alias_free);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2009-2015 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
@@ -43,7 +43,7 @@ int
audit_success(int argc, char *argv[])
{
int rc = 0;
debug_decl(audit_success, SUDOERS_DEBUG_AUDIT, sudoers_debug_instance)
debug_decl(audit_success, SUDOERS_DEBUG_AUDIT)
if (argv != NULL) {
#ifdef HAVE_BSM_AUDIT
@@ -67,7 +67,7 @@ int
audit_failure(int argc, char *argv[], char const *const fmt, ...)
{
int rc = 0;
debug_decl(audit_success, SUDOERS_DEBUG_AUDIT, sudoers_debug_instance)
debug_decl(audit_success, SUDOERS_DEBUG_AUDIT)
#if defined(HAVE_BSM_AUDIT) || defined(HAVE_LINUX_AUDIT)
if (argv != NULL) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999, 2001-2005, 2007, 2010-2012, 2014
* Copyright (c) 1999, 2001-2005, 2007, 2010-2012, 2014-2015
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -53,7 +53,7 @@ sudo_afs_verify(struct passwd *pw, char *pass, sudo_auth *auth)
{
struct ktc_encryptionKey afs_key;
struct ktc_token afs_token;
debug_decl(sudo_afs_verify, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_afs_verify, SUDOERS_DEBUG_AUTH)
/* Try to just check the password */
ka_StringToKey(pass, NULL, &afs_key);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999-2005, 2007-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 1999-2005, 2007-2015 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
@@ -55,7 +55,7 @@ sudo_aix_verify(struct passwd *pw, char *prompt, sudo_auth *auth)
char *pass, *message = NULL;
int result = 1, reenter = 0;
int rval = AUTH_SUCCESS;
debug_decl(sudo_aix_verify, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_aix_verify, SUDOERS_DEBUG_AUTH)
do {
pass = auth_getpass(prompt, def_passwd_timeout * 60,
@@ -90,7 +90,7 @@ sudo_aix_verify(struct passwd *pw, char *prompt, sudo_auth *auth)
int
sudo_aix_cleanup(struct passwd *pw, sudo_auth *auth)
{
debug_decl(sudo_aix_cleanup, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_aix_cleanup, SUDOERS_DEBUG_AUTH)
/* Unset AUTHSTATE as it may not be correct for the runas user. */
if (sudo_unsetenv("AUTHSTATE") == -1)

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000-2005, 2007-2008, 2010-2014
* Copyright (c) 2000-2005, 2007-2008, 2010-2015
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -63,7 +63,7 @@ int
bsdauth_init(struct passwd *pw, sudo_auth *auth)
{
static struct bsdauth_state state;
debug_decl(bsdauth_init, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(bsdauth_init, SUDOERS_DEBUG_AUTH)
/* Get login class based on auth user, which may not be invoking user. */
if (pw->pw_class && *pw->pw_class)
@@ -113,7 +113,7 @@ bsdauth_verify(struct passwd *pw, char *prompt, sudo_auth *auth)
int authok = 0;
sigaction_t sa, osa;
auth_session_t *as = ((struct bsdauth_state *) auth->data)->as;
debug_decl(bsdauth_verify, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(bsdauth_verify, SUDOERS_DEBUG_AUTH)
/* save old signal handler */
sigemptyset(&sa.sa_mask);
@@ -174,7 +174,7 @@ int
bsdauth_cleanup(struct passwd *pw, sudo_auth *auth)
{
struct bsdauth_state *state = auth->data;
debug_decl(bsdauth_cleanup, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(bsdauth_cleanup, SUDOERS_DEBUG_AUTH)
if (state != NULL) {
auth_close(state->as);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 1998-2005, 2010-2012, 2014
* Copyright (c) 1996, 1998-2005, 2010-2012, 2014-2015
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -74,7 +74,7 @@ sudo_dce_verify(struct passwd *pw, char *plain_pw, sudo_auth *auth)
boolean32 reset_passwd;
sec_login_auth_src_t auth_src;
error_status_t status;
debug_decl(sudo_dce_verify, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_dce_verify, SUDOERS_DEBUG_AUTH)
/*
* Create the local context of the DCE principal necessary
@@ -188,7 +188,7 @@ check_dce_status(error_status_t input_status, char *comment)
{
int error_stat;
unsigned char error_string[dce_c_error_string_len];
debug_decl(check_dce_status, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(check_dce_status, SUDOERS_DEBUG_AUTH)
if (input_status == rpc_s_ok)
debug_return_bool(0);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999-2005, 2008, 2010-2014
* Copyright (c) 1999-2005, 2008, 2010-2015
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -53,7 +53,7 @@ sudo_fwtk_init(struct passwd *pw, sudo_auth *auth)
{
static Cfg *confp; /* Configuration entry struct */
char resp[128]; /* Response from the server */
debug_decl(sudo_fwtk_init, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_fwtk_init, SUDOERS_DEBUG_AUTH)
if ((confp = cfg_read("sudo")) == (Cfg *)-1) {
sudo_warnx(U_("unable to read fwtk config"));
@@ -85,7 +85,7 @@ sudo_fwtk_verify(struct passwd *pw, char *prompt, sudo_auth *auth)
char buf[SUDO_CONV_REPL_MAX + 12]; /* General prupose buffer */
char resp[128]; /* Response from the server */
int error;
debug_decl(sudo_fwtk_verify, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_fwtk_verify, SUDOERS_DEBUG_AUTH)
/* Send username to authentication server. */
(void) snprintf(buf, sizeof(buf), "authorize %s 'sudo'", pw->pw_name);
@@ -147,7 +147,7 @@ done:
int
sudo_fwtk_cleanup(struct passwd *pw, sudo_auth *auth)
{
debug_decl(sudo_fwtk_cleanup, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_fwtk_cleanup, SUDOERS_DEBUG_AUTH)
auth_close();
debug_return_int(AUTH_SUCCESS);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999-2005, 2007-2008, 2010-2014
* Copyright (c) 1999-2005, 2007-2008, 2010-2015
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -96,7 +96,7 @@ int
sudo_krb5_setup(struct passwd *pw, char **promptp, sudo_auth *auth)
{
static char *krb5_prompt;
debug_decl(sudo_krb5_init, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_krb5_init, SUDOERS_DEBUG_AUTH)
if (krb5_prompt == NULL) {
krb5_context sudo_context;
@@ -135,7 +135,7 @@ sudo_krb5_init(struct passwd *pw, sudo_auth *auth)
krb5_context sudo_context;
krb5_error_code error;
char cache_name[64], *pname = pw->pw_name;
debug_decl(sudo_krb5_init, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_krb5_init, SUDOERS_DEBUG_AUTH)
auth->data = (void *) &sudo_krb5_data; /* Stash all our data here */
@@ -183,7 +183,7 @@ sudo_krb5_verify(struct passwd *pw, char *pass, sudo_auth *auth)
krb5_principal princ;
krb5_ccache ccache;
krb5_error_code error;
debug_decl(sudo_krb5_verify, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_krb5_verify, SUDOERS_DEBUG_AUTH)
sudo_context = ((sudo_krb5_datap) auth->data)->sudo_context;
princ = ((sudo_krb5_datap) auth->data)->princ;
@@ -202,7 +202,7 @@ sudo_krb5_verify(struct passwd *pw, char *pass, sudo_auth *auth)
krb5_ccache ccache;
krb5_error_code error;
krb5_get_init_creds_opt *opts = NULL;
debug_decl(sudo_krb5_verify, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_krb5_verify, SUDOERS_DEBUG_AUTH)
sudo_context = ((sudo_krb5_datap) auth->data)->sudo_context;
princ = ((sudo_krb5_datap) auth->data)->princ;
@@ -266,7 +266,7 @@ sudo_krb5_cleanup(struct passwd *pw, sudo_auth *auth)
krb5_context sudo_context;
krb5_principal princ;
krb5_ccache ccache;
debug_decl(sudo_krb5_cleanup, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_krb5_cleanup, SUDOERS_DEBUG_AUTH)
sudo_context = ((sudo_krb5_datap) auth->data)->sudo_context;
princ = ((sudo_krb5_datap) auth->data)->princ;
@@ -298,7 +298,7 @@ verify_krb_v5_tgt(krb5_context sudo_context, krb5_creds *cred, char *auth_name)
krb5_error_code error;
krb5_principal server;
krb5_verify_init_creds_opt vopt;
debug_decl(verify_krb_v5_tgt, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(verify_krb_v5_tgt, SUDOERS_DEBUG_AUTH)
/*
* Get the server principal for the local host.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999-2005, 2007-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 1999-2005, 2007-2015 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
@@ -87,7 +87,7 @@ sudo_pam_init(struct passwd *pw, sudo_auth *auth)
{
static struct pam_conv pam_conv;
static int pam_status;
debug_decl(sudo_pam_init, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_pam_init, SUDOERS_DEBUG_AUTH)
/* Initial PAM setup */
auth->data = (void *) &pam_status;
@@ -133,7 +133,7 @@ sudo_pam_verify(struct passwd *pw, char *prompt, sudo_auth *auth)
{
const char *s;
int *pam_status = (int *) auth->data;
debug_decl(sudo_pam_verify, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_pam_verify, SUDOERS_DEBUG_AUTH)
def_prompt = prompt; /* for converse */
@@ -193,7 +193,7 @@ int
sudo_pam_cleanup(struct passwd *pw, sudo_auth *auth)
{
int *pam_status = (int *) auth->data;
debug_decl(sudo_pam_cleanup, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_pam_cleanup, SUDOERS_DEBUG_AUTH)
/* If successful, we can't close the session until sudo_pam_end_session() */
if (*pam_status != PAM_SUCCESS || auth->end_session == NULL) {
@@ -208,7 +208,7 @@ sudo_pam_begin_session(struct passwd *pw, char **user_envp[], sudo_auth *auth)
{
int status = AUTH_SUCCESS;
int *pam_status = (int *) auth->data;
debug_decl(sudo_pam_begin_session, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_pam_begin_session, SUDOERS_DEBUG_AUTH)
/*
* If there is no valid user we cannot open a PAM session.
@@ -279,7 +279,7 @@ int
sudo_pam_end_session(struct passwd *pw, sudo_auth *auth)
{
int status = AUTH_SUCCESS;
debug_decl(sudo_pam_end_session, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_pam_end_session, SUDOERS_DEBUG_AUTH)
if (pamh != NULL) {
/*
@@ -326,7 +326,7 @@ converse(int num_msg, PAM_CONST struct pam_message **msg,
char *pass;
int n, type;
int ret = PAM_AUTH_ERR;
debug_decl(converse, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(converse, SUDOERS_DEBUG_AUTH)
if ((*response = calloc(num_msg, sizeof(struct pam_response))) == NULL)
debug_return_int(PAM_SYSTEM_ERR);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999-2005, 2010-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 1999-2005, 2010-2015 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
@@ -50,7 +50,7 @@
int
sudo_passwd_init(struct passwd *pw, sudo_auth *auth)
{
debug_decl(sudo_passwd_init, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_passwd_init, SUDOERS_DEBUG_AUTH)
#ifdef HAVE_SKEYACCESS
if (skeyaccess(pw, user_tty, NULL, NULL) == 0)
@@ -69,7 +69,7 @@ sudo_passwd_verify(struct passwd *pw, char *pass, sudo_auth *auth)
char *pw_epasswd = auth->data;
size_t pw_len;
int matched = 0;
debug_decl(sudo_passwd_verify, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_passwd_verify, SUDOERS_DEBUG_AUTH)
pw_len = strlen(pw_epasswd);
@@ -111,7 +111,7 @@ sudo_passwd_cleanup(pw, auth)
sudo_auth *auth;
{
char *pw_epasswd = auth->data;
debug_decl(sudo_passwd_cleanup, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_passwd_cleanup, SUDOERS_DEBUG_AUTH)
if (pw_epasswd != NULL) {
memset_s(pw_epasswd, SUDO_CONV_REPL_MAX, 0, strlen(pw_epasswd));

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1994-1996, 1998-2005, 2010-2012, 2014
* Copyright (c) 1994-1996, 1998-2005, 2010-2012, 2014-2015
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -68,7 +68,7 @@ sudo_rfc1938_setup(struct passwd *pw, char **promptp, sudo_auth *auth)
static char *orig_prompt = NULL, *new_prompt = NULL;
static int op_len, np_size;
static struct RFC1938 rfc1938;
debug_decl(sudo_rfc1938_setup, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_rfc1938_setup, SUDOERS_DEBUG_AUTH)
/* Stash a pointer to the rfc1938 struct if we have not initialized */
if (!auth->data)
@@ -126,7 +126,7 @@ sudo_rfc1938_setup(struct passwd *pw, char **promptp, sudo_auth *auth)
int
sudo_rfc1938_verify(struct passwd *pw, char *pass, sudo_auth *auth)
{
debug_decl(sudo_rfc1938_verify, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_rfc1938_verify, SUDOERS_DEBUG_AUTH)
if (rfc1938verify((struct RFC1938 *) auth->data, pass) == 0)
debug_return_int(AUTH_SUCCESS);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1998-2005, 2010-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 1998-2005, 2010-2015 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
@@ -56,12 +56,12 @@ sudo_secureware_init(struct passwd *pw, sudo_auth *auth)
{
#ifdef __alpha
extern int crypt_type;
debug_decl(sudo_secureware_init, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_secureware_init, SUDOERS_DEBUG_AUTH)
if (crypt_type == INT_MAX)
debug_return_int(AUTH_FAILURE); /* no shadow */
#else
debug_decl(secureware_init, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(secureware_init, SUDOERS_DEBUG_AUTH)
#endif
sudo_setspent();
auth->data = sudo_getepw(pw);
@@ -74,7 +74,7 @@ sudo_secureware_verify(struct passwd *pw, char *pass, sudo_auth *auth)
{
char *pw_epasswd = auth->data;
char *epass = NULL;
debug_decl(sudo_secureware_verify, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_secureware_verify, SUDOERS_DEBUG_AUTH)
#ifdef __alpha
{
extern int crypt_type;
@@ -103,7 +103,7 @@ sudo_secureware_cleanup(pw, auth)
sudo_auth *auth;
{
char *pw_epasswd = auth->data;
debug_decl(sudo_secureware_cleanup, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_secureware_cleanup, SUDOERS_DEBUG_AUTH)
if (pw_epasswd != NULL) {
memset_s(pw_epasswd, SUDO_CONV_REPL_MAX, 0, strlen(pw_epasswd));

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999-2005, 2007, 2010-2012, 2014
* Copyright (c) 1999-2005, 2007, 2010-2012, 2014-2015
* Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2002 Michael Stroucken <michael@stroucken.org>
*
@@ -69,7 +69,7 @@ int
sudo_securid_init(struct passwd *pw, sudo_auth *auth)
{
static SDI_HANDLE sd_dat; /* SecurID handle */
debug_decl(sudo_securid_init, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_securid_init, SUDOERS_DEBUG_AUTH)
auth->data = (void *) &sd_dat; /* For method-specific data */
@@ -99,7 +99,7 @@ sudo_securid_setup(struct passwd *pw, char **promptp, sudo_auth *auth)
{
SDI_HANDLE *sd = (SDI_HANDLE *) auth->data;
int retval;
debug_decl(sudo_securid_setup, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_securid_setup, SUDOERS_DEBUG_AUTH)
/* Re-initialize SecurID every time. */
if (SD_Init(sd) != ACM_OK) {
@@ -150,7 +150,7 @@ sudo_securid_verify(struct passwd *pw, char *pass, sudo_auth *auth)
{
SDI_HANDLE *sd = (SDI_HANDLE *) auth->data;
int rval;
debug_decl(sudo_securid_verify, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_securid_verify, SUDOERS_DEBUG_AUTH)
pass = auth_getpass("Enter your PASSCODE: ",
def_passwd_timeout * 60, SUDO_CONV_PROMPT_ECHO_OFF);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999-2005, 2007, 2010-2014
* Copyright (c) 1999-2005, 2007, 2010-2015
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -69,7 +69,7 @@ sudo_collect(int timeout, int rendition, uchar_t *title, int nprompts,
{
int rval;
sigset_t mask, omask;
debug_decl(sudo_collect, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_collect, SUDOERS_DEBUG_AUTH)
switch (rendition) {
case SIAFORM:
@@ -108,7 +108,7 @@ sudo_sia_setup(struct passwd *pw, char **promptp, sudo_auth *auth)
{
SIAENTITY *siah = NULL;
int i;
debug_decl(sudo_sia_setup, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_sia_setup, SUDOERS_DEBUG_AUTH)
/* Rebuild argv for sia_ses_init() */
sudo_argc = NewArgc + 1;
@@ -132,7 +132,7 @@ int
sudo_sia_verify(struct passwd *pw, char *prompt, sudo_auth *auth)
{
SIAENTITY *siah = (SIAENTITY *) auth->data;
debug_decl(sudo_sia_verify, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_sia_verify, SUDOERS_DEBUG_AUTH)
def_prompt = prompt; /* for sudo_collect */
@@ -147,7 +147,7 @@ int
sudo_sia_cleanup(struct passwd *pw, sudo_auth *auth)
{
SIAENTITY *siah = (SIAENTITY *) auth->data;
debug_decl(sudo_sia_cleanup, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_sia_cleanup, SUDOERS_DEBUG_AUTH)
(void) sia_ses_release(&siah);
sudo_efree(sudo_argv);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999-2005, 2008-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 1999-2005, 2008-2015 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
@@ -104,7 +104,7 @@ sudo_auth_init(struct passwd *pw)
{
sudo_auth *auth;
int status = AUTH_SUCCESS;
debug_decl(sudo_auth_init, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_auth_init, SUDOERS_DEBUG_AUTH)
if (auth_switch[0].name == NULL)
debug_return_int(0);
@@ -146,7 +146,7 @@ sudo_auth_cleanup(struct passwd *pw)
{
sudo_auth *auth;
int status = AUTH_SUCCESS;
debug_decl(sudo_auth_cleanup, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_auth_cleanup, SUDOERS_DEBUG_AUTH)
/* Call cleanup routines. */
for (auth = auth_switch; auth->name; auth++) {
@@ -163,7 +163,7 @@ static void
pass_warn(void)
{
const char *warning = def_badpass_message;
debug_decl(pass_warn, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(pass_warn, SUDOERS_DEBUG_AUTH)
#ifdef INSULT
if (def_insults)
@@ -196,7 +196,7 @@ verify_user(struct passwd *pw, char *prompt, int validated)
sudo_auth *auth;
sigset_t mask, omask;
sigaction_t sa, saved_sigtstp;
debug_decl(verify_user, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(verify_user, SUDOERS_DEBUG_AUTH)
/* Make sure we have at least one auth method. */
if (auth_switch[0].name == NULL) {
@@ -316,7 +316,7 @@ sudo_auth_begin_session(struct passwd *pw, char **user_env[])
{
sudo_auth *auth;
int status = AUTH_SUCCESS;
debug_decl(sudo_auth_begin_session, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_auth_begin_session, SUDOERS_DEBUG_AUTH)
for (auth = auth_switch; auth->name; auth++) {
if (auth->begin_session && !IS_DISABLED(auth)) {
@@ -333,7 +333,7 @@ sudo_auth_needs_end_session(void)
{
sudo_auth *auth;
bool needed = false;
debug_decl(sudo_auth_needs_end_session, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_auth_needs_end_session, SUDOERS_DEBUG_AUTH)
for (auth = auth_switch; auth->name; auth++) {
if (auth->end_session && !IS_DISABLED(auth)) {
@@ -353,7 +353,7 @@ sudo_auth_end_session(struct passwd *pw)
{
sudo_auth *auth;
int status = AUTH_SUCCESS;
debug_decl(sudo_auth_end_session, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_auth_end_session, SUDOERS_DEBUG_AUTH)
for (auth = auth_switch; auth->name; auth++) {
if (auth->end_session && !IS_DISABLED(auth)) {
@@ -371,7 +371,7 @@ auth_getpass(const char *prompt, int timeout, int type)
struct sudo_conv_message msg;
struct sudo_conv_reply repl;
sigset_t mask, omask;
debug_decl(auth_getpass, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(auth_getpass, SUDOERS_DEBUG_AUTH)
/* Mask user input if pwfeedback set and echo is off. */
if (type == SUDO_CONV_PROMPT_ECHO_OFF && def_pwfeedback)
@@ -407,7 +407,7 @@ void
dump_auth_methods(void)
{
sudo_auth *auth;
debug_decl(dump_auth_methods, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(dump_auth_methods, SUDOERS_DEBUG_AUTH)
sudo_printf(SUDO_CONV_INFO_MSG, _("Authentication methods:"));
for (auth = auth_switch; auth->name; auth++)

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2013-2015 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
@@ -51,7 +51,7 @@ base64_decode(const char *str, unsigned char *dst, size_t dsize)
unsigned char ch[4];
char *pos;
int i;
debug_decl(base64_decode, SUDOERS_DEBUG_MATCH, sudoers_debug_instance)
debug_decl(base64_decode, SUDOERS_DEBUG_MATCH)
/*
* Convert from base64 to binary. Each base64 char holds 6 bits of data

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2009-2015 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
@@ -72,7 +72,7 @@ get_boottime(struct timeval *tv)
bool found = false;
ssize_t len;
FILE *fp;
debug_decl(get_boottime, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(get_boottime, SUDOERS_DEBUG_UTIL)
/* read btime from /proc/stat */
fp = fopen("/proc/stat", "r");
@@ -102,7 +102,7 @@ get_boottime(struct timeval *tv)
{
size_t size;
int mib[2];
debug_decl(get_boottime, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(get_boottime, SUDOERS_DEBUG_UTIL)
mib[0] = CTL_KERN;
mib[1] = KERN_BOOTTIME;
@@ -119,7 +119,7 @@ bool
get_boottime(struct timeval *tv)
{
struct utmpx *ut, key;
debug_decl(get_boottime, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(get_boottime, SUDOERS_DEBUG_UTIL)
memset(&key, 0, sizeof(key));
key.ut_type = BOOT_TIME;
@@ -138,7 +138,7 @@ bool
get_boottime(struct timeval *tv)
{
struct utmp *ut, key;
debug_decl(get_boottime, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(get_boottime, SUDOERS_DEBUG_UTIL)
memset(&key, 0, sizeof(key));
key.ut_type = BOOT_TIME;
@@ -156,7 +156,7 @@ get_boottime(struct timeval *tv)
bool
get_boottime(struct timeval *tv)
{
debug_decl(get_boottime, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(get_boottime, SUDOERS_DEBUG_UTIL)
debug_return_bool(false);
}
#endif

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2009-2015 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2009 Christian S.J. Peron
*
* Permission to use, copy, modify, and distribute this software for any
@@ -49,7 +49,7 @@ audit_sudo_selected(int sorf)
auditinfo_addr_t ainfo_addr;
struct au_mask *mask;
int rc;
debug_decl(audit_sudo_selected, SUDOERS_DEBUG_AUDIT, sudoers_debug_instance)
debug_decl(audit_sudo_selected, SUDOERS_DEBUG_AUDIT)
if (getaudit_addr(&ainfo_addr, sizeof(ainfo_addr)) < 0) {
if (errno == ENOSYS) {
@@ -84,7 +84,7 @@ bsm_audit_success(char *exec_args[])
long au_cond;
int aufd, selected;
pid_t pid;
debug_decl(bsm_audit_success, SUDOERS_DEBUG_AUDIT, sudoers_debug_instance)
debug_decl(bsm_audit_success, SUDOERS_DEBUG_AUDIT)
/*
* If we are not auditing, don't cut an audit record; just return.
@@ -173,7 +173,7 @@ bsm_audit_failure(char *exec_args[], char const *const fmt, va_list ap)
au_id_t auid;
pid_t pid;
int aufd;
debug_decl(bsm_audit_success, SUDOERS_DEBUG_AUDIT, sudoers_debug_instance)
debug_decl(bsm_audit_success, SUDOERS_DEBUG_AUDIT)
/*
* If we are not auditing, don't cut an audit record; just return.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1993-1996,1998-2005, 2007-2014
* Copyright (c) 1993-1996,1998-2005, 2007-2015
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -63,7 +63,7 @@ static int
check_user_interactive(int validated, int mode, struct passwd *auth_pw)
{
int status, rval = true;
debug_decl(check_user_interactive, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(check_user_interactive, SUDOERS_DEBUG_AUTH)
/* Always need a password when -k was specified with the command. */
if (ISSET(mode, MODE_IGNORE_TICKET))
@@ -121,7 +121,7 @@ check_user(int validated, int mode)
{
struct passwd *auth_pw;
int rval = -1;
debug_decl(check_user, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(check_user, SUDOERS_DEBUG_AUTH)
/*
* Init authentication system regardless of whether we need a password.
@@ -175,7 +175,7 @@ display_lecture(int status)
ssize_t nread;
struct sudo_conv_message msg;
struct sudo_conv_reply repl;
debug_decl(lecture, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(lecture, SUDOERS_DEBUG_AUTH)
if (def_lecture == never ||
(def_lecture == once && already_lectured(status)))
@@ -212,7 +212,7 @@ bool
user_is_exempt(void)
{
bool rval = false;
debug_decl(user_is_exempt, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(user_is_exempt, SUDOERS_DEBUG_AUTH)
if (def_exempt_group)
rval = user_in_group(sudo_user.pw, def_exempt_group);
@@ -228,7 +228,7 @@ static struct passwd *
get_authpw(int mode)
{
struct passwd *pw = NULL;
debug_decl(get_authpw, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(get_authpw, SUDOERS_DEBUG_AUTH)
if (ISSET(mode, (MODE_CHECK|MODE_LIST))) {
/* In list mode we always prompt for the user's password. */

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1999-2005, 2007-2014
* Copyright (c) 1999-2005, 2007-2015
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -118,7 +118,7 @@ dump_defaults(void)
struct list_member *item;
struct def_values *def;
char *desc;
debug_decl(dump_defaults, SUDOERS_DEBUG_DEFAULTS, sudoers_debug_instance)
debug_decl(dump_defaults, SUDOERS_DEBUG_DEFAULTS)
for (cur = sudo_defs_table; cur->name; cur++) {
if (cur->desc) {
@@ -200,7 +200,7 @@ set_default(char *var, char *val, int op)
{
struct sudo_defs_types *cur;
int num;
debug_decl(set_default, SUDOERS_DEBUG_DEFAULTS, sudoers_debug_instance)
debug_decl(set_default, SUDOERS_DEBUG_DEFAULTS)
for (cur = sudo_defs_table, num = 0; cur->name; cur++, num++) {
if (strcmp(var, cur->name) == 0)
@@ -345,7 +345,7 @@ init_defaults(void)
{
static int firsttime = 1;
struct sudo_defs_types *def;
debug_decl(init_defaults, SUDOERS_DEBUG_DEFAULTS, sudoers_debug_instance)
debug_decl(init_defaults, SUDOERS_DEBUG_DEFAULTS)
/* Clear any old settings. */
if (!firsttime) {
@@ -508,7 +508,7 @@ update_defaults(int what)
{
struct defaults *def;
bool rc = true;
debug_decl(update_defaults, SUDOERS_DEBUG_DEFAULTS, sudoers_debug_instance)
debug_decl(update_defaults, SUDOERS_DEBUG_DEFAULTS)
TAILQ_FOREACH(def, &defaults, entries) {
switch (def->type) {
@@ -567,7 +567,7 @@ check_defaults(int what, bool quiet)
struct sudo_defs_types *cur;
struct defaults *def;
bool rc = true;
debug_decl(check_defaults, SUDOERS_DEBUG_DEFAULTS, sudoers_debug_instance)
debug_decl(check_defaults, SUDOERS_DEBUG_DEFAULTS)
TAILQ_FOREACH(def, &defaults, entries) {
switch (def->type) {
@@ -610,7 +610,7 @@ store_int(char *val, struct sudo_defs_types *def, int op)
{
const char *errstr;
int i;
debug_decl(store_int, SUDOERS_DEBUG_DEFAULTS, sudoers_debug_instance)
debug_decl(store_int, SUDOERS_DEBUG_DEFAULTS)
if (op == false) {
def->sd_un.ival = 0;
@@ -633,7 +633,7 @@ store_uint(char *val, struct sudo_defs_types *def, int op)
{
const char *errstr;
unsigned int u;
debug_decl(store_uint, SUDOERS_DEBUG_DEFAULTS, sudoers_debug_instance)
debug_decl(store_uint, SUDOERS_DEBUG_DEFAULTS)
if (op == false) {
def->sd_un.uival = 0;
@@ -656,7 +656,7 @@ store_float(char *val, struct sudo_defs_types *def, int op)
{
char *endp;
double d;
debug_decl(store_float, SUDOERS_DEBUG_DEFAULTS, sudoers_debug_instance)
debug_decl(store_float, SUDOERS_DEBUG_DEFAULTS)
if (op == false) {
def->sd_un.fval = 0.0;
@@ -676,7 +676,7 @@ static bool
store_tuple(char *val, struct sudo_defs_types *def, int op)
{
struct def_values *v;
debug_decl(store_tuple, SUDOERS_DEBUG_DEFAULTS, sudoers_debug_instance)
debug_decl(store_tuple, SUDOERS_DEBUG_DEFAULTS)
/*
* Look up tuple value by name to find enum def_tuple value.
@@ -703,7 +703,7 @@ store_tuple(char *val, struct sudo_defs_types *def, int op)
static bool
store_str(char *val, struct sudo_defs_types *def, int op)
{
debug_decl(store_str, SUDOERS_DEBUG_DEFAULTS, sudoers_debug_instance)
debug_decl(store_str, SUDOERS_DEBUG_DEFAULTS)
sudo_efree(def->sd_un.str);
if (op == false)
@@ -719,7 +719,7 @@ static bool
store_list(char *str, struct sudo_defs_types *def, int op)
{
char *start, *end;
debug_decl(store_list, SUDOERS_DEBUG_DEFAULTS, sudoers_debug_instance)
debug_decl(store_list, SUDOERS_DEBUG_DEFAULTS)
/* Remove all old members. */
if (op == false || op == true)
@@ -748,7 +748,7 @@ static bool
store_syslogfac(char *val, struct sudo_defs_types *def, int op)
{
struct strmap *fac;
debug_decl(store_syslogfac, SUDOERS_DEBUG_DEFAULTS, sudoers_debug_instance)
debug_decl(store_syslogfac, SUDOERS_DEBUG_DEFAULTS)
if (op == false) {
def->sd_un.ival = false;
@@ -774,7 +774,7 @@ logfac2str(int n)
{
#ifdef LOG_NFACILITIES
struct strmap *fac;
debug_decl(logfac2str, SUDOERS_DEBUG_DEFAULTS, sudoers_debug_instance)
debug_decl(logfac2str, SUDOERS_DEBUG_DEFAULTS)
for (fac = facilities; fac->name && fac->num != n; fac++)
;
@@ -788,7 +788,7 @@ static bool
store_syslogpri(char *val, struct sudo_defs_types *def, int op)
{
struct strmap *pri;
debug_decl(store_syslogpri, SUDOERS_DEBUG_DEFAULTS, sudoers_debug_instance)
debug_decl(store_syslogpri, SUDOERS_DEBUG_DEFAULTS)
if (op == false || !val)
debug_return_bool(false);
@@ -806,7 +806,7 @@ static const char *
logpri2str(int n)
{
struct strmap *pri;
debug_decl(logpri2str, SUDOERS_DEBUG_DEFAULTS, sudoers_debug_instance)
debug_decl(logpri2str, SUDOERS_DEBUG_DEFAULTS)
for (pri = priorities; pri->name && pri->num != n; pri++)
;
@@ -818,7 +818,7 @@ store_mode(char *val, struct sudo_defs_types *def, int op)
{
mode_t mode;
const char *errstr;
debug_decl(store_mode, SUDOERS_DEBUG_DEFAULTS, sudoers_debug_instance)
debug_decl(store_mode, SUDOERS_DEBUG_DEFAULTS)
if (op == false) {
def->sd_un.mode = 0777;
@@ -840,7 +840,7 @@ static void
list_op(char *val, size_t len, struct sudo_defs_types *def, enum list_ops op)
{
struct list_member *cur, *prev = NULL;
debug_decl(list_op, SUDOERS_DEBUG_DEFAULTS, sudoers_debug_instance)
debug_decl(list_op, SUDOERS_DEBUG_DEFAULTS)
if (op == freeall) {
while ((cur = SLIST_FIRST(&def->sd_un.list)) != NULL) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000-2005, 2007-2014
* Copyright (c) 2000-2005, 2007-2015
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -214,7 +214,7 @@ env_init(char * const envp[])
{
char * const *ep;
size_t len;
debug_decl(env_init, SUDOERS_DEBUG_ENV, sudoers_debug_instance)
debug_decl(env_init, SUDOERS_DEBUG_ENV)
if (envp == NULL) {
/* Reset to initial state but keep a pointer to what we allocated. */
@@ -348,7 +348,7 @@ static int
sudo_putenv(char *str, bool dupcheck, bool overwrite)
{
int rval;
debug_decl(sudo_putenv, SUDOERS_DEBUG_ENV, sudoers_debug_instance)
debug_decl(sudo_putenv, SUDOERS_DEBUG_ENV)
sudo_debug_printf(SUDO_DEBUG_INFO, "sudo_putenv: %s", str);
@@ -373,7 +373,7 @@ sudo_setenv2(const char *var, const char *val, bool dupcheck, bool overwrite)
char *estring;
size_t esize;
int rval = -1;
debug_decl(sudo_setenv2, SUDOERS_DEBUG_ENV, sudoers_debug_instance)
debug_decl(sudo_setenv2, SUDOERS_DEBUG_ENV)
esize = strlen(var) + 1 + strlen(val) + 1;
estring = sudo_emalloc(esize);
@@ -488,7 +488,7 @@ int
sudo_unsetenv(const char *name)
{
int rval;
debug_decl(sudo_unsetenv, SUDOERS_DEBUG_ENV, sudoers_debug_instance)
debug_decl(sudo_unsetenv, SUDOERS_DEBUG_ENV)
sudo_debug_printf(SUDO_DEBUG_INFO, "sudo_unsetenv: %s", name);
@@ -528,7 +528,7 @@ char *
sudo_getenv(const char *name)
{
char *val;
debug_decl(sudo_getenv, SUDOERS_DEBUG_ENV, sudoers_debug_instance)
debug_decl(sudo_getenv, SUDOERS_DEBUG_ENV)
sudo_debug_printf(SUDO_DEBUG_INFO, "sudo_getenv: %s", name);
@@ -546,7 +546,7 @@ matches_env_list(const char *var, struct list_members *list, bool *full_match)
{
struct list_member *cur;
bool match = false;
debug_decl(matches_env_list, SUDOERS_DEBUG_ENV, sudoers_debug_instance)
debug_decl(matches_env_list, SUDOERS_DEBUG_ENV)
SLIST_FOREACH(cur, list, entries) {
size_t sep_pos, len = strlen(cur->value);
@@ -579,7 +579,7 @@ static bool
matches_env_delete(const char *var)
{
bool full_match; /* unused */
debug_decl(matches_env_delete, SUDOERS_DEBUG_ENV, sudoers_debug_instance)
debug_decl(matches_env_delete, SUDOERS_DEBUG_ENV)
/* Skip anything listed in env_delete. */
debug_return_bool(matches_env_list(var, &def_env_delete, &full_match));
@@ -594,7 +594,7 @@ static int
matches_env_check(const char *var, bool *full_match)
{
int keepit = -1;
debug_decl(matches_env_check, SUDOERS_DEBUG_ENV, sudoers_debug_instance)
debug_decl(matches_env_check, SUDOERS_DEBUG_ENV)
/* Skip anything listed in env_check that includes '/' or '%'. */
if (matches_env_list(var, &def_env_check, full_match)) {
@@ -613,7 +613,7 @@ static bool
matches_env_keep(const char *var, bool *full_match)
{
bool keepit = false;
debug_decl(matches_env_keep, SUDOERS_DEBUG_ENV, sudoers_debug_instance)
debug_decl(matches_env_keep, SUDOERS_DEBUG_ENV)
/* Preserve SHELL variable for "sudo -s". */
if (ISSET(sudo_mode, MODE_SHELL) && strncmp(var, "SHELL=", 6) == 0) {
@@ -634,7 +634,7 @@ env_should_delete(const char *var)
const char *cp;
int delete_it;
bool full_match = false;
debug_decl(env_should_delete, SUDOERS_DEBUG_ENV, sudoers_debug_instance);
debug_decl(env_should_delete, SUDOERS_DEBUG_ENV);
/* Skip variables with values beginning with () (bash functions) */
if ((cp = strchr(var, '=')) != NULL) {
@@ -664,7 +664,7 @@ env_should_keep(const char *var)
int keepit;
bool full_match = false;
const char *cp;
debug_decl(env_should_keep, SUDOERS_DEBUG_ENV, sudoers_debug_instance)
debug_decl(env_should_keep, SUDOERS_DEBUG_ENV)
keepit = matches_env_check(var, &full_match);
if (keepit == -1)
@@ -694,7 +694,7 @@ env_merge(char * const envp[])
{
char * const *ep;
bool rval = true;
debug_decl(env_merge, SUDOERS_DEBUG_ENV, sudoers_debug_instance)
debug_decl(env_merge, SUDOERS_DEBUG_ENV)
for (ep = envp; *ep != NULL; ep++) {
/* XXX - avoid checking value here, should only check name */
@@ -759,7 +759,7 @@ rebuild_env(void)
char idbuf[MAX_UID_T_LEN + 1];
unsigned int didvar;
bool reset_home = false;
debug_decl(rebuild_env, SUDOERS_DEBUG_ENV, sudoers_debug_instance)
debug_decl(rebuild_env, SUDOERS_DEBUG_ENV)
/*
* Either clean out the environment or reset to a safe default.
@@ -985,7 +985,7 @@ insert_env_vars(char * const envp[])
{
char * const *ep;
bool rval = true;
debug_decl(insert_env_vars, SUDOERS_DEBUG_ENV, sudoers_debug_instance)
debug_decl(insert_env_vars, SUDOERS_DEBUG_ENV)
/* Add user-specified environment variables. */
if (envp != NULL) {
@@ -1013,7 +1013,7 @@ validate_env_vars(char * const env_vars[])
char *eq, *bad = NULL;
size_t len, blen = 0, bsize = 0;
bool okvar, rval = true;
debug_decl(validate_env_vars, SUDOERS_DEBUG_ENV, sudoers_debug_instance)
debug_decl(validate_env_vars, SUDOERS_DEBUG_ENV)
if (env_vars == NULL)
debug_return_bool(true); /* nothing to do */
@@ -1075,7 +1075,7 @@ read_env_file(const char *path, int overwrite)
bool rval = true;
char *cp, *var, *val, *line = NULL;
size_t var_len, val_len, linesize = 0;
debug_decl(read_env_file, SUDOERS_DEBUG_ENV, sudoers_debug_instance)
debug_decl(read_env_file, SUDOERS_DEBUG_ENV)
if ((fp = fopen(path, "r")) == NULL) {
if (errno != ENOENT)

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 1998-2005, 2010-2014
* Copyright (c) 1996, 1998-2005, 2010-2015
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -62,7 +62,7 @@ find_path(char *infile, char **outfile, struct stat *sbp, char *path,
bool found = false; /* did we find the command? */
bool checkdot = false; /* check current dir? */
int len; /* length parameter */
debug_decl(find_path, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(find_path, SUDOERS_DEBUG_UTIL)
if (strlen(infile) >= PATH_MAX) {
errno = ENAMETOOLONG;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 1998-2005, 2010-2012, 2014
* Copyright (c) 1996, 1998-2005, 2010-2012, 2014-2015
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -81,7 +81,7 @@ char *
sudo_getepw(const struct passwd *pw)
{
char *epw = NULL;
debug_decl(sudo_getepw, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_getepw, SUDOERS_DEBUG_AUTH)
/* If there is a function to check for shadow enabled, use it... */
#ifdef HAVE_ISCOMSEC
@@ -148,7 +148,7 @@ done:
void
sudo_setspent(void)
{
debug_decl(sudo_setspent, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_setspent, SUDOERS_DEBUG_AUTH)
#ifdef HAVE_GETPRPWNAM
setprpwent();
@@ -171,7 +171,7 @@ sudo_setspent(void)
void
sudo_endspent(void)
{
debug_decl(sudo_endspent, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(sudo_endspent, SUDOERS_DEBUG_AUTH)
#ifdef HAVE_GETPRPWNAM
endprpwent();

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 1998-2005, 2010-2012, 2014
* Copyright (c) 1996, 1998-2005, 2010-2012, 2014-2015
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -45,7 +45,7 @@ sudo_goodpath(const char *path, struct stat *sbp)
{
struct stat sb;
bool rval = false;
debug_decl(sudo_goodpath, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(sudo_goodpath, SUDOERS_DEBUG_UTIL)
if (path != NULL && stat(path, &sb) == 0) {
/* Make sure path describes an executable regular file. */

View File

@@ -38,7 +38,7 @@
#define YYPREFIX "sudoers"
#line 2 "gram.y"
/*
* Copyright (c) 1996, 1998-2005, 2007-2013, 2014
* Copyright (c) 1996, 1998-2005, 2007-2013, 2014-2015
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -687,7 +687,7 @@ unsigned int yystacksize;
void
sudoerserror(const char *s)
{
debug_decl(sudoerserror, SUDOERS_DEBUG_PARSER, sudoers_debug_instance)
debug_decl(sudoerserror, SUDOERS_DEBUG_PARSER)
/* If we last saw a newline the error is on the preceding line. */
if (last_token == COMMENT)
@@ -720,7 +720,7 @@ static struct defaults *
new_default(char *var, char *val, int op)
{
struct defaults *d;
debug_decl(new_default, SUDOERS_DEBUG_PARSER, sudoers_debug_instance)
debug_decl(new_default, SUDOERS_DEBUG_PARSER)
d = sudo_ecalloc(1, sizeof(struct defaults));
d->var = var;
@@ -737,7 +737,7 @@ static struct member *
new_member(char *name, int type)
{
struct member *m;
debug_decl(new_member, SUDOERS_DEBUG_PARSER, sudoers_debug_instance)
debug_decl(new_member, SUDOERS_DEBUG_PARSER)
m = sudo_ecalloc(1, sizeof(struct member));
m->name = name;
@@ -751,7 +751,7 @@ struct sudo_digest *
new_digest(int digest_type, const char *digest_str)
{
struct sudo_digest *dig;
debug_decl(new_digest, SUDOERS_DEBUG_PARSER, sudoers_debug_instance)
debug_decl(new_digest, SUDOERS_DEBUG_PARSER)
dig = sudo_emalloc(sizeof(*dig));
dig->digest_type = digest_type;
@@ -770,7 +770,7 @@ add_defaults(int type, struct member *bmem, struct defaults *defs)
{
struct defaults *d;
struct member_list *binding;
debug_decl(add_defaults, SUDOERS_DEBUG_PARSER, sudoers_debug_instance)
debug_decl(add_defaults, SUDOERS_DEBUG_PARSER)
if (defs != NULL) {
/*
@@ -804,7 +804,7 @@ static void
add_userspec(struct member *members, struct privilege *privs)
{
struct userspec *u;
debug_decl(add_userspec, SUDOERS_DEBUG_PARSER, sudoers_debug_instance)
debug_decl(add_userspec, SUDOERS_DEBUG_PARSER)
u = sudo_ecalloc(1, sizeof(*u));
HLTQ_TO_TAILQ(&u->users, members, entries);
@@ -824,7 +824,7 @@ init_parser(const char *path, bool quiet)
struct member_list *binding;
struct defaults *d, *d_next;
struct userspec *us, *us_next;
debug_decl(init_parser, SUDOERS_DEBUG_PARSER, sudoers_debug_instance)
debug_decl(init_parser, SUDOERS_DEBUG_PARSER)
TAILQ_FOREACH_SAFE(us, &userspecs, entries, us_next) {
struct member *m, *m_next;

View File

@@ -1,6 +1,6 @@
%{
/*
* Copyright (c) 1996, 1998-2005, 2007-2013, 2014
* Copyright (c) 1996, 1998-2005, 2007-2013, 2014-2015
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -675,7 +675,7 @@ group : ALIAS {
void
sudoerserror(const char *s)
{
debug_decl(sudoerserror, SUDOERS_DEBUG_PARSER, sudoers_debug_instance)
debug_decl(sudoerserror, SUDOERS_DEBUG_PARSER)
/* If we last saw a newline the error is on the preceding line. */
if (last_token == COMMENT)
@@ -708,7 +708,7 @@ static struct defaults *
new_default(char *var, char *val, int op)
{
struct defaults *d;
debug_decl(new_default, SUDOERS_DEBUG_PARSER, sudoers_debug_instance)
debug_decl(new_default, SUDOERS_DEBUG_PARSER)
d = sudo_ecalloc(1, sizeof(struct defaults));
d->var = var;
@@ -725,7 +725,7 @@ static struct member *
new_member(char *name, int type)
{
struct member *m;
debug_decl(new_member, SUDOERS_DEBUG_PARSER, sudoers_debug_instance)
debug_decl(new_member, SUDOERS_DEBUG_PARSER)
m = sudo_ecalloc(1, sizeof(struct member));
m->name = name;
@@ -739,7 +739,7 @@ struct sudo_digest *
new_digest(int digest_type, const char *digest_str)
{
struct sudo_digest *dig;
debug_decl(new_digest, SUDOERS_DEBUG_PARSER, sudoers_debug_instance)
debug_decl(new_digest, SUDOERS_DEBUG_PARSER)
dig = sudo_emalloc(sizeof(*dig));
dig->digest_type = digest_type;
@@ -758,7 +758,7 @@ add_defaults(int type, struct member *bmem, struct defaults *defs)
{
struct defaults *d;
struct member_list *binding;
debug_decl(add_defaults, SUDOERS_DEBUG_PARSER, sudoers_debug_instance)
debug_decl(add_defaults, SUDOERS_DEBUG_PARSER)
if (defs != NULL) {
/*
@@ -792,7 +792,7 @@ static void
add_userspec(struct member *members, struct privilege *privs)
{
struct userspec *u;
debug_decl(add_userspec, SUDOERS_DEBUG_PARSER, sudoers_debug_instance)
debug_decl(add_userspec, SUDOERS_DEBUG_PARSER)
u = sudo_ecalloc(1, sizeof(*u));
HLTQ_TO_TAILQ(&u->users, members, entries);
@@ -812,7 +812,7 @@ init_parser(const char *path, bool quiet)
struct member_list *binding;
struct defaults *d, *d_next;
struct userspec *us, *us_next;
debug_decl(init_parser, SUDOERS_DEBUG_PARSER, sudoers_debug_instance)
debug_decl(init_parser, SUDOERS_DEBUG_PARSER)
TAILQ_FOREACH_SAFE(us, &userspecs, entries, us_next) {
struct member *m, *m_next;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2010-2015 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
@@ -64,7 +64,7 @@ group_plugin_load(char *plugin_info)
char *args, path[PATH_MAX];
char **argv = NULL;
int len, rc = -1;
debug_decl(group_plugin_load, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(group_plugin_load, SUDOERS_DEBUG_UTIL)
/*
* Fill in .so path and split out args (if any).
@@ -161,7 +161,7 @@ done:
void
group_plugin_unload(void)
{
debug_decl(group_plugin_unload, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(group_plugin_unload, SUDOERS_DEBUG_UTIL)
if (group_plugin != NULL) {
(group_plugin->cleanup)();
@@ -178,7 +178,7 @@ int
group_plugin_query(const char *user, const char *group,
const struct passwd *pwd)
{
debug_decl(group_plugin_query, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(group_plugin_query, SUDOERS_DEBUG_UTIL)
if (group_plugin == NULL)
debug_return_bool(false);
@@ -194,14 +194,14 @@ group_plugin_query(const char *user, const char *group,
int
group_plugin_load(char *plugin_info)
{
debug_decl(group_plugin_load, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(group_plugin_load, SUDOERS_DEBUG_UTIL)
debug_return_bool(false);
}
void
group_plugin_unload(void)
{
debug_decl(group_plugin_unload, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(group_plugin_unload, SUDOERS_DEBUG_UTIL)
debug_return;
}
@@ -209,7 +209,7 @@ int
group_plugin_query(const char *user, const char *group,
const struct passwd *pwd)
{
debug_decl(group_plugin_query, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(group_plugin_query, SUDOERS_DEBUG_UTIL)
debug_return_bool(false);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2013-2015 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
@@ -30,7 +30,7 @@ hexchar(const char *s)
{
unsigned char result[2];
int i;
debug_decl(hexchar, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(hexchar, SUDOERS_DEBUG_UTIL)
for (i = 0; i < 2; i++) {
switch (s[i]) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2010-2015 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
@@ -62,7 +62,7 @@ set_interfaces(const char *ai)
{
char *addrinfo, *addr, *mask;
struct interface *ifp;
debug_decl(set_interfaces, SUDOERS_DEBUG_NETIF, sudoers_debug_instance)
debug_decl(set_interfaces, SUDOERS_DEBUG_NETIF)
addrinfo = sudo_estrdup(ai);
for (addr = strtok(addrinfo, " \t"); addr != NULL; addr = strtok(NULL, " \t")) {
@@ -109,7 +109,7 @@ void
dump_interfaces(const char *ai)
{
char *cp, *addrinfo;
debug_decl(set_interfaces, SUDOERS_DEBUG_NETIF, sudoers_debug_instance)
debug_decl(set_interfaces, SUDOERS_DEBUG_NETIF)
addrinfo = sudo_estrdup(ai);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2009-2015 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
@@ -92,7 +92,7 @@ io_mkdirs(char *path, mode_t mode, bool is_temp)
gid_t parent_gid = 0;
char *slash = path;
bool ok = true;
debug_decl(io_mkdirs, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(io_mkdirs, SUDOERS_DEBUG_UTIL)
/* Fast path: not a temporary and already exists. */
if (!is_temp && stat(path, &sb) == 0) {
@@ -155,7 +155,7 @@ io_set_max_sessid(const char *maxval)
{
const char *errstr;
unsigned int value;
debug_decl(io_set_max_sessid, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(io_set_max_sessid, SUDOERS_DEBUG_UTIL)
value = strtonum(maxval, 0, SESSID_MAX, &errstr);
if (errstr != NULL) {
@@ -187,7 +187,7 @@ io_nextid(char *iolog_dir, char *iolog_dir_fallback, char sessid[7])
ssize_t nread;
char pathbuf[PATH_MAX];
static const char b36char[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
debug_decl(io_nextid, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(io_nextid, SUDOERS_DEBUG_UTIL)
/*
* Create I/O log directory if it doesn't already exist.
@@ -297,7 +297,7 @@ mkdir_iopath(const char *iolog_path, char *pathbuf, size_t pathsize)
{
size_t len;
bool is_temp = false;
debug_decl(mkdir_iopath, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(mkdir_iopath, SUDOERS_DEBUG_UTIL)
len = strlcpy(pathbuf, iolog_path, pathsize);
if (len >= pathsize) {
@@ -328,7 +328,7 @@ static bool
open_io_fd(char *pathbuf, size_t len, struct io_log_file *iol, bool docompress)
{
int fd;
debug_decl(open_io_fd, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(open_io_fd, SUDOERS_DEBUG_UTIL)
pathbuf[len] = '\0';
strlcat(pathbuf, iol->suffix, PATH_MAX);
@@ -370,7 +370,7 @@ iolog_deserialize_info(struct iolog_details *details, char * const user_info[],
id_t id;
uid_t runas_uid = 0;
gid_t runas_gid = 0;
debug_decl(iolog_deserialize_info, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(iolog_deserialize_info, SUDOERS_DEBUG_UTIL)
details->lines = 24;
details->cols = 80;
@@ -536,7 +536,7 @@ write_info_log(char *pathbuf, size_t len, struct iolog_details *details,
char * const *av;
FILE *fp;
int fd;
debug_decl(write_info_log, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(write_info_log, SUDOERS_DEBUG_UTIL)
pathbuf[len] = '\0';
strlcat(pathbuf, "/log", PATH_MAX);
@@ -574,7 +574,7 @@ sudoers_io_open(unsigned int version, sudo_conv_t conversation,
const char *plugin_path = NULL;
size_t len;
int i, rval = -1;
debug_decl(sudoers_io_open, SUDOERS_DEBUG_PLUGIN, sudoers_debug_instance)
debug_decl(sudoers_io_open, SUDOERS_DEBUG_PLUGIN)
sudo_conv = conversation;
sudo_printf = plugin_printf;
@@ -677,7 +677,7 @@ static void
sudoers_io_close(int exit_status, int error)
{
int i;
debug_decl(sudoers_io_close, SUDOERS_DEBUG_PLUGIN, sudoers_debug_instance)
debug_decl(sudoers_io_close, SUDOERS_DEBUG_PLUGIN)
for (i = 0; i < IOFD_MAX; i++) {
if (io_log_files[i].fd.v == NULL)
@@ -698,7 +698,7 @@ sudoers_io_close(int exit_status, int error)
static int
sudoers_io_version(int verbose)
{
debug_decl(sudoers_io_version, SUDOERS_DEBUG_PLUGIN, sudoers_debug_instance)
debug_decl(sudoers_io_version, SUDOERS_DEBUG_PLUGIN)
sudo_printf(SUDO_CONV_INFO_MSG, "Sudoers I/O plugin version %s\n",
PACKAGE_VERSION);
@@ -714,7 +714,7 @@ sudoers_io_log(const char *buf, unsigned int len, int idx)
{
struct timeval now, delay;
int rval = true;
debug_decl(sudoers_io_version, SUDOERS_DEBUG_PLUGIN, sudoers_debug_instance)
debug_decl(sudoers_io_version, SUDOERS_DEBUG_PLUGIN)
gettimeofday(&now, NULL);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2011-2015 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
@@ -50,12 +50,12 @@ static size_t
fill_seq(char *str, size_t strsize, char *logdir)
{
#ifdef SUDOERS_NO_SEQ
debug_decl(fill_seq, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(fill_seq, SUDOERS_DEBUG_UTIL)
debug_return_size_t(strlcpy(str, "%{seq}", strsize));
#else
static char sessid[7];
int len;
debug_decl(fill_seq, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(fill_seq, SUDOERS_DEBUG_UTIL)
if (sessid[0] == '\0') {
if (!io_nextid(logdir, def_iolog_dir, sessid))
@@ -74,7 +74,7 @@ fill_seq(char *str, size_t strsize, char *logdir)
static size_t
fill_user(char *str, size_t strsize, char *unused)
{
debug_decl(fill_user, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(fill_user, SUDOERS_DEBUG_UTIL)
debug_return_size_t(strlcpy(str, user_name, strsize));
}
@@ -83,7 +83,7 @@ fill_group(char *str, size_t strsize, char *unused)
{
struct group *grp;
size_t len;
debug_decl(fill_group, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(fill_group, SUDOERS_DEBUG_UTIL)
if ((grp = sudo_getgrgid(user_gid)) != NULL) {
len = strlcpy(str, grp->gr_name, strsize);
@@ -99,7 +99,7 @@ fill_group(char *str, size_t strsize, char *unused)
static size_t
fill_runas_user(char *str, size_t strsize, char *unused)
{
debug_decl(fill_runas_user, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(fill_runas_user, SUDOERS_DEBUG_UTIL)
debug_return_size_t(strlcpy(str, runas_pw->pw_name, strsize));
}
@@ -108,7 +108,7 @@ fill_runas_group(char *str, size_t strsize, char *unused)
{
struct group *grp;
size_t len;
debug_decl(fill_runas_group, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(fill_runas_group, SUDOERS_DEBUG_UTIL)
if (runas_gr != NULL) {
len = strlcpy(str, runas_gr->gr_name, strsize);
@@ -128,14 +128,14 @@ fill_runas_group(char *str, size_t strsize, char *unused)
static size_t
fill_hostname(char *str, size_t strsize, char *unused)
{
debug_decl(fill_hostname, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(fill_hostname, SUDOERS_DEBUG_UTIL)
debug_return_size_t(strlcpy(str, user_shost, strsize));
}
static size_t
fill_command(char *str, size_t strsize, char *unused)
{
debug_decl(fill_command, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(fill_command, SUDOERS_DEBUG_UTIL)
debug_return_size_t(strlcpy(str, user_base, strsize));
}
@@ -167,7 +167,7 @@ expand_iolog_path(const char *prefix, const char *dir, const char *file,
struct path_escape *escapes = NULL;
int pass, oldlocale;
bool strfit;
debug_decl(expand_iolog_path, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(expand_iolog_path, SUDOERS_DEBUG_UTIL)
/* Expanded path must be <= PATH_MAX */
if (prefix != NULL)

View File

@@ -427,7 +427,7 @@ sudo_ldap_conf_add_ports(void)
char *host, *port, defport[13];
char hostbuf[LINE_MAX * 2];
int len;
debug_decl(sudo_ldap_conf_add_ports, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_conf_add_ports, SUDOERS_DEBUG_LDAP)
hostbuf[0] = '\0';
len = snprintf(defport, sizeof(defport), ":%d", ldap_conf.port);
@@ -473,7 +473,7 @@ sudo_ldap_parse_uri(const struct ldap_config_str_list *uri_list)
char hostbuf[LINE_MAX];
int nldap = 0, nldaps = 0;
int rc = -1;
debug_decl(sudo_ldap_parse_uri, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_parse_uri, SUDOERS_DEBUG_LDAP)
hostbuf[0] = '\0';
STAILQ_FOREACH(entry, uri_list, entries) {
@@ -545,7 +545,7 @@ sudo_ldap_join_uri(struct ldap_config_str_list *uri_list)
struct ldap_config_str *uri;
size_t len = 0;
char *buf, *cp;
debug_decl(sudo_ldap_join_uri, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_join_uri, SUDOERS_DEBUG_LDAP)
STAILQ_FOREACH(uri, uri_list, entries) {
if (ldap_conf.ssl_mode == SUDO_LDAP_STARTTLS) {
@@ -577,7 +577,7 @@ sudo_ldap_init(LDAP **ldp, const char *host, int port)
{
LDAP *ld;
int rc = LDAP_CONNECT_ERROR;
debug_decl(sudo_ldap_init, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_init, SUDOERS_DEBUG_LDAP)
#ifdef HAVE_LDAPSSL_INIT
if (ldap_conf.ssl_mode != SUDO_LDAP_CLEAR) {
@@ -674,7 +674,7 @@ sudo_ldap_check_non_unix_group(LDAP *ld, LDAPMessage *entry, struct passwd *pw)
struct berval **bv, **p;
char *val;
int ret = false;
debug_decl(sudo_ldap_check_non_unix_group, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_check_non_unix_group, SUDOERS_DEBUG_LDAP)
if (!entry)
debug_return_bool(ret);
@@ -715,7 +715,7 @@ sudo_ldap_check_host(LDAP *ld, LDAPMessage *entry)
struct berval **bv, **p;
char *val;
bool ret = false;
debug_decl(sudo_ldap_check_host, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_check_host, SUDOERS_DEBUG_LDAP)
if (!entry)
debug_return_bool(ret);
@@ -747,7 +747,7 @@ sudo_ldap_check_runas_user(LDAP *ld, LDAPMessage *entry)
struct berval **bv, **p;
char *val;
bool ret = false;
debug_decl(sudo_ldap_check_runas_user, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_check_runas_user, SUDOERS_DEBUG_LDAP)
if (!runas_pw)
debug_return_bool(UNSPEC);
@@ -818,7 +818,7 @@ sudo_ldap_check_runas_group(LDAP *ld, LDAPMessage *entry)
struct berval **bv, **p;
char *val;
bool ret = false;
debug_decl(sudo_ldap_check_runas_group, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_check_runas_group, SUDOERS_DEBUG_LDAP)
/* runas_gr is only set if the user specified the -g flag */
if (!runas_gr)
@@ -851,7 +851,7 @@ static bool
sudo_ldap_check_runas(LDAP *ld, LDAPMessage *entry)
{
bool ret;
debug_decl(sudo_ldap_check_runas, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_check_runas, SUDOERS_DEBUG_LDAP)
if (!entry)
debug_return_bool(false);
@@ -867,7 +867,7 @@ sudo_ldap_extract_digest(char **cmnd, struct sudo_digest *digest)
{
char *ep, *cp = *cmnd;
int digest_type = SUDO_DIGEST_INVALID;
debug_decl(sudo_ldap_check_command, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_check_command, SUDOERS_DEBUG_LDAP)
/*
* Check for and extract a digest prefix, e.g.
@@ -933,7 +933,7 @@ sudo_ldap_check_command(LDAP *ld, LDAPMessage *entry, int *setenv_implied)
char *allowed_cmnd, *allowed_args, *val;
bool foundbang;
int ret = UNSPEC;
debug_decl(sudo_ldap_check_command, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_check_command, SUDOERS_DEBUG_LDAP)
if (!entry)
debug_return_bool(ret);
@@ -1001,7 +1001,7 @@ sudo_ldap_check_bool(LDAP *ld, LDAPMessage *entry, char *option)
struct berval **bv, **p;
char ch, *var;
int ret = UNSPEC;
debug_decl(sudo_ldap_check_bool, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_check_bool, SUDOERS_DEBUG_LDAP)
if (entry == NULL)
debug_return_bool(ret);
@@ -1035,7 +1035,7 @@ sudo_ldap_parse_options(LDAP *ld, LDAPMessage *entry)
{
struct berval **bv, **p;
char op, *var, *val;
debug_decl(sudo_ldap_parse_options, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_parse_options, SUDOERS_DEBUG_LDAP)
if (entry == NULL)
debug_return;
@@ -1106,7 +1106,7 @@ sudo_ldap_timefilter(char *buffer, size_t buffersize)
time_t now;
char timebuffer[sizeof("20120727121554.0Z")];
int bytes = 0;
debug_decl(sudo_ldap_timefilter, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_timefilter, SUDOERS_DEBUG_LDAP)
/* Make sure we have a formatted timestamp for __now__. */
time(&now);
@@ -1140,7 +1140,7 @@ static char *
sudo_ldap_build_default_filter(void)
{
char *filt;
debug_decl(sudo_ldap_build_default_filter, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_build_default_filter, SUDOERS_DEBUG_LDAP)
if (ldap_conf.search_filter)
sudo_easprintf(&filt, "(&%s(cn=defaults))", ldap_conf.search_filter);
@@ -1257,7 +1257,7 @@ sudo_netgroup_lookup_nested(LDAP *ld, char *base, struct timeval *timeout,
size_t filt_len;
char *filt;
int rc;
debug_decl(sudo_netgroup_lookup_nested, SUDOERS_DEBUG_LDAP, sudoers_debug_instance);
debug_decl(sudo_netgroup_lookup_nested, SUDOERS_DEBUG_LDAP);
DPRINTF1("Checking for nested netgroups from netgroup_base '%s'", base);
do {
@@ -1333,7 +1333,7 @@ sudo_netgroup_lookup(LDAP *ld, struct passwd *pw,
size_t filt_len;
char *filt;
int rc;
debug_decl(sudo_netgroup_lookup, SUDOERS_DEBUG_LDAP, sudoers_debug_instance);
debug_decl(sudo_netgroup_lookup, SUDOERS_DEBUG_LDAP);
if (ldap_conf.timeout > 0) {
tv.tv_sec = ldap_conf.timeout;
@@ -1488,7 +1488,7 @@ sudo_ldap_build_pass1(LDAP *ld, struct passwd *pw)
struct group *grp;
size_t sz = 0;
int i;
debug_decl(sudo_ldap_build_pass1, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_build_pass1, SUDOERS_DEBUG_LDAP)
STAILQ_INIT(&netgroups);
@@ -1633,7 +1633,7 @@ sudo_ldap_build_pass2(void)
{
char *filt, timebuffer[TIMEFILTER_LENGTH + 1];
bool query_netgroups = def_use_netgroups;
debug_decl(sudo_ldap_build_pass2, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_build_pass2, SUDOERS_DEBUG_LDAP)
/* No need to query netgroups if using netgroup_base. */
if (!STAILQ_EMPTY(&ldap_conf.netgroup_base))
@@ -1677,7 +1677,7 @@ sudo_ldap_decode_secret(const char *secret)
{
unsigned char *result = NULL;
size_t len, reslen;
debug_decl(sudo_ldap_decode_secret, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_decode_secret, SUDOERS_DEBUG_LDAP)
if (strncasecmp(secret, "base64:", sizeof("base64:") - 1) == 0) {
/*
@@ -1703,7 +1703,7 @@ sudo_ldap_read_secret(const char *path)
{
FILE *fp;
char buf[LINE_MAX];
debug_decl(sudo_ldap_read_secret, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_read_secret, SUDOERS_DEBUG_LDAP)
if ((fp = fopen(path_ldap_secret, "r")) != NULL) {
if (fgets(buf, sizeof(buf), fp) != NULL) {
@@ -1732,7 +1732,7 @@ sudo_ldap_parse_keyword(const char *keyword, const char *value,
{
struct ldap_config_table *cur;
const char *errstr;
debug_decl(sudo_ldap_parse_keyword, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_parse_keyword, SUDOERS_DEBUG_LDAP)
/* Look up keyword in config tables */
for (cur = table; cur->conf_str != NULL; cur++) {
@@ -1788,7 +1788,7 @@ static const char *
sudo_krb5_ccname_path(const char *old_ccname)
{
const char *ccname = old_ccname;
debug_decl(sudo_krb5_ccname_path, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_krb5_ccname_path, SUDOERS_DEBUG_LDAP)
/* Strip off leading FILE: or WRFILE: prefix. */
switch (ccname[0]) {
@@ -1815,7 +1815,7 @@ sudo_check_krb5_ccname(const char *ccname)
{
int fd = -1;
const char *ccname_path;
debug_decl(sudo_check_krb5_ccname, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_check_krb5_ccname, SUDOERS_DEBUG_LDAP)
/* Strip off prefix to get path name. */
ccname_path = sudo_krb5_ccname_path(ccname);
@@ -1845,7 +1845,7 @@ sudo_ldap_read_config(void)
struct ldap_config_str *conf_str;
size_t linesize = 0;
FILE *fp;
debug_decl(sudo_ldap_read_config, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_read_config, SUDOERS_DEBUG_LDAP)
/* defaults */
ldap_conf.version = 3;
@@ -2088,7 +2088,7 @@ sudo_ldap_get_first_rdn(LDAP *ld, LDAPMessage *entry)
#ifdef HAVE_LDAP_STR2DN
char *dn, *rdn = NULL;
LDAPDN tmpDN;
debug_decl(sudo_ldap_get_first_rdn, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_get_first_rdn, SUDOERS_DEBUG_LDAP)
if ((dn = ldap_get_dn(ld, entry)) == NULL)
debug_return_str(NULL);
@@ -2100,7 +2100,7 @@ sudo_ldap_get_first_rdn(LDAP *ld, LDAPMessage *entry)
debug_return_str(rdn);
#else
char *dn, **edn;
debug_decl(sudo_ldap_get_first_rdn, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_get_first_rdn, SUDOERS_DEBUG_LDAP)
if ((dn = ldap_get_dn(ld, entry)) == NULL)
return NULL;
@@ -2125,7 +2125,7 @@ sudo_ldap_display_defaults(struct sudo_nss *nss, struct passwd *pw,
LDAPMessage *entry, *result;
char *prefix, *filt;
int rc, count = 0;
debug_decl(sudo_ldap_display_defaults, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_display_defaults, SUDOERS_DEBUG_LDAP)
if (handle == NULL || handle->ld == NULL)
goto done;
@@ -2171,7 +2171,7 @@ static int
sudo_ldap_display_bound_defaults(struct sudo_nss *nss, struct passwd *pw,
struct sudo_lbuf *lbuf)
{
debug_decl(sudo_ldap_display_bound_defaults, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_display_bound_defaults, SUDOERS_DEBUG_LDAP)
debug_return_int(0);
}
@@ -2183,7 +2183,7 @@ sudo_ldap_display_entry_short(LDAP *ld, LDAPMessage *entry, struct sudo_lbuf *lb
{
struct berval **bv, **p;
int count = 0;
debug_decl(sudo_ldap_display_entry_short, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_display_entry_short, SUDOERS_DEBUG_LDAP)
sudo_lbuf_append(lbuf, " (");
@@ -2253,7 +2253,7 @@ sudo_ldap_display_entry_long(LDAP *ld, LDAPMessage *entry, struct sudo_lbuf *lbu
struct berval **bv, **p;
char *rdn;
int count = 0;
debug_decl(sudo_ldap_display_entry_long, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_display_entry_long, SUDOERS_DEBUG_LDAP)
/* extract the dn, only show the first rdn */
rdn = sudo_ldap_get_first_rdn(ld, entry);
@@ -2338,7 +2338,7 @@ sudo_ldap_display_privs(struct sudo_nss *nss, struct passwd *pw,
struct ldap_result *lres;
LDAPMessage *entry;
int i, count = 0;
debug_decl(sudo_ldap_display_privs, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_display_privs, SUDOERS_DEBUG_LDAP)
if (handle == NULL || handle->ld == NULL)
goto done;
@@ -2369,7 +2369,7 @@ sudo_ldap_display_cmnd(struct sudo_nss *nss, struct passwd *pw)
LDAPMessage *entry;
bool found = false;
int i;
debug_decl(sudo_ldap_display_cmnd, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_display_cmnd, SUDOERS_DEBUG_LDAP)
if (handle == NULL || handle->ld == NULL)
goto done;
@@ -2406,7 +2406,7 @@ sudo_set_krb5_ccache_name(const char *name, const char **old_name)
int rc = 0;
unsigned int junk;
static bool initialized;
debug_decl(sudo_set_krb5_ccache_name, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_set_krb5_ccache_name, SUDOERS_DEBUG_LDAP)
if (!initialized) {
sudo_gss_krb5_ccache_name =
@@ -2449,7 +2449,7 @@ sudo_krb5_copy_cc_file(const char *old_ccname)
ssize_t nread, nwritten = -1;
static char new_ccname[sizeof(_PATH_TMP) + sizeof("sudocc_XXXXXXXX") - 1];
char buf[10240], *ret = NULL;
debug_decl(sudo_krb5_copy_cc_file, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_krb5_copy_cc_file, SUDOERS_DEBUG_LDAP)
old_ccname = sudo_krb5_ccname_path(old_ccname);
if (old_ccname != NULL) {
@@ -2510,7 +2510,7 @@ sudo_ldap_sasl_interact(LDAP *ld, unsigned int flags, void *_auth_id,
char *auth_id = (char *)_auth_id;
sasl_interact_t *interact = (sasl_interact_t *)_interact;
int rc = LDAP_SUCCESS;
debug_decl(sudo_ldap_sasl_interact, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_sasl_interact, SUDOERS_DEBUG_LDAP)
for (; interact->id != SASL_CB_LIST_END; interact++) {
if (interact->id != SASL_CB_USER) {
@@ -2552,7 +2552,7 @@ sudo_ldap_set_options_table(LDAP *ld, struct ldap_config_table *table)
struct ldap_config_table *cur;
int ival, rc, errors = 0;
char *sval;
debug_decl(sudo_ldap_set_options_table, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_set_options_table, SUDOERS_DEBUG_LDAP)
for (cur = table; cur->conf_str != NULL; cur++) {
if (cur->opt_val == -1)
@@ -2597,7 +2597,7 @@ static int
sudo_ldap_set_options_global(void)
{
int rc;
debug_decl(sudo_ldap_set_options_global, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_set_options_global, SUDOERS_DEBUG_LDAP)
/* Set ber options */
#ifdef LBER_OPT_DEBUG_LEVEL
@@ -2618,7 +2618,7 @@ static int
sudo_ldap_set_options_conn(LDAP *ld)
{
int rc;
debug_decl(sudo_ldap_set_options_conn, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_set_options_conn, SUDOERS_DEBUG_LDAP)
/* Parse per-connection LDAP options table. */
rc = sudo_ldap_set_options_table(ld, ldap_conf_conn);
@@ -2680,7 +2680,7 @@ static struct ldap_result *
sudo_ldap_result_alloc(void)
{
struct ldap_result *result;
debug_decl(sudo_ldap_result_alloc, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_result_alloc, SUDOERS_DEBUG_LDAP)
result = sudo_ecalloc(1, sizeof(*result));
STAILQ_INIT(&result->searches);
@@ -2695,7 +2695,7 @@ static void
sudo_ldap_result_free(struct ldap_result *lres)
{
struct ldap_search_result *s;
debug_decl(sudo_ldap_result_free, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_result_free, SUDOERS_DEBUG_LDAP)
if (lres != NULL) {
if (lres->nentries) {
@@ -2720,7 +2720,7 @@ sudo_ldap_result_add_search(struct ldap_result *lres, LDAP *ldap,
LDAPMessage *searchresult)
{
struct ldap_search_result *news;
debug_decl(sudo_ldap_result_add_search, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_result_add_search, SUDOERS_DEBUG_LDAP)
/* Create new entry and add it to the end of the chain. */
news = sudo_ecalloc(1, sizeof(*news));
@@ -2739,7 +2739,7 @@ static int
sudo_ldap_bind_s(LDAP *ld)
{
int rc;
debug_decl(sudo_ldap_bind_s, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_bind_s, SUDOERS_DEBUG_LDAP)
#ifdef HAVE_LDAP_SASL_INTERACTIVE_BIND_S
if (ldap_conf.rootuse_sasl == true ||
@@ -2835,7 +2835,7 @@ sudo_ldap_open(struct sudo_nss *nss)
sigaction_t sa, saved_sa_pipe;
bool ldapnoinit = false;
struct sudo_ldap_handle *handle;
debug_decl(sudo_ldap_open, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_open, SUDOERS_DEBUG_LDAP)
/* Ignore SIGPIPE if we cannot bind to the server. */
memset(&sa, 0, sizeof(sa));
@@ -2939,7 +2939,7 @@ sudo_ldap_setdefs(struct sudo_nss *nss)
LDAPMessage *entry, *result;
char *filt;
int rc;
debug_decl(sudo_ldap_setdefs, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_setdefs, SUDOERS_DEBUG_LDAP)
if (handle == NULL || handle->ld == NULL)
debug_return_int(-1);
@@ -2982,7 +2982,7 @@ sudo_ldap_lookup(struct sudo_nss *nss, int ret, int pwflag)
LDAPMessage *entry;
int i, rc, setenv_implied;
struct ldap_result *lres = NULL;
debug_decl(sudo_ldap_lookup, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_lookup, SUDOERS_DEBUG_LDAP)
if (handle == NULL || handle->ld == NULL)
debug_return_int(ret);
@@ -3101,7 +3101,7 @@ ldap_entry_compare(const void *a, const void *b)
{
const struct ldap_entry_wrapper *aw = a;
const struct ldap_entry_wrapper *bw = b;
debug_decl(ldap_entry_compare, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(ldap_entry_compare, SUDOERS_DEBUG_LDAP)
debug_return_int(bw->order < aw->order ? -1 :
(bw->order > aw->order ? 1 : 0));
@@ -3114,7 +3114,7 @@ ldap_entry_compare(const void *a, const void *b)
static struct ldap_search_result *
sudo_ldap_result_last_search(struct ldap_result *lres)
{
debug_decl(sudo_ldap_result_last_search, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_result_last_search, SUDOERS_DEBUG_LDAP)
debug_return_ptr(STAILQ_LAST(&lres->searches, ldap_search_result, entries));
}
@@ -3129,7 +3129,7 @@ sudo_ldap_result_add_entry(struct ldap_result *lres, LDAPMessage *entry)
struct berval **bv;
double order = 0.0;
char *ep;
debug_decl(sudo_ldap_result_add_entry, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_result_add_entry, SUDOERS_DEBUG_LDAP)
/* Determine whether the entry has the sudoOrder attribute. */
last = sudo_ldap_result_last_search(lres);
@@ -3172,7 +3172,7 @@ static void
sudo_ldap_result_free_nss(struct sudo_nss *nss)
{
struct sudo_ldap_handle *handle = nss->handle;
debug_decl(sudo_ldap_result_free_nss, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_result_free_nss, SUDOERS_DEBUG_LDAP)
if (handle->result != NULL) {
DPRINTF1("removing reusable search result");
@@ -3202,7 +3202,7 @@ sudo_ldap_result_get(struct sudo_nss *nss, struct passwd *pw)
LDAP *ld = handle->ld;
int pass, rc;
char *filt;
debug_decl(sudo_ldap_result_get, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_result_get, SUDOERS_DEBUG_LDAP)
/*
* If we already have a cached result, return it so we don't have to
@@ -3298,7 +3298,7 @@ static int
sudo_ldap_close(struct sudo_nss *nss)
{
struct sudo_ldap_handle *handle = nss->handle;
debug_decl(sudo_ldap_close, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_ldap_close, SUDOERS_DEBUG_LDAP)
if (handle != NULL) {
/* Free the result before unbinding; it may use the LDAP connection. */

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2010-2015 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
@@ -44,7 +44,7 @@ static int
linux_audit_open(void)
{
static int au_fd = -1;
debug_decl(linux_audit_open, SUDOERS_DEBUG_AUDIT, sudoers_debug_instance)
debug_decl(linux_audit_open, SUDOERS_DEBUG_AUDIT)
if (au_fd != -1)
debug_return_int(au_fd);
@@ -67,7 +67,7 @@ linux_audit_command(char *argv[], int result)
int au_fd, rc = -1;
char *command, *cp, **av;
size_t size, n;
debug_decl(linux_audit_command, SUDOERS_DEBUG_AUDIT, sudoers_debug_instance)
debug_decl(linux_audit_command, SUDOERS_DEBUG_AUDIT)
/* Don't return an error if auditing is not configured. */
if ((au_fd = linux_audit_open()) < 0)

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1994-1996, 1998-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 1994-1996, 1998-2015 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
@@ -87,7 +87,7 @@ mysyslog(int pri, const char *fmt, ...)
#endif
char buf[MAXSYSLOGLEN+1];
va_list ap;
debug_decl(mysyslog, SUDOERS_DEBUG_LOGGING, sudoers_debug_instance)
debug_decl(mysyslog, SUDOERS_DEBUG_LOGGING)
va_start(ap, fmt);
#ifdef LOG_NFACILITIES
@@ -124,7 +124,7 @@ do_syslog(int pri, char *msg)
char *p, *tmp, save;
const char *fmt;
int oldlocale;
debug_decl(do_syslog, SUDOERS_DEBUG_LOGGING, sudoers_debug_instance)
debug_decl(do_syslog, SUDOERS_DEBUG_LOGGING)
sudoers_setlocale(SUDOERS_LOCALE_SUDOERS, &oldlocale);
@@ -176,7 +176,7 @@ do_logfile(char *msg)
mode_t oldmask;
int oldlocale;
FILE *fp;
debug_decl(do_logfile, SUDOERS_DEBUG_LOGGING, sudoers_debug_instance)
debug_decl(do_logfile, SUDOERS_DEBUG_LOGGING)
sudoers_setlocale(SUDOERS_LOCALE_SUDOERS, &oldlocale);
@@ -235,7 +235,7 @@ log_denial(int status, bool inform_user)
char *logline;
int oldlocale;
bool uid_changed;
debug_decl(log_denial, SUDOERS_DEBUG_LOGGING, sudoers_debug_instance)
debug_decl(log_denial, SUDOERS_DEBUG_LOGGING)
/* Handle auditing first (audit_failure() handles the locale itself). */
if (ISSET(status, FLAG_NO_USER | FLAG_NO_HOST))
@@ -315,7 +315,7 @@ void
log_failure(int status, int flags)
{
bool inform_user = true;
debug_decl(log_failure, SUDOERS_DEBUG_LOGGING, sudoers_debug_instance)
debug_decl(log_failure, SUDOERS_DEBUG_LOGGING)
/* The user doesn't always get to see the log message (path info). */
if (!ISSET(status, FLAG_NO_USER | FLAG_NO_HOST) && def_path_info &&
@@ -347,7 +347,7 @@ void
log_auth_failure(int status, unsigned int tries)
{
int flags = 0;
debug_decl(log_auth_failure, SUDOERS_DEBUG_LOGGING, sudoers_debug_instance)
debug_decl(log_auth_failure, SUDOERS_DEBUG_LOGGING)
/* Handle auditing first. */
audit_failure(NewArgc, NewArgv, N_("authentication failure"));
@@ -390,7 +390,7 @@ log_allowed(int status)
char *logline;
int oldlocale;
bool uid_changed;
debug_decl(log_allowed, SUDOERS_DEBUG_LOGGING, sudoers_debug_instance)
debug_decl(log_allowed, SUDOERS_DEBUG_LOGGING)
/* Log and mail messages should be in the sudoers locale. */
sudoers_setlocale(SUDOERS_LOCALE_SUDOERS, &oldlocale);
@@ -431,7 +431,7 @@ vlog_warning(int flags, const char *fmt, va_list ap)
char *logline, *message;
bool uid_changed;
va_list ap2;
debug_decl(vlog_error, SUDOERS_DEBUG_LOGGING, sudoers_debug_instance)
debug_decl(vlog_error, SUDOERS_DEBUG_LOGGING)
/* Need extra copy of ap for sudo_vwarn()/sudo_vwarnx() below. */
if (!ISSET(flags, SLOG_NO_STDERR))
@@ -517,7 +517,7 @@ void
log_warning(int flags, const char *fmt, ...)
{
va_list ap;
debug_decl(log_error, SUDOERS_DEBUG_LOGGING, sudoers_debug_instance)
debug_decl(log_error, SUDOERS_DEBUG_LOGGING)
/* Log the error. */
va_start(ap, fmt);
@@ -531,7 +531,7 @@ void
log_warningx(int flags, const char *fmt, ...)
{
va_list ap;
debug_decl(log_error, SUDOERS_DEBUG_LOGGING, sudoers_debug_instance)
debug_decl(log_error, SUDOERS_DEBUG_LOGGING)
/* Log the error. */
va_start(ap, fmt);
@@ -567,7 +567,7 @@ send_mail(const char *fmt, ...)
NULL
};
#endif /* NO_ROOT_MAILER */
debug_decl(send_mail, SUDOERS_DEBUG_LOGGING, sudoers_debug_instance)
debug_decl(send_mail, SUDOERS_DEBUG_LOGGING)
/* If mailer is disabled just return. */
if (!def_mailerpath || !def_mailto)
@@ -754,7 +754,7 @@ send_mail(const char *fmt, ...)
static bool
should_mail(int status)
{
debug_decl(should_mail, SUDOERS_DEBUG_LOGGING, sudoers_debug_instance)
debug_decl(should_mail, SUDOERS_DEBUG_LOGGING)
debug_return_bool(def_mail_always ||
(def_mail_no_user && ISSET(status, FLAG_NO_USER)) ||
@@ -790,7 +790,7 @@ new_logline(const char *message, int serrno)
#endif
const char *tsid = NULL;
size_t len = 0;
debug_decl(new_logline, SUDOERS_DEBUG_LOGGING, sudoers_debug_instance)
debug_decl(new_logline, SUDOERS_DEBUG_LOGGING)
#ifndef SUDOERS_NO_SEQ
/* A TSID may be a sudoers-style session ID or a free-form string. */

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, 2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2011, 2014-2015 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
@@ -41,7 +41,7 @@ writeln_wrap(FILE *fp, char *line, size_t len, size_t maxlen)
char *indent = "";
char *beg = line;
char *end;
debug_decl(writeln_wrap, SUDOERS_DEBUG_LOGGING, sudoers_debug_instance)
debug_decl(writeln_wrap, SUDOERS_DEBUG_LOGGING)
/*
* Print out line with word wrap around maxlen characters.

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 1998-2005, 2007-2014
* Copyright (c) 1996, 1998-2005, 2007-2015
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -119,7 +119,7 @@ userlist_matches(const struct passwd *pw, const struct member_list *list)
struct member *m;
struct alias *a;
int rval, matched = UNSPEC;
debug_decl(userlist_matches, SUDOERS_DEBUG_MATCH, sudoers_debug_instance)
debug_decl(userlist_matches, SUDOERS_DEBUG_MATCH)
TAILQ_FOREACH_REVERSE(m, list, member_list, entries) {
switch (m->type) {
@@ -169,7 +169,7 @@ runaslist_matches(const struct member_list *user_list,
int rval;
int user_matched = UNSPEC;
int group_matched = UNSPEC;
debug_decl(runaslist_matches, SUDOERS_DEBUG_MATCH, sudoers_debug_instance)
debug_decl(runaslist_matches, SUDOERS_DEBUG_MATCH)
if (runas_pw != NULL) {
/* If no runas user or runas group listed in sudoers, use default. */
@@ -275,7 +275,7 @@ hostlist_matches(const struct member_list *list)
struct member *m;
struct alias *a;
int rval, matched = UNSPEC;
debug_decl(hostlist_matches, SUDOERS_DEBUG_MATCH, sudoers_debug_instance)
debug_decl(hostlist_matches, SUDOERS_DEBUG_MATCH)
TAILQ_FOREACH_REVERSE(m, list, member_list, entries) {
switch (m->type) {
@@ -319,7 +319,7 @@ cmndlist_matches(const struct member_list *list)
{
struct member *m;
int matched = UNSPEC;
debug_decl(cmndlist_matches, SUDOERS_DEBUG_MATCH, sudoers_debug_instance)
debug_decl(cmndlist_matches, SUDOERS_DEBUG_MATCH)
TAILQ_FOREACH_REVERSE(m, list, member_list, entries) {
matched = cmnd_matches(m);
@@ -339,7 +339,7 @@ cmnd_matches(const struct member *m)
struct alias *a;
struct sudo_command *c;
int rval, matched = UNSPEC;
debug_decl(cmnd_matches, SUDOERS_DEBUG_MATCH, sudoers_debug_instance)
debug_decl(cmnd_matches, SUDOERS_DEBUG_MATCH)
switch (m->type) {
case ALL:
@@ -366,7 +366,7 @@ static bool
command_args_match(const char *sudoers_cmnd, const char *sudoers_args)
{
int flags = 0;
debug_decl(command_args_match, SUDOERS_DEBUG_MATCH, sudoers_debug_instance)
debug_decl(command_args_match, SUDOERS_DEBUG_MATCH)
/*
* If no args specified in sudoers, any user args are allowed.
@@ -397,7 +397,7 @@ bool
command_matches(const char *sudoers_cmnd, const char *sudoers_args, const struct sudo_digest *digest)
{
bool rc = false;
debug_decl(command_matches, SUDOERS_DEBUG_MATCH, sudoers_debug_instance)
debug_decl(command_matches, SUDOERS_DEBUG_MATCH)
/* Check for pseudo-commands */
if (sudoers_cmnd[0] != '/') {
@@ -445,7 +445,7 @@ done:
static bool
command_matches_fnmatch(const char *sudoers_cmnd, const char *sudoers_args)
{
debug_decl(command_matches_fnmatch, SUDOERS_DEBUG_MATCH, sudoers_debug_instance)
debug_decl(command_matches_fnmatch, SUDOERS_DEBUG_MATCH)
/*
* Return true if fnmatch(3) succeeds AND
@@ -473,7 +473,7 @@ command_matches_glob(const char *sudoers_cmnd, const char *sudoers_args)
size_t dlen;
char **ap, *base, *cp;
glob_t gl;
debug_decl(command_matches_glob, SUDOERS_DEBUG_MATCH, sudoers_debug_instance)
debug_decl(command_matches_glob, SUDOERS_DEBUG_MATCH)
/*
* First check to see if we can avoid the call to glob(3).
@@ -543,7 +543,7 @@ static bool
command_matches_normal(const char *sudoers_cmnd, const char *sudoers_args, const struct sudo_digest *digest)
{
size_t dlen;
debug_decl(command_matches_normal, SUDOERS_DEBUG_MATCH, sudoers_debug_instance)
debug_decl(command_matches_normal, SUDOERS_DEBUG_MATCH)
dlen = strlen(sudoers_cmnd);
@@ -615,7 +615,7 @@ digest_matches(const char *file, const struct sudo_digest *sd)
FILE *fp;
unsigned int i;
int h;
debug_decl(digest_matches, SUDOERS_DEBUG_MATCH, sudoers_debug_instance)
debug_decl(digest_matches, SUDOERS_DEBUG_MATCH)
for (i = 0; digest_functions[i].digest_name != NULL; i++) {
if (sd->digest_type == i) {
@@ -678,7 +678,7 @@ command_matches_normal(const char *sudoers_cmnd, const char *sudoers_args, const
struct stat sudoers_stat;
const char *base;
size_t dlen;
debug_decl(command_matches_normal, SUDOERS_DEBUG_MATCH, sudoers_debug_instance)
debug_decl(command_matches_normal, SUDOERS_DEBUG_MATCH)
/* If it ends in '/' it is a directory spec. */
dlen = strlen(sudoers_cmnd);
@@ -725,7 +725,7 @@ command_matches_normal(const char *sudoers_cmnd, const char *sudoers_args, const
static bool
command_matches_dir(const char *sudoers_dir, size_t dlen)
{
debug_decl(command_matches_dir, SUDOERS_DEBUG_MATCH, sudoers_debug_instance)
debug_decl(command_matches_dir, SUDOERS_DEBUG_MATCH)
debug_return_bool(strncmp(user_cmnd, sudoers_dir, dlen) == 0);
}
#else /* !SUDOERS_NAME_MATCH */
@@ -739,7 +739,7 @@ command_matches_dir(const char *sudoers_dir, size_t dlen)
struct dirent *dent;
char buf[PATH_MAX];
DIR *dirp;
debug_decl(command_matches_dir, SUDOERS_DEBUG_MATCH, sudoers_debug_instance)
debug_decl(command_matches_dir, SUDOERS_DEBUG_MATCH)
/*
* Grot through directory entries, looking for user_base.
@@ -784,7 +784,7 @@ hostname_matches(const char *shost, const char *lhost, const char *pattern)
{
const char *host;
bool rc;
debug_decl(hostname_matches, SUDOERS_DEBUG_MATCH, sudoers_debug_instance)
debug_decl(hostname_matches, SUDOERS_DEBUG_MATCH)
host = strchr(pattern, '.') != NULL ? lhost : shost;
if (has_meta(pattern)) {
@@ -808,7 +808,7 @@ userpw_matches(const char *sudoers_user, const char *user, const struct passwd *
const char *errstr;
uid_t uid;
bool rc;
debug_decl(userpw_matches, SUDOERS_DEBUG_MATCH, sudoers_debug_instance)
debug_decl(userpw_matches, SUDOERS_DEBUG_MATCH)
if (pw != NULL && *sudoers_user == '#') {
uid = (uid_t) sudo_strtoid(sudoers_user + 1, NULL, NULL, &errstr);
@@ -835,7 +835,7 @@ group_matches(const char *sudoers_group, const struct group *gr)
const char *errstr;
gid_t gid;
bool rc;
debug_decl(group_matches, SUDOERS_DEBUG_MATCH, sudoers_debug_instance)
debug_decl(group_matches, SUDOERS_DEBUG_MATCH)
if (*sudoers_group == '#') {
gid = (gid_t) sudo_strtoid(sudoers_group + 1, NULL, NULL, &errstr);
@@ -861,7 +861,7 @@ usergr_matches(const char *group, const char *user, const struct passwd *pw)
{
int matched = false;
struct passwd *pw0 = NULL;
debug_decl(usergr_matches, SUDOERS_DEBUG_MATCH, sudoers_debug_instance)
debug_decl(usergr_matches, SUDOERS_DEBUG_MATCH)
/* make sure we have a valid usergroup, sudo style */
if (*group++ != '%') {
@@ -945,7 +945,7 @@ netgr_matches(const char *netgr, const char *lhost, const char *shost, const cha
const char *domain;
#endif
bool rc = false;
debug_decl(netgr_matches, SUDOERS_DEBUG_MATCH, sudoers_debug_instance)
debug_decl(netgr_matches, SUDOERS_DEBUG_MATCH)
if (!def_use_netgroups) {
sudo_debug_printf(SUDO_DEBUG_INFO, "netgroups are disabled");

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 1998-2005, 2007-2014
* Copyright (c) 1996, 1998-2005, 2007-2015
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -58,7 +58,7 @@ addr_matches_if(const char *n)
unsigned int j;
#endif
unsigned int family;
debug_decl(addr_matches_if, SUDOERS_DEBUG_MATCH, sudoers_debug_instance)
debug_decl(addr_matches_if, SUDOERS_DEBUG_MATCH)
#ifdef HAVE_STRUCT_IN6_ADDR
if (inet_pton(AF_INET6, n, &addr.ip6) == 1) {
@@ -111,7 +111,7 @@ addr_matches_if_netmask(const char *n, const char *m)
#endif
unsigned int family;
const char *errstr;
debug_decl(addr_matches_if, SUDOERS_DEBUG_MATCH, sudoers_debug_instance)
debug_decl(addr_matches_if, SUDOERS_DEBUG_MATCH)
#ifdef HAVE_STRUCT_IN6_ADDR
if (inet_pton(AF_INET6, n, &addr.ip6) == 1)
@@ -197,7 +197,7 @@ addr_matches(char *n)
{
char *m;
bool rc;
debug_decl(addr_matches, SUDOERS_DEBUG_MATCH, sudoers_debug_instance)
debug_decl(addr_matches, SUDOERS_DEBUG_MATCH)
/* If there's an explicit netmask, use it. */
if ((m = strchr(n, '/'))) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2005, 2007-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2004-2005, 2007-2015 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
@@ -82,7 +82,7 @@ struct sudo_nss sudo_nss_file = {
int
sudo_file_open(struct sudo_nss *nss)
{
debug_decl(sudo_file_open, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_file_open, SUDOERS_DEBUG_NSS)
if (def_ignore_local_sudoers)
debug_return_int(-1);
@@ -93,7 +93,7 @@ sudo_file_open(struct sudo_nss *nss)
int
sudo_file_close(struct sudo_nss *nss)
{
debug_decl(sudo_file_close, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_file_close, SUDOERS_DEBUG_NSS)
/* Free parser data structures and close sudoers file. */
init_parser(NULL, false);
@@ -111,7 +111,7 @@ sudo_file_close(struct sudo_nss *nss)
int
sudo_file_parse(struct sudo_nss *nss)
{
debug_decl(sudo_file_close, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_file_close, SUDOERS_DEBUG_NSS)
if (nss->handle == NULL)
debug_return_int(-1);
@@ -136,7 +136,7 @@ sudo_file_parse(struct sudo_nss *nss)
int
sudo_file_setdefs(struct sudo_nss *nss)
{
debug_decl(sudo_file_setdefs, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_file_setdefs, SUDOERS_DEBUG_NSS)
if (nss->handle == NULL)
debug_return_int(-1);
@@ -159,7 +159,7 @@ sudo_file_lookup(struct sudo_nss *nss, int validated, int pwflag)
struct privilege *priv;
struct userspec *us;
struct member *matching_user;
debug_decl(sudo_file_lookup, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_file_lookup, SUDOERS_DEBUG_NSS)
if (nss->handle == NULL)
debug_return_int(validated);
@@ -301,7 +301,7 @@ static void
sudo_file_append_cmnd(struct cmndspec *cs, struct cmndtag *tags,
struct sudo_lbuf *lbuf)
{
debug_decl(sudo_file_append_cmnd, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_file_append_cmnd, SUDOERS_DEBUG_NSS)
#ifdef HAVE_PRIV_SET
if (cs->privs)
@@ -352,7 +352,7 @@ sudo_file_display_priv_short(struct passwd *pw, struct userspec *us,
struct privilege *priv;
struct cmndtag tags;
int nfound = 0;
debug_decl(sudo_file_display_priv_short, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_file_display_priv_short, SUDOERS_DEBUG_NSS)
/* gcc -Wuninitialized false positive */
tags.noexec = UNSPEC;
@@ -448,7 +448,7 @@ sudo_file_display_priv_long(struct passwd *pw, struct userspec *us,
struct member *m;
struct privilege *priv;
int nfound = 0, olen;
debug_decl(sudo_file_display_priv_long, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_file_display_priv_long, SUDOERS_DEBUG_NSS)
TAILQ_FOREACH(priv, &us->privileges, entries) {
if (hostlist_matches(&priv->hostlist) != ALLOW)
@@ -527,7 +527,7 @@ sudo_file_display_privs(struct sudo_nss *nss, struct passwd *pw,
{
struct userspec *us;
int nfound = 0;
debug_decl(sudo_file_display_priv, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_file_display_priv, SUDOERS_DEBUG_NSS)
if (nss->handle == NULL)
goto done;
@@ -555,7 +555,7 @@ sudo_file_display_defaults(struct sudo_nss *nss, struct passwd *pw,
struct defaults *d;
char *prefix;
int nfound = 0;
debug_decl(sudo_file_display_defaults, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_file_display_defaults, SUDOERS_DEBUG_NSS)
if (nss->handle == NULL)
goto done;
@@ -606,7 +606,7 @@ sudo_file_display_bound_defaults(struct sudo_nss *nss, struct passwd *pw,
struct sudo_lbuf *lbuf)
{
int nfound = 0;
debug_decl(sudo_file_display_bound_defaults, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_file_display_bound_defaults, SUDOERS_DEBUG_NSS)
/* XXX - should only print ones that match what the user can do. */
nfound += display_bound_defaults(DEFAULTS_RUNAS, lbuf);
@@ -626,7 +626,7 @@ display_bound_defaults(int dtype, struct sudo_lbuf *lbuf)
struct member *m;
char *dsep;
int atype, nfound = 0;
debug_decl(display_bound_defaults, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(display_bound_defaults, SUDOERS_DEBUG_NSS)
switch (dtype) {
case DEFAULTS_HOST:
@@ -685,7 +685,7 @@ sudo_file_display_cmnd(struct sudo_nss *nss, struct passwd *pw)
struct userspec *us;
int rval = 1;
int host_match, runas_match, cmnd_match;
debug_decl(sudo_file_display_cmnd, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_file_display_cmnd, SUDOERS_DEBUG_NSS)
if (nss->handle == NULL)
goto done;
@@ -733,7 +733,7 @@ _print_member(struct sudo_lbuf *lbuf, char *name, int type, int negated,
struct alias *a;
struct member *m;
struct sudo_command *c;
debug_decl(_print_member, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(_print_member, SUDOERS_DEBUG_NSS)
switch (type) {
case ALL:

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2010-2015 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
@@ -91,7 +91,7 @@ sudoers_policy_deserialize_info(void *v, char **runas_user, char **runas_group)
const char *p, *errstr, *groups = NULL;
const char *remhost = NULL;
int flags = 0;
debug_decl(sudoers_policy_deserialize_info, SUDOERS_DEBUG_PLUGIN, sudoers_debug_instance)
debug_decl(sudoers_policy_deserialize_info, SUDOERS_DEBUG_PLUGIN)
#define MATCHES(s, v) (strncmp(s, v, sizeof(v) - 1) == 0)
@@ -389,7 +389,7 @@ sudoers_policy_exec_setup(char *argv[], char *envp[], mode_t cmnd_umask,
char **command_info;
int info_len = 0;
int rval = -1;
debug_decl(sudoers_policy_exec_setup, SUDOERS_DEBUG_PLUGIN, sudoers_debug_instance)
debug_decl(sudoers_policy_exec_setup, SUDOERS_DEBUG_PLUGIN)
/* Increase the length of command_info as needed, it is *not* checked. */
command_info = sudo_ecalloc(32, sizeof(char **));
@@ -527,7 +527,7 @@ sudoers_policy_open(unsigned int version, sudo_conv_t conversation,
struct sudoers_policy_open_info info;
const char *plugin_path = NULL;
char * const *cur;
debug_decl(sudoers_policy_open, SUDOERS_DEBUG_PLUGIN, sudoers_debug_instance)
debug_decl(sudoers_policy_open, SUDOERS_DEBUG_PLUGIN)
sudo_version = version;
sudo_conv = conversation;
@@ -561,7 +561,7 @@ sudoers_policy_open(unsigned int version, sudo_conv_t conversation,
static void
sudoers_policy_close(int exit_status, int error_code)
{
debug_decl(sudoers_policy_close, SUDOERS_DEBUG_PLUGIN, sudoers_debug_instance)
debug_decl(sudoers_policy_close, SUDOERS_DEBUG_PLUGIN)
/* We do not currently log the exit status. */
if (error_code) {
@@ -606,7 +606,7 @@ sudoers_policy_close(int exit_status, int error_code)
static int
sudoers_policy_init_session(struct passwd *pwd, char **user_env[])
{
debug_decl(sudoers_policy_init_session, SUDOERS_DEBUG_PLUGIN, sudoers_debug_instance)
debug_decl(sudoers_policy_init_session, SUDOERS_DEBUG_PLUGIN)
/* user_env is only specified for API version 1.2 and higher. */
if (sudo_version < SUDO_API_MKVERSION(1, 2))
@@ -621,7 +621,7 @@ sudoers_policy_check(int argc, char * const argv[], char *env_add[],
{
struct sudoers_exec_args exec_args;
int rval;
debug_decl(sudoers_policy_check, SUDOERS_DEBUG_PLUGIN, sudoers_debug_instance)
debug_decl(sudoers_policy_check, SUDOERS_DEBUG_PLUGIN)
if (!ISSET(sudo_mode, MODE_EDIT))
SET(sudo_mode, MODE_RUN);
@@ -643,7 +643,7 @@ sudoers_policy_check(int argc, char * const argv[], char *env_add[],
static int
sudoers_policy_validate(void)
{
debug_decl(sudoers_policy_validate, SUDOERS_DEBUG_PLUGIN, sudoers_debug_instance)
debug_decl(sudoers_policy_validate, SUDOERS_DEBUG_PLUGIN)
user_cmnd = "validate";
SET(sudo_mode, MODE_VALIDATE);
@@ -654,7 +654,7 @@ sudoers_policy_validate(void)
static void
sudoers_policy_invalidate(int remove)
{
debug_decl(sudoers_policy_invalidate, SUDOERS_DEBUG_PLUGIN, sudoers_debug_instance)
debug_decl(sudoers_policy_invalidate, SUDOERS_DEBUG_PLUGIN)
user_cmnd = "kill";
remove_timestamp(remove);
@@ -668,7 +668,7 @@ sudoers_policy_list(int argc, char * const argv[], int verbose,
const char *list_user)
{
int rval;
debug_decl(sudoers_policy_list, SUDOERS_DEBUG_PLUGIN, sudoers_debug_instance)
debug_decl(sudoers_policy_list, SUDOERS_DEBUG_PLUGIN)
user_cmnd = "list";
if (argc)
@@ -696,7 +696,7 @@ sudoers_policy_list(int argc, char * const argv[], int verbose,
static int
sudoers_policy_version(int verbose)
{
debug_decl(sudoers_policy_version, SUDOERS_DEBUG_PLUGIN, sudoers_debug_instance)
debug_decl(sudoers_policy_version, SUDOERS_DEBUG_PLUGIN)
sudo_printf(SUDO_CONV_INFO_MSG, _("Sudoers policy plugin version %s\n"),
PACKAGE_VERSION);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1993-1996,1998-2005, 2007-2014
* Copyright (c) 1993-1996,1998-2005, 2007-2015
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -53,7 +53,7 @@ expand_prompt(const char *old_prompt, const char *auth_user)
int subst;
const char *p;
char *np, *new_prompt, *endp;
debug_decl(expand_prompt, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(expand_prompt, SUDOERS_DEBUG_AUTH)
/* How much space do we need to malloc for the prompt? */
subst = 0;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 1998-2005, 2007-2014
* Copyright (c) 1996, 1998-2005, 2007-2015
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -91,7 +91,7 @@ cmp_pwnam(const void *v1, const void *v2)
void
sudo_pw_addref(struct passwd *pw)
{
debug_decl(sudo_pw_addref, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_pw_addref, SUDOERS_DEBUG_NSS)
ptr_to_item(pw)->refcnt++;
debug_return;
}
@@ -100,7 +100,7 @@ static void
sudo_pw_delref_item(void *v)
{
struct cache_item *item = v;
debug_decl(sudo_pw_delref_item, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_pw_delref_item, SUDOERS_DEBUG_NSS)
if (--item->refcnt == 0)
sudo_efree(item);
@@ -111,7 +111,7 @@ sudo_pw_delref_item(void *v)
void
sudo_pw_delref(struct passwd *pw)
{
debug_decl(sudo_pw_delref, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_pw_delref, SUDOERS_DEBUG_NSS)
sudo_pw_delref_item(ptr_to_item(pw));
debug_return;
}
@@ -124,7 +124,7 @@ sudo_getpwuid(uid_t uid)
{
struct cache_item key, *item;
struct rbnode *node;
debug_decl(sudo_getpwuid, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_getpwuid, SUDOERS_DEBUG_NSS)
key.k.uid = uid;
if ((node = rbfind(pwcache_byuid, &key)) != NULL) {
@@ -167,7 +167,7 @@ sudo_getpwnam(const char *name)
struct cache_item key, *item;
struct rbnode *node;
size_t len;
debug_decl(sudo_getpwnam, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_getpwnam, SUDOERS_DEBUG_NSS)
key.k.name = (char *) name;
if ((node = rbfind(pwcache_byname, &key)) != NULL) {
@@ -215,7 +215,7 @@ sudo_mkpwent(const char *user, uid_t uid, gid_t gid, const char *home,
struct rbnode *node;
size_t len, name_len, home_len, shell_len;
int i;
debug_decl(sudo_mkpwent, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_mkpwent, SUDOERS_DEBUG_NSS)
/* Optional arguments. */
if (home == NULL)
@@ -278,7 +278,7 @@ sudo_fakepwnam(const char *user, gid_t gid)
{
const char *errstr;
uid_t uid;
debug_decl(sudo_fakepwnam, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_fakepwnam, SUDOERS_DEBUG_NSS)
uid = (uid_t) sudo_strtoid(user + 1, NULL, NULL, &errstr);
if (errstr != NULL) {
@@ -292,7 +292,7 @@ sudo_fakepwnam(const char *user, gid_t gid)
void
sudo_setpwent(void)
{
debug_decl(sudo_setpwent, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_setpwent, SUDOERS_DEBUG_NSS)
setpwent();
if (pwcache_byuid == NULL)
@@ -306,7 +306,7 @@ sudo_setpwent(void)
void
sudo_freepwcache(void)
{
debug_decl(sudo_freepwcache, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_freepwcache, SUDOERS_DEBUG_NSS)
if (pwcache_byuid != NULL) {
rbdestroy(pwcache_byuid, sudo_pw_delref_item);
@@ -323,7 +323,7 @@ sudo_freepwcache(void)
void
sudo_endpwent(void)
{
debug_decl(sudo_endpwent, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_endpwent, SUDOERS_DEBUG_NSS)
endpwent();
sudo_freepwcache();
@@ -345,7 +345,7 @@ cmp_grgid(const void *v1, const void *v2)
void
sudo_gr_addref(struct group *gr)
{
debug_decl(sudo_gr_addref, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_gr_addref, SUDOERS_DEBUG_NSS)
ptr_to_item(gr)->refcnt++;
debug_return;
}
@@ -354,7 +354,7 @@ static void
sudo_gr_delref_item(void *v)
{
struct cache_item *item = v;
debug_decl(sudo_gr_delref_item, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_gr_delref_item, SUDOERS_DEBUG_NSS)
if (--item->refcnt == 0)
sudo_efree(item);
@@ -365,7 +365,7 @@ sudo_gr_delref_item(void *v)
void
sudo_gr_delref(struct group *gr)
{
debug_decl(sudo_gr_delref, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_gr_delref, SUDOERS_DEBUG_NSS)
sudo_gr_delref_item(ptr_to_item(gr));
debug_return;
}
@@ -378,7 +378,7 @@ sudo_getgrgid(gid_t gid)
{
struct cache_item key, *item;
struct rbnode *node;
debug_decl(sudo_getgrgid, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_getgrgid, SUDOERS_DEBUG_NSS)
key.k.gid = gid;
if ((node = rbfind(grcache_bygid, &key)) != NULL) {
@@ -415,7 +415,7 @@ sudo_getgrnam(const char *name)
struct cache_item key, *item;
struct rbnode *node;
size_t len;
debug_decl(sudo_getgrnam, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_getgrnam, SUDOERS_DEBUG_NSS)
key.k.name = (char *) name;
if ((node = rbfind(grcache_byname, &key)) != NULL) {
@@ -456,7 +456,7 @@ sudo_fakegrnam(const char *group)
struct rbnode *node;
size_t len, name_len;
int i;
debug_decl(sudo_fakegrnam, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_fakegrnam, SUDOERS_DEBUG_NSS)
name_len = strlen(group);
len = sizeof(*gritem) + name_len + 1;
@@ -501,7 +501,7 @@ sudo_fakegrnam(const char *group)
void
sudo_grlist_addref(struct group_list *grlist)
{
debug_decl(sudo_gr_addref, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_gr_addref, SUDOERS_DEBUG_NSS)
ptr_to_item(grlist)->refcnt++;
debug_return;
}
@@ -510,7 +510,7 @@ static void
sudo_grlist_delref_item(void *v)
{
struct cache_item *item = v;
debug_decl(sudo_gr_delref_item, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_gr_delref_item, SUDOERS_DEBUG_NSS)
if (--item->refcnt == 0)
sudo_efree(item);
@@ -521,7 +521,7 @@ sudo_grlist_delref_item(void *v)
void
sudo_grlist_delref(struct group_list *grlist)
{
debug_decl(sudo_gr_delref, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_gr_delref, SUDOERS_DEBUG_NSS)
sudo_grlist_delref_item(ptr_to_item(grlist));
debug_return;
}
@@ -529,7 +529,7 @@ sudo_grlist_delref(struct group_list *grlist)
void
sudo_setgrent(void)
{
debug_decl(sudo_setgrent, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_setgrent, SUDOERS_DEBUG_NSS)
setgrent();
if (grcache_bygid == NULL)
@@ -545,7 +545,7 @@ sudo_setgrent(void)
void
sudo_freegrcache(void)
{
debug_decl(sudo_freegrcache, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_freegrcache, SUDOERS_DEBUG_NSS)
if (grcache_bygid != NULL) {
rbdestroy(grcache_bygid, sudo_gr_delref_item);
@@ -566,7 +566,7 @@ sudo_freegrcache(void)
void
sudo_endgrent(void)
{
debug_decl(sudo_endgrent, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_endgrent, SUDOERS_DEBUG_NSS)
endgrent();
sudo_freegrcache();
@@ -580,7 +580,7 @@ sudo_get_grlist(const struct passwd *pw)
struct cache_item key, *item;
struct rbnode *node;
size_t len;
debug_decl(sudo_get_grlist, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_get_grlist, SUDOERS_DEBUG_NSS)
key.k.name = pw->pw_name;
if ((node = rbfind(grlist_cache, &key)) != NULL) {
@@ -616,7 +616,7 @@ sudo_set_grlist(struct passwd *pw, char * const *groups, char * const *gids)
{
struct cache_item key, *item;
struct rbnode *node;
debug_decl(sudo_set_grlist, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_set_grlist, SUDOERS_DEBUG_NSS)
/*
* Cache group db entry if it doesn't already exist
@@ -644,7 +644,7 @@ user_in_group(const struct passwd *pw, const char *group)
const char *errstr;
int i;
bool matched = false;
debug_decl(user_in_group, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(user_in_group, SUDOERS_DEBUG_NSS)
if ((grlist = sudo_get_grlist(pw)) != NULL) {
/*

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 1998-2005, 2007-2014
* Copyright (c) 1996, 1998-2005, 2007-2015
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -88,7 +88,7 @@ sudo_make_pwitem(uid_t uid, const char *name)
size_t nsize, psize, csize, gsize, dsize, ssize, total;
struct cache_item_pw *pwitem;
struct passwd *pw, *newpw;
debug_decl(sudo_make_pwitem, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_make_pwitem, SUDOERS_DEBUG_NSS)
/* Look up by name or uid. */
pw = name ? getpwnam(name) : getpwuid(uid);
@@ -162,7 +162,7 @@ sudo_make_gritem(gid_t gid, const char *name)
size_t nsize, psize, nmem, total, len;
struct cache_item_gr *gritem;
struct group *gr, *newgr;
debug_decl(sudo_make_gritem, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_make_gritem, SUDOERS_DEBUG_NSS)
/* Look up by name or gid. */
gr = name ? getgrnam(name) : getgrgid(gid);
@@ -235,7 +235,7 @@ sudo_make_grlist_item(const struct passwd *pw, char * const *unused1,
GETGROUPS_T *gids;
struct group *grp;
int i, ngids, groupname_len;
debug_decl(sudo_make_grlist_item, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_make_grlist_item, SUDOERS_DEBUG_NSS)
if (pw == sudo_user.pw && sudo_user.gids != NULL) {
gids = user_gids;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2005, 2007, 2009-2014
* Copyright (c) 2004-2005, 2007, 2009-2015
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -88,7 +88,7 @@ struct rbtree *
rbcreate(int (*compar)(const void *, const void*))
{
struct rbtree *tree;
debug_decl(rbcreate, SUDOERS_DEBUG_RBTREE, sudoers_debug_instance)
debug_decl(rbcreate, SUDOERS_DEBUG_RBTREE)
tree = (struct rbtree *) sudo_emalloc(sizeof(*tree));
tree->compar = compar;
@@ -119,7 +119,7 @@ static void
rotate_left(struct rbtree *tree, struct rbnode *node)
{
struct rbnode *child;
debug_decl(rotate_left, SUDOERS_DEBUG_RBTREE, sudoers_debug_instance)
debug_decl(rotate_left, SUDOERS_DEBUG_RBTREE)
child = node->right;
node->right = child->left;
@@ -145,7 +145,7 @@ static void
rotate_right(struct rbtree *tree, struct rbnode *node)
{
struct rbnode *child;
debug_decl(rotate_right, SUDOERS_DEBUG_RBTREE, sudoers_debug_instance)
debug_decl(rotate_right, SUDOERS_DEBUG_RBTREE)
child = node->left;
node->left = child->right;
@@ -175,7 +175,7 @@ rbinsert(struct rbtree *tree, void *data)
struct rbnode *node = rbfirst(tree);
struct rbnode *parent = rbroot(tree);
int res;
debug_decl(rbinsert, SUDOERS_DEBUG_RBTREE, sudoers_debug_instance)
debug_decl(rbinsert, SUDOERS_DEBUG_RBTREE)
/* Find correct insertion point. */
while (node != rbnil(tree)) {
@@ -267,7 +267,7 @@ rbfind(struct rbtree *tree, void *key)
{
struct rbnode *node = rbfirst(tree);
int res;
debug_decl(rbfind, SUDOERS_DEBUG_RBTREE, sudoers_debug_instance)
debug_decl(rbfind, SUDOERS_DEBUG_RBTREE)
while (node != rbnil(tree)) {
if ((res = tree->compar(key, node->data)) == 0)
@@ -287,7 +287,7 @@ rbapply_node(struct rbtree *tree, struct rbnode *node,
int (*func)(void *, void *), void *cookie, enum rbtraversal order)
{
int error;
debug_decl(rbapply_node, SUDOERS_DEBUG_RBTREE, sudoers_debug_instance)
debug_decl(rbapply_node, SUDOERS_DEBUG_RBTREE)
if (node != rbnil(tree)) {
if (order == preorder)
@@ -314,7 +314,7 @@ static struct rbnode *
rbsuccessor(struct rbtree *tree, struct rbnode *node)
{
struct rbnode *succ;
debug_decl(rbsuccessor, SUDOERS_DEBUG_RBTREE, sudoers_debug_instance)
debug_decl(rbsuccessor, SUDOERS_DEBUG_RBTREE)
if ((succ = node->right) != rbnil(tree)) {
while (succ->left != rbnil(tree))
@@ -335,7 +335,7 @@ rbsuccessor(struct rbtree *tree, struct rbnode *node)
static void
_rbdestroy(struct rbtree *tree, struct rbnode *node, void (*destroy)(void *))
{
debug_decl(_rbdestroy, SUDOERS_DEBUG_RBTREE, sudoers_debug_instance)
debug_decl(_rbdestroy, SUDOERS_DEBUG_RBTREE)
if (node != rbnil(tree)) {
_rbdestroy(tree, node->left, destroy);
_rbdestroy(tree, node->right, destroy);
@@ -353,7 +353,7 @@ _rbdestroy(struct rbtree *tree, struct rbnode *node, void (*destroy)(void *))
void
rbdestroy(struct rbtree *tree, void (*destroy)(void *))
{
debug_decl(rbdestroy, SUDOERS_DEBUG_RBTREE, sudoers_debug_instance)
debug_decl(rbdestroy, SUDOERS_DEBUG_RBTREE)
_rbdestroy(tree, rbfirst(tree), destroy);
sudo_efree(tree);
debug_return;
@@ -366,7 +366,7 @@ void *rbdelete(struct rbtree *tree, struct rbnode *z)
{
struct rbnode *x, *y;
void *data = z->data;
debug_decl(rbdelete, SUDOERS_DEBUG_RBTREE, sudoers_debug_instance)
debug_decl(rbdelete, SUDOERS_DEBUG_RBTREE)
if (z->left == rbnil(tree) || z->right == rbnil(tree))
y = z;
@@ -408,7 +408,7 @@ static void
rbrepair(struct rbtree *tree, struct rbnode *node)
{
struct rbnode *sibling;
debug_decl(rbrepair, SUDOERS_DEBUG_RBTREE, sudoers_debug_instance)
debug_decl(rbrepair, SUDOERS_DEBUG_RBTREE)
while (node->color == black && node != rbfirst(tree)) {
if (node == node->parent->left) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1994-1996,1998-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 1994-1996,1998-2015 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
@@ -86,7 +86,7 @@ static int perm_stack_depth = 0;
bool
rewind_perms(void)
{
debug_decl(rewind_perms, SUDOERS_DEBUG_PERMS, sudoers_debug_instance)
debug_decl(rewind_perms, SUDOERS_DEBUG_PERMS)
if (perm_stack_depth != 0) {
while (perm_stack_depth > 1) {
@@ -116,7 +116,7 @@ set_perms(int perm)
struct perm_state *state, *ostate = NULL;
char errbuf[1024];
const char *errstr = errbuf;
debug_decl(set_perms, SUDOERS_DEBUG_PERMS, sudoers_debug_instance)
debug_decl(set_perms, SUDOERS_DEBUG_PERMS)
if (perm_stack_depth == PERM_STACK_MAX) {
errstr = N_("perm stack overflow");
@@ -372,7 +372,7 @@ bool
restore_perms(void)
{
struct perm_state *state, *ostate;
debug_decl(restore_perms, SUDOERS_DEBUG_PERMS, sudoers_debug_instance)
debug_decl(restore_perms, SUDOERS_DEBUG_PERMS)
if (perm_stack_depth < 2) {
sudo_warnx(U_("perm stack underflow"));
@@ -441,7 +441,7 @@ set_perms(int perm)
struct perm_state *state, *ostate = NULL;
char errbuf[1024];
const char *errstr = errbuf;
debug_decl(set_perms, SUDOERS_DEBUG_PERMS, sudoers_debug_instance)
debug_decl(set_perms, SUDOERS_DEBUG_PERMS)
if (perm_stack_depth == PERM_STACK_MAX) {
errstr = N_("perm stack overflow");
@@ -711,7 +711,7 @@ bool
restore_perms(void)
{
struct perm_state *state, *ostate;
debug_decl(restore_perms, SUDOERS_DEBUG_PERMS, sudoers_debug_instance)
debug_decl(restore_perms, SUDOERS_DEBUG_PERMS)
if (perm_stack_depth < 2) {
sudo_warnx(U_("perm stack underflow"));
@@ -844,7 +844,7 @@ set_perms(int perm)
struct perm_state *state, *ostate = NULL;
char errbuf[1024];
const char *errstr = errbuf;
debug_decl(set_perms, SUDOERS_DEBUG_PERMS, sudoers_debug_instance)
debug_decl(set_perms, SUDOERS_DEBUG_PERMS)
if (perm_stack_depth == PERM_STACK_MAX) {
errstr = N_("perm stack overflow");
@@ -1070,7 +1070,7 @@ bool
restore_perms(void)
{
struct perm_state *state, *ostate;
debug_decl(restore_perms, SUDOERS_DEBUG_PERMS, sudoers_debug_instance)
debug_decl(restore_perms, SUDOERS_DEBUG_PERMS)
if (perm_stack_depth < 2) {
sudo_warnx(U_("perm stack underflow"));
@@ -1141,7 +1141,7 @@ set_perms(int perm)
struct perm_state *state, *ostate = NULL;
char errbuf[1024];
const char *errstr = errbuf;
debug_decl(set_perms, SUDOERS_DEBUG_PERMS, sudoers_debug_instance)
debug_decl(set_perms, SUDOERS_DEBUG_PERMS)
if (perm_stack_depth == PERM_STACK_MAX) {
errstr = N_("perm stack overflow");
@@ -1366,7 +1366,7 @@ bool
restore_perms(void)
{
struct perm_state *state, *ostate;
debug_decl(restore_perms, SUDOERS_DEBUG_PERMS, sudoers_debug_instance)
debug_decl(restore_perms, SUDOERS_DEBUG_PERMS)
if (perm_stack_depth < 2) {
sudo_warnx(U_("perm stack underflow"));
@@ -1433,7 +1433,7 @@ set_perms(int perm)
struct perm_state *state, *ostate = NULL;
char errbuf[1024];
const char *errstr = errbuf;
debug_decl(set_perms, SUDOERS_DEBUG_PERMS, sudoers_debug_instance)
debug_decl(set_perms, SUDOERS_DEBUG_PERMS)
if (perm_stack_depth == PERM_STACK_MAX) {
errstr = N_("perm stack overflow");
@@ -1530,7 +1530,7 @@ boll
restore_perms(void)
{
struct perm_state *state, *ostate;
debug_decl(restore_perms, SUDOERS_DEBUG_PERMS, sudoers_debug_instance)
debug_decl(restore_perms, SUDOERS_DEBUG_PERMS)
if (perm_stack_depth < 2) {
sudo_warnx(U_("perm stack underflow"));
@@ -1574,7 +1574,7 @@ runas_setgroups(void)
{
struct passwd *pw;
struct group_list *grlist;
debug_decl(runas_setgroups, SUDOERS_DEBUG_PERMS, sudoers_debug_instance)
debug_decl(runas_setgroups, SUDOERS_DEBUG_PERMS)
if (def_preserve_groups) {
sudo_grlist_addref(user_group_list);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2003-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2003-2015 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2011 Daniel Kopecek <dkopecek@redhat.com>
*
* This code is derived from software contributed by Aaron Spangler.
@@ -124,7 +124,7 @@ static void
sudo_sss_attrcpy(struct sss_sudo_attr *dst, const struct sss_sudo_attr *src)
{
unsigned int i;
debug_decl(sudo_sss_attrcpy, SUDOERS_DEBUG_SSSD, sudoers_debug_instance)
debug_decl(sudo_sss_attrcpy, SUDOERS_DEBUG_SSSD)
sudo_debug_printf(SUDO_DEBUG_DEBUG, "dst=%p, src=%p", dst, src);
sudo_debug_printf(SUDO_DEBUG_INFO, "sudo_emalloc: cnt=%d", src->num_values);
@@ -143,7 +143,7 @@ static void
sudo_sss_rulecpy(struct sss_sudo_rule *dst, const struct sss_sudo_rule *src)
{
unsigned int i;
debug_decl(sudo_sss_rulecpy, SUDOERS_DEBUG_SSSD, sudoers_debug_instance)
debug_decl(sudo_sss_rulecpy, SUDOERS_DEBUG_SSSD)
sudo_debug_printf(SUDO_DEBUG_DEBUG, "dst=%p, src=%p", dst, src);
sudo_debug_printf(SUDO_DEBUG_INFO, "sudo_emalloc: cnt=%d", src->num_attrs);
@@ -172,7 +172,7 @@ sudo_sss_filter_result(struct sudo_sss_handle *handle,
struct sss_sudo_result *out_res;
unsigned int i, l;
int r;
debug_decl(sudo_sss_filter_result, SUDOERS_DEBUG_SSSD, sudoers_debug_instance)
debug_decl(sudo_sss_filter_result, SUDOERS_DEBUG_SSSD)
sudo_debug_printf(SUDO_DEBUG_DEBUG, "in_res=%p, count=%u, act=%s",
in_res, in_res ? in_res->num_rules : 0,
@@ -240,7 +240,7 @@ static int sudo_sss_open(struct sudo_nss *nss)
{
struct sudo_sss_handle *handle;
static const char path[] = _PATH_SSSD_LIB"/libsss_sudo.so";
debug_decl(sudo_sss_open, SUDOERS_DEBUG_SSSD, sudoers_debug_instance);
debug_decl(sudo_sss_open, SUDOERS_DEBUG_SSSD);
/* Create a handle container. */
handle = sudo_emalloc(sizeof(struct sudo_sss_handle));
@@ -306,7 +306,7 @@ static int sudo_sss_open(struct sudo_nss *nss)
static int sudo_sss_close(struct sudo_nss *nss)
{
struct sudo_sss_handle *handle;
debug_decl(sudo_sss_close, SUDOERS_DEBUG_SSSD, sudoers_debug_instance);
debug_decl(sudo_sss_close, SUDOERS_DEBUG_SSSD);
if (nss && nss->handle) {
handle = nss->handle;
@@ -319,7 +319,7 @@ static int sudo_sss_close(struct sudo_nss *nss)
// ok
static int sudo_sss_parse(struct sudo_nss *nss)
{
debug_decl(sudo_sss_parse, SUDOERS_DEBUG_SSSD, sudoers_debug_instance);
debug_decl(sudo_sss_parse, SUDOERS_DEBUG_SSSD);
debug_return_int(0);
}
@@ -331,7 +331,7 @@ static int sudo_sss_setdefs(struct sudo_nss *nss)
struct sss_sudo_rule *sss_rule;
uint32_t sss_error;
unsigned int i;
debug_decl(sudo_sss_setdefs, SUDOERS_DEBUG_SSSD, sudoers_debug_instance);
debug_decl(sudo_sss_setdefs, SUDOERS_DEBUG_SSSD);
if (handle == NULL)
debug_return_int(-1);
@@ -368,7 +368,7 @@ static int sudo_sss_setdefs(struct sudo_nss *nss)
static int sudo_sss_checkpw(struct sudo_nss *nss, struct passwd *pw)
{
struct sudo_sss_handle *handle = nss->handle;
debug_decl(sudo_sss_checkpw, SUDOERS_DEBUG_SSSD, sudoers_debug_instance);
debug_decl(sudo_sss_checkpw, SUDOERS_DEBUG_SSSD);
if (pw->pw_name != handle->pw->pw_name ||
pw->pw_uid != handle->pw->pw_uid) {
@@ -389,7 +389,7 @@ sudo_sss_check_runas_user(struct sudo_sss_handle *handle, struct sss_sudo_rule *
char **val_array = NULL;
char *val;
int ret = false, i;
debug_decl(sudo_sss_check_runas_user, SUDOERS_DEBUG_SSSD, sudoers_debug_instance);
debug_decl(sudo_sss_check_runas_user, SUDOERS_DEBUG_SSSD);
if (!runas_pw)
debug_return_int(UNSPEC);
@@ -492,7 +492,7 @@ sudo_sss_check_runas_group(struct sudo_sss_handle *handle, struct sss_sudo_rule
char **val_array = NULL;
char *val;
int ret = false, i;
debug_decl(sudo_sss_check_runas_group, SUDOERS_DEBUG_SSSD, sudoers_debug_instance);
debug_decl(sudo_sss_check_runas_group, SUDOERS_DEBUG_SSSD);
/* runas_gr is only set if the user specified the -g flag */
if (!runas_gr)
@@ -536,7 +536,7 @@ static bool
sudo_sss_check_runas(struct sudo_sss_handle *handle, struct sss_sudo_rule *rule)
{
bool ret;
debug_decl(sudo_sss_check_runas, SUDOERS_DEBUG_SSSD, sudoers_debug_instance);
debug_decl(sudo_sss_check_runas, SUDOERS_DEBUG_SSSD);
if (rule == NULL)
debug_return_bool(false);
@@ -553,7 +553,7 @@ sudo_sss_check_host(struct sudo_sss_handle *handle, struct sss_sudo_rule *rule)
char **val_array, *val;
bool ret = false;
int i;
debug_decl(sudo_sss_check_host, SUDOERS_DEBUG_SSSD, sudoers_debug_instance);
debug_decl(sudo_sss_check_host, SUDOERS_DEBUG_SSSD);
if (rule == NULL)
debug_return_bool(ret);
@@ -605,7 +605,7 @@ sudo_sss_filter_user_netgroup(struct sudo_sss_handle *handle, struct sss_sudo_ru
bool ret = false, netgroup_spec_found = false;
char **val_array, *val;
int i;
debug_decl(sudo_sss_filter_user_netgroup, SUDOERS_DEBUG_SSSD, sudoers_debug_instance);
debug_decl(sudo_sss_filter_user_netgroup, SUDOERS_DEBUG_SSSD);
if (!handle || !rule)
debug_return_bool(ret);
@@ -645,7 +645,7 @@ sudo_sss_result_filterp(struct sudo_sss_handle *handle,
struct sss_sudo_rule *rule, void *unused)
{
(void)unused;
debug_decl(sudo_sss_result_filterp, SUDOERS_DEBUG_SSSD, sudoers_debug_instance);
debug_decl(sudo_sss_result_filterp, SUDOERS_DEBUG_SSSD);
if (sudo_sss_check_host(handle, rule) &&
sudo_sss_filter_user_netgroup(handle, rule))
@@ -660,7 +660,7 @@ sudo_sss_result_get(struct sudo_nss *nss, struct passwd *pw, uint32_t *state)
struct sudo_sss_handle *handle = nss->handle;
struct sss_sudo_result *u_sss_result, *f_sss_result;
uint32_t sss_error = 0, ret;
debug_decl(sudo_sss_result_get, SUDOERS_DEBUG_SSSD, sudoers_debug_instance);
debug_decl(sudo_sss_result_get, SUDOERS_DEBUG_SSSD);
if (sudo_sss_checkpw(nss, pw) != 0)
debug_return_ptr(NULL);
@@ -738,7 +738,7 @@ sudo_sss_check_bool(struct sudo_sss_handle *handle, struct sss_sudo_rule *rule,
{
char ch, *var, **val_array = NULL;
int i, ret = UNSPEC;
debug_decl(sudo_sss_check_bool, SUDOERS_DEBUG_SSSD, sudoers_debug_instance);
debug_decl(sudo_sss_check_bool, SUDOERS_DEBUG_SSSD);
if (rule == NULL)
debug_return_int(ret);
@@ -780,7 +780,7 @@ sudo_sss_extract_digest(char **cmnd, struct sudo_digest *digest)
{
char *ep, *cp = *cmnd;
int digest_type = SUDO_DIGEST_INVALID;
debug_decl(sudo_sss_check_command, SUDOERS_DEBUG_LDAP, sudoers_debug_instance)
debug_decl(sudo_sss_check_command, SUDOERS_DEBUG_LDAP)
/*
* Check for and extract a digest prefix, e.g.
@@ -849,7 +849,7 @@ sudo_sss_check_command(struct sudo_sss_handle *handle,
bool foundbang;
unsigned int i;
struct sudo_digest digest, *allowed_digest = NULL;
debug_decl(sudo_sss_check_command, SUDOERS_DEBUG_SSSD, sudoers_debug_instance);
debug_decl(sudo_sss_check_command, SUDOERS_DEBUG_SSSD);
if (rule == NULL)
debug_return_int(ret);
@@ -924,7 +924,7 @@ sudo_sss_parse_options(struct sudo_sss_handle *handle, struct sss_sudo_rule *rul
int i;
char op, *v, *val;
char **val_array = NULL;
debug_decl(sudo_sss_parse_options, SUDOERS_DEBUG_SSSD, sudoers_debug_instance);
debug_decl(sudo_sss_parse_options, SUDOERS_DEBUG_SSSD);
if (rule == NULL)
debug_return;
@@ -982,7 +982,7 @@ sudo_sss_lookup(struct sudo_nss *nss, int ret, int pwflag)
struct sss_sudo_result *sss_result = NULL;
struct sss_sudo_rule *rule;
uint32_t i, state = 0;
debug_decl(sudo_sss_lookup, SUDOERS_DEBUG_SSSD, sudoers_debug_instance);
debug_decl(sudo_sss_lookup, SUDOERS_DEBUG_SSSD);
/* Fetch list of sudoRole entries that match user and host. */
sss_result = sudo_sss_result_get(nss, sudo_user.pw, &state);
@@ -1103,7 +1103,7 @@ sudo_sss_display_cmnd(struct sudo_nss *nss, struct passwd *pw)
struct sss_sudo_rule *rule;
unsigned int i;
bool found = false;
debug_decl(sudo_sss_display_cmnd, SUDOERS_DEBUG_SSSD, sudoers_debug_instance);
debug_decl(sudo_sss_display_cmnd, SUDOERS_DEBUG_SSSD);
if (handle == NULL)
goto done;
@@ -1152,7 +1152,7 @@ sudo_sss_display_defaults(struct sudo_nss *nss, struct passwd *pw,
char *prefix, *val, **val_array = NULL;
unsigned int i, j;
int count = 0;
debug_decl(sudo_sss_display_defaults, SUDOERS_DEBUG_SSSD, sudoers_debug_instance);
debug_decl(sudo_sss_display_defaults, SUDOERS_DEBUG_SSSD);
if (handle == NULL)
goto done;
@@ -1214,7 +1214,7 @@ static int
sudo_sss_display_bound_defaults(struct sudo_nss *nss,
struct passwd *pw, struct sudo_lbuf *lbuf)
{
debug_decl(sudo_sss_display_bound_defaults, SUDOERS_DEBUG_SSSD, sudoers_debug_instance);
debug_decl(sudo_sss_display_bound_defaults, SUDOERS_DEBUG_SSSD);
debug_return_int(0);
}
@@ -1224,7 +1224,7 @@ sudo_sss_display_entry_long(struct sudo_sss_handle *handle,
{
char **val_array = NULL;
int count = 0, i;
debug_decl(sudo_sss_display_entry_long, SUDOERS_DEBUG_SSSD, sudoers_debug_instance);
debug_decl(sudo_sss_display_entry_long, SUDOERS_DEBUG_SSSD);
/* get the RunAsUser Values from the entry */
sudo_lbuf_append(lbuf, " RunAsUsers: ");
@@ -1319,7 +1319,7 @@ sudo_sss_display_entry_short(struct sudo_sss_handle *handle,
{
char **val_array = NULL;
int count = 0, i;
debug_decl(sudo_sss_display_entry_short, SUDOERS_DEBUG_SSSD, sudoers_debug_instance);
debug_decl(sudo_sss_display_entry_short, SUDOERS_DEBUG_SSSD);
sudo_lbuf_append(lbuf, " (");
@@ -1432,7 +1432,7 @@ sudo_sss_display_privs(struct sudo_nss *nss, struct passwd *pw,
struct sss_sudo_result *sss_result = NULL;
struct sss_sudo_rule *rule;
unsigned int i, count = 0;
debug_decl(sudo_sss_display_privs, SUDOERS_DEBUG_SSSD, sudoers_debug_instance);
debug_decl(sudo_sss_display_privs, SUDOERS_DEBUG_SSSD);
if (handle == NULL)
debug_return_int(-1);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2007-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2007-2015 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
@@ -80,7 +80,7 @@ sudo_read_nss(void)
bool saw_files = false;
bool got_match = false;
static struct sudo_nss_list snl = TAILQ_HEAD_INITIALIZER(snl);
debug_decl(sudo_read_nss, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_read_nss, SUDOERS_DEBUG_NSS)
if ((fp = fopen(_PATH_NSSWITCH_CONF, "r")) == NULL)
goto nomatch;
@@ -158,7 +158,7 @@ sudo_read_nss(void)
bool saw_ldap = false;
bool got_match = false;
static struct sudo_nss_list snl = TAILQ_HEAD_INITIALIZER(snl);
debug_decl(sudo_read_nss, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_read_nss, SUDOERS_DEBUG_NSS)
if ((fp = fopen(_PATH_NETSVC_CONF, "r")) == NULL)
goto nomatch;
@@ -239,7 +239,7 @@ struct sudo_nss_list *
sudo_read_nss(void)
{
static struct sudo_nss_list snl = TAILQ_HEAD_INITIALIZER(snl);
debug_decl(sudo_read_nss, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(sudo_read_nss, SUDOERS_DEBUG_NSS)
# ifdef HAVE_SSSD
TAILQ_INSERT_TAIL(&snl, &sudo_nss_sss, entries);
@@ -261,7 +261,7 @@ output(const char *buf)
{
struct sudo_conv_message msg;
struct sudo_conv_reply repl;
debug_decl(output, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(output, SUDOERS_DEBUG_NSS)
/* Call conversation function */
memset(&msg, 0, sizeof(msg));
@@ -284,7 +284,7 @@ display_privs(struct sudo_nss_list *snl, struct passwd *pw)
struct sudo_lbuf defs, privs;
struct stat sb;
int cols, count, olen;
debug_decl(display_privs, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(display_privs, SUDOERS_DEBUG_NSS)
cols = sudo_user.cols;
if (fstat(STDOUT_FILENO, &sb) == 0 && S_ISFIFO(sb.st_mode))
@@ -349,7 +349,7 @@ bool
display_cmnd(struct sudo_nss_list *snl, struct passwd *pw)
{
struct sudo_nss *nss;
debug_decl(display_cmnd, SUDOERS_DEBUG_NSS, sudoers_debug_instance)
debug_decl(display_cmnd, SUDOERS_DEBUG_NSS)
TAILQ_FOREACH(nss, snl, entries) {
if (nss->display_cmnd(nss, pw) == 0)

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1993-1996, 1998-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 1993-1996, 1998-2015 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
@@ -120,7 +120,7 @@ sudoers_policy_init(void *info, char * const envp[])
volatile int sources = 0;
struct sudo_nss *nss, *nss_next;
int rval = -1;
debug_decl(sudoers_policy_init, SUDOERS_DEBUG_PLUGIN, sudoers_debug_instance)
debug_decl(sudoers_policy_init, SUDOERS_DEBUG_PLUGIN)
bindtextdomain("sudoers", LOCALEDIR);
@@ -226,7 +226,7 @@ sudoers_policy_main(int argc, char * const argv[], int pwflag, char *env_add[],
struct sudo_nss *nss;
int cmnd_status = -1, oldlocale, validated;
volatile int rval = true;
debug_decl(sudoers_policy_main, SUDOERS_DEBUG_PLUGIN, sudoers_debug_instance)
debug_decl(sudoers_policy_main, SUDOERS_DEBUG_PLUGIN)
/* Is root even allowed to run sudo? */
if (user_uid == 0 && !def_root_sudo) {
@@ -561,7 +561,7 @@ init_vars(char * const envp[])
{
char * const * ep;
bool unknown_user = false;
debug_decl(init_vars, SUDOERS_DEBUG_PLUGIN, sudoers_debug_instance)
debug_decl(init_vars, SUDOERS_DEBUG_PLUGIN)
sudoers_initlocale(setlocale(LC_ALL, NULL), def_sudoers_locale);
@@ -642,7 +642,7 @@ set_cmnd(void)
{
int rval = FOUND;
char *path = user_path;
debug_decl(set_cmnd, SUDOERS_DEBUG_PLUGIN, sudoers_debug_instance)
debug_decl(set_cmnd, SUDOERS_DEBUG_PLUGIN)
/* Allocate user_stat for find_path() and match functions. */
user_stat = sudo_ecalloc(1, sizeof(struct stat));
@@ -739,7 +739,7 @@ open_sudoers(const char *sudoers, bool doedit, bool *keepopen)
{
struct stat sb;
FILE *fp = NULL;
debug_decl(open_sudoers, SUDOERS_DEBUG_PLUGIN, sudoers_debug_instance)
debug_decl(open_sudoers, SUDOERS_DEBUG_PLUGIN)
if (!set_perms(PERM_SUDOERS))
debug_return_ptr(NULL);
@@ -817,7 +817,7 @@ set_loginclass(struct passwd *pw)
const int errflags = SLOG_RAW_MSG;
login_cap_t *lc;
bool rval = true;
debug_decl(set_loginclass, SUDOERS_DEBUG_PLUGIN, sudoers_debug_instance)
debug_decl(set_loginclass, SUDOERS_DEBUG_PLUGIN)
if (!def_use_loginclass)
goto done;
@@ -875,7 +875,7 @@ set_fqdn(void)
struct addrinfo *res0, hint;
bool remote;
char *p;
debug_decl(set_fqdn, SUDOERS_DEBUG_PLUGIN, sudoers_debug_instance)
debug_decl(set_fqdn, SUDOERS_DEBUG_PLUGIN)
/* If the -h flag was given we need to resolve both host and runhost. */
remote = strcmp(user_runhost, user_host) != 0;
@@ -940,7 +940,7 @@ static bool
set_runaspw(const char *user, bool quiet)
{
struct passwd *pw = NULL;
debug_decl(set_runaspw, SUDOERS_DEBUG_PLUGIN, sudoers_debug_instance)
debug_decl(set_runaspw, SUDOERS_DEBUG_PLUGIN)
if (*user == '#') {
const char *errstr;
@@ -971,7 +971,7 @@ static bool
set_runasgr(const char *group, bool quiet)
{
struct group *gr = NULL;
debug_decl(set_runasgr, SUDOERS_DEBUG_PLUGIN, sudoers_debug_instance)
debug_decl(set_runasgr, SUDOERS_DEBUG_PLUGIN)
if (*group == '#') {
const char *errstr;
@@ -1023,7 +1023,7 @@ void
sudoers_cleanup(void)
{
struct sudo_nss *nss;
debug_decl(sudoers_cleanup, SUDOERS_DEBUG_PLUGIN, sudoers_debug_instance)
debug_decl(sudoers_cleanup, SUDOERS_DEBUG_PLUGIN)
if (snl != NULL) {
TAILQ_FOREACH(nss, snl, entries) {
@@ -1044,7 +1044,7 @@ resolve_editor(const char *ed, size_t edlen, int nfiles, char **files, int *argc
char *cp, **nargv, *editor, *editor_path = NULL;
int ac, i, nargc;
bool wasblank;
debug_decl(resolve_editor, SUDOERS_DEBUG_PLUGIN, sudoers_debug_instance)
debug_decl(resolve_editor, SUDOERS_DEBUG_PLUGIN)
/* Note: editor becomes part of argv_out and is not freed. */
editor = sudo_emalloc(edlen + 1);
@@ -1098,7 +1098,7 @@ find_editor(int nfiles, char **files, int *argc_out, char ***argv_out)
const char *cp, *ep, *editor;
char *editor_path = NULL, **ev, *ev0[4];
size_t len;
debug_decl(find_editor, SUDOERS_DEBUG_PLUGIN, sudoers_debug_instance)
debug_decl(find_editor, SUDOERS_DEBUG_PLUGIN)
/*
* If any of SUDO_EDITOR, VISUAL or EDITOR are set, choose the first one.
@@ -1139,7 +1139,7 @@ create_admin_success_flag(void)
struct stat statbuf;
char flagfile[PATH_MAX];
int fd, n;
debug_decl(create_admin_success_flag, SUDOERS_DEBUG_PLUGIN, sudoers_debug_instance)
debug_decl(create_admin_success_flag, SUDOERS_DEBUG_PLUGIN)
/* Check whether the user is in the admin group. */
if (!user_in_group(sudo_user.pw, "admin"))

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1993-1996, 1998-2005, 2007-2014
* Copyright (c) 1993-1996, 1998-2005, 2007-2015
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -348,7 +348,6 @@ void sudoers_cleanup(void);
void sudoers_debug_parse_flags(struct sudo_conf_debug_file_list *debug_files, const char *entry);
void sudoers_debug_register(const char *plugin_path, struct sudo_conf_debug_file_list *debug_files);
void sudoers_debug_deregister(void);
extern int sudoers_debug_instance;
/* policy.c */
int sudoers_policy_deserialize_info(void *v, char **runas_user, char **runas_group);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2014-2015 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
@@ -44,7 +44,7 @@
#include "sudoers.h"
int sudoers_debug_instance = SUDO_DEBUG_INSTANCE_INITIALIZER;
static int sudoers_debug_instance = SUDO_DEBUG_INSTANCE_INITIALIZER;
static const char *const sudoers_subsystem_names[] = {
"alias",
@@ -136,7 +136,7 @@ sudoers_debug_register(const char *program,
void
sudoers_debug_deregister(void)
{
debug_decl(sudoers_debug_deregister, SUDOERS_DEBUG_PLUGIN, sudoers_debug_instance)
debug_decl(sudoers_debug_deregister, SUDOERS_DEBUG_PLUGIN)
if (sudoers_debug_instance != SUDO_DEBUG_INSTANCE_INITIALIZER) {
sudo_debug_exit(__func__, __FILE__, __LINE__, sudo_debug_subsys);
sudo_debug_deregister(sudoers_debug_instance);

View File

@@ -169,8 +169,6 @@ struct search_node {
static struct search_node_list search_expr = STAILQ_HEAD_INITIALIZER(search_expr);
static int sudoreplay_debug_instance = SUDO_DEBUG_INSTANCE_INITIALIZER;
static int timing_idx_adj;
static double speed_factor = 1.0;
@@ -238,7 +236,7 @@ main(int argc, char *argv[])
char *cp, *ep, path[PATH_MAX];
struct log_info *li;
double max_wait = 0;
debug_decl(main, SUDO_DEBUG_MAIN, sudoreplay_debug_instance)
debug_decl(main, SUDO_DEBUG_MAIN)
#if defined(SUDO_DEVEL) && defined(__OpenBSD__)
{
@@ -258,8 +256,8 @@ main(int argc, char *argv[])
/* Read sudo.conf and initialize the debug subsystem. */
sudo_conf_read(NULL, SUDO_CONF_DEBUG);
sudoreplay_debug_instance = sudo_debug_register(getprogname(),
NULL, NULL, sudo_conf_debug_files(getprogname()));
sudo_debug_register(getprogname(), NULL, NULL,
sudo_conf_debug_files(getprogname()));
while ((ch = getopt_long(argc, argv, short_opts, long_opts, NULL)) != -1) {
switch (ch) {
@@ -389,7 +387,7 @@ replay_session(const double max_wait, const char *decimal)
char buf[LINE_MAX];
sigaction_t sa;
int idx;
debug_decl(replay_session, SUDO_DEBUG_UTIL, sudoreplay_debug_instance)
debug_decl(replay_session, SUDO_DEBUG_UTIL)
/* Restore tty settings if interupted. */
fflush(stdout);
@@ -563,7 +561,7 @@ replay_session(const double max_wait, const char *decimal)
static int
open_io_fd(char *path, int len, struct io_log_file *iol)
{
debug_decl(open_io_fd, SUDO_DEBUG_UTIL, sudoreplay_debug_instance)
debug_decl(open_io_fd, SUDO_DEBUG_UTIL)
if (!iol->enabled)
debug_return_int(0);
@@ -584,7 +582,7 @@ write_output(int fd, int what, void *v)
struct write_closure *wc = v;
size_t nwritten;
unsigned int i;
debug_decl(write_output, SUDO_DEBUG_UTIL, sudoreplay_debug_instance)
debug_decl(write_output, SUDO_DEBUG_UTIL)
nwritten = writev(STDOUT_FILENO, wc->iov, wc->iovcnt);
switch ((ssize_t)nwritten) {
@@ -631,7 +629,7 @@ parse_expr(struct search_node_list *head, char *argv[], bool sub_expr)
bool or = false, not = false;
struct search_node *sn;
char type, **av;
debug_decl(parse_expr, SUDO_DEBUG_UTIL, sudoreplay_debug_instance)
debug_decl(parse_expr, SUDO_DEBUG_UTIL)
for (av = argv; *av != NULL; av++) {
switch (av[0][0]) {
@@ -750,7 +748,7 @@ match_expr(struct search_node_list *head, struct log_info *log, bool last_match)
struct search_node *sn;
bool res, matched = last_match;
int rc;
debug_decl(match_expr, SUDO_DEBUG_UTIL, sudoreplay_debug_instance)
debug_decl(match_expr, SUDO_DEBUG_UTIL)
STAILQ_FOREACH(sn, head, entries) {
switch (sn->type) {
@@ -811,7 +809,7 @@ parse_logfile(char *logfile)
const char *errstr;
size_t bufsize = 0, cwdsize = 0, cmdsize = 0;
struct log_info *li = NULL;
debug_decl(parse_logfile, SUDO_DEBUG_UTIL, sudoreplay_debug_instance)
debug_decl(parse_logfile, SUDO_DEBUG_UTIL)
fp = fopen(logfile, "r");
if (fp == NULL) {
@@ -943,7 +941,7 @@ list_session(char *logfile, REGEX_T *re, const char *user, const char *tty)
const char *timestr;
struct log_info *li;
int rval = -1;
debug_decl(list_session, SUDO_DEBUG_UTIL, sudoreplay_debug_instance)
debug_decl(list_session, SUDO_DEBUG_UTIL)
if ((li = parse_logfile(logfile)) == NULL)
goto done;
@@ -1008,7 +1006,7 @@ find_sessions(const char *dir, REGEX_T *re, const char *user, const char *tty)
#else
const bool checked_type = false;
#endif
debug_decl(find_sessions, SUDO_DEBUG_UTIL, sudoreplay_debug_instance)
debug_decl(find_sessions, SUDO_DEBUG_UTIL)
d = opendir(dir);
if (d == NULL)
@@ -1082,7 +1080,7 @@ list_sessions(int argc, char **argv, const char *pattern, const char *user,
const char *tty)
{
REGEX_T rebuf, *re = NULL;
debug_decl(list_sessions, SUDO_DEBUG_UTIL, sudoreplay_debug_instance)
debug_decl(list_sessions, SUDO_DEBUG_UTIL)
/* Parse search expression if present */
parse_expr(&search_expr, argv, false);
@@ -1113,7 +1111,7 @@ check_input(int fd, int what, void *v)
struct timeval tv, *timeout = NULL;
static bool paused = 0;
char ch;
debug_decl(check_input, SUDO_DEBUG_UTIL, sudoreplay_debug_instance)
debug_decl(check_input, SUDO_DEBUG_UTIL)
if (ISSET(what, SUDO_EV_READ)) {
switch (read(fd, &ch, 1)) {
@@ -1177,7 +1175,7 @@ parse_timing(const char *buf, const char *decimal, int *idx, double *seconds,
long l;
double d, fract = 0;
char *cp, *ep;
debug_decl(parse_timing, SUDO_DEBUG_UTIL, sudoreplay_debug_instance)
debug_decl(parse_timing, SUDO_DEBUG_UTIL)
/* Parse index */
ul = strtoul(buf, &ep, 10);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 1998-2005, 2007-2014
* Copyright (c) 1996, 1998-2005, 2007-2015
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -123,7 +123,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, SUDOERS_DEBUG_MAIN, sudoers_debug_instance)
debug_decl(main, SUDOERS_DEBUG_MAIN)
#if defined(SUDO_DEVEL) && defined(__OpenBSD__)
malloc_options = "AFGJPR";
@@ -349,7 +349,7 @@ static void
set_runaspw(const char *user)
{
struct passwd *pw = NULL;
debug_decl(set_runaspw, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(set_runaspw, SUDOERS_DEBUG_UTIL)
if (*user == '#') {
const char *errstr;
@@ -373,7 +373,7 @@ static void
set_runasgr(const char *group)
{
struct group *gr = NULL;
debug_decl(set_runasgr, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(set_runasgr, SUDOERS_DEBUG_UTIL)
if (*group == '#') {
const char *errstr;
@@ -423,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, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(open_sudoers, SUDOERS_DEBUG_UTIL)
sudoers_base = strrchr(sudoers, '/');
if (sudoers_base != NULL)
@@ -480,7 +480,7 @@ void
print_member(struct member *m)
{
struct sudo_command *c;
debug_decl(print_member, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(print_member, SUDOERS_DEBUG_UTIL)
if (m->negated)
putchar('!');
@@ -502,7 +502,7 @@ print_defaults(void)
{
struct defaults *d;
struct member *m;
debug_decl(print_defaults, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(print_defaults, SUDOERS_DEBUG_UTIL)
TAILQ_FOREACH(d, &defaults, entries) {
(void) fputs("Defaults", stdout);
@@ -541,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, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(print_alias, SUDOERS_DEBUG_UTIL)
switch (a->type) {
case HOSTALIAS:
@@ -580,7 +580,7 @@ print_privilege(struct privilege *priv)
struct cmndspec *cs;
struct member *m;
struct cmndtag tags;
debug_decl(print_privilege, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(print_privilege, SUDOERS_DEBUG_UTIL)
TAILQ_FOREACH(m, &priv->hostlist, entries) {
if (m != TAILQ_FIRST(&priv->hostlist))
@@ -644,7 +644,7 @@ print_userspecs(void)
struct member *m;
struct userspec *us;
struct privilege *priv;
debug_decl(print_userspecs, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(print_userspecs, SUDOERS_DEBUG_UTIL)
TAILQ_FOREACH(us, &userspecs, entries) {
TAILQ_FOREACH(m, &us->users, entries) {
@@ -666,7 +666,7 @@ print_userspecs(void)
void
dump_sudoers(void)
{
debug_decl(dump_sudoers, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(dump_sudoers, SUDOERS_DEBUG_UTIL)
print_defaults();

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2014-2015 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
@@ -70,7 +70,7 @@ static struct timestamp_entry timestamp_key;
static bool
ts_match_record(struct timestamp_entry *key, struct timestamp_entry *entry)
{
debug_decl(ts_match_record, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(ts_match_record, SUDOERS_DEBUG_AUTH)
if (entry->version != key->version)
debug_return_bool(false);
@@ -110,7 +110,7 @@ static bool
ts_find_record(int fd, struct timestamp_entry *key, struct timestamp_entry *entry)
{
struct timestamp_entry cur;
debug_decl(ts_find_record, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(ts_find_record, SUDOERS_DEBUG_AUTH)
/*
* Look for a matching record.
@@ -145,7 +145,7 @@ ts_update_record(int fd, struct timestamp_entry *entry, off_t timestamp_hint)
struct timestamp_entry cur;
ssize_t nwritten;
off_t old_eof = (off_t)-1;
debug_decl(ts_update_record, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(ts_update_record, SUDOERS_DEBUG_AUTH)
/* First try the hint if one is given. */
if (timestamp_hint != (off_t)-1) {
@@ -215,7 +215,7 @@ ts_mkdirs(char *path, uid_t owner, mode_t mode, mode_t parent_mode, bool quiet)
gid_t parent_gid = 0;
char *slash = path;
bool rval = false;
debug_decl(ts_mkdirs, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(ts_mkdirs, SUDOERS_DEBUG_AUTH)
while ((slash = strchr(slash + 1, '/')) != NULL) {
*slash = '\0';
@@ -265,7 +265,7 @@ ts_secure_dir(char *path, bool make_it, bool quiet)
{
struct stat sb;
bool rval = false;
debug_decl(ts_secure_dir, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(ts_secure_dir, SUDOERS_DEBUG_AUTH)
sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO, "checking %s", path);
switch (sudo_secure_dir(path, timestamp_uid, -1, &sb)) {
@@ -309,7 +309,7 @@ int
build_timestamp(struct passwd *pw)
{
int len;
debug_decl(build_timestamp, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(build_timestamp, SUDOERS_DEBUG_AUTH)
len = snprintf(timestamp_file, sizeof(timestamp_file), "%s/%s",
def_timestampdir, user_name);
@@ -333,7 +333,7 @@ update_timestamp(struct passwd *pw)
bool uid_changed = false;
bool rval = false;
int fd;
debug_decl(update_timestamp, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(update_timestamp, SUDOERS_DEBUG_AUTH)
/* Zero timeout means don't update the time stamp file. */
if (def_timestamp_timeout == 0)
@@ -382,7 +382,7 @@ timestamp_status(struct passwd *pw)
int status = TS_ERROR; /* assume the worst */
struct stat sb;
int fd = -1;
debug_decl(timestamp_status, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(timestamp_status, SUDOERS_DEBUG_AUTH)
/* Reset time stamp offset hint. */
timestamp_hint = (off_t)-1;
@@ -533,7 +533,7 @@ remove_timestamp(bool unlink_it)
struct timestamp_entry entry;
bool uid_changed = false;
int fd = -1;
debug_decl(remove_timestamp, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(remove_timestamp, SUDOERS_DEBUG_AUTH)
if (build_timestamp(NULL) == -1)
debug_return;
@@ -602,7 +602,7 @@ already_lectured(int unused)
char status_file[PATH_MAX];
struct stat sb;
int len;
debug_decl(already_lectured, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(already_lectured, SUDOERS_DEBUG_AUTH)
if (ts_secure_dir(def_lecture_status_dir, false, true)) {
len = snprintf(status_file, sizeof(status_file), "%s/%s",
@@ -626,7 +626,7 @@ set_lectured(void)
char lecture_status[PATH_MAX];
bool uid_changed = false;
int len, fd = -1;
debug_decl(set_lectured, SUDOERS_DEBUG_AUTH, sudoers_debug_instance)
debug_decl(set_lectured, SUDOERS_DEBUG_AUTH)
len = snprintf(lecture_status, sizeof(lecture_status), "%s/%s",
def_lecture_status_dir, user_name);

View File

@@ -1928,7 +1928,7 @@ char *yytext;
#define INITIAL 0
#line 2 "toke.l"
/*
* Copyright (c) 1996, 1998-2005, 2007-2014
* Copyright (c) 1996, 1998-2005, 2007-2015
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -4030,7 +4030,7 @@ read_dir_files(const char *dirpath, struct path_list ***pathsp)
int max_paths = 32;
struct dirent *dent;
struct path_list **paths = NULL;
debug_decl(read_dir_files, SUDOERS_DEBUG_PARSER, sudoers_debug_instance)
debug_decl(read_dir_files, SUDOERS_DEBUG_PARSER)
dir = opendir(dirpath);
if (dir == NULL) {
@@ -4105,7 +4105,7 @@ switch_dir(struct include_stack *stack, char *dirpath)
{
struct path_list **paths = NULL;
int count, i;
debug_decl(switch_dir, SUDOERS_DEBUG_PARSER, sudoers_debug_instance)
debug_decl(switch_dir, SUDOERS_DEBUG_PARSER)
count = read_dir_files(dirpath, &paths);
if (count > 0) {
@@ -4133,7 +4133,7 @@ void
init_lexer(void)
{
struct path_list *pl;
debug_decl(init_lexer, SUDOERS_DEBUG_PARSER, sudoers_debug_instance)
debug_decl(init_lexer, SUDOERS_DEBUG_PARSER)
while (idepth) {
idepth--;
@@ -4164,7 +4164,7 @@ _push_include(char *path, bool isdir)
{
struct path_list *pl;
FILE *fp;
debug_decl(_push_include, SUDOERS_DEBUG_PARSER, sudoers_debug_instance)
debug_decl(_push_include, SUDOERS_DEBUG_PARSER)
/* push current state onto stack */
if (idepth >= istacksize) {
@@ -4265,7 +4265,7 @@ pop_include(void)
{
struct path_list *pl;
FILE *fp;
debug_decl(pop_include, SUDOERS_DEBUG_PARSER, sudoers_debug_instance)
debug_decl(pop_include, SUDOERS_DEBUG_PARSER)
if (idepth == 0)
debug_return_bool(false);
@@ -4307,7 +4307,7 @@ parse_include(char *base)
char *cp, *ep, *path, *pp;
int dirlen = 0, len = 0, subst = 0;
size_t shost_len = 0;
debug_decl(parse_include, SUDOERS_DEBUG_PARSER, sudoers_debug_instance)
debug_decl(parse_include, SUDOERS_DEBUG_PARSER)
/* Pull out path from #include line. */
cp = base + sizeof("#include");

View File

@@ -1,6 +1,6 @@
%{
/*
* Copyright (c) 1996, 1998-2005, 2007-2014
* Copyright (c) 1996, 1998-2005, 2007-2015
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -771,7 +771,7 @@ read_dir_files(const char *dirpath, struct path_list ***pathsp)
int max_paths = 32;
struct dirent *dent;
struct path_list **paths = NULL;
debug_decl(read_dir_files, SUDOERS_DEBUG_PARSER, sudoers_debug_instance)
debug_decl(read_dir_files, SUDOERS_DEBUG_PARSER)
dir = opendir(dirpath);
if (dir == NULL) {
@@ -846,7 +846,7 @@ switch_dir(struct include_stack *stack, char *dirpath)
{
struct path_list **paths = NULL;
int count, i;
debug_decl(switch_dir, SUDOERS_DEBUG_PARSER, sudoers_debug_instance)
debug_decl(switch_dir, SUDOERS_DEBUG_PARSER)
count = read_dir_files(dirpath, &paths);
if (count > 0) {
@@ -874,7 +874,7 @@ void
init_lexer(void)
{
struct path_list *pl;
debug_decl(init_lexer, SUDOERS_DEBUG_PARSER, sudoers_debug_instance)
debug_decl(init_lexer, SUDOERS_DEBUG_PARSER)
while (idepth) {
idepth--;
@@ -905,7 +905,7 @@ _push_include(char *path, bool isdir)
{
struct path_list *pl;
FILE *fp;
debug_decl(_push_include, SUDOERS_DEBUG_PARSER, sudoers_debug_instance)
debug_decl(_push_include, SUDOERS_DEBUG_PARSER)
/* push current state onto stack */
if (idepth >= istacksize) {
@@ -1006,7 +1006,7 @@ pop_include(void)
{
struct path_list *pl;
FILE *fp;
debug_decl(pop_include, SUDOERS_DEBUG_PARSER, sudoers_debug_instance)
debug_decl(pop_include, SUDOERS_DEBUG_PARSER)
if (idepth == 0)
debug_return_bool(false);
@@ -1048,7 +1048,7 @@ parse_include(char *base)
char *cp, *ep, *path, *pp;
int dirlen = 0, len = 0, subst = 0;
size_t shost_len = 0;
debug_decl(parse_include, SUDOERS_DEBUG_PARSER, sudoers_debug_instance)
debug_decl(parse_include, SUDOERS_DEBUG_PARSER)
/* Pull out path from #include line. */
cp = base + sizeof("#include");

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 1998-2005, 2007-2014
* Copyright (c) 1996, 1998-2005, 2007-2015
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -61,7 +61,7 @@ fill_txt(const char *src, int len, int olen)
{
char *dst;
int h;
debug_decl(fill_txt, SUDOERS_DEBUG_PARSER, sudoers_debug_instance)
debug_decl(fill_txt, SUDOERS_DEBUG_PARSER)
dst = olen ? realloc(sudoerslval.string, olen + len + 1) : malloc(len + 1);
if (dst == NULL) {
@@ -96,7 +96,7 @@ bool
append(const char *src, int len)
{
int olen = 0;
debug_decl(append, SUDOERS_DEBUG_PARSER, sudoers_debug_instance)
debug_decl(append, SUDOERS_DEBUG_PARSER)
if (sudoerslval.string != NULL)
olen = strlen(sudoerslval.string);
@@ -112,7 +112,7 @@ fill_cmnd(const char *src, int len)
{
char *dst;
int i;
debug_decl(fill_cmnd, SUDOERS_DEBUG_PARSER, sudoers_debug_instance)
debug_decl(fill_cmnd, SUDOERS_DEBUG_PARSER)
arg_len = arg_size = 0;
@@ -141,7 +141,7 @@ fill_args(const char *s, int len, int addspace)
{
int new_len;
char *p;
debug_decl(fill_args, SUDOERS_DEBUG_PARSER, sudoers_debug_instance)
debug_decl(fill_args, SUDOERS_DEBUG_PARSER)
if (sudoerslval.command.args == NULL) {
addspace = 0;
@@ -188,7 +188,7 @@ bool
ipv6_valid(const char *s)
{
int nmatch = 0;
debug_decl(ipv6_valid, SUDOERS_DEBUG_PARSER, sudoers_debug_instance)
debug_decl(ipv6_valid, SUDOERS_DEBUG_PARSER)
for (; *s != '\0'; s++) {
if (s[0] == ':' && s[1] == ':') {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 1998-2005, 2007-2014
* Copyright (c) 1996, 1998-2005, 2007-2015
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -150,7 +150,7 @@ main(int argc, char *argv[])
int ch, exitcode = 0;
bool quiet, strict, oldperms;
const char *export_path;
debug_decl(main, SUDOERS_DEBUG_MAIN, sudoers_debug_instance)
debug_decl(main, SUDOERS_DEBUG_MAIN)
#if defined(SUDO_DEVEL) && defined(__OpenBSD__)
{
@@ -327,7 +327,7 @@ edit_sudoers(struct sudoersfile *sp, char *editor, char *args, int lineno)
ssize_t nread; /* number of bytes read */
struct stat sb; /* stat buffer */
bool rval = false; /* return value */
debug_decl(edit_sudoers, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(edit_sudoers, SUDOERS_DEBUG_UTIL)
if (fstat(sp->fd, &sb) == -1)
sudo_fatal(U_("unable to stat %s"), sp->path);
@@ -485,7 +485,7 @@ reparse_sudoers(char *editor, char *args, bool strict, bool quiet)
struct sudoersfile *sp, *last;
FILE *fp;
int ch;
debug_decl(reparse_sudoers, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(reparse_sudoers, SUDOERS_DEBUG_UTIL)
/*
* Parse the edited sudoers files and do sanity checking
@@ -572,7 +572,7 @@ install_sudoers(struct sudoersfile *sp, bool oldperms)
{
struct stat sb;
bool rval = false;
debug_decl(install_sudoers, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(install_sudoers, SUDOERS_DEBUG_UTIL)
if (!sp->modified) {
/*
@@ -712,7 +712,7 @@ static int
whatnow(void)
{
int choice, c;
debug_decl(whatnow, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(whatnow, SUDOERS_DEBUG_UTIL)
for (;;) {
(void) fputs(_("What now? "), stdout);
@@ -744,7 +744,7 @@ static void
setup_signals(void)
{
sigaction_t sa;
debug_decl(setup_signals, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(setup_signals, SUDOERS_DEBUG_UTIL)
/*
* Setup signal handlers to cleanup nicely.
@@ -766,7 +766,7 @@ run_command(char *path, char **argv)
{
int status;
pid_t pid, rv;
debug_decl(run_command, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(run_command, SUDOERS_DEBUG_UTIL)
switch (pid = sudo_debug_fork()) {
case -1:
@@ -796,7 +796,7 @@ check_owner(const char *path, bool quiet)
{
struct stat sb;
bool ok = true;
debug_decl(check_owner, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(check_owner, SUDOERS_DEBUG_UTIL)
if (stat(path, &sb) == 0) {
if (sb.st_uid != sudoers_uid || sb.st_gid != sudoers_gid) {
@@ -822,7 +822,7 @@ static bool
check_syntax(const char *sudoers_file, bool quiet, bool strict, bool oldperms)
{
bool ok = false;
debug_decl(check_syntax, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(check_syntax, SUDOERS_DEBUG_UTIL)
if (strcmp(sudoers_file, "-") == 0) {
sudoersin = stdin;
@@ -890,7 +890,7 @@ open_sudoers(const char *path, bool doedit, bool *keepopen)
struct sudoersfile *entry;
FILE *fp;
int open_flags;
debug_decl(open_sudoers, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(open_sudoers, SUDOERS_DEBUG_UTIL)
if (checkonly)
open_flags = O_RDONLY;
@@ -939,7 +939,7 @@ static char *
get_editor(char **args)
{
char *Editor, *EditorArgs, *EditorPath, *UserEditor, *UserEditorArgs;
debug_decl(get_editor, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(get_editor, SUDOERS_DEBUG_UTIL)
/*
* Check VISUAL and EDITOR environment variables to see which editor
@@ -1043,7 +1043,7 @@ static char *
get_args(char *cmnd)
{
char *args;
debug_decl(get_args, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(get_args, SUDOERS_DEBUG_UTIL)
args = cmnd;
while (*args && !isblank((unsigned char) *args))
@@ -1063,7 +1063,7 @@ static void
get_hostname(void)
{
char *p, thost[HOST_NAME_MAX + 1];
debug_decl(get_hostname, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(get_hostname, SUDOERS_DEBUG_UTIL)
if (gethostname(thost, sizeof(thost)) != -1) {
thost[sizeof(thost) - 1] = '\0';
@@ -1090,7 +1090,7 @@ alias_remove_recursive(char *name, int type)
struct member *m;
struct alias *a;
bool rval = true;
debug_decl(alias_remove_recursive, SUDOERS_DEBUG_ALIAS, sudoers_debug_instance)
debug_decl(alias_remove_recursive, SUDOERS_DEBUG_ALIAS)
if ((a = alias_remove(name, type)) != NULL) {
TAILQ_FOREACH(m, &a->members, entries) {
@@ -1120,7 +1120,7 @@ check_alias(char *name, int type, int strict, int quiet)
struct member *m;
struct alias *a;
int errors = 0;
debug_decl(check_alias, SUDOERS_DEBUG_ALIAS, sudoers_debug_instance)
debug_decl(check_alias, SUDOERS_DEBUG_ALIAS)
if ((a = alias_get(name, type)) != NULL) {
/* check alias contents */
@@ -1162,7 +1162,7 @@ check_aliases(bool strict, bool quiet)
struct userspec *us;
struct defaults *d;
int atype, errors = 0;
debug_decl(check_aliases, SUDOERS_DEBUG_ALIAS, sudoers_debug_instance)
debug_decl(check_aliases, SUDOERS_DEBUG_ALIAS)
alias_freelist = rbcreate(alias_compare);
@@ -1287,7 +1287,7 @@ static void
parse_sudoers_options(void)
{
struct plugin_info_list *plugins;
debug_decl(parse_sudoers_options, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(parse_sudoers_options, SUDOERS_DEBUG_UTIL)
plugins = sudo_conf_plugins();
if (plugins) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2013-2015 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
@@ -162,7 +162,7 @@ static void
print_pair_json(FILE *fp, const char *pre, const char *name,
const struct json_value *value, const char *post, int indent)
{
debug_decl(print_pair_json, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(print_pair_json, SUDOERS_DEBUG_UTIL)
print_indent(fp, indent);
@@ -215,7 +215,7 @@ static void
printstr_json(FILE *fp, const char *pre, const char *str, const char *post,
int indent)
{
debug_decl(printstr_json, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(printstr_json, SUDOERS_DEBUG_UTIL)
print_indent(fp, indent);
if (pre != NULL)
@@ -239,7 +239,7 @@ print_command_json(FILE *fp, struct member *m, int indent, bool last_one)
struct sudo_command *c = (struct sudo_command *)m->name;
struct json_value value;
const char *digest_name;
debug_decl(print_command_json, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(print_command_json, SUDOERS_DEBUG_UTIL)
printstr_json(fp, "{", NULL, NULL, indent);
if (m->negated || c->digest != NULL) {
@@ -362,7 +362,7 @@ print_member_json(FILE *fp, struct member *m, enum word_type word_type,
const char *typestr;
const char *errstr;
id_t id;
debug_decl(print_member_json, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(print_member_json, SUDOERS_DEBUG_UTIL)
/* Most of the time we print a string. */
value.type = JSON_STRING;
@@ -494,7 +494,7 @@ print_alias_json(void *v1, void *v2)
struct alias *a = v1;
struct json_alias_closure *closure = v2;
struct member *m;
debug_decl(print_alias_json, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(print_alias_json, SUDOERS_DEBUG_UTIL)
if (a->type != closure->alias_type)
debug_return_int(0);
@@ -527,7 +527,7 @@ static void
print_binding_json(FILE *fp, struct member_list *binding, int type, int indent)
{
struct member *m;
debug_decl(print_binding_json, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(print_binding_json, SUDOERS_DEBUG_UTIL)
if (TAILQ_EMPTY(binding))
debug_return;
@@ -555,7 +555,7 @@ print_defaults_list_json(FILE *fp, struct defaults *def, int indent)
{
char savech, *start, *end = def->val;
struct json_value value;
debug_decl(print_defaults_list_json, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(print_defaults_list_json, SUDOERS_DEBUG_UTIL)
fprintf(fp, "%*s{\n", indent, "");
indent += 4;
@@ -628,7 +628,7 @@ print_defaults_json(FILE *fp, int indent, bool need_comma)
struct json_value value;
struct defaults *def, *next;
int type;
debug_decl(print_defaults_json, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(print_defaults_json, SUDOERS_DEBUG_UTIL)
if (TAILQ_EMPTY(&defaults))
debug_return_bool(need_comma);
@@ -706,7 +706,7 @@ print_aliases_by_type_json(FILE *fp, int alias_type, const char *title,
int indent, bool need_comma)
{
struct json_alias_closure closure;
debug_decl(print_aliases_by_type_json, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(print_aliases_by_type_json, SUDOERS_DEBUG_UTIL)
closure.fp = fp;
closure.indent = indent;
@@ -733,7 +733,7 @@ print_aliases_by_type_json(FILE *fp, int alias_type, const char *title,
static bool
print_aliases_json(FILE *fp, int indent, bool need_comma)
{
debug_decl(print_aliases_json, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(print_aliases_json, SUDOERS_DEBUG_UTIL)
need_comma = print_aliases_by_type_json(fp, USERALIAS, "User_Aliases",
indent, need_comma);
@@ -776,7 +776,7 @@ print_cmndspec_json(FILE *fp, struct cmndspec *cs, struct cmndspec **nextp,
struct json_value value;
struct member *m;
bool last_one;
debug_decl(print_cmndspec_json, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(print_cmndspec_json, SUDOERS_DEBUG_UTIL)
/* Open Cmnd_Spec object. */
fprintf(fp, "%*s{\n", indent, "");
@@ -934,7 +934,7 @@ print_userspec_json(FILE *fp, struct userspec *us, int indent)
struct privilege *priv;
struct member *m;
struct cmndspec *cs, *next;
debug_decl(print_userspec_json, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(print_userspec_json, SUDOERS_DEBUG_UTIL)
/*
* Each userspec struct may contain multiple privileges for
@@ -988,7 +988,7 @@ static bool
print_userspecs_json(FILE *fp, int indent, bool need_comma)
{
struct userspec *us;
debug_decl(print_userspecs_json, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(print_userspecs_json, SUDOERS_DEBUG_UTIL)
if (TAILQ_EMPTY(&userspecs))
debug_return_bool(need_comma);
@@ -1015,7 +1015,7 @@ export_sudoers(const char *sudoers_path, const char *export_path,
bool ok = false, need_comma = false;
const int indent = 4;
FILE *export_fp = stdout;
debug_decl(export_sudoers, SUDOERS_DEBUG_UTIL, sudoers_debug_instance)
debug_decl(export_sudoers, SUDOERS_DEBUG_UTIL)
if (strcmp(sudoers_path, "-") == 0) {
sudoersin = stdin;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2009-2015 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
@@ -93,7 +93,7 @@ static int fork_cmnd(struct command_details *details, int sv[2])
{
struct command_status cstat;
sigaction_t sa;
debug_decl(fork_cmnd, SUDO_DEBUG_EXEC, sudo_debug_instance)
debug_decl(fork_cmnd, SUDO_DEBUG_EXEC)
ppgrp = getpgrp(); /* parent's process group */
@@ -160,7 +160,7 @@ void
exec_cmnd(struct command_details *details, struct command_status *cstat,
int errfd)
{
debug_decl(exec_cmnd, SUDO_DEBUG_EXEC, sudo_debug_instance)
debug_decl(exec_cmnd, SUDO_DEBUG_EXEC)
restore_signals();
if (exec_setup(details, NULL, -1) == true) {
@@ -206,7 +206,7 @@ backchannel_cb(int fd, int what, void *v)
{
struct exec_closure *ec = v;
ssize_t n;
debug_decl(backchannel_cb, SUDO_DEBUG_EXEC, sudo_debug_instance)
debug_decl(backchannel_cb, SUDO_DEBUG_EXEC)
/* read child status */
n = recv(fd, ec->cstat, sizeof(struct command_status), MSG_WAITALL);
@@ -298,7 +298,7 @@ static struct sudo_event_base *
exec_event_setup(int backchannel, struct exec_closure *ec)
{
struct sudo_event_base *evbase;
debug_decl(exec_event_setup, SUDO_DEBUG_EXEC, sudo_debug_instance)
debug_decl(exec_event_setup, SUDO_DEBUG_EXEC)
evbase = sudo_ev_base_alloc();
if (evbase == NULL)
@@ -349,7 +349,7 @@ sudo_execute(struct command_details *details, struct command_status *cstat)
sigaction_t sa;
pid_t child;
int sv[2];
debug_decl(sudo_execute, SUDO_DEBUG_EXEC, sudo_debug_instance)
debug_decl(sudo_execute, SUDO_DEBUG_EXEC)
dispatch_pending_signals(cstat);
@@ -542,7 +542,7 @@ dispatch_signal(struct sudo_event_base *evbase, pid_t child,
int signo, char *signame, struct command_status *cstat)
{
int rc = 1;
debug_decl(dispatch_signal, SUDO_DEBUG_EXEC, sudo_debug_instance)
debug_decl(dispatch_signal, SUDO_DEBUG_EXEC)
sudo_debug_printf(SUDO_DEBUG_INFO,
"%s: evbase %p, child: %d, signo %s(%d), cstat %p",
@@ -653,7 +653,7 @@ dispatch_signal_pty(struct sudo_event_base *evbase, pid_t child,
int signo, char *signame, struct command_status *cstat)
{
int rc = 1;
debug_decl(dispatch_signal_pty, SUDO_DEBUG_EXEC, sudo_debug_instance)
debug_decl(dispatch_signal_pty, SUDO_DEBUG_EXEC)
sudo_debug_printf(SUDO_DEBUG_INFO,
"%s: evbase %p, child: %d, signo %s(%d), cstat %p",
@@ -712,7 +712,7 @@ signal_pipe_cb(int fd, int what, void *v)
unsigned char signo;
ssize_t nread;
int rc = 0;
debug_decl(signal_pipe_cb, SUDO_DEBUG_EXEC, sudo_debug_instance)
debug_decl(signal_pipe_cb, SUDO_DEBUG_EXEC)
do {
/* read signal pipe */
@@ -760,7 +760,7 @@ dispatch_pending_signals(struct command_status *cstat)
struct sigaction sa;
unsigned char signo = 0;
int rval = 0;
debug_decl(dispatch_pending_signals, SUDO_DEBUG_EXEC, sudo_debug_instance)
debug_decl(dispatch_pending_signals, SUDO_DEBUG_EXEC)
for (;;) {
nread = read(signal_pipe[0], &signo, sizeof(signo));
@@ -815,7 +815,7 @@ forward_signals(int sock, int what, void *v)
struct sigforward *sigfwd;
struct command_status cstat;
ssize_t nsent;
debug_decl(forward_signals, SUDO_DEBUG_EXEC, sudo_debug_instance)
debug_decl(forward_signals, SUDO_DEBUG_EXEC)
while (!TAILQ_EMPTY(&sigfwd_list)) {
sigfwd = TAILQ_FIRST(&sigfwd_list);
@@ -859,7 +859,7 @@ schedule_signal(struct sudo_event_base *evbase, int signo)
{
struct sigforward *sigfwd;
char signame[SIG2STR_MAX];
debug_decl(schedule_signal, SUDO_DEBUG_EXEC, sudo_debug_instance)
debug_decl(schedule_signal, SUDO_DEBUG_EXEC)
if (signo == SIGCONT_FG)
strlcpy(signame, "CONT_FG", sizeof(signame));
@@ -979,7 +979,7 @@ int
pipe_nonblock(int fds[2])
{
int flags, rval;
debug_decl(pipe_nonblock, SUDO_DEBUG_EXEC, sudo_debug_instance)
debug_decl(pipe_nonblock, SUDO_DEBUG_EXEC)
rval = pipe(fds);
if (rval != -1) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2009-2015 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
@@ -61,7 +61,7 @@ disable_execute(char *const envp[])
bool enabled = false;
# endif
#endif /* _PATH_SUDO_NOEXEC */
debug_decl(disable_execute, SUDO_DEBUG_UTIL, sudo_debug_instance)
debug_decl(disable_execute, SUDO_DEBUG_UTIL)
#ifdef HAVE_PRIV_SET
/* Solaris privileges, remove PRIV_PROC_EXEC post-execve. */

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2009-2015 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
@@ -119,7 +119,7 @@ static void check_foreground(void);
static void
pty_cleanup(void)
{
debug_decl(cleanup, SUDO_DEBUG_EXEC, sudo_debug_instance);
debug_decl(cleanup, SUDO_DEBUG_EXEC);
if (!TAILQ_EMPTY(&io_plugins) && io_fds[SFD_USERTTY] != -1)
sudo_term_restore(io_fds[SFD_USERTTY], 0);
@@ -191,7 +191,7 @@ mon_handler(int s)
void
pty_setup(uid_t uid, const char *tty, const char *utmp_user)
{
debug_decl(pty_setup, SUDO_DEBUG_EXEC, sudo_debug_instance);
debug_decl(pty_setup, SUDO_DEBUG_EXEC);
io_fds[SFD_USERTTY] = open(_PATH_TTY, O_RDWR|O_NOCTTY, 0);
if (io_fds[SFD_USERTTY] != -1) {
@@ -213,14 +213,14 @@ log_ttyin(const char *buf, unsigned int n, struct io_buffer *iob)
struct plugin_container *plugin;
sigset_t omask;
bool rval = true;
debug_decl(log_ttyin, SUDO_DEBUG_EXEC, sudo_debug_instance);
debug_decl(log_ttyin, SUDO_DEBUG_EXEC);
sigprocmask(SIG_BLOCK, &ttyblock, &omask);
TAILQ_FOREACH(plugin, &io_plugins, entries) {
if (plugin->u.io->log_ttyin) {
int rc;
sudo_debug_set_default_instance(plugin->debug_instance);
sudo_debug_set_active_instance(plugin->debug_instance);
rc = plugin->u.io->log_ttyin(buf, n);
if (rc <= 0) {
if (rc < 0) {
@@ -232,7 +232,7 @@ log_ttyin(const char *buf, unsigned int n, struct io_buffer *iob)
}
}
}
sudo_debug_set_default_instance(sudo_debug_instance);
sudo_debug_set_active_instance(sudo_debug_instance);
sigprocmask(SIG_SETMASK, &omask, NULL);
debug_return_bool(rval);
@@ -245,14 +245,14 @@ log_stdin(const char *buf, unsigned int n, struct io_buffer *iob)
struct plugin_container *plugin;
sigset_t omask;
bool rval = true;
debug_decl(log_stdin, SUDO_DEBUG_EXEC, sudo_debug_instance);
debug_decl(log_stdin, SUDO_DEBUG_EXEC);
sigprocmask(SIG_BLOCK, &ttyblock, &omask);
TAILQ_FOREACH(plugin, &io_plugins, entries) {
if (plugin->u.io->log_stdin) {
int rc;
sudo_debug_set_default_instance(plugin->debug_instance);
sudo_debug_set_active_instance(plugin->debug_instance);
rc = plugin->u.io->log_stdin(buf, n);
if (rc <= 0) {
if (rc < 0) {
@@ -264,7 +264,7 @@ log_stdin(const char *buf, unsigned int n, struct io_buffer *iob)
}
}
}
sudo_debug_set_default_instance(sudo_debug_instance);
sudo_debug_set_active_instance(sudo_debug_instance);
sigprocmask(SIG_SETMASK, &omask, NULL);
debug_return_bool(rval);
@@ -277,14 +277,14 @@ log_ttyout(const char *buf, unsigned int n, struct io_buffer *iob)
struct plugin_container *plugin;
sigset_t omask;
bool rval = true;
debug_decl(log_ttyout, SUDO_DEBUG_EXEC, sudo_debug_instance);
debug_decl(log_ttyout, SUDO_DEBUG_EXEC);
sigprocmask(SIG_BLOCK, &ttyblock, &omask);
TAILQ_FOREACH(plugin, &io_plugins, entries) {
if (plugin->u.io->log_ttyout) {
int rc;
sudo_debug_set_default_instance(plugin->debug_instance);
sudo_debug_set_active_instance(plugin->debug_instance);
rc = plugin->u.io->log_ttyout(buf, n);
if (rc <= 0) {
if (rc < 0) {
@@ -296,7 +296,7 @@ log_ttyout(const char *buf, unsigned int n, struct io_buffer *iob)
}
}
}
sudo_debug_set_default_instance(sudo_debug_instance);
sudo_debug_set_active_instance(sudo_debug_instance);
if (!rval) {
/*
* I/O plugin rejected the output, delete the write event
@@ -321,14 +321,14 @@ log_stdout(const char *buf, unsigned int n, struct io_buffer *iob)
struct plugin_container *plugin;
sigset_t omask;
bool rval = true;
debug_decl(log_stdout, SUDO_DEBUG_EXEC, sudo_debug_instance);
debug_decl(log_stdout, SUDO_DEBUG_EXEC);
sigprocmask(SIG_BLOCK, &ttyblock, &omask);
TAILQ_FOREACH(plugin, &io_plugins, entries) {
if (plugin->u.io->log_stdout) {
int rc;
sudo_debug_set_default_instance(plugin->debug_instance);
sudo_debug_set_active_instance(plugin->debug_instance);
rc = plugin->u.io->log_stdout(buf, n);
if (rc <= 0) {
if (rc < 0) {
@@ -340,7 +340,7 @@ log_stdout(const char *buf, unsigned int n, struct io_buffer *iob)
}
}
}
sudo_debug_set_default_instance(sudo_debug_instance);
sudo_debug_set_active_instance(sudo_debug_instance);
if (!rval) {
/*
* I/O plugin rejected the output, delete the write event
@@ -365,14 +365,14 @@ log_stderr(const char *buf, unsigned int n, struct io_buffer *iob)
struct plugin_container *plugin;
sigset_t omask;
bool rval = true;
debug_decl(log_stderr, SUDO_DEBUG_EXEC, sudo_debug_instance);
debug_decl(log_stderr, SUDO_DEBUG_EXEC);
sigprocmask(SIG_BLOCK, &ttyblock, &omask);
TAILQ_FOREACH(plugin, &io_plugins, entries) {
if (plugin->u.io->log_stderr) {
int rc;
sudo_debug_set_default_instance(plugin->debug_instance);
sudo_debug_set_active_instance(plugin->debug_instance);
rc = plugin->u.io->log_stderr(buf, n);
if (rc <= 0) {
if (rc < 0) {
@@ -384,7 +384,7 @@ log_stderr(const char *buf, unsigned int n, struct io_buffer *iob)
}
}
}
sudo_debug_set_default_instance(sudo_debug_instance);
sudo_debug_set_active_instance(sudo_debug_instance);
if (!rval) {
/*
* I/O plugin rejected the output, delete the write event
@@ -410,7 +410,7 @@ log_stderr(const char *buf, unsigned int n, struct io_buffer *iob)
static void
check_foreground(void)
{
debug_decl(check_foreground, SUDO_DEBUG_EXEC, sudo_debug_instance);
debug_decl(check_foreground, SUDO_DEBUG_EXEC);
if (io_fds[SFD_USERTTY] != -1) {
foreground = tcgetpgrp(io_fds[SFD_USERTTY]) == ppgrp;
@@ -436,7 +436,7 @@ suspend_parent(int signo)
char signame[SIG2STR_MAX];
sigaction_t sa, osa;
int n, rval = 0;
debug_decl(suspend_parent, SUDO_DEBUG_EXEC, sudo_debug_instance);
debug_decl(suspend_parent, SUDO_DEBUG_EXEC);
switch (signo) {
case SIGTTOU:
@@ -526,7 +526,7 @@ suspend_parent(int signo)
void
terminate_command(pid_t pid, bool use_pgrp)
{
debug_decl(terminate_command, SUDO_DEBUG_EXEC, sudo_debug_instance);
debug_decl(terminate_command, SUDO_DEBUG_EXEC);
/*
* Note that SIGCHLD will interrupt the sleep()
@@ -561,7 +561,7 @@ io_callback(int fd, int what, void *v)
struct io_buffer *iob = v;
struct sudo_event_base *evbase;
int n;
debug_decl(io_callback, SUDO_DEBUG_EXEC, sudo_debug_instance);
debug_decl(io_callback, SUDO_DEBUG_EXEC);
if (ISSET(what, SUDO_EV_READ)) {
evbase = sudo_ev_get_base(iob->revent);
@@ -684,7 +684,7 @@ io_buf_new(int rfd, int wfd, bool (*action)(const char *, unsigned int, struct i
{
int n;
struct io_buffer *iob;
debug_decl(io_buf_new, SUDO_DEBUG_EXEC, sudo_debug_instance);
debug_decl(io_buf_new, SUDO_DEBUG_EXEC);
/* Set non-blocking mode. */
n = fcntl(rfd, F_GETFL, 0);
@@ -722,7 +722,7 @@ fork_pty(struct command_details *details, int sv[], sigset_t *omask)
sigaction_t sa;
sigset_t mask;
pid_t child;
debug_decl(fork_pty, SUDO_DEBUG_EXEC, sudo_debug_instance);
debug_decl(fork_pty, SUDO_DEBUG_EXEC);
ppgrp = getpgrp(); /* parent's pgrp, so child can signal us */
@@ -892,7 +892,7 @@ pty_close(struct command_status *cstat)
{
struct io_buffer *iob;
int n;
debug_decl(pty_close, SUDO_DEBUG_EXEC, sudo_debug_instance);
debug_decl(pty_close, SUDO_DEBUG_EXEC);
/* Flush any remaining output (the plugin already got it) */
if (io_fds[SFD_USERTTY] != -1) {
@@ -941,7 +941,7 @@ void
add_io_events(struct sudo_event_base *evbase)
{
struct io_buffer *iob;
debug_decl(add_io_events, SUDO_DEBUG_EXEC, sudo_debug_instance);
debug_decl(add_io_events, SUDO_DEBUG_EXEC);
/*
* Schedule all readers as long as the buffer is not full.
@@ -983,7 +983,7 @@ del_io_events(void)
{
struct io_buffer *iob;
struct sudo_event_base *evbase;
debug_decl(del_io_events, SUDO_DEBUG_EXEC, sudo_debug_instance);
debug_decl(del_io_events, SUDO_DEBUG_EXEC);
/* Remove iobufs from existing event base. */
SLIST_FOREACH(iob, &iobufs, entries) {
@@ -1047,7 +1047,7 @@ deliver_signal(pid_t pid, int signo, bool from_parent)
{
char signame[SIG2STR_MAX];
int status;
debug_decl(deliver_signal, SUDO_DEBUG_EXEC, sudo_debug_instance);
debug_decl(deliver_signal, SUDO_DEBUG_EXEC);
if (signo == SIGCONT_FG)
strlcpy(signame, "CONT_FG", sizeof(signame));
@@ -1096,7 +1096,7 @@ static int
send_status(int fd, struct command_status *cstat)
{
int n = -1;
debug_decl(send_status, SUDO_DEBUG_EXEC, sudo_debug_instance);
debug_decl(send_status, SUDO_DEBUG_EXEC);
if (cstat->type != CMD_INVALID) {
sudo_debug_printf(SUDO_DEBUG_INFO,
@@ -1126,7 +1126,7 @@ handle_sigchld(int backchannel, struct command_status *cstat)
bool alive = true;
int status;
pid_t pid;
debug_decl(handle_sigchld, SUDO_DEBUG_EXEC, sudo_debug_instance);
debug_decl(handle_sigchld, SUDO_DEBUG_EXEC);
/* read command status */
do {
@@ -1183,7 +1183,7 @@ mon_signal_pipe_cb(int fd, int what, void *v)
struct monitor_closure *mc = v;
unsigned char signo;
ssize_t nread;
debug_decl(mon_signal_pipe_cb, SUDO_DEBUG_EXEC, sudo_debug_instance);
debug_decl(mon_signal_pipe_cb, SUDO_DEBUG_EXEC);
nread = read(fd, &signo, sizeof(signo));
if (nread <= 0) {
@@ -1218,7 +1218,7 @@ mon_errpipe_cb(int fd, int what, void *v)
{
struct monitor_closure *mc = v;
ssize_t n;
debug_decl(mon_errpipe_cb, SUDO_DEBUG_EXEC, sudo_debug_instance);
debug_decl(mon_errpipe_cb, SUDO_DEBUG_EXEC);
/* read errno or EOF from command pipe */
n = read(fd, mc->cstat, sizeof(struct command_status));
@@ -1241,7 +1241,7 @@ mon_backchannel_cb(int fd, int what, void *v)
struct monitor_closure *mc = v;
struct command_status cstmp;
ssize_t n;
debug_decl(mon_backchannel_cb, SUDO_DEBUG_EXEC, sudo_debug_instance);
debug_decl(mon_backchannel_cb, SUDO_DEBUG_EXEC);
/* read command from backchannel, should be a signal */
n = recv(fd, &cstmp, sizeof(cstmp), MSG_WAITALL);
@@ -1279,7 +1279,7 @@ exec_monitor(struct command_details *details, int backchannel)
struct monitor_closure mc;
sigaction_t sa;
int errpipe[2], n;
debug_decl(exec_monitor, SUDO_DEBUG_EXEC, sudo_debug_instance);
debug_decl(exec_monitor, SUDO_DEBUG_EXEC);
/* Close unused fds. */
if (io_fds[SFD_MASTER] != -1)
@@ -1496,7 +1496,7 @@ exec_pty(struct command_details *details,
struct command_status *cstat, int errfd)
{
pid_t self = getpid();
debug_decl(exec_pty, SUDO_DEBUG_EXEC, sudo_debug_instance);
debug_decl(exec_pty, SUDO_DEBUG_EXEC);
/* Register cleanup function */
sudo_fatal_callback_register(pty_cleanup);
@@ -1541,7 +1541,7 @@ sync_ttysize(int src, int dst)
#ifdef TIOCGWINSZ
struct winsize wsize;
pid_t pgrp;
debug_decl(sync_ttysize, SUDO_DEBUG_EXEC, sudo_debug_instance);
debug_decl(sync_ttysize, SUDO_DEBUG_EXEC);
if (ioctl(src, TIOCGWINSZ, &wsize) == 0) {
ioctl(dst, TIOCSWINSZ, &wsize);
@@ -1573,7 +1573,7 @@ static void
ev_free_by_fd(struct sudo_event_base *evbase, int fd)
{
struct io_buffer *iob;
debug_decl(ev_free_by_fd, SUDO_DEBUG_EXEC, sudo_debug_instance);
debug_decl(ev_free_by_fd, SUDO_DEBUG_EXEC);
/* Deschedule any users of the fd and free up the events. */
SLIST_FOREACH(iob, &iobufs, entries) {
@@ -1608,7 +1608,7 @@ ev_free_by_fd(struct sudo_event_base *evbase, int fd)
static int
safe_close(int fd)
{
debug_decl(safe_close, SUDO_DEBUG_EXEC, sudo_debug_instance);
debug_decl(safe_close, SUDO_DEBUG_EXEC);
/* Avoid closing /dev/tty or std{in,out,err}. */
if (fd < 3 || fd == io_fds[SFD_USERTTY]) {

View File

@@ -1,5 +1,6 @@
/*
* Copyright (c) 2009-2012, 2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2009-2012, 2014-2015
* 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
@@ -63,7 +64,7 @@ get_pty(int *master, int *slave, char *name, size_t namesz, uid_t ttyuid)
struct group *gr;
gid_t ttygid = -1;
int rval = 0;
debug_decl(get_pty, SUDO_DEBUG_PTY, sudo_debug_instance)
debug_decl(get_pty, SUDO_DEBUG_PTY)
if ((gr = getgrnam("tty")) != NULL)
ttygid = gr->gr_gid;
@@ -82,7 +83,7 @@ get_pty(int *master, int *slave, char *name, size_t namesz, uid_t ttyuid)
{
char *line;
int rval = 0;
debug_decl(get_pty, SUDO_DEBUG_PTY, sudo_debug_instance)
debug_decl(get_pty, SUDO_DEBUG_PTY)
/* IRIX-style dynamic ptys (may fork) */
line = _getpty(master, O_RDWR, S_IRUSR|S_IWUSR|S_IWGRP, 0);
@@ -120,7 +121,7 @@ get_pty(int *master, int *slave, char *name, size_t namesz, uid_t ttyuid)
{
char *line;
int rval = 0;
debug_decl(get_pty, SUDO_DEBUG_PTY, sudo_debug_instance)
debug_decl(get_pty, SUDO_DEBUG_PTY)
*master = posix_openpt(O_RDWR|O_NOCTTY);
if (*master != -1) {
@@ -162,7 +163,7 @@ get_pty(int *master, int *slave, char *name, size_t namesz, uid_t ttyuid)
struct group *gr;
gid_t ttygid = -1;
int rval = 0;
debug_decl(get_pty, SUDO_DEBUG_PTY, sudo_debug_instance)
debug_decl(get_pty, SUDO_DEBUG_PTY)
if ((gr = getgrnam("tty")) != NULL)
ttygid = gr->gr_gid;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2012-2015 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
@@ -137,7 +137,7 @@ register_hook_internal(struct sudo_hook_list *head,
int (*hook_fn)(), void *closure)
{
struct sudo_hook_entry *hook;
debug_decl(register_hook_internal, SUDO_DEBUG_HOOKS, sudo_debug_instance)
debug_decl(register_hook_internal, SUDO_DEBUG_HOOKS)
hook = sudo_ecalloc(1, sizeof(*hook));
hook->u.generic_fn = hook_fn;
@@ -152,7 +152,7 @@ int
register_hook(struct sudo_hook *hook)
{
int rval = 0;
debug_decl(register_hook, SUDO_DEBUG_HOOKS, sudo_debug_instance)
debug_decl(register_hook, SUDO_DEBUG_HOOKS)
if (SUDO_HOOK_VERSION_GET_MAJOR(hook->hook_version) != SUDO_HOOK_VERSION_MAJOR) {
/* Major versions must match. */
@@ -191,7 +191,7 @@ deregister_hook_internal(struct sudo_hook_list *head,
int (*hook_fn)(), void *closure)
{
struct sudo_hook_entry *hook, *prev = NULL;
debug_decl(deregister_hook_internal, SUDO_DEBUG_HOOKS, sudo_debug_instance)
debug_decl(deregister_hook_internal, SUDO_DEBUG_HOOKS)
SLIST_FOREACH(hook, head, entries) {
if (hook->u.generic_fn == hook_fn && hook->closure == closure) {
@@ -214,7 +214,7 @@ int
deregister_hook(struct sudo_hook *hook)
{
int rval = 0;
debug_decl(deregister_hook, SUDO_DEBUG_HOOKS, sudo_debug_instance)
debug_decl(deregister_hook, SUDO_DEBUG_HOOKS)
if (SUDO_HOOK_VERSION_GET_MAJOR(hook->hook_version) != SUDO_HOOK_VERSION_MAJOR) {
/* Major versions must match. */

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2009-2015 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
@@ -52,7 +52,7 @@ sudo_stat_plugin(struct plugin_info *info, char *fullpath,
size_t pathsize, struct stat *sb)
{
int status = -1;
debug_decl(sudo_stat_plugin, SUDO_DEBUG_PLUGIN, sudo_debug_instance)
debug_decl(sudo_stat_plugin, SUDO_DEBUG_PLUGIN)
if (info->path[0] == '/') {
if (strlcpy(fullpath, info->path, pathsize) >= pathsize) {
@@ -136,7 +136,7 @@ sudo_check_plugin(struct plugin_info *info, char *fullpath, size_t pathsize)
{
struct stat sb;
int rval = false;
debug_decl(sudo_check_plugin, SUDO_DEBUG_PLUGIN, sudo_debug_instance)
debug_decl(sudo_check_plugin, SUDO_DEBUG_PLUGIN)
if (sudo_stat_plugin(info, fullpath, pathsize, &sb) != 0) {
sudo_warnx(U_("error in %s, line %d while loading plugin `%s'"),
@@ -165,7 +165,7 @@ done:
static bool
sudo_check_plugin(struct plugin_info *info, char *fullpath, size_t pathsize)
{
debug_decl(sudo_check_plugin, SUDO_DEBUG_PLUGIN, sudo_debug_instance)
debug_decl(sudo_check_plugin, SUDO_DEBUG_PLUGIN)
(void)strlcpy(fullpath, info->path, pathsize);
debug_return_bool(true);
}
@@ -183,7 +183,7 @@ sudo_load_plugin(struct plugin_container *policy_plugin,
char path[PATH_MAX];
bool rval = false;
void *handle;
debug_decl(sudo_load_plugin, SUDO_DEBUG_PLUGIN, sudo_debug_instance)
debug_decl(sudo_load_plugin, SUDO_DEBUG_PLUGIN)
/* Sanity check plugin and fill in path */
if (!sudo_check_plugin(info, path, sizeof(path)))
@@ -295,7 +295,7 @@ sudo_load_plugins(struct plugin_container *policy_plugin,
struct plugin_info_list *plugins;
struct plugin_info *info, *next;
bool rval = false;
debug_decl(sudo_load_plugins, SUDO_DEBUG_PLUGIN, sudo_debug_instance)
debug_decl(sudo_load_plugins, SUDO_DEBUG_PLUGIN)
/* Walk the plugin list from sudo.conf, if any and free it. */
plugins = sudo_conf_plugins();
@@ -342,7 +342,7 @@ sudo_load_plugins(struct plugin_container *policy_plugin,
}
/* Install hooks (XXX - later). */
sudo_debug_set_default_instance(SUDO_DEBUG_INSTANCE_INITIALIZER);
sudo_debug_set_active_instance(SUDO_DEBUG_INSTANCE_INITIALIZER);
if (policy_plugin->u.policy->version >= SUDO_API_MKVERSION(1, 2)) {
if (policy_plugin->u.policy->register_hooks != NULL)
policy_plugin->u.policy->register_hooks(SUDO_HOOK_VERSION, register_hook);
@@ -353,7 +353,7 @@ sudo_load_plugins(struct plugin_container *policy_plugin,
container->u.io->register_hooks(SUDO_HOOK_VERSION, register_hook);
}
}
sudo_debug_set_default_instance(sudo_debug_instance);
sudo_debug_set_active_instance(sudo_debug_instance);
done:
debug_return_bool(rval);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 1998-2005, 2007-2014
* Copyright (c) 1996, 1998-2005, 2007-2015
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -126,7 +126,7 @@ get_net_ifs(char **addrinfo)
#endif
int ailen, len, num_interfaces = 0;
char *cp;
debug_decl(get_net_ifs, SUDO_DEBUG_NETIF, SUDO_DEBUG_INSTANCE_DEFAULT) /* XXX */
debug_decl(get_net_ifs, SUDO_DEBUG_NETIF)
if (!sudo_conf_probe_interfaces() || getifaddrs(&ifaddrs) != 0)
debug_return_int(0);
@@ -226,7 +226,7 @@ get_net_ifs(char **addrinfo)
#ifdef _ISC
struct strioctl strioctl;
#endif /* _ISC */
debug_decl(get_net_ifs, SUDO_DEBUG_NETIF, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(get_net_ifs, SUDO_DEBUG_NETIF)
if (!sudo_conf_probe_interfaces())
debug_return_int(0);
@@ -347,7 +347,7 @@ done:
int
get_net_ifs(char **addrinfo)
{
debug_decl(get_net_ifs, SUDO_DEBUG_NETIF, SUDO_DEBUG_INSTANCE_DEFAULT)
debug_decl(get_net_ifs, SUDO_DEBUG_NETIF)
debug_return_int(0);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1993-1996, 1998-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 1993-1996, 1998-2015 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
@@ -178,7 +178,7 @@ parse_args(int argc, char **argv, int *nargc, char ***nargv,
int proglen;
int nenv = 0;
int env_size = 32;
debug_decl(parse_args, SUDO_DEBUG_ARGS, sudo_debug_instance)
debug_decl(parse_args, SUDO_DEBUG_ARGS)
env_add = sudo_emallocarray(env_size, sizeof(char *));
@@ -565,7 +565,7 @@ usage(int fatal)
static void
usage_excl(int fatal)
{
debug_decl(usage_excl, SUDO_DEBUG_ARGS, sudo_debug_instance)
debug_decl(usage_excl, SUDO_DEBUG_ARGS)
sudo_warnx(U_("Only one of the -e, -h, -i, -K, -l, -s, -v or -V options may be specified"));
usage(fatal);
@@ -577,7 +577,7 @@ help(void)
struct sudo_lbuf lbuf;
const int indent = 30;
const char *pname = getprogname();
debug_decl(help, SUDO_DEBUG_ARGS, sudo_debug_instance)
debug_decl(help, SUDO_DEBUG_ARGS)
sudo_lbuf_init(&lbuf, usage_out, indent, NULL, user_details.ts_cols);
if (strcmp(pname, "sudoedit") == 0)

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2013-2015 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
@@ -57,7 +57,7 @@ int
add_preserved_fd(struct preserved_fd_list *pfds, int fd)
{
struct preserved_fd *pfd, *pfd_new;
debug_decl(add_preserved_fd, SUDO_DEBUG_UTIL, sudo_debug_instance)
debug_decl(add_preserved_fd, SUDO_DEBUG_UTIL)
pfd_new = sudo_emalloc(sizeof(*pfd));
pfd_new->lowfd = fd;
@@ -102,7 +102,7 @@ closefrom_except(int startfd, struct preserved_fd_list *pfds)
int fd, lastfd = -1;
struct preserved_fd *pfd, *pfd_next;
fd_set *fdsp;
debug_decl(closefrom_except, SUDO_DEBUG_UTIL, sudo_debug_instance)
debug_decl(closefrom_except, SUDO_DEBUG_UTIL)
/* First, relocate preserved fds to be as contiguous as possible. */
TAILQ_FOREACH_REVERSE_SAFE(pfd, pfds, preserved_fd_list, entries, pfd_next) {
@@ -205,7 +205,7 @@ parse_preserved_fds(struct preserved_fd_list *pfds, const char *fdstr)
const char *cp = fdstr;
long lval;
char *ep;
debug_decl(parse_preserved_fds, SUDO_DEBUG_UTIL, sudo_debug_instance)
debug_decl(parse_preserved_fds, SUDO_DEBUG_UTIL)
do {
errno = 0;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2009-2015 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2008 Dan Walsh <dwalsh@redhat.com>
*
* Borrowed heavily from newrole source code
@@ -67,7 +67,7 @@ audit_role_change(const security_context_t old_context,
{
int au_fd, rc = -1;
char *message;
debug_decl(audit_role_change, SUDO_DEBUG_SELINUX, sudo_debug_instance)
debug_decl(audit_role_change, SUDO_DEBUG_SELINUX)
au_fd = audit_open();
if (au_fd == -1) {
@@ -103,7 +103,7 @@ selinux_restore_tty(void)
{
int retval = 0;
security_context_t chk_tty_context = NULL;
debug_decl(selinux_restore_tty, SUDO_DEBUG_SELINUX, sudo_debug_instance)
debug_decl(selinux_restore_tty, SUDO_DEBUG_SELINUX)
if (se_state.ttyfd == -1 || se_state.new_tty_context == NULL)
goto skip_relabel;
@@ -148,7 +148,7 @@ relabel_tty(const char *ttyn, int ptyfd)
security_context_t tty_con = NULL;
security_context_t new_tty_con = NULL;
int fd;
debug_decl(relabel_tty, SUDO_DEBUG_SELINUX, sudo_debug_instance)
debug_decl(relabel_tty, SUDO_DEBUG_SELINUX)
se_state.ttyfd = ptyfd;
@@ -245,7 +245,7 @@ get_exec_context(security_context_t old_context, const char *role, const char *t
security_context_t new_context = NULL;
context_t context = NULL;
char *typebuf = NULL;
debug_decl(get_exec_context, SUDO_DEBUG_SELINUX, sudo_debug_instance)
debug_decl(get_exec_context, SUDO_DEBUG_SELINUX)
/* We must have a role, the type is optional (we can use the default). */
if (!role) {
@@ -317,7 +317,7 @@ selinux_setup(const char *role, const char *type, const char *ttyn,
int ptyfd)
{
int rval = -1;
debug_decl(selinux_setup, SUDO_DEBUG_SELINUX, sudo_debug_instance)
debug_decl(selinux_setup, SUDO_DEBUG_SELINUX)
/* Store the caller's SID in old_context. */
if (getprevcon(&se_state.old_context)) {
@@ -373,7 +373,7 @@ selinux_execve(const char *path, char *const argv[], char *const envp[],
char **nargv;
const char *sesh;
int argc, serrno;
debug_decl(selinux_execve, SUDO_DEBUG_SELINUX, sudo_debug_instance)
debug_decl(selinux_execve, SUDO_DEBUG_SELINUX)
sesh = sudo_conf_sesh_path();
if (sesh == NULL) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008, 2010-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2008, 2010-2015 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
@@ -51,8 +51,6 @@
__dso_public int main(int argc, char *argv[], char *envp[]);
int sudo_debug_instance = SUDO_DEBUG_INSTANCE_INITIALIZER;
static int sesh_sudoedit(int argc, char *argv[]);
/*
@@ -68,7 +66,7 @@ int
main(int argc, char *argv[], char *envp[])
{
int ret;
debug_decl(main, SUDO_DEBUG_MAIN, sudo_debug_instance)
debug_decl(main, SUDO_DEBUG_MAIN)
initprogname(argc > 0 ? argv[0] : "sesh");
@@ -81,8 +79,8 @@ main(int argc, char *argv[], char *envp[])
/* Read sudo.conf and initialize the debug subsystem. */
sudo_conf_read(NULL, SUDO_CONF_DEBUG);
sudo_debug_instance = sudo_debug_register(getprogname(),
NULL, NULL, sudo_conf_debug_files(getprogname()));
sudo_debug_register(getprogname(), NULL, NULL,
sudo_conf_debug_files(getprogname()));
if (strcmp(argv[1], "-e") == 0) {
ret = sesh_sudoedit(argc, argv);
@@ -125,7 +123,7 @@ sesh_sudoedit(int argc, char *argv[])
struct stat sb;
struct timeval times[2];
char buf[BUFSIZ];
debug_decl(sesh_sudoedit, SUDO_DEBUG_EDIT, sudo_debug_instance)
debug_decl(sesh_sudoedit, SUDO_DEBUG_EDIT)
if (argc < 3)
debug_return_int(SESH_ERR_FAILURE);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2009-2015 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
@@ -70,7 +70,7 @@ void
save_signals(void)
{
struct signal_state *ss;
debug_decl(save_signals, SUDO_DEBUG_MAIN, sudo_debug_instance)
debug_decl(save_signals, SUDO_DEBUG_MAIN)
for (ss = saved_signals; ss->signo != -1; ss++) {
if (sigaction(ss->signo, NULL, &ss->sa) != 0)
@@ -87,7 +87,7 @@ void
restore_signals(void)
{
struct signal_state *ss;
debug_decl(restore_signals, SUDO_DEBUG_MAIN, sudo_debug_instance)
debug_decl(restore_signals, SUDO_DEBUG_MAIN)
for (ss = saved_signals; ss->signo != -1; ss++) {
if (ss->restore) {
@@ -127,7 +127,7 @@ init_signals(void)
{
struct sigaction sa;
struct signal_state *ss;
debug_decl(init_signals, SUDO_DEBUG_MAIN, sudo_debug_instance)
debug_decl(init_signals, SUDO_DEBUG_MAIN)
/*
* We use a pipe to atomically handle signal notification within
@@ -172,7 +172,7 @@ sudo_sigaction(int signo, struct sigaction *sa, struct sigaction *osa)
{
struct signal_state *ss;
int rval;
debug_decl(sudo_sigaction, SUDO_DEBUG_MAIN, sudo_debug_instance)
debug_decl(sudo_sigaction, SUDO_DEBUG_MAIN)
for (ss = saved_signals; ss->signo > 0; ss++) {
if (ss->signo == signo) {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2009-2015 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
@@ -71,7 +71,7 @@ set_project(struct passwd *pw)
struct project proj;
char buf[PROJECT_BUFSZ];
int errval;
debug_decl(set_project, SUDO_DEBUG_UTIL, sudo_debug_instance)
debug_decl(set_project, SUDO_DEBUG_UTIL)
/*
* Collect the default project for the user and settaskid

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2009-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2009-2015 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
@@ -152,7 +152,7 @@ main(int argc, char *argv[], char *envp[])
struct sudo_settings *settings;
struct plugin_container *plugin, *next;
sigset_t mask;
debug_decl(main, SUDO_DEBUG_MAIN, sudo_debug_instance)
debug_decl(main, SUDO_DEBUG_MAIN)
/* Make sure fds 0-2 are open and do OS-specific initialization. */
fix_fds();
@@ -327,7 +327,7 @@ static void
fix_fds(void)
{
int miss[3], devnull = -1;
debug_decl(fix_fds, SUDO_DEBUG_UTIL, sudo_debug_instance)
debug_decl(fix_fds, SUDO_DEBUG_UTIL)
/*
* stdin, stdout and stderr must be open; set them to /dev/null
@@ -359,7 +359,7 @@ static int
fill_group_list(struct user_details *ud, int system_maxgroups)
{
int tries, rval = -1;
debug_decl(fill_group_list, SUDO_DEBUG_UTIL, sudo_debug_instance)
debug_decl(fill_group_list, SUDO_DEBUG_UTIL)
/*
* If user specified a max number of groups, use it, otherwise keep
@@ -395,7 +395,7 @@ get_user_groups(struct user_details *ud)
char *cp, *gid_list = NULL;
size_t glsize;
int i, len, maxgroups, group_source;
debug_decl(get_user_groups, SUDO_DEBUG_UTIL, sudo_debug_instance)
debug_decl(get_user_groups, SUDO_DEBUG_UTIL)
#if defined(HAVE_SYSCONF) && defined(_SC_NGROUPS_MAX)
maxgroups = (int)sysconf(_SC_NGROUPS_MAX);
@@ -452,7 +452,7 @@ get_user_info(struct user_details *ud)
char *cp, **user_info, cwd[PATH_MAX], host[HOST_NAME_MAX + 1];
struct passwd *pw;
int fd, i = 0;
debug_decl(get_user_info, SUDO_DEBUG_UTIL, sudo_debug_instance)
debug_decl(get_user_info, SUDO_DEBUG_UTIL)
/* XXX - bound check number of entries */
user_info = sudo_emallocarray(32, sizeof(char *));
@@ -545,7 +545,7 @@ command_info_to_details(char * const info[], struct command_details *details)
id_t id;
char *cp;
const char *errstr;
debug_decl(command_info_to_details, SUDO_DEBUG_PCOMM, sudo_debug_instance)
debug_decl(command_info_to_details, SUDO_DEBUG_PCOMM)
memset(details, 0, sizeof(*details));
details->closefrom = -1;
@@ -749,7 +749,7 @@ sudo_check_suid(const char *sudo)
char pathbuf[PATH_MAX];
struct stat sb;
bool qualified;
debug_decl(sudo_check_suid, SUDO_DEBUG_PCOMM, sudo_debug_instance)
debug_decl(sudo_check_suid, SUDO_DEBUG_PCOMM)
if (geteuid() != 0) {
/* Search for sudo binary in PATH if not fully qualified. */
@@ -808,7 +808,7 @@ disable_coredumps(void)
{
#if defined(RLIMIT_CORE)
struct rlimit rl;
debug_decl(disable_coredumps, SUDO_DEBUG_UTIL, sudo_debug_instance)
debug_decl(disable_coredumps, SUDO_DEBUG_UTIL)
/*
* Turn off core dumps?
@@ -833,7 +833,7 @@ unlimit_nproc(void)
{
#ifdef __linux__
struct rlimit rl;
debug_decl(unlimit_nproc, SUDO_DEBUG_UTIL, sudo_debug_instance)
debug_decl(unlimit_nproc, SUDO_DEBUG_UTIL)
(void) getrlimit(RLIMIT_NPROC, &nproclimit);
rl.rlim_cur = rl.rlim_max = RLIM_INFINITY;
@@ -853,7 +853,7 @@ static void
restore_nproc(void)
{
#ifdef __linux__
debug_decl(restore_nproc, SUDO_DEBUG_UTIL, sudo_debug_instance)
debug_decl(restore_nproc, SUDO_DEBUG_UTIL)
(void) setrlimit(RLIMIT_NPROC, &nproclimit);
@@ -869,7 +869,7 @@ bool
exec_setup(struct command_details *details, const char *ptyname, int ptyfd)
{
bool rval = false;
debug_decl(exec_setup, SUDO_DEBUG_EXEC, sudo_debug_instance)
debug_decl(exec_setup, SUDO_DEBUG_EXEC)
#ifdef HAVE_SELINUX
if (ISSET(details->flags, CD_RBAC_ENABLED)) {
@@ -1039,7 +1039,7 @@ run_command(struct command_details *details)
struct plugin_container *plugin;
struct command_status cstat;
int exitcode = 1;
debug_decl(run_command, SUDO_DEBUG_EXEC, sudo_debug_instance)
debug_decl(run_command, SUDO_DEBUG_EXEC)
cstat.type = CMD_INVALID;
cstat.val = 0;
@@ -1097,7 +1097,7 @@ format_plugin_settings(struct plugin_container *plugin,
struct sudo_debug_file *debug_file;
struct sudo_settings *setting;
char **plugin_settings;
debug_decl(format_plugin_settings, SUDO_DEBUG_PCOMM, sudo_debug_instance)
debug_decl(format_plugin_settings, SUDO_DEBUG_PCOMM)
/* XXX - should use exact plugin_settings_size */
/* Determine sudo_settings array size (including plugin_path and NULL) */
@@ -1142,7 +1142,7 @@ policy_open(struct plugin_container *plugin, struct sudo_settings *settings,
{
char **plugin_settings;
int rval;
debug_decl(policy_open, SUDO_DEBUG_PCOMM, sudo_debug_instance)
debug_decl(policy_open, SUDO_DEBUG_PCOMM)
/* Convert struct sudo_settings to plugin_settings[] */
plugin_settings = format_plugin_settings(plugin, settings);
@@ -1152,7 +1152,7 @@ policy_open(struct plugin_container *plugin, struct sudo_settings *settings,
/*
* Backwards compatibility for older API versions
*/
sudo_debug_set_default_instance(SUDO_DEBUG_INSTANCE_INITIALIZER);
sudo_debug_set_active_instance(SUDO_DEBUG_INSTANCE_INITIALIZER);
switch (plugin->u.generic->version) {
case SUDO_API_MKVERSION(1, 0):
case SUDO_API_MKVERSION(1, 1):
@@ -1167,8 +1167,8 @@ policy_open(struct plugin_container *plugin, struct sudo_settings *settings,
}
/* Stash plugin debug instance ID if set in open() function. */
plugin->debug_instance = sudo_debug_get_default_instance();
sudo_debug_set_default_instance(sudo_debug_instance);
plugin->debug_instance = sudo_debug_get_active_instance();
sudo_debug_set_active_instance(sudo_debug_instance);
debug_return_bool(rval);
}
@@ -1176,11 +1176,11 @@ policy_open(struct plugin_container *plugin, struct sudo_settings *settings,
static void
policy_close(struct plugin_container *plugin, int exit_status, int error_code)
{
debug_decl(policy_close, SUDO_DEBUG_PCOMM, sudo_debug_instance)
debug_decl(policy_close, SUDO_DEBUG_PCOMM)
if (plugin->u.policy->close != NULL) {
sudo_debug_set_default_instance(plugin->debug_instance);
sudo_debug_set_active_instance(plugin->debug_instance);
plugin->u.policy->close(exit_status, error_code);
sudo_debug_set_default_instance(sudo_debug_instance);
sudo_debug_set_active_instance(sudo_debug_instance);
} else if (error_code) {
errno = error_code;
sudo_warn(U_("unable to execute %s"), command_details.command);
@@ -1192,13 +1192,13 @@ static int
policy_show_version(struct plugin_container *plugin, int verbose)
{
int rval;
debug_decl(policy_show_version, SUDO_DEBUG_PCOMM, sudo_debug_instance)
debug_decl(policy_show_version, SUDO_DEBUG_PCOMM)
if (plugin->u.policy->show_version == NULL)
debug_return_bool(true);
sudo_debug_set_default_instance(plugin->debug_instance);
sudo_debug_set_active_instance(plugin->debug_instance);
rval = plugin->u.policy->show_version(verbose);
sudo_debug_set_default_instance(sudo_debug_instance);
sudo_debug_set_active_instance(sudo_debug_instance);
debug_return_bool(rval);
}
@@ -1208,16 +1208,16 @@ policy_check(struct plugin_container *plugin, int argc, char * const argv[],
char **user_env_out[])
{
int rval;
debug_decl(policy_check, SUDO_DEBUG_PCOMM, sudo_debug_instance)
debug_decl(policy_check, SUDO_DEBUG_PCOMM)
if (plugin->u.policy->check_policy == NULL) {
sudo_fatalx(U_("policy plugin %s is missing the `check_policy' method"),
plugin->name);
}
sudo_debug_set_default_instance(plugin->debug_instance);
sudo_debug_set_active_instance(plugin->debug_instance);
rval = plugin->u.policy->check_policy(argc, argv, env_add, command_info,
argv_out, user_env_out);
sudo_debug_set_default_instance(sudo_debug_instance);
sudo_debug_set_active_instance(sudo_debug_instance);
debug_return_bool(rval);
}
@@ -1226,16 +1226,16 @@ policy_list(struct plugin_container *plugin, int argc, char * const argv[],
int verbose, const char *list_user)
{
int rval;
debug_decl(policy_list, SUDO_DEBUG_PCOMM, sudo_debug_instance)
debug_decl(policy_list, SUDO_DEBUG_PCOMM)
if (plugin->u.policy->list == NULL) {
sudo_warnx(U_("policy plugin %s does not support listing privileges"),
plugin->name);
debug_return_bool(false);
}
sudo_debug_set_default_instance(plugin->debug_instance);
sudo_debug_set_active_instance(plugin->debug_instance);
rval = plugin->u.policy->list(argc, argv, verbose, list_user);
sudo_debug_set_default_instance(sudo_debug_instance);
sudo_debug_set_active_instance(sudo_debug_instance);
debug_return_bool(rval);
}
@@ -1243,30 +1243,30 @@ static int
policy_validate(struct plugin_container *plugin)
{
int rval;
debug_decl(policy_validate, SUDO_DEBUG_PCOMM, sudo_debug_instance)
debug_decl(policy_validate, SUDO_DEBUG_PCOMM)
if (plugin->u.policy->validate == NULL) {
sudo_warnx(U_("policy plugin %s does not support the -v option"),
plugin->name);
debug_return_bool(false);
}
sudo_debug_set_default_instance(plugin->debug_instance);
sudo_debug_set_active_instance(plugin->debug_instance);
rval = plugin->u.policy->validate();
sudo_debug_set_default_instance(sudo_debug_instance);
sudo_debug_set_active_instance(sudo_debug_instance);
debug_return_bool(rval);
}
static void
policy_invalidate(struct plugin_container *plugin, int remove)
{
debug_decl(policy_invalidate, SUDO_DEBUG_PCOMM, sudo_debug_instance)
debug_decl(policy_invalidate, SUDO_DEBUG_PCOMM)
if (plugin->u.policy->invalidate == NULL) {
sudo_fatalx(U_("policy plugin %s does not support the -k/-K options"),
plugin->name);
}
sudo_debug_set_default_instance(plugin->debug_instance);
sudo_debug_set_active_instance(plugin->debug_instance);
plugin->u.policy->invalidate(remove);
sudo_debug_set_default_instance(sudo_debug_instance);
sudo_debug_set_active_instance(sudo_debug_instance);
debug_return;
}
@@ -1274,13 +1274,13 @@ int
policy_init_session(struct command_details *details)
{
int rval = true;
debug_decl(policy_init_session, SUDO_DEBUG_PCOMM, sudo_debug_instance)
debug_decl(policy_init_session, SUDO_DEBUG_PCOMM)
if (policy_plugin.u.policy->init_session) {
/*
* Backwards compatibility for older API versions
*/
sudo_debug_set_default_instance(policy_plugin.debug_instance);
sudo_debug_set_active_instance(policy_plugin.debug_instance);
switch (policy_plugin.u.generic->version) {
case SUDO_API_MKVERSION(1, 0):
case SUDO_API_MKVERSION(1, 1):
@@ -1290,7 +1290,7 @@ policy_init_session(struct command_details *details)
rval = policy_plugin.u.policy->init_session(details->pw,
&details->envp);
}
sudo_debug_set_default_instance(sudo_debug_instance);
sudo_debug_set_active_instance(sudo_debug_instance);
}
debug_return_bool(rval);
}
@@ -1302,7 +1302,7 @@ iolog_open(struct plugin_container *plugin, struct sudo_settings *settings,
{
char **plugin_settings;
int rval;
debug_decl(iolog_open, SUDO_DEBUG_PCOMM, sudo_debug_instance)
debug_decl(iolog_open, SUDO_DEBUG_PCOMM)
/* Convert struct sudo_settings to plugin_settings[] */
plugin_settings = format_plugin_settings(plugin, settings);
@@ -1312,7 +1312,7 @@ iolog_open(struct plugin_container *plugin, struct sudo_settings *settings,
/*
* Backwards compatibility for older API versions
*/
sudo_debug_set_default_instance(plugin->debug_instance);
sudo_debug_set_active_instance(plugin->debug_instance);
switch (plugin->u.generic->version) {
case SUDO_API_MKVERSION(1, 0):
rval = plugin->u.io_1_0->open(plugin->u.io_1_0->version,
@@ -1329,19 +1329,19 @@ iolog_open(struct plugin_container *plugin, struct sudo_settings *settings,
sudo_conversation_printf, plugin_settings, user_info, command_info,
argc, argv, user_env, plugin->options);
}
sudo_debug_set_default_instance(sudo_debug_instance);
sudo_debug_set_active_instance(sudo_debug_instance);
debug_return_bool(rval);
}
static void
iolog_close(struct plugin_container *plugin, int exit_status, int error_code)
{
debug_decl(iolog_close, SUDO_DEBUG_PCOMM, sudo_debug_instance)
debug_decl(iolog_close, SUDO_DEBUG_PCOMM)
if (plugin->u.io->close != NULL) {
sudo_debug_set_default_instance(plugin->debug_instance);
sudo_debug_set_active_instance(plugin->debug_instance);
plugin->u.io->close(exit_status, error_code);
sudo_debug_set_default_instance(sudo_debug_instance);
sudo_debug_set_active_instance(sudo_debug_instance);
}
debug_return;
}
@@ -1350,14 +1350,14 @@ static int
iolog_show_version(struct plugin_container *plugin, int verbose)
{
int rval;
debug_decl(iolog_show_version, SUDO_DEBUG_PCOMM, sudo_debug_instance)
debug_decl(iolog_show_version, SUDO_DEBUG_PCOMM)
if (plugin->u.io->show_version == NULL)
debug_return_bool(true);
sudo_debug_set_default_instance(plugin->debug_instance);
sudo_debug_set_active_instance(plugin->debug_instance);
rval = plugin->u.io->show_version(verbose);
sudo_debug_set_default_instance(sudo_debug_instance);
sudo_debug_set_active_instance(sudo_debug_instance);
debug_return_bool(rval);
}
@@ -1368,15 +1368,15 @@ iolog_show_version(struct plugin_container *plugin, int verbose)
static void
iolog_unlink(struct plugin_container *plugin)
{
debug_decl(iolog_unlink, SUDO_DEBUG_PCOMM, sudo_debug_instance)
debug_decl(iolog_unlink, SUDO_DEBUG_PCOMM)
/* Deregister hooks, if any. */
if (plugin->u.io->version >= SUDO_API_MKVERSION(1, 2)) {
if (plugin->u.io->deregister_hooks != NULL) {
sudo_debug_set_default_instance(plugin->debug_instance);
sudo_debug_set_active_instance(plugin->debug_instance);
plugin->u.io->deregister_hooks(SUDO_HOOK_VERSION,
deregister_hook);
sudo_debug_set_default_instance(sudo_debug_instance);
sudo_debug_set_active_instance(sudo_debug_instance);
}
}
/* Remove from io_plugins list and free. */

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2004-2008, 2010-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2004-2008, 2010-2015 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
@@ -79,7 +79,7 @@ set_tmpdir(void)
const char *tdir;
struct stat sb;
size_t len;
debug_decl(set_tmpdir, SUDO_DEBUG_EDIT, sudo_debug_instance)
debug_decl(set_tmpdir, SUDO_DEBUG_EDIT)
if (stat(_PATH_VARTMP, &sb) == 0 && S_ISDIR(sb.st_mode)) {
tdir = _PATH_VARTMP;
@@ -107,7 +107,7 @@ static void
switch_user(uid_t euid, gid_t egid, int ngroups, GETGROUPS_T *groups)
{
int serrno = errno;
debug_decl(switch_user, SUDO_DEBUG_EDIT, sudo_debug_instance)
debug_decl(switch_user, SUDO_DEBUG_EDIT)
sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,
"set uid:gid to %u:%u(%u)", euid, egid, ngroups ? groups[0] : egid);
@@ -142,7 +142,7 @@ sudo_edit_mktemp(const char *ofile, char **tfile)
{
const char *cp, *suff;
int tfd;
debug_decl(sudo_edit_mktemp, SUDO_DEBUG_EDIT, sudo_debug_instance)
debug_decl(sudo_edit_mktemp, SUDO_DEBUG_EDIT)
if ((cp = strrchr(ofile, '/')) != NULL)
cp++;
@@ -176,7 +176,7 @@ sudo_edit_create_tfiles(struct command_details *command_details,
ssize_t nwritten, nread;
struct timeval times[2];
struct stat sb;
debug_decl(sudo_edit_create_tfiles, SUDO_DEBUG_EDIT, sudo_debug_instance)
debug_decl(sudo_edit_create_tfiles, SUDO_DEBUG_EDIT)
/*
* For each file specified by the user, make a temporary version
@@ -271,7 +271,7 @@ sudo_edit_copy_tfiles(struct command_details *command_details,
ssize_t nwritten, nread;
struct timeval tv;
struct stat sb;
debug_decl(sudo_edit_copy_tfiles, SUDO_DEBUG_EDIT, sudo_debug_instance)
debug_decl(sudo_edit_copy_tfiles, SUDO_DEBUG_EDIT)
/* Copy contents of temp files to real ones. */
for (i = 0; i < nfiles; i++) {
@@ -358,7 +358,7 @@ selinux_edit_create_tfiles(struct command_details *command_details,
int i, rc, sesh_nargs;
struct stat sb;
struct command_details saved_command_details;
debug_decl(selinux_edit_create_tfiles, SUDO_DEBUG_EDIT, sudo_debug_instance)
debug_decl(selinux_edit_create_tfiles, SUDO_DEBUG_EDIT)
/* Prepare selinux stuff (setexeccon) */
if (selinux_setup(command_details->selinux_role,
@@ -449,7 +449,7 @@ selinux_edit_copy_tfiles(struct command_details *command_details,
struct command_details saved_command_details;
struct timeval tv;
struct stat sb;
debug_decl(selinux_edit_copy_tfiles, SUDO_DEBUG_EDIT, sudo_debug_instance)
debug_decl(selinux_edit_copy_tfiles, SUDO_DEBUG_EDIT)
/* Prepare selinux stuff (setexeccon) */
if (selinux_setup(command_details->selinux_role,
@@ -539,7 +539,7 @@ sudo_edit(struct command_details *command_details)
int editor_argc = 0, nfiles = 0;
struct timeval times[2];
struct tempfile *tf = NULL;
debug_decl(sudo_edit, SUDO_DEBUG_EDIT, sudo_debug_instance)
debug_decl(sudo_edit, SUDO_DEBUG_EDIT)
if (!set_tmpdir())
goto cleanup;
@@ -654,7 +654,7 @@ cleanup:
int
sudo_edit(struct command_details *command_details)
{
debug_decl(sudo_edit, SUDO_DEBUG_EDIT, sudo_debug_instance)
debug_decl(sudo_edit, SUDO_DEBUG_EDIT)
debug_return_int(1);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 1996, 1998-2005, 2007-2014
* Copyright (c) 1996, 1998-2005, 2007-2015
* Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
@@ -74,7 +74,7 @@ tgetpass(const char *prompt, int timeout, int flags)
static const char *askpass;
static char buf[SUDO_CONV_REPL_MAX + 1];
int i, input, output, save_errno, neednl = 0, need_restart;
debug_decl(tgetpass, SUDO_DEBUG_CONV, sudo_debug_instance)
debug_decl(tgetpass, SUDO_DEBUG_CONV)
(void) fflush(stdout);
@@ -213,7 +213,7 @@ sudo_askpass(const char *askpass, const char *prompt)
sigaction_t sa, saved_sa_pipe;
int pfd[2], status;
pid_t child;
debug_decl(sudo_askpass, SUDO_DEBUG_CONV, sudo_debug_instance)
debug_decl(sudo_askpass, SUDO_DEBUG_CONV)
if (pipe(pfd) == -1)
sudo_fatal(U_("unable to create pipe"));
@@ -276,7 +276,7 @@ getln(int fd, char *buf, size_t bufsiz, int feedback)
ssize_t nr = -1;
char *cp = buf;
char c = '\0';
debug_decl(getln, SUDO_DEBUG_CONV, sudo_debug_instance)
debug_decl(getln, SUDO_DEBUG_CONV)
if (left == 0) {
errno = EINVAL;
@@ -333,7 +333,7 @@ int
tty_present(void)
{
int fd;
debug_decl(tty_present, SUDO_DEBUG_UTIL, sudo_debug_instance)
debug_decl(tty_present, SUDO_DEBUG_UTIL)
if ((fd = open(_PATH_TTY, O_RDWR|O_NOCTTY)) != -1)
close(fd);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2012-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2012-2015 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
@@ -124,7 +124,7 @@ static char *
sudo_ttyname_dev(dev_t tdev)
{
char *dev, *tty = NULL;
debug_decl(sudo_ttyname_dev, SUDO_DEBUG_UTIL, sudo_debug_instance)
debug_decl(sudo_ttyname_dev, SUDO_DEBUG_UTIL)
/* Some versions of devname() return NULL on failure, others do not. */
dev = devname(tdev, S_IFCHR);
@@ -154,7 +154,7 @@ static char *
sudo_ttyname_dev(dev_t tdev)
{
char buf[TTYNAME_MAX], *tty;
debug_decl(sudo_ttyname_dev, SUDO_DEBUG_UTIL, sudo_debug_instance)
debug_decl(sudo_ttyname_dev, SUDO_DEBUG_UTIL)
tty = _ttyname_dev(tdev, buf, sizeof(buf));
@@ -194,7 +194,7 @@ sudo_ttyname_scan(const char *dir, dev_t rdev, bool builtin)
struct dirent *dp;
struct stat sb;
unsigned int i;
debug_decl(sudo_ttyname_scan, SUDO_DEBUG_UTIL, sudo_debug_instance)
debug_decl(sudo_ttyname_scan, SUDO_DEBUG_UTIL)
if (dir[0] == '\0' || (d = opendir(dir)) == NULL)
goto done;
@@ -301,7 +301,7 @@ sudo_ttyname_dev(dev_t rdev)
struct stat sb;
size_t len;
char buf[PATH_MAX], **sd, *devname, *tty = NULL;
debug_decl(sudo_ttyname_dev, SUDO_DEBUG_UTIL, sudo_debug_instance)
debug_decl(sudo_ttyname_dev, SUDO_DEBUG_UTIL)
/*
* First check search_devs for common tty devices.
@@ -353,7 +353,7 @@ get_process_ttyname(void)
struct sudo_kinfo_proc *ki_proc = NULL;
size_t size = sizeof(*ki_proc);
int mib[6], rc;
debug_decl(get_process_ttyname, SUDO_DEBUG_UTIL, sudo_debug_instance)
debug_decl(get_process_ttyname, SUDO_DEBUG_UTIL)
/*
* Lookup controlling tty for this process via sysctl.
@@ -399,7 +399,7 @@ get_process_ttyname(void)
struct psinfo psinfo;
ssize_t nread;
int fd;
debug_decl(get_process_ttyname, SUDO_DEBUG_UTIL, sudo_debug_instance)
debug_decl(get_process_ttyname, SUDO_DEBUG_UTIL)
/* Try to determine the tty from pr_ttydev in /proc/pid/psinfo. */
snprintf(path, sizeof(path), "/proc/%u/psinfo", (unsigned int)getpid());
@@ -431,7 +431,7 @@ get_process_ttyname(void)
size_t linesize = 0;
ssize_t len;
FILE *fp;
debug_decl(get_process_ttyname, SUDO_DEBUG_UTIL, sudo_debug_instance)
debug_decl(get_process_ttyname, SUDO_DEBUG_UTIL)
/* Try to determine the tty from tty_nr in /proc/pid/stat. */
snprintf(path, sizeof(path), "/proc/%u/stat", (unsigned int)getpid());
@@ -477,7 +477,7 @@ get_process_ttyname(void)
struct pst_status pstat;
char *tty = NULL;
int rc;
debug_decl(get_process_ttyname, SUDO_DEBUG_UTIL, sudo_debug_instance)
debug_decl(get_process_ttyname, SUDO_DEBUG_UTIL)
/*
* Determine the tty from psdev in struct pst_status.
@@ -501,7 +501,7 @@ char *
get_process_ttyname(void)
{
char *tty;
debug_decl(get_process_ttyname, SUDO_DEBUG_UTIL, sudo_debug_instance)
debug_decl(get_process_ttyname, SUDO_DEBUG_UTIL)
if ((tty = ttyname(STDIN_FILENO)) == NULL) {
if ((tty = ttyname(STDOUT_FILENO)) == NULL)

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011-2014 Todd C. Miller <Todd.Miller@courtesan.com>
* Copyright (c) 2011-2015 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
@@ -94,7 +94,7 @@ utmp_setid(sudo_utmp_t *old, sudo_utmp_t *new)
{
const char *line = new->ut_line;
size_t idlen;
debug_decl(utmp_setid, SUDO_DEBUG_UTMP, sudo_debug_instance)
debug_decl(utmp_setid, SUDO_DEBUG_UTMP)
/* Skip over "tty" in the id if old entry did too. */
if (old != NULL) {
@@ -124,7 +124,7 @@ static void
utmp_settime(sudo_utmp_t *ut)
{
struct timeval tv;
debug_decl(utmp_settime, SUDO_DEBUG_UTMP, sudo_debug_instance)
debug_decl(utmp_settime, SUDO_DEBUG_UTMP)
gettimeofday(&tv, NULL);
@@ -145,7 +145,7 @@ static void
utmp_fill(const char *line, const char *user, sudo_utmp_t *ut_old,
sudo_utmp_t *ut_new)
{
debug_decl(utmp_file, SUDO_DEBUG_UTMP, sudo_debug_instance)
debug_decl(utmp_file, SUDO_DEBUG_UTMP)
if (ut_old == NULL) {
memset(ut_new, 0, sizeof(*ut_new));
@@ -187,7 +187,7 @@ utmp_login(const char *from_line, const char *to_line, int ttyfd,
{
sudo_utmp_t utbuf, *ut_old = NULL;
bool rval = false;
debug_decl(utmp_login, SUDO_DEBUG_UTMP, sudo_debug_instance)
debug_decl(utmp_login, SUDO_DEBUG_UTMP)
/* Strip off /dev/ prefix from line as needed. */
if (strncmp(to_line, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
@@ -215,7 +215,7 @@ utmp_logout(const char *line, int status)
{
bool rval = false;
sudo_utmp_t *ut, utbuf;
debug_decl(utmp_logout, SUDO_DEBUG_UTMP, sudo_debug_instance)
debug_decl(utmp_logout, SUDO_DEBUG_UTMP)
/* Strip off /dev/ prefix from line as needed. */
if (strncmp(line, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
@@ -252,7 +252,7 @@ utmp_slot(const char *line, int ttyfd)
{
int slot = 1;
struct ttyent *tty;
debug_decl(utmp_slot, SUDO_DEBUG_UTMP, sudo_debug_instance)
debug_decl(utmp_slot, SUDO_DEBUG_UTMP)
setttyent();
while ((tty = getttyent()) != NULL) {
@@ -268,7 +268,7 @@ static int
utmp_slot(const char *line, int ttyfd)
{
int sfd, slot;
debug_decl(utmp_slot, SUDO_DEBUG_UTMP, sudo_debug_instance)
debug_decl(utmp_slot, SUDO_DEBUG_UTMP)
/*
* Temporarily point stdin to the tty since ttyslot()
@@ -295,7 +295,7 @@ utmp_login(const char *from_line, const char *to_line, int ttyfd,
bool rval = false;
int slot;
FILE *fp;
debug_decl(utmp_login, SUDO_DEBUG_UTMP, sudo_debug_instance)
debug_decl(utmp_login, SUDO_DEBUG_UTMP)
/* Strip off /dev/ prefix from line as needed. */
if (strncmp(to_line, _PATH_DEV, sizeof(_PATH_DEV) - 1) == 0)
@@ -347,7 +347,7 @@ utmp_logout(const char *line, int status)
sudo_utmp_t utbuf;
bool rval = false;
FILE *fp;
debug_decl(utmp_logout, SUDO_DEBUG_UTMP, sudo_debug_instance)
debug_decl(utmp_logout, SUDO_DEBUG_UTMP)
if ((fp = fopen(_PATH_UTMP, "r+")) == NULL)
debug_return_int(rval);