#define _SUDO_DEBUG_H
#include <stdarg.h>
+#ifdef HAVE_STDBOOL_H
+# include <stdbool.h>
+#else
+# include "compat/stdbool.h"
+#endif
#include "sudo_queue.h"
/* Number of bits in a byte. */
#define debug_return_bool(rval) \
do { \
- int sudo_debug_rval = (rval); \
+ bool sudo_debug_rval = (rval); \
sudo_debug_exit_bool(__func__, __FILE__, __LINE__, sudo_debug_subsys, \
sudo_debug_rval); \
return sudo_debug_rval; \
__dso_public void sudo_debug_enter_v1(const char *func, const char *file, int line, int subsys);
__dso_public void sudo_debug_execve2_v1(int level, const char *path, char *const argv[], char *const envp[]);
__dso_public void sudo_debug_exit_v1(const char *func, const char *file, int line, int subsys);
-__dso_public void sudo_debug_exit_bool_v1(const char *func, const char *file, int line, int subsys, int rval);
+__dso_public void sudo_debug_exit_bool_v1(const char *func, const char *file, int line, int subsys, bool rval);
__dso_public void sudo_debug_exit_int_v1(const char *func, const char *file, int line, int subsys, int rval);
__dso_public void sudo_debug_exit_long_v1(const char *func, const char *file, int line, int subsys, long rval);
__dso_public void sudo_debug_exit_ptr_v1(const char *func, const char *file, int line, int subsys, const void *rval);
# include <stdlib.h>
# endif
#endif /* STDC_HEADERS */
-#ifdef HAVE_STDBOOL_H
-# include <stdbool.h>
-#else
-# include "compat/stdbool.h"
-#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif /* HAVE_STRING_H */
#include "sudo_alloc.h"
#include "sudo_fatal.h"
#include "sudo_plugin.h"
-#include "sudo_conf.h"
#include "sudo_debug.h"
+#include "sudo_conf.h"
#include "sudo_util.h"
/*
"<- %s @ %s:%d := %zu", func, file, line, rval);
}
-/* We use int, not bool, here for functions that return -1 on error. */
void
sudo_debug_exit_bool_v1(const char *func, const char *file, int line,
- int subsys, int rval)
+ int subsys, bool rval)
{
- if (rval == true || rval == false) {
- sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE,
- "<- %s @ %s:%d := %s", func, file, line, rval ? "true" : "false");
- } else {
- sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE,
- "<- %s @ %s:%d := %d", func, file, line, rval);
- }
+ sudo_debug_printf2(NULL, NULL, 0, subsys | SUDO_DEBUG_TRACE,
+ "<- %s @ %s:%d := %s", func, file, line, rval ? "true" : "false");
}
void
debug_decl(check_dce_status, SUDOERS_DEBUG_AUTH)
if (input_status == rpc_s_ok)
- debug_return_bool(0);
+ debug_return_int(0);
dce_error_inq_text(input_status, error_string, &error_stat);
(void) fprintf(stderr, "%s %s\n", comment, error_string);
- debug_return_bool(1);
+ debug_return_int(1);
}
!ISSET(mode, MODE_IGNORE_TICKET) && status != TS_ERROR)
update_timestamp(auth_pw);
done:
- debug_return_bool(rval);
+ debug_return_int(rval);
}
/*
sudo_auth_cleanup(auth_pw);
sudo_pw_delref(auth_pw);
- debug_return_bool(rval);
+ debug_return_int(rval);
}
/*
keepit = !strpbrk(++val, "/%");
}
}
- debug_return_bool(keepit);
+ debug_return_int(keepit);
}
/*
}
}
- debug_return_bool(rc);
+ debug_return_int(rc);
}
void
debug_decl(group_plugin_query, SUDOERS_DEBUG_UTIL)
if (group_plugin == NULL)
- debug_return_bool(false);
- debug_return_bool((group_plugin->query)(user, group, pwd));
+ debug_return_int(false);
+ debug_return_int((group_plugin->query)(user, group, pwd));
}
#else /* !HAVE_DLOPEN && !HAVE_SHL_LOAD */
group_plugin_load(char *plugin_info)
{
debug_decl(group_plugin_load, SUDOERS_DEBUG_UTIL)
- debug_return_bool(false);
+ debug_return_int(false);
}
void
const struct passwd *pwd)
{
debug_decl(group_plugin_query, SUDOERS_DEBUG_UTIL)
- debug_return_bool(false);
+ debug_return_int(false);
}
#endif /* HAVE_DLOPEN || HAVE_SHL_LOAD */
/* If we have no command (because -V was specified) just return. */
if (argc == 0)
- debug_return_bool(true);
+ debug_return_int(true);
memset(&details, 0, sizeof(details));
sudo_gr_delref(details.runas_gr);
sudo_endgrent();
- debug_return_bool(rval);
+ debug_return_int(rval);
}
static void
sudo_printf(SUDO_CONV_INFO_MSG, "Sudoers I/O plugin version %s\n",
PACKAGE_VERSION);
- debug_return_bool(true);
+ debug_return_int(true);
}
/*
last_time.tv_sec = now.tv_sec;
last_time.tv_usec = now.tv_usec;
- debug_return_bool(rval);
+ debug_return_int(rval);
}
static int
debug_decl(sudo_ldap_check_runas_user, SUDOERS_DEBUG_LDAP)
if (!runas_pw)
- debug_return_bool(UNSPEC);
+ debug_return_int(UNSPEC);
/* get the runas user from the entry */
bv = ldap_get_values_len(ld, entry, "sudoRunAsUser");
* what the user specified on the command line.
*/
if (bv == NULL)
- debug_return_bool(!strcasecmp(runas_pw->pw_name, def_runas_default));
+ debug_return_int(!strcasecmp(runas_pw->pw_name, def_runas_default));
/* walk through values returned, looking for a match */
for (p = bv; *p != NULL && !ret; p++) {
ldap_value_free_len(bv); /* cleanup */
- debug_return_bool(ret);
+ debug_return_int(ret);
}
static int
/* runas_gr is only set if the user specified the -g flag */
if (!runas_gr)
- debug_return_bool(UNSPEC);
+ debug_return_int(UNSPEC);
/* get the values from the entry */
bv = ldap_get_values_len(ld, entry, "sudoRunAsGroup");
if (bv == NULL)
- debug_return_bool(ret);
+ debug_return_int(ret);
/* walk through values returned, looking for a match */
for (p = bv; *p != NULL && !ret; p++) {
ldap_value_free_len(bv); /* cleanup */
- debug_return_bool(ret);
+ debug_return_int(ret);
}
/*
debug_decl(sudo_ldap_check_command, SUDOERS_DEBUG_LDAP)
if (!entry)
- debug_return_bool(ret);
+ debug_return_int(ret);
bv = ldap_get_values_len(ld, entry, "sudoCommand");
if (bv == NULL)
- debug_return_bool(ret);
+ debug_return_int(ret);
for (p = bv; *p != NULL && ret != false; p++) {
val = (*p)->bv_val;
ldap_value_free_len(bv); /* more cleanup */
- debug_return_bool(ret);
+ debug_return_int(ret);
}
/*
debug_decl(sudo_ldap_check_bool, SUDOERS_DEBUG_LDAP)
if (entry == NULL)
- debug_return_bool(ret);
+ debug_return_int(ret);
bv = ldap_get_values_len(ld, entry, "sudoOption");
if (bv == NULL)
- debug_return_bool(ret);
+ debug_return_int(ret);
/* walk through options */
for (p = bv; *p != NULL; p++) {
ldap_value_free_len(bv);
- debug_return_bool(ret);
+ debug_return_int(ret);
}
/*
if (found)
printf("%s%s%s\n", safe_cmnd ? safe_cmnd : user_cmnd,
user_args ? " " : "", user_args ? user_args : "");
- debug_return_bool(!found);
+ debug_return_int(!found);
}
#ifdef HAVE_LDAP_SASL_INTERACTIVE_BIND_S
if (matched != UNSPEC)
break;
}
- debug_return_bool(matched);
+ debug_return_int(matched);
}
/*
if (matched != UNSPEC)
break;
}
- debug_return_bool(matched);
+ debug_return_int(matched);
}
/*
if (matched != UNSPEC)
break;
}
- debug_return_bool(matched);
+ debug_return_int(matched);
}
/*
matched = !m->negated;
break;
}
- debug_return_bool(matched);
+ debug_return_int(matched);
}
static bool
rval = true;
done:
- debug_return_bool(rval);
+ debug_return_int(rval);
}
static int
info.settings = settings;
info.user_info = user_info;
info.plugin_args = args;
- debug_return_bool(sudoers_policy_init(&info, envp));
+ debug_return_int(sudoers_policy_init(&info, envp));
}
static void
if (sudo_version < SUDO_API_MKVERSION(1, 2))
user_env = NULL;
- debug_return_bool(sudo_auth_begin_session(pwd, user_env));
+ debug_return_int(sudo_auth_begin_session(pwd, user_env));
}
static int
!sudo_auth_needs_end_session())
sudoers_policy.close = NULL;
}
- debug_return_bool(rval);
+ debug_return_int(rval);
}
static int
user_cmnd = "validate";
SET(sudo_mode, MODE_VALIDATE);
- debug_return_bool(sudoers_policy_main(0, NULL, I_VERIFYPW, NULL, NULL));
+ debug_return_int(sudoers_policy_main(0, NULL, I_VERIFYPW, NULL, NULL));
}
static void
list_pw = sudo_getpwnam(list_user);
if (list_pw == NULL) {
sudo_warnx(U_("unknown user: %s"), list_user);
- debug_return_bool(-1);
+ debug_return_int(-1);
}
}
rval = sudoers_policy_main(argc, argv, I_LISTPW, NULL, NULL);
list_pw = NULL;
}
- debug_return_bool(rval);
+ debug_return_int(rval);
}
static int
sudo_printf(SUDO_CONV_INFO_MSG, "\n");
}
}
- debug_return_bool(true);
+ debug_return_int(true);
}
/*
/* Parse info from front-end. */
sudo_mode = sudoers_policy_deserialize_info(info, &runas_user, &runas_group);
if (ISSET(sudo_mode, MODE_ERROR))
- debug_return_bool(-1);
+ debug_return_int(-1);
if (!init_vars(envp))
- debug_return_bool(-1);
+ debug_return_int(-1);
/* Parse nsswitch.conf for sudoers order. */
snl = sudo_read_nss();
/* LDAP or NSS may modify the euid so we need to be root for the open. */
if (!set_perms(PERM_ROOT))
- debug_return_bool(-1);
+ debug_return_int(-1);
/* Open and parse sudoers, set global defaults */
TAILQ_FOREACH_SAFE(nss, snl, entries, nss_next) {
if (!restore_perms())
rval = -1;
- debug_return_bool(rval);
+ debug_return_int(rval);
}
int
sudo_endpwent();
sudo_endgrent();
- debug_return_bool(rval);
+ debug_return_int(rval);
}
/*
/* Convert struct sudo_settings to plugin_settings[] */
plugin_settings = format_plugin_settings(plugin, settings);
if (plugin_settings == NULL)
- debug_return_bool(-1);
+ debug_return_int(-1);
/*
* Backwards compatibility for older API versions
plugin->debug_instance = sudo_debug_get_active_instance();
sudo_debug_set_active_instance(sudo_debug_instance);
- debug_return_bool(rval);
+ debug_return_int(rval);
}
static void
debug_decl(policy_show_version, SUDO_DEBUG_PCOMM)
if (plugin->u.policy->show_version == NULL)
- debug_return_bool(true);
+ debug_return_int(true);
sudo_debug_set_active_instance(plugin->debug_instance);
rval = plugin->u.policy->show_version(verbose);
sudo_debug_set_active_instance(sudo_debug_instance);
- debug_return_bool(rval);
+ debug_return_int(rval);
}
static int
rval = plugin->u.policy->check_policy(argc, argv, env_add, command_info,
argv_out, user_env_out);
sudo_debug_set_active_instance(sudo_debug_instance);
- debug_return_bool(rval);
+ debug_return_int(rval);
}
static int
if (plugin->u.policy->list == NULL) {
sudo_warnx(U_("policy plugin %s does not support listing privileges"),
plugin->name);
- debug_return_bool(false);
+ debug_return_int(false);
}
sudo_debug_set_active_instance(plugin->debug_instance);
rval = plugin->u.policy->list(argc, argv, verbose, list_user);
sudo_debug_set_active_instance(sudo_debug_instance);
- debug_return_bool(rval);
+ debug_return_int(rval);
}
static int
if (plugin->u.policy->validate == NULL) {
sudo_warnx(U_("policy plugin %s does not support the -v option"),
plugin->name);
- debug_return_bool(false);
+ debug_return_int(false);
}
sudo_debug_set_active_instance(plugin->debug_instance);
rval = plugin->u.policy->validate();
sudo_debug_set_active_instance(sudo_debug_instance);
- debug_return_bool(rval);
+ debug_return_int(rval);
}
static void
}
sudo_debug_set_active_instance(sudo_debug_instance);
}
- debug_return_bool(rval);
+ debug_return_int(rval);
}
static int
/* Convert struct sudo_settings to plugin_settings[] */
plugin_settings = format_plugin_settings(plugin, settings);
if (plugin_settings == NULL)
- debug_return_bool(-1);
+ debug_return_int(-1);
/*
* Backwards compatibility for older API versions
argc, argv, user_env, plugin->options);
}
sudo_debug_set_active_instance(sudo_debug_instance);
- debug_return_bool(rval);
+ debug_return_int(rval);
}
static void
debug_decl(iolog_show_version, SUDO_DEBUG_PCOMM)
if (plugin->u.io->show_version == NULL)
- debug_return_bool(true);
+ debug_return_int(true);
sudo_debug_set_active_instance(plugin->debug_instance);
rval = plugin->u.io->show_version(verbose);
sudo_debug_set_active_instance(sudo_debug_instance);
- debug_return_bool(rval);
+ debug_return_int(rval);
}
/*