diff --git a/include/sudo_debug.h b/include/sudo_debug.h index 5ee5cc18d..56653771e 100644 --- a/include/sudo_debug.h +++ b/include/sudo_debug.h @@ -107,13 +107,13 @@ struct sudo_conf_debug_file_list; #ifdef HAVE___FUNC__ # define debug_decl_func(funcname) # define debug_decl_vars(funcname, subsys) \ - const int sudo_debug_subsys = (subsys) + const unsigned int sudo_debug_subsys = (subsys) #else # define debug_decl_func(funcname) \ const char __func__[] = #funcname; # define debug_decl_vars(funcname, subsys) \ debug_decl_func(funcname) \ - const int sudo_debug_subsys = (subsys) + const unsigned int sudo_debug_subsys = (subsys) #endif #define debug_decl(funcname, subsys) \ debug_decl_vars((funcname), (subsys)); \ @@ -247,33 +247,33 @@ struct sudo_conf_debug_file_list; sudo_debug_write2(fd, NULL, NULL, 0, (str), (len), (errnum)) sudo_dso_public int sudo_debug_deregister_v1(int instance_id); -sudo_dso_public void sudo_debug_enter_v1(const char *func, const char *file, int line, int subsys); -sudo_dso_public void sudo_debug_execve2_v1(int level, const char *path, char *const argv[], char *const envp[]); -sudo_dso_public void sudo_debug_exit_v1(const char *func, const char *file, int line, int subsys); -sudo_dso_public void sudo_debug_exit_bool_v1(const char *func, const char *file, int line, int subsys, bool ret); -sudo_dso_public void sudo_debug_exit_int_v1(const char *func, const char *file, int line, int subsys, int ret); -sudo_dso_public void sudo_debug_exit_long_v1(const char *func, const char *file, int line, int subsys, long ret); -sudo_dso_public void sudo_debug_exit_ptr_v1(const char *func, const char *file, int line, int subsys, const void *ret); -sudo_dso_public void sudo_debug_exit_id_t_v1(const char *func, const char *file, int line, int subsys, id_t ret); -sudo_dso_public void sudo_debug_exit_size_t_v1(const char *func, const char *file, int line, int subsys, size_t ret); -sudo_dso_public void sudo_debug_exit_ssize_t_v1(const char *func, const char *file, int line, int subsys, ssize_t ret); -sudo_dso_public void sudo_debug_exit_str_v1(const char *func, const char *file, int line, int subsys, const char *ret); -sudo_dso_public void sudo_debug_exit_str_masked_v1(const char *func, const char *file, int line, int subsys, const char *ret); -sudo_dso_public void sudo_debug_exit_time_t_v1(const char *func, const char *file, int line, int subsys, time_t ret); +sudo_dso_public void sudo_debug_enter_v1(const char *func, const char *file, int line, unsigned int subsys); +sudo_dso_public void sudo_debug_execve2_v1(unsigned int level, const char *path, char *const argv[], char *const envp[]); +sudo_dso_public void sudo_debug_exit_v1(const char *func, const char *file, int line, unsigned int subsys); +sudo_dso_public void sudo_debug_exit_bool_v1(const char *func, const char *file, int line, unsigned int subsys, bool ret); +sudo_dso_public void sudo_debug_exit_int_v1(const char *func, const char *file, int line, unsigned int subsys, int ret); +sudo_dso_public void sudo_debug_exit_long_v1(const char *func, const char *file, int line, unsigned int subsys, long ret); +sudo_dso_public void sudo_debug_exit_ptr_v1(const char *func, const char *file, int line, unsigned int subsys, const void *ret); +sudo_dso_public void sudo_debug_exit_id_t_v1(const char *func, const char *file, int line, unsigned int subsys, id_t ret); +sudo_dso_public void sudo_debug_exit_size_t_v1(const char *func, const char *file, int line, unsigned int subsys, size_t ret); +sudo_dso_public void sudo_debug_exit_ssize_t_v1(const char *func, const char *file, int line, unsigned int subsys, ssize_t ret); +sudo_dso_public void sudo_debug_exit_str_v1(const char *func, const char *file, int line, unsigned int subsys, const char *ret); +sudo_dso_public void sudo_debug_exit_str_masked_v1(const char *func, const char *file, int line, unsigned int subsys, const char *ret); +sudo_dso_public void sudo_debug_exit_time_t_v1(const char *func, const char *file, int line, unsigned int subsys, time_t ret); sudo_dso_public pid_t sudo_debug_fork_v1(void); sudo_dso_public int sudo_debug_get_active_instance_v1(void); sudo_dso_public int sudo_debug_get_fds_v1(unsigned char **fds); sudo_dso_public int sudo_debug_get_instance_v1(const char *program); sudo_dso_public int sudo_debug_parse_flags_v1(struct sudo_conf_debug_file_list *debug_files, const char *entry); -sudo_dso_public void sudo_debug_printf2_v1(const char *func, const char *file, int line, int level, const char *fmt, ...) sudo_printf0like(5, 6); +sudo_dso_public void sudo_debug_printf2_v1(const char *func, const char *file, int line, unsigned int level, const char *fmt, ...) sudo_printf0like(5, 6); sudo_dso_public void sudo_debug_printf_nvm_v1(int pri, const char *fmt, ...) sudo_printf0like(2, 3); sudo_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); sudo_dso_public int sudo_debug_register_v2(const char *program, const char *const subsystems[], unsigned int ids[], struct sudo_conf_debug_file_list *debug_files, int minfd); sudo_dso_public int sudo_debug_set_active_instance_v1(int inst); sudo_dso_public void sudo_debug_update_fd_v1(int ofd, int nfd); -sudo_dso_public void sudo_debug_vprintf2_v1(const char *func, const char *file, int line, int level, const char *fmt, va_list ap) sudo_printf0like(5, 0); -sudo_dso_public void sudo_debug_write2_v1(int fd, const char *func, const char *file, int line, const char *str, int len, int errnum); -sudo_dso_public bool sudo_debug_needed_v1(int level); +sudo_dso_public void sudo_debug_vprintf2_v1(const char *func, const char *file, int line, unsigned int level, const char *fmt, va_list ap) sudo_printf0like(5, 0); +sudo_dso_public void sudo_debug_write2_v1(int fd, const char *func, const char *file, int line, const char *str, unsigned int len, int errnum); +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_deregister(_a) sudo_debug_deregister_v1((_a)) diff --git a/lib/util/sudo_debug.c b/lib/util/sudo_debug.c index d8f07ffe4..c7c64651c 100644 --- a/lib/util/sudo_debug.c +++ b/lib/util/sudo_debug.c @@ -409,7 +409,7 @@ sudo_debug_deregister_v1(int idx) return -1; /* already deregistered */ if (--instance->refcnt != 0) - return instance->refcnt; /* ref held by other caller */ + return (int)instance->refcnt; /* ref held by other caller */ /* Free up instance data, note that subsystems[] is owned by caller. */ sudo_debug_instances[idx] = NULL; @@ -497,7 +497,7 @@ sudo_debug_fork_v1(void) void sudo_debug_enter_v1(const char *func, const char *file, int line, - int subsys) + unsigned int subsys) { sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE, "-> %s @ %s:%d", func, file, line); @@ -505,7 +505,7 @@ sudo_debug_enter_v1(const char *func, const char *file, int line, void sudo_debug_exit_v1(const char *func, const char *file, int line, - int subsys) + unsigned int subsys) { sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE, "<- %s @ %s:%d", func, file, line); @@ -513,7 +513,7 @@ sudo_debug_exit_v1(const char *func, const char *file, int line, void sudo_debug_exit_int_v1(const char *func, const char *file, int line, - int subsys, int ret) + unsigned int subsys, int ret) { sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE, "<- %s @ %s:%d := %d", func, file, line, ret); @@ -521,7 +521,7 @@ sudo_debug_exit_int_v1(const char *func, const char *file, int line, void sudo_debug_exit_long_v1(const char *func, const char *file, int line, - int subsys, long ret) + unsigned int subsys, long ret) { sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE, "<- %s @ %s:%d := %ld", func, file, line, ret); @@ -529,7 +529,7 @@ sudo_debug_exit_long_v1(const char *func, const char *file, int line, void sudo_debug_exit_id_t_v1(const char *func, const char *file, int line, - int subsys, id_t ret) + unsigned int subsys, id_t ret) { #if SIZEOF_ID_T == 8 sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE, @@ -542,7 +542,7 @@ sudo_debug_exit_id_t_v1(const char *func, const char *file, int line, void sudo_debug_exit_size_t_v1(const char *func, const char *file, int line, - int subsys, size_t ret) + unsigned int subsys, size_t ret) { sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE, "<- %s @ %s:%d := %zu", func, file, line, ret); @@ -550,7 +550,7 @@ sudo_debug_exit_size_t_v1(const char *func, const char *file, int line, void sudo_debug_exit_ssize_t_v1(const char *func, const char *file, int line, - int subsys, ssize_t ret) + unsigned int subsys, ssize_t ret) { sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE, "<- %s @ %s:%d := %zd", func, file, line, ret); @@ -558,7 +558,7 @@ sudo_debug_exit_ssize_t_v1(const char *func, const char *file, int line, void sudo_debug_exit_time_t_v1(const char *func, const char *file, int line, - int subsys, time_t ret) + unsigned int subsys, time_t ret) { #if SIZEOF_TIME_T == 8 sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE, @@ -571,7 +571,7 @@ sudo_debug_exit_time_t_v1(const char *func, const char *file, int line, void sudo_debug_exit_bool_v1(const char *func, const char *file, int line, - int subsys, bool ret) + unsigned int subsys, bool ret) { sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE, "<- %s @ %s:%d := %s", func, file, line, ret ? "true" : "false"); @@ -579,7 +579,7 @@ sudo_debug_exit_bool_v1(const char *func, const char *file, int line, void sudo_debug_exit_str_v1(const char *func, const char *file, int line, - int subsys, const char *ret) + unsigned int subsys, const char *ret) { sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE, "<- %s @ %s:%d := %s", func, file, line, ret ? ret : "(null)"); @@ -587,18 +587,19 @@ sudo_debug_exit_str_v1(const char *func, const char *file, int line, void sudo_debug_exit_str_masked_v1(const char *func, const char *file, int line, - int subsys, const char *ret) + unsigned int subsys, const char *ret) { static const char stars[] = "********************************************************************************"; - int len = ret ? strlen(ret) : sizeof("(null)") - 1; + 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, len, ret ? stars : "(null)"); + "<- %s @ %s:%d := %.*s", func, file, line, (int)len, + ret ? stars : "(null)"); } void sudo_debug_exit_ptr_v1(const char *func, const char *file, int line, - int subsys, const void *ret) + unsigned int subsys, const void *ret) { sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE, "<- %s @ %s:%d := %p", func, file, line, ret); @@ -606,7 +607,7 @@ sudo_debug_exit_ptr_v1(const char *func, const char *file, int line, void sudo_debug_write2_v1(int fd, const char *func, const char *file, int lineno, - const char *str, int len, int errnum) + const char *str, unsigned int len, int errnum) { char numbuf[(((sizeof(int) * 8) + 2) / 3) + 2]; char timebuf[64]; @@ -644,7 +645,7 @@ sudo_debug_write2_v1(int fd, const char *func, const char *file, int lineno, /* Add string, trimming any trailing newlines. */ while (len > 0 && str[len - 1] == '\n') len--; - if (len > 0) { + if (len != 0) { iov[iovcnt].iov_base = (char *)str; iov[iovcnt].iov_len = len; iovcnt++; @@ -652,7 +653,7 @@ sudo_debug_write2_v1(int fd, const char *func, const char *file, int lineno, /* Append error string if errno is specified. */ if (errnum) { - if (len > 0) { + if (len != 0) { iov[iovcnt].iov_base = (char *)": "; iov[iovcnt].iov_len = 2; iovcnt++; @@ -696,7 +697,7 @@ sudo_debug_write2_v1(int fd, const char *func, const char *file, int lineno, } bool -sudo_debug_needed_v1(int level) +sudo_debug_needed_v1(unsigned int level) { unsigned int subsys; int pri; @@ -708,8 +709,8 @@ sudo_debug_needed_v1(int level) goto out; /* Extract priority and subsystem from level. */ - pri = SUDO_DEBUG_PRI(level); - subsys = (unsigned int)SUDO_DEBUG_SUBSYS(level); + pri = (int)SUDO_DEBUG_PRI(level); + subsys = SUDO_DEBUG_SUBSYS(level); if (sudo_debug_active_instance > sudo_debug_last_instance) goto out; @@ -731,10 +732,10 @@ out: } void -sudo_debug_vprintf2_v1(const char *func, const char *file, int lineno, int level, - const char *fmt, va_list ap) +sudo_debug_vprintf2_v1(const char *func, const char *file, int lineno, + unsigned int level, const char *fmt, va_list ap) { - int buflen, pri, saved_errno = errno; + int pri, saved_errno = errno; unsigned int subsys; char static_buf[1024], *buf = static_buf; struct sudo_debug_instance *instance; @@ -745,9 +746,16 @@ sudo_debug_vprintf2_v1(const char *func, const char *file, int lineno, int level goto out; /* Extract priority and subsystem from level. */ - pri = SUDO_DEBUG_PRI(level); + pri = (int)SUDO_DEBUG_PRI(level); subsys = SUDO_DEBUG_SUBSYS(level); + /* Disable extra info if SUDO_DEBUG_LINENO is not enabled. */ + if (!ISSET(level, SUDO_DEBUG_LINENO)) { + func = NULL; + file = NULL; + lineno = 0; + } + /* Find matching instance. */ if (sudo_debug_active_instance > sudo_debug_last_instance) { sudo_warnx_nodebug("%s: invalid instance ID %d, max %d", @@ -764,31 +772,36 @@ sudo_debug_vprintf2_v1(const char *func, const char *file, int lineno, int level SLIST_FOREACH(output, &instance->outputs, entries) { /* Make sure we want debug info at this level. */ if (subsys <= instance->max_subsystem && output->settings[subsys] >= pri) { + int errcode, buflen = 0; va_list ap2; - /* Operate on a copy of ap to support multiple outputs. */ - va_copy(ap2, ap); - buflen = fmt ? vsnprintf(static_buf, sizeof(static_buf), fmt, ap2) : 0; - va_end(ap2); - if (buflen >= ssizeof(static_buf)) { - va_list ap3; - - /* Not enough room in static buf, allocate dynamically. */ - va_copy(ap3, ap); - buflen = vasprintf(&buf, fmt, ap3); - va_end(ap3); - } - if (buflen != -1) { - int errcode = ISSET(level, SUDO_DEBUG_ERRNO) ? saved_errno : 0; - if (ISSET(level, SUDO_DEBUG_LINENO)) - sudo_debug_write2(output->fd, func, file, lineno, buf, buflen, errcode); - else - sudo_debug_write2(output->fd, NULL, NULL, 0, buf, buflen, errcode); - if (buf != static_buf) { - free(buf); - buf = static_buf; + if (fmt != NULL) { + /* Operate on a copy of ap to support multiple outputs. */ + va_copy(ap2, ap); + buflen = vsnprintf(static_buf, sizeof(static_buf), fmt, ap2); + va_end(ap2); + if (buflen < 0) { + sudo_warnx_nodebug("%s: invalid format string \"%s\"", + __func__, fmt); + buflen = 0; + } else if (buflen >= ssizeof(static_buf)) { + /* Not enough room in static buf, allocate dynamically. */ + va_copy(ap2, ap); + buflen = vasprintf(&buf, fmt, ap2); + if (buflen == -1) { + buf = static_buf; + buflen = (int)strlen(buf); + } + va_end(ap2); } } + errcode = ISSET(level, SUDO_DEBUG_ERRNO) ? saved_errno : 0; + sudo_debug_write2(output->fd, func, file, lineno, buf, + (unsigned int)buflen, errcode); + if (buf != static_buf) { + free(buf); + buf = static_buf; + } } } out: @@ -808,8 +821,8 @@ sudo_debug_printf_nvm_v1(int pri, const char *fmt, ...) #endif /* NO_VARIADIC_MACROS */ void -sudo_debug_printf2_v1(const char *func, const char *file, int lineno, int level, - const char *fmt, ...) +sudo_debug_printf2_v1(const char *func, const char *file, int lineno, + unsigned int level, const char *fmt, ...) { va_list ap; @@ -821,22 +834,23 @@ sudo_debug_printf2_v1(const char *func, const char *file, int lineno, int level, #define EXEC_PREFIX "exec " void -sudo_debug_execve2_v1(int level, const char *path, char *const argv[], char *const envp[]) +sudo_debug_execve2_v1(unsigned int level, const char *path, char *const argv[], + char *const envp[]) { - int buflen, pri, saved_errno = errno; + int pri, saved_errno = errno; unsigned int subsys; struct sudo_debug_instance *instance; struct sudo_debug_output *output; char * const *av; char *cp, static_buf[4096], *buf = static_buf; - size_t plen; + size_t buflen, plen; debug_decl_func(sudo_debug_execve2); if (sudo_debug_active_instance == -1 || path == NULL) goto out; /* Extract priority and subsystem from level. */ - pri = SUDO_DEBUG_PRI(level); + pri = (int)SUDO_DEBUG_PRI(level); subsys = SUDO_DEBUG_SUBSYS(level); /* Find matching instance. */ @@ -880,7 +894,7 @@ sudo_debug_execve2_v1(int level, const char *path, char *const argv[], char *con buflen += strlen(*av) + 1; buflen--; } - if (buflen >= ssizeof(static_buf)) { + if (buflen >= sizeof(static_buf)) { buf = malloc(buflen + 1); if (buf == NULL) goto out; @@ -919,7 +933,7 @@ sudo_debug_execve2_v1(int level, const char *path, char *const argv[], char *con *cp = '\0'; - sudo_debug_write(output->fd, buf, buflen, 0); + sudo_debug_write(output->fd, buf, (unsigned int)buflen, 0); if (buf != static_buf) { free(buf); buf = static_buf; @@ -1037,91 +1051,91 @@ sudo_debug_fork_v1(void) void sudo_debug_enter_v1(const char *func, const char *file, int line, - int subsys) + unsigned int subsys) { } void sudo_debug_exit_v1(const char *func, const char *file, int line, - int subsys) + unsigned int subsys) { } void sudo_debug_exit_int_v1(const char *func, const char *file, int line, - int subsys, int ret) + unsigned int subsys, int ret) { } void sudo_debug_exit_long_v1(const char *func, const char *file, int line, - int subsys, long ret) + unsigned int subsys, long ret) { } void sudo_debug_exit_id_t_v1(const char *func, const char *file, int line, - int subsys, id_t ret) + unsigned int subsys, id_t ret) { } void sudo_debug_exit_size_t_v1(const char *func, const char *file, int line, - int subsys, size_t ret) + unsigned int subsys, size_t ret) { } void sudo_debug_exit_ssize_t_v1(const char *func, const char *file, int line, - int subsys, ssize_t ret) + unsigned int subsys, ssize_t ret) { } void sudo_debug_exit_time_t_v1(const char *func, const char *file, int line, - int subsys, time_t ret) + unsigned int subsys, time_t ret) { } void sudo_debug_exit_bool_v1(const char *func, const char *file, int line, - int subsys, bool ret) + unsigned int subsys, bool ret) { } void sudo_debug_exit_str_v1(const char *func, const char *file, int line, - int subsys, const char *ret) + unsigned int subsys, const char *ret) { } void sudo_debug_exit_str_masked_v1(const char *func, const char *file, int line, - int subsys, const char *ret) + unsigned int subsys, const char *ret) { } void sudo_debug_exit_ptr_v1(const char *func, const char *file, int line, - int subsys, const void *ret) + unsigned int subsys, const void *ret) { } void sudo_debug_write2_v1(int fd, const char *func, const char *file, int lineno, - const char *str, int len, int errnum) + const char *str, unsigned int len, int errnum) { } bool -sudo_debug_needed_v1(int level) +sudo_debug_needed_v1(unsigned int level) { return false; } void -sudo_debug_vprintf2_v1(const char *func, const char *file, int lineno, int level, - const char *fmt, va_list ap) +sudo_debug_vprintf2_v1(const char *func, const char *file, int lineno, + unsigned int level, const char *fmt, va_list ap) { } @@ -1133,13 +1147,14 @@ sudo_debug_printf_nvm_v1(int pri, const char *fmt, ...) #endif /* NO_VARIADIC_MACROS */ void -sudo_debug_printf2_v1(const char *func, const char *file, int lineno, int level, - const char *fmt, ...) +sudo_debug_printf2_v1(const char *func, const char *file, int lineno, + unsigned int level, const char *fmt, ...) { } void -sudo_debug_execve2_v1(int level, const char *path, char *const argv[], char *const envp[]) +sudo_debug_execve2_v1(unsigned int level, const char *path, char *const argv[], + char *const envp[]) { } diff --git a/plugins/python/pyhelpers.c b/plugins/python/pyhelpers.c index 882b31a6b..f3a0b67d9 100644 --- a/plugins/python/pyhelpers.c +++ b/plugins/python/pyhelpers.c @@ -321,7 +321,7 @@ done: static void _py_debug_python_function(const char *class_name, const char *function_name, const char *message, - PyObject *py_args, PyObject *py_kwargs, int subsystem_id) + PyObject *py_args, PyObject *py_kwargs, unsigned int subsystem_id) { debug_decl_vars(_py_debug_python_function, subsystem_id); @@ -373,7 +373,8 @@ _py_debug_python_function(const char *class_name, const char *function_name, con void py_debug_python_call(const char *class_name, const char *function_name, - PyObject *py_args, PyObject *py_kwargs, int subsystem_id) + PyObject *py_args, PyObject *py_kwargs, + unsigned int subsystem_id) { debug_decl_vars(py_debug_python_call, subsystem_id); @@ -397,7 +398,7 @@ py_debug_python_call(const char *class_name, const char *function_name, void py_debug_python_result(const char *class_name, const char *function_name, - PyObject *py_result, int subsystem_id) + PyObject *py_result, unsigned int subsystem_id) { if (py_result == NULL) { debug_decl_vars(py_debug_python_result, subsystem_id); diff --git a/plugins/python/pyhelpers.h b/plugins/python/pyhelpers.h index 6ab7c4984..ef0289b87 100644 --- a/plugins/python/pyhelpers.h +++ b/plugins/python/pyhelpers.h @@ -94,9 +94,10 @@ void py_object_set_attr_string(PyObject *py_object, const char *attr_name, const PyObject *py_create_version(unsigned int version); void py_debug_python_call(const char *class_name, const char *function_name, - PyObject *py_args, PyObject *py_kwargs, int subsystem_id); + PyObject *py_args, PyObject *py_kwargs, + unsigned int subsystem_id); void py_debug_python_result(const char *class_name, const char *function_name, - PyObject *py_args, int subsystem_id); + PyObject *py_args, unsigned int subsystem_id); void str_array_free(char ***array); diff --git a/plugins/python/python_loghandler.c b/plugins/python/python_loghandler.c index 2541e687e..5c19cba04 100644 --- a/plugins/python/python_loghandler.c +++ b/plugins/python/python_loghandler.c @@ -27,7 +27,7 @@ PyObject *sudo_type_LogHandler; static void -_debug_plugin(int log_level, const char *log_message) +_debug_plugin(unsigned int log_level, const char *log_message) { debug_decl_vars(python_sudo_debug, PYTHON_DEBUG_PLUGIN); @@ -54,7 +54,7 @@ python_sudo_debug(PyObject *Py_UNUSED(py_self), PyObject *py_args) debug_decl(python_sudo_debug, PYTHON_DEBUG_C_CALLS); py_debug_python_call("sudo", "debug", py_args, NULL, PYTHON_DEBUG_C_CALLS); - int log_level = SUDO_DEBUG_DEBUG; + unsigned int log_level = SUDO_DEBUG_DEBUG; const char *log_message = NULL; if (!PyArg_ParseTuple(py_args, "is:sudo.debug", &log_level, &log_message)) { debug_return_ptr(NULL); @@ -65,7 +65,7 @@ python_sudo_debug(PyObject *Py_UNUSED(py_self), PyObject *py_args) debug_return_ptr_pynone; } -static int +static unsigned int _sudo_log_level_from_python(long level) { if (level >= 50) @@ -99,7 +99,7 @@ _sudo_LogHandler__emit(PyObject *py_self, PyObject *py_args) goto cleanup; } - int sudo_loglevel = _sudo_log_level_from_python(python_loglevel); + unsigned int sudo_loglevel = _sudo_log_level_from_python(python_loglevel); py_message = PyObject_CallMethod(py_self, "format", "O", py_record); if (py_message == NULL) diff --git a/plugins/python/sudo_python_debug.c b/plugins/python/sudo_python_debug.c index 83e68456c..3ba79bfca 100644 --- a/plugins/python/sudo_python_debug.c +++ b/plugins/python/sudo_python_debug.c @@ -51,7 +51,7 @@ static const char *const python_subsystem_names[] = { #define NUM_SUBSYSTEMS sizeof(python_subsystem_names) / sizeof(*python_subsystem_names) - 1 /* Subsystem IDs assigned at registration time. */ -int python_subsystem_ids[NUM_SUBSYSTEMS]; +unsigned int python_subsystem_ids[NUM_SUBSYSTEMS]; /* * Parse the "filename flags,..." debug_flags entry and insert a new @@ -84,7 +84,7 @@ python_debug_register(const char *program, if (debug_files != NULL && !TAILQ_EMPTY(debug_files)) { if (program != NULL) { instance = sudo_debug_register(program, python_subsystem_names, - (unsigned int *)python_subsystem_ids, debug_files, -1); + python_subsystem_ids, debug_files, -1); } TAILQ_FOREACH_SAFE(debug_file, debug_files, entries, debug_next) { TAILQ_REMOVE(debug_files, debug_file, entries); diff --git a/plugins/python/sudo_python_debug.h b/plugins/python/sudo_python_debug.h index 02a715a7e..08c4f29ff 100644 --- a/plugins/python/sudo_python_debug.h +++ b/plugins/python/sudo_python_debug.h @@ -25,7 +25,7 @@ * Sudo python plugin debug subsystems. * Note that python_subsystem_ids[] is filled in at debug registration time. */ -extern int python_subsystem_ids[]; +extern unsigned int python_subsystem_ids[]; #define PYTHON_DEBUG_PY_CALLS (python_subsystem_ids[0]) #define PYTHON_DEBUG_C_CALLS (python_subsystem_ids[1]) #define PYTHON_DEBUG_PLUGIN_LOAD (python_subsystem_ids[2])