pollution in libsudo_util.so.
/*
- * Copyright (c) 2004, 2010-2013 Todd C. Miller <Todd.Miller@courtesan.com>
+ * Copyright (c) 2004, 2010-2014 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
#include <stdarg.h>
/*
- * We wrap fatal/fatalx and warning/warningx so that the same output can
+ * We wrap fatal/fatalx and warn/warnx so that the same output can
* go to the debug file, if there is one.
*/
#if (defined(SUDO_ERROR_WRAP) && SUDO_ERROR_WRAP == 0) || defined(NO_VARIADIC_MACROS)
-# define fatal fatal_nodebug
-# define fatalx fatalx_nodebug
-# define warning warning_nodebug
-# define warningx warningx_nodebug
-# define vfatal(fmt, ap) fatal_nodebug((fmt), (ap))
-# define vfatalx(fmt, ap) fatalx_nodebug((fmt), (ap))
-# define vwarning(fmt, ap) warning_nodebug((fmt), (ap))
-# define vwarningx(fmt, ap) warningx_nodebug((fmt), (ap))
+# define sudo_fatal sudo_fatal_nodebug
+# define sudo_fatalx sudo_fatalx_nodebug
+# define sudo_warn sudo_warn_nodebug
+# define sudo_warnx sudo_warnx_nodebug
+# define sudo_vfatal(fmt, ap) sudo_vfatal_nodebug((fmt), (ap))
+# define sudo_vfatalx(fmt, ap) sudo_vfatalx_nodebug((fmt), (ap))
+# define sudo_vwarn(fmt, ap) sudo_vwarn_nodebug((fmt), (ap))
+# define sudo_vwarnx(fmt, ap) sudo_vwarnx_nodebug((fmt), (ap))
#else /* SUDO_ERROR_WRAP */
# if defined(__GNUC__) && __GNUC__ == 2
-# define fatal(fmt...) do { \
+# define sudo_fatal(fmt...) do { \
sudo_debug_printf2(__func__, __FILE__, __LINE__, \
SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO|SUDO_DEBUG_ERRNO|sudo_debug_subsys, \
fmt); \
- fatal_nodebug(fmt); \
+ sudo_fatal_nodebug(fmt); \
} while (0)
-# define fatalx(fmt...) do { \
+# define sudo_fatalx(fmt...) do { \
sudo_debug_printf2(__func__, __FILE__, __LINE__, \
SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO|sudo_debug_subsys, fmt); \
- fatalx_nodebug(fmt); \
+ sudo_fatalx_nodebug(fmt); \
} while (0)
-# define warning(fmt...) do { \
+# define sudo_warn(fmt...) do { \
sudo_debug_printf2(__func__, __FILE__, __LINE__, \
SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO|SUDO_DEBUG_ERRNO|sudo_debug_subsys, \
fmt); \
- warning_nodebug(fmt); \
+ sudo_warn_nodebug(fmt); \
} while (0)
-# define warningx(fmt...) do { \
+# define sudo_warnx(fmt...) do { \
sudo_debug_printf2(__func__, __FILE__, __LINE__, \
SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO|sudo_debug_subsys, fmt); \
- warningx_nodebug(fmt); \
+ sudo_warnx_nodebug(fmt); \
} while (0)
# else
-# define fatal(...) do { \
+# define sudo_fatal(...) do { \
sudo_debug_printf2(__func__, __FILE__, __LINE__, \
SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO|SUDO_DEBUG_ERRNO|sudo_debug_subsys, \
__VA_ARGS__); \
- fatal_nodebug(__VA_ARGS__); \
+ sudo_fatal_nodebug(__VA_ARGS__); \
} while (0)
-# define fatalx(...) do { \
+# define sudo_fatalx(...) do { \
sudo_debug_printf2(__func__, __FILE__, __LINE__, \
SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO|sudo_debug_subsys, __VA_ARGS__); \
- fatalx_nodebug(__VA_ARGS__); \
+ sudo_fatalx_nodebug(__VA_ARGS__); \
} while (0)
-# define warning(...) do { \
+# define sudo_warn(...) do { \
sudo_debug_printf2(__func__, __FILE__, __LINE__, \
SUDO_DEBUG_WARN|SUDO_DEBUG_LINENO|SUDO_DEBUG_ERRNO|sudo_debug_subsys, \
__VA_ARGS__); \
- warning_nodebug(__VA_ARGS__); \
+ sudo_warn_nodebug(__VA_ARGS__); \
} while (0)
-# define warningx(...) do { \
+# define sudo_warnx(...) do { \
sudo_debug_printf2(__func__, __FILE__, __LINE__, \
SUDO_DEBUG_WARN|SUDO_DEBUG_LINENO|sudo_debug_subsys, __VA_ARGS__); \
- warningx_nodebug(__VA_ARGS__); \
+ sudo_warnx_nodebug(__VA_ARGS__); \
} while (0)
# endif /* __GNUC__ == 2 */
-# define vfatal(fmt, ap) do { \
+# define sudo_vfatal(fmt, ap) do { \
va_list ap2; \
va_copy(ap2, (ap)); \
sudo_debug_vprintf2(__func__, __FILE__, __LINE__, \
SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO|SUDO_DEBUG_ERRNO|sudo_debug_subsys, \
(fmt), ap2); \
- vfatal_nodebug((fmt), (ap)); \
+ sudo_vfatal_nodebug((fmt), (ap)); \
} while (0)
-# define vfatalx(fmt, ap) do { \
+# define sudo_vfatalx(fmt, ap) do { \
va_list ap2; \
va_copy(ap2, (ap)); \
sudo_debug_vprintf2(__func__, __FILE__, __LINE__, \
SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO|sudo_debug_subsys, (fmt), ap2); \
- vfatalx_nodebug((fmt), (ap)); \
+ sudo_vfatalx_nodebug((fmt), (ap)); \
} while (0)
-# define vwarning(fmt, ap) do { \
+# define sudo_vwarn(fmt, ap) do { \
va_list ap2; \
va_copy(ap2, (ap)); \
sudo_debug_vprintf2(__func__, __FILE__, __LINE__, \
SUDO_DEBUG_WARN|SUDO_DEBUG_LINENO|SUDO_DEBUG_ERRNO|sudo_debug_subsys, \
(fmt), ap2); \
- vwarning_nodebug((fmt), (ap)); \
+ sudo_vwarn_nodebug((fmt), (ap)); \
} while (0)
-# define vwarningx(fmt, ap) do { \
+# define sudo_vwarnx(fmt, ap) do { \
va_list ap2; \
va_copy(ap2, (ap)); \
sudo_debug_vprintf2(__func__, __FILE__, __LINE__, \
SUDO_DEBUG_WARN|SUDO_DEBUG_LINENO|sudo_debug_subsys, (fmt), ap2); \
- vwarningx_nodebug((fmt), (ap)); \
+ sudo_vwarnx_nodebug((fmt), (ap)); \
} while (0)
#endif /* SUDO_ERROR_WRAP */
extern int (*sudo_printf)(int msg_type, const char *fmt, ...);
-__dso_public int fatal_callback_deregister(void (*func)(void));
-__dso_public int fatal_callback_register(void (*func)(void));
-__dso_public char *warning_gettext(const char *msgid) __format_arg(1);
-__dso_public void fatal_nodebug(const char *, ...) __printf0like(1, 2) __attribute__((__noreturn__));
-__dso_public void fatalx_nodebug(const char *, ...) __printflike(1, 2) __attribute__((__noreturn__));
-__dso_public void vfatal_nodebug(const char *, va_list ap) __printf0like(1, 0) __attribute__((__noreturn__));
-__dso_public void vfatalx_nodebug(const char *, va_list ap) __printflike(1, 0) __attribute__((__noreturn__));
-__dso_public void warning_nodebug(const char *, ...) __printf0like(1, 2);
-__dso_public void warningx_nodebug(const char *, ...) __printflike(1, 2);
-__dso_public void vwarning_nodebug(const char *, va_list ap) __printf0like(1, 0);
-__dso_public void vwarningx_nodebug(const char *, va_list ap) __printflike(1, 0);
+__dso_public int sudo_fatal_callback_deregister(void (*func)(void));
+__dso_public int sudo_fatal_callback_register(void (*func)(void));
+__dso_public char *sudo_warn_gettext(const char *msgid) __format_arg(1);
+__dso_public void sudo_fatal_nodebug(const char *, ...) __printf0like(1, 2) __attribute__((__noreturn__));
+__dso_public void sudo_fatalx_nodebug(const char *, ...) __printflike(1, 2) __attribute__((__noreturn__));
+__dso_public void sudo_vfatal_nodebug(const char *, va_list ap) __printf0like(1, 0) __attribute__((__noreturn__));
+__dso_public void sudo_vfatalx_nodebug(const char *, va_list ap) __printflike(1, 0) __attribute__((__noreturn__));
+__dso_public void sudo_warn_nodebug(const char *, ...) __printf0like(1, 2);
+__dso_public void sudo_warnx_nodebug(const char *, ...) __printflike(1, 2);
+__dso_public void sudo_vwarn_nodebug(const char *, va_list ap) __printf0like(1, 0);
+__dso_public void sudo_vwarnx_nodebug(const char *, va_list ap) __printflike(1, 0);
#endif /* _SUDO_FATAL_H_ */
# define _(String) gettext(String)
# define gettext_noop(String) String
# define N_(String) gettext_noop(String)
-# define U_(String) warning_gettext(String)
+# define U_(String) sudo_warn_gettext(String)
#else /* !HAVE_LIBINTL_H */
debug_decl(aix_setlimits, SUDO_DEBUG_UTIL)
if (setuserdb(S_READ) != 0) {
- warning(U_("unable to open userdb"));
+ sudo_warn(U_("unable to open userdb"));
debug_return_int(-1);
}
if (user != NULL) {
if (setuserdb(S_READ) != 0) {
- warning(U_("unable to open userdb"));
+ sudo_warn(U_("unable to open userdb"));
debug_return_int(-1);
}
if (getuserattr(user, S_REGISTRY, ®istry, SEC_CHAR) == 0) {
if (setauthdb(registry, NULL) != 0) {
- warning(U_("unable to switch to registry \"%s\" for %s"),
+ sudo_warn(U_("unable to switch to registry \"%s\" for %s"),
registry, user);
debug_return_int(-1);
}
debug_decl(aix_setauthdb, SUDO_DEBUG_UTIL)
if (setauthdb(NULL, NULL) != 0) {
- warning(U_("unable to restore registry"));
+ sudo_warn(U_("unable to restore registry"));
debug_return_int(-1);
}
debug_return_int(0);
void *ptr;
if (size == 0)
- fatalx_nodebug(_("internal error, tried to emalloc(0)"));
+ sudo_fatalx_nodebug(_("internal error, tried to emalloc(0)"));
if ((ptr = malloc(size)) == NULL)
- fatal_nodebug(NULL);
+ sudo_fatal_nodebug(NULL);
return ptr;
}
void *ptr;
if (nmemb == 0 || size == 0)
- fatalx_nodebug(_("internal error, tried to emallocarray(0)"));
+ sudo_fatalx_nodebug(_("internal error, tried to emallocarray(0)"));
if (nmemb > SIZE_MAX / size)
- fatalx_nodebug(_("internal error, %s overflow"), "emallocarray");
+ sudo_fatalx_nodebug(_("internal error, %s overflow"), "emallocarray");
size *= nmemb;
if ((ptr = malloc(size)) == NULL)
- fatal_nodebug(NULL);
+ sudo_fatal_nodebug(NULL);
return ptr;
}
void *ptr;
if (nmemb == 0 || size == 0)
- fatalx_nodebug(_("internal error, tried to ecalloc(0)"));
+ sudo_fatalx_nodebug(_("internal error, tried to ecalloc(0)"));
if (nmemb != 1) {
if (nmemb > SIZE_MAX / size)
- fatalx_nodebug(_("internal error, %s overflow"), "ecalloc");
+ sudo_fatalx_nodebug(_("internal error, %s overflow"), "ecalloc");
size *= nmemb;
}
if ((ptr = malloc(size)) == NULL)
- fatal_nodebug(NULL);
+ sudo_fatal_nodebug(NULL);
memset(ptr, 0, size);
return ptr;
}
{
if (size == 0)
- fatalx_nodebug(_("internal error, tried to erealloc(0)"));
+ sudo_fatalx_nodebug(_("internal error, tried to erealloc(0)"));
ptr = ptr ? realloc(ptr, size) : malloc(size);
if (ptr == NULL)
- fatal_nodebug(NULL);
+ sudo_fatal_nodebug(NULL);
return ptr;
}
{
if (nmemb == 0 || size == 0)
- fatalx_nodebug(_("internal error, tried to ereallocarray(0)"));
+ sudo_fatalx_nodebug(_("internal error, tried to ereallocarray(0)"));
if (nmemb > SIZE_MAX / size)
- fatalx_nodebug(_("internal error, %s overflow"), "ereallocarray");
+ sudo_fatalx_nodebug(_("internal error, %s overflow"), "ereallocarray");
size *= nmemb;
ptr = ptr ? realloc(ptr, size) : malloc(size);
if (ptr == NULL)
- fatal_nodebug(NULL);
+ sudo_fatal_nodebug(NULL);
return ptr;
}
size_t size;
if (nmemb == 0 || msize == 0)
- fatalx_nodebug(_("internal error, tried to erecalloc(0)"));
+ sudo_fatalx_nodebug(_("internal error, tried to erecalloc(0)"));
if (nmemb > SIZE_MAX / msize)
- fatalx_nodebug(_("internal error, %s overflow"), "erecalloc");
+ sudo_fatalx_nodebug(_("internal error, %s overflow"), "erecalloc");
size = nmemb * msize;
ptr = ptr ? realloc(ptr, size) : malloc(size);
if (ptr == NULL)
- fatal_nodebug(NULL);
+ sudo_fatal_nodebug(NULL);
if (nmemb > onmemb) {
size = (nmemb - onmemb) * msize;
memset((char *)ptr + (onmemb * msize), 0, size);
va_end(ap);
if (len == -1)
- fatal_nodebug(NULL);
+ sudo_fatal_nodebug(NULL);
return len;
}
int len;
if ((len = vasprintf(ret, format, args)) == -1)
- fatal_nodebug(NULL);
+ sudo_fatal_nodebug(NULL);
return len;
}
}
void
-fatal_nodebug(const char *fmt, ...)
+sudo_fatal_nodebug(const char *fmt, ...)
{
va_list ap;
}
void
-fatalx_nodebug(const char *fmt, ...)
+sudo_fatalx_nodebug(const char *fmt, ...)
{
va_list ap;
}
void
-vfatal_nodebug(const char *fmt, va_list ap)
+sudo_sudo_vfatal_nodebug(const char *fmt, va_list ap)
{
_warning(1, fmt, ap);
do_cleanup();
}
void
-vfatalx_nodebug(const char *fmt, va_list ap)
+sudo_sudo_vfatalx_nodebug(const char *fmt, va_list ap)
{
_warning(0, fmt, ap);
do_cleanup();
}
void
-warning_nodebug(const char *fmt, ...)
+sudo_warn_nodebug(const char *fmt, ...)
{
va_list ap;
}
void
-warningx_nodebug(const char *fmt, ...)
+sudo_warnx_nodebug(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
}
void
-vwarning_nodebug(const char *fmt, va_list ap)
+sudo_vwarn_nodebug(const char *fmt, va_list ap)
{
_warning(1, fmt, ap);
}
void
-vwarningx_nodebug(const char *fmt, va_list ap)
+sudo_vwarnx_nodebug(const char *fmt, va_list ap)
{
_warning(0, fmt, ap);
}
}
/*
- * Register a callback to be run when fatal()/fatalx() is called.
+ * Register a callback to be run when sudo_fatal()/sudo_fatalx() is called.
*/
int
-fatal_callback_register(void (*func)(void))
+sudo_fatal_callback_register(void (*func)(void))
{
struct sudo_fatal_callback *cb;
}
/*
- * Deregister a fatal()/fatalx() callback.
+ * Deregister a sudo_fatal()/sudo_fatalx() callback.
*/
int
-fatal_callback_deregister(void (*func)(void))
+sudo_fatal_callback_deregister(void (*func)(void))
{
struct sudo_fatal_callback *cb, **prev;
if (!exact_match && second_partial_match) {
/* ambiguous abbreviation */
if (PRINT_ERROR)
- warningx(ambig,
+ sudo_warnx(ambig,
#ifdef GNU_COMPATIBLE
current_dash,
#endif
if (long_options[match].has_arg == no_argument
&& has_equal) {
if (PRINT_ERROR)
- warningx(noarg,
+ sudo_warnx(noarg,
#ifdef GNU_COMPATIBLE
current_dash,
#endif
* should be generated.
*/
if (PRINT_ERROR)
- warningx(recargstring,
+ sudo_warnx(recargstring,
#ifdef GNU_COMPATIBLE
current_dash,
#endif
return (-1);
}
if (PRINT_ERROR)
- warningx(illoptstring,
+ sudo_warnx(illoptstring,
#ifdef GNU_COMPATIBLE
current_dash,
#endif
++optind;
#ifdef GNU_COMPATIBLE
if (PRINT_ERROR)
- warningx(posixly_correct ? illoptchar : gnuoptchar,
+ sudo_warnx(posixly_correct ? illoptchar : gnuoptchar,
optchar);
#else
if (PRINT_ERROR)
- warningx(illoptchar, optchar);
+ sudo_warnx(illoptchar, optchar);
#endif
optopt = optchar;
return (BADCH);
else if (++optind >= nargc) { /* no arg */
place = EMSG;
if (PRINT_ERROR)
- warningx(recargchar, optchar);
+ sudo_warnx(recargchar, optchar);
optopt = optchar;
return (BADARG);
} else /* white space */
if (++optind >= nargc) { /* no arg */
place = EMSG;
if (PRINT_ERROR)
- warningx(recargchar, optchar);
+ sudo_warnx(recargchar, optchar);
optopt = optchar;
return (BADARG);
} else
do {
gids[ngids] = (GETGROUPS_T) atoid(cp, ",", &ep, &errstr);
if (errstr != NULL) {
- warningx(U_("%s: %s"), cp, U_(errstr));
+ sudo_warnx(U_("%s: %s"), cp, U_(errstr));
free(gids);
debug_return_int(-1);
}
(*ntests)++;
value = atobool(d->bool_str);
if (value != d->value) {
- warningx_nodebug("FAIL: %s != %d", d->bool_str, d->value);
+ sudo_warnx_nodebug("FAIL: %s != %d", d->bool_str, d->value);
errors++;
}
}
value = atoid(d->idstr, d->sep, &ep, &errstr);
if (errstr != NULL) {
if (d->id != (id_t)-1) {
- warningx_nodebug("FAIL: %s: %s", d->idstr, errstr);
+ sudo_warnx_nodebug("FAIL: %s: %s", d->idstr, errstr);
errors++;
}
} else if (value != d->id) {
- warningx_nodebug("FAIL: %s != %u", d->idstr, (unsigned int)d->id);
+ sudo_warnx_nodebug("FAIL: %s != %u", d->idstr, (unsigned int)d->id);
errors++;
} else if (d->ep != NULL && ep[0] != d->ep[0]) {
- warningx_nodebug("FAIL: ep[0] %d != %d", (int)(unsigned char)ep[0],
+ sudo_warnx_nodebug("FAIL: ep[0] %d != %d", (int)(unsigned char)ep[0],
(int)(unsigned char)d->ep[0]);
errors++;
}
mode = atomode(d->mode_str, &errstr);
if (errstr != NULL) {
if (d->mode != (mode_t)-1) {
- warningx_nodebug("FAIL: %s: %s", d->mode_str, errstr);
+ sudo_warnx_nodebug("FAIL: %s: %s", d->mode_str, errstr);
errors++;
}
} else if (mode != d->mode) {
- warningx_nodebug("FAIL: %s != 0%o", d->mode_str,
+ sudo_warnx_nodebug("FAIL: %s != 0%o", d->mode_str,
(unsigned int) d->mode);
errors++;
}
d1.a = 1;
d1.b = 'a';
if (HLTQ_FIRST(&d1) != &d1) {
- warningx_nodebug("FAIL: HLTQ_FIRST(1 entry) doesn't return first element: got %p, expected %p", HLTQ_FIRST(&d1), &d1);
+ sudo_warnx_nodebug("FAIL: HLTQ_FIRST(1 entry) doesn't return first element: got %p, expected %p", HLTQ_FIRST(&d1), &d1);
errors++;
}
ntests++;
if (HLTQ_LAST(&d1, test_data, entries) != &d1) {
- warningx_nodebug("FAIL: HLTQ_LAST(1 entry) doesn't return first element: got %p, expected %p", HLTQ_LAST(&d1, test_data, entries), &d1);
+ sudo_warnx_nodebug("FAIL: HLTQ_LAST(1 entry) doesn't return first element: got %p, expected %p", HLTQ_LAST(&d1, test_data, entries), &d1);
errors++;
}
ntests++;
if (HLTQ_PREV(&d1, test_data, entries) != NULL) {
- warningx_nodebug("FAIL: HLTQ_PREV(1 entry) doesn't return NULL: got %p", HLTQ_PREV(&d1, test_data, entries));
+ sudo_warnx_nodebug("FAIL: HLTQ_PREV(1 entry) doesn't return NULL: got %p", HLTQ_PREV(&d1, test_data, entries));
errors++;
}
ntests++;
* work as expected.
*/
if (HLTQ_FIRST(hltq) != &d1) {
- warningx_nodebug("FAIL: HLTQ_FIRST(3 entries) doesn't return first element: got %p, expected %p", HLTQ_FIRST(hltq), &d1);
+ sudo_warnx_nodebug("FAIL: HLTQ_FIRST(3 entries) doesn't return first element: got %p, expected %p", HLTQ_FIRST(hltq), &d1);
errors++;
}
ntests++;
if (HLTQ_LAST(hltq, test_data, entries) != &d3) {
- warningx_nodebug("FAIL: HLTQ_LAST(3 entries) doesn't return third element: got %p, expected %p", HLTQ_LAST(hltq, test_data, entries), &d3);
+ sudo_warnx_nodebug("FAIL: HLTQ_LAST(3 entries) doesn't return third element: got %p, expected %p", HLTQ_LAST(hltq, test_data, entries), &d3);
errors++;
}
ntests++;
if (HLTQ_NEXT(&d1, entries) != &d2) {
- warningx_nodebug("FAIL: HLTQ_NEXT(&d1) doesn't return &d2: got %p, expected %p", HLTQ_NEXT(&d1, entries), &d2);
+ sudo_warnx_nodebug("FAIL: HLTQ_NEXT(&d1) doesn't return &d2: got %p, expected %p", HLTQ_NEXT(&d1, entries), &d2);
errors++;
}
ntests++;
if (HLTQ_NEXT(&d2, entries) != &d3) {
- warningx_nodebug("FAIL: HLTQ_NEXT(&d2) doesn't return &d3: got %p, expected %p", HLTQ_NEXT(&d2, entries), &d3);
+ sudo_warnx_nodebug("FAIL: HLTQ_NEXT(&d2) doesn't return &d3: got %p, expected %p", HLTQ_NEXT(&d2, entries), &d3);
errors++;
}
ntests++;
if (HLTQ_NEXT(&d3, entries) != NULL) {
- warningx_nodebug("FAIL: HLTQ_NEXT(&d3) doesn't return NULL: got %p", HLTQ_NEXT(&d3, entries));
+ sudo_warnx_nodebug("FAIL: HLTQ_NEXT(&d3) doesn't return NULL: got %p", HLTQ_NEXT(&d3, entries));
errors++;
}
ntests++;
if (HLTQ_PREV(&d1, test_data, entries) != NULL) {
- warningx_nodebug("FAIL: HLTQ_PREV(&d1) doesn't return NULL: got %p", HLTQ_PREV(&d1, test_data, entries));
+ sudo_warnx_nodebug("FAIL: HLTQ_PREV(&d1) doesn't return NULL: got %p", HLTQ_PREV(&d1, test_data, entries));
errors++;
}
ntests++;
if (HLTQ_PREV(&d2, test_data, entries) != &d1) {
- warningx_nodebug("FAIL: HLTQ_PREV(&d2) doesn't return &d1: got %p, expected %p", HLTQ_PREV(&d2, test_data, entries), &d1);
+ sudo_warnx_nodebug("FAIL: HLTQ_PREV(&d2) doesn't return &d1: got %p, expected %p", HLTQ_PREV(&d2, test_data, entries), &d1);
errors++;
}
ntests++;
if (HLTQ_PREV(&d3, test_data, entries) != &d2) {
- warningx_nodebug("FAIL: HLTQ_PREV(&d3) doesn't return &d2: got %p, expected %p", HLTQ_PREV(&d3, test_data, entries), &d2);
+ sudo_warnx_nodebug("FAIL: HLTQ_PREV(&d3) doesn't return &d2: got %p, expected %p", HLTQ_PREV(&d3, test_data, entries), &d2);
errors++;
}
ntests++;
HLTQ_TO_TAILQ(&tq, hltq, entries);
if (TAILQ_FIRST(&tq) != &d1) {
- warningx_nodebug("FAIL: TAILQ_FIRST(&tq) doesn't return first element: got %p, expected %p", TAILQ_FIRST(&tq), &d1);
+ sudo_warnx_nodebug("FAIL: TAILQ_FIRST(&tq) doesn't return first element: got %p, expected %p", TAILQ_FIRST(&tq), &d1);
errors++;
}
ntests++;
if (TAILQ_LAST(&tq, test_data_list) != &d3) {
- warningx_nodebug("FAIL: TAILQ_LAST(&tq) doesn't return third element: got %p, expected %p", TAILQ_LAST(&tq, test_data_list), &d3);
+ sudo_warnx_nodebug("FAIL: TAILQ_LAST(&tq) doesn't return third element: got %p, expected %p", TAILQ_LAST(&tq, test_data_list), &d3);
errors++;
}
ntests++;
if (TAILQ_NEXT(&d1, entries) != &d2) {
- warningx_nodebug("FAIL: TAILQ_NEXT(&d1) doesn't return &d2: got %p, expected %p", TAILQ_NEXT(&d1, entries), &d2);
+ sudo_warnx_nodebug("FAIL: TAILQ_NEXT(&d1) doesn't return &d2: got %p, expected %p", TAILQ_NEXT(&d1, entries), &d2);
errors++;
}
ntests++;
if (TAILQ_NEXT(&d2, entries) != &d3) {
- warningx_nodebug("FAIL: TAILQ_NEXT(&d2) doesn't return &d3: got %p, expected %p", TAILQ_NEXT(&d2, entries), &d3);
+ sudo_warnx_nodebug("FAIL: TAILQ_NEXT(&d2) doesn't return &d3: got %p, expected %p", TAILQ_NEXT(&d2, entries), &d3);
errors++;
}
ntests++;
if (TAILQ_NEXT(&d3, entries) != NULL) {
- warningx_nodebug("FAIL: TAILQ_NEXT(&d3) doesn't return NULL: got %p", TAILQ_NEXT(&d3, entries));
+ sudo_warnx_nodebug("FAIL: TAILQ_NEXT(&d3) doesn't return NULL: got %p", TAILQ_NEXT(&d3, entries));
errors++;
}
ntests++;
if (TAILQ_PREV(&d1, test_data_list, entries) != NULL) {
- warningx_nodebug("FAIL: TAILQ_PREV(&d1) doesn't return NULL: got %p", TAILQ_PREV(&d1, test_data_list, entries));
+ sudo_warnx_nodebug("FAIL: TAILQ_PREV(&d1) doesn't return NULL: got %p", TAILQ_PREV(&d1, test_data_list, entries));
errors++;
}
ntests++;
if (TAILQ_PREV(&d2, test_data_list, entries) != &d1) {
- warningx_nodebug("FAIL: TAILQ_PREV(&d2) doesn't return &d1: got %p, expected %p", TAILQ_PREV(&d2, test_data_list, entries), &d1);
+ sudo_warnx_nodebug("FAIL: TAILQ_PREV(&d2) doesn't return &d1: got %p, expected %p", TAILQ_PREV(&d2, test_data_list, entries), &d1);
errors++;
}
ntests++;
if (TAILQ_PREV(&d3, test_data_list, entries) != &d2) {
- warningx_nodebug("FAIL: TAILQ_PREV(&d3) doesn't return &d2: got %p, expected %p", TAILQ_PREV(&d3, test_data_list, entries), &d2);
+ sudo_warnx_nodebug("FAIL: TAILQ_PREV(&d3) doesn't return &d2: got %p, expected %p", TAILQ_PREV(&d3, test_data_list, entries), &d2);
errors++;
}
ntests++;
} else if (strcasecmp(entry, "dynamic") == 0) {
sudo_conf_data.group_source = GROUP_SOURCE_DYNAMIC;
} else {
- warningx(U_("unsupported group source `%s' in %s, line %d"), entry,
+ sudo_warnx(U_("unsupported group source `%s' in %s, line %d"), entry,
conf_file, conf_lineno);
}
}
if (max_groups > 0) {
sudo_conf_data.max_groups = max_groups;
} else {
- warningx(U_("invalid max groups `%s' in %s, line %d"), entry,
+ sudo_warnx(U_("invalid max groups `%s' in %s, line %d"), entry,
conf_file, conf_lineno);
}
}
case SUDO_PATH_MISSING:
/* Root should always be able to read sudo.conf. */
if (errno != ENOENT && geteuid() == ROOT_UID)
- warning(U_("unable to stat %s"), conf_file);
+ sudo_warn(U_("unable to stat %s"), conf_file);
goto done;
case SUDO_PATH_BAD_TYPE:
- warningx(U_("%s is not a regular file"), conf_file);
+ sudo_warnx(U_("%s is not a regular file"), conf_file);
goto done;
case SUDO_PATH_WRONG_OWNER:
- warningx(U_("%s is owned by uid %u, should be %u"),
+ sudo_warnx(U_("%s is owned by uid %u, should be %u"),
conf_file, (unsigned int) sb.st_uid, ROOT_UID);
goto done;
case SUDO_PATH_WORLD_WRITABLE:
- warningx(U_("%s is world writable"), conf_file);
+ sudo_warnx(U_("%s is world writable"), conf_file);
goto done;
case SUDO_PATH_GROUP_WRITABLE:
- warningx(U_("%s is group writable"), conf_file);
+ sudo_warnx(U_("%s is group writable"), conf_file);
goto done;
default:
/* NOTREACHED */
if ((fp = fopen(conf_file, "r")) == NULL) {
if (errno != ENOENT && geteuid() == ROOT_UID)
- warning(U_("unable to open %s"), conf_file);
+ sudo_warn(U_("unable to open %s"), conf_file);
goto done;
}
estrdup
estrndup
evasprintf
-fatal_callback_deregister
-fatal_callback_register
-fatal_nodebug
-fatalx_nodebug
+sudo_fatal_callback_deregister
+sudo_fatal_callback_register
+sudo_fatal_nodebug
+sudo_fatalx_nodebug
getprogname
initprogname
isblank
sudo_utimes
sudo_vasprintf
sudo_vsnprintf
-vfatal_nodebug
-vfatalx_nodebug
-vwarning_nodebug
-vwarningx_nodebug
-warning_gettext
-warning_nodebug
-warningx_nodebug
+sudo_vfatal_nodebug
+sudo_vfatalx_nodebug
+sudo_vwarn_nodebug
+sudo_vwarnx_nodebug
+sudo_warn_gettext
+sudo_warn_nodebug
+sudo_warnx_nodebug
debug_decl(sudo_fwtk_init, SUDO_DEBUG_AUTH)
if ((confp = cfg_read("sudo")) == (Cfg *)-1) {
- warningx(U_("unable to read fwtk config"));
+ sudo_warnx(U_("unable to read fwtk config"));
debug_return_int(AUTH_FATAL);
}
if (auth_open(confp)) {
- warningx(U_("unable to connect to authentication server"));
+ sudo_warnx(U_("unable to connect to authentication server"));
debug_return_int(AUTH_FATAL);
}
/* Get welcome message from auth server */
if (auth_recv(resp, sizeof(resp))) {
- warningx(U_("lost connection to authentication server"));
+ sudo_warnx(U_("lost connection to authentication server"));
debug_return_int(AUTH_FATAL);
}
if (strncmp(resp, "Authsrv ready", 13) != 0) {
- warningx(U_("authentication server error:\n%s"), resp);
+ sudo_warnx(U_("authentication server error:\n%s"), resp);
debug_return_int(AUTH_FATAL);
}
(void) snprintf(buf, sizeof(buf), "authorize %s 'sudo'", pw->pw_name);
restart:
if (auth_send(buf) || auth_recv(resp, sizeof(resp))) {
- warningx(U_("lost connection to authentication server"));
+ sudo_warnx(U_("lost connection to authentication server"));
debug_return_int(AUTH_FATAL);
}
strlcpy(buf, "response dummy", sizeof(buf));
goto restart;
} else {
- warningx("%s", resp);
+ sudo_warnx("%s", resp);
debug_return_int(AUTH_FATAL);
}
if (!pass) { /* ^C or error */
/* Send the user's response to the server */
(void) snprintf(buf, sizeof(buf), "response '%s'", pass);
if (auth_send(buf) || auth_recv(resp, sizeof(resp))) {
- warningx(U_("lost connection to authentication server"));
+ sudo_warnx(U_("lost connection to authentication server"));
error = AUTH_FATAL;
goto done;
}
/* Main loop prints "Permission Denied" or insult. */
if (strcmp(resp, "Permission Denied.") != 0)
- warningx("%s", resp);
+ sudo_warnx("%s", resp);
error = AUTH_FAILURE;
done:
memset_s(pass, SUDO_PASS_MAX, 0, strlen(pass));
*/
if (rfc1938challenge(&rfc1938, pw->pw_name, challenge, sizeof(challenge))) {
if (IS_ONEANDONLY(auth)) {
- warningx(U_("you do not exist in the %s database"), auth->name);
+ sudo_warnx(U_("you do not exist in the %s database"), auth->name);
debug_return_int(AUTH_FATAL);
} else {
debug_return_int(AUTH_FAILURE);
if (AceInitialize() != SD_FALSE)
debug_return_int(AUTH_SUCCESS);
- warningx(U_("failed to initialise the ACE API library"));
+ sudo_warnx(U_("failed to initialise the ACE API library"));
debug_return_int(AUTH_FATAL);
}
/* Re-initialize SecurID every time. */
if (SD_Init(sd) != ACM_OK) {
- warningx(U_("unable to contact the SecurID server"));
+ sudo_warnx(U_("unable to contact the SecurID server"));
debug_return_int(AUTH_FATAL);
}
switch (retval) {
case ACM_OK:
- warningx(U_("User ID locked for SecurID Authentication"));
+ sudo_warnx(U_("User ID locked for SecurID Authentication"));
debug_return_int(AUTH_SUCCESS);
case ACE_UNDEFINED_USERNAME:
- warningx(U_("invalid username length for SecurID"));
+ sudo_warnx(U_("invalid username length for SecurID"));
debug_return_int(AUTH_FATAL);
case ACE_ERR_INVALID_HANDLE:
- warningx(U_("invalid Authentication Handle for SecurID"));
+ sudo_warnx(U_("invalid Authentication Handle for SecurID"));
debug_return_int(AUTH_FATAL);
case ACM_ACCESS_DENIED:
- warningx(U_("SecurID communication failed"));
+ sudo_warnx(U_("SecurID communication failed"));
debug_return_int(AUTH_FATAL);
default:
- warningx(U_("unknown SecurID error"));
+ sudo_warnx(U_("unknown SecurID error"));
debug_return_int(AUTH_FATAL);
}
}
break;
case ACE_UNDEFINED_PASSCODE:
- warningx(U_("invalid passcode length for SecurID"));
+ sudo_warnx(U_("invalid passcode length for SecurID"));
rval = AUTH_FATAL;
break;
case ACE_UNDEFINED_USERNAME:
- warningx(U_("invalid username length for SecurID"));
+ sudo_warnx(U_("invalid username length for SecurID"));
rval = AUTH_FATAL;
break;
case ACE_ERR_INVALID_HANDLE:
- warningx(U_("invalid Authentication Handle for SecurID"));
+ sudo_warnx(U_("invalid Authentication Handle for SecurID"));
rval = AUTH_FATAL;
break;
break;
default:
- warningx(U_("unknown SecurID error"));
+ sudo_warnx(U_("unknown SecurID error"));
rval = AUTH_FATAL;
break;
}
auditinfo_t ainfo;
/* Fall back to older BSM API. */
if (getaudit(&ainfo) < 0) {
- warning("getaudit");
+ sudo_warn("getaudit");
debug_return_int(-1);
}
mask = &ainfo.ai_mask;
} else {
- warning("getaudit_addr");
+ sudo_warn("getaudit_addr");
debug_return_int(-1);
}
} else {
if (auditon(A_GETCOND, (caddr_t)&au_cond, sizeof(long)) < 0) {
if (errno == AUDIT_NOT_CONFIGURED)
debug_return_int(0);
- warning(U_("Could not determine audit condition"));
+ sudo_warn(U_("Could not determine audit condition"));
debug_return_int(-1);
}
if (au_cond == AUC_NOAUDIT)
if (selected != 1)
debug_return_int(!selected ? 0 : -1);
if (getauid(&auid) < 0) {
- warning("getauid");
+ sudo_warn("getauid");
debug_return_int(-1);
}
if ((aufd = au_open()) == -1) {
- warning("au_open");
+ sudo_warn("au_open");
debug_return_int(-1);
}
pid = getpid();
* NB: We should probably watch out for ERANGE here.
*/
if (getaudit(&ainfo) < 0) {
- warning("getaudit");
+ sudo_warn("getaudit");
debug_return_int(-1);
}
tok = au_to_subject(auid, geteuid(), getegid(), getuid(),
getuid(), pid, pid, &ainfo.ai_termid);
} else {
- warning("getaudit_addr");
+ sudo_warn("getaudit_addr");
debug_return_int(-1);
}
if (tok == NULL) {
- warning("au_to_subject");
+ sudo_warn("au_to_subject");
debug_return_int(-1);
}
au_write(aufd, tok);
tok = au_to_exec_args(exec_args);
if (tok == NULL) {
- warning("au_to_exec_args");
+ sudo_warn("au_to_exec_args");
debug_return_int(-1);
}
au_write(aufd, tok);
tok = au_to_return32(0, 0);
if (tok == NULL) {
- warning("au_to_return32");
+ sudo_warn("au_to_return32");
debug_return_int(-1);
}
au_write(aufd, tok);
if (au_close(aufd, 1, AUE_sudo) == -1)
#endif
{
- warning(U_("unable to commit audit record"));
+ sudo_warn(U_("unable to commit audit record"));
debug_return_int(-1);
}
debug_return_int(0);
if (auditon(A_GETCOND, (caddr_t)&au_cond, sizeof(long)) < 0) {
if (errno == AUDIT_NOT_CONFIGURED)
debug_return_int(0);
- warning(U_("Could not determine audit condition"));
+ sudo_warn(U_("Could not determine audit condition"));
debug_return_int(-1);
}
if (au_cond == AUC_NOAUDIT)
if (!audit_sudo_selected(AU_PRS_FAILURE))
debug_return_int(0);
if (getauid(&auid) < 0) {
- warning("getauid");
+ sudo_warn("getauid");
debug_return_int(-1);
}
if ((aufd = au_open()) == -1) {
- warning("au_open");
+ sudo_warn("au_open");
debug_return_int(-1);
}
pid = getpid();
getuid(), pid, pid, &ainfo_addr.ai_termid);
} else if (errno == ENOSYS) {
if (getaudit(&ainfo) < 0) {
- warning("getaudit");
+ sudo_warn("getaudit");
debug_return_int(-1);
}
tok = au_to_subject(auid, geteuid(), getegid(), getuid(),
getuid(), pid, pid, &ainfo.ai_termid);
} else {
- warning("getaudit_addr");
+ sudo_warn("getaudit_addr");
debug_return_int(-1);
}
if (tok == NULL) {
- warning("au_to_subject");
+ sudo_warn("au_to_subject");
debug_return_int(-1);
}
au_write(aufd, tok);
tok = au_to_exec_args(exec_args);
if (tok == NULL) {
- warning("au_to_exec_args");
+ sudo_warn("au_to_exec_args");
debug_return_int(-1);
}
au_write(aufd, tok);
(void) vsnprintf(text, sizeof(text), fmt, ap);
tok = au_to_text(text);
if (tok == NULL) {
- warning("au_to_text");
+ sudo_warn("au_to_text");
debug_return_int(-1);
}
au_write(aufd, tok);
tok = au_to_return32(EPERM, 1);
if (tok == NULL) {
- warning("au_to_return32");
+ sudo_warn("au_to_return32");
debug_return_int(-1);
}
au_write(aufd, tok);
if (au_close(aufd, 1, AUE_sudo) == -1)
#endif
{
- warning(U_("unable to commit audit record"));
+ sudo_warn(U_("unable to commit audit record"));
debug_return_int(-1);
}
debug_return_int(0);
break;
}
if (!cur->name) {
- warningx(U_("unknown defaults entry `%s'"), var);
+ sudo_warnx(U_("unknown defaults entry `%s'"), var);
debug_return_bool(false);
}
case T_LOGFAC:
if (!store_syslogfac(val, cur, op)) {
if (val)
- warningx(U_("value `%s' is invalid for option `%s'"),
+ sudo_warnx(U_("value `%s' is invalid for option `%s'"),
val, var);
else
- warningx(U_("no value specified for `%s'"), var);
+ sudo_warnx(U_("no value specified for `%s'"), var);
debug_return_bool(false);
}
break;
case T_LOGPRI:
if (!store_syslogpri(val, cur, op)) {
if (val)
- warningx(U_("value `%s' is invalid for option `%s'"),
+ sudo_warnx(U_("value `%s' is invalid for option `%s'"),
val, var);
else
- warningx(U_("no value specified for `%s'"), var);
+ sudo_warnx(U_("no value specified for `%s'"), var);
debug_return_bool(false);
}
break;
if (!val) {
/* Check for bogus boolean usage or lack of a value. */
if (!ISSET(cur->type, T_BOOL) || op != false) {
- warningx(U_("no value specified for `%s'"), var);
+ sudo_warnx(U_("no value specified for `%s'"), var);
debug_return_bool(false);
}
}
if (ISSET(cur->type, T_PATH) && val && *val != '/') {
- warningx(U_("values for `%s' must start with a '/'"), var);
+ sudo_warnx(U_("values for `%s' must start with a '/'"), var);
debug_return_bool(false);
}
if (!store_str(val, cur, op)) {
- warningx(U_("value `%s' is invalid for option `%s'"), val, var);
+ sudo_warnx(U_("value `%s' is invalid for option `%s'"), val, var);
debug_return_bool(false);
}
break;
if (!val) {
/* Check for bogus boolean usage or lack of a value. */
if (!ISSET(cur->type, T_BOOL) || op != false) {
- warningx(U_("no value specified for `%s'"), var);
+ sudo_warnx(U_("no value specified for `%s'"), var);
debug_return_bool(false);
}
}
if (!store_int(val, cur, op)) {
- warningx(U_("value `%s' is invalid for option `%s'"), val, var);
+ sudo_warnx(U_("value `%s' is invalid for option `%s'"), val, var);
debug_return_bool(false);
}
break;
if (!val) {
/* Check for bogus boolean usage or lack of a value. */
if (!ISSET(cur->type, T_BOOL) || op != false) {
- warningx(U_("no value specified for `%s'"), var);
+ sudo_warnx(U_("no value specified for `%s'"), var);
debug_return_bool(false);
}
}
if (!store_uint(val, cur, op)) {
- warningx(U_("value `%s' is invalid for option `%s'"), val, var);
+ sudo_warnx(U_("value `%s' is invalid for option `%s'"), val, var);
debug_return_bool(false);
}
break;
if (!val) {
/* Check for bogus boolean usage or lack of a value. */
if (!ISSET(cur->type, T_BOOL) || op != false) {
- warningx(U_("no value specified for `%s'"), var);
+ sudo_warnx(U_("no value specified for `%s'"), var);
debug_return_bool(false);
}
}
if (!store_float(val, cur, op)) {
- warningx(U_("value `%s' is invalid for option `%s'"), val, var);
+ sudo_warnx(U_("value `%s' is invalid for option `%s'"), val, var);
debug_return_bool(false);
}
break;
if (!val) {
/* Check for bogus boolean usage or lack of a value. */
if (!ISSET(cur->type, T_BOOL) || op != false) {
- warningx(U_("no value specified for `%s'"), var);
+ sudo_warnx(U_("no value specified for `%s'"), var);
debug_return_bool(false);
}
}
if (!store_mode(val, cur, op)) {
- warningx(U_("value `%s' is invalid for option `%s'"), val, var);
+ sudo_warnx(U_("value `%s' is invalid for option `%s'"), val, var);
debug_return_bool(false);
}
break;
case T_FLAG:
if (val) {
- warningx(U_("option `%s' does not take a value"), var);
+ sudo_warnx(U_("option `%s' does not take a value"), var);
debug_return_bool(false);
}
cur->sd_un.flag = op;
if (!val) {
/* Check for bogus boolean usage or lack of a value. */
if (!ISSET(cur->type, T_BOOL) || op != false) {
- warningx(U_("no value specified for `%s'"), var);
+ sudo_warnx(U_("no value specified for `%s'"), var);
debug_return_bool(false);
}
}
if (!store_list(val, cur, op)) {
- warningx(U_("value `%s' is invalid for option `%s'"), val, var);
+ sudo_warnx(U_("value `%s' is invalid for option `%s'"), val, var);
debug_return_bool(false);
}
break;
case T_TUPLE:
if (!val && !ISSET(cur->type, T_BOOL)) {
- warningx(U_("no value specified for `%s'"), var);
+ sudo_warnx(U_("no value specified for `%s'"), var);
debug_return_bool(false);
}
if (!store_tuple(val, cur, op)) {
- warningx(U_("value `%s' is invalid for option `%s'"), val, var);
+ sudo_warnx(U_("value `%s' is invalid for option `%s'"), val, var);
debug_return_bool(false);
}
break;
}
if (cur->name == NULL) {
if (!quiet)
- warningx(U_("unknown defaults entry `%s'"), def->var);
+ sudo_warnx(U_("unknown defaults entry `%s'"), def->var);
rc = false;
}
}
size_t nsize;
if (env.env_size > SIZE_MAX - 128) {
- warningx_nodebug(U_("internal error, %s overflow"),
+ sudo_warnx_nodebug(U_("internal error, %s overflow"),
"sudo_putenv_nodebug");
errno = EOVERFLOW;
return -1;
}
nsize = env.env_size + 128;
if (nsize > SIZE_MAX / sizeof(char *)) {
- warningx_nodebug(U_("internal error, %s overflow"),
+ sudo_warnx_nodebug(U_("internal error, %s overflow"),
"sudo_putenv_nodebug");
errno = EOVERFLOW;
return -1;
if (rval == -1) {
#ifdef ENV_DEBUG
if (env.envp[env.env_len] != NULL)
- warningx(U_("sudo_putenv: corrupted envp, length mismatch"));
+ sudo_warnx(U_("sudo_putenv: corrupted envp, length mismatch"));
#endif
}
debug_return_int(rval);
strlcat(estring, "=", esize) >= esize ||
strlcat(estring, val, esize) >= esize) {
- warningx(U_("internal error, %s overflow"), __func__);
+ sudo_warnx(U_("internal error, %s overflow"), __func__);
errno = EOVERFLOW;
} else {
rval = sudo_putenv(estring, dupcheck, overwrite);
}
if (len <= 0 || (size_t)len >= sizeof(path)) {
errno = ENAMETOOLONG;
- warning("%s%s",
+ sudo_warn("%s%s",
(*plugin_info != '/') ? _PATH_SUDO_PLUGIN_DIR : "", plugin_info);
goto done;
}
/* Sanity check plugin path. */
if (stat(path, &sb) != 0) {
- warning("%s", path);
+ sudo_warn("%s", path);
goto done;
}
if (sb.st_uid != ROOT_UID) {
- warningx(U_("%s must be owned by uid %d"), path, ROOT_UID);
+ sudo_warnx(U_("%s must be owned by uid %d"), path, ROOT_UID);
goto done;
}
if ((sb.st_mode & (S_IWGRP|S_IWOTH)) != 0) {
- warningx(U_("%s must only be writable by owner"), path);
+ sudo_warnx(U_("%s must only be writable by owner"), path);
goto done;
}
/* Open plugin and map in symbol. */
group_handle = sudo_dso_load(path, SUDO_DSO_LAZY|SUDO_DSO_GLOBAL);
if (!group_handle) {
- warningx(U_("unable to load %s: %s"), path, sudo_dso_strerror());
+ sudo_warnx(U_("unable to load %s: %s"), path, sudo_dso_strerror());
goto done;
}
group_plugin = sudo_dso_findsym(group_handle, "group_plugin");
if (group_plugin == NULL) {
- warningx(U_("unable to find symbol \"group_plugin\" in %s"), path);
+ sudo_warnx(U_("unable to find symbol \"group_plugin\" in %s"), path);
goto done;
}
if (GROUP_API_VERSION_GET_MAJOR(group_plugin->version) != GROUP_API_VERSION_MAJOR) {
- warningx(U_("%s: incompatible group plugin major version %d, expected %d"),
+ sudo_warnx(U_("%s: incompatible group plugin major version %d, expected %d"),
path, GROUP_API_VERSION_GET_MAJOR(group_plugin->version),
GROUP_API_VERSION_MAJOR);
goto done;
if (runas_uid_str != NULL) {
id = atoid(runas_uid_str, NULL, NULL, &errstr);
if (errstr != NULL)
- warningx("runas uid %s: %s", runas_uid_str, U_(errstr));
+ sudo_warnx("runas uid %s: %s", runas_uid_str, U_(errstr));
else
runas_uid = (uid_t)id;
}
if (runas_gid_str != NULL) {
id = atoid(runas_gid_str, NULL, NULL, &errstr);
if (errstr != NULL)
- warningx("runas gid %s: %s", runas_gid_str, U_(errstr));
+ sudo_warnx("runas gid %s: %s", runas_gid_str, U_(errstr));
else
runas_gid = (gid_t)id;
}
#if defined(__GNUC__) && __GNUC__ == 2
# define DPRINTF1(fmt...) do { \
if (ldap_conf.debug >= 1) \
- warningx(__VA_ARGS__); \
+ sudo_warnx(__VA_ARGS__); \
sudo_debug_printf(SUDO_DEBUG_DIAG, fmt); \
} while (0)
# define DPRINTF2(fmt...) do { \
if (ldap_conf.debug >= 2) \
- warningx(__VA_ARGS__); \
+ sudo_warnx(__VA_ARGS__); \
sudo_debug_printf(SUDO_DEBUG_INFO, fmt); \
} while (0)
#else
# define DPRINTF1(...) do { \
if (ldap_conf.debug >= 1) \
- warningx(__VA_ARGS__); \
+ sudo_warnx(__VA_ARGS__); \
sudo_debug_printf(SUDO_DEBUG_DIAG, __VA_ARGS__); \
} while (0)
# define DPRINTF2(...) do { \
if (ldap_conf.debug >= 2) \
- warningx(__VA_ARGS__); \
+ sudo_warnx(__VA_ARGS__); \
sudo_debug_printf(SUDO_DEBUG_INFO, __VA_ARGS__); \
} while (0)
#endif
hostbuf[0] = '\0';
len = snprintf(defport, sizeof(defport), ":%d", ldap_conf.port);
if (len <= 0 || (size_t)len >= sizeof(defport)) {
- warningx(U_("sudo_ldap_conf_add_ports: port too large"));
+ sudo_warnx(U_("sudo_ldap_conf_add_ports: port too large"));
debug_return_bool(false);
}
debug_return_bool(true);
toobig:
- warningx(U_("sudo_ldap_conf_add_ports: out of space expanding hostbuf"));
+ sudo_warnx(U_("sudo_ldap_conf_add_ports: out of space expanding hostbuf"));
debug_return_bool(false);
}
#endif
nldaps++;
host = uri + 8;
} else {
- warningx(U_("unsupported LDAP uri type: %s"), uri);
+ sudo_warnx(U_("unsupported LDAP uri type: %s"), uri);
goto done;
}
if (nldaps != 0) {
if (nldap != 0) {
- warningx(U_("unable to mix ldap and ldaps URIs"));
+ sudo_warnx(U_("unable to mix ldap and ldaps URIs"));
goto done;
}
if (ldap_conf.ssl_mode == SUDO_LDAP_STARTTLS)
- warningx(U_("starttls not supported when using ldaps"));
+ sudo_warnx(U_("starttls not supported when using ldaps"));
ldap_conf.ssl_mode = SUDO_LDAP_SSL;
}
efree(buf);
debug_return_int(rc);
toobig:
- warningx(U_("sudo_ldap_parse_uri: out of space building hostbuf"));
+ sudo_warnx(U_("sudo_ldap_parse_uri: out of space building hostbuf"));
debug_return_int(-1);
}
#else
STAILQ_FOREACH(uri, uri_list, entries) {
if (ldap_conf.ssl_mode == SUDO_LDAP_STARTTLS) {
if (strncasecmp(uri->val, "ldaps://", 8) == 0) {
- warningx(U_("starttls not supported when using ldaps"));
+ sudo_warnx(U_("starttls not supported when using ldaps"));
ldap_conf.ssl_mode = SUDO_LDAP_SSL;
}
}
}
}
if (rc != LDAP_SUCCESS) {
- warningx(U_("unable to initialize SSL cert and key db: %s"),
+ sudo_warnx(U_("unable to initialize SSL cert and key db: %s"),
ldapssl_err2string(rc));
if (ldap_conf.tls_certfile == NULL)
- warningx(U_("you must set TLS_CERT in %s to use SSL"),
+ sudo_warnx(U_("you must set TLS_CERT in %s to use SSL"),
path_ldap_conf);
goto done;
}
rc = ldap_ssl_client_init(ldap_conf.tls_keyfile, ldap_conf.tls_keypw,
0, &sslrc);
if (rc != LDAP_SUCCESS) {
- warningx("ldap_ssl_client_init(): %s (SSL reason code %d)",
+ sudo_warnx("ldap_ssl_client_init(): %s (SSL reason code %d)",
ldap_err2string(rc), sslrc);
goto done;
}
/* Make sure we have a formatted timestamp for __now__. */
time(&now);
if ((tp = gmtime(&now)) == NULL) {
- warning(U_("unable to get GMT time"));
+ sudo_warn(U_("unable to get GMT time"));
goto done;
}
/* Format the timestamp according to the RFC. */
if (strftime(timebuffer, sizeof(timebuffer), "%Y%m%d%H%M%S.0Z", tp) == 0) {
- warningx(U_("unable to format timestamp"));
+ sudo_warnx(U_("unable to format timestamp"));
goto done;
}
bytes = snprintf(buffer, buffersize, "(&(|(!(sudoNotAfter=*))(sudoNotAfter>=%s))(|(!(sudoNotBefore=*))(sudoNotBefore<=%s)))",
timebuffer, timebuffer);
if (bytes <= 0 || (size_t)bytes >= buffersize) {
- warning(U_("unable to build time filter"));
+ sudo_warn(U_("unable to build time filter"));
bytes = 0;
}
/* Add ALL to list and end the global OR */
if (strlcat(buf, "(sudoUser=ALL)", sz) >= sz) {
- warningx(U_("sudo_ldap_build_pass1 allocation mismatch"));
+ sudo_warnx(U_("sudo_ldap_build_pass1 allocation mismatch"));
debug_return_str(NULL);
}
case CONF_INT:
*(int *)(cur->valp) = strtonum(value, INT_MIN, INT_MAX, &errstr);
if (errstr != NULL) {
- warningx(U_("%s: %s: %s: %s"),
+ sudo_warnx(U_("%s: %s: %s: %s"),
path_ldap_conf, keyword, value, U_(errstr));
}
break;
do {
nwritten = write(nfd, buf + off, nread - off);
if (nwritten == -1) {
- warning("error writing to %s", new_ccname);
+ sudo_warn("error writing to %s", new_ccname);
goto write_error;
}
off += nwritten;
} while (off < nread);
}
if (nread == -1)
- warning("unable to read %s", new_ccname);
+ sudo_warn("unable to read %s", new_ccname);
write_error:
close(nfd);
if (nread != -1 && nwritten != -1) {
unlink(new_ccname); /* failed */
}
} else {
- warning("unable to create temp file %s", new_ccname);
+ sudo_warn("unable to create temp file %s", new_ccname);
}
}
close(ofd);
for (; interact->id != SASL_CB_LIST_END; interact++) {
if (interact->id != SASL_CB_USER) {
- warningx("sudo_ldap_sasl_interact: unexpected interact id %lu",
+ sudo_warnx("sudo_ldap_sasl_interact: unexpected interact id %lu",
interact->id);
rc = LDAP_PARAM_ERROR;
break;
DPRINTF1("ldap_set_option: %s -> %d", cur->conf_str, ival);
rc = ldap_set_option(ld, cur->opt_val, &ival);
if (rc != LDAP_OPT_SUCCESS) {
- warningx("ldap_set_option: %s -> %d: %s",
+ sudo_warnx("ldap_set_option: %s -> %d: %s",
cur->conf_str, ival, ldap_err2string(rc));
errors++;
}
DPRINTF1("ldap_set_option: %s -> %s", cur->conf_str, sval);
rc = ldap_set_option(ld, cur->opt_val, sval);
if (rc != LDAP_OPT_SUCCESS) {
- warningx("ldap_set_option: %s -> %s: %s",
+ sudo_warnx("ldap_set_option: %s -> %s: %s",
cur->conf_str, sval, ldap_err2string(rc));
errors++;
}
DPRINTF1("ldap_set_option(LDAP_OPT_TIMEOUT, %d)", ldap_conf.timeout);
rc = ldap_set_option(ld, LDAP_OPT_TIMEOUT, &tv);
if (rc != LDAP_OPT_SUCCESS) {
- warningx("ldap_set_option(TIMEOUT, %d): %s",
+ sudo_warnx("ldap_set_option(TIMEOUT, %d): %s",
ldap_conf.timeout, ldap_err2string(rc));
}
}
# if !defined(LDAP_OPT_CONNECT_TIMEOUT) || LDAP_VENDOR_VERSION != 510
/* Tivoli Directory Server 6.3 libs always return a (bogus) error. */
if (rc != LDAP_OPT_SUCCESS) {
- warningx("ldap_set_option(NETWORK_TIMEOUT, %d): %s",
+ sudo_warnx("ldap_set_option(NETWORK_TIMEOUT, %d): %s",
ldap_conf.bind_timelimit / 1000, ldap_err2string(rc));
}
# endif
DPRINTF1("ldap_set_option(LDAP_OPT_X_TLS, LDAP_OPT_X_TLS_HARD)");
rc = ldap_set_option(ld, LDAP_OPT_X_TLS, &val);
if (rc != LDAP_SUCCESS) {
- warningx("ldap_set_option(LDAP_OPT_X_TLS, LDAP_OPT_X_TLS_HARD): %s",
+ sudo_warnx("ldap_set_option(LDAP_OPT_X_TLS, LDAP_OPT_X_TLS_HARD): %s",
ldap_err2string(rc));
debug_return_int(-1);
}
unlink(tmp_ccname);
}
if (rc != LDAP_SUCCESS) {
- warningx("ldap_sasl_interactive_bind_s(): %s",
+ sudo_warnx("ldap_sasl_interactive_bind_s(): %s",
ldap_err2string(rc));
goto done;
}
rc = ldap_sasl_bind_s(ld, ldap_conf.binddn, LDAP_SASL_SIMPLE, &bv,
NULL, NULL, NULL);
if (rc != LDAP_SUCCESS) {
- warningx("ldap_sasl_bind_s(): %s", ldap_err2string(rc));
+ sudo_warnx("ldap_sasl_bind_s(): %s", ldap_err2string(rc));
goto done;
}
DPRINTF1("ldap_sasl_bind_s() ok");
{
rc = ldap_simple_bind_s(ld, ldap_conf.binddn, ldap_conf.bindpw);
if (rc != LDAP_SUCCESS) {
- warningx("ldap_simple_bind_s(): %s", ldap_err2string(rc));
+ sudo_warnx("ldap_simple_bind_s(): %s", ldap_err2string(rc));
goto done;
}
DPRINTF1("ldap_simple_bind_s() ok");
rc = ldap_initialize(&ld, buf);
efree(buf);
if (rc != LDAP_SUCCESS) {
- warningx(U_("unable to initialize LDAP: %s"),
+ sudo_warnx(U_("unable to initialize LDAP: %s"),
ldap_err2string(rc));
}
}
#if defined(HAVE_LDAP_START_TLS_S)
rc = ldap_start_tls_s(ld, NULL, NULL);
if (rc != LDAP_SUCCESS) {
- warningx("ldap_start_tls_s(): %s", ldap_err2string(rc));
+ sudo_warnx("ldap_start_tls_s(): %s", ldap_err2string(rc));
goto done;
}
DPRINTF1("ldap_start_tls_s() ok");
rc = ldap_ssl_client_init(ldap_conf.tls_keyfile, ldap_conf.tls_keypw,
0, &sslrc);
if (rc != LDAP_SUCCESS) {
- warningx("ldap_ssl_client_init(): %s (SSL reason code %d)",
+ sudo_warnx("ldap_ssl_client_init(): %s (SSL reason code %d)",
ldap_err2string(rc), sslrc);
goto done;
}
rc = ldap_start_tls_s_np(ld, NULL);
if (rc != LDAP_SUCCESS) {
- warningx("ldap_start_tls_s_np(): %s", ldap_err2string(rc));
+ sudo_warnx("ldap_start_tls_s_np(): %s", ldap_err2string(rc));
goto done;
}
DPRINTF1("ldap_start_tls_s_np() ok");
#else
- warningx(U_("start_tls specified but LDAP libs do not support ldap_start_tls_s() or ldap_start_tls_s_np()"));
+ sudo_warnx(U_("start_tls specified but LDAP libs do not support ldap_start_tls_s() or ldap_start_tls_s_np()"));
#endif /* !HAVE_LDAP_START_TLS_S && !HAVE_LDAP_START_TLS_S_NP */
}
DPRINTF2("order attribute raw: %s", (*bv)->bv_val);
order = strtod((*bv)->bv_val, &ep);
if (ep == (*bv)->bv_val || *ep != '\0') {
- warningx(U_("invalid sudoOrder attribute: %s"), (*bv)->bv_val);
+ sudo_warnx(U_("invalid sudoOrder attribute: %s"), (*bv)->bv_val);
order = 0.0;
}
DPRINTF2("order attribute: %f", order);
if (au_fd == -1) {
/* Kernel may not have audit support. */
if (errno != EINVAL && errno != EPROTONOSUPPORT && errno != EAFNOSUPPORT) {
- warning(U_("unable to open audit system"));
+ sudo_warn(U_("unable to open audit system"));
au_fd == AUDIT_NOT_CONFIGURED;
}
} else {
for (av = argv; *av != NULL; av++) {
n = strlcpy(cp, *av, size - (cp - command));
if (n >= size - (cp - command)) {
- warningx(U_("internal error, %s overflow"), __func__);
+ sudo_warnx(U_("internal error, %s overflow"), __func__);
goto done;
}
cp += n;
/* Log command, ignoring ECONNREFUSED on error. */
if (audit_log_user_command(au_fd, AUDIT_USER_CMD, command, NULL, result) <= 0) {
if (errno != ECONNREFUSED) {
- warning(U_("unable to send audit message"));
+ sudo_warn(U_("unable to send audit message"));
goto done;
}
}
#ifdef HAVE_LIBINTL_H
char *
-warning_gettext(const char *msgid)
+sudo_warn_gettext(const char *msgid)
{
int warning_locale;
char *msg;
* their path to just contain a single dir.
*/
if (flags == NOT_FOUND)
- warningx(U_("%s: command not found"), user_cmnd);
+ sudo_warnx(U_("%s: command not found"), user_cmnd);
else if (flags == NOT_FOUND_DOT)
- warningx(U_("ignoring `%s' found in '.'\nUse `sudo ./%s' if this is the `%s' you wish to run."), user_cmnd, user_cmnd, user_cmnd);
+ sudo_warnx(U_("ignoring `%s' found in '.'\nUse `sudo ./%s' if this is the `%s' you wish to run."), user_cmnd, user_cmnd, user_cmnd);
}
debug_return;
va_list ap2;
debug_decl(vlog_error, SUDO_DEBUG_LOGGING)
- /* Need extra copy of ap for vwarning()/vwarningx() below. */
+ /* Need extra copy of ap for sudo_vwarn()/sudo_vwarnx() below. */
if (!ISSET(flags, SLOG_NO_STDERR))
va_copy(ap2, ap);
sudoers_setlocale(SUDOERS_LOCALE_USER, &oldlocale);
if (fmt == INCORRECT_PASSWORD_ATTEMPT) {
unsigned int tries = va_arg(ap2, unsigned int);
- warningx_nodebug(ngettext("%u incorrect password attempt",
+ sudo_warnx_nodebug(ngettext("%u incorrect password attempt",
"%u incorrect password attempts", tries), tries);
} else {
if (ISSET(flags, SLOG_USE_ERRNO))
- vwarning_nodebug(_(fmt), ap2);
+ sudo_vwarn_nodebug(_(fmt), ap2);
else
- vwarningx_nodebug(_(fmt), ap2);
+ sudo_vwarnx_nodebug(_(fmt), ap2);
}
sudoers_setlocale(oldlocale, NULL);
va_end(ap2);
switch (pid = sudo_debug_fork()) {
case -1:
/* Error. */
- warning(U_("unable to fork"));
+ sudo_warn(U_("unable to fork"));
debug_return_int(false);
break;
case 0:
/* Daemonize - disassociate from session/tty. */
if (setsid() == -1)
- warning("setsid");
+ sudo_warn("setsid");
if (chdir("/") == -1)
- warning("chdir(/)");
+ sudo_warn("chdir(/)");
if ((fd = open(_PATH_DEVNULL, O_RDWR, 0644)) != -1) {
(void) dup2(fd, STDIN_FILENO);
(void) dup2(fd, STDOUT_FILENO);
debug_return_str(line);
toobig:
- warningx(U_("internal error, %s overflow"), __func__);
+ sudo_warnx(U_("internal error, %s overflow"), __func__);
debug_return_str(NULL);
}
}
}
if (func == NULL) {
- warningx(U_("unsupported digest type %d for %s"), sd->digest_type, file);
+ sudo_warnx(U_("unsupported digest type %d for %s"), sd->digest_type, file);
debug_return_bool(false);
}
if (strlen(sd->digest_str) == func->digest_len * 2) {
func->update(&ctx, buf, nread);
}
if (ferror(fp)) {
- warningx(U_("%s: read error"), file);
+ sudo_warnx(U_("%s: read error"), file);
fclose(fp);
debug_return_bool(false);
}
func->digest_name, file, sd->digest_str);
debug_return_bool(false);
bad_format:
- warningx(U_("digest for %s (%s) is not in %s form"), file,
+ sudo_warnx(U_("digest for %s (%s) is not in %s form"), file,
sd->digest_str, func->digest_name);
debug_return_bool(false);
}
p = *cur + sizeof("sudoers_uid=") - 1;
sudoers_uid = (uid_t) atoid(p, NULL, NULL, &errstr);
if (errstr != NULL) {
- warningx(U_("%s: %s"), *cur, U_(errstr));
+ sudo_warnx(U_("%s: %s"), *cur, U_(errstr));
goto bad;
}
continue;
p = *cur + sizeof("sudoers_gid=") - 1;
sudoers_gid = (gid_t) atoid(p, NULL, NULL, &errstr);
if (errstr != NULL) {
- warningx(U_("%s: %s"), *cur, U_(errstr));
+ sudo_warnx(U_("%s: %s"), *cur, U_(errstr));
goto bad;
}
continue;
p = *cur + sizeof("sudoers_mode=") - 1;
sudoers_mode = atomode(p, &errstr);
if (errstr != NULL) {
- warningx(U_("%s: %s"), *cur, U_(errstr));
+ sudo_warnx(U_("%s: %s"), *cur, U_(errstr));
goto bad;
}
continue;
p = *cur + sizeof("closefrom=") - 1;
user_closefrom = strtonum(p, 4, INT_MAX, &errstr);
if (user_closefrom == 0) {
- warningx(U_("%s: %s"), *cur, U_(errstr));
+ sudo_warnx(U_("%s: %s"), *cur, U_(errstr));
goto bad;
}
continue;
p = *cur + sizeof("max_groups=") - 1;
sudo_user.max_groups = strtonum(p, 1, INT_MAX, &errstr);
if (sudo_user.max_groups == 0) {
- warningx(U_("%s: %s"), *cur, U_(errstr));
+ sudo_warnx(U_("%s: %s"), *cur, U_(errstr));
goto bad;
}
continue;
p = *cur + sizeof("uid=") - 1;
user_uid = (uid_t) atoid(p, NULL, NULL, &errstr);
if (errstr != NULL) {
- warningx(U_("%s: %s"), *cur, U_(errstr));
+ sudo_warnx(U_("%s: %s"), *cur, U_(errstr));
goto bad;
}
continue;
p = *cur + sizeof("gid=") - 1;
user_gid = (gid_t) atoid(p, NULL, NULL, &errstr);
if (errstr != NULL) {
- warningx(U_("%s: %s"), *cur, U_(errstr));
+ sudo_warnx(U_("%s: %s"), *cur, U_(errstr));
goto bad;
}
continue;
p = *cur + sizeof("lines=") - 1;
sudo_user.lines = strtonum(p, 1, INT_MAX, &errstr);
if (sudo_user.lines == 0) {
- warningx(U_("%s: %s"), *cur, U_(errstr));
+ sudo_warnx(U_("%s: %s"), *cur, U_(errstr));
goto bad;
}
continue;
p = *cur + sizeof("cols=") - 1;
sudo_user.cols = strtonum(p, 1, INT_MAX, &errstr);
if (sudo_user.lines == 0) {
- warningx(U_("%s: %s"), *cur, U_(errstr));
+ sudo_warnx(U_("%s: %s"), *cur, U_(errstr));
goto bad;
}
continue;
p = *cur + sizeof("sid=") - 1;
sudo_user.sid = (pid_t) atoid(p, NULL, NULL, &errstr);
if (errstr != NULL) {
- warningx(U_("%s: %s"), *cur, U_(errstr));
+ sudo_warnx(U_("%s: %s"), *cur, U_(errstr));
goto bad;
}
continue;
(unsigned int)runas_pw->pw_gid;
len = snprintf(cp, glsize - (cp - gid_list), "%u", egid);
if (len < 0 || (size_t)len >= glsize - (cp - gid_list)) {
- warningx(U_("internal error, %s overflow"), __func__);
+ sudo_warnx(U_("internal error, %s overflow"), __func__);
goto done;
}
cp += len;
len = snprintf(cp, glsize - (cp - gid_list), ",%u",
(unsigned int) grlist->gids[i]);
if (len < 0 || (size_t)len >= glsize - (cp - gid_list)) {
- warningx(U_("internal error, %s overflow"), __func__);
+ sudo_warnx(U_("internal error, %s overflow"), __func__);
goto done;
}
cp += len;
/* We do not currently log the exit status. */
if (error_code) {
errno = error_code;
- warning(U_("unable to execute %s"), safe_cmnd);
+ sudo_warn(U_("unable to execute %s"), safe_cmnd);
}
/* Close the session we opened in sudoers_policy_init_session(). */
if (ISSET(sudo_mode, MODE_RUN|MODE_EDIT))
(void)sudo_auth_end_session(runas_pw);
- /* Deregister the callback for fatal()/fatalx(). */
- fatal_callback_deregister(sudoers_cleanup);
+ /* Deregister the callback for sudo_fatal()/sudo_fatalx(). */
+ sudo_fatal_callback_deregister(sudoers_cleanup);
/* Free remaining references to password and group entries. */
/* XXX - move cleanup to function in sudoers.c */
if (list_user) {
list_pw = sudo_getpwnam(list_user);
if (list_pw == NULL) {
- warningx(U_("unknown user: %s"), list_user);
+ sudo_warnx(U_("unknown user: %s"), list_user);
debug_return_bool(-1);
}
}
oflow:
/* We pre-allocate enough space, so this should never happen. */
- warningx(U_("internal error, %s overflow"), __func__);
+ sudo_warnx(U_("internal error, %s overflow"), __func__);
debug_return_str(NULL);
}
}
if (rbinsert(pwcache_byuid, item) != NULL) {
/* should not happen */
- warningx(U_("unable to cache uid %u, already exists"),
+ sudo_warnx(U_("unable to cache uid %u, already exists"),
(unsigned int) uid);
item->refcnt = 0;
}
}
if (rbinsert(pwcache_byname, item) != NULL) {
/* should not happen */
- warningx(U_("unable to cache user %s, already exists"), name);
+ sudo_warnx(U_("unable to cache user %s, already exists"), name);
item->refcnt = 0;
}
#ifdef HAVE_SETAUTHDB
}
if (rbinsert(grcache_bygid, item) != NULL) {
/* should not happen */
- warningx(U_("unable to cache gid %u, already exists"),
+ sudo_warnx(U_("unable to cache gid %u, already exists"),
(unsigned int) gid);
item->refcnt = 0;
}
}
if (rbinsert(grcache_byname, item) != NULL) {
/* should not happen */
- warningx(U_("unable to cache group %s, already exists"), name);
+ sudo_warnx(U_("unable to cache group %s, already exists"), name);
item->refcnt = 0;
}
done:
}
if (rbinsert(grlist_cache, item) != NULL) {
/* should not happen */
- warningx(U_("unable to cache group list for %s, already exists"),
+ sudo_warnx(U_("unable to cache group list for %s, already exists"),
pw->pw_name);
item->refcnt = 0;
}
key.k.name = pw->pw_name;
if ((node = rbfind(grlist_cache, &key)) == NULL) {
if ((item = sudo_make_grlist_item(pw, groups, gids)) == NULL) {
- warningx(U_("unable to parse groups for %s"), pw->pw_name);
+ sudo_warnx(U_("unable to parse groups for %s"), pw->pw_name);
debug_return_int(-1);
}
if (rbinsert(grlist_cache, item) != NULL) {
- warningx(U_("unable to cache group list for %s, already exists"),
+ sudo_warnx(U_("unable to cache group list for %s, already exists"),
pw->pw_name);
sudo_grlist_delref_item(item);
}
handle = sudo_dso_load(plugin_path, SUDO_DSO_LAZY|SUDO_DSO_GLOBAL);
if (handle == NULL)
- fatalx_nodebug("unable to load %s: %s", plugin_path, sudo_dso_strerror());
+ sudo_fatalx_nodebug("unable to load %s: %s", plugin_path, sudo_dso_strerror());
fp = fopen(symbols_file, "r");
if (fp == NULL)
- fatal_nodebug("unable to open %s", symbols_file);
+ sudo_fatal_nodebug("unable to open %s", symbols_file);
while (fgets(line, sizeof(line), fp) != NULL) {
ntests++;
time(&now);
timeptr = localtime(&now);
if (timeptr == NULL)
- fatalx("localtime returned NULL");
+ sudo_fatalx("localtime returned NULL");
strftime(dir_out, sizeof(dir_out), tdir_out, timeptr);
strftime(file_out, sizeof(file_out), tfile_out, timeptr);
path = expand_iolog_path(NULL, dir_in, file_in, &slash);
*slash = '\0';
if (strcmp(path, dir_out) != 0) {
- warningx("%s: expected %s, got %s", dir_in, dir_out, path);
+ sudo_warnx("%s: expected %s, got %s", dir_in, dir_out, path);
error = 1;
}
if (strcmp(slash + 1, file_out) != 0) {
- warningx("%s: expected %s, got %s", file_in, file_out, slash + 1);
+ sudo_warnx("%s: expected %s, got %s", file_in, file_out, slash + 1);
error = 1;
}
fp = fopen(argv[1], "r");
if (fp == NULL)
- fatalx("unable to open %s", argv[1]);
+ sudo_fatalx("unable to open %s", argv[1]);
memset(&pw, 0, sizeof(pw));
memset(&rpw, 0, sizeof(rpw));
case 2:
user_gid = (gid_t)atoid(line, NULL, NULL, &errstr);
if (errstr != NULL)
- fatalx("group ID %s: %s", line, errstr);
+ sudo_fatalx("group ID %s: %s", line, errstr);
break;
case 3:
if (runas_pw->pw_name != NULL)
case 4:
runas_pw->pw_gid = (gid_t)atoid(line, NULL, NULL, &errstr);
if (errstr != NULL)
- fatalx("group ID %s: %s", line, errstr);
+ sudo_fatalx("group ID %s: %s", line, errstr);
break;
case 5:
user_shost = strdup(line);
tests++;
break;
default:
- fatalx("internal error, invalid state %d", state);
+ sudo_fatalx("internal error, invalid state %d", state);
}
state = (state + 1) % MAX_STATE;
}
fp = fopen(argv[1], "r");
if (fp == NULL)
- fatalx("unable to open %s", argv[1]);
+ sudo_fatalx("unable to open %s", argv[1]);
/*
* Each test record consists of a log entry on one line and a list of
len = maxlen = strtonum(cp, 1, INT_MAX, NULL);
}
if (len == 0 || maxlen == 0)
- fatalx("%s: invalid length on line %d\n", argv[1], lineno);
+ sudo_fatalx("%s: invalid length on line %d\n", argv[1], lineno);
while (len <= maxlen) {
printf("# word wrap at %d characters\n", (int)len);
writeln_wrap(stdout, lines[0], strlen(lines[0]), len);
cp++;
expected = strtonum(cp, 0, 1, &errstr);
if (errstr != NULL)
- fatalx("expecting 0 or 1, got %s", cp);
+ sudo_fatalx("expecting 0 or 1, got %s", cp);
input[len] = '\0';
matched = addr_matches(input);
if (matched != expected) {
- warningx("%s %smatched: FAIL", input, matched ? "" : "not ");
+ sudo_warnx("%s %smatched: FAIL", input, matched ? "" : "not ");
return 1;
}
return 0;
fp = fopen(argv[1], "r");
if (fp == NULL)
- fatalx("unable to open %s", argv[1]);
+ sudo_fatalx("unable to open %s", argv[1]);
/*
* Input is in the following format. There are two types of
errors += check_addr(line + sizeof("address:") - 1);
ntests++;
} else {
- warningx("unexpected data line: %s\n", line);
+ sudo_warnx("unexpected data line: %s\n", line);
continue;
}
}
debug_return_bool(true);
bad:
if (errno == EAGAIN)
- warningx(U_("%s: %s"), U_(errstr), U_("too many processes"));
+ sudo_warnx(U_("%s: %s"), U_(errstr), U_("too many processes"));
else
- warning("%s", U_(errstr));
+ sudo_warn("%s", U_(errstr));
debug_return_bool(false);
}
debug_decl(restore_perms, SUDO_DEBUG_PERMS)
if (perm_stack_depth < 2) {
- warningx(U_("perm stack underflow"));
+ sudo_warnx(U_("perm stack underflow"));
debug_return_bool(true);
}
/* XXX - more cases here where euid != ruid */
if (OID(euid) == ROOT_UID) {
if (setresuid(-1, ROOT_UID, -1)) {
- warning("setresuid() [%d, %d, %d] -> [%d, %d, %d]",
+ sudo_warn("setresuid() [%d, %d, %d] -> [%d, %d, %d]",
(int)state->ruid, (int)state->euid, (int)state->suid,
-1, ROOT_UID, -1);
goto bad;
}
}
if (setresuid(OID(ruid), OID(euid), OID(suid))) {
- warning("setresuid() [%d, %d, %d] -> [%d, %d, %d]",
+ sudo_warn("setresuid() [%d, %d, %d] -> [%d, %d, %d]",
(int)state->ruid, (int)state->euid, (int)state->suid,
(int)OID(ruid), (int)OID(euid), (int)OID(suid));
goto bad;
}
if (setresgid(OID(rgid), OID(egid), OID(sgid))) {
- warning("setresgid() [%d, %d, %d] -> [%d, %d, %d]",
+ sudo_warn("setresgid() [%d, %d, %d] -> [%d, %d, %d]",
(int)state->rgid, (int)state->egid, (int)state->sgid,
(int)OID(rgid), (int)OID(egid), (int)OID(sgid));
goto bad;
}
if (state->grlist != ostate->grlist) {
if (sudo_setgroups(ostate->grlist->ngids, ostate->grlist->gids)) {
- warning("setgroups()");
+ sudo_warn("setgroups()");
goto bad;
}
}
debug_return_bool(true);
bad:
if (errno == EAGAIN)
- warningx(U_("%s: %s"), U_(errstr), U_("too many processes"));
+ sudo_warnx(U_("%s: %s"), U_(errstr), U_("too many processes"));
else
- warning("%s", U_(errstr));
+ sudo_warn("%s", U_(errstr));
debug_return_bool(false);
}
debug_decl(restore_perms, SUDO_DEBUG_PERMS)
if (perm_stack_depth < 2) {
- warningx(U_("perm stack underflow"));
+ sudo_warnx(U_("perm stack underflow"));
debug_return_bool(true);
}
sudo_debug_printf(SUDO_DEBUG_INFO, "%s: setuidx(ID_EFFECTIVE, %d)",
__func__, ROOT_UID);
if (setuidx(ID_EFFECTIVE, ROOT_UID)) {
- warning("setuidx(ID_EFFECTIVE) [%d, %d, %d] -> [%d, %d, %d]",
+ sudo_warn("setuidx(ID_EFFECTIVE) [%d, %d, %d] -> [%d, %d, %d]",
(int)state->ruid, (int)state->euid, (int)state->suid,
-1, ROOT_UID, -1);
goto bad;
"%s: setuidx(ID_EFFECTIVE|ID_REAL|ID_SAVED, %d)",
__func__, OID(ruid));
if (setuidx(ID_EFFECTIVE|ID_REAL|ID_SAVED, OID(ruid))) {
- warning("setuidx(ID_EFFECTIVE|ID_REAL|ID_SAVED) [%d, %d, %d] -> [%d, %d, %d]",
+ sudo_warn("setuidx(ID_EFFECTIVE|ID_REAL|ID_SAVED) [%d, %d, %d] -> [%d, %d, %d]",
(int)state->ruid, (int)state->euid, (int)state->suid,
(int)OID(ruid), (int)OID(euid), (int)OID(suid));
goto bad;
sudo_debug_printf(SUDO_DEBUG_INFO,
"%s: setuidx(ID_EFFECTIVE, %d)", __func__, OID(euid));
if (setuidx(ID_EFFECTIVE, OID(euid))) {
- warning("setuidx(ID_EFFECTIVE) [%d, %d, %d] -> [%d, %d, %d]",
+ sudo_warn("setuidx(ID_EFFECTIVE) [%d, %d, %d] -> [%d, %d, %d]",
(int)state->ruid, (int)state->euid, (int)state->suid,
(int)OID(ruid), (int)OID(euid), (int)OID(suid));
goto bad;
sudo_debug_printf(SUDO_DEBUG_INFO,
"%s: setuidx(ID_REAL|ID_EFFECTIVE, %d)", __func__, OID(ruid));
if (setuidx(ID_REAL|ID_EFFECTIVE, OID(ruid))) {
- warning("setuidx(ID_REAL|ID_EFFECTIVE) [%d, %d, %d] -> [%d, %d, %d]",
+ sudo_warn("setuidx(ID_REAL|ID_EFFECTIVE) [%d, %d, %d] -> [%d, %d, %d]",
(int)state->ruid, (int)state->euid, (int)state->suid,
(int)OID(ruid), (int)OID(euid), (int)OID(suid));
goto bad;
sudo_debug_printf(SUDO_DEBUG_INFO,
"%s: setuidx(ID_EFFECTIVE, %d)", __func__, ostate->euid);
if (setuidx(ID_EFFECTIVE, ostate->euid)) {
- warning("setuidx(ID_EFFECTIVE, %d)", ostate->euid);
+ sudo_warn("setuidx(ID_EFFECTIVE, %d)", ostate->euid);
goto bad;
}
}
"%s: setgidx(ID_EFFECTIVE|ID_REAL|ID_SAVED, %d)",
__func__, OID(rgid));
if (setgidx(ID_EFFECTIVE|ID_REAL|ID_SAVED, OID(rgid))) {
- warning("setgidx(ID_EFFECTIVE|ID_REAL|ID_SAVED) [%d, %d, %d] -> [%d, %d, %d]",
+ sudo_warn("setgidx(ID_EFFECTIVE|ID_REAL|ID_SAVED) [%d, %d, %d] -> [%d, %d, %d]",
(int)state->rgid, (int)state->egid, (int)state->sgid,
(int)OID(rgid), (int)OID(egid), (int)OID(sgid));
goto bad;
sudo_debug_printf(SUDO_DEBUG_INFO, "%s: setgidx(ID_EFFECTIVE, %d)",
__func__, OID(egid));
if (setgidx(ID_EFFECTIVE, OID(egid))) {
- warning("setgidx(ID_EFFECTIVE) [%d, %d, %d] -> [%d, %d, %d]",
+ sudo_warn("setgidx(ID_EFFECTIVE) [%d, %d, %d] -> [%d, %d, %d]",
(int)state->rgid, (int)state->egid, (int)state->sgid,
(int)OID(rgid), (int)OID(egid), (int)OID(sgid));
goto bad;
sudo_debug_printf(SUDO_DEBUG_INFO,
"%s: setgidx(ID_EFFECTIVE|ID_REAL, %d)", __func__, OID(rgid));
if (setgidx(ID_REAL|ID_EFFECTIVE, OID(rgid))) {
- warning("setgidx(ID_REAL|ID_EFFECTIVE) [%d, %d, %d] -> [%d, %d, %d]",
+ sudo_warn("setgidx(ID_REAL|ID_EFFECTIVE) [%d, %d, %d] -> [%d, %d, %d]",
(int)state->rgid, (int)state->egid, (int)state->sgid,
(int)OID(rgid), (int)OID(egid), (int)OID(sgid));
goto bad;
}
if (state->grlist != ostate->grlist) {
if (sudo_setgroups(ostate->grlist->ngids, ostate->grlist->gids)) {
- warning("setgroups()");
+ sudo_warn("setgroups()");
goto bad;
}
}
debug_return_bool(true);
bad:
if (errno == EAGAIN)
- warningx(U_("%s: %s"), U_(errstr), U_("too many processes"));
+ sudo_warnx(U_("%s: %s"), U_(errstr), U_("too many processes"));
else
- warning("%s", U_(errstr));
+ sudo_warn("%s", U_(errstr));
debug_return_bool(false);
}
debug_decl(restore_perms, SUDO_DEBUG_PERMS)
if (perm_stack_depth < 2) {
- warningx(U_("perm stack underflow"));
+ sudo_warnx(U_("perm stack underflow"));
debug_return_bool(true);
}
if (ID(euid) != ROOT_UID)
ignore_result(setreuid(-1, ROOT_UID));
if (setuid(ROOT_UID)) {
- warning("setuid() [%d, %d] -> %d)", (int)state->ruid,
+ sudo_warn("setuid() [%d, %d] -> %d)", (int)state->ruid,
(int)state->euid, ROOT_UID);
goto bad;
}
}
if (setreuid(OID(ruid), OID(euid))) {
- warning("setreuid() [%d, %d] -> [%d, %d]", (int)state->ruid,
+ sudo_warn("setreuid() [%d, %d] -> [%d, %d]", (int)state->ruid,
(int)state->euid, (int)OID(ruid), (int)OID(euid));
goto bad;
}
if (setregid(OID(rgid), OID(egid))) {
- warning("setregid() [%d, %d] -> [%d, %d]", (int)state->rgid,
+ sudo_warn("setregid() [%d, %d] -> [%d, %d]", (int)state->rgid,
(int)state->egid, (int)OID(rgid), (int)OID(egid));
goto bad;
}
if (state->grlist != ostate->grlist) {
if (sudo_setgroups(ostate->grlist->ngids, ostate->grlist->gids)) {
- warning("setgroups()");
+ sudo_warn("setgroups()");
goto bad;
}
}
debug_return_bool(true);
bad:
if (errno == EAGAIN)
- warningx(U_("%s: %s"), U_(errstr), U_("too many processes"));
+ sudo_warnx(U_("%s: %s"), U_(errstr), U_("too many processes"));
else
- warning("%s", U_(errstr));
+ sudo_warn("%s", U_(errstr));
debug_return_bool(false);
}
debug_decl(restore_perms, SUDO_DEBUG_PERMS)
if (perm_stack_depth < 2) {
- warningx(U_("perm stack underflow"));
+ sudo_warnx(U_("perm stack underflow"));
debug_return_bool(true);
}
* real and effective uids to ROOT_UID initially to be safe.
*/
if (seteuid(ROOT_UID)) {
- warningx("seteuid() [%d] -> [%d]", (int)state->euid, ROOT_UID);
+ sudo_warnx("seteuid() [%d] -> [%d]", (int)state->euid, ROOT_UID);
goto bad;
}
if (setuid(ROOT_UID)) {
- warningx("setuid() [%d, %d] -> [%d, %d]", (int)state->ruid, ROOT_UID,
+ sudo_warnx("setuid() [%d, %d] -> [%d, %d]", (int)state->ruid, ROOT_UID,
ROOT_UID, ROOT_UID);
goto bad;
}
if (OID(egid) != (gid_t)-1 && setegid(ostate->egid)) {
- warning("setegid(%d)", (int)ostate->egid);
+ sudo_warn("setegid(%d)", (int)ostate->egid);
goto bad;
}
if (state->grlist != ostate->grlist) {
if (sudo_setgroups(ostate->grlist->ngids, ostate->grlist->gids)) {
- warning("setgroups()");
+ sudo_warn("setgroups()");
goto bad;
}
}
if (OID(euid) != (uid_t)-1 && seteuid(ostate->euid)) {
- warning("seteuid(%d)", ostate->euid);
+ sudo_warn("seteuid(%d)", ostate->euid);
goto bad;
}
sudo_grlist_delref(state->grlist);
debug_return_bool(true);
bad:
if (errno == EAGAIN)
- warningx(U_("%s: %s"), U_(errstr), U_("too many processes"));
+ sudo_warnx(U_("%s: %s"), U_(errstr), U_("too many processes"));
else
- warning("%s", U_(errstr));
+ sudo_warn("%s", U_(errstr));
debug_return_bool(false);
}
debug_decl(restore_perms, SUDO_DEBUG_PERMS)
if (perm_stack_depth < 2) {
- warningx(U_("perm stack underflow"));
+ sudo_warnx(U_("perm stack underflow"));
debug_return_bool(true);
}
__func__, (int)state->rgid, (int)ostate->rgid);
if (OID(rgid) != (gid_t)-1 && setgid(ostate->rgid)) {
- warning("setgid(%d)", (int)ostate->rgid);
+ sudo_warn("setgid(%d)", (int)ostate->rgid);
goto bad;
}
if (state->grlist != ostate->grlist) {
if (sudo_setgroups(ostate->grlist->ngids, ostate->grlist->gids)) {
- warning("setgroups()");
+ sudo_warn("setgroups()");
goto bad;
}
}
sudo_grlist_delref(state->grlist);
if (OID(ruid) != (uid_t)-1 && setuid(ostate->ruid)) {
- warning("setuid(%d)", (int)ostate->ruid);
+ sudo_warn("setuid(%d)", (int)ostate->ruid);
goto bad;
}
debug_return_bool(true);
/* Load symbols */
handle->ssslib = sudo_dso_load(path, SUDO_DSO_LAZY);
if (handle->ssslib == NULL) {
- warningx(U_("unable to load %s: %s"), path, sudo_dso_strerror());
- warningx(U_("unable to initialize SSS source. Is SSSD installed on your machine?"));
+ sudo_warnx(U_("unable to load %s: %s"), path, sudo_dso_strerror());
+ sudo_warnx(U_("unable to initialize SSS source. Is SSSD installed on your machine?"));
debug_return_int(EFAULT);
}
handle->fn_send_recv =
sudo_dso_findsym(handle->ssslib, "sss_sudo_send_recv");
if (handle->fn_send_recv == NULL) {
- warningx(U_("unable to find symbol \"%s\" in %s"), path,
+ sudo_warnx(U_("unable to find symbol \"%s\" in %s"), path,
"sss_sudo_send_recv");
debug_return_int(EFAULT);
}
handle->fn_send_recv_defaults =
sudo_dso_findsym(handle->ssslib, "sss_sudo_send_recv_defaults");
if (handle->fn_send_recv_defaults == NULL) {
- warningx(U_("unable to find symbol \"%s\" in %s"), path,
+ sudo_warnx(U_("unable to find symbol \"%s\" in %s"), path,
"sss_sudo_send_recv_defaults");
debug_return_int(EFAULT);
}
handle->fn_free_result =
sudo_dso_findsym(handle->ssslib, "sss_sudo_free_result");
if (handle->fn_free_result == NULL) {
- warningx(U_("unable to find symbol \"%s\" in %s"), path,
+ sudo_warnx(U_("unable to find symbol \"%s\" in %s"), path,
"sss_sudo_free_result");
debug_return_int(EFAULT);
}
handle->fn_get_values =
sudo_dso_findsym(handle->ssslib, "sss_sudo_get_values");
if (handle->fn_get_values == NULL) {
- warningx(U_("unable to find symbol \"%s\" in %s"), path,
+ sudo_warnx(U_("unable to find symbol \"%s\" in %s"), path,
"sss_sudo_get_values");
debug_return_int(EFAULT);
}
handle->fn_free_values =
sudo_dso_findsym(handle->ssslib, "sss_sudo_free_values");
if (handle->fn_free_values == NULL) {
- warningx(U_("unable to find symbol \"%s\" in %s"), path,
+ sudo_warnx(U_("unable to find symbol \"%s\" in %s"), path,
"sss_sudo_free_values");
debug_return_int(EFAULT);
}
sudo_setgrent();
/* Register fatal/fatalx callback. */
- fatal_callback_register(sudoers_cleanup);
+ sudo_fatal_callback_register(sudoers_cleanup);
/* Initialize environment functions (including replacements). */
env_init(envp);
}
}
if (sources == 0) {
- warningx(U_("no valid sudoers sources found, quitting"));
+ sudo_warnx(U_("no valid sudoers sources found, quitting"));
goto cleanup;
}
/* Is root even allowed to run sudo? */
if (user_uid == 0 && !def_root_sudo) {
/* Not an audit event. */
- warningx(U_("sudoers specifies that root is not allowed to sudo"));
+ sudo_warnx(U_("sudoers specifies that root is not allowed to sudo"));
goto bad;
}
if (user_closefrom >= 0 && user_closefrom != def_closefrom) {
if (!def_closefrom_override) {
/* XXX - audit? */
- warningx(U_("you are not permitted to use the -C option"));
+ sudo_warnx(U_("you are not permitted to use the -C option"));
goto bad;
}
def_closefrom = user_closefrom;
/* Bail if a tty is required and we don't have one. */
if (def_requiretty && !tty_present()) {
audit_failure(NewArgc, NewArgv, N_("no tty"));
- warningx(U_("sorry, you must have a tty to run sudo"));
+ sudo_warnx(U_("sorry, you must have a tty to run sudo"));
goto bad;
}
/* Finally tell the user if the command did not exist. */
if (cmnd_status == NOT_FOUND_DOT) {
audit_failure(NewArgc, NewArgv, N_("command in current directory"));
- warningx(U_("ignoring `%s' found in '.'\nUse `sudo ./%s' if this is the `%s' you wish to run."), user_cmnd, user_cmnd, user_cmnd);
+ sudo_warnx(U_("ignoring `%s' found in '.'\nUse `sudo ./%s' if this is the `%s' you wish to run."), user_cmnd, user_cmnd, user_cmnd);
goto bad;
} else if (cmnd_status == NOT_FOUND) {
if (ISSET(sudo_mode, MODE_CHECK)) {
audit_failure(NewArgc, NewArgv, N_("%s: command not found"),
NewArgv[0]);
- warningx(U_("%s: command not found"), NewArgv[0]);
+ sudo_warnx(U_("%s: command not found"), NewArgv[0]);
} else {
audit_failure(NewArgc, NewArgv, N_("%s: command not found"),
user_cmnd);
- warningx(U_("%s: command not found"), user_cmnd);
+ sudo_warnx(U_("%s: command not found"), user_cmnd);
}
goto bad;
}
if (ISSET(sudo_mode, MODE_RUN) && !def_setenv) {
if (ISSET(sudo_mode, MODE_PRESERVE_ENV)) {
/* XXX - audit? */
- warningx(U_("sorry, you are not allowed to preserve the environment"));
+ sudo_warnx(U_("sorry, you are not allowed to preserve the environment"));
goto bad;
} else {
if (!validate_env_vars(sudo_user.env_vars))
#if defined(_AIX) || (defined(__linux__) && !defined(HAVE_PAM))
/* Insert system-wide environment variables. */
if (!read_env_file(_PATH_ENVIRONMENT, true))
- warning("%s", _PATH_ENVIRONMENT);
+ sudo_warn("%s", _PATH_ENVIRONMENT);
#endif
#ifdef HAVE_LOGIN_CAP_H
/* Set environment based on login class. */
/* Insert system-wide environment variables. */
if (def_env_file) {
if (!read_env_file(def_env_file, false))
- warning("%s", def_env_file);
+ sudo_warn("%s", def_env_file);
}
/* Insert user-specified environment variables. */
* YP/NIS/NIS+/LDAP/etc daemon has died.
*/
if (sudo_mode == MODE_KILL || sudo_mode == MODE_INVALIDATE) {
- warningx(U_("unknown uid: %u"), (unsigned int) user_uid);
+ sudo_warnx(U_("unknown uid: %u"), (unsigned int) user_uid);
debug_return_bool(false);
}
for (to = user_args, av = NewArgv + 1; *av; av++) {
n = strlcpy(to, *av, size - (to - user_args));
if (n >= size - (to - user_args)) {
- warningx(U_("internal error, %s overflow"), __func__);
+ sudo_warnx(U_("internal error, %s overflow"), __func__);
debug_return_int(-1);
}
to += n;
if (login_class && strcmp(login_class, "-") != 0) {
if (user_uid != 0 && pw->pw_uid != 0) {
- warningx(U_("only root can use `-c %s'"), login_class);
+ sudo_warnx(U_("only root can use `-c %s'"), login_class);
rval = false;
goto done;
}
}
/*
- * Cleanup hook for fatal()/fatalx()
+ * Cleanup hook for sudo_fatal()/sudo_fatalx()
*/
void
sudoers_cleanup(void)
}
if (!editor_path) {
audit_failure(NewArgc, NewArgv, N_("%s: command not found"), editor);
- warningx(U_("%s: command not found"), editor);
+ sudo_warnx(U_("%s: command not found"), editor);
}
debug_return_str(editor_path);
}
textdomain("sudoers");
/* Register fatal/fatalx callback. */
- fatal_callback_register(sudoreplay_cleanup);
+ sudo_fatal_callback_register(sudoreplay_cleanup);
/* Read sudo.conf. */
sudo_conf_read(NULL);
else if (strcmp(cp, "ttyout") == 0)
io_log_files[IOFD_TTYOUT].enabled = true;
else
- fatalx(U_("invalid filter option: %s"), optarg);
+ sudo_fatalx(U_("invalid filter option: %s"), optarg);
}
break;
case 'h':
errno = 0;
max_wait = strtod(optarg, &ep);
if (*ep != '\0' || errno != 0)
- fatalx(U_("invalid max wait: %s"), optarg);
+ sudo_fatalx(U_("invalid max wait: %s"), optarg);
break;
case 's':
errno = 0;
speed_factor = strtod(optarg, &ep);
if (*ep != '\0' || errno != 0)
- fatalx(U_("invalid speed factor: %s"), optarg);
+ sudo_fatalx(U_("invalid speed factor: %s"), optarg);
break;
case 'V':
(void) printf(_("%s version %s\n"), getprogname(), PACKAGE_VERSION);
plen = snprintf(path, sizeof(path), "%s/%.2s/%.2s/%.2s/timing",
session_dir, id, &id[2], &id[4]);
if (plen <= 0 || (size_t)plen >= sizeof(path))
- fatalx(U_("%s/%.2s/%.2s/%.2s/timing: %s"), session_dir,
+ sudo_fatalx(U_("%s/%.2s/%.2s/%.2s/timing: %s"), session_dir,
id, &id[2], &id[4], strerror(ENAMETOOLONG));
} else {
plen = snprintf(path, sizeof(path), "%s/%s/timing",
session_dir, id);
if (plen <= 0 || (size_t)plen >= sizeof(path))
- fatalx(U_("%s/%s/timing: %s"), session_dir,
+ sudo_fatalx(U_("%s/%s/timing: %s"), session_dir,
id, strerror(ENAMETOOLONG));
}
plen -= 7;
/* Open files for replay, applying replay filter for the -f flag. */
for (idx = 0; idx < IOFD_MAX; idx++) {
if (open_io_fd(path, plen, &io_log_files[idx]) == -1)
- fatal(U_("unable to open %s"), path);
+ sudo_fatal(U_("unable to open %s"), path);
}
/* Parse log file. */
if (idx != -1)
(void) fcntl(STDIN_FILENO, F_SETFL, idx | O_NONBLOCK);
if (!sudo_term_raw(STDIN_FILENO, 1))
- fatal(U_("unable to set tty to raw mode"));
+ sudo_fatal(U_("unable to set tty to raw mode"));
}
/* Setup event base and input/output events. */
evbase = sudo_ev_base_alloc();
if (evbase == NULL)
- fatal(NULL);
+ sudo_fatal(NULL);
input_ev = sudo_ev_alloc(STDIN_FILENO, interactive ? SUDO_EV_READ :
SUDO_EV_TIMEOUT, check_input, sudo_ev_self_cbarg());
if (input_ev == NULL)
- fatal(NULL);
+ sudo_fatal(NULL);
output_ev = sudo_ev_alloc(STDIN_FILENO, SUDO_EV_WRITE, write_output, &wc);
if (output_ev == NULL)
- fatal(NULL);
+ sudo_fatal(NULL);
/*
* Read each line of the timing file, displaying the output streams.
buf[strcspn(buf, "\n")] = '\0';
if (!parse_timing(buf, decimal, &idx, &seconds, &nbytes))
- fatalx(U_("invalid timing file line: %s"), buf);
+ sudo_fatalx(U_("invalid timing file line: %s"), buf);
/* Adjust delay using speed factor and clamp to max_wait */
to_wait = seconds / speed_factor;
switch (nwritten) {
case -1:
if (errno != EINTR && errno != EAGAIN)
- fatal(U_("unable to write to %s"), "stdout");
+ sudo_fatal(U_("unable to write to %s"), "stdout");
break;
case 0:
break;
continue;
case 'c': /* command */
if (av[0][1] == '\0')
- fatalx(U_("ambiguous expression \"%s\""), *av);
+ sudo_fatalx(U_("ambiguous expression \"%s\""), *av);
if (strncmp(*av, "cwd", strlen(*av)) == 0)
type = ST_CWD;
else if (strncmp(*av, "command", strlen(*av)) == 0)
break;
case 't': /* tty or to date */
if (av[0][1] == '\0')
- fatalx(U_("ambiguous expression \"%s\""), *av);
+ sudo_fatalx(U_("ambiguous expression \"%s\""), *av);
if (strncmp(*av, "todate", strlen(*av)) == 0)
type = ST_TODATE;
else if (strncmp(*av, "tty", strlen(*av)) == 0)
if (av[0][1] != '\0')
goto bad;
if (!sub_expr)
- fatalx(U_("unmatched ')' in expression"));
+ sudo_fatalx(U_("unmatched ')' in expression"));
debug_return_int(av - argv + 1);
bad:
default:
- fatalx(U_("unknown search term \"%s\""), *av);
+ sudo_fatalx(U_("unknown search term \"%s\""), *av);
/* NOTREACHED */
}
av += parse_expr(&sn->u.expr, av + 1, true);
} else {
if (*(++av) == NULL)
- fatalx(U_("%s requires an argument"), av[-1]);
+ sudo_fatalx(U_("%s requires an argument"), av[-1]);
#ifdef HAVE_REGCOMP
if (type == ST_PATTERN) {
if (regcomp(&sn->u.cmdre, *av, REG_EXTENDED|REG_NOSUB) != 0)
- fatalx(U_("invalid regular expression: %s"), *av);
+ sudo_fatalx(U_("invalid regular expression: %s"), *av);
} else
#endif
if (type == ST_TODATE || type == ST_FROMDATE) {
sn->u.tstamp = get_date(*av);
if (sn->u.tstamp == -1)
- fatalx(U_("could not parse date \"%s\""), *av);
+ sudo_fatalx(U_("could not parse date \"%s\""), *av);
} else {
sn->u.ptr = *av;
}
STAILQ_INSERT_TAIL(head, sn, entries);
}
if (sub_expr)
- fatalx(U_("unmatched '(' in expression"));
+ sudo_fatalx(U_("unmatched '(' in expression"));
if (or)
- fatalx(U_("illegal trailing \"or\""));
+ sudo_fatalx(U_("illegal trailing \"or\""));
if (not)
- fatalx(U_("illegal trailing \"!\""));
+ sudo_fatalx(U_("illegal trailing \"!\""));
debug_return_int(av - argv);
}
if (rc && rc != REG_NOMATCH) {
char buf[BUFSIZ];
regerror(rc, &sn->u.cmdre, buf, sizeof(buf));
- fatalx("%s", buf);
+ sudo_fatalx("%s", buf);
}
res = rc == REG_NOMATCH ? 0 : 1;
#else
res = log->tstamp <= sn->u.tstamp;
break;
default:
- fatalx(U_("unknown search type %d"), sn->type);
+ sudo_fatalx(U_("unknown search type %d"), sn->type);
/* NOTREACHED */
}
if (sn->negated)
fp = fopen(logfile, "r");
if (fp == NULL) {
- warning(U_("unable to open %s"), logfile);
+ sudo_warn(U_("unable to open %s"), logfile);
goto bad;
}
if (getline(&buf, &bufsize, fp) == -1 ||
getline(&li->cwd, &cwdsize, fp) == -1 ||
getline(&li->cmd, &cmdsize, fp) == -1) {
- warning(U_("%s: invalid log file"), logfile);
+ sudo_warn(U_("%s: invalid log file"), logfile);
goto bad;
}
/* timestamp */
if ((ep = strchr(cp, ':')) == NULL) {
- warning(U_("%s: time stamp field is missing"), logfile);
+ sudo_warn(U_("%s: time stamp field is missing"), logfile);
goto bad;
}
*ep = '\0';
li->tstamp = sizeof(time_t) == 4 ? strtonum(cp, INT_MIN, INT_MAX, &errstr) :
strtonum(cp, LLONG_MIN, LLONG_MAX, &errstr);
if (errstr != NULL) {
- warning(U_("%s: time stamp %s: %s"), logfile, cp, errstr);
+ sudo_warn(U_("%s: time stamp %s: %s"), logfile, cp, errstr);
goto bad;
}
/* user */
cp = ep + 1;
if ((ep = strchr(cp, ':')) == NULL) {
- warning(U_("%s: user field is missing"), logfile);
+ sudo_warn(U_("%s: user field is missing"), logfile);
goto bad;
}
li->user = estrndup(cp, (size_t)(ep - cp));
/* runas user */
cp = ep + 1;
if ((ep = strchr(cp, ':')) == NULL) {
- warning(U_("%s: runas user field is missing"), logfile);
+ sudo_warn(U_("%s: runas user field is missing"), logfile);
goto bad;
}
li->runas_user = estrndup(cp, (size_t)(ep - cp));
/* runas group */
cp = ep + 1;
if ((ep = strchr(cp, ':')) == NULL) {
- warning(U_("%s: runas group field is missing"), logfile);
+ sudo_warn(U_("%s: runas group field is missing"), logfile);
goto bad;
}
if (cp != ep)
return strcmp(s1, s2);
}
-/* XXX - always returns 0, calls fatal() on failure */
+/* XXX - always returns 0, calls sudo_fatal() on failure */
static int
find_sessions(const char *dir, REGEX_T *re, const char *user, const char *tty)
{
d = opendir(dir);
if (d == NULL)
- fatal(U_("unable to open %s"), dir);
+ sudo_fatal(U_("unable to open %s"), dir);
/* XXX - would be faster to chdir and use relative names */
sdlen = strlcpy(pathbuf, dir, sizeof(pathbuf));
if (sdlen + 1 >= sizeof(pathbuf)) {
errno = ENAMETOOLONG;
- fatal("%s/", dir);
+ sudo_fatal("%s/", dir);
}
pathbuf[sdlen++] = '/';
pathbuf[sdlen] = '\0';
"%s/log", sessions[i]);
if (len <= 0 || (size_t)len >= sizeof(pathbuf) - sdlen) {
errno = ENAMETOOLONG;
- fatal("%s/%s/log", dir, sessions[i]);
+ sudo_fatal("%s/%s/log", dir, sessions[i]);
}
efree(sessions[i]);
debug_return_int(0);
}
-/* XXX - always returns 0, calls fatal() on failure */
+/* XXX - always returns 0, calls sudo_fatal() on failure */
static int
list_sessions(int argc, char **argv, const char *pattern, const char *user,
const char *tty)
if (pattern) {
re = &rebuf;
if (regcomp(re, pattern, REG_EXTENDED|REG_NOSUB) != 0)
- fatalx(U_("invalid regular expression: %s"), pattern);
+ sudo_fatalx(U_("invalid regular expression: %s"), pattern);
}
#else
re = (char *) pattern;
switch (read(fd, &ch, 1)) {
case -1:
if (errno != EINTR && errno != EAGAIN)
- fatal(U_("unable to read %s"), "stdin");
+ sudo_fatal(U_("unable to read %s"), "stdin");
break;
case 0:
/* Ignore EOF. */
}
/*
- * Cleanup hook for fatal()/fatalx()
+ * Cleanup hook for sudo_fatal()/sudo_fatalx()
*/
static void
sudoreplay_cleanup(void)
case 'G':
sudoers_gid = (gid_t)atoid(optarg, NULL, NULL, &errstr);
if (errstr != NULL)
- fatalx("group ID %s: %s", optarg, errstr);
+ sudo_fatalx("group ID %s: %s", optarg, errstr);
break;
case 'g':
runas_group = optarg;
case 'U':
sudoers_uid = (uid_t)atoid(optarg, NULL, NULL, &errstr);
if (errstr != NULL)
- fatalx("user ID %s: %s", optarg, errstr);
+ sudo_fatalx("user ID %s: %s", optarg, errstr);
break;
case 'u':
runas_user = optarg;
argc -= 2;
}
if ((sudo_user.pw = sudo_getpwnam(user_name)) == NULL)
- fatalx(U_("unknown user: %s"), user_name);
+ sudo_fatalx(U_("unknown user: %s"), user_name);
if (user_host == NULL) {
if (gethostname(hbuf, sizeof(hbuf)) != 0)
- fatal("gethostname");
+ sudo_fatal("gethostname");
hbuf[sizeof(hbuf) - 1] = '\0';
user_host = hbuf;
}
for (to = user_args, from = argv; *from; from++) {
n = strlcpy(to, *from, size - (to - user_args));
if (n >= size - (to - user_args))
- fatalx(U_("internal error, %s overflow"), getprogname());
+ sudo_fatalx(U_("internal error, %s overflow"), getprogname());
to += n;
*to++ = ' ';
}
}
if (pw == NULL) {
if ((pw = sudo_getpwnam(user)) == NULL)
- fatalx(U_("unknown user: %s"), user);
+ sudo_fatalx(U_("unknown user: %s"), user);
}
if (runas_pw != NULL)
sudo_pw_delref(runas_pw);
}
if (gr == NULL) {
if ((gr = sudo_getgrnam(group)) == NULL)
- fatalx(U_("unknown group: %s"), group);
+ sudo_fatalx(U_("unknown group: %s"), group);
}
if (runas_gr != NULL)
sudo_gr_delref(runas_gr);
fp = fopen(sudoers, "r");
break;
case SUDO_PATH_MISSING:
- warning("unable to stat %s", sudoers_base);
+ sudo_warn("unable to stat %s", sudoers_base);
break;
case SUDO_PATH_BAD_TYPE:
- warningx("%s is not a regular file", sudoers_base);
+ sudo_warnx("%s is not a regular file", sudoers_base);
break;
case SUDO_PATH_WRONG_OWNER:
- warningx("%s should be owned by uid %u",
+ sudo_warnx("%s should be owned by uid %u",
sudoers_base, (unsigned int) sudoers_uid);
break;
case SUDO_PATH_WORLD_WRITABLE:
- warningx("%s is world writable", sudoers_base);
+ sudo_warnx("%s is world writable", sudoers_base);
break;
case SUDO_PATH_GROUP_WRITABLE:
- warningx("%s should be owned by gid %u",
+ sudo_warnx("%s should be owned by gid %u",
sudoers_base, (unsigned int) sudoers_gid);
break;
default:
sudo_debug_printf(SUDO_DEBUG_DEBUG|SUDO_DEBUG_LINENO,
"short write, truncating partial time stamp record");
if (ftruncate(fd, old_eof) != 0) {
- warning(U_("unable to truncate time stamp file to %lld bytes"),
+ sudo_warn(U_("unable to truncate time stamp file to %lld bytes"),
(long long)old_eof);
}
}
"mkdir %s, mode 0%o", path, (unsigned int) parent_mode);
if (mkdir(path, parent_mode) != 0) {
if (!quiet)
- warning(U_("unable to mkdir %s"), path);
+ sudo_warn(U_("unable to mkdir %s"), path);
goto done;
}
ignore_result(chown(path, (uid_t)-1, parent_gid));
} else if (!S_ISDIR(sb.st_mode)) {
if (!quiet) {
- warningx(U_("%s exists but is not a directory (0%o)"),
+ sudo_warnx(U_("%s exists but is not a directory (0%o)"),
path, (unsigned int) sb.st_mode);
}
goto done;
"mkdir %s, mode 0%o", path, (unsigned int) mode);
if (mkdir(path, mode) != 0 && errno != EEXIST) {
if (!quiet)
- warning(U_("unable to mkdir %s"), path);
+ sudo_warn(U_("unable to mkdir %s"), path);
goto done;
}
ignore_result(chown(path, owner, parent_gid));
case SUDO_PATH_BAD_TYPE:
errno = ENOTDIR;
if (!quiet)
- warning("%s", path);
+ sudo_warn("%s", path);
break;
case SUDO_PATH_WRONG_OWNER:
if (!quiet) {
- warningx(U_("%s is owned by uid %u, should be %u"),
+ sudo_warnx(U_("%s is owned by uid %u, should be %u"),
path, (unsigned int) sb.st_uid,
(unsigned int) timestamp_uid);
}
break;
case SUDO_PATH_GROUP_WRITABLE:
if (!quiet)
- warningx(U_("%s is group writable"), path);
+ sudo_warnx(U_("%s is group writable"), path);
errno = EACCES;
break;
}
dir = opendir(dirpath);
if (dir == NULL) {
if (errno != ENOENT) {
- warning("%s", dirpath);
+ sudo_warn("%s", dirpath);
sudoerserror(NULL);
}
goto bad;
new_istack = (struct include_stack *) realloc(istack,
sizeof(*istack) * istacksize);
if (new_istack == NULL) {
- warning(NULL);
+ sudo_warn(NULL);
sudoerserror(NULL);
debug_return_bool(false);
}
case SUDO_PATH_BAD_TYPE:
errno = ENOTDIR;
if (sudoers_warnings) {
- warning("%s", path);
+ sudo_warn("%s", path);
}
debug_return_bool(false);
case SUDO_PATH_WRONG_OWNER:
if (sudoers_warnings) {
- warningx(U_("%s is owned by uid %u, should be %u"),
+ sudo_warnx(U_("%s is owned by uid %u, should be %u"),
path, (unsigned int) sb.st_uid,
(unsigned int) sudoers_uid);
}
debug_return_bool(false);
case SUDO_PATH_WORLD_WRITABLE:
if (sudoers_warnings) {
- warningx(U_("%s is world writable"), path);
+ sudo_warnx(U_("%s is world writable"), path);
}
debug_return_bool(false);
case SUDO_PATH_GROUP_WRITABLE:
if (sudoers_warnings) {
- warningx(U_("%s is owned by gid %u, should be %u"),
+ sudo_warnx(U_("%s is owned by gid %u, should be %u"),
path, (unsigned int) sb.st_gid,
(unsigned int) sudoers_gid);
}
len += (int)(ep - cp);
path = pp = malloc(len + dirlen + 1);
if (path == NULL) {
- warning(NULL);
+ sudo_warn(NULL);
sudoerserror(NULL);
debug_return_str(NULL);
}
dir = opendir(dirpath);
if (dir == NULL) {
if (errno != ENOENT) {
- warning("%s", dirpath);
+ sudo_warn("%s", dirpath);
sudoerserror(NULL);
}
goto bad;
new_istack = (struct include_stack *) realloc(istack,
sizeof(*istack) * istacksize);
if (new_istack == NULL) {
- warning(NULL);
+ sudo_warn(NULL);
sudoerserror(NULL);
debug_return_bool(false);
}
case SUDO_PATH_BAD_TYPE:
errno = ENOTDIR;
if (sudoers_warnings) {
- warning("%s", path);
+ sudo_warn("%s", path);
}
debug_return_bool(false);
case SUDO_PATH_WRONG_OWNER:
if (sudoers_warnings) {
- warningx(U_("%s is owned by uid %u, should be %u"),
+ sudo_warnx(U_("%s is owned by uid %u, should be %u"),
path, (unsigned int) sb.st_uid,
(unsigned int) sudoers_uid);
}
debug_return_bool(false);
case SUDO_PATH_WORLD_WRITABLE:
if (sudoers_warnings) {
- warningx(U_("%s is world writable"), path);
+ sudo_warnx(U_("%s is world writable"), path);
}
debug_return_bool(false);
case SUDO_PATH_GROUP_WRITABLE:
if (sudoers_warnings) {
- warningx(U_("%s is owned by gid %u, should be %u"),
+ sudo_warnx(U_("%s is owned by gid %u, should be %u"),
path, (unsigned int) sb.st_gid,
(unsigned int) sudoers_gid);
}
len += (int)(ep - cp);
path = pp = malloc(len + dirlen + 1);
if (path == NULL) {
- warning(NULL);
+ sudo_warn(NULL);
sudoerserror(NULL);
debug_return_str(NULL);
}
dst = olen ? realloc(sudoerslval.string, olen + len + 1) : malloc(len + 1);
if (dst == NULL) {
- warning(NULL);
+ sudo_warn(NULL);
sudoerserror(NULL);
debug_return_bool(false);
}
dst = sudoerslval.command.cmnd = (char *) malloc(len + 1);
if (sudoerslval.command.cmnd == NULL) {
- warning(NULL);
+ sudo_warn(NULL);
sudoerserror(NULL);
debug_return_bool(false);
}
(char *) malloc(arg_size);
if (p == NULL) {
efree(sudoerslval.command.args);
- warning(NULL);
+ sudo_warn(NULL);
sudoerserror(NULL);
debug_return_bool(false);
} else
if (addspace)
*p++ = ' ';
if (strlcpy(p, s, arg_size - (p - sudoerslval.command.args)) != (size_t)len) {
- warningx(U_("internal error, %s overflow"), __func__);
+ sudo_warnx(U_("internal error, %s overflow"), __func__);
sudoerserror(NULL);
debug_return_bool(false);
}
usage(1);
/* Register fatal/fatalx callback. */
- fatal_callback_register(visudo_cleanup);
+ sudo_fatal_callback_register(visudo_cleanup);
/* Read sudo.conf. */
sudo_conf_read(NULL);
/* Mock up a fake sudo_user struct. */
user_cmnd = user_base = "";
if ((sudo_user.pw = sudo_getpwuid(getuid())) == NULL)
- fatalx(U_("you do not exist in the %s database"), "passwd");
+ sudo_fatalx(U_("you do not exist in the %s database"), "passwd");
get_hostname();
/* Setup defaults data structures. */
debug_decl(edit_sudoers, SUDO_DEBUG_UTIL)
if (fstat(sp->fd, &sb) == -1)
- fatal(U_("unable to stat %s"), sp->path);
+ sudo_fatal(U_("unable to stat %s"), sp->path);
orig_size = sb.st_size;
mtim_get(&sb, &orig_mtim);
easprintf(&sp->tpath, "%s.tmp", sp->path);
tfd = open(sp->tpath, O_WRONLY | O_CREAT | O_TRUNC, 0600);
if (tfd < 0)
- fatal("%s", sp->tpath);
+ sudo_fatal("%s", sp->tpath);
/* Copy sp->path -> sp->tpath and reset the mtime. */
if (orig_size != 0) {
(void) lseek(sp->fd, (off_t)0, SEEK_SET);
while ((nread = read(sp->fd, buf, sizeof(buf))) > 0)
if (write(tfd, buf, nread) != nread)
- fatal(U_("write error"));
+ sudo_fatal(U_("write error"));
/* Add missing newline at EOF if needed. */
if (nread > 0 && buf[nread - 1] != '\n') {
buf[0] = '\n';
if (write(tfd, buf, 1) != 1)
- fatal(U_("write error"));
+ sudo_fatal(U_("write error"));
}
}
(void) close(tfd);
* Sanity checks.
*/
if (stat(sp->tpath, &sb) < 0) {
- warningx(U_("unable to stat temporary file (%s), %s unchanged"),
+ sudo_warnx(U_("unable to stat temporary file (%s), %s unchanged"),
sp->tpath, sp->path);
goto done;
}
if (sb.st_size == 0 && orig_size != 0) {
- warningx(U_("zero length temporary file (%s), %s unchanged"),
+ sudo_warnx(U_("zero length temporary file (%s), %s unchanged"),
sp->tpath, sp->path);
sp->modified = true;
goto done;
}
} else {
- warningx(U_("editor (%s) failed, %s unchanged"), editor, sp->path);
+ sudo_warnx(U_("editor (%s) failed, %s unchanged"), editor, sp->path);
goto done;
}
if (modified)
sp->modified = modified;
else
- warningx(U_("%s unchanged"), sp->tpath);
+ sudo_warnx(U_("%s unchanged"), sp->tpath);
rval = true;
done:
last = TAILQ_LAST(&sudoerslist, sudoersfile_list);
fp = fopen(sp->tpath, "r+");
if (fp == NULL)
- fatalx(U_("unable to re-open temporary file (%s), %s unchanged."),
+ sudo_fatalx(U_("unable to re-open temporary file (%s), %s unchanged."),
sp->tpath, sp->path);
/* Clean slate for each parse */
/* Parse the sudoers temp file(s) */
sudoersrestart(fp);
if (sudoersparse() && !parse_error) {
- warningx(U_("unabled to parse temporary file (%s), unknown error"),
+ sudo_warnx(U_("unabled to parse temporary file (%s), unknown error"),
sp->tpath);
parse_error = true;
errorfile = sp->path;
}
}
if (errorfile != NULL && sp == NULL) {
- fatalx(U_("internal error, unable to find %s in list!"),
+ sudo_fatalx(U_("internal error, unable to find %s in list!"),
sudoers);
}
break;
if (oldperms) {
/* Use perms of the existing file. */
if (fstat(sp->fd, &sb) == -1)
- fatal(U_("unable to stat %s"), sp->path);
+ sudo_fatal(U_("unable to stat %s"), sp->path);
if (chown(sp->tpath, sb.st_uid, sb.st_gid) != 0) {
- warning(U_("unable to set (uid, gid) of %s to (%u, %u)"),
+ sudo_warn(U_("unable to set (uid, gid) of %s to (%u, %u)"),
sp->tpath, (unsigned int)sb.st_uid, (unsigned int)sb.st_gid);
}
if (chmod(sp->tpath, sb.st_mode & 0777) != 0) {
- warning(U_("unable to change mode of %s to 0%o"), sp->tpath,
+ sudo_warn(U_("unable to change mode of %s to 0%o"), sp->tpath,
(unsigned int)(sb.st_mode & 0777));
}
} else {
if (chown(sp->tpath, SUDOERS_UID, SUDOERS_GID) != 0) {
- warning(U_("unable to set (uid, gid) of %s to (%u, %u)"),
+ sudo_warn(U_("unable to set (uid, gid) of %s to (%u, %u)"),
sp->tpath, SUDOERS_UID, SUDOERS_GID);
goto done;
}
if (chmod(sp->tpath, SUDOERS_MODE) != 0) {
- warning(U_("unable to change mode of %s to 0%o"), sp->tpath,
+ sudo_warn(U_("unable to change mode of %s to 0%o"), sp->tpath,
SUDOERS_MODE);
goto done;
}
} else {
if (errno == EXDEV) {
char *av[4];
- warningx(U_("%s and %s not on the same file system, using mv to rename"),
+ sudo_warnx(U_("%s and %s not on the same file system, using mv to rename"),
sp->tpath, sp->path);
/* Build up argument vector for the command */
/* And run it... */
if (run_command(_PATH_MV, av)) {
- warningx(U_("command failed: '%s %s %s', %s unchanged"),
+ sudo_warnx(U_("command failed: '%s %s %s', %s unchanged"),
_PATH_MV, sp->tpath, sp->path, sp->path);
(void) unlink(sp->tpath);
efree(sp->tpath);
efree(sp->tpath);
sp->tpath = NULL;
} else {
- warning(U_("error renaming %s, %s unchanged"), sp->tpath, sp->path);
+ sudo_warn(U_("error renaming %s, %s unchanged"), sp->tpath, sp->path);
(void) unlink(sp->tpath);
goto done;
}
switch (pid = sudo_debug_fork()) {
case -1:
- fatal(U_("unable to execute %s"), path);
+ sudo_fatal(U_("unable to execute %s"), path);
break; /* NOTREACHED */
case 0:
sudo_endpwent();
sudo_endgrent();
closefrom(STDERR_FILENO + 1);
execv(path, argv);
- warning(U_("unable to run %s"), path);
+ sudo_warn(U_("unable to run %s"), path);
_exit(127);
break; /* NOTREACHED */
}
sudoers_path = "stdin";
} else if ((sudoersin = fopen(sudoers_path, "r")) == NULL) {
if (!quiet)
- warning(U_("unable to open %s"), sudoers_path);
+ sudo_warn(U_("unable to open %s"), sudoers_path);
goto done;
}
init_parser(sudoers_path, quiet);
if (sudoersparse() && !parse_error) {
if (!quiet)
- warningx(U_("failed to parse %s file, unknown error"), sudoers_path);
+ sudo_warnx(U_("failed to parse %s file, unknown error"), sudoers_path);
parse_error = true;
errorfile = sudoers_path;
}
/* entry->tpath = NULL; */
entry->doedit = doedit;
if (entry->fd == -1) {
- warning("%s", entry->path);
+ sudo_warn("%s", entry->path);
efree(entry);
debug_return_ptr(NULL);
}
if (!checkonly && !sudo_lock_file(entry->fd, SUDO_TLOCK))
- fatalx(U_("%s busy, try again later"), entry->path);
+ sudo_fatalx(U_("%s busy, try again later"), entry->path);
if ((fp = fdopen(entry->fd, "r")) == NULL)
- fatal("%s", entry->path);
+ sudo_fatal("%s", entry->path);
TAILQ_INSERT_TAIL(&sudoerslist, entry, entries);
} else {
/* Already exists, open .tmp version if there is one. */
if (entry->tpath != NULL) {
if ((fp = fopen(entry->tpath, "r")) == NULL)
- fatal("%s", entry->tpath);
+ sudo_fatal("%s", entry->tpath);
} else {
if ((fp = fdopen(entry->fd, "r")) == NULL)
- fatal("%s", entry->path);
+ sudo_fatal("%s", entry->path);
rewind(fp);
}
}
} else {
if (def_env_editor) {
/* If we are honoring $EDITOR this is a fatal error. */
- fatalx(U_("specified editor (%s) doesn't exist"), UserEditor);
+ sudo_fatalx(U_("specified editor (%s) doesn't exist"), UserEditor);
} else {
/* Otherwise, just ignore $EDITOR. */
UserEditor = NULL;
if (stat(UserEditor, &user_editor_sb) != 0) {
/* Should never happen since we already checked above. */
- fatal(U_("unable to stat editor (%s)"), UserEditor);
+ sudo_fatal(U_("unable to stat editor (%s)"), UserEditor);
}
EditorPath = estrdup(def_editor);
Editor = strtok(EditorPath, ":");
/* Bleah, none of the editors existed! */
if (Editor == NULL || *Editor == '\0')
- fatalx(U_("no editor found (editor path = %s)"), def_editor);
+ sudo_fatalx(U_("no editor found (editor path = %s)"), def_editor);
}
*args = EditorArgs;
debug_return_str(Editor);
} else {
if (!quiet) {
if (errno == ELOOP) {
- warningx(strict ?
+ sudo_warnx(strict ?
U_("Error: cycle in %s_Alias `%s'") :
U_("Warning: cycle in %s_Alias `%s'"),
type == HOSTALIAS ? "Host" : type == CMNDALIAS ? "Cmnd" :
type == USERALIAS ? "User" : type == RUNASALIAS ? "Runas" :
"Unknown", name);
} else {
- warningx(strict ?
+ sudo_warnx(strict ?
U_("Error: %s_Alias `%s' referenced but not defined") :
U_("Warning: %s_Alias `%s' referenced but not defined"),
type == HOSTALIAS ? "Host" : type == CMNDALIAS ? "Cmnd" :
struct alias *a = (struct alias *)v1;
char *prefix = (char *)v2;
- warningx_nodebug(U_("%s: unused %s_Alias %s"), prefix,
+ sudo_warnx_nodebug(U_("%s: unused %s_Alias %s"), prefix,
a->type == HOSTALIAS ? "Host" : a->type == CMNDALIAS ? "Cmnd" :
a->type == USERALIAS ? "User" : a->type == RUNASALIAS ? "Runas" :
"Unknown", a->name);
fputs(value->u.boolean ? "true" : "false", fp);
break;
case JSON_OBJECT:
- fatalx("internal error: can't print JSON_OBJECT");
+ sudo_fatalx("internal error: can't print JSON_OBJECT");
break;
case JSON_ARRAY:
- fatalx("internal error: can't print JSON_ARRAY");
+ sudo_fatalx("internal error: can't print JSON_ARRAY");
break;
}
case USERALIAS:
return TYPE_USERNAME;
default:
- fatalx_nodebug("unexpected alias type %d", alias_type);
+ sudo_fatalx_nodebug("unexpected alias type %d", alias_type);
}
}
case DEFAULTS_USER:
return TYPE_USERNAME;
default:
- fatalx_nodebug("unexpected defaults type %d", defaults_type);
+ sudo_fatalx_nodebug("unexpected defaults type %d", defaults_type);
}
}
if (*value.u.string == '#') {
id = atoid(m->name + 3, NULL, NULL, &errstr);
if (errstr != NULL) {
- warningx("internal error: non-Unix group ID %s: \"%s\"",
+ sudo_warnx("internal error: non-Unix group ID %s: \"%s\"",
errstr, m->name);
} else {
value.type = JSON_ID;
if (*value.u.string == '#') {
id = atoid(m->name + 2, NULL, NULL, &errstr);
if (errstr != NULL) {
- warningx("internal error: group ID %s: \"%s\"",
+ sudo_warnx("internal error: group ID %s: \"%s\"",
errstr, m->name);
} else {
value.type = JSON_ID;
if (*value.u.string == '#') {
id = atoid(m->name + 1, NULL, NULL, &errstr);
if (errstr != NULL) {
- warningx("internal error: user ID %s: \"%s\"",
+ sudo_warnx("internal error: user ID %s: \"%s\"",
errstr, m->name);
} else {
value.type = JSON_ID;
}
break;
default:
- fatalx("unexpected word type %d", word_type);
+ sudo_fatalx("unexpected word type %d", word_type);
}
break;
case ALL:
typestr = "useralias";
break;
default:
- fatalx("unexpected word type %d", word_type);
+ sudo_fatalx("unexpected word type %d", word_type);
}
break;
default:
- fatalx("unexpected member type %d", m->type);
+ sudo_fatalx("unexpected member type %d", m->type);
}
if (m->negated) {
value.u.string = "list_assign";
break;
default:
- warningx("internal error: unexpected list op %d", def->op);
+ sudo_warnx("internal error: unexpected list op %d", def->op);
value.u.string = "unsupported";
break;
}
TAILQ_FOREACH_SAFE(def, &defaults, entries, next) {
type = get_defaults_type(def);
if (type == -1) {
- warningx(U_("unknown defaults entry `%s'"), def->var);
+ sudo_warnx(U_("unknown defaults entry `%s'"), def->var);
/* XXX - just pass it through as a string anyway? */
continue;
}
def = next;
type = get_defaults_type(def);
if (type == -1) {
- warningx(U_("unknown defaults entry `%s'"), def->var);
+ sudo_warnx(U_("unknown defaults entry `%s'"), def->var);
/* XXX - just pass it through as a string anyway? */
break;;
}
sudoers_path = "stdin";
} else if ((sudoersin = fopen(sudoers_path, "r")) == NULL) {
if (!quiet)
- warning(U_("unable to open %s"), sudoers_path);
+ sudo_warn(U_("unable to open %s"), sudoers_path);
goto done;
}
if (strcmp(export_path, "-") != 0) {
if (strcmp(sudoers_path, export_path) == 0) {
if (!quiet) {
- warningx(U_("%s: input and output files must be different"),
+ sudo_warnx(U_("%s: input and output files must be different"),
sudoers_path);
}
goto done;
}
if ((export_fp = fopen(export_path, "w")) == NULL) {
if (!quiet)
- warning(U_("unable to open %s"), export_path);
+ sudo_warn(U_("unable to open %s"), export_path);
goto done;
}
}
init_parser(sudoers_path, quiet);
if (sudoersparse() && !parse_error) {
if (!quiet)
- warningx(U_("failed to parse %s file, unknown error"), sudoers_path);
+ sudo_warnx(U_("failed to parse %s file, unknown error"), sudoers_path);
parse_error = true;
errorfile = sudoers_path;
}
if (parse_error) {
if (!quiet) {
if (errorlineno != -1)
- warningx(_("parse error in %s near line %d\n"),
+ sudo_warnx(_("parse error in %s near line %d\n"),
errorfile, errorlineno);
else if (errorfile != NULL)
- warningx(_("parse error in %s\n"), errorfile);
+ sudo_warnx(_("parse error in %s\n"), errorfile);
}
goto done;
}
* or certain pam modules won't be able to track their state.
*/
if (policy_init_session(details) != true)
- fatalx(U_("policy plugin failed session initialization"));
+ sudo_fatalx(U_("policy plugin failed session initialization"));
cmnd_pid = sudo_debug_fork();
switch (cmnd_pid) {
case -1:
- fatal(U_("unable to fork"));
+ sudo_fatal(U_("unable to fork"));
break;
case 0:
/* child */
evbase = sudo_ev_base_alloc();
if (evbase == NULL)
- fatal(NULL);
+ sudo_fatal(NULL);
/* Event for incoming signals via signal_pipe. */
signal_event = sudo_ev_alloc(signal_pipe[0],
SUDO_EV_READ|SUDO_EV_PERSIST, signal_pipe_cb, ec);
if (signal_event == NULL)
- fatal(NULL);
+ sudo_fatal(NULL);
if (sudo_ev_add(evbase, signal_event, NULL, false) == -1)
- fatal(U_("unable to add event to queue"));
+ sudo_fatal(U_("unable to add event to queue"));
/* Event for command status via backchannel. */
backchannel_event = sudo_ev_alloc(backchannel,
SUDO_EV_READ|SUDO_EV_PERSIST, backchannel_cb, ec);
if (backchannel_event == NULL)
- fatal(NULL);
+ sudo_fatal(NULL);
if (sudo_ev_add(evbase, backchannel_event, NULL, false) == -1)
- fatal(U_("unable to add event to queue"));
+ sudo_fatal(U_("unable to add event to queue"));
/* The signal forwarding event gets added on demand. */
sigfwd_event = sudo_ev_alloc(backchannel,
SUDO_EV_WRITE, forward_signals, NULL);
if (sigfwd_event == NULL)
- fatal(NULL);
+ sudo_fatal(NULL);
sudo_debug_printf(SUDO_DEBUG_INFO, "signal pipe fd %d\n", signal_pipe[0]);
sudo_debug_printf(SUDO_DEBUG_INFO, "backchannel fd %d\n", backchannel);
* Parent sends signal info to child and child sends back wait status.
*/
if (socketpair(PF_UNIX, SOCK_STREAM, 0, sv) == -1)
- fatal(U_("unable to create sockets"));
+ sudo_fatal(U_("unable to create sockets"));
/*
* Signals to forward to the child process (excluding SIGALRM and SIGCHLD).
if (log_io)
add_io_events(evbase);
if (sudo_ev_loop(evbase, 0) == -1)
- warning(U_("error in event loop"));
+ sudo_warn(U_("error in event loop"));
if (sudo_ev_got_break(evbase)) {
/* error from callback */
sudo_debug_printf(SUDO_DEBUG_ERROR, "event loop exited prematurely");
if (ISSET(details->flags, CD_RBAC_ENABLED)) {
/* This is probably not needed in log_io mode. */
if (selinux_restore_tty() != 0)
- warningx(U_("unable to restore tty label"));
+ sudo_warnx(U_("unable to restore tty label"));
}
#endif
if (child_pgrp != ppgrp) {
if (tcsetpgrp(fd, child_pgrp) == 0) {
if (killpg(child_pgrp, SIGCONT) != 0) {
- warning("kill(%d, SIGCONT)",
+ sudo_warn("kill(%d, SIGCONT)",
(int)child_pgrp);
}
close(fd);
sudo_sigaction(SIGTSTP, &sa, &osa);
}
if (kill(getpid(), signo) != 0)
- warning("kill(%d, SIG%s)", (int)getpid(), signame);
+ sudo_warn("kill(%d, SIG%s)", (int)getpid(), signame);
if (signo == SIGTSTP)
sudo_sigaction(SIGTSTP, &osa, NULL);
if (fd != -1) {
if (signo == SIGALRM) {
terminate_command(child, false);
} else if (kill(child, signo) != 0) {
- warning("kill(%d, SIG%s)", (int)child, signame);
+ sudo_warn("kill(%d, SIG%s)", (int)child, signame);
}
}
rc = 0;
sa.sa_handler = SIG_DFL;
sudo_sigaction(SIGTSTP, &sa, NULL);
if (kill(getpid(), SIGTSTP) != 0)
- warning("kill(%d, SIGTSTP)", (int)getpid());
+ sudo_warn("kill(%d, SIGTSTP)", (int)getpid());
/* No need to reinstall SIGTSTP handler. */
}
debug_return_int(rval);
TAILQ_INSERT_TAIL(&sigfwd_list, sigfwd, entries);
if (sudo_ev_add(evbase, sigfwd_event, NULL, true) == -1)
- fatal(U_("unable to add event to queue"));
+ sudo_fatal(U_("unable to add event to queue"));
debug_return;
}
(void)priv_set(PRIV_ON, PRIV_INHERITABLE, "PRIV_FILE_DAC_SEARCH", NULL);
if (priv_set(PRIV_OFF, PRIV_LIMIT, "PRIV_PROC_EXEC", NULL) == 0)
debug_return_const_ptr(envp);
- warning(U_("unable to remove PRIV_PROC_EXEC from PRIV_LIMIT"));
+ sudo_warn(U_("unable to remove PRIV_PROC_EXEC from PRIV_LIMIT"));
#endif /* HAVE_PRIV_SET */
#ifdef _PATH_SUDO_NOEXEC
preload = sudo_new_key_val(RTLD_PRELOAD_VAR, sudo_conf_noexec_path());
# endif
if (preload == NULL)
- fatal(NULL);
+ sudo_fatal(NULL);
nenvp[env_len++] = preload;
nenvp[env_len] = NULL;
} else {
static void check_foreground(void);
/*
- * Cleanup hook for fatal()/fatalx()
+ * Cleanup hook for sudo_fatal()/sudo_fatalx()
*/
static void
pty_cleanup(void)
if (io_fds[SFD_USERTTY] != -1) {
if (!get_pty(&io_fds[SFD_MASTER], &io_fds[SFD_SLAVE],
slavename, sizeof(slavename), uid))
- fatal(U_("unable to allocate pty"));
+ sudo_fatal(U_("unable to allocate pty"));
/* Add entry to utmp/utmpx? */
if (utmp_user != NULL)
utmp_login(tty, slavename, io_fds[SFD_SLAVE], utmp_user);
}
sudo_debug_printf(SUDO_DEBUG_INFO, "kill parent SIG%s", signame);
if (killpg(ppgrp, signo) != 0)
- warning("killpg(%d, SIG%s)", (int)ppgrp, signame);
+ sudo_warn("killpg(%d, SIG%s)", (int)ppgrp, signame);
/* Check foreground/background status on resume. */
check_foreground();
if (iob->wevent != NULL &&
(foreground || !USERTTY_EVENT(iob->wevent))) {
if (sudo_ev_add(evbase, iob->wevent, NULL, false) == -1)
- fatal(U_("unable to add event to queue"));
+ sudo_fatal(U_("unable to add event to queue"));
}
/* Re-enable reader if buffer is not full. */
if (iob->len != sizeof(iob->buf)) {
if (sudo_ev_add(evbase, iob->revent, NULL, false) == -1)
- fatal(U_("unable to add event to queue"));
+ sudo_fatal(U_("unable to add event to queue"));
}
break;
}
/* Re-enable writer if buffer is not empty. */
if (iob->len > iob->off) {
if (sudo_ev_add(evbase, iob->wevent, NULL, false) == -1)
- fatal(U_("unable to add event to queue"));
+ sudo_fatal(U_("unable to add event to queue"));
}
/* Enable reader if buffer is not full. */
if (iob->revent != NULL &&
(ttymode == TERM_RAW || !USERTTY_EVENT(iob->revent))) {
if (iob->len != sizeof(iob->buf)) {
if (sudo_ev_add(evbase, iob->revent, NULL, false) == -1)
- fatal(U_("unable to add event to queue"));
+ sudo_fatal(U_("unable to add event to queue"));
}
}
}
iob->action = action;
iob->buf[0] = '\0';
if (iob->revent == NULL || iob->wevent == NULL)
- fatal(NULL);
+ sudo_fatal(NULL);
SLIST_INSERT_HEAD(head, iob, entries);
debug_return;
sudo_debug_printf(SUDO_DEBUG_INFO, "stdin not a tty, creating a pipe");
pipeline = true;
if (pipe(io_pipe[STDIN_FILENO]) != 0)
- fatal(U_("unable to create pipe"));
+ sudo_fatal(U_("unable to create pipe"));
io_buf_new(STDIN_FILENO, io_pipe[STDIN_FILENO][1],
log_stdin, &iobufs);
io_fds[SFD_STDIN] = io_pipe[STDIN_FILENO][0];
sudo_debug_printf(SUDO_DEBUG_INFO, "stdout not a tty, creating a pipe");
pipeline = true;
if (pipe(io_pipe[STDOUT_FILENO]) != 0)
- fatal(U_("unable to create pipe"));
+ sudo_fatal(U_("unable to create pipe"));
io_buf_new(io_pipe[STDOUT_FILENO][0], STDOUT_FILENO,
log_stdout, &iobufs);
io_fds[SFD_STDOUT] = io_pipe[STDOUT_FILENO][1];
if (io_fds[SFD_STDERR] == -1 || !isatty(STDERR_FILENO)) {
sudo_debug_printf(SUDO_DEBUG_INFO, "stderr not a tty, creating a pipe");
if (pipe(io_pipe[STDERR_FILENO]) != 0)
- fatal(U_("unable to create pipe"));
+ sudo_fatal(U_("unable to create pipe"));
io_buf_new(io_pipe[STDERR_FILENO][0], STDERR_FILENO,
log_stderr, &iobufs);
io_fds[SFD_STDERR] = io_pipe[STDERR_FILENO][1];
n = sudo_term_raw(io_fds[SFD_USERTTY], 0);
} while (!n && errno == EINTR);
if (!n)
- fatal(U_("unable to set terminal to raw mode"));
+ sudo_fatal(U_("unable to set terminal to raw mode"));
}
}
* or certain pam modules won't be able to track their state.
*/
if (policy_init_session(details) != true)
- fatalx(U_("policy plugin failed session initialization"));
+ sudo_fatalx(U_("policy plugin failed session initialization"));
/*
* Block some signals until cmnd_pid is set in the parent to avoid a
child = sudo_debug_fork();
switch (child) {
case -1:
- fatal(U_("unable to fork"));
+ sudo_fatal(U_("unable to fork"));
break;
case 0:
/* child */
"added I/O revent %p, fd %d, events %d",
iob->revent, iob->revent->fd, iob->revent->events);
if (sudo_ev_add(evbase, iob->revent, NULL, false) == -1)
- fatal(U_("unable to add event to queue"));
+ sudo_fatal(U_("unable to add event to queue"));
}
}
if (iob->wevent != NULL &&
"added I/O wevent %p, fd %d, events %d",
iob->wevent, iob->wevent->fd, iob->wevent->events);
if (sudo_ev_add(evbase, iob->wevent, NULL, false) == -1)
- fatal(U_("unable to add event to queue"));
+ sudo_fatal(U_("unable to add event to queue"));
}
}
}
/* Create temporary event base for flushing. */
evbase = sudo_ev_base_alloc();
if (evbase == NULL)
- fatal(NULL);
+ sudo_fatal(NULL);
/* Avoid reading from /dev/tty, just flush existing data. */
SLIST_FOREACH(iob, &iobufs, entries) {
if (iob->revent != NULL && !USERTTY_EVENT(iob->revent)) {
if (iob->len != sizeof(iob->buf)) {
if (sudo_ev_add(evbase, iob->revent, NULL, false) == -1)
- fatal(U_("unable to add event to queue"));
+ sudo_fatal(U_("unable to add event to queue"));
}
}
/* Flush any write buffers with data in them. */
if (iob->wevent != NULL) {
if (iob->len > iob->off) {
if (sudo_ev_add(evbase, iob->wevent, NULL, false) == -1)
- fatal(U_("unable to add event to queue"));
+ sudo_fatal(U_("unable to add event to queue"));
}
}
}
n = read(fd, &signo, sizeof(signo));
if (n == -1) {
if (errno != EINTR && errno != EAGAIN) {
- warning(U_("error reading from signal pipe"));
+ sudo_warn(U_("error reading from signal pipe"));
sudo_ev_loopbreak(mc->evbase);
}
} else {
n = read(fd, mc->cstat, sizeof(struct command_status));
if (n == -1) {
if (errno != EINTR && errno != EAGAIN) {
- warning(U_("error reading from pipe"));
+ sudo_warn(U_("error reading from pipe"));
sudo_ev_loopbreak(mc->evbase);
}
} else {
if (n == -1) {
if (errno == EINTR || errno == EAGAIN)
debug_return;
- warning(U_("error reading from socketpair"));
+ sudo_warn(U_("error reading from socketpair"));
} else {
/* short read or EOF, parent process died? */
}
if (cstmp.type == CMD_SIGNO) {
deliver_signal(cmnd_pid, cstmp.val, true);
} else {
- warningx(U_("unexpected reply type on backchannel: %d"), cstmp.type);
+ sudo_warnx(U_("unexpected reply type on backchannel: %d"), cstmp.type);
}
}
debug_return;
* the event loop.
*/
if (pipe_nonblock(signal_pipe) != 0)
- fatal(U_("unable to create pipe"));
+ sudo_fatal(U_("unable to create pipe"));
/* Reset SIGWINCH and SIGALRM. */
memset(&sa, 0, sizeof(sa));
* This allows us to be notified when the command has been suspended.
*/
if (setsid() == -1) {
- warning("setsid");
+ sudo_warn("setsid");
goto bad;
}
if (io_fds[SFD_SLAVE] != -1) {
#ifdef TIOCSCTTY
if (ioctl(io_fds[SFD_SLAVE], TIOCSCTTY, NULL) != 0)
- fatal(U_("unable to set controlling tty"));
+ sudo_fatal(U_("unable to set controlling tty"));
#else
/* Set controlling tty by reopening slave. */
if ((n = open(slavename, O_RDWR)) >= 0)
/* Start command and wait for it to stop or exit */
if (pipe(errpipe) == -1)
- fatal(U_("unable to create pipe"));
+ sudo_fatal(U_("unable to create pipe"));
cmnd_pid = sudo_debug_fork();
if (cmnd_pid == -1) {
- warning(U_("unable to fork"));
+ sudo_warn(U_("unable to fork"));
goto bad;
}
if (cmnd_pid == 0) {
*/
evbase = sudo_ev_base_alloc();
if (evbase == NULL)
- fatal(NULL);
+ sudo_fatal(NULL);
memset(&cstat, 0, sizeof(cstat));
mc.cstat = &cstat;
mc.signal_pipe_event = sudo_ev_alloc(signal_pipe[0],
SUDO_EV_READ|SUDO_EV_PERSIST, mon_signal_pipe_cb, &mc);
if (mc.signal_pipe_event == NULL)
- fatal(NULL);
+ sudo_fatal(NULL);
if (sudo_ev_add(evbase, mc.signal_pipe_event, NULL, false) == -1)
- fatal(U_("unable to add event to queue"));
+ sudo_fatal(U_("unable to add event to queue"));
mc.errpipe_event = sudo_ev_alloc(errpipe[0],
SUDO_EV_READ|SUDO_EV_PERSIST, mon_errpipe_cb, &mc);
if (mc.errpipe_event == NULL)
- fatal(NULL);
+ sudo_fatal(NULL);
if (sudo_ev_add(evbase, mc.errpipe_event, NULL, false) == -1)
- fatal(U_("unable to add event to queue"));
+ sudo_fatal(U_("unable to add event to queue"));
mc.backchannel_event = sudo_ev_alloc(backchannel,
SUDO_EV_READ|SUDO_EV_PERSIST, mon_backchannel_cb, &mc);
if (mc.backchannel_event == NULL)
- fatal(NULL);
+ sudo_fatal(NULL);
if (sudo_ev_add(evbase, mc.backchannel_event, NULL, false) == -1)
- fatal(U_("unable to add event to queue"));
+ sudo_fatal(U_("unable to add event to queue"));
/*
* Wait for errno on pipe, signal on backchannel or for SIGCHLD.
debug_decl(exec_pty, SUDO_DEBUG_EXEC);
/* Register cleanup function */
- fatal_callback_register(pty_cleanup);
+ sudo_fatal_callback_register(pty_cleanup);
/* Set command process group here too to avoid a race. */
setpgid(0, self);
if (dup2(io_fds[SFD_STDIN], STDIN_FILENO) == -1 ||
dup2(io_fds[SFD_STDOUT], STDOUT_FILENO) == -1 ||
dup2(io_fds[SFD_STDERR], STDERR_FILENO) == -1)
- fatal("dup2");
+ sudo_fatal("dup2");
/* Wait for parent to grant us the tty if we are foreground. */
if (foreground && !ISSET(details->flags, CD_EXEC_BG)) {
case SUDO_HOOK_RET_STOP:
goto done;
default:
- warningx_nodebug("invalid setenv hook return value: %d", rc);
+ sudo_warnx_nodebug("invalid setenv hook return value: %d", rc);
break;
}
}
case SUDO_HOOK_RET_STOP:
goto done;
default:
- warningx_nodebug("invalid putenv hook return value: %d", rc);
+ sudo_warnx_nodebug("invalid putenv hook return value: %d", rc);
break;
}
}
case SUDO_HOOK_RET_STOP:
goto done;
default:
- warningx_nodebug("invalid getenv hook return value: %d", rc);
+ sudo_warnx_nodebug("invalid getenv hook return value: %d", rc);
break;
}
}
case SUDO_HOOK_RET_STOP:
goto done;
default:
- warningx_nodebug("invalid unsetenv hook return value: %d", rc);
+ sudo_warnx_nodebug("invalid unsetenv hook return value: %d", rc);
break;
}
}
if (info->path[0] == '/') {
if (strlcpy(fullpath, info->path, pathsize) >= pathsize) {
- warningx(U_("error in %s, line %d while loading plugin `%s'"),
+ sudo_warnx(U_("error in %s, line %d while loading plugin `%s'"),
_PATH_SUDO_CONF, info->lineno, info->symbol_name);
- warningx(U_("%s: %s"), info->path, strerror(ENAMETOOLONG));
+ sudo_warnx(U_("%s: %s"), info->path, strerror(ENAMETOOLONG));
goto done;
}
status = stat(fullpath, sb);
/* Check static symbols. */
if (strcmp(info->path, SUDOERS_PLUGIN) == 0) {
if (strlcpy(fullpath, info->path, pathsize) >= pathsize) {
- warningx(U_("error in %s, line %d while loading plugin `%s'"),
+ sudo_warnx(U_("error in %s, line %d while loading plugin `%s'"),
_PATH_SUDO_CONF, info->lineno, info->symbol_name);
- warningx(U_("%s: %s"), info->path, strerror(ENAMETOOLONG));
+ sudo_warnx(U_("%s: %s"), info->path, strerror(ENAMETOOLONG));
goto done;
}
/* Plugin is static, fake up struct stat. */
len = snprintf(fullpath, pathsize, "%s%s", _PATH_SUDO_PLUGIN_DIR,
info->path);
if (len <= 0 || (size_t)len >= pathsize) {
- warningx(U_("error in %s, line %d while loading plugin `%s'"),
+ sudo_warnx(U_("error in %s, line %d while loading plugin `%s'"),
_PATH_SUDO_CONF, info->lineno, info->symbol_name);
- warningx(U_("%s%s: %s"), _PATH_SUDO_PLUGIN_DIR, info->path,
+ sudo_warnx(U_("%s%s: %s"), _PATH_SUDO_PLUGIN_DIR, info->path,
strerror(ENAMETOOLONG));
goto done;
}
debug_decl(sudo_check_plugin, SUDO_DEBUG_PLUGIN)
if (sudo_stat_plugin(info, fullpath, pathsize, &sb) != 0) {
- warningx(U_("error in %s, line %d while loading plugin `%s'"),
+ sudo_warnx(U_("error in %s, line %d while loading plugin `%s'"),
_PATH_SUDO_CONF, info->lineno, info->symbol_name);
- warning("%s%s", _PATH_SUDO_PLUGIN_DIR, info->path);
+ sudo_warn("%s%s", _PATH_SUDO_PLUGIN_DIR, info->path);
goto done;
}
if (sb.st_uid != ROOT_UID) {
- warningx(U_("error in %s, line %d while loading plugin `%s'"),
+ sudo_warnx(U_("error in %s, line %d while loading plugin `%s'"),
_PATH_SUDO_CONF, info->lineno, info->symbol_name);
- warningx(U_("%s must be owned by uid %d"), fullpath, ROOT_UID);
+ sudo_warnx(U_("%s must be owned by uid %d"), fullpath, ROOT_UID);
goto done;
}
if ((sb.st_mode & (S_IWGRP|S_IWOTH)) != 0) {
- warningx(U_("error in %s, line %d while loading plugin `%s'"),
+ sudo_warnx(U_("error in %s, line %d while loading plugin `%s'"),
_PATH_SUDO_CONF, info->lineno, info->symbol_name);
- warningx(U_("%s must be only be writable by owner"), fullpath);
+ sudo_warnx(U_("%s must be only be writable by owner"), fullpath);
goto done;
}
rval = true;
/* Open plugin and map in symbol */
handle = sudo_dso_load(path, SUDO_DSO_LAZY|SUDO_DSO_GLOBAL);
if (!handle) {
- warningx(U_("error in %s, line %d while loading plugin `%s'"),
+ sudo_warnx(U_("error in %s, line %d while loading plugin `%s'"),
_PATH_SUDO_CONF, info->lineno, info->symbol_name);
- warningx(U_("unable to load %s: %s"), path, sudo_dso_strerror());
+ sudo_warnx(U_("unable to load %s: %s"), path, sudo_dso_strerror());
goto done;
}
plugin = sudo_dso_findsym(handle, info->symbol_name);
if (!plugin) {
- warningx(U_("error in %s, line %d while loading plugin `%s'"),
+ sudo_warnx(U_("error in %s, line %d while loading plugin `%s'"),
_PATH_SUDO_CONF, info->lineno, info->symbol_name);
- warningx(U_("unable to find symbol `%s' in %s"), info->symbol_name, path);
+ sudo_warnx(U_("unable to find symbol `%s' in %s"), info->symbol_name, path);
goto done;
}
if (plugin->type != SUDO_POLICY_PLUGIN && plugin->type != SUDO_IO_PLUGIN) {
- warningx(U_("error in %s, line %d while loading plugin `%s'"),
+ sudo_warnx(U_("error in %s, line %d while loading plugin `%s'"),
_PATH_SUDO_CONF, info->lineno, info->symbol_name);
- warningx(U_("unknown policy type %d found in %s"), plugin->type, path);
+ sudo_warnx(U_("unknown policy type %d found in %s"), plugin->type, path);
goto done;
}
if (SUDO_API_VERSION_GET_MAJOR(plugin->version) != SUDO_API_VERSION_MAJOR) {
- warningx(U_("error in %s, line %d while loading plugin `%s'"),
+ sudo_warnx(U_("error in %s, line %d while loading plugin `%s'"),
_PATH_SUDO_CONF, info->lineno, info->symbol_name);
- warningx(U_("incompatible plugin major version %d (expected %d) found in %s"),
+ sudo_warnx(U_("incompatible plugin major version %d (expected %d) found in %s"),
SUDO_API_VERSION_GET_MAJOR(plugin->version),
SUDO_API_VERSION_MAJOR, path);
goto done;
if (policy_plugin->handle) {
/* Ignore duplicate entries. */
if (strcmp(policy_plugin->name, info->symbol_name) != 0) {
- warningx(U_("ignoring policy plugin `%s' in %s, line %d"),
+ sudo_warnx(U_("ignoring policy plugin `%s' in %s, line %d"),
info->symbol_name, _PATH_SUDO_CONF, info->lineno);
- warningx(U_("only a single policy plugin may be specified"));
+ sudo_warnx(U_("only a single policy plugin may be specified"));
goto done;
}
- warningx(U_("ignoring duplicate policy plugin `%s' in %s, line %d"),
+ sudo_warnx(U_("ignoring duplicate policy plugin `%s' in %s, line %d"),
info->symbol_name, _PATH_SUDO_CONF, info->lineno);
sudo_dso_unload(handle);
handle = NULL;
/* Check for duplicate entries. */
TAILQ_FOREACH(container, io_plugins, entries) {
if (strcmp(container->name, info->symbol_name) == 0) {
- warningx(U_("ignoring duplicate I/O plugin `%s' in %s, line %d"),
+ sudo_warnx(U_("ignoring duplicate I/O plugin `%s' in %s, line %d"),
info->symbol_name, _PATH_SUDO_CONF, info->lineno);
sudo_dso_unload(handle);
handle = NULL;
}
}
if (policy_plugin->u.policy->check_policy == NULL) {
- warningx(U_("policy plugin %s does not include a check_policy method"),
+ sudo_warnx(U_("policy plugin %s does not include a check_policy method"),
policy_plugin->name);
rval = false;
goto done;
#ifdef HAVE_LIBINTL_H
/* No need to swap locales in the front end. */
char *
-warning_gettext(const char *msgid)
+sudo_warn_gettext(const char *msgid)
{
return gettext(msgid);
}
"%s%s/", cp == *addrinfo ? "" : " ",
inet_ntoa(sin->sin_addr));
if (len <= 0 || len >= ailen - (*addrinfo - cp)) {
- warningx(U_("internal error, %s overflow"), __func__);
+ sudo_warnx(U_("internal error, %s overflow"), __func__);
goto done;
}
cp += len;
len = snprintf(cp, ailen - (*addrinfo - cp),
"%s", inet_ntoa(sin->sin_addr));
if (len <= 0 || len >= ailen - (*addrinfo - cp)) {
- warningx(U_("internal error, %s overflow"), __func__);
+ sudo_warnx(U_("internal error, %s overflow"), __func__);
goto done;
}
cp += len;
len = snprintf(cp, ailen - (*addrinfo - cp),
"%s%s/", cp == *addrinfo ? "" : " ", addrbuf);
if (len <= 0 || len >= ailen - (*addrinfo - cp)) {
- warningx(U_("internal error, %s overflow"), __func__);
+ sudo_warnx(U_("internal error, %s overflow"), __func__);
goto done;
}
cp += len;
inet_ntop(AF_INET6, &sin6->sin6_addr, addrbuf, sizeof(addrbuf));
len = snprintf(cp, ailen - (*addrinfo - cp), "%s", addrbuf);
if (len <= 0 || len >= ailen - (*addrinfo - cp)) {
- warningx(U_("internal error, %s overflow"), __func__);
+ sudo_warnx(U_("internal error, %s overflow"), __func__);
goto done;
}
cp += len;
sock = socket(AF_INET, SOCK_DGRAM, 0);
if (sock < 0)
- fatal(U_("unable to open socket"));
+ sudo_fatal(U_("unable to open socket"));
/*
* Get interface configuration or return.
"%s%s/", cp == *addrinfo ? "" : " ",
inet_ntoa(sin->sin_addr));
if (len <= 0 || len >= ailen - (*addrinfo - cp)) {
- warningx(U_("internal error, %s overflow"), __func__);
+ sudo_warnx(U_("internal error, %s overflow"), __func__);
goto done;
}
cp += len;
len = snprintf(cp, ailen - (*addrinfo - cp),
"%s", inet_ntoa(sin->sin_addr));
if (len <= 0 || len >= ailen - (*addrinfo - cp)) {
- warningx(U_("internal error, %s overflow"), __func__);
+ sudo_warnx(U_("internal error, %s overflow"), __func__);
goto done;
}
cp += len;
break;
case 'C':
if (strtonum(optarg, 3, INT_MAX, NULL) == 0) {
- warningx(_("the argument to -C must be a number greater than or equal to 3"));
+ sudo_warnx(_("the argument to -C must be a number greater than or equal to 3"));
usage(1);
}
sudo_settings[ARG_CLOSEFROM].value = optarg;
if (ISSET(flags, MODE_LOGIN_SHELL)) {
if (ISSET(flags, MODE_SHELL)) {
- warningx(U_("you may not specify both the `-i' and `-s' options"));
+ sudo_warnx(U_("you may not specify both the `-i' and `-s' options"));
usage(1);
}
if (ISSET(flags, MODE_PRESERVE_ENV)) {
- warningx(U_("you may not specify both the `-i' and `-E' options"));
+ sudo_warnx(U_("you may not specify both the `-i' and `-E' options"));
usage(1);
}
SET(flags, MODE_SHELL);
if (mode == MODE_EDIT &&
(ISSET(flags, MODE_PRESERVE_ENV) || env_add[0] != NULL)) {
if (ISSET(mode, MODE_PRESERVE_ENV))
- warningx(U_("the `-E' option is not valid in edit mode"));
+ sudo_warnx(U_("the `-E' option is not valid in edit mode"));
if (env_add[0] != NULL)
- warningx(U_("you may not specify environment variables in edit mode"));
+ sudo_warnx(U_("you may not specify environment variables in edit mode"));
usage(1);
}
if ((runas_user != NULL || runas_group != NULL) &&
usage(1);
}
if (list_user != NULL && mode != MODE_LIST && mode != MODE_CHECK) {
- warningx(U_("the `-U' option may only be used with the `-l' option"));
+ sudo_warnx(U_("the `-U' option may only be used with the `-l' option"));
usage(1);
}
if (ISSET(tgetpass_flags, TGP_STDIN) && ISSET(tgetpass_flags, TGP_ASKPASS)) {
- warningx(U_("the `-A' and `-S' options may not be used together"));
+ sudo_warnx(U_("the `-A' and `-S' options may not be used together"));
usage(1);
}
if ((argc == 0 && mode == MODE_EDIT) ||
settings[j] = sudo_new_key_val(sudo_settings[i].name,
sudo_settings[i].value);
if (settings[j] == NULL)
- fatal(NULL);
+ sudo_fatal(NULL);
j++;
}
}
argv--;
argv[0] = "sudoedit";
#else
- fatalx(U_("sudoedit is not supported on this platform"));
+ sudo_fatalx(U_("sudoedit is not supported on this platform"));
#endif
}
{
debug_decl(usage_excl, SUDO_DEBUG_ARGS)
- warningx(U_("Only one of the -e, -h, -i, -K, -l, -s, -v or -V options may be specified"));
+ sudo_warnx(U_("Only one of the -e, -h, -i, -K, -l, -s, -v or -V options may be specified"));
usage(fatal);
}
/* Kernel may not have audit support. */
if (errno != EINVAL && errno != EPROTONOSUPPORT && errno != EAFNOSUPPORT
)
- fatal(U_("unable to open audit system"));
+ sudo_fatal(U_("unable to open audit system"));
} else {
/* audit role change using the same format as newrole(1) */
easprintf(&message, "newrole: old-context=%s new-context=%s",
rc = audit_log_user_message(au_fd, AUDIT_USER_ROLE_CHANGE,
message, NULL, NULL, ttyn, 1);
if (rc <= 0)
- warning(U_("unable to send audit message"));
+ sudo_warn(U_("unable to send audit message"));
efree(message);
close(au_fd);
}
/* Verify that the tty still has the context set by sudo. */
if ((retval = fgetfilecon(se_state.ttyfd, &chk_tty_context)) < 0) {
- warning(U_("unable to fgetfilecon %s"), se_state.ttyn);
+ sudo_warn(U_("unable to fgetfilecon %s"), se_state.ttyn);
goto skip_relabel;
}
if ((retval = strcmp(chk_tty_context, se_state.new_tty_context))) {
- warningx(U_("%s changed labels"), se_state.ttyn);
+ sudo_warnx(U_("%s changed labels"), se_state.ttyn);
goto skip_relabel;
}
if ((retval = fsetfilecon(se_state.ttyfd, se_state.tty_context)) < 0)
- warning(U_("unable to restore context for %s"), se_state.ttyn);
+ sudo_warn(U_("unable to restore context for %s"), se_state.ttyn);
skip_relabel:
if (se_state.ttyfd != -1) {
if (ptyfd == -1) {
se_state.ttyfd = open(ttyn, O_RDWR|O_NONBLOCK);
if (se_state.ttyfd == -1) {
- warning(U_("unable to open %s, not relabeling tty"), ttyn);
+ sudo_warn(U_("unable to open %s, not relabeling tty"), ttyn);
if (se_state.enforcing)
goto bad;
}
}
if (fgetfilecon(se_state.ttyfd, &tty_con) < 0) {
- warning(U_("unable to get current tty context, not relabeling tty"));
+ sudo_warn(U_("unable to get current tty context, not relabeling tty"));
if (se_state.enforcing)
goto bad;
}
if (tty_con && (security_compute_relabel(se_state.new_context, tty_con,
SECCLASS_CHR_FILE, &new_tty_con) < 0)) {
- warning(U_("unable to get new tty context, not relabeling tty"));
+ sudo_warn(U_("unable to get new tty context, not relabeling tty"));
if (se_state.enforcing)
goto bad;
}
if (new_tty_con != NULL) {
if (fsetfilecon(se_state.ttyfd, new_tty_con) < 0) {
- warning(U_("unable to set new tty context"));
+ sudo_warn(U_("unable to set new tty context"));
if (se_state.enforcing)
goto bad;
}
/* Reopen pty that was relabeled, std{in,out,err} are reset later. */
se_state.ttyfd = open(ttyn, O_RDWR|O_NOCTTY, 0);
if (se_state.ttyfd == -1) {
- warning(U_("unable to open %s"), ttyn);
+ sudo_warn(U_("unable to open %s"), ttyn);
if (se_state.enforcing)
goto bad;
}
if (dup2(se_state.ttyfd, ptyfd) == -1) {
- warning("dup2");
+ sudo_warn("dup2");
goto bad;
}
} else {
close(se_state.ttyfd);
se_state.ttyfd = open(ttyn, O_RDWR|O_NONBLOCK);
if (se_state.ttyfd == -1) {
- warning(U_("unable to open %s"), ttyn);
+ sudo_warn(U_("unable to open %s"), ttyn);
goto bad;
}
(void)fcntl(se_state.ttyfd, F_SETFL,
fcntl(se_state.ttyfd, F_GETFL, 0) & ~O_NONBLOCK);
for (fd = STDIN_FILENO; fd <= STDERR_FILENO; fd++) {
if (isatty(fd) && dup2(se_state.ttyfd, fd) == -1) {
- warning("dup2");
+ sudo_warn("dup2");
goto bad;
}
}
/* We must have a role, the type is optional (we can use the default). */
if (!role) {
- warningx(U_("you must specify a role for type %s"), type);
+ sudo_warnx(U_("you must specify a role for type %s"), type);
errno = EINVAL;
goto bad;
}
if (!type) {
if (get_default_type(role, &typebuf)) {
- warningx(U_("unable to get default type for role %s"), role);
+ sudo_warnx(U_("unable to get default type for role %s"), role);
errno = EINVAL;
goto bad;
}
* type we will be running the command as.
*/
if (context_role_set(context, role)) {
- warning(U_("failed to set new role %s"), role);
+ sudo_warn(U_("failed to set new role %s"), role);
goto bad;
}
if (context_type_set(context, type)) {
- warning(U_("failed to set new type %s"), type);
+ sudo_warn(U_("failed to set new type %s"), type);
goto bad;
}
*/
new_context = estrdup(context_str(context));
if (security_check_context(new_context) < 0) {
- warningx(U_("%s is not a valid context"), new_context);
+ sudo_warnx(U_("%s is not a valid context"), new_context);
errno = EINVAL;
goto bad;
}
#ifdef DEBUG
- warningx("Your new context is %s", new_context);
+ sudo_warnx("Your new context is %s", new_context);
#endif
context_free(context);
/* Store the caller's SID in old_context. */
if (getprevcon(&se_state.old_context)) {
- warning(U_("failed to get old_context"));
+ sudo_warn(U_("failed to get old_context"));
goto done;
}
se_state.enforcing = security_getenforce();
if (se_state.enforcing < 0) {
- warning(U_("unable to determine enforcing mode."));
+ sudo_warn(U_("unable to determine enforcing mode."));
goto done;
}
#ifdef DEBUG
- warningx("your old context was %s", se_state.old_context);
+ sudo_warnx("your old context was %s", se_state.old_context);
#endif
se_state.new_context = get_exec_context(se_state.old_context, role, type);
if (!se_state.new_context)
goto done;
if (relabel_tty(ttyn, ptyfd) < 0) {
- warning(U_("unable to set tty context to %s"), se_state.new_context);
+ sudo_warn(U_("unable to set tty context to %s"), se_state.new_context);
goto done;
}
#ifdef DEBUG
if (se_state.ttyfd != -1) {
- warningx("your old tty context is %s", se_state.tty_context);
- warningx("your new tty context is %s", se_state.new_tty_context);
+ sudo_warnx("your old tty context is %s", se_state.tty_context);
+ sudo_warnx("your new tty context is %s", se_state.new_tty_context);
}
#endif
sesh = sudo_conf_sesh_path();
if (sesh == NULL) {
- warningx("internal error: sesh path not set");
+ sudo_warnx("internal error: sesh path not set");
errno = EINVAL;
debug_return;
}
if (setexeccon(se_state.new_context)) {
- warning(U_("unable to set exec context to %s"), se_state.new_context);
+ sudo_warn(U_("unable to set exec context to %s"), se_state.new_context);
if (se_state.enforcing)
debug_return;
}
#ifdef HAVE_SETKEYCREATECON
if (setkeycreatecon(se_state.new_context)) {
- warning(U_("unable to set key creation context to %s"), se_state.new_context);
+ sudo_warn(U_("unable to set key creation context to %s"), se_state.new_context);
if (se_state.enforcing)
debug_return;
}
textdomain(PACKAGE_NAME);
if (argc < 2)
- fatalx(U_("requires at least one argument"));
+ sudo_fatalx(U_("requires at least one argument"));
/* Read sudo.conf. */
sudo_conf_read(NULL);
*cp = '-';
}
sudo_execve(cmnd, argv, envp, noexec);
- warning(U_("unable to execute %s"), argv[0]);
+ sudo_warn(U_("unable to execute %s"), argv[0]);
sudo_debug_exit_int(__func__, __FILE__, __LINE__, sudo_debug_subsys, EXIT_FAILURE);
_exit(EXIT_FAILURE);
}
* the select() loop without races (we may not have pselect()).
*/
if (pipe_nonblock(signal_pipe) != 0)
- fatal(U_("unable to create pipe"));
+ sudo_fatal(U_("unable to create pipe"));
memset(&sa, 0, sizeof(sa));
sigfillset(&sa.sa_mask);
case SETPROJ_ERR_TASK:
switch (errno) {
case EAGAIN:
- warningx(U_("resource control limit has been reached"));
+ sudo_warnx(U_("resource control limit has been reached"));
break;
case ESRCH:
- warningx(U_("user \"%s\" is not a member of project \"%s\""),
+ sudo_warnx(U_("user \"%s\" is not a member of project \"%s\""),
pw->pw_name, proj.pj_name);
break;
case EACCES:
- warningx(U_("the invoking task is final"));
+ sudo_warnx(U_("the invoking task is final"));
break;
default:
- warningx(U_("could not join project \"%s\""), proj.pj_name);
+ sudo_warnx(U_("could not join project \"%s\""), proj.pj_name);
}
case SETPROJ_ERR_POOL:
switch (errno) {
case EACCES:
- warningx(U_("no resource pool accepting default bindings "
+ sudo_warnx(U_("no resource pool accepting default bindings "
"exists for project \"%s\""), proj.pj_name);
break;
case ESRCH:
- warningx(U_("specified resource pool does not exist for "
+ sudo_warnx(U_("specified resource pool does not exist for "
"project \"%s\""), proj.pj_name);
break;
default:
- warningx(U_("could not bind to default resource pool for "
+ sudo_warnx(U_("could not bind to default resource pool for "
"project \"%s\""), proj.pj_name);
}
break;
default:
if (errval <= 0) {
- warningx(U_("setproject failed for project \"%s\""), proj.pj_name);
+ sudo_warnx(U_("setproject failed for project \"%s\""), proj.pj_name);
} else {
- warningx(U_("warning, resource control assignment failed for "
+ sudo_warnx(U_("warning, resource control assignment failed for "
"project \"%s\""), proj.pj_name);
}
}
} else {
- warning("getdefaultproj");
+ sudo_warn("getdefaultproj");
}
endprojent();
debug_return;
/* Load plugins. */
if (!sudo_load_plugins(&policy_plugin, &io_plugins))
- fatalx(U_("fatal error, unable to load plugins"));
+ sudo_fatalx(U_("fatal error, unable to load plugins"));
/* Open policy plugin. */
ok = policy_open(&policy_plugin, settings, user_info, envp);
if (ok == -2)
usage(1);
else
- fatalx(U_("unable to initialize policy plugin"));
+ sudo_fatalx(U_("unable to initialize policy plugin"));
}
init_signals();
usage(1);
break;
default:
- fatalx(U_("error initializing I/O plugin %s"),
+ sudo_fatalx(U_("error initializing I/O plugin %s"),
plugin->name);
}
}
SET(command_details.flags, CD_BACKGROUND);
/* Become full root (not just setuid) so user cannot kill us. */
if (setuid(ROOT_UID) == -1)
- warning("setuid(%d)", ROOT_UID);
+ sudo_warn("setuid(%d)", ROOT_UID);
/* Restore coredumpsize resource limit before running. */
#ifdef RLIMIT_CORE
if (sudo_conf_disable_coredump())
/* The close method was called by sudo_edit/run_command. */
break;
default:
- fatalx(U_("unexpected sudo mode 0x%x"), sudo_mode);
+ sudo_fatalx(U_("unexpected sudo mode 0x%x"), sudo_mode);
}
sudo_debug_exit_int(__func__, __FILE__, __LINE__, sudo_debug_subsys, exitcode);
exit(exitcode);
miss[STDERR_FILENO] = fcntl(STDERR_FILENO, F_GETFL, 0) == -1;
if (miss[STDIN_FILENO] || miss[STDOUT_FILENO] || miss[STDERR_FILENO]) {
if ((devnull = open(_PATH_DEVNULL, O_RDWR, 0644)) == -1)
- fatal(U_("unable to open %s"), _PATH_DEVNULL);
+ sudo_fatal(U_("unable to open %s"), _PATH_DEVNULL);
if (miss[STDIN_FILENO] && dup2(devnull, STDIN_FILENO) == -1)
- fatal("dup2");
+ sudo_fatal("dup2");
if (miss[STDOUT_FILENO] && dup2(devnull, STDOUT_FILENO) == -1)
- fatal("dup2");
+ sudo_fatal("dup2");
if (miss[STDERR_FILENO] && dup2(devnull, STDERR_FILENO) == -1)
- fatal("dup2");
+ sudo_fatal("dup2");
if (devnull > STDERR_FILENO)
close(devnull);
}
* Typically, this is because NFS can only support up to 16 groups.
*/
if (fill_group_list(ud, maxgroups) == -1)
- fatal(U_("unable to get group vector"));
+ sudo_fatal(U_("unable to get group vector"));
}
/*
pw = getpwuid(ud->uid);
if (pw == NULL)
- fatalx(U_("unknown uid %u: who are you?"), (unsigned int)ud->uid);
+ sudo_fatalx(U_("unknown uid %u: who are you?"), (unsigned int)ud->uid);
user_info[i] = sudo_new_key_val("user", pw->pw_name);
if (user_info[i] == NULL)
- fatal(NULL);
+ sudo_fatal(NULL);
ud->username = user_info[i] + sizeof("user=") - 1;
/* Stash user's shell for use with the -s flag; don't pass to plugin. */
if (getcwd(cwd, sizeof(cwd)) != NULL) {
user_info[++i] = sudo_new_key_val("cwd", cwd);
if (user_info[i] == NULL)
- fatal(NULL);
+ sudo_fatal(NULL);
ud->cwd = user_info[i] + sizeof("cwd=") - 1;
}
if ((cp = get_process_ttyname()) != NULL) {
user_info[++i] = sudo_new_key_val("tty", cp);
if (user_info[i] == NULL)
- fatal(NULL);
+ sudo_fatal(NULL);
ud->tty = user_info[i] + sizeof("tty=") - 1;
efree(cp);
}
strlcpy(host, "localhost", sizeof(host));
user_info[++i] = sudo_new_key_val("host", host);
if (user_info[i] == NULL)
- fatal(NULL);
+ sudo_fatal(NULL);
ud->host = user_info[i] + sizeof("host=") - 1;
sudo_get_ttysize(&ud->ts_lines, &ud->ts_cols);
cp = info[i] + sizeof("closefrom=") - 1;
details->closefrom = strtonum(cp, 0, INT_MAX, &errstr);
if (errstr != NULL)
- fatalx(U_("%s: %s"), info[i], U_(errstr));
+ sudo_fatalx(U_("%s: %s"), info[i], U_(errstr));
break;
}
break;
cp = info[i] + sizeof("nice=") - 1;
details->priority = strtonum(cp, INT_MIN, INT_MAX, &errstr);
if (errstr != NULL)
- fatalx(U_("%s: %s"), info[i], U_(errstr));
+ sudo_fatalx(U_("%s: %s"), info[i], U_(errstr));
SET(details->flags, CD_SET_PRIORITY);
break;
}
cp = info[i] + sizeof("runas_egid=") - 1;
id = atoid(cp, NULL, NULL, &errstr);
if (errstr != NULL)
- fatalx(U_("%s: %s"), info[i], U_(errstr));
+ sudo_fatalx(U_("%s: %s"), info[i], U_(errstr));
details->egid = (gid_t)id;
SET(details->flags, CD_SET_EGID);
break;
cp = info[i] + sizeof("runas_euid=") - 1;
id = atoid(cp, NULL, NULL, &errstr);
if (errstr != NULL)
- fatalx(U_("%s: %s"), info[i], U_(errstr));
+ sudo_fatalx(U_("%s: %s"), info[i], U_(errstr));
details->euid = (uid_t)id;
SET(details->flags, CD_SET_EUID);
break;
cp = info[i] + sizeof("runas_gid=") - 1;
id = atoid(cp, NULL, NULL, &errstr);
if (errstr != NULL)
- fatalx(U_("%s: %s"), info[i], U_(errstr));
+ sudo_fatalx(U_("%s: %s"), info[i], U_(errstr));
details->gid = (gid_t)id;
SET(details->flags, CD_SET_GID);
break;
cp = info[i] + sizeof("runas_uid=") - 1;
id = atoid(cp, NULL, NULL, &errstr);
if (errstr != NULL)
- fatalx(U_("%s: %s"), info[i], U_(errstr));
+ sudo_fatalx(U_("%s: %s"), info[i], U_(errstr));
details->uid = (uid_t)id;
SET(details->flags, CD_SET_UID);
break;
if (*cp != '\0') {
details->privs = priv_str_to_set(cp, ",", &endp);
if (details->privs == NULL)
- warning("invalid runas_privs %s", endp);
+ sudo_warn("invalid runas_privs %s", endp);
}
break;
}
if (*cp != '\0') {
details->limitprivs = priv_str_to_set(cp, ",", &endp);
if (details->limitprivs == NULL)
- warning("invalid runas_limitprivs %s", endp);
+ sudo_warn("invalid runas_limitprivs %s", endp);
}
break;
}
cp = info[i] + sizeof("timeout=") - 1;
details->timeout = strtonum(cp, 0, INT_MAX, &errstr);
if (errstr != NULL)
- fatalx(U_("%s: %s"), info[i], U_(errstr));
+ sudo_fatalx(U_("%s: %s"), info[i], U_(errstr));
SET(details->flags, CD_SET_TIMEOUT);
break;
}
cp = info[i] + sizeof("umask=") - 1;
details->umask = atomode(cp, &errstr);
if (errstr != NULL)
- fatalx(U_("%s: %s"), info[i], U_(errstr));
+ sudo_fatalx(U_("%s: %s"), info[i], U_(errstr));
SET(details->flags, CD_SET_UMASK);
break;
}
#endif
details->pw = getpwuid(details->euid);
if (details->pw != NULL && (details->pw = pw_dup(details->pw)) == NULL)
- fatal(NULL);
+ sudo_fatal(NULL);
#ifdef HAVE_SETAUTHDB
aix_restoreauthdb();
#endif
if (qualified && stat(sudo, &sb) == 0) {
/* Try to determine why sudo was not running as root. */
if (sb.st_uid != ROOT_UID || !ISSET(sb.st_mode, S_ISUID)) {
- fatalx(
+ sudo_fatalx(
U_("%s must be owned by uid %d and have the setuid bit set"),
sudo, ROOT_UID);
} else {
- fatalx(U_("effective uid is not %d, is %s on a file system "
+ sudo_fatalx(U_("effective uid is not %d, is %s on a file system "
"with the 'nosuid' option set or an NFS file system without"
" root privileges?"), ROOT_UID, sudo);
}
} else {
- fatalx(
+ sudo_fatalx(
U_("effective uid is not %d, is sudo installed setuid root?"),
ROOT_UID);
}
#ifdef HAVE_PRIV_SET
if (details->privs != NULL) {
if (setppriv(PRIV_SET, PRIV_INHERITABLE, details->privs) != 0) {
- warning("unable to set privileges");
+ sudo_warn("unable to set privileges");
goto done;
}
}
if (details->limitprivs != NULL) {
if (setppriv(PRIV_SET, PRIV_LIMIT, details->limitprivs) != 0) {
- warning("unable to set limit privileges");
+ sudo_warn("unable to set limit privileges");
goto done;
}
} else if (details->privs != NULL) {
if (setppriv(PRIV_SET, PRIV_LIMIT, details->privs) != 0) {
- warning("unable to set limit privileges");
+ sudo_warn("unable to set limit privileges");
goto done;
}
}
*/
lc = login_getclass((char *)details->login_class);
if (!lc) {
- warningx(U_("unknown login class %s"), details->login_class);
+ sudo_warnx(U_("unknown login class %s"), details->login_class);
errno = ENOENT;
goto done;
}
flags = LOGIN_SETRESOURCES|LOGIN_SETPRIORITY;
}
if (setusercontext(lc, details->pw, details->pw->pw_uid, flags)) {
- warning(U_("unable to set user context"));
+ sudo_warn(U_("unable to set user context"));
if (details->pw->pw_uid != ROOT_UID)
goto done;
}
if (!ISSET(details->flags, CD_PRESERVE_GROUPS)) {
if (details->ngroups >= 0) {
if (sudo_setgroups(details->ngroups, details->groups) < 0) {
- warning(U_("unable to set supplementary group IDs"));
+ sudo_warn(U_("unable to set supplementary group IDs"));
goto done;
}
}
}
#ifdef HAVE_SETEUID
if (ISSET(details->flags, CD_SET_EGID) && setegid(details->egid)) {
- warning(U_("unable to set effective gid to runas gid %u"),
+ sudo_warn(U_("unable to set effective gid to runas gid %u"),
(unsigned int)details->egid);
goto done;
}
#endif
if (ISSET(details->flags, CD_SET_GID) && setgid(details->gid)) {
- warning(U_("unable to set gid to runas gid %u"),
+ sudo_warn(U_("unable to set gid to runas gid %u"),
(unsigned int)details->gid);
goto done;
}
if (ISSET(details->flags, CD_SET_PRIORITY)) {
if (setpriority(PRIO_PROCESS, 0, details->priority) != 0) {
- warning(U_("unable to set process priority"));
+ sudo_warn(U_("unable to set process priority"));
goto done;
}
}
(void) umask(details->umask);
if (details->chroot) {
if (chroot(details->chroot) != 0 || chdir("/") != 0) {
- warning(U_("unable to change root to %s"), details->chroot);
+ sudo_warn(U_("unable to change root to %s"), details->chroot);
goto done;
}
}
#ifdef HAVE_SETRESUID
if (setresuid(details->uid, details->euid, details->euid) != 0) {
- warning(U_("unable to change to runas uid (%u, %u)"), details->uid,
+ sudo_warn(U_("unable to change to runas uid (%u, %u)"), details->uid,
details->euid);
goto done;
}
#elif defined(HAVE_SETREUID)
if (setreuid(details->uid, details->euid) != 0) {
- warning(U_("unable to change to runas uid (%u, %u)"),
+ sudo_warn(U_("unable to change to runas uid (%u, %u)"),
(unsigned int)details->uid, (unsigned int)details->euid);
goto done;
}
#else
if (seteuid(details->euid) != 0 || setuid(details->euid) != 0) {
- warning(U_("unable to change to runas uid (%u, %u)"), details->uid,
+ sudo_warn(U_("unable to change to runas uid (%u, %u)"), details->uid,
details->euid);
goto done;
}
if (details->chroot || strcmp(details->cwd, user_details.cwd) != 0) {
/* Note: cwd is relative to the new root, if any. */
if (chdir(details->cwd) != 0) {
- warning(U_("unable to change directory to %s"), details->cwd);
+ sudo_warn(U_("unable to change directory to %s"), details->cwd);
goto done;
}
}
exitcode = WTERMSIG(cstat.val) | 128;
break;
default:
- warningx(U_("unexpected child termination condition: %d"), cstat.type);
+ sudo_warnx(U_("unexpected child termination condition: %d"), cstat.type);
break;
}
debug_return_int(exitcode);
if (plugin->u.policy->close != NULL)
plugin->u.policy->close(exit_status, error);
else
- warning(U_("unable to execute %s"), command_details.command);
+ sudo_warn(U_("unable to execute %s"), command_details.command);
debug_return;
}
{
debug_decl(policy_check, SUDO_DEBUG_PCOMM)
if (plugin->u.policy->check_policy == NULL) {
- fatalx(U_("policy plugin %s is missing the `check_policy' method"),
+ sudo_fatalx(U_("policy plugin %s is missing the `check_policy' method"),
plugin->name);
}
debug_return_bool(plugin->u.policy->check_policy(argc, argv, env_add,
{
debug_decl(policy_list, SUDO_DEBUG_PCOMM)
if (plugin->u.policy->list == NULL) {
- warningx(U_("policy plugin %s does not support listing privileges"),
+ sudo_warnx(U_("policy plugin %s does not support listing privileges"),
plugin->name);
debug_return_bool(false);
}
{
debug_decl(policy_validate, SUDO_DEBUG_PCOMM)
if (plugin->u.policy->validate == NULL) {
- warningx(U_("policy plugin %s does not support the -v option"),
+ sudo_warnx(U_("policy plugin %s does not support the -v option"),
plugin->name);
debug_return_bool(false);
}
{
debug_decl(policy_invalidate, SUDO_DEBUG_PCOMM)
if (plugin->u.policy->invalidate == NULL) {
- fatalx(U_("policy plugin %s does not support the -k/-K options"),
+ sudo_fatalx(U_("policy plugin %s does not support the -k/-K options"),
plugin->name);
}
plugin->u.policy->invalidate(remove);
/* When restoring root, change euid first; otherwise change it last. */
if (euid == ROOT_UID) {
if (seteuid(ROOT_UID) != 0)
- fatal("seteuid(ROOT_UID)");
+ sudo_fatal("seteuid(ROOT_UID)");
}
if (setegid(egid) != 0)
- fatal("setegid(%d)", (int)egid);
+ sudo_fatal("setegid(%d)", (int)egid);
if (ngroups != -1) {
if (sudo_setgroups(ngroups, groups) != 0)
- fatal("setgroups");
+ sudo_fatal("setgroups");
}
if (euid != ROOT_UID) {
if (seteuid(euid) != 0)
- fatal("seteuid(%d)", (int)euid);
+ sudo_fatal("seteuid(%d)", (int)euid);
}
errno = serrno;
* We will change the euid as needed below.
*/
if (setuid(ROOT_UID) != 0) {
- warning(U_("unable to change uid to root (%u)"), ROOT_UID);
+ sudo_warn(U_("unable to change uid to root (%u)"), ROOT_UID);
goto cleanup;
}
editor_argc++;
}
if (nfiles == 0) {
- warningx(U_("plugin error: missing file list for sudoedit"));
+ sudo_warnx(U_("plugin error: missing file list for sudoedit"));
goto cleanup;
}
user_details.ngroups, user_details.groups);
if (rc || (ofd != -1 && !S_ISREG(sb.st_mode))) {
if (rc)
- warning("%s", files[i]);
+ sudo_warn("%s", files[i]);
else
- warningx(U_("%s: not a regular file"), files[i]);
+ sudo_warnx(U_("%s: not a regular file"), files[i]);
if (ofd != -1)
close(ofd);
continue;
easprintf(&tf[j].tfile, "%.*s/%s.XXXXXXXX", tmplen, tmpdir, cp);
}
if (seteuid(user_details.uid) != 0)
- fatal("seteuid(%d)", (int)user_details.uid);
+ sudo_fatal("seteuid(%d)", (int)user_details.uid);
tfd = mkstemps(tf[j].tfile, suff ? strlen(suff) : 0);
if (seteuid(ROOT_UID) != 0)
- fatal("seteuid(ROOT_UID)");
+ sudo_fatal("seteuid(ROOT_UID)");
if (tfd == -1) {
- warning("mkstemps");
+ sudo_warn("mkstemps");
goto cleanup;
}
if (ofd != -1) {
while ((nread = read(ofd, buf, sizeof(buf))) != 0) {
if ((nwritten = write(tfd, buf, nread)) != nread) {
if (nwritten == -1)
- warning("%s", tf[j].tfile);
+ sudo_warn("%s", tf[j].tfile);
else
- warningx(U_("%s: short write"), tf[j].tfile);
+ sudo_warnx(U_("%s: short write"), tf[j].tfile);
goto cleanup;
}
}
for (i = 0; i < nfiles; i++) {
rc = -1;
if (seteuid(user_details.uid) != 0)
- fatal("seteuid(%d)", (int)user_details.uid);
+ sudo_fatal("seteuid(%d)", (int)user_details.uid);
if ((tfd = open(tf[i].tfile, O_RDONLY, 0644)) != -1) {
rc = fstat(tfd, &sb);
}
if (seteuid(ROOT_UID) != 0)
- fatal("seteuid(ROOT_UID)");
+ sudo_fatal("seteuid(ROOT_UID)");
if (rc || !S_ISREG(sb.st_mode)) {
if (rc)
- warning("%s", tf[i].tfile);
+ sudo_warn("%s", tf[i].tfile);
else
- warningx(U_("%s: not a regular file"), tf[i].tfile);
- warningx(U_("%s left unmodified"), tf[i].ofile);
+ sudo_warnx(U_("%s: not a regular file"), tf[i].tfile);
+ sudo_warnx(U_("%s left unmodified"), tf[i].ofile);
if (tfd != -1)
close(tfd);
continue;
* time in the editor we can't tell if the file was changed.
*/
if (sudo_timevalcmp(×[0], ×[1], !=)) {
- warningx(U_("%s unchanged"), tf[i].ofile);
+ sudo_warnx(U_("%s unchanged"), tf[i].ofile);
unlink(tf[i].tfile);
close(tfd);
continue;
switch_user(ROOT_UID, user_details.egid,
user_details.ngroups, user_details.groups);
if (ofd == -1) {
- warning(U_("unable to write to %s"), tf[i].ofile);
- warningx(U_("contents of edit session left in %s"), tf[i].tfile);
+ sudo_warn(U_("unable to write to %s"), tf[i].ofile);
+ sudo_warnx(U_("contents of edit session left in %s"), tf[i].tfile);
close(tfd);
continue;
}
while ((nread = read(tfd, buf, sizeof(buf))) > 0) {
if ((nwritten = write(ofd, buf, nread)) != nread) {
if (nwritten == -1)
- warning("%s", tf[i].ofile);
+ sudo_warn("%s", tf[i].ofile);
else
- warningx(U_("%s: short write"), tf[i].ofile);
+ sudo_warnx(U_("%s: short write"), tf[i].ofile);
break;
}
}
/* success, got EOF */
unlink(tf[i].tfile);
} else if (nread < 0) {
- warning(U_("unable to read temporary file"));
- warningx(U_("contents of edit session left in %s"), tf[i].tfile);
+ sudo_warn(U_("unable to read temporary file"));
+ sudo_warnx(U_("contents of edit session left in %s"), tf[i].tfile);
} else {
- warning(U_("unable to write to %s"), tf[i].ofile);
- warningx(U_("contents of edit session left in %s"), tf[i].tfile);
+ sudo_warn(U_("unable to write to %s"), tf[i].ofile);
+ sudo_warnx(U_("contents of edit session left in %s"), tf[i].tfile);
}
close(ofd);
}
if (!ISSET(flags, TGP_STDIN|TGP_ECHO|TGP_ASKPASS|TGP_NOECHO_TRY) &&
!tty_present()) {
if (askpass == NULL || getenv_unhooked("DISPLAY") == NULL) {
- warningx(U_("no tty present and no askpass program specified"));
+ sudo_warnx(U_("no tty present and no askpass program specified"));
debug_return_str(NULL);
}
SET(flags, TGP_ASKPASS);
/* If using a helper program to get the password, run it instead. */
if (ISSET(flags, TGP_ASKPASS)) {
if (askpass == NULL || *askpass == '\0')
- fatalx(U_("no askpass program specified, try setting SUDO_ASKPASS"));
+ sudo_fatalx(U_("no askpass program specified, try setting SUDO_ASKPASS"));
debug_return_str_masked(sudo_askpass(askpass, prompt));
}
debug_decl(sudo_askpass, SUDO_DEBUG_CONV)
if (pipe(pfd) == -1)
- fatal(U_("unable to create pipe"));
+ sudo_fatal(U_("unable to create pipe"));
if ((pid = fork()) == -1)
- fatal(U_("unable to fork"));
+ sudo_fatal(U_("unable to fork"));
if (pid == 0) {
/* child, point stdout to output side of the pipe and exec askpass */
if (dup2(pfd[1], STDOUT_FILENO) == -1) {
- warning("dup2");
+ sudo_warn("dup2");
_exit(255);
}
if (setuid(ROOT_UID) == -1)
- warning("setuid(%d)", ROOT_UID);
+ sudo_warn("setuid(%d)", ROOT_UID);
if (setgid(user_details.gid)) {
- warning(U_("unable to set gid to %u"), (unsigned int)user_details.gid);
+ sudo_warn(U_("unable to set gid to %u"), (unsigned int)user_details.gid);
_exit(255);
}
if (setuid(user_details.uid)) {
- warning(U_("unable to set uid to %u"), (unsigned int)user_details.uid);
+ sudo_warn(U_("unable to set uid to %u"), (unsigned int)user_details.uid);
_exit(255);
}
closefrom(STDERR_FILENO + 1);
execl(askpass, askpass, prompt, (char *)NULL);
- warning(U_("unable to run %s"), askpass);
+ sudo_warn(U_("unable to run %s"), askpass);
_exit(255);
}
sdlen--;
if (sdlen + 1 >= sizeof(pathbuf)) {
errno = ENAMETOOLONG;
- warning("%.*s/", (int)sdlen, dir);
+ sudo_warn("%.*s/", (int)sdlen, dir);
goto done;
}
memcpy(pathbuf, dir, sdlen);
* doesn't take an argument.
*/
if ((sfd = dup(STDIN_FILENO)) == -1)
- fatal(U_("unable to save stdin"));
+ sudo_fatal(U_("unable to save stdin"));
if (dup2(ttyfd, STDIN_FILENO) == -1)
- fatal(U_("unable to dup2 stdin"));
+ sudo_fatal(U_("unable to dup2 stdin"));
slot = ttyslot();
if (dup2(sfd, STDIN_FILENO) == -1)
- fatal(U_("unable to restore stdin"));
+ sudo_fatal(U_("unable to restore stdin"));
close(sfd);
debug_return_int(slot);