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