common/aix.c
common/alloc.c
common/atobool.c
+common/error.c
common/fileops.c
common/fmt_string.c
common/lbuf.c
plugins/sudoers/mkdefaults
plugins/sudoers/parse.c
plugins/sudoers/parse.h
-plugins/sudoers/plugin_error.c
plugins/sudoers/po/README
plugins/sudoers/po/da.mo
plugins/sudoers/po/da.po
src/Makefile.in
src/conversation.c
src/env_hooks.c
-src/error.c
src/exec.c
src/exec_common.c
src/exec_pty.c
src/get_pty.c
src/hooks.c
src/load_plugins.c
+src/locale_stub.c
src/net_ifs.c
src/openbsd.c
src/parse_args.c
SHELL = @SHELL@
-LTOBJS = alloc.lo atobool.lo fileops.lo fmt_string.lo lbuf.lo list.lo \
+LTOBJS = alloc.lo atobool.lo error.lo fileops.lo fmt_string.lo lbuf.lo list.lo \
secure_path.lo setgroups.lo sudo_conf.lo sudo_debug.lo sudo_printf.lo \
term.lo ttysize.lo zero_bytes.lo @COMMON_OBJS@
atobool.lo: $(srcdir)/atobool.c $(top_builddir)/config.h $(incdir)/missing.h \
$(incdir)/sudo_debug.h
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/atobool.c
+error.lo: $(srcdir)/error.c $(top_builddir)/config.h \
+ $(top_srcdir)/compat/stdbool.h $(incdir)/missing.h $(incdir)/alloc.h \
+ $(incdir)/error.h $(incdir)/sudo_plugin.h $(incdir)/gettext.h
+ $(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/error.c
fileops.lo: $(srcdir)/fileops.c $(top_builddir)/config.h \
$(top_srcdir)/compat/stdbool.h $(top_srcdir)/compat/timespec.h \
$(incdir)/missing.h $(incdir)/fileops.h $(incdir)/sudo_debug.h
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/sudo_conf.c
sudo_debug.lo: $(srcdir)/sudo_debug.c $(top_builddir)/config.h \
$(top_srcdir)/compat/stdbool.h $(incdir)/missing.h \
- $(incdir)/alloc.h $(incdir)/error.h $(incdir)/gettext.h \
- $(incdir)/sudo_plugin.h $(incdir)/sudo_debug.h
+ $(incdir)/alloc.h $(incdir)/error.h $(incdir)/sudo_plugin.h \
+ $(incdir)/sudo_debug.h $(incdir)/gettext.h
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/sudo_debug.c
sudo_printf.lo: $(srcdir)/sudo_printf.c $(top_builddir)/config.h \
- $(incdir)/sudo_plugin.h
+ $(incdir)/sudo_plugin.h $(incdir)/sudo_debug.h
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/sudo_printf.c
term.lo: $(srcdir)/term.c $(top_builddir)/config.h $(incdir)/missing.h \
$(incdir)/sudo_debug.h
#include "missing.h"
#include "alloc.h"
#include "error.h"
-#include "logging.h"
#include "sudo_plugin.h"
-#define DEFAULT_TEXT_DOMAIN "sudoers"
+#define DEFAULT_TEXT_DOMAIN "sudo"
#include "gettext.h"
-static void _warning(int, const char *, va_list);
- void sudoers_cleanup(int);
-
static sigjmp_buf error_jmp;
static bool setjmp_enabled = false;
+static struct sudo_error_callback {
+ void (*func)(void);
+ struct sudo_error_callback *next;
+} *callbacks;
+
+static void _warning(int, const char *, va_list);
+
+static void
+do_cleanup(void)
+{
+ struct sudo_error_callback *cb;
+
+ /* Run callbacks, removing them from the list as we go. */
+ while ((cb = callbacks) != NULL) {
+ callbacks = cb->next;
+ cb->func();
+ free(cb);
+ }
+}
void
error2(int eval, const char *fmt, ...)
va_start(ap, fmt);
_warning(1, fmt, ap);
va_end(ap);
- sudoers_cleanup(0);
+ do_cleanup();
if (setjmp_enabled)
siglongjmp(error_jmp, eval);
else
va_start(ap, fmt);
_warning(0, fmt, ap);
va_end(ap);
- sudoers_cleanup(0);
+ do_cleanup();
if (setjmp_enabled)
siglongjmp(error_jmp, eval);
else
verror2(int eval, const char *fmt, va_list ap)
{
_warning(1, fmt, ap);
- sudoers_cleanup(0);
+ do_cleanup();
if (setjmp_enabled)
siglongjmp(error_jmp, eval);
else
verrorx2(int eval, const char *fmt, va_list ap)
{
_warning(0, fmt, ap);
- sudoers_cleanup(0);
+ do_cleanup();
if (setjmp_enabled)
siglongjmp(error_jmp, eval);
else
errno = serrno;
}
-static int oldlocale;
-
-void
-warning_set_locale(void)
+int
+error_callback_register(void (*func)(void))
{
- sudoers_setlocale(SUDOERS_LOCALE_USER, &oldlocale);
-}
+ struct sudo_error_callback *cb;
-void
-warning_restore_locale(void)
-{
- sudoers_setlocale(oldlocale, NULL);
+ cb = malloc(sizeof(*cb));
+ if (cb == NULL)
+ return -1;
+ cb->func = func;
+ cb->next = callbacks;
+ callbacks = cb;
+
+ return 0;
}
int
_sudo_printf(int msg_type, const char *fmt, ...)
{
va_list ap;
- FILE *fp;
- int len;
+ char *buf;
+ int len = -1;
switch (msg_type) {
case SUDO_CONV_INFO_MSG:
- fp = stdout;
+ va_start(ap, fmt);
+ len = vfprintf(stdout, fmt, ap);
+ va_end(ap);
break;
case SUDO_CONV_ERROR_MSG:
- fp = stderr;
+ va_start(ap, fmt);
+ len = vfprintf(stderr, fmt, ap);
+ va_end(ap);
break;
case SUDO_CONV_DEBUG_MSG:
- {
- char *buf;
- va_list ap;
-
/* XXX - add debug version of vfprintf()? */
va_start(ap, fmt);
len = vasprintf(&buf, fmt, ap);
va_end(ap);
- if (len == -1)
- return -1;
- sudo_debug_write(buf, len, 0);
+ if (len != -1)
+ sudo_debug_write(buf, len, 0);
break;
- }
default:
errno = EINVAL;
- return -1;
+ break;
}
- va_start(ap, fmt);
- len = vfprintf(fp, fmt, ap);
- va_end(ap);
-
return len;
}
-int (*sudo_printf)(int msg_type, const char *fmt, ...) = _sudo_printf;
+sudo_printf_t sudo_printf = _sudo_printf;
dlopen)
$as_echo "#define HAVE_DLOPEN 1" >>confdefs.h
- SUDOERS_OBJS="$SUDOERS_OBJS plugin_error.lo"
+ SUDO_OBJS="$SUDO_OBJS locale_stub.lo"
LT_STATIC="--tag=disable-static"
;;
shl_load)
$as_echo "#define HAVE_SHL_LOAD 1" >>confdefs.h
- SUDOERS_OBJS="$SUDOERS_OBJS plugin_error.lo"
+ SUDO_OBJS="$SUDO_OBJS locale_stub.lo"
LT_STATIC="--tag=disable-static"
case " $LIBOBJS " in
*" dlopen.$ac_objext "* ) ;;
case "$lt_cv_dlopen" in
dlopen)
AC_DEFINE(HAVE_DLOPEN)
- SUDOERS_OBJS="$SUDOERS_OBJS plugin_error.lo"
+ SUDO_OBJS="$SUDO_OBJS locale_stub.lo"
LT_STATIC="--tag=disable-static"
;;
shl_load)
AC_DEFINE(HAVE_SHL_LOAD)
- SUDOERS_OBJS="$SUDOERS_OBJS plugin_error.lo"
+ SUDO_OBJS="$SUDO_OBJS locale_stub.lo"
LT_STATIC="--tag=disable-static"
AC_LIBOBJ(dlopen)
;;
#define _SUDO_ERROR_H_
#include <stdarg.h>
-#include <sudo_plugin.h>
/*
* We wrap error/errorx and warn/warnx so that the same output can
warning_restore_locale(); \
} while (0)
-extern sudo_printf_t sudo_printf;
+extern int (*sudo_printf)(int msg_type, const char *fmt, ...);
+int error_callback_register(void (*func)(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__));
$makefile =~ s:\@DEV\@::g;
$makefile =~ s:\@COMMON_OBJS\@:aix.lo:;
$makefile =~ s:\@SUDO_OBJS\@:openbsd.o preload.o selinux.o sesh.o solaris.o sudo_noexec.lo:;
- $makefile =~ s:\@SUDOERS_OBJS\@:bsm_audit.lo linux_audit.lo ldap.lo plugin_error.lo sssd.lo:;
+ $makefile =~ s:\@SUDOERS_OBJS\@:bsm_audit.lo linux_audit.lo ldap.lo sssd.lo:;
# XXX - fill in AUTH_OBJS from contents of the auth dir instead
$makefile =~ s:\@AUTH_OBJS\@:afs.lo aix_auth.lo bsdauth.lo dce.lo fwtk.lo getspwuid.lo kerb5.lo pam.lo passwd.lo rfc1938.lo secureware.lo securid5.lo sia.lo:;
$makefile =~ s:\@LTLIBOBJS\@:closefrom.lo dlopen.lo fnmatch.lo getcwd.lo getgrouplist.lo getline.lo getprogname.lo glob.lo isblank.lo memrchr.lo mksiglist.lo mksigname.lo mktemp.lo nanosleep.lo pw_dup.lo sig2str.lo siglist.lo signame.lo snprintf.lo strlcat.lo strlcpy.lo strsignal.lo utimes.lo globtest.o fnm_test.o:;
policy.lo prompt.lo set_perms.lo sudo_nss.lo sudoers.lo \
timestamp.lo @SUDOERS_OBJS@
-VISUDO_OBJS = find_path.o goodpath.o locale.o plugin_error.o visudo.o
+VISUDO_OBJS = find_path.o goodpath.o locale.o visudo.o
-REPLAY_OBJS = getdate.o locale.o plugin_error.o sudoreplay.o
+REPLAY_OBJS = getdate.o locale.o sudoreplay.o
-TEST_OBJS = group_plugin.o interfaces.o locale.o net_ifs.o plugin_error.o \
+TEST_OBJS = group_plugin.o interfaces.o locale.o net_ifs.o \
testsudoers.o tsgetgrpw.o
-CHECK_ADDR_OBJS = check_addr.o interfaces.o locale.o match_addr.o plugin_error.o
+CHECK_ADDR_OBJS = check_addr.o interfaces.o locale.o match_addr.o
-CHECK_FILL_OBJS = check_fill.o locale.o plugin_error.o toke_util.o
+CHECK_FILL_OBJS = check_fill.o locale.o toke_util.o
CHECK_IOLOG_PATH_OBJS = check_iolog_path.o iolog_path.o locale.o \
- plugin_error.o pwutil.o pwutil_impl.o redblack.o
+ pwutil.o pwutil_impl.o redblack.o
-CHECK_SYMBOLS_OBJS = check_symbols.o locale.o plugin_error.o
+CHECK_SYMBOLS_OBJS = check_symbols.o locale.o
-CHECK_WRAP_OBJS = check_wrap.o locale.o logwrap.o plugin_error.o
+CHECK_WRAP_OBJS = check_wrap.o locale.o logwrap.o
LIBOBJDIR = $(top_builddir)/@ac_config_libobj_dir@/
$(srcdir)/interfaces.h
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/regress/parser/check_addr.c
check_fill.o: $(srcdir)/regress/parser/check_fill.c $(top_builddir)/config.h \
- $(top_srcdir)/compat/stdbool.h $(incdir)/list.h \
- $(srcdir)/parse.h $(srcdir)/toke.h $(incdir)/sudo_plugin.h \
- $(devdir)/gram.h
+ $(top_srcdir)/compat/stdbool.h $(incdir)/missing.h \
+ $(incdir)/list.h $(srcdir)/parse.h $(srcdir)/toke.h \
+ $(incdir)/sudo_plugin.h $(devdir)/gram.h
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/regress/parser/check_fill.c
check_iolog_path.o: $(srcdir)/regress/iolog_path/check_iolog_path.c \
$(top_builddir)/config.h $(srcdir)/sudoers.h \
$(devdir)/def_data.h $(srcdir)/logging.h $(srcdir)/sudo_nss.h \
$(incdir)/sudo_plugin.h $(incdir)/sudo_debug.h $(incdir)/gettext.h
$(LIBTOOL) --mode=compile $(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(authdir)/passwd.c
-plugin_error.lo: $(srcdir)/plugin_error.c $(top_builddir)/config.h \
- $(top_srcdir)/compat/stdbool.h $(incdir)/missing.h \
- $(incdir)/alloc.h $(incdir)/error.h $(srcdir)/logging.h \
- $(incdir)/sudo_plugin.h $(incdir)/gettext.h
- $(LIBTOOL) --mode=compile $(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/plugin_error.c
-plugin_error.o: plugin_error.lo
policy.lo: $(srcdir)/policy.c $(top_builddir)/config.h $(srcdir)/sudoers.h \
$(top_srcdir)/compat/stdbool.h $(top_builddir)/pathnames.h \
$(incdir)/missing.h $(incdir)/error.h $(incdir)/alloc.h \
}
return res ? true : false;
}
+
+static int warning_locale;
+
+void
+warning_set_locale(void)
+{
+ sudoers_setlocale(SUDOERS_LOCALE_USER, &warning_locale);
+}
+
+void
+warning_restore_locale(void)
+{
+ sudoers_setlocale(warning_locale, NULL);
+}
va_end(ap);
/* Exit the plugin. */
- sudoers_cleanup(0);
+ sudoers_cleanup();
sudo_debug_exit(__func__, __FILE__, __LINE__, sudo_debug_subsys);
plugin_longjmp(1);
}
user_cmnd = "kill";
if (plugin_setjmp() == 0) {
remove_timestamp(remove);
- sudoers_cleanup(0);
+ sudoers_cleanup();
}
plugin_clearjmp();
sudo_setpwent();
sudo_setgrent();
+ /* Register error/errorx callback. */
+ error_callback_register(sudoers_cleanup);
+
/* Initialize environment functions (including replacements). */
env_init(envp);
return true;
}
-/*
/*
* Callback for sudoers_locale sudoers setting.
*/
* Cleanup hook for error()/errorx()
*/
void
-sudoers_cleanup(int gotsignal)
+sudoers_cleanup(void)
{
struct sudo_nss *nss;
+ debug_decl(sudoers_cleanup, SUDO_DEBUG_PLUGIN)
- if (!gotsignal) {
- debug_decl(sudoers_cleanup, SUDO_DEBUG_PLUGIN)
- if (snl != NULL) {
- tq_foreach_fwd(snl, nss)
- nss->close(nss);
- }
- if (def_group_plugin)
- group_plugin_unload();
- sudo_endpwent();
- sudo_endgrent();
- debug_return;
+ if (snl != NULL) {
+ tq_foreach_fwd(snl, nss)
+ nss->close(nss);
}
+ if (def_group_plugin)
+ group_plugin_unload();
+ sudo_endpwent();
+ sudo_endgrent();
+
+ debug_return;
}
static char *
FILE *open_sudoers(const char *, bool, bool *);
int sudoers_policy_init(void *info, char * const envp[]);
int sudoers_policy_main(int argc, char * const argv[], int pwflag, char *env_add[], void *closure);
-void sudoers_cleanup(int);
+void sudoers_cleanup(void);
/* policy.c */
int sudoers_policy_deserialize_info(void *v, char **runas_user, char **runas_group);
extern int term_raw(int, int);
extern int term_restore(int, int);
extern void get_ttysize(int *rowp, int *colp);
-void sudoers_cleanup(int);
static int list_sessions(int, char **, const char *, const char *, const char *);
static int parse_expr(struct search_node **, char **);
static struct log_info *parse_logfile(char *logfile);
static void free_log_info(struct log_info *li);
static size_t atomic_writev(int fd, struct iovec *iov, int iovcnt);
+static void sudoreplay_handler(int);
+static void sudoreplay_cleanup(void);
#ifdef HAVE_REGCOMP
# define REGEX_T regex_t
bindtextdomain("sudoers", LOCALEDIR); /* XXX - should have sudoreplay domain */
textdomain("sudoers");
+ /* Register error/errorx callback. */
+ error_callback_register(sudoreplay_cleanup);
+
/* Read sudo.conf. */
sudo_conf_read();
memset(&sa, 0, sizeof(sa));
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_RESETHAND;
- sa.sa_handler = sudoers_cleanup;
+ sa.sa_handler = sudoreplay_handler;
(void) sigaction(SIGINT, &sa, NULL);
(void) sigaction(SIGKILL, &sa, NULL);
(void) sigaction(SIGTERM, &sa, NULL);
/*
* Cleanup hook for error()/errorx()
*/
-void
-sudoers_cleanup(int signo)
+static void
+sudoreplay_cleanup(void)
+{
+ term_restore(STDIN_FILENO, 0);
+}
+
+/*
+ * Signal handler for SIGINT, SIGKILL, SIGTERM, SIGHUP
+ * Must be installed with SA_RESETHAND enabled.
+ */
+static void
+sudoreplay_handler(int signo)
{
term_restore(STDIN_FILENO, 0);
- if (signo)
- kill(getpid(), signo);
+ kill(getpid(), signo);
}
void print_privilege(struct privilege *);
void print_userspecs(void);
void usage(void) __attribute__((__noreturn__));
-void sudoers_cleanup(int);
static void set_runaspw(const char *);
static void set_runasgr(const char *);
static int cb_runas_default(const char *);
{
}
-void
-sudoers_cleanup(int gotsignal)
-{
- if (!gotsignal) {
- sudo_endpwent();
- sudo_endgrent();
- }
-}
-
void
print_member(struct member *m)
{
#include <sys/stat.h>
#include <sys/socket.h>
#include <sys/time.h>
+#include <sys/uio.h>
#ifndef __TANDEM
# include <sys/file.h>
#endif
static void setup_signals(void);
static void help(void) __attribute__((__noreturn__));
static void usage(int);
-
-void sudoers_cleanup(int);
+static void visudo_cleanup(void);
extern void sudoerserror(const char *);
extern void sudoersrestart(FILE *);
if (argc < 1)
usage(1);
+ /* Register error/errorx callback. */
+ error_callback_register(visudo_cleanup);
+
/* Read sudo.conf. */
sudo_conf_read();
case 'Q' : parse_error = false; /* ignore parse error */
break;
case 'x' : /* XXX - should return instead of exiting */
- sudoers_cleanup(0);
+ visudo_cleanup();
sudo_debug_exit_int(__func__, __FILE__,
__LINE__, sudo_debug_subsys, 0);
exit(0);
/*
* Unlink any sudoers temp files that remain.
*/
-void
-sudoers_cleanup(int gotsignal)
+static void
+visudo_cleanup(void)
{
struct sudoersfile *sp;
if (sp->tpath != NULL)
(void) unlink(sp->tpath);
}
- if (!gotsignal) {
- sudo_endpwent();
- sudo_endgrent();
- }
+ sudo_endpwent();
+ sudo_endgrent();
}
/*
static void
quit(int signo)
{
- const char *signame, *myname;
+ struct sudoersfile *sp;
+ struct iovec iov[4];
+
+ tq_foreach_fwd(&sudoerslist, sp) {
+ if (sp->tpath != NULL)
+ (void) unlink(sp->tpath);
+ }
- sudoers_cleanup(signo);
#define emsg " exiting due to signal: "
- myname = getprogname();
- signame = strsignal(signo);
- ignore_result(write(STDERR_FILENO, myname, strlen(myname)));
- ignore_result(write(STDERR_FILENO, emsg, sizeof(emsg) - 1));
- ignore_result(write(STDERR_FILENO, signame, strlen(signame)));
- ignore_result(write(STDERR_FILENO, "\n", 1));
+ iov[0].iov_base = (char *)getprogname();
+ iov[0].iov_len = strlen(iov[0].iov_base);
+ iov[1].iov_base = emsg;
+ iov[1].iov_len = sizeof(emsg) - 1;
+ iov[2].iov_base = strsignal(signo);
+ iov[2].iov_len = strlen(iov[2].iov_base);
+ iov[3].iov_base = "\n";
+ iov[3].iov_len = 1;
+ ignore_result(writev(STDERR_FILENO, iov, 4));
_exit(signo);
}
PROGS = @PROGS@
-OBJS = conversation.o env_hooks.o error.o exec.o exec_common.o exec_pty.o \
- get_pty.o hooks.o net_ifs.o load_plugins.o parse_args.o sudo.o \
- sudo_edit.o tgetpass.o ttyname.o utmp.o @SUDO_OBJS@
+OBJS = conversation.o env_hooks.o exec.o exec_common.o exec_pty.o get_pty.o \
+ hooks.o net_ifs.o load_plugins.o parse_args.o sudo.o sudo_edit.o \
+ tgetpass.o ttyname.o utmp.o @SUDO_OBJS@
LIBOBJDIR = $(top_builddir)/@ac_config_libobj_dir@/
libsudo_noexec.la: sudo_noexec.lo
$(LIBTOOL) --mode=link $(CC) $(LDFLAGS) $(LT_LDFLAGS) -o $@ sudo_noexec.lo -avoid-version -rpath $(noexecdir)
-sesh: sesh.o error.o exec_common.o @LIBINTL@ $(LT_LIBS)
- $(LIBTOOL) --mode=link $(CC) -o $@ sesh.o error.o exec_common.o $(LDFLAGS) $(PIE_LDFLAGS) @LIBINTL@ $(LIBS)
+sesh: sesh.o locale_stub.o exec_common.o @LIBINTL@ $(LT_LIBS)
+ $(LIBTOOL) --mode=link $(CC) -o $@ sesh.o locale_stub.o exec_common.o $(LDFLAGS) $(PIE_LDFLAGS) @LIBINTL@ $(LIBS)
pre-install:
$(incdir)/list.h $(incdir)/sudo_debug.h $(incdir)/gettext.h \
$(incdir)/sudo_plugin.h
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/env_hooks.c
-error.o: $(srcdir)/error.c $(top_builddir)/config.h $(incdir)/missing.h \
- $(incdir)/error.h $(incdir)/gettext.h
- $(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/error.c
exec.o: $(srcdir)/exec.c $(top_builddir)/config.h $(srcdir)/sudo.h \
$(top_builddir)/pathnames.h $(top_srcdir)/compat/stdbool.h \
$(incdir)/missing.h $(incdir)/alloc.h $(incdir)/error.h \
$(incdir)/sudo_plugin.h $(srcdir)/sudo_plugin_int.h \
$(incdir)/sudo_conf.h $(incdir)/list.h $(incdir)/sudo_debug.h
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/load_plugins.c
+locale_stub.o: $(srcdir)/locale_stub.c $(top_builddir)/config.h \
+ $(incdir)/missing.h $(incdir)/error.h
+ $(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/locale_stub.c
net_ifs.o: $(srcdir)/net_ifs.c $(top_builddir)/config.h $(incdir)/missing.h \
$(incdir)/alloc.h $(incdir)/error.h $(incdir)/sudo_debug.h \
$(incdir)/gettext.h
+++ /dev/null
-/*
- * Copyright (c) 2004-2005, 2010-2012 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
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <config.h>
-
-#include <sys/types.h>
-
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include "missing.h"
-#include "error.h"
-
-#define DEFAULT_TEXT_DOMAIN "sudo"
-#include "gettext.h"
-
-static void _warning(int, const char *, va_list);
- void cleanup(int);
-
-void
-error2(int eval, const char *fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
- _warning(1, fmt, ap);
- va_end(ap);
- cleanup(0);
- exit(eval);
-}
-
-void
-errorx2(int eval, const char *fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
- _warning(0, fmt, ap);
- va_end(ap);
- cleanup(0);
- exit(eval);
-}
-
-void
-verror2(int eval, const char *fmt, va_list ap)
-{
- _warning(1, fmt, ap);
- cleanup(0);
- exit(eval);
-}
-
-void
-verrorx2(int eval, const char *fmt, va_list ap)
-{
- _warning(0, fmt, ap);
- cleanup(0);
- exit(eval);
-}
-
-void
-warning2(const char *fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
- _warning(1, fmt, ap);
- va_end(ap);
-}
-
-void
-warningx2(const char *fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
- _warning(0, fmt, ap);
- va_end(ap);
-}
-
-void
-vwarning2(const char *fmt, va_list ap)
-{
- _warning(1, fmt, ap);
-}
-
-void
-vwarningx2(const char *fmt, va_list ap)
-{
- _warning(0, fmt, ap);
-}
-
-static void
-_warning(int use_errno, const char *fmt, va_list ap)
-{
- int serrno = errno;
-
- fputs(getprogname(), stderr);
- if (fmt != NULL) {
- fputs(_(": "), stderr);
- vfprintf(stderr, fmt, ap);
- }
- if (use_errno) {
- fputs(_(": "), stderr);
- fputs(strerror(serrno), stderr);
- }
- putc('\n', stderr);
-}
-
-/* No need to swap locales in the front end. */
-void
-warning_set_locale(void)
-{
- return;
-}
-
-void
-warning_restore_locale(void)
-{
- return;
-}
/*
* Cleanup hook for error()/errorx()
*/
-void
-cleanup(int gotsignal)
+static void
+pty_cleanup(void)
{
debug_decl(cleanup, SUDO_DEBUG_EXEC);
pid_t self = getpid();
debug_decl(exec_pty, SUDO_DEBUG_EXEC);
+ /* Register cleanup function */
+ error_callback_register(pty_cleanup);
+
/* Set command process group here too to avoid a race. */
setpgid(0, self);
--- /dev/null
+/*
+ * Copyright (c) 2012 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
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <config.h>
+
+#include <sys/types.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "missing.h"
+#include "error.h"
+
+/* No need to swap locales in the front end. */
+void
+warning_set_locale(void)
+{
+ return;
+}
+
+void
+warning_restore_locale(void)
+{
+ return;
+}
__dso_public int main(int argc, char *argv[], char *envp[]);
-/*
- * Cleanup hook for error()/errorx()
- */
-void
-cleanup(int gotsignal)
-{
- return;
-}
-
int
main(int argc, char *argv[], char *envp[])
{