Use a macro instead.
#define DEFAULT_TEXT_DOMAIN "sudo"
#include "gettext.h"
-static sigjmp_buf error_jmp;
+sigjmp_buf error_jmp;
static bool setjmp_enabled = false;
static struct sudo_error_callback {
void (*func)(void);
return 0;
}
-int
-plugin_setjmp(void)
-{
- setjmp_enabled = true;
- return sigsetjmp(error_jmp, 1);
-}
-
void
-plugin_longjmp(int val)
+error_disable_setjmp(void)
{
- siglongjmp(error_jmp, val);
+ setjmp_enabled = false;
}
void
-plugin_clearjmp(void)
+error_enable_setjmp(void)
{
- setjmp_enabled = false;
+ setjmp_enabled = true;
}
#define _SUDO_ERROR_H_
#include <stdarg.h>
+#include <setjmp.h>
/*
* We wrap error/errorx and warn/warnx so that the same output can
warning_restore_locale(); \
} while (0)
+#define error_setjmp() (error_enable_setjmp(), sigsetjmp(error_jmp, 1))
+#define error_longjmp(val) siglongjmp(error_jmp, val)
+
extern int (*sudo_printf)(int msg_type, const char *fmt, ...);
+extern sigjmp_buf error_jmp;
int error_callback_register(void (*func)(void));
+void error_disable_setjmp(void);
+void error_enable_setjmp(void);
void error2(int, const char *, ...) __printflike(2, 3) __attribute__((__noreturn__));
void errorx2(int, const char *, ...) __printflike(2, 3) __attribute__((__noreturn__));
void verror2(int, const char *, va_list ap) __attribute__((__noreturn__));
if (argc == 0)
debug_return_bool(true);
- if (plugin_setjmp() != 0) {
+ if (error_setjmp() != 0) {
/* called via error(), errorx() or log_fatal() */
rval = -1;
goto done;
rval = true;
done:
- plugin_clearjmp();
+ error_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 (plugin_setjmp() != 0) {
+ if (error_setjmp() != 0) {
/* called via error(), errorx() or log_fatal() */
- plugin_clearjmp();
+ error_disable_setjmp();
debug_return;
}
{
debug_decl(sudoers_io_version, SUDO_DEBUG_PLUGIN)
- if (plugin_setjmp() != 0) {
+ if (error_setjmp() != 0) {
/* called via error(), errorx() or log_fatal() */
- plugin_clearjmp();
+ error_disable_setjmp();
debug_return_bool(-1);
}
gettimeofday(&now, NULL);
- if (plugin_setjmp() != 0) {
+ if (error_setjmp() != 0) {
/* called via error(), errorx() or log_fatal() */
- plugin_clearjmp();
+ error_disable_setjmp();
debug_return_bool(-1);
}
/* Exit the plugin. */
sudoers_cleanup();
sudo_debug_exit(__func__, __FILE__, __LINE__, sudo_debug_subsys);
- plugin_longjmp(1);
+ error_longjmp(1);
}
#define MAX_MAILFLAGS 63
if (sudo_version < SUDO_API_MKVERSION(1, 2))
args = NULL;
- if (plugin_setjmp() != 0) {
+ if (error_setjmp() != 0) {
/* called via error(), errorx() or log_fatal() */
rewind_perms();
- plugin_clearjmp();
+ error_disable_setjmp();
debug_return_bool(-1);
}
{
debug_decl(sudoers_policy_close, SUDO_DEBUG_PLUGIN)
- if (plugin_setjmp() != 0) {
+ if (error_setjmp() != 0) {
/* called via error(), errorx() or log_fatal() */
- plugin_clearjmp();
+ error_disable_setjmp();
debug_return;
}
if (sudo_version < SUDO_API_MKVERSION(1, 2))
user_env = NULL;
- if (plugin_setjmp() != 0) {
+ if (error_setjmp() != 0) {
/* called via error(), errorx() or log_fatal() */
- plugin_clearjmp();
+ error_disable_setjmp();
debug_return_bool(-1);
}
debug_decl(sudoers_policy_invalidate, SUDO_DEBUG_PLUGIN)
user_cmnd = "kill";
- if (plugin_setjmp() == 0) {
+ if (error_setjmp() == 0) {
remove_timestamp(remove);
sudoers_cleanup();
}
- plugin_clearjmp();
+ error_disable_setjmp();
debug_return;
}
{
debug_decl(sudoers_policy_version, SUDO_DEBUG_PLUGIN)
- if (plugin_setjmp() != 0) {
+ if (error_setjmp() != 0) {
/* error recovery via error(), errorx() or log_fatal() */
- plugin_clearjmp();
+ error_disable_setjmp();
debug_return_bool(-1);
}
(void) sigaction(SIGTSTP, &sa, &saved_sa_tstp);
/* XXX - would like to move this to policy.c but need the cleanup. */
- if (plugin_setjmp() != 0) {
+ if (error_setjmp() != 0) {
/* error recovery via error(), errorx() or log_fatal() */
rval = -1;
goto done;
rval = false;
done:
- plugin_clearjmp();
+ error_disable_setjmp();
rewind_perms();
/* Restore signal handlers before we exec. */
/* setgroups.c */
int sudo_setgroups(int ngids, const GETGROUPS_T *gids);
-/* plugin_error.c */
-int plugin_setjmp(void);
-void plugin_clearjmp(void);
-void plugin_longjmp(int val) __attribute__((__noreturn__));
-
#ifndef _SUDO_MAIN
extern struct sudo_user sudo_user;
extern struct passwd *list_pw;