#define _SUDO_FATAL_H_
#include <stdarg.h>
-#include <setjmp.h>
/*
* We wrap fatal/fatalx and warning/warningx so that the same output can
} while (0)
#endif /* SUDO_ERROR_WRAP */
-#define fatal_setjmp() (fatal_enable_setjmp(), sigsetjmp(fatal_jmp, 1))
-#define fatal_longjmp(val) siglongjmp(fatal_jmp, val)
-
extern int (*sudo_printf)(int msg_type, const char *fmt, ...);
-extern sigjmp_buf fatal_jmp;
__dso_public int fatal_callback_deregister(void (*func)(void));
__dso_public int fatal_callback_register(void (*func)(void));
__dso_public char *warning_gettext(const char *msgid) __format_arg(1);
-__dso_public void fatal_disable_setjmp(void);
-__dso_public void fatal_enable_setjmp(void);
__dso_public void fatal_nodebug(const char *, ...) __printf0like(1, 2) __attribute__((__noreturn__));
__dso_public void fatalx_nodebug(const char *, ...) __printflike(1, 2) __attribute__((__noreturn__));
__dso_public void vfatal_nodebug(const char *, va_list ap) __printf0like(1, 0) __attribute__((__noreturn__));
/*
- * Copyright (c) 2004-2005, 2010-2013 Todd C. Miller <Todd.Miller@courtesan.com>
+ * Copyright (c) 2004-2005, 2010-2014 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
};
SLIST_HEAD(sudo_fatal_callback_list, sudo_fatal_callback);
-__dso_public sigjmp_buf fatal_jmp;
-static bool setjmp_enabled = false;
static struct sudo_fatal_callback_list callbacks;
static void _warning(int, const char *, va_list);
_warning(1, fmt, ap);
va_end(ap);
do_cleanup();
- if (setjmp_enabled)
- siglongjmp(fatal_jmp, 1);
- else
- exit(EXIT_FAILURE);
+ exit(EXIT_FAILURE);
}
void
_warning(0, fmt, ap);
va_end(ap);
do_cleanup();
- if (setjmp_enabled)
- siglongjmp(fatal_jmp, 1);
- else
- exit(EXIT_FAILURE);
+ exit(EXIT_FAILURE);
}
void
{
_warning(1, fmt, ap);
do_cleanup();
- if (setjmp_enabled)
- siglongjmp(fatal_jmp, 1);
- else
- exit(EXIT_FAILURE);
+ exit(EXIT_FAILURE);
}
void
{
_warning(0, fmt, ap);
do_cleanup();
- if (setjmp_enabled)
- siglongjmp(fatal_jmp, 1);
- else
- exit(EXIT_FAILURE);
+ exit(EXIT_FAILURE);
}
void
return -1;
}
-
-void
-fatal_disable_setjmp(void)
-{
- setjmp_enabled = false;
-}
-
-void
-fatal_enable_setjmp(void)
-{
- setjmp_enabled = true;
-}
evasprintf
fatal_callback_deregister
fatal_callback_register
-fatal_disable_setjmp
-fatal_enable_setjmp
-fatal_jmp
fatal_nodebug
fatalx_nodebug
fmt_string
memset(&details, 0, sizeof(details));
- if (fatal_setjmp() != 0) {
- /* called via fatal() or fatalx() */
- rval = -1;
- goto done;
- }
-
bindtextdomain("sudoers", LOCALEDIR);
sudo_setpwent();
rval = true;
done:
- fatal_disable_setjmp();
efree(tofree);
if (details.runas_pw)
sudo_pw_delref(details.runas_pw);
int i;
debug_decl(sudoers_io_close, SUDO_DEBUG_PLUGIN)
- if (fatal_setjmp() != 0) {
- /* called via fatal() or fatalx() */
- fatal_disable_setjmp();
- debug_return;
- }
-
for (i = 0; i < IOFD_MAX; i++) {
if (io_log_files[i].fd.v == NULL)
continue;
{
debug_decl(sudoers_io_version, SUDO_DEBUG_PLUGIN)
- if (fatal_setjmp() != 0) {
- /* called via fatal() or fatalx() */
- fatal_disable_setjmp();
- debug_return_bool(-1);
- }
-
sudo_printf(SUDO_CONV_INFO_MSG, "Sudoers I/O plugin version %s\n",
PACKAGE_VERSION);
gettimeofday(&now, NULL);
- if (fatal_setjmp() != 0) {
- /* called via fatal() or fatalx() */
- fatal_disable_setjmp();
- debug_return_bool(-1);
- }
-
#ifdef HAVE_ZLIB_H
if (iolog_compress)
ignore_result(gzwrite(io_log_files[idx].fd.g, (const voidp)buf, len));
if (sudo_version < SUDO_API_MKVERSION(1, 2))
args = NULL;
- if (fatal_setjmp() != 0) {
- /* called via fatal() or fatalx() */
- (void) rewind_perms();
- fatal_disable_setjmp();
- debug_return_bool(-1);
- }
-
/* Call the sudoers init function. */
info.settings = settings;
info.user_info = user_info;
{
debug_decl(sudoers_policy_close, SUDO_DEBUG_PLUGIN)
- if (fatal_setjmp() != 0) {
- /* called via fatal() or fatalx() */
- fatal_disable_setjmp();
- debug_return;
- }
-
/* We do not currently log the exit status. */
if (error_code) {
errno = error_code;
if (sudo_version < SUDO_API_MKVERSION(1, 2))
user_env = NULL;
- if (fatal_setjmp() != 0) {
- /* called via fatal() or fatalx() */
- fatal_disable_setjmp();
- debug_return_bool(-1);
- }
-
debug_return_bool(sudo_auth_begin_session(pwd, user_env));
}
debug_decl(sudoers_policy_invalidate, SUDO_DEBUG_PLUGIN)
user_cmnd = "kill";
- if (fatal_setjmp() == 0) {
- remove_timestamp(remove);
- sudoers_cleanup();
- }
- fatal_disable_setjmp();
+ remove_timestamp(remove);
+ sudoers_cleanup();
debug_return;
}
{
debug_decl(sudoers_policy_version, SUDO_DEBUG_PLUGIN)
- if (fatal_setjmp() != 0) {
- /* error recovery via fatal() or fatalx() */
- fatal_disable_setjmp();
- debug_return_bool(-1);
- }
-
sudo_printf(SUDO_CONV_INFO_MSG, _("Sudoers policy plugin version %s\n"),
PACKAGE_VERSION);
sudo_printf(SUDO_CONV_INFO_MSG, _("Sudoers file grammar version %d\n"),
volatile int rval = true;
debug_decl(sudoers_policy_main, SUDO_DEBUG_PLUGIN)
- /* XXX - would like to move this to policy.c but need the cleanup. */
- if (fatal_setjmp() != 0) {
- /* error recovery via fatal() or fatalx() */
- rval = -1;
- goto done;
- }
-
/* Is root even allowed to run sudo? */
if (user_uid == 0 && !def_root_sudo) {
/* Not an audit event. */
rval = false;
done:
- fatal_disable_setjmp();
if (!rewind_perms())
rval = -1;