From 39acd2fcba1770b4f765744264be7393648259fd Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Thu, 18 Apr 2013 14:07:59 -0400 Subject: [PATCH] Rename error/errorx -> fatal/fatalx and remove the exit value as it was always 1. --- common/aix.c | 8 +- common/alloc.c | 36 ++++---- common/error.c | 40 ++++----- include/error.h | 84 +++++++++---------- plugins/sudoers/bsm_audit.c | 42 +++++----- plugins/sudoers/env.c | 10 +-- plugins/sudoers/find_path.c | 6 +- plugins/sudoers/hexchar.c | 2 +- plugins/sudoers/iolog.c | 16 ++-- plugins/sudoers/ldap.c | 8 +- plugins/sudoers/linux_audit.c | 4 +- plugins/sudoers/logging.c | 6 +- plugins/sudoers/policy.c | 24 +++--- plugins/sudoers/prompt.c | 2 +- plugins/sudoers/pwutil.c | 14 ++-- .../regress/check_symbols/check_symbols.c | 4 +- .../regress/iolog_path/check_iolog_path.c | 4 +- plugins/sudoers/regress/logging/check_wrap.c | 2 +- plugins/sudoers/regress/parser/check_addr.c | 2 +- plugins/sudoers/sudoers.c | 14 ++-- plugins/sudoers/sudoreplay.c | 54 ++++++------ plugins/sudoers/testsudoers.c | 10 +-- plugins/sudoers/timestamp.c | 2 +- plugins/sudoers/visudo.c | 34 ++++---- src/exec.c | 6 +- src/exec_common.c | 2 +- src/exec_pty.c | 24 +++--- src/net_ifs.c | 2 +- src/parse_args.c | 6 +- src/selinux.c | 2 +- src/signal.c | 2 +- src/sudo.c | 40 ++++----- src/sudo_edit.c | 16 ++-- src/tgetpass.c | 6 +- src/utmp.c | 6 +- 35 files changed, 270 insertions(+), 270 deletions(-) diff --git a/common/aix.c b/common/aix.c index 2af2694f9..cc9ca7cc4 100644 --- a/common/aix.c +++ b/common/aix.c @@ -90,7 +90,7 @@ aix_setlimits(char *user) debug_decl(aix_setlimits, SUDO_DEBUG_UTIL) if (setuserdb(S_READ) != 0) - error(1, "unable to open userdb"); + fatal("unable to open userdb"); /* * For each resource limit, get the soft/hard values for the user @@ -147,10 +147,10 @@ aix_setauthdb(char *user) if (user != NULL) { if (setuserdb(S_READ) != 0) - error(1, _("unable to open userdb")); + fatal(_("unable to open userdb")); if (getuserattr(user, S_REGISTRY, ®istry, SEC_CHAR) == 0) { if (setauthdb(registry, NULL) != 0) - error(1, _("unable to switch to registry \"%s\" for %s"), + fatal(_("unable to switch to registry \"%s\" for %s"), registry, user); } enduserdb(); @@ -167,7 +167,7 @@ aix_restoreauthdb(void) debug_decl(aix_setauthdb, SUDO_DEBUG_UTIL) if (setauthdb(NULL, NULL) != 0) - error(1, _("unable to restore registry")); + fatal(_("unable to restore registry")); debug_return; } diff --git a/common/alloc.c b/common/alloc.c index e69c367bd..765048390 100644 --- a/common/alloc.c +++ b/common/alloc.c @@ -79,10 +79,10 @@ emalloc(size_t size) void *ptr; if (size == 0) - errorx_nodebug(1, _("internal error, tried to emalloc(0)")); + fatalx_nodebug(_("internal error, tried to emalloc(0)")); if ((ptr = malloc(size)) == NULL) - errorx_nodebug(1, NULL); + fatalx_nodebug(NULL); return ptr; } @@ -96,13 +96,13 @@ emalloc2(size_t nmemb, size_t size) void *ptr; if (nmemb == 0 || size == 0) - errorx_nodebug(1, _("internal error, tried to emalloc2(0)")); + fatalx_nodebug(_("internal error, tried to emalloc2(0)")); if (nmemb > SIZE_MAX / size) - errorx_nodebug(1, _("internal error, %s overflow"), "emalloc2()"); + fatalx_nodebug(_("internal error, %s overflow"), "emalloc2()"); size *= nmemb; if ((ptr = malloc(size)) == NULL) - errorx_nodebug(1, NULL); + fatalx_nodebug(NULL); return ptr; } @@ -117,14 +117,14 @@ ecalloc(size_t nmemb, size_t size) void *ptr; if (nmemb == 0 || size == 0) - errorx_nodebug(1, _("internal error, tried to ecalloc(0)")); + fatalx_nodebug(_("internal error, tried to ecalloc(0)")); if (nmemb != 1) { if (nmemb > SIZE_MAX / size) - errorx_nodebug(1, _("internal error, %s overflow"), "ecalloc()"); + fatalx_nodebug(_("internal error, %s overflow"), "ecalloc()"); size *= nmemb; } if ((ptr = malloc(size)) == NULL) - errorx_nodebug(1, NULL); + fatalx_nodebug(NULL); memset(ptr, 0, size); return ptr; } @@ -139,11 +139,11 @@ erealloc(void *ptr, size_t size) { if (size == 0) - errorx_nodebug(1, _("internal error, tried to erealloc(0)")); + fatalx_nodebug(_("internal error, tried to erealloc(0)")); ptr = ptr ? realloc(ptr, size) : malloc(size); if (ptr == NULL) - errorx_nodebug(1, NULL); + fatalx_nodebug(NULL); return ptr; } @@ -158,14 +158,14 @@ erealloc3(void *ptr, size_t nmemb, size_t size) { if (nmemb == 0 || size == 0) - errorx_nodebug(1, _("internal error, tried to erealloc3(0)")); + fatalx_nodebug(_("internal error, tried to erealloc3(0)")); if (nmemb > SIZE_MAX / size) - errorx_nodebug(1, _("internal error, %s overflow"), "erealloc3()"); + fatalx_nodebug(_("internal error, %s overflow"), "erealloc3()"); size *= nmemb; ptr = ptr ? realloc(ptr, size) : malloc(size); if (ptr == NULL) - errorx_nodebug(1, NULL); + fatalx_nodebug(NULL); return ptr; } @@ -182,14 +182,14 @@ erecalloc(void *ptr, size_t onmemb, size_t nmemb, size_t msize) size_t size; if (nmemb == 0 || msize == 0) - errorx_nodebug(1, _("internal error, tried to erecalloc(0)")); + fatalx_nodebug(_("internal error, tried to erecalloc(0)")); if (nmemb > SIZE_MAX / msize) - errorx_nodebug(1, _("internal error, %s overflow"), "erecalloc()"); + fatalx_nodebug(_("internal error, %s overflow"), "erecalloc()"); size = nmemb * msize; ptr = ptr ? realloc(ptr, size) : malloc(size); if (ptr == NULL) - errorx_nodebug(1, NULL); + fatalx_nodebug(NULL); if (nmemb > onmemb) { size = (nmemb - onmemb) * msize; memset((char *)ptr + (onmemb * msize), 0, size); @@ -254,7 +254,7 @@ easprintf(char **ret, const char *fmt, ...) va_end(ap); if (len == -1) - errorx_nodebug(1, NULL); + fatalx_nodebug(NULL); return len; } @@ -268,6 +268,6 @@ evasprintf(char **ret, const char *format, va_list args) int len; if ((len = vasprintf(ret, format, args)) == -1) - errorx_nodebug(1, NULL); + fatalx_nodebug(NULL); return len; } diff --git a/common/error.c b/common/error.c index 6bf9fcbc3..ad9b7dddb 100644 --- a/common/error.c +++ b/common/error.c @@ -36,11 +36,11 @@ #define DEFAULT_TEXT_DOMAIN "sudo" #include "gettext.h" -sigjmp_buf error_jmp; +sigjmp_buf fatal_jmp; static bool setjmp_enabled = false; -static struct sudo_error_callback { +static struct sudo_fatal_callback { void (*func)(void); - struct sudo_error_callback *next; + struct sudo_fatal_callback *next; } *callbacks; static void _warning(int, const char *, va_list); @@ -48,7 +48,7 @@ static void _warning(int, const char *, va_list); static void do_cleanup(void) { - struct sudo_error_callback *cb; + struct sudo_fatal_callback *cb; /* Run callbacks, removing them from the list as we go. */ while ((cb = callbacks) != NULL) { @@ -59,7 +59,7 @@ do_cleanup(void) } void -error2(int eval, const char *fmt, ...) +fatal2(const char *fmt, ...) { va_list ap; @@ -68,13 +68,13 @@ error2(int eval, const char *fmt, ...) va_end(ap); do_cleanup(); if (setjmp_enabled) - siglongjmp(error_jmp, eval); + siglongjmp(fatal_jmp, 1); else - exit(eval); + exit(1); } void -errorx2(int eval, const char *fmt, ...) +fatalx2(const char *fmt, ...) { va_list ap; @@ -83,31 +83,31 @@ errorx2(int eval, const char *fmt, ...) va_end(ap); do_cleanup(); if (setjmp_enabled) - siglongjmp(error_jmp, eval); + siglongjmp(fatal_jmp, 1); else - exit(eval); + exit(1); } void -verror2(int eval, const char *fmt, va_list ap) +vfatal2(const char *fmt, va_list ap) { _warning(1, fmt, ap); do_cleanup(); if (setjmp_enabled) - siglongjmp(error_jmp, eval); + siglongjmp(fatal_jmp, 1); else - exit(eval); + exit(1); } void -verrorx2(int eval, const char *fmt, va_list ap) +vfatalx2(const char *fmt, va_list ap) { _warning(0, fmt, ap); do_cleanup(); if (setjmp_enabled) - siglongjmp(error_jmp, eval); + siglongjmp(fatal_jmp, 1); else - exit(eval); + exit(1); } void @@ -165,9 +165,9 @@ _warning(int use_errno, const char *fmt, va_list ap) } int -error_callback_register(void (*func)(void)) +fatal_callback_register(void (*func)(void)) { - struct sudo_error_callback *cb; + struct sudo_fatal_callback *cb; cb = malloc(sizeof(*cb)); if (cb == NULL) @@ -180,13 +180,13 @@ error_callback_register(void (*func)(void)) } void -error_disable_setjmp(void) +fatal_disable_setjmp(void) { setjmp_enabled = false; } void -error_enable_setjmp(void) +fatal_enable_setjmp(void) { setjmp_enabled = true; } diff --git a/include/error.h b/include/error.h index 88360f84c..bbdc9e213 100644 --- a/include/error.h +++ b/include/error.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2010-2012 Todd C. Miller + * Copyright (c) 2004, 2010-2013 Todd C. Miller * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above @@ -21,37 +21,37 @@ #include /* - * We wrap error/errorx and warn/warnx so that the same output can + * We wrap fatal/fatalx and warning/warningx so that the same output can * go to the debug file, if there is one. */ #if defined(SUDO_ERROR_WRAP) && SUDO_ERROR_WRAP == 0 # if defined(__GNUC__) && __GNUC__ == 2 -# define error(rval, fmt...) error_nodebug((rval), fmt) -# define errorx(rval, fmt...) errorx_nodebug((rval), fmt) +# define fatal(fmt...) fatal_nodebug(fmt) +# define fatalx(fmt...) fatalx_nodebug(fmt) # define warning(fmt...) warning_nodebug(fmt) # define warningx(fmt...) warningx_nodebug(fmt) # else -# define error(rval, ...) error_nodebug((rval), __VA_ARGS__) -# define errorx(rval, ...) errorx_nodebug((rval), __VA_ARGS__) +# define fatal(...) fatal_nodebug(__VA_ARGS__) +# define fatalx(...) fatalx_nodebug(__VA_ARGS__) # define warning(...) warning_nodebug(__VA_ARGS__) # define warningx(...) warningx_nodebug(__VA_ARGS__) # endif /* __GNUC__ == 2 */ -# define verror(rval, fmt, ap) error_nodebug((rval), (fmt), (ap)) -# define verrorx(rval, fmt, ap) errorx_nodebug((rval), (fmt), (ap)) +# define vfatal(fmt, ap) fatal_nodebug((fmt), (ap)) +# define vfatalx(fmt, ap) fatalx_nodebug((fmt), (ap)) # define vwarning(fmt, ap) warning_nodebug((fmt), (ap)) # define vwarningx(fmt, ap) warningx_nodebug((fmt), (ap)) #else /* SUDO_ERROR_WRAP */ # if defined(__GNUC__) && __GNUC__ == 2 -# define error(rval, fmt...) do { \ +# define fatal(fmt...) do { \ sudo_debug_printf2(__func__, __FILE__, __LINE__, \ SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO|SUDO_DEBUG_ERRNO|sudo_debug_subsys, \ fmt); \ - error_nodebug((rval), fmt); \ + fatal_nodebug(fmt); \ } while (0) -# define errorx(rval, fmt...) do { \ +# define fatalx(fmt...) do { \ sudo_debug_printf2(__func__, __FILE__, __LINE__, \ SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO|sudo_debug_subsys, fmt); \ - errorx_nodebug((rval), fmt); \ + fatalx_nodebug(fmt); \ } while (0) # define warning(fmt...) do { \ sudo_debug_printf2(__func__, __FILE__, __LINE__, \ @@ -65,16 +65,16 @@ warningx_nodebug(fmt); \ } while (0) # else -# define error(rval, ...) do { \ +# define fatal(...) do { \ sudo_debug_printf2(__func__, __FILE__, __LINE__, \ SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO|SUDO_DEBUG_ERRNO|sudo_debug_subsys, \ __VA_ARGS__); \ - error_nodebug((rval), __VA_ARGS__); \ + fatal_nodebug(__VA_ARGS__); \ } while (0) -# define errorx(rval, ...) do { \ +# define fatalx(...) do { \ sudo_debug_printf2(__func__, __FILE__, __LINE__, \ SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO|sudo_debug_subsys, __VA_ARGS__); \ - errorx_nodebug((rval), __VA_ARGS__); \ + fatalx_nodebug(__VA_ARGS__); \ } while (0) # define warning(...) do { \ sudo_debug_printf2(__func__, __FILE__, __LINE__, \ @@ -88,16 +88,16 @@ warningx_nodebug(__VA_ARGS__); \ } while (0) # endif /* __GNUC__ == 2 */ -# define verror(rval, fmt, ap) do { \ +# define vfatal(fmt, ap) do { \ sudo_debug_vprintf2(__func__, __FILE__, __LINE__, \ SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO|SUDO_DEBUG_ERRNO|sudo_debug_subsys, \ (fmt), (ap)); \ - verror_nodebug((rval), (fmt), (ap)); \ + vfatal_nodebug((fmt), (ap)); \ } while (0) -# define verrorx(rval, fmt, ap) do { \ +# define vfatalx(fmt, ap) do { \ sudo_debug_vprintf2(__func__, __FILE__, __LINE__, \ SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO|sudo_debug_subsys, (fmt), (ap)); \ - verrorx_nodebug((rval), (fmt), (ap)); \ + vfatalx_nodebug((fmt), (ap)); \ } while (0) # define vwarning(fmt, ap) do { \ sudo_debug_vprintf2(__func__, __FILE__, __LINE__, \ @@ -114,13 +114,13 @@ #endif /* SUDO_ERROR_WRAP */ #if defined(__GNUC__) && __GNUC__ == 2 -# define error_nodebug(rval, fmt...) do { \ +# define fatal_nodebug(fmt...) do { \ warning_set_locale(); \ - error2((rval), fmt); \ + fatal2(fmt); \ } while (0) -# define errorx_nodebug(rval, fmt...) do { \ +# define fatalx_nodebug(fmt...) do { \ warning_set_locale(); \ - errorx2((rval), fmt); \ + fatalx2(fmt); \ } while (0) # define warning_nodebug(fmt...) do { \ warning_set_locale(); \ @@ -133,13 +133,13 @@ warning_restore_locale(); \ } while (0) #else -# define error_nodebug(rval, ...) do { \ +# define fatal_nodebug(...) do { \ warning_set_locale(); \ - error2((rval), __VA_ARGS__); \ + fatal2(__VA_ARGS__); \ } while (0) -# define errorx_nodebug(rval, ...) do { \ +# define fatalx_nodebug(...) do { \ warning_set_locale(); \ - errorx2((rval), __VA_ARGS__); \ + fatalx2(__VA_ARGS__); \ } while (0) # define warning_nodebug(...) do { \ warning_set_locale(); \ @@ -152,13 +152,13 @@ warning_restore_locale(); \ } while (0) #endif /* __GNUC__ == 2 */ -#define verror_nodebug(rval, fmt, ap) do { \ +#define vfatal_nodebug(fmt, ap) do { \ warning_set_locale(); \ - verror2((rval), (fmt), (ap)); \ + vfatal2((fmt), (ap)); \ } while (0) -#define verrorx_nodebug(rval, fmt, ap) do { \ +#define vfatalx_nodebug(fmt, ap) do { \ warning_set_locale(); \ - verrorx2((rval), (fmt), (ap)); \ + vfatalx2((fmt), (ap)); \ } while (0) #define vwarning_nodebug(fmt, ap) do { \ warning_set_locale(); \ @@ -171,19 +171,19 @@ warning_restore_locale(); \ } while (0) -#define error_setjmp() (error_enable_setjmp(), sigsetjmp(error_jmp, 1)) -#define error_longjmp(val) siglongjmp(error_jmp, val) +#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 error_jmp; +extern sigjmp_buf fatal_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__)); -void verrorx2(int, const char *, va_list ap) __attribute__((__noreturn__)); +int fatal_callback_register(void (*func)(void)); +void fatal_disable_setjmp(void); +void fatal_enable_setjmp(void); +void fatal2(const char *, ...) __printflike(1, 2) __attribute__((__noreturn__)); +void fatalx2(const char *, ...) __printflike(1, 2) __attribute__((__noreturn__)); +void vfatal2(const char *, va_list ap) __attribute__((__noreturn__)); +void vfatalx2(const char *, va_list ap) __attribute__((__noreturn__)); void warning2(const char *, ...) __printflike(1, 2); void warningx2(const char *, ...) __printflike(1, 2); void vwarning2(const char *, va_list ap); diff --git a/plugins/sudoers/bsm_audit.c b/plugins/sudoers/bsm_audit.c index a7111b0ec..86c4005f1 100644 --- a/plugins/sudoers/bsm_audit.c +++ b/plugins/sudoers/bsm_audit.c @@ -57,10 +57,10 @@ audit_sudo_selected(int sf) if (getaudit_addr(&ainfo_addr, sizeof(ainfo_addr)) < 0) { if (errno == ENOSYS) { if (getaudit(&ainfo) < 0) - error(1, _("getaudit: failed")); + fatal(_("getaudit: failed")); mask = &ainfo.ai_mask; } else - error(1, _("getaudit: failed")); + fatal(_("getaudit: failed")); } else mask = &ainfo_addr.ai_mask; sorf = (sf == 0) ? AU_PRS_SUCCESS : AU_PRS_FAILURE; @@ -87,7 +87,7 @@ bsm_audit_success(char **exec_args) if (auditon(A_GETCOND, (caddr_t)&au_cond, sizeof(long)) < 0) { if (errno == AUDIT_NOT_CONFIGURED) return; - error(1, _("Could not determine audit condition")); + fatal(_("Could not determine audit condition")); } if (au_cond == AUC_NOAUDIT) debug_return; @@ -98,9 +98,9 @@ bsm_audit_success(char **exec_args) if (!audit_sudo_selected(0)) debug_return; if (getauid(&auid) < 0) - error(1, _("getauid: failed")); + fatal(_("getauid: failed")); if ((aufd = au_open()) == -1) - error(1, _("au_open: failed")); + fatal(_("au_open: failed")); if (getaudit_addr(&ainfo_addr, sizeof(ainfo_addr)) == 0) { tok = au_to_subject_ex(auid, geteuid(), getegid(), getuid(), getuid(), pid, pid, &ainfo_addr.ai_termid); @@ -109,24 +109,24 @@ bsm_audit_success(char **exec_args) * NB: We should probably watch out for ERANGE here. */ if (getaudit(&ainfo) < 0) - error(1, _("getaudit: failed")); + fatal(_("getaudit: failed")); tok = au_to_subject(auid, geteuid(), getegid(), getuid(), getuid(), pid, pid, &ainfo.ai_termid); } else - error(1, _("getaudit: failed")); + fatal(_("getaudit: failed")); if (tok == NULL) - error(1, _("au_to_subject: failed")); + fatal(_("au_to_subject: failed")); au_write(aufd, tok); tok = au_to_exec_args(exec_args); if (tok == NULL) - error(1, _("au_to_exec_args: failed")); + fatal(_("au_to_exec_args: failed")); au_write(aufd, tok); tok = au_to_return32(0, 0); if (tok == NULL) - error(1, _("au_to_return32: failed")); + fatal(_("au_to_return32: failed")); au_write(aufd, tok); if (au_close(aufd, 1, AUE_sudo) == -1) - error(1, _("unable to commit audit record")); + fatal(_("unable to commit audit record")); debug_return; } @@ -150,43 +150,43 @@ bsm_audit_failure(char **exec_args, char const *const fmt, va_list ap) if (auditon(A_GETCOND, &au_cond, sizeof(long)) < 0) { if (errno == AUDIT_NOT_CONFIGURED) debug_return; - error(1, _("Could not determine audit condition")); + fatal(_("Could not determine audit condition")); } if (au_cond == AUC_NOAUDIT) debug_return; if (!audit_sudo_selected(1)) debug_return; if (getauid(&auid) < 0) - error(1, _("getauid: failed")); + fatal(_("getauid: failed")); if ((aufd = au_open()) == -1) - error(1, _("au_open: failed")); + fatal(_("au_open: failed")); if (getaudit_addr(&ainfo_addr, sizeof(ainfo_addr)) == 0) { tok = au_to_subject_ex(auid, geteuid(), getegid(), getuid(), getuid(), pid, pid, &ainfo_addr.ai_termid); } else if (errno == ENOSYS) { if (getaudit(&ainfo) < 0) - error(1, _("getaudit: failed")); + fatal(_("getaudit: failed")); tok = au_to_subject(auid, geteuid(), getegid(), getuid(), getuid(), pid, pid, &ainfo.ai_termid); } else - error(1, _("getaudit: failed")); + fatal(_("getaudit: failed")); if (tok == NULL) - error(1, _("au_to_subject: failed")); + fatal(_("au_to_subject: failed")); au_write(aufd, tok); tok = au_to_exec_args(exec_args); if (tok == NULL) - error(1, _("au_to_exec_args: failed")); + fatal(_("au_to_exec_args: failed")); au_write(aufd, tok); (void) vsnprintf(text, sizeof(text), fmt, ap); tok = au_to_text(text); if (tok == NULL) - error(1, _("au_to_text: failed")); + fatal(_("au_to_text: failed")); au_write(aufd, tok); tok = au_to_return32(EPERM, 1); if (tok == NULL) - error(1, _("au_to_return32: failed")); + fatal(_("au_to_return32: failed")); au_write(aufd, tok); if (au_close(aufd, 1, AUE_sudo) == -1) - error(1, _("unable to commit audit record")); + fatal(_("unable to commit audit record")); debug_return; } diff --git a/plugins/sudoers/env.c b/plugins/sudoers/env.c index 4e2eb12b9..acca9af56 100644 --- a/plugins/sudoers/env.c +++ b/plugins/sudoers/env.c @@ -285,12 +285,12 @@ sudo_putenv_nodebug(char *str, bool dupcheck, bool overwrite) size_t nsize; if (env.env_size > SIZE_MAX - 128) { - errorx_nodebug(1, _("internal error, %s overflow"), + fatalx_nodebug(_("internal error, %s overflow"), "sudo_putenv_nodebug()"); } nsize = env.env_size + 128; if (nsize > SIZE_MAX / sizeof(char *)) { - errorx_nodebug(1, _("internal error, %s overflow"), + fatalx_nodebug(_("internal error, %s overflow"), "sudo_putenv_nodebug()"); } nenvp = realloc(env.envp, nsize * sizeof(char *)); @@ -364,9 +364,9 @@ sudo_putenv(char *str, bool dupcheck, bool overwrite) if (rval == -1) { #ifdef ENV_DEBUG if (env.envp[env.env_len] != NULL) - errorx(1, _("sudo_putenv: corrupted envp, length mismatch")); + fatalx(_("sudo_putenv: corrupted envp, length mismatch")); #endif - errorx(1, NULL); + fatalx(NULL); } debug_return_int(rval); } @@ -392,7 +392,7 @@ sudo_setenv2(const char *var, const char *val, bool dupcheck, bool overwrite) strlcat(estring, "=", esize) >= esize || strlcat(estring, val, esize) >= esize) { - errorx(1, _("internal error, %s overflow"), "sudo_setenv2()"); + fatalx(_("internal error, %s overflow"), "sudo_setenv2()"); } rval = sudo_putenv(estring, dupcheck, overwrite); if (rval == -1) diff --git a/plugins/sudoers/find_path.c b/plugins/sudoers/find_path.c index a8a85d3f9..14264b06d 100644 --- a/plugins/sudoers/find_path.c +++ b/plugins/sudoers/find_path.c @@ -66,7 +66,7 @@ find_path(char *infile, char **outfile, struct stat *sbp, char *path, if (strlen(infile) >= PATH_MAX) { errno = ENAMETOOLONG; - error(1, "%s", infile); + fatal("%s", infile); } /* @@ -107,7 +107,7 @@ find_path(char *infile, char **outfile, struct stat *sbp, char *path, len = snprintf(command, sizeof(command), "%s/%s", path, infile); if (len <= 0 || len >= sizeof(command)) { errno = ENAMETOOLONG; - error(1, "%s", infile); + fatal("%s", infile); } if ((found = sudo_goodpath(command, sbp))) break; @@ -124,7 +124,7 @@ find_path(char *infile, char **outfile, struct stat *sbp, char *path, len = snprintf(command, sizeof(command), "./%s", infile); if (len <= 0 || len >= sizeof(command)) { errno = ENAMETOOLONG; - error(1, "%s", infile); + fatal("%s", infile); } found = sudo_goodpath(command, sbp); if (found && ignore_dot) diff --git a/plugins/sudoers/hexchar.c b/plugins/sudoers/hexchar.c index bcfe526ac..9f9970d0d 100644 --- a/plugins/sudoers/hexchar.c +++ b/plugins/sudoers/hexchar.c @@ -88,7 +88,7 @@ hexchar(const char *s) break; default: /* Should not happen. */ - errorx(1, "internal error, \\x%s not in proper hex format", s); + fatalx("internal error, \\x%s not in proper hex format", s); } } debug_return_int((result[0] << 4) | result[1]); diff --git a/plugins/sudoers/iolog.c b/plugins/sudoers/iolog.c index 276a23830..8611314e0 100644 --- a/plugins/sudoers/iolog.c +++ b/plugins/sudoers/iolog.c @@ -535,7 +535,7 @@ sudoers_io_open(unsigned int version, sudo_conv_t conversation, memset(&details, 0, sizeof(details)); - if (error_setjmp() != 0) { + if (fatal_setjmp() != 0) { /* called via error(), errorx() or log_fatal() */ rval = -1; goto done; @@ -610,7 +610,7 @@ sudoers_io_open(unsigned int version, sudo_conv_t conversation, rval = true; done: - error_disable_setjmp(); + fatal_disable_setjmp(); efree(tofree); if (details.runas_pw) sudo_pw_delref(details.runas_pw); @@ -628,9 +628,9 @@ sudoers_io_close(int exit_status, int error) int i; debug_decl(sudoers_io_close, SUDO_DEBUG_PLUGIN) - if (error_setjmp() != 0) { + if (fatal_setjmp() != 0) { /* called via error(), errorx() or log_fatal() */ - error_disable_setjmp(); + fatal_disable_setjmp(); debug_return; } @@ -652,9 +652,9 @@ sudoers_io_version(int verbose) { debug_decl(sudoers_io_version, SUDO_DEBUG_PLUGIN) - if (error_setjmp() != 0) { + if (fatal_setjmp() != 0) { /* called via error(), errorx() or log_fatal() */ - error_disable_setjmp(); + fatal_disable_setjmp(); debug_return_bool(-1); } @@ -675,9 +675,9 @@ sudoers_io_log(const char *buf, unsigned int len, int idx) gettimeofday(&now, NULL); - if (error_setjmp() != 0) { + if (fatal_setjmp() != 0) { /* called via error(), errorx() or log_fatal() */ - error_disable_setjmp(); + fatal_disable_setjmp(); debug_return_bool(-1); } diff --git a/plugins/sudoers/ldap.c b/plugins/sudoers/ldap.c index 38de6cb36..c487cdc71 100644 --- a/plugins/sudoers/ldap.c +++ b/plugins/sudoers/ldap.c @@ -382,7 +382,7 @@ sudo_ldap_conf_add_ports(void) hostbuf[0] = '\0'; if (snprintf(defport, sizeof(defport), ":%d", ldap_conf.port) >= sizeof(defport)) - errorx(1, _("sudo_ldap_conf_add_ports: port too large")); + fatalx(_("sudo_ldap_conf_add_ports: port too large")); for ((host = strtok(ldap_conf.host, " \t")); host; (host = strtok(NULL, " \t"))) { if (hostbuf[0] != '\0') { @@ -405,7 +405,7 @@ sudo_ldap_conf_add_ports(void) debug_return; toobig: - errorx(1, _("sudo_ldap_conf_add_ports: out of space expanding hostbuf")); + fatalx(_("sudo_ldap_conf_add_ports: out of space expanding hostbuf")); } #endif @@ -493,7 +493,7 @@ done: debug_return_int(rc); toobig: - errorx(1, _("sudo_ldap_parse_uri: out of space building hostbuf")); + fatalx(_("sudo_ldap_parse_uri: out of space building hostbuf")); } #else static char * @@ -1292,7 +1292,7 @@ sudo_ldap_build_pass1(struct passwd *pw) /* Add ALL to list and end the global OR */ if (strlcat(buf, "(sudoUser=ALL)", sz) >= sz) - errorx(1, _("sudo_ldap_build_pass1 allocation mismatch")); + fatalx(_("sudo_ldap_build_pass1 allocation mismatch")); /* Add the time restriction, or simply end the global OR. */ if (ldap_conf.timed) { diff --git a/plugins/sudoers/linux_audit.c b/plugins/sudoers/linux_audit.c index 9cfd4a7a6..55a041357 100644 --- a/plugins/sudoers/linux_audit.c +++ b/plugins/sudoers/linux_audit.c @@ -54,7 +54,7 @@ static linux_audit_open(void) if (au_fd == -1) { /* Kernel may not have audit support. */ if (errno != EINVAL && errno != EPROTONOSUPPORT && errno != EAFNOSUPPORT) - error(1, _("unable to open audit system")); + fatal(_("unable to open audit system")); } else { (void)fcntl(au_fd, F_SETFD, FD_CLOEXEC); } @@ -79,7 +79,7 @@ linux_audit_command(char *argv[], int result) for (av = argv; *av != NULL; av++) { n = strlcpy(cp, *av, size - (cp - command)); if (n >= size - (cp - command)) { - errorx(1, _("internal error, %s overflow"), + fatalx(_("internal error, %s overflow"), "linux_audit_command()"); } cp += n; diff --git a/plugins/sudoers/logging.c b/plugins/sudoers/logging.c index c8835cab5..b48076c86 100644 --- a/plugins/sudoers/logging.c +++ b/plugins/sudoers/logging.c @@ -526,7 +526,7 @@ log_fatal(int flags, const char *fmt, ...) /* Exit the plugin. */ sudoers_cleanup(); sudo_debug_exit(__func__, __FILE__, __LINE__, sudo_debug_subsys); - error_longjmp(1); + fatal_longjmp(1); } #define MAX_MAILFLAGS 63 @@ -563,7 +563,7 @@ send_mail(const char *fmt, ...) switch (pid = sudo_debug_fork()) { case -1: /* Error. */ - error(1, _("unable to fork")); + fatal(_("unable to fork")); break; case 0: /* Child. */ @@ -896,5 +896,5 @@ new_logline(const char *message, int serrno) debug_return_str(line); toobig: - errorx(1, _("internal error: insufficient space for log line")); + fatalx(_("internal error: insufficient space for log line")); } diff --git a/plugins/sudoers/policy.c b/plugins/sudoers/policy.c index 6876bc237..2e759b432 100644 --- a/plugins/sudoers/policy.c +++ b/plugins/sudoers/policy.c @@ -417,14 +417,14 @@ sudoers_policy_exec_setup(char *argv[], char *envp[], mode_t cmnd_umask, (unsigned int)runas_pw->pw_gid; len = snprintf(cp, glsize - (cp - gid_list), "%u", egid); if (len < 0 || len >= glsize - (cp - gid_list)) - errorx(1, _("internal error, %s overflow"), "runas_groups"); + fatalx(_("internal error, %s overflow"), "runas_groups"); cp += len; for (i = 0; i < grlist->ngids; i++) { if (grlist->gids[i] != egid) { len = snprintf(cp, glsize - (cp - gid_list), ",%u", (unsigned int) grlist->gids[i]); if (len < 0 || len >= glsize - (cp - gid_list)) - errorx(1, _("internal error, %s overflow"), "runas_groups"); + fatalx(_("internal error, %s overflow"), "runas_groups"); cp += len; } } @@ -486,10 +486,10 @@ sudoers_policy_open(unsigned int version, sudo_conv_t conversation, if (sudo_version < SUDO_API_MKVERSION(1, 2)) args = NULL; - if (error_setjmp() != 0) { + if (fatal_setjmp() != 0) { /* called via error(), errorx() or log_fatal() */ rewind_perms(); - error_disable_setjmp(); + fatal_disable_setjmp(); debug_return_bool(-1); } @@ -505,9 +505,9 @@ sudoers_policy_close(int exit_status, int error_code) { debug_decl(sudoers_policy_close, SUDO_DEBUG_PLUGIN) - if (error_setjmp() != 0) { + if (fatal_setjmp() != 0) { /* called via error(), errorx() or log_fatal() */ - error_disable_setjmp(); + fatal_disable_setjmp(); debug_return; } @@ -555,9 +555,9 @@ sudoers_policy_init_session(struct passwd *pwd, char **user_env[]) if (sudo_version < SUDO_API_MKVERSION(1, 2)) user_env = NULL; - if (error_setjmp() != 0) { + if (fatal_setjmp() != 0) { /* called via error(), errorx() or log_fatal() */ - error_disable_setjmp(); + fatal_disable_setjmp(); debug_return_bool(-1); } @@ -606,11 +606,11 @@ sudoers_policy_invalidate(int remove) debug_decl(sudoers_policy_invalidate, SUDO_DEBUG_PLUGIN) user_cmnd = "kill"; - if (error_setjmp() == 0) { + if (fatal_setjmp() == 0) { remove_timestamp(remove); sudoers_cleanup(); } - error_disable_setjmp(); + fatal_disable_setjmp(); debug_return; } @@ -650,9 +650,9 @@ sudoers_policy_version(int verbose) { debug_decl(sudoers_policy_version, SUDO_DEBUG_PLUGIN) - if (error_setjmp() != 0) { + if (fatal_setjmp() != 0) { /* error recovery via error(), errorx() or log_fatal() */ - error_disable_setjmp(); + fatal_disable_setjmp(); debug_return_bool(-1); } diff --git a/plugins/sudoers/prompt.c b/plugins/sudoers/prompt.c index aadedb7c5..5945409bc 100644 --- a/plugins/sudoers/prompt.c +++ b/plugins/sudoers/prompt.c @@ -168,5 +168,5 @@ expand_prompt(const char *old_prompt, const char *user, const char *host) oflow: /* We pre-allocate enough space, so this should never happen. */ - errorx(1, _("internal error, %s overflow"), "expand_prompt()"); + fatalx(_("internal error, %s overflow"), "expand_prompt()"); } diff --git a/plugins/sudoers/pwutil.c b/plugins/sudoers/pwutil.c index fee9791a7..3257106ab 100644 --- a/plugins/sudoers/pwutil.c +++ b/plugins/sudoers/pwutil.c @@ -145,7 +145,7 @@ sudo_getpwuid(uid_t uid) /* item->d.pw = NULL; */ } if (rbinsert(pwcache_byuid, item) != NULL) - errorx(1, _("unable to cache uid %u, already exists"), + fatalx(_("unable to cache uid %u, already exists"), (unsigned int) uid); #ifdef HAVE_SETAUTHDB aix_restoreauthdb(); @@ -187,7 +187,7 @@ sudo_getpwnam(const char *name) /* item->d.pw = NULL; */ } if (rbinsert(pwcache_byname, item) != NULL) - errorx(1, _("unable to cache user %s, already exists"), name); + fatalx(_("unable to cache user %s, already exists"), name); #ifdef HAVE_SETAUTHDB aix_restoreauthdb(); #endif @@ -371,7 +371,7 @@ sudo_getgrgid(gid_t gid) /* item->d.gr = NULL; */ } if (rbinsert(grcache_bygid, item) != NULL) - errorx(1, _("unable to cache gid %u, already exists"), + fatalx(_("unable to cache gid %u, already exists"), (unsigned int) gid); done: item->refcnt++; @@ -407,7 +407,7 @@ sudo_getgrnam(const char *name) /* item->d.gr = NULL; */ } if (rbinsert(grcache_byname, item) != NULL) - errorx(1, _("unable to cache group %s, already exists"), name); + fatalx(_("unable to cache group %s, already exists"), name); done: item->refcnt++; debug_return_ptr(item->d.gr); @@ -561,7 +561,7 @@ sudo_get_grlist(struct passwd *pw) /* item->d.grlist = NULL; */ } if (rbinsert(grlist_cache, item) != NULL) - errorx(1, _("unable to cache group list for %s, already exists"), + fatalx(_("unable to cache group list for %s, already exists"), pw->pw_name); done: item->refcnt++; @@ -581,9 +581,9 @@ sudo_set_grlist(struct passwd *pw, char * const *groups, char * const *gids) key.k.name = pw->pw_name; if ((node = rbfind(grlist_cache, &key)) == NULL) { if ((item = sudo_make_grlist_item(pw, groups, gids)) == NULL) - errorx(1, _("unable to parse groups for %s"), pw->pw_name); + fatalx(_("unable to parse groups for %s"), pw->pw_name); if (rbinsert(grlist_cache, item) != NULL) - errorx(1, _("unable to cache group list for %s, already exists"), + fatalx(_("unable to cache group list for %s, already exists"), pw->pw_name); } debug_return; diff --git a/plugins/sudoers/regress/check_symbols/check_symbols.c b/plugins/sudoers/regress/check_symbols/check_symbols.c index 7f8f1b93c..6b49ca38b 100644 --- a/plugins/sudoers/regress/check_symbols/check_symbols.c +++ b/plugins/sudoers/regress/check_symbols/check_symbols.c @@ -80,11 +80,11 @@ main(int argc, char *argv[]) handle = dlopen(plugin_path, RTLD_LAZY|RTLD_GLOBAL); if (handle == NULL) - errorx_nodebug(1, "unable to dlopen %s: %s", plugin_path, dlerror()); + fatalx_nodebug("unable to dlopen %s: %s", plugin_path, dlerror()); fp = fopen(symbols_file, "r"); if (fp == NULL) - error_nodebug(1, "unable to open %s", symbols_file); + fatal_nodebug("unable to open %s", symbols_file); while (fgets(line, sizeof(line), fp) != NULL) { ntests++; diff --git a/plugins/sudoers/regress/iolog_path/check_iolog_path.c b/plugins/sudoers/regress/iolog_path/check_iolog_path.c index 3a3eaff27..0fbeaae30 100644 --- a/plugins/sudoers/regress/iolog_path/check_iolog_path.c +++ b/plugins/sudoers/regress/iolog_path/check_iolog_path.c @@ -115,7 +115,7 @@ main(int argc, char *argv[]) fp = fopen(argv[1], "r"); if (fp == NULL) - errorx(1, "unable to open %s", argv[1]); + fatalx("unable to open %s", argv[1]); memset(&pw, 0, sizeof(pw)); memset(&rpw, 0, sizeof(rpw)); @@ -184,7 +184,7 @@ main(int argc, char *argv[]) tests++; break; default: - errorx(1, "internal error, invalid state %d", state); + fatalx("internal error, invalid state %d", state); } state = (state + 1) % MAX_STATE; } diff --git a/plugins/sudoers/regress/logging/check_wrap.c b/plugins/sudoers/regress/logging/check_wrap.c index 226bbef27..7aeb679a4 100644 --- a/plugins/sudoers/regress/logging/check_wrap.c +++ b/plugins/sudoers/regress/logging/check_wrap.c @@ -70,7 +70,7 @@ main(int argc, char *argv[]) fp = fopen(argv[1], "r"); if (fp == NULL) - errorx(1, "unable to open %s", argv[1]); + fatalx("unable to open %s", argv[1]); /* * Each test record consists of a log entry on one line and a list of diff --git a/plugins/sudoers/regress/parser/check_addr.c b/plugins/sudoers/regress/parser/check_addr.c index af498d748..1c34db3e9 100644 --- a/plugins/sudoers/regress/parser/check_addr.c +++ b/plugins/sudoers/regress/parser/check_addr.c @@ -100,7 +100,7 @@ main(int argc, char *argv[]) fp = fopen(argv[1], "r"); if (fp == NULL) - errorx(1, "unable to open %s", argv[1]); + fatalx("unable to open %s", argv[1]); /* * Input is in the following format. There are two types of diff --git a/plugins/sudoers/sudoers.c b/plugins/sudoers/sudoers.c index f9e820bd5..d0d06cd0b 100644 --- a/plugins/sudoers/sudoers.c +++ b/plugins/sudoers/sudoers.c @@ -130,7 +130,7 @@ sudoers_policy_init(void *info, char * const envp[]) sudo_setgrent(); /* Register error/errorx callback. */ - error_callback_register(sudoers_cleanup); + fatal_callback_register(sudoers_cleanup); /* Initialize environment functions (including replacements). */ env_init(envp); @@ -216,7 +216,7 @@ sudoers_policy_main(int argc, char * const argv[], int pwflag, char *env_add[], debug_decl(sudoers_policy_main, SUDO_DEBUG_PLUGIN) /* XXX - would like to move this to policy.c but need the cleanup. */ - if (error_setjmp() != 0) { + if (fatal_setjmp() != 0) { /* error recovery via error(), errorx() or log_fatal() */ rval = -1; goto done; @@ -506,7 +506,7 @@ bad: rval = false; done: - error_disable_setjmp(); + fatal_disable_setjmp(); rewind_perms(); /* Close the password and group files and free up memory. */ @@ -559,7 +559,7 @@ init_vars(char * const envp[]) * YP/NIS/NIS+/LDAP/etc daemon has died. */ if (sudo_mode == MODE_KILL || sudo_mode == MODE_INVALIDATE) - errorx(1, _("unknown uid: %u"), (unsigned int) user_uid); + fatalx(_("unknown uid: %u"), (unsigned int) user_uid); /* Need to make a fake struct passwd for the call to log_fatal(). */ sudo_user.pw = sudo_fakepwnamid(user_name, user_uid, user_gid); @@ -651,7 +651,7 @@ set_cmnd(void) for (to = user_args, av = NewArgv + 1; *av; av++) { n = strlcpy(to, *av, size - (to - user_args)); if (n >= size - (to - user_args)) - errorx(1, _("internal error, %s overflow"), "set_cmnd()"); + fatalx(_("internal error, %s overflow"), "set_cmnd()"); to += n; *to++ = ' '; } @@ -661,7 +661,7 @@ set_cmnd(void) } if (strlen(user_cmnd) >= PATH_MAX) { errno = ENAMETOOLONG; - error(1, "%s", user_cmnd); + fatal("%s", user_cmnd); } if ((user_base = strrchr(user_cmnd, '/')) != NULL) @@ -760,7 +760,7 @@ set_loginclass(struct passwd *pw) if (login_class && strcmp(login_class, "-") != 0) { if (user_uid != 0 && strcmp(runas_user ? runas_user : def_runas_default, "root") != 0) - errorx(1, _("only root can use `-c %s'"), login_class); + fatalx(_("only root can use `-c %s'"), login_class); } else { login_class = pw->pw_class; if (!login_class || !*login_class) diff --git a/plugins/sudoers/sudoreplay.c b/plugins/sudoers/sudoreplay.c index b41c9358f..7180696b3 100644 --- a/plugins/sudoers/sudoreplay.c +++ b/plugins/sudoers/sudoreplay.c @@ -268,7 +268,7 @@ main(int argc, char *argv[]) textdomain("sudoers"); /* Register error/errorx callback. */ - error_callback_register(sudoreplay_cleanup); + fatal_callback_register(sudoreplay_cleanup); /* Read sudo.conf. */ sudo_conf_read(NULL); @@ -289,7 +289,7 @@ main(int argc, char *argv[]) else if (strcmp(cp, "ttyout") == 0) SET(replay_filter, 1 << IOFD_TTYOUT); else - errorx(1, _("invalid filter option: %s"), optarg); + fatalx(_("invalid filter option: %s"), optarg); } break; case 'h': @@ -302,13 +302,13 @@ main(int argc, char *argv[]) errno = 0; max_wait = strtod(optarg, &ep); if (*ep != '\0' || errno != 0) - errorx(1, _("invalid max wait: %s"), optarg); + fatalx(_("invalid max wait: %s"), optarg); break; case 's': errno = 0; speed = strtod(optarg, &ep); if (*ep != '\0' || errno != 0) - errorx(1, _("invalid speed factor: %s"), optarg); + fatalx(_("invalid speed factor: %s"), optarg); break; case 'V': (void) printf(_("%s version %s\n"), getprogname(), PACKAGE_VERSION); @@ -336,13 +336,13 @@ main(int argc, char *argv[]) plen = snprintf(path, sizeof(path), "%s/%.2s/%.2s/%.2s/timing", session_dir, id, &id[2], &id[4]); if (plen <= 0 || plen >= sizeof(path)) - errorx(1, _("%s/%.2s/%.2s/%.2s/timing: %s"), session_dir, + fatalx(_("%s/%.2s/%.2s/%.2s/timing: %s"), session_dir, id, &id[2], &id[4], strerror(ENAMETOOLONG)); } else { plen = snprintf(path, sizeof(path), "%s/%s/timing", session_dir, id); if (plen <= 0 || plen >= sizeof(path)) - errorx(1, _("%s/%s/timing: %s"), session_dir, + fatalx(_("%s/%s/timing: %s"), session_dir, id, strerror(ENAMETOOLONG)); } plen -= 7; @@ -351,7 +351,7 @@ main(int argc, char *argv[]) for (idx = 0; idx < IOFD_MAX; idx++) { if (ISSET(replay_filter, 1 << idx) || idx == IOFD_TIMING) { if (open_io_fd(path, plen, io_fnames[idx], &io_fds[idx]) == -1) - error(1, _("unable to open %s"), path); + fatal(_("unable to open %s"), path); } } @@ -397,7 +397,7 @@ main(int argc, char *argv[]) if (ch != -1) (void) fcntl(STDIN_FILENO, F_SETFL, ch | O_NONBLOCK); if (!term_raw(STDIN_FILENO, 1)) - error(1, _("unable to set tty to raw mode")); + fatal(_("unable to set tty to raw mode")); iovmax = 32; iov = ecalloc(iovmax, sizeof(*iov)); } @@ -413,7 +413,7 @@ main(int argc, char *argv[]) char last_char = '\0'; if (!parse_timing(buf, decimal, &idx, &seconds, &nbytes)) - errorx(1, _("invalid timing file line: %s"), buf); + fatalx(_("invalid timing file line: %s"), buf); if (interactive) check_input(STDIN_FILENO, &speed); @@ -496,7 +496,7 @@ main(int argc, char *argv[]) iovcnt = 1; } if (atomic_writev(STDOUT_FILENO, iov, iovcnt) == -1) - error(1, _("writing to standard output")); + fatal(_("writing to standard output")); } } term_restore(STDIN_FILENO, 1); @@ -525,7 +525,7 @@ delay(double secs) rval = nanosleep(&ts, &rts); } while (rval == -1 && errno == EINTR); if (rval == -1) { - error_nodebug(1, _("nanosleep: tv_sec %ld, tv_nsec %ld"), + fatal_nodebug(_("nanosleep: tv_sec %ld, tv_nsec %ld"), (long)ts.tv_sec, (long)ts.tv_nsec); } } @@ -638,7 +638,7 @@ parse_expr(struct search_node **headp, char *argv[]) continue; case 'c': /* command */ if (av[0][1] == '\0') - errorx(1, _("ambiguous expression \"%s\""), *av); + fatalx(_("ambiguous expression \"%s\""), *av); if (strncmp(*av, "cwd", strlen(*av)) == 0) type = ST_CWD; else if (strncmp(*av, "command", strlen(*av)) == 0) @@ -663,7 +663,7 @@ parse_expr(struct search_node **headp, char *argv[]) break; case 't': /* tty or to date */ if (av[0][1] == '\0') - errorx(1, _("ambiguous expression \"%s\""), *av); + fatalx(_("ambiguous expression \"%s\""), *av); if (strncmp(*av, "todate", strlen(*av)) == 0) type = ST_TODATE; else if (strncmp(*av, "tty", strlen(*av)) == 0) @@ -680,7 +680,7 @@ parse_expr(struct search_node **headp, char *argv[]) if (av[0][1] != '\0') goto bad; if (stack_top + 1 == STACK_NODE_SIZE) { - errorx(1, _("too many parenthesized expressions, max %d"), + fatalx(_("too many parenthesized expressions, max %d"), STACK_NODE_SIZE); } node_stack[stack_top++] = sn; @@ -691,13 +691,13 @@ parse_expr(struct search_node **headp, char *argv[]) goto bad; /* pop */ if (--stack_top < 0) - errorx(1, _("unmatched ')' in expression")); + fatalx(_("unmatched ')' in expression")); if (node_stack[stack_top]) sn->next = node_stack[stack_top]->next; debug_return_int(av - argv + 1); bad: default: - errorx(1, _("unknown search term \"%s\""), *av); + fatalx(_("unknown search term \"%s\""), *av); /* NOTREACHED */ } @@ -711,17 +711,17 @@ parse_expr(struct search_node **headp, char *argv[]) av += parse_expr(&newsn->u.expr, av + 1); } else { if (*(++av) == NULL) - errorx(1, _("%s requires an argument"), av[-1]); + fatalx(_("%s requires an argument"), av[-1]); #ifdef HAVE_REGCOMP if (type == ST_PATTERN) { if (regcomp(&newsn->u.cmdre, *av, REG_EXTENDED|REG_NOSUB) != 0) - errorx(1, _("invalid regular expression: %s"), *av); + fatalx(_("invalid regular expression: %s"), *av); } else #endif if (type == ST_TODATE || type == ST_FROMDATE) { newsn->u.tstamp = get_date(*av); if (newsn->u.tstamp == -1) - errorx(1, _("could not parse date \"%s\""), *av); + fatalx(_("could not parse date \"%s\""), *av); } else { newsn->u.ptr = *av; } @@ -734,11 +734,11 @@ parse_expr(struct search_node **headp, char *argv[]) sn = newsn; } if (stack_top) - errorx(1, _("unmatched '(' in expression")); + fatalx(_("unmatched '(' in expression")); if (or) - errorx(1, _("illegal trailing \"or\"")); + fatalx(_("illegal trailing \"or\"")); if (not) - errorx(1, _("illegal trailing \"!\"")); + fatalx(_("illegal trailing \"!\"")); debug_return_int(av - argv); } @@ -781,7 +781,7 @@ match_expr(struct search_node *head, struct log_info *log) if (rc && rc != REG_NOMATCH) { char buf[BUFSIZ]; regerror(rc, &sn->u.cmdre, buf, sizeof(buf)); - errorx(1, "%s", buf); + fatalx("%s", buf); } matched = rc == REG_NOMATCH ? 0 : 1; #else @@ -975,13 +975,13 @@ find_sessions(const char *dir, REGEX_T *re, const char *user, const char *tty) d = opendir(dir); if (d == NULL) - error(1, _("unable to open %s"), dir); + fatal(_("unable to open %s"), dir); /* XXX - would be faster to chdir and use relative names */ sdlen = strlcpy(pathbuf, dir, sizeof(pathbuf)); if (sdlen + 1 >= sizeof(pathbuf)) { errno = ENAMETOOLONG; - error(1, "%s/", dir); + fatal("%s/", dir); } pathbuf[sdlen++] = '/'; pathbuf[sdlen] = '\0'; @@ -1020,7 +1020,7 @@ find_sessions(const char *dir, REGEX_T *re, const char *user, const char *tty) "%s/log", sessions[i]); if (len <= 0 || len >= sizeof(pathbuf) - sdlen) { errno = ENAMETOOLONG; - error(1, "%s/%s/log", dir, sessions[i]); + fatal("%s/%s/log", dir, sessions[i]); } efree(sessions[i]); @@ -1055,7 +1055,7 @@ list_sessions(int argc, char **argv, const char *pattern, const char *user, if (pattern) { re = &rebuf; if (regcomp(re, pattern, REG_EXTENDED|REG_NOSUB) != 0) - errorx(1, _("invalid regular expression: %s"), pattern); + fatalx(_("invalid regular expression: %s"), pattern); } #else re = (char *) pattern; diff --git a/plugins/sudoers/testsudoers.c b/plugins/sudoers/testsudoers.c index 5f3140b5c..07b343a85 100644 --- a/plugins/sudoers/testsudoers.c +++ b/plugins/sudoers/testsudoers.c @@ -212,11 +212,11 @@ main(int argc, char *argv[]) argc -= 2; } if ((sudo_user.pw = sudo_getpwnam(user_name)) == NULL) - errorx(1, _("unknown user: %s"), user_name); + fatalx(_("unknown user: %s"), user_name); if (user_host == NULL) { if (gethostname(hbuf, sizeof(hbuf)) != 0) - error(1, "gethostname"); + fatal("gethostname"); hbuf[sizeof(hbuf) - 1] = '\0'; user_host = hbuf; } @@ -240,7 +240,7 @@ main(int argc, char *argv[]) for (to = user_args, from = argv; *from; from++) { n = strlcpy(to, *from, size - (to - user_args)); if (n >= size - (to - user_args)) - errorx(1, _("internal error, %s overflow"), "init_vars()"); + fatalx(_("internal error, %s overflow"), "init_vars()"); to += n; *to++ = ' '; } @@ -356,7 +356,7 @@ set_runaspw(const char *user) runas_pw = sudo_fakepwnam(user, runas_gr ? runas_gr->gr_gid : 0); } else { if ((runas_pw = sudo_getpwnam(user)) == NULL) - errorx(1, _("unknown user: %s"), user); + fatalx(_("unknown user: %s"), user); } debug_return; @@ -374,7 +374,7 @@ set_runasgr(const char *group) runas_gr = sudo_fakegrnam(group); } else { if ((runas_gr = sudo_getgrnam(group)) == NULL) - errorx(1, _("unknown group: %s"), group); + fatalx(_("unknown group: %s"), group); } debug_return; diff --git a/plugins/sudoers/timestamp.c b/plugins/sudoers/timestamp.c index 62e10478b..f998f56db 100644 --- a/plugins/sudoers/timestamp.c +++ b/plugins/sudoers/timestamp.c @@ -411,7 +411,7 @@ remove_timestamp(bool remove) if (!remove) { timevalclear(&tv); if (touch(-1, path, &tv) == -1 && errno != ENOENT) - error(1, _("unable to reset %s to the epoch"), path); + fatal(_("unable to reset %s to the epoch"), path); } } diff --git a/plugins/sudoers/visudo.c b/plugins/sudoers/visudo.c index 832e97f72..27f9e4b92 100644 --- a/plugins/sudoers/visudo.c +++ b/plugins/sudoers/visudo.c @@ -163,7 +163,7 @@ main(int argc, char *argv[]) usage(1); /* Register error/errorx callback. */ - error_callback_register(visudo_cleanup); + fatal_callback_register(visudo_cleanup); /* Read sudo.conf. */ sudo_conf_read(NULL); @@ -209,7 +209,7 @@ main(int argc, char *argv[]) /* Mock up a fake sudo_user struct. */ user_cmnd = ""; if ((sudo_user.pw = sudo_getpwuid(getuid())) == NULL) - errorx(1, _("you do not exist in the %s database"), "passwd"); + fatalx(_("you do not exist in the %s database"), "passwd"); get_hostname(); /* Setup defaults data structures. */ @@ -307,7 +307,7 @@ edit_sudoers(struct sudoersfile *sp, char *editor, char *args, int lineno) debug_decl(edit_sudoers, SUDO_DEBUG_UTIL) if (fstat(sp->fd, &sb) == -1) - error(1, _("unable to stat %s"), sp->path); + fatal(_("unable to stat %s"), sp->path); orig_size = sb.st_size; mtim_get(&sb, &orig_mtim); @@ -316,20 +316,20 @@ edit_sudoers(struct sudoersfile *sp, char *editor, char *args, int lineno) easprintf(&sp->tpath, "%s.tmp", sp->path); tfd = open(sp->tpath, O_WRONLY | O_CREAT | O_TRUNC, 0600); if (tfd < 0) - error(1, "%s", sp->tpath); + fatal("%s", sp->tpath); /* Copy sp->path -> sp->tpath and reset the mtime. */ if (orig_size != 0) { (void) lseek(sp->fd, (off_t)0, SEEK_SET); while ((nread = read(sp->fd, buf, sizeof(buf))) > 0) if (write(tfd, buf, nread) != nread) - error(1, _("write error")); + fatal(_("write error")); /* Add missing newline at EOF if needed. */ if (nread > 0 && buf[nread - 1] != '\n') { buf[0] = '\n'; if (write(tfd, buf, 1) != 1) - error(1, _("write error")); + fatal(_("write error")); } } (void) close(tfd); @@ -474,7 +474,7 @@ reparse_sudoers(char *editor, char *args, bool strict, bool quiet) last = tq_last(&sudoerslist); fp = fopen(sp->tpath, "r+"); if (fp == NULL) - errorx(1, _("unable to re-open temporary file (%s), %s unchanged."), + fatalx(_("unable to re-open temporary file (%s), %s unchanged."), sp->tpath, sp->path); /* Clean slate for each parse */ @@ -523,7 +523,7 @@ reparse_sudoers(char *editor, char *args, bool strict, bool quiet) } } if (errorfile != NULL && sp == NULL) { - errorx(1, _("internal error, unable to find %s in list!"), + fatalx(_("internal error, unable to find %s in list!"), sudoers); } } @@ -573,7 +573,7 @@ install_sudoers(struct sudoersfile *sp, bool oldperms) if (oldperms) { /* Use perms of the existing file. */ if (fstat(sp->fd, &sb) == -1) - error(1, _("unable to stat %s"), sp->path); + fatal(_("unable to stat %s"), sp->path); if (chown(sp->tpath, sb.st_uid, sb.st_gid) != 0) { warning(_("unable to set (uid, gid) of %s to (%u, %u)"), sp->tpath, (unsigned int)sb.st_uid, (unsigned int)sb.st_gid); @@ -747,7 +747,7 @@ run_command(char *path, char **argv) switch (pid = sudo_debug_fork()) { case -1: - error(1, _("unable to execute %s"), path); + fatal(_("unable to execute %s"), path); break; /* NOTREACHED */ case 0: sudo_endpwent(); @@ -890,18 +890,18 @@ open_sudoers(const char *path, bool doedit, bool *keepopen) debug_return_ptr(NULL); } if (!checkonly && !lock_file(entry->fd, SUDO_TLOCK)) - errorx(1, _("%s busy, try again later"), entry->path); + fatalx(_("%s busy, try again later"), entry->path); if ((fp = fdopen(entry->fd, "r")) == NULL) - error(1, "%s", entry->path); + fatal("%s", entry->path); tq_append(&sudoerslist, entry); } else { /* Already exists, open .tmp version if there is one. */ if (entry->tpath != NULL) { if ((fp = fopen(entry->tpath, "r")) == NULL) - error(1, "%s", entry->tpath); + fatal("%s", entry->tpath); } else { if ((fp = fdopen(entry->fd, "r")) == NULL) - error(1, "%s", entry->path); + fatal("%s", entry->path); rewind(fp); } } @@ -934,7 +934,7 @@ get_editor(char **args) } else { if (def_env_editor) { /* If we are honoring $EDITOR this is a fatal error. */ - errorx(1, _("specified editor (%s) doesn't exist"), UserEditor); + fatalx(_("specified editor (%s) doesn't exist"), UserEditor); } else { /* Otherwise, just ignore $EDITOR. */ UserEditor = NULL; @@ -957,7 +957,7 @@ get_editor(char **args) if (stat(UserEditor, &user_editor_sb) != 0) { /* Should never happen since we already checked above. */ - error(1, _("unable to stat editor (%s)"), UserEditor); + fatal(_("unable to stat editor (%s)"), UserEditor); } EditorPath = estrdup(def_editor); Editor = strtok(EditorPath, ":"); @@ -1005,7 +1005,7 @@ get_editor(char **args) /* Bleah, none of the editors existed! */ if (Editor == NULL || *Editor == '\0') - errorx(1, _("no editor found (editor path = %s)"), def_editor); + fatalx(_("no editor found (editor path = %s)"), def_editor); } *args = EditorArgs; debug_return_str(Editor); diff --git a/src/exec.c b/src/exec.c index ddb5c4bf3..a2289810a 100644 --- a/src/exec.c +++ b/src/exec.c @@ -124,12 +124,12 @@ static int fork_cmnd(struct command_details *details, int sv[2]) * or certain pam modules won't be able to track their state. */ if (policy_init_session(details) != true) - errorx(1, _("policy plugin failed session initialization")); + fatalx(_("policy plugin failed session initialization")); cmnd_pid = sudo_debug_fork(); switch (cmnd_pid) { case -1: - error(1, _("unable to fork")); + fatal(_("unable to fork")); break; case 0: /* child */ @@ -256,7 +256,7 @@ sudo_execute(struct command_details *details, struct command_status *cstat) * Parent sends signal info to child and child sends back wait status. */ if (socketpair(PF_UNIX, SOCK_DGRAM, 0, sv) == -1) - error(1, _("unable to create sockets")); + fatal(_("unable to create sockets")); /* * Signals to forward to the child process (excluding SIGALRM and SIGCHLD). diff --git a/src/exec_common.c b/src/exec_common.c index 923a0fe01..22c152da2 100644 --- a/src/exec_common.c +++ b/src/exec_common.c @@ -109,7 +109,7 @@ disable_execute(char *const envp[]) preload = fmt_string(RTLD_PRELOAD_VAR, sudo_conf_noexec_path()); # endif if (preload == NULL) - errorx(1, NULL); + fatalx(NULL); nenvp[env_len++] = preload; nenvp[env_len] = NULL; } else { diff --git a/src/exec_pty.c b/src/exec_pty.c index 1302aaef6..92ab06d2a 100644 --- a/src/exec_pty.c +++ b/src/exec_pty.c @@ -180,7 +180,7 @@ pty_setup(uid_t uid, const char *tty, const char *utmp_user) if (io_fds[SFD_USERTTY] != -1) { if (!get_pty(&io_fds[SFD_MASTER], &io_fds[SFD_SLAVE], slavename, sizeof(slavename), uid)) - error(1, _("unable to allocate pty")); + fatal(_("unable to allocate pty")); /* Add entry to utmp/utmpx? */ if (utmp_user != NULL) utmp_login(tty, slavename, io_fds[SFD_SLAVE], utmp_user); @@ -620,7 +620,7 @@ fork_pty(struct command_details *details, int sv[], int *maxfd, sigset_t *omask) sudo_debug_printf(SUDO_DEBUG_INFO, "stdin not a tty, creating a pipe"); pipeline = true; if (pipe(io_pipe[STDIN_FILENO]) != 0) - error(1, _("unable to create pipe")); + fatal(_("unable to create pipe")); iobufs = io_buf_new(STDIN_FILENO, io_pipe[STDIN_FILENO][1], log_stdin, iobufs); io_fds[SFD_STDIN] = io_pipe[STDIN_FILENO][0]; @@ -629,7 +629,7 @@ fork_pty(struct command_details *details, int sv[], int *maxfd, sigset_t *omask) sudo_debug_printf(SUDO_DEBUG_INFO, "stdout not a tty, creating a pipe"); pipeline = true; if (pipe(io_pipe[STDOUT_FILENO]) != 0) - error(1, _("unable to create pipe")); + fatal(_("unable to create pipe")); iobufs = io_buf_new(io_pipe[STDOUT_FILENO][0], STDOUT_FILENO, log_stdout, iobufs); io_fds[SFD_STDOUT] = io_pipe[STDOUT_FILENO][1]; @@ -637,7 +637,7 @@ fork_pty(struct command_details *details, int sv[], int *maxfd, sigset_t *omask) if (io_fds[SFD_STDERR] == -1 || !isatty(STDERR_FILENO)) { sudo_debug_printf(SUDO_DEBUG_INFO, "stderr not a tty, creating a pipe"); if (pipe(io_pipe[STDERR_FILENO]) != 0) - error(1, _("unable to create pipe")); + fatal(_("unable to create pipe")); iobufs = io_buf_new(io_pipe[STDERR_FILENO][0], STDERR_FILENO, log_stderr, iobufs); io_fds[SFD_STDERR] = io_pipe[STDERR_FILENO][1]; @@ -673,7 +673,7 @@ fork_pty(struct command_details *details, int sv[], int *maxfd, sigset_t *omask) n = term_raw(io_fds[SFD_USERTTY], 0); } while (!n && errno == EINTR); if (!n) - error(1, _("unable to set terminal to raw mode")); + fatal(_("unable to set terminal to raw mode")); } } @@ -682,7 +682,7 @@ fork_pty(struct command_details *details, int sv[], int *maxfd, sigset_t *omask) * or certain pam modules won't be able to track their state. */ if (policy_init_session(details) != true) - errorx(1, _("policy plugin failed session initialization")); + fatalx(_("policy plugin failed session initialization")); /* * Block some signals until cmnd_pid is set in the parent to avoid a @@ -698,7 +698,7 @@ fork_pty(struct command_details *details, int sv[], int *maxfd, sigset_t *omask) child = sudo_debug_fork(); switch (child) { case -1: - error(1, _("unable to fork")); + fatal(_("unable to fork")); break; case 0: /* child */ @@ -983,7 +983,7 @@ exec_monitor(struct command_details *details, int backchannel) * the select() loop. */ if (pipe_nonblock(signal_pipe) != 0) - error(1, _("unable to create pipe")); + fatal(_("unable to create pipe")); /* Reset SIGWINCH and SIGALRM. */ memset(&sa, 0, sizeof(sa)); @@ -1039,7 +1039,7 @@ exec_monitor(struct command_details *details, int backchannel) if (io_fds[SFD_SLAVE] != -1) { #ifdef TIOCSCTTY if (ioctl(io_fds[SFD_SLAVE], TIOCSCTTY, NULL) != 0) - error(1, _("unable to set controlling tty")); + fatal(_("unable to set controlling tty")); #else /* Set controlling tty by reopening slave. */ if ((n = open(slavename, O_RDWR)) >= 0) @@ -1060,7 +1060,7 @@ exec_monitor(struct command_details *details, int backchannel) /* Start command and wait for it to stop or exit */ if (pipe(errpipe) == -1) - error(1, _("unable to create pipe")); + fatal(_("unable to create pipe")); cmnd_pid = sudo_debug_fork(); if (cmnd_pid == -1) { warning(_("unable to fork")); @@ -1287,7 +1287,7 @@ exec_pty(struct command_details *details, debug_decl(exec_pty, SUDO_DEBUG_EXEC); /* Register cleanup function */ - error_callback_register(pty_cleanup); + fatal_callback_register(pty_cleanup); /* Set command process group here too to avoid a race. */ setpgid(0, self); @@ -1296,7 +1296,7 @@ exec_pty(struct command_details *details, if (dup2(io_fds[SFD_STDIN], STDIN_FILENO) == -1 || dup2(io_fds[SFD_STDOUT], STDOUT_FILENO) == -1 || dup2(io_fds[SFD_STDERR], STDERR_FILENO) == -1) - error(1, "dup2"); + fatal("dup2"); /* Wait for parent to grant us the tty if we are foreground. */ if (foreground && !ISSET(details->flags, CD_EXEC_BG)) { diff --git a/src/net_ifs.c b/src/net_ifs.c index 82fc3629f..738cf1c3d 100644 --- a/src/net_ifs.c +++ b/src/net_ifs.c @@ -223,7 +223,7 @@ get_net_ifs(char **addrinfo) sock = socket(AF_INET, SOCK_DGRAM, 0); if (sock < 0) - error(1, _("unable to open socket")); + fatal(_("unable to open socket")); /* * Get interface configuration or return. diff --git a/src/parse_args.c b/src/parse_args.c index b7aab2718..72f9d1002 100644 --- a/src/parse_args.c +++ b/src/parse_args.c @@ -283,7 +283,7 @@ parse_args(int argc, char **argv, int *nargc, char ***nargv, char ***settingsp, break; case 'U': if ((getpwnam(optarg)) == NULL) - errorx(1, _("unknown user: %s"), optarg); + fatalx(_("unknown user: %s"), optarg); list_user = optarg; break; case 'u': @@ -440,7 +440,7 @@ parse_args(int argc, char **argv, int *nargc, char ***nargv, char ***settingsp, settings[j] = fmt_string(sudo_settings[i].name, sudo_settings[i].value); if (settings[j] == NULL) - errorx(1, NULL); + fatalx(NULL); j++; } } @@ -453,7 +453,7 @@ parse_args(int argc, char **argv, int *nargc, char ***nargv, char ***settingsp, argv--; argv[0] = "sudoedit"; #else - errorx(1, _("sudoedit is not supported on this platform")); + fatalx(_("sudoedit is not supported on this platform")); #endif } diff --git a/src/selinux.c b/src/selinux.c index f80cfab86..5fbafe87d 100644 --- a/src/selinux.c +++ b/src/selinux.c @@ -74,7 +74,7 @@ audit_role_change(const security_context_t old_context, /* Kernel may not have audit support. */ if (errno != EINVAL && errno != EPROTONOSUPPORT && errno != EAFNOSUPPORT ) - error(1, _("unable to open audit system")); + fatal(_("unable to open audit system")); } else { /* audit role change using the same format as newrole(1) */ easprintf(&message, "newrole: old-context=%s new-context=%s", diff --git a/src/signal.c b/src/signal.c index 522e76d2a..7ac0d96a5 100644 --- a/src/signal.c +++ b/src/signal.c @@ -123,7 +123,7 @@ init_signals(void) * the select() loop without races (we may not have pselect()). */ if (pipe_nonblock(signal_pipe) != 0) - error(1, _("unable to create pipe")); + fatal(_("unable to create pipe")); memset(&sa, 0, sizeof(sa)); sigfillset(&sa.sa_mask); diff --git a/src/sudo.c b/src/sudo.c index cc1f41517..5a849efd3 100644 --- a/src/sudo.c +++ b/src/sudo.c @@ -200,7 +200,7 @@ main(int argc, char *argv[], char *envp[]) /* Load plugins. */ if (!sudo_load_plugins(&policy_plugin, &io_plugins)) - errorx(1, _("fatal error, unable to load plugins")); + fatalx(_("fatal error, unable to load plugins")); /* Open policy plugin. */ ok = policy_open(&policy_plugin, settings, user_info, envp); @@ -208,7 +208,7 @@ main(int argc, char *argv[], char *envp[]) if (ok == -2) usage(1); else - errorx(1, _("unable to initialize policy plugin")); + fatalx(_("unable to initialize policy plugin")); } init_signals(); @@ -265,7 +265,7 @@ main(int argc, char *argv[], char *envp[]) usage(1); break; default: - errorx(1, _("error initializing I/O plugin %s"), + fatalx(_("error initializing I/O plugin %s"), plugin->name); } } @@ -290,7 +290,7 @@ main(int argc, char *argv[], char *envp[]) /* The close method was called by sudo_edit/run_command. */ break; default: - errorx(1, _("unexpected sudo mode 0x%x"), sudo_mode); + fatalx(_("unexpected sudo mode 0x%x"), sudo_mode); } sudo_debug_exit_int(__func__, __FILE__, __LINE__, sudo_debug_subsys, exitcode); exit(exitcode); @@ -325,13 +325,13 @@ fix_fds(void) miss[STDERR_FILENO] = fcntl(STDERR_FILENO, F_GETFL, 0) == -1; if (miss[STDIN_FILENO] || miss[STDOUT_FILENO] || miss[STDERR_FILENO]) { if ((devnull = open(_PATH_DEVNULL, O_RDWR, 0644)) == -1) - error(1, _("unable to open %s"), _PATH_DEVNULL); + fatal(_("unable to open %s"), _PATH_DEVNULL); if (miss[STDIN_FILENO] && dup2(devnull, STDIN_FILENO) == -1) - error(1, "dup2"); + fatal("dup2"); if (miss[STDOUT_FILENO] && dup2(devnull, STDOUT_FILENO) == -1) - error(1, "dup2"); + fatal("dup2"); if (miss[STDERR_FILENO] && dup2(devnull, STDERR_FILENO) == -1) - error(1, "dup2"); + fatal("dup2"); if (devnull > STDERR_FILENO) close(devnull); } @@ -410,7 +410,7 @@ get_user_groups(struct user_details *ud) * Typically, this is because NFS can only support up to 16 groups. */ if (fill_group_list(ud, maxgroups) == -1) - error(1, _("unable to get group vector")); + fatal(_("unable to get group vector")); } /* @@ -462,11 +462,11 @@ get_user_info(struct user_details *ud) pw = getpwuid(ud->uid); if (pw == NULL) - errorx(1, _("unknown uid %u: who are you?"), (unsigned int)ud->uid); + fatalx(_("unknown uid %u: who are you?"), (unsigned int)ud->uid); user_info[i] = fmt_string("user", pw->pw_name); if (user_info[i] == NULL) - errorx(1, NULL); + fatalx(NULL); ud->username = user_info[i] + sizeof("user=") - 1; /* Stash user's shell for use with the -s flag; don't pass to plugin. */ @@ -492,14 +492,14 @@ get_user_info(struct user_details *ud) if (getcwd(cwd, sizeof(cwd)) != NULL) { user_info[++i] = fmt_string("cwd", cwd); if (user_info[i] == NULL) - errorx(1, NULL); + fatalx(NULL); ud->cwd = user_info[i] + sizeof("cwd=") - 1; } if ((cp = get_process_ttyname()) != NULL) { user_info[++i] = fmt_string("tty", cp); if (user_info[i] == NULL) - errorx(1, NULL); + fatalx(NULL); ud->tty = user_info[i] + sizeof("tty=") - 1; efree(cp); } @@ -510,7 +510,7 @@ get_user_info(struct user_details *ud) strlcpy(host, "localhost", sizeof(host)); user_info[++i] = fmt_string("host", host); if (user_info[i] == NULL) - errorx(1, NULL); + fatalx(NULL); ud->host = user_info[i] + sizeof("host=") - 1; get_ttysize(&ud->ts_lines, &ud->ts_cols); @@ -776,7 +776,7 @@ command_info_to_details(char * const info[], struct command_details *details) #endif details->pw = getpwuid(details->euid); if (details->pw != NULL && (details->pw = pw_dup(details->pw)) == NULL) - errorx(1, NULL); + fatalx(NULL); #ifdef HAVE_SETAUTHDB aix_restoreauthdb(); #endif @@ -798,16 +798,16 @@ sudo_check_suid(const char *path) if (strchr(path, '/') != NULL && stat(path, &sb) == 0) { /* Try to determine why sudo was not running as root. */ if (sb.st_uid != ROOT_UID || !ISSET(sb.st_mode, S_ISUID)) { - errorx(1, + fatalx( _("%s must be owned by uid %d and have the setuid bit set"), path, ROOT_UID); } else { - errorx(1, _("effective uid is not %d, is %s on a file system " + fatalx(_("effective uid is not %d, is %s on a file system " "with the 'nosuid' option set or an NFS file system without" " root privileges?"), ROOT_UID, path); } } else { - errorx(1, + fatalx( _("effective uid is not %d, is sudo installed setuid root?"), ROOT_UID); } @@ -1143,7 +1143,7 @@ policy_check(struct plugin_container *plugin, int argc, char * const argv[], { debug_decl(policy_check, SUDO_DEBUG_PCOMM) if (plugin->u.policy->check_policy == NULL) { - errorx(1, _("policy plugin %s is missing the `check_policy' method"), + fatalx(_("policy plugin %s is missing the `check_policy' method"), plugin->name); } debug_return_bool(plugin->u.policy->check_policy(argc, argv, env_add, @@ -1180,7 +1180,7 @@ policy_invalidate(struct plugin_container *plugin, int remove) { debug_decl(policy_invalidate, SUDO_DEBUG_PCOMM) if (plugin->u.policy->invalidate == NULL) { - errorx(1, _("policy plugin %s does not support the -k/-K options"), + fatalx(_("policy plugin %s does not support the -k/-K options"), plugin->name); } plugin->u.policy->invalidate(remove); diff --git a/src/sudo_edit.c b/src/sudo_edit.c index 0c9d1b12b..ca45d8785 100644 --- a/src/sudo_edit.c +++ b/src/sudo_edit.c @@ -62,17 +62,17 @@ switch_user(uid_t euid, gid_t egid, int ngroups, GETGROUPS_T *groups) /* When restoring root, change euid first; otherwise change it last. */ if (euid == ROOT_UID) { if (seteuid(ROOT_UID) != 0) - error(1, "seteuid(ROOT_UID)"); + fatal("seteuid(ROOT_UID)"); } if (setegid(egid) != 0) - error(1, "setegid(%d)", (int)egid); + fatal("setegid(%d)", (int)egid); if (ngroups != -1) { if (sudo_setgroups(ngroups, groups) != 0) - error(1, "setgroups"); + fatal("setgroups"); } if (euid != ROOT_UID) { if (seteuid(euid) != 0) - error(1, "seteuid(%d)", (int)euid); + fatal("seteuid(%d)", (int)euid); } errno = serrno; @@ -187,10 +187,10 @@ sudo_edit(struct command_details *command_details) easprintf(&tf[j].tfile, "%.*s/%s.XXXXXXXX", tmplen, tmpdir, cp); } if (seteuid(user_details.uid) != 0) - error(1, "seteuid(%d)", (int)user_details.uid); + fatal("seteuid(%d)", (int)user_details.uid); tfd = mkstemps(tf[j].tfile, suff ? strlen(suff) : 0); if (seteuid(ROOT_UID) != 0) - error(1, "seteuid(ROOT_UID)"); + fatal("seteuid(ROOT_UID)"); if (tfd == -1) { warning("mkstemps"); goto cleanup; @@ -257,12 +257,12 @@ sudo_edit(struct command_details *command_details) for (i = 0; i < nfiles; i++) { rc = -1; if (seteuid(user_details.uid) != 0) - error(1, "seteuid(%d)", (int)user_details.uid); + fatal("seteuid(%d)", (int)user_details.uid); if ((tfd = open(tf[i].tfile, O_RDONLY, 0644)) != -1) { rc = fstat(tfd, &sb); } if (seteuid(ROOT_UID) != 0) - error(1, "seteuid(ROOT_UID)"); + fatal("seteuid(ROOT_UID)"); if (rc || !S_ISREG(sb.st_mode)) { if (rc) warning("%s", tf[i].tfile); diff --git a/src/tgetpass.c b/src/tgetpass.c index 0d51c23ed..ed74a0a7e 100644 --- a/src/tgetpass.c +++ b/src/tgetpass.c @@ -95,7 +95,7 @@ tgetpass(const char *prompt, int timeout, int flags) /* If using a helper program to get the password, run it instead. */ if (ISSET(flags, TGP_ASKPASS)) { if (askpass == NULL || *askpass == '\0') - errorx(1, _("no askpass program specified, try setting SUDO_ASKPASS")); + fatalx(_("no askpass program specified, try setting SUDO_ASKPASS")); debug_return_str_masked(sudo_askpass(askpass, prompt)); } @@ -214,10 +214,10 @@ sudo_askpass(const char *askpass, const char *prompt) debug_decl(sudo_askpass, SUDO_DEBUG_CONV) if (pipe(pfd) == -1) - error(1, _("unable to create pipe")); + fatal(_("unable to create pipe")); if ((pid = fork()) == -1) - error(1, _("unable to fork")); + fatal(_("unable to fork")); if (pid == 0) { /* child, point stdout to output side of the pipe and exec askpass */ diff --git a/src/utmp.c b/src/utmp.c index 613e78c2f..2e71d6812 100644 --- a/src/utmp.c +++ b/src/utmp.c @@ -275,12 +275,12 @@ utmp_slot(const char *line, int ttyfd) * doesn't take an argument. */ if ((sfd = dup(STDIN_FILENO)) == -1) - error(1, _("unable to save stdin")); + fatal(_("unable to save stdin")); if (dup2(ttyfd, STDIN_FILENO) == -1) - error(1, _("unable to dup2 stdin")); + fatal(_("unable to dup2 stdin")); slot = ttyslot(); if (dup2(sfd, STDIN_FILENO) == -1) - error(1, _("unable to restore stdin")); + fatal(_("unable to restore stdin")); close(sfd); debug_return_int(slot); -- 2.40.0