Convert sudo_debug_enter and sudo_debug_exit into macros.
In most cases, these simply expand to a call to sudo_debug_printf2(). We need to keep the function versions around in libsudo_util for backwards compatibility.
This commit is contained in:
@@ -119,6 +119,129 @@ struct sudo_conf_debug_file_list;
|
|||||||
debug_decl_vars((funcname), (subsys)); \
|
debug_decl_vars((funcname), (subsys)); \
|
||||||
sudo_debug_enter(__func__, __FILE__, __LINE__, sudo_debug_subsys)
|
sudo_debug_enter(__func__, __FILE__, __LINE__, sudo_debug_subsys)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Different flavors of sudo_debug_exit() macros.
|
||||||
|
*/
|
||||||
|
#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
|
||||||
|
# define sudo_debug_enter(_func, _file, _line, _sys) \
|
||||||
|
do { \
|
||||||
|
sudo_debug_printf2(NULL, NULL, 0, (_sys) | SUDO_DEBUG_TRACE, \
|
||||||
|
"-> %s @ %s:%d", (_func), (_file), (_line)); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
# define sudo_debug_exit(_func, _file, _line, _sys) \
|
||||||
|
do { \
|
||||||
|
sudo_debug_printf2(NULL, NULL, 0, (_sys) | SUDO_DEBUG_TRACE, \
|
||||||
|
"<- %s @ %s:%d", (_func), (_file), (_line)); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
# define sudo_debug_exit_int(_func, _file, _line, _sys, _ret) \
|
||||||
|
do { \
|
||||||
|
sudo_debug_printf2(NULL, NULL, 0, (_sys) | SUDO_DEBUG_TRACE, \
|
||||||
|
"<- %s @ %s:%d := %d", (_func), (_file), (_line), (_ret)); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
# define sudo_debug_exit_uint(_func, _file, _line, _sys, _ret) \
|
||||||
|
do { \
|
||||||
|
sudo_debug_printf2(NULL, NULL, 0, (_sys) | SUDO_DEBUG_TRACE, \
|
||||||
|
"<- %s @ %s:%d := %u", (_func), (_file), (_line), (_ret)); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
# define sudo_debug_exit_long(_func, _file, _line, _sys, _ret) \
|
||||||
|
do { \
|
||||||
|
sudo_debug_printf2(NULL, NULL, 0, (_sys) | SUDO_DEBUG_TRACE, \
|
||||||
|
"<- %s @ %s:%d := %ld", (_func), (_file), (_line), (_ret)); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
# if SIZEOF_ID_T == 8
|
||||||
|
# define sudo_debug_exit_id_t(_func, _file, _line, _sys, _ret) \
|
||||||
|
do { \
|
||||||
|
sudo_debug_printf2(NULL, NULL, 0, (_sys) | SUDO_DEBUG_TRACE, \
|
||||||
|
"<- %s @ %s:%d := %lld", (_func), (_file), (_line), (long long)(_ret));\
|
||||||
|
} while (0)
|
||||||
|
# else
|
||||||
|
# define sudo_debug_exit_id_t(_func, _file, _line, _sys, _ret) \
|
||||||
|
do { \
|
||||||
|
sudo_debug_printf2(NULL, NULL, 0, (_sys) | SUDO_DEBUG_TRACE, \
|
||||||
|
"<- %s @ %s:%d := %d", (_func), (_file), (_line), (int)(_ret)); \
|
||||||
|
} while (0)
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# define sudo_debug_exit_size_t(_func, _file, _line, _sys, _ret) \
|
||||||
|
do { \
|
||||||
|
sudo_debug_printf2(NULL, NULL, 0, (_sys) | SUDO_DEBUG_TRACE, \
|
||||||
|
"<- %s @ %s:%d := %zu", (_func), (_file), (_line), (_ret)); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
# define sudo_debug_exit_ssize_t(_func, _file, _line, _sys, _ret) \
|
||||||
|
do { \
|
||||||
|
sudo_debug_printf2(NULL, NULL, 0, (_sys) | SUDO_DEBUG_TRACE, \
|
||||||
|
"<- %s @ %s:%d := %zd", (_func), (_file), (_line), (_ret)); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
# if SIZEOF_TIME_T == 8
|
||||||
|
# define sudo_debug_exit_time_t(_func, _file, _line, _sys, _ret) \
|
||||||
|
do { \
|
||||||
|
sudo_debug_printf2(NULL, NULL, 0, (_sys) | SUDO_DEBUG_TRACE, \
|
||||||
|
"<- %s @ %s:%d := %lld", (_func), (_file), (_line), (long long)(_ret));\
|
||||||
|
} while (0)
|
||||||
|
# else
|
||||||
|
# define sudo_debug_exit_time_t(_func, _file, _line, _sys, _ret) \
|
||||||
|
do { \
|
||||||
|
sudo_debug_printf2(NULL, NULL, 0, (_sys) | SUDO_DEBUG_TRACE, \
|
||||||
|
"<- %s @ %s:%d := %d", (_func), (_file), (_line), (int)(_ret)); \
|
||||||
|
} while (0)
|
||||||
|
# endif
|
||||||
|
|
||||||
|
# define sudo_debug_exit_mode_t(_func, _file, _line, _sys, _ret) \
|
||||||
|
do { \
|
||||||
|
sudo_debug_printf2(NULL, NULL, 0, (_sys) | SUDO_DEBUG_TRACE, \
|
||||||
|
"<- %s @ %s:%d := %d", (_func), (_file), (_line), (int)(_ret)); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
# define sudo_debug_exit_bool(_func, _file, _line, _sys, _ret) \
|
||||||
|
do { \
|
||||||
|
sudo_debug_printf2(NULL, NULL, 0, (_sys) | SUDO_DEBUG_TRACE, \
|
||||||
|
"<- %s @ %s:%d := %s", (_func), (_file), (_line), (_ret) ? "true": "false");\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
# define sudo_debug_exit_str(_func, _file, _line, _sys, _ret) \
|
||||||
|
do { \
|
||||||
|
sudo_debug_printf2(NULL, NULL, 0, (_sys) | SUDO_DEBUG_TRACE, \
|
||||||
|
"<- %s @ %s:%d := %s", (_func), (_file), (_line), (_ret) ? (_ret) : "(null)");\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
# define sudo_debug_exit_str_masked(_func, _file, _line, _sys, _ret) \
|
||||||
|
do { \
|
||||||
|
const char _stars[] = "********************************************************************************"; \
|
||||||
|
const size_t _len = (_ret) ? strlen(_ret) : sizeof("(null)") - 1; \
|
||||||
|
const char *_s = (_ret) ? _stars : "(null)"; \
|
||||||
|
sudo_debug_printf2(NULL, NULL, 0, (_sys) | SUDO_DEBUG_TRACE, \
|
||||||
|
"<- %s @ %s:%d := %.*s", (_func), (_file), (_line), (int)_len, _s);\
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
# define sudo_debug_exit_ptr(_func, _file, _line, _sys, _ret) \
|
||||||
|
do { \
|
||||||
|
sudo_debug_printf2(NULL, NULL, 0, (_sys) | SUDO_DEBUG_TRACE, \
|
||||||
|
"<- %s @ %s:%d := %p", (_func), (_file), (_line), (_ret)); \
|
||||||
|
} while (0)
|
||||||
|
#else /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */
|
||||||
|
# define sudo_debug_enter(_a, _b, _c, _d)
|
||||||
|
# define sudo_debug_exit(_a, _b, _c, _d)
|
||||||
|
# define sudo_debug_exit_int(_a, _b, _c, _d, _e)
|
||||||
|
# define sudo_debug_exit_uint(_a, _b, _c, _d, _e)
|
||||||
|
# define sudo_debug_exit_long(_a, _b, _c, _d, _e)
|
||||||
|
# define sudo_debug_exit_id_t(_a, _b, _c, _d, _e)
|
||||||
|
# define sudo_debug_exit_size_t(_a, _b, _c, _d, _e)
|
||||||
|
# define sudo_debug_exit_ssize_t(_a, _b, _c, _d, _e)
|
||||||
|
# define sudo_debug_exit_time_t(_a, _b, _c, _d, _e)
|
||||||
|
# define sudo_debug_exit_mode_t(_a, _b, _c, _d, _e)
|
||||||
|
# define sudo_debug_exit_bool(_a, _b, _c, _d, _e)
|
||||||
|
# define sudo_debug_exit_str(_a, _b, _c, _d, _e)
|
||||||
|
# define sudo_debug_exit_str_masked(_a, _b, _c, _d, _e)
|
||||||
|
# define sudo_debug_exit_ptr(_a, _b, _c, _d, _e)
|
||||||
|
#endif /* FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Wrappers for sudo_debug_exit() and friends.
|
* Wrappers for sudo_debug_exit() and friends.
|
||||||
*/
|
*/
|
||||||
@@ -295,21 +418,7 @@ sudo_dso_public bool sudo_debug_needed_v1(unsigned int level);
|
|||||||
|
|
||||||
#define sudo_debug_needed(level) sudo_debug_needed_v1((level)|sudo_debug_subsys)
|
#define sudo_debug_needed(level) sudo_debug_needed_v1((level)|sudo_debug_subsys)
|
||||||
#define sudo_debug_deregister(_a) sudo_debug_deregister_v1((_a))
|
#define sudo_debug_deregister(_a) sudo_debug_deregister_v1((_a))
|
||||||
#define sudo_debug_enter(_a, _b, _c, _d) sudo_debug_enter_v1((_a), (_b), (_c), (_d))
|
|
||||||
#define sudo_debug_execve2(_a, _b, _c, _d) sudo_debug_execve2_v1((_a), (_b), (_c), (_d))
|
#define sudo_debug_execve2(_a, _b, _c, _d) sudo_debug_execve2_v1((_a), (_b), (_c), (_d))
|
||||||
#define sudo_debug_exit(_a, _b, _c, _d) sudo_debug_exit_v1((_a), (_b), (_c), (_d))
|
|
||||||
#define sudo_debug_exit_bool(_a, _b, _c, _d, _e) sudo_debug_exit_bool_v1((_a), (_b), (_c), (_d), (_e))
|
|
||||||
#define sudo_debug_exit_int(_a, _b, _c, _d, _e) sudo_debug_exit_int_v1((_a), (_b), (_c), (_d), (_e))
|
|
||||||
#define sudo_debug_exit_uint(_a, _b, _c, _d, _e) sudo_debug_exit_uint_v1((_a), (_b), (_c), (_d), (_e))
|
|
||||||
#define sudo_debug_exit_long(_a, _b, _c, _d, _e) sudo_debug_exit_long_v1((_a), (_b), (_c), (_d), (_e))
|
|
||||||
#define sudo_debug_exit_ptr(_a, _b, _c, _d, _e) sudo_debug_exit_ptr_v1((_a), (_b), (_c), (_d), (_e))
|
|
||||||
#define sudo_debug_exit_id_t(_a, _b, _c, _d, _e) sudo_debug_exit_id_t_v1((_a), (_b), (_c), (_d), (_e))
|
|
||||||
#define sudo_debug_exit_size_t(_a, _b, _c, _d, _e) sudo_debug_exit_size_t_v1((_a), (_b), (_c), (_d), (_e))
|
|
||||||
#define sudo_debug_exit_ssize_t(_a, _b, _c, _d, _e) sudo_debug_exit_ssize_t_v1((_a), (_b), (_c), (_d), (_e))
|
|
||||||
#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_exit_time_t(_a, _b, _c, _d, _e) sudo_debug_exit_time_t_v1((_a), (_b), (_c), (_d), (_e))
|
|
||||||
#define sudo_debug_exit_mode_t(_a, _b, _c, _d, _e) sudo_debug_exit_mode_t_v1((_a), (_b), (_c), (_d), (_e))
|
|
||||||
#define sudo_debug_fork() sudo_debug_fork_v1()
|
#define sudo_debug_fork() sudo_debug_fork_v1()
|
||||||
#define sudo_debug_get_active_instance() sudo_debug_get_active_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_fds(_a) sudo_debug_get_fds_v1((_a))
|
||||||
|
@@ -495,130 +495,103 @@ sudo_debug_fork_v1(void)
|
|||||||
return pid;
|
return pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Functions versions of sudo_debug_enter* for backwards compatibility. */
|
||||||
void
|
void
|
||||||
sudo_debug_enter_v1(const char *func, const char *file, int line,
|
sudo_debug_enter_v1(const char *func, const char *file, int line,
|
||||||
unsigned int subsys)
|
unsigned int subsys)
|
||||||
{
|
{
|
||||||
sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE,
|
sudo_debug_enter(func, file, line, subsys);
|
||||||
"-> %s @ %s:%d", func, file, line);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sudo_debug_exit_v1(const char *func, const char *file, int line,
|
sudo_debug_exit_v1(const char *func, const char *file, int line,
|
||||||
unsigned int subsys)
|
unsigned int subsys)
|
||||||
{
|
{
|
||||||
sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE,
|
sudo_debug_exit(func, file, line, subsys);
|
||||||
"<- %s @ %s:%d", func, file, line);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sudo_debug_exit_int_v1(const char *func, const char *file, int line,
|
sudo_debug_exit_int_v1(const char *func, const char *file, int line,
|
||||||
unsigned int subsys, int ret)
|
unsigned int subsys, int ret)
|
||||||
{
|
{
|
||||||
sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE,
|
sudo_debug_exit_int(func, file, line, subsys, ret);
|
||||||
"<- %s @ %s:%d := %d", func, file, line, ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sudo_debug_exit_uint_v1(const char *func, const char *file, int line,
|
sudo_debug_exit_uint_v1(const char *func, const char *file, int line,
|
||||||
unsigned int subsys, unsigned int ret)
|
unsigned int subsys, unsigned int ret)
|
||||||
{
|
{
|
||||||
sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE,
|
sudo_debug_exit_uint(func, file, line, subsys, ret);
|
||||||
"<- %s @ %s:%d := %u", func, file, line, ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sudo_debug_exit_long_v1(const char *func, const char *file, int line,
|
sudo_debug_exit_long_v1(const char *func, const char *file, int line,
|
||||||
unsigned int subsys, long ret)
|
unsigned int subsys, long ret)
|
||||||
{
|
{
|
||||||
sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE,
|
sudo_debug_exit_long(func, file, line, subsys, ret);
|
||||||
"<- %s @ %s:%d := %ld", func, file, line, ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sudo_debug_exit_id_t_v1(const char *func, const char *file, int line,
|
sudo_debug_exit_id_t_v1(const char *func, const char *file, int line,
|
||||||
unsigned int subsys, id_t ret)
|
unsigned int subsys, id_t ret)
|
||||||
{
|
{
|
||||||
#if SIZEOF_ID_T == 8
|
sudo_debug_exit_id_t(func, file, line, subsys, ret);
|
||||||
sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE,
|
|
||||||
"<- %s @ %s:%d := %lld", func, file, line, (long long)ret);
|
|
||||||
#else
|
|
||||||
sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE,
|
|
||||||
"<- %s @ %s:%d := %d", func, file, line, (int)ret);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sudo_debug_exit_size_t_v1(const char *func, const char *file, int line,
|
sudo_debug_exit_size_t_v1(const char *func, const char *file, int line,
|
||||||
unsigned int subsys, size_t ret)
|
unsigned int subsys, size_t ret)
|
||||||
{
|
{
|
||||||
sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE,
|
sudo_debug_exit_size_t(func, file, line, subsys, ret);
|
||||||
"<- %s @ %s:%d := %zu", func, file, line, ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sudo_debug_exit_ssize_t_v1(const char *func, const char *file, int line,
|
sudo_debug_exit_ssize_t_v1(const char *func, const char *file, int line,
|
||||||
unsigned int subsys, ssize_t ret)
|
unsigned int subsys, ssize_t ret)
|
||||||
{
|
{
|
||||||
sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE,
|
sudo_debug_exit_ssize_t(func, file, line, subsys, ret);
|
||||||
"<- %s @ %s:%d := %zd", func, file, line, ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sudo_debug_exit_time_t_v1(const char *func, const char *file, int line,
|
sudo_debug_exit_time_t_v1(const char *func, const char *file, int line,
|
||||||
unsigned int subsys, time_t ret)
|
unsigned int subsys, time_t ret)
|
||||||
{
|
{
|
||||||
#if SIZEOF_TIME_T == 8
|
sudo_debug_exit_time_t(func, file, line, subsys, ret);
|
||||||
sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE,
|
|
||||||
"<- %s @ %s:%d := %lld", func, file, line, (long long)ret);
|
|
||||||
#else
|
|
||||||
sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE,
|
|
||||||
"<- %s @ %s:%d := %d", func, file, line, (int)ret);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sudo_debug_exit_mode_t_v1(const char *func, const char *file, int line,
|
sudo_debug_exit_mode_t_v1(const char *func, const char *file, int line,
|
||||||
unsigned int subsys, mode_t ret)
|
unsigned int subsys, mode_t ret)
|
||||||
{
|
{
|
||||||
sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE,
|
sudo_debug_exit_mode_t(func, file, line, subsys, ret);
|
||||||
"<- %s @ %s:%d := %d", func, file, line, (int)ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sudo_debug_exit_bool_v1(const char *func, const char *file, int line,
|
sudo_debug_exit_bool_v1(const char *func, const char *file, int line,
|
||||||
unsigned int subsys, bool ret)
|
unsigned int subsys, bool ret)
|
||||||
{
|
{
|
||||||
sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE,
|
sudo_debug_exit_bool(func, file, line, subsys, ret);
|
||||||
"<- %s @ %s:%d := %s", func, file, line, ret ? "true" : "false");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sudo_debug_exit_str_v1(const char *func, const char *file, int line,
|
sudo_debug_exit_str_v1(const char *func, const char *file, int line,
|
||||||
unsigned int subsys, const char *ret)
|
unsigned int subsys, const char *ret)
|
||||||
{
|
{
|
||||||
sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE,
|
sudo_debug_exit_str(func, file, line, subsys, ret);
|
||||||
"<- %s @ %s:%d := %s", func, file, line, ret ? ret : "(null)");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sudo_debug_exit_str_masked_v1(const char *func, const char *file, int line,
|
sudo_debug_exit_str_masked_v1(const char *func, const char *file, int line,
|
||||||
unsigned int subsys, const char *ret)
|
unsigned int subsys, const char *ret)
|
||||||
{
|
{
|
||||||
static const char stars[] = "********************************************************************************";
|
sudo_debug_exit_str_masked(func, file, line, subsys, ret);
|
||||||
const size_t len = ret ? strlen(ret) : sizeof("(null)") - 1;
|
|
||||||
|
|
||||||
sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE,
|
|
||||||
"<- %s @ %s:%d := %.*s", func, file, line, (int)len,
|
|
||||||
ret ? stars : "(null)");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
sudo_debug_exit_ptr_v1(const char *func, const char *file, int line,
|
sudo_debug_exit_ptr_v1(const char *func, const char *file, int line,
|
||||||
unsigned int subsys, const void *ret)
|
unsigned int subsys, const void *ret)
|
||||||
{
|
{
|
||||||
sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE,
|
sudo_debug_exit_ptr(func, file, line, subsys, ret);
|
||||||
"<- %s @ %s:%d := %p", func, file, line, ret);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Reference in New Issue
Block a user