Move _sudo_printf from src/conversation.c to common/sudo_printf.c.
Add sudo_printf function pointer that is initialized to _sudo_printf() instead of requiring a sudo_conv function pointer everywhere. The plugin will reset sudo_printf to point to the version passed in via the plugin open function. Now plugin_error.c can just call sudo_printf in all cases. The sudoers binaries no longer need their own version of sudo_printf.
This commit is contained in:
1
MANIFEST
1
MANIFEST
@@ -19,6 +19,7 @@ common/secure_path.c
|
|||||||
common/setgroups.c
|
common/setgroups.c
|
||||||
common/sudo_conf.c
|
common/sudo_conf.c
|
||||||
common/sudo_debug.c
|
common/sudo_debug.c
|
||||||
|
common/sudo_printf.c
|
||||||
common/term.c
|
common/term.c
|
||||||
common/ttysize.c
|
common/ttysize.c
|
||||||
common/zero_bytes.c
|
common/zero_bytes.c
|
||||||
|
@@ -58,8 +58,8 @@ DEFS = @OSDEFS@ -D_PATH_SUDO_CONF=\"$(sysconfdir)/sudo.conf\"
|
|||||||
SHELL = @SHELL@
|
SHELL = @SHELL@
|
||||||
|
|
||||||
LTOBJS = alloc.lo atobool.lo fileops.lo fmt_string.lo lbuf.lo list.lo \
|
LTOBJS = alloc.lo atobool.lo fileops.lo fmt_string.lo lbuf.lo list.lo \
|
||||||
secure_path.lo setgroups.lo sudo_conf.lo sudo_debug.lo term.lo \
|
secure_path.lo setgroups.lo sudo_conf.lo sudo_debug.lo sudo_printf.lo \
|
||||||
ttysize.lo zero_bytes.lo @COMMON_OBJS@
|
term.lo ttysize.lo zero_bytes.lo @COMMON_OBJS@
|
||||||
|
|
||||||
all: libcommon.la
|
all: libcommon.la
|
||||||
|
|
||||||
@@ -151,6 +151,9 @@ sudo_debug.lo: $(srcdir)/sudo_debug.c $(top_builddir)/config.h \
|
|||||||
$(incdir)/alloc.h $(incdir)/error.h $(incdir)/gettext.h \
|
$(incdir)/alloc.h $(incdir)/error.h $(incdir)/gettext.h \
|
||||||
$(incdir)/sudo_plugin.h $(incdir)/sudo_debug.h
|
$(incdir)/sudo_plugin.h $(incdir)/sudo_debug.h
|
||||||
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/sudo_debug.c
|
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/sudo_debug.c
|
||||||
|
sudo_printf.lo: $(srcdir)/sudo_printf.c $(top_builddir)/config.h \
|
||||||
|
$(incdir)/sudo_plugin.h
|
||||||
|
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/sudo_printf.c
|
||||||
term.lo: $(srcdir)/term.c $(top_builddir)/config.h $(incdir)/missing.h \
|
term.lo: $(srcdir)/term.c $(top_builddir)/config.h $(incdir)/missing.h \
|
||||||
$(incdir)/sudo_debug.h
|
$(incdir)/sudo_debug.h
|
||||||
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/term.c
|
$(LIBTOOL) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/term.c
|
||||||
|
@@ -120,8 +120,6 @@ static int sudo_debug_mode;
|
|||||||
static char sudo_debug_pidstr[(((sizeof(int) * 8) + 2) / 3) + 3];
|
static char sudo_debug_pidstr[(((sizeof(int) * 8) + 2) / 3) + 3];
|
||||||
static size_t sudo_debug_pidlen;
|
static size_t sudo_debug_pidlen;
|
||||||
|
|
||||||
extern sudo_conv_t sudo_conv;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Parse settings string from sudo.conf and open debugfile.
|
* Parse settings string from sudo.conf and open debugfile.
|
||||||
* Returns 1 on success, 0 if cannot open debugfile.
|
* Returns 1 on success, 0 if cannot open debugfile.
|
||||||
@@ -285,36 +283,21 @@ static void
|
|||||||
sudo_debug_write_conv(const char *func, const char *file, int lineno,
|
sudo_debug_write_conv(const char *func, const char *file, int lineno,
|
||||||
const char *str, int len, int errno_val)
|
const char *str, int len, int errno_val)
|
||||||
{
|
{
|
||||||
struct sudo_conv_message msg;
|
|
||||||
struct sudo_conv_reply repl;
|
|
||||||
char *buf = NULL;
|
|
||||||
|
|
||||||
/* Call conversation function */
|
|
||||||
if (sudo_conv != NULL) {
|
|
||||||
/* Remove the newline at the end if appending extra info. */
|
/* Remove the newline at the end if appending extra info. */
|
||||||
if (str[len - 1] == '\n')
|
if (str[len - 1] == '\n')
|
||||||
len--;
|
len--;
|
||||||
|
|
||||||
if (func != NULL && file != NULL && lineno != 0) {
|
if (func != NULL && file != NULL && lineno != 0) {
|
||||||
if (errno_val) {
|
if (errno_val) {
|
||||||
easprintf(&buf, "%.*s: %s @ %s() %s:%d", len, str,
|
sudo_printf(SUDO_CONV_DEBUG_MSG, "%.*s: %s @ %s() %s:%d",
|
||||||
strerror(errno_val), func, file, lineno);
|
len, str, strerror(errno_val), func, file, lineno);
|
||||||
} else {
|
} else {
|
||||||
easprintf(&buf, "%.*s @ %s() %s:%d", len, str,
|
sudo_printf(SUDO_CONV_DEBUG_MSG, "%.*s @ %s() %s:%d",
|
||||||
func, file, lineno);
|
len, str, func, file, lineno);
|
||||||
}
|
}
|
||||||
str = buf;
|
|
||||||
} else if (errno_val) {
|
} else if (errno_val) {
|
||||||
easprintf(&buf, "%.*s: %s", len, str, strerror(errno_val));
|
sudo_printf(SUDO_CONV_DEBUG_MSG, "%.*s: %s",
|
||||||
str = buf;
|
len, str, strerror(errno_val));
|
||||||
}
|
|
||||||
memset(&msg, 0, sizeof(msg));
|
|
||||||
memset(&repl, 0, sizeof(repl));
|
|
||||||
msg.msg_type = SUDO_CONV_DEBUG_MSG;
|
|
||||||
msg.msg = str;
|
|
||||||
sudo_conv(1, &msg, &repl);
|
|
||||||
if (buf != NULL)
|
|
||||||
efree(buf);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
75
common/sudo_printf.c
Normal file
75
common/sudo_printf.c
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2010-2012 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||||
|
*
|
||||||
|
* Permission to use, copy, modify, and distribute this software for any
|
||||||
|
* purpose with or without fee is hereby granted, provided that the above
|
||||||
|
* copyright notice and this permission notice appear in all copies.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||||
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||||
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||||
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||||
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#ifdef STDC_HEADERS
|
||||||
|
# include <stdlib.h>
|
||||||
|
# include <stddef.h>
|
||||||
|
#else
|
||||||
|
# ifdef HAVE_STDLIB_H
|
||||||
|
# include <stdlib.h>
|
||||||
|
# endif
|
||||||
|
#endif /* STDC_HEADERS */
|
||||||
|
#include <stdarg.h>
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
|
#include "sudo_plugin.h"
|
||||||
|
#include "sudo_debug.h"
|
||||||
|
|
||||||
|
int
|
||||||
|
_sudo_printf(int msg_type, const char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list ap;
|
||||||
|
FILE *fp;
|
||||||
|
int len;
|
||||||
|
|
||||||
|
switch (msg_type) {
|
||||||
|
case SUDO_CONV_INFO_MSG:
|
||||||
|
fp = stdout;
|
||||||
|
break;
|
||||||
|
case SUDO_CONV_ERROR_MSG:
|
||||||
|
fp = stderr;
|
||||||
|
break;
|
||||||
|
case SUDO_CONV_DEBUG_MSG:
|
||||||
|
{
|
||||||
|
char *buf;
|
||||||
|
va_list ap;
|
||||||
|
|
||||||
|
/* XXX - add debug version of vfprintf()? */
|
||||||
|
va_start(ap, fmt);
|
||||||
|
len = vasprintf(&buf, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
if (len == -1)
|
||||||
|
return -1;
|
||||||
|
sudo_debug_write(buf, len, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
errno = EINVAL;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
va_start(ap, fmt);
|
||||||
|
len = vfprintf(fp, fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
int (*sudo_printf)(int msg_type, const char *fmt, ...) = _sudo_printf;
|
@@ -18,6 +18,7 @@
|
|||||||
#define _SUDO_ERROR_H_
|
#define _SUDO_ERROR_H_
|
||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
#include <sudo_plugin.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We wrap error/errorx and warn/warnx so that the same output can
|
* We wrap error/errorx and warn/warnx so that the same output can
|
||||||
@@ -170,6 +171,8 @@
|
|||||||
warning_restore_locale(); \
|
warning_restore_locale(); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
extern sudo_printf_t sudo_printf;
|
||||||
|
|
||||||
void error2(int, const char *, ...) __printflike(2, 3) __attribute__((__noreturn__));
|
void error2(int, const char *, ...) __printflike(2, 3) __attribute__((__noreturn__));
|
||||||
void errorx2(int, const char *, ...) __printflike(2, 3) __attribute__((__noreturn__));
|
void errorx2(int, const char *, ...) __printflike(2, 3) __attribute__((__noreturn__));
|
||||||
void verror2(int, const char *, va_list ap) __attribute__((__noreturn__));
|
void verror2(int, const char *, va_list ap) __attribute__((__noreturn__));
|
||||||
|
@@ -615,6 +615,7 @@ locale.lo: $(srcdir)/locale.c $(top_builddir)/config.h $(srcdir)/sudoers.h \
|
|||||||
$(devdir)/def_data.h $(srcdir)/logging.h $(srcdir)/sudo_nss.h \
|
$(devdir)/def_data.h $(srcdir)/logging.h $(srcdir)/sudo_nss.h \
|
||||||
$(incdir)/sudo_plugin.h $(incdir)/sudo_debug.h $(incdir)/gettext.h
|
$(incdir)/sudo_plugin.h $(incdir)/sudo_debug.h $(incdir)/gettext.h
|
||||||
$(LIBTOOL) --mode=compile $(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/locale.c
|
$(LIBTOOL) --mode=compile $(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/locale.c
|
||||||
|
locale.o: locale.lo
|
||||||
logging.lo: $(srcdir)/logging.c $(top_builddir)/config.h $(srcdir)/sudoers.h \
|
logging.lo: $(srcdir)/logging.c $(top_builddir)/config.h $(srcdir)/sudoers.h \
|
||||||
$(top_srcdir)/compat/stdbool.h $(top_builddir)/pathnames.h \
|
$(top_srcdir)/compat/stdbool.h $(top_builddir)/pathnames.h \
|
||||||
$(incdir)/missing.h $(incdir)/error.h $(incdir)/alloc.h \
|
$(incdir)/missing.h $(incdir)/error.h $(incdir)/alloc.h \
|
||||||
@@ -800,8 +801,8 @@ sudoreplay.o: $(srcdir)/sudoreplay.c $(top_builddir)/config.h \
|
|||||||
$(top_srcdir)/compat/timespec.h $(top_srcdir)/compat/stdbool.h \
|
$(top_srcdir)/compat/timespec.h $(top_srcdir)/compat/stdbool.h \
|
||||||
$(top_builddir)/pathnames.h $(incdir)/missing.h \
|
$(top_builddir)/pathnames.h $(incdir)/missing.h \
|
||||||
$(incdir)/alloc.h $(incdir)/error.h $(incdir)/gettext.h \
|
$(incdir)/alloc.h $(incdir)/error.h $(incdir)/gettext.h \
|
||||||
$(incdir)/sudo_plugin.h $(incdir)/sudo_conf.h $(incdir)/list.h \
|
$(srcdir)/logging.h $(incdir)/sudo_plugin.h \
|
||||||
$(incdir)/sudo_debug.h
|
$(incdir)/sudo_conf.h $(incdir)/list.h $(incdir)/sudo_debug.h
|
||||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/sudoreplay.c
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/sudoreplay.c
|
||||||
testsudoers.o: $(srcdir)/testsudoers.c $(top_builddir)/config.h \
|
testsudoers.o: $(srcdir)/testsudoers.c $(top_builddir)/config.h \
|
||||||
$(top_srcdir)/compat/fnmatch.h $(srcdir)/tsgetgrpw.h \
|
$(top_srcdir)/compat/fnmatch.h $(srcdir)/tsgetgrpw.h \
|
||||||
|
@@ -148,27 +148,12 @@ sudoerserror(const char *s)
|
|||||||
LEXTRACE("<*> ");
|
LEXTRACE("<*> ");
|
||||||
#ifndef TRACELEXER
|
#ifndef TRACELEXER
|
||||||
if (trace_print == NULL || trace_print == sudoers_trace_print) {
|
if (trace_print == NULL || trace_print == sudoers_trace_print) {
|
||||||
int oldlocale;
|
|
||||||
const char fmt[] = ">>> %s: %s near line %d <<<\n";
|
const char fmt[] = ">>> %s: %s near line %d <<<\n";
|
||||||
|
int oldlocale;
|
||||||
|
|
||||||
/* Warnings are displayed in the user's locale. */
|
/* Warnings are displayed in the user's locale. */
|
||||||
sudoers_setlocale(SUDOERS_LOCALE_USER, &oldlocale);
|
sudoers_setlocale(SUDOERS_LOCALE_USER, &oldlocale);
|
||||||
if (sudo_conv != NULL) {
|
sudo_printf(SUDO_CONV_ERROR_MSG, _(fmt), sudoers, _(s), sudolineno);
|
||||||
struct sudo_conv_message msg;
|
|
||||||
struct sudo_conv_reply repl;
|
|
||||||
char *str;
|
|
||||||
|
|
||||||
easprintf(&str, _(fmt), sudoers, _(s), sudolineno);
|
|
||||||
|
|
||||||
memset(&msg, 0, sizeof(repl));
|
|
||||||
memset(&repl, 0, sizeof(repl));
|
|
||||||
msg.msg_type = SUDO_CONV_ERROR_MSG;
|
|
||||||
msg.msg = str;
|
|
||||||
sudo_conv(1, &msg, &repl);
|
|
||||||
efree(str);
|
|
||||||
} else {
|
|
||||||
fprintf(stderr, _(fmt), sudoers, _(s), sudolineno);
|
|
||||||
}
|
|
||||||
sudoers_setlocale(oldlocale, NULL);
|
sudoers_setlocale(oldlocale, NULL);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -110,27 +110,12 @@ sudoerserror(const char *s)
|
|||||||
LEXTRACE("<*> ");
|
LEXTRACE("<*> ");
|
||||||
#ifndef TRACELEXER
|
#ifndef TRACELEXER
|
||||||
if (trace_print == NULL || trace_print == sudoers_trace_print) {
|
if (trace_print == NULL || trace_print == sudoers_trace_print) {
|
||||||
int oldlocale;
|
|
||||||
const char fmt[] = ">>> %s: %s near line %d <<<\n";
|
const char fmt[] = ">>> %s: %s near line %d <<<\n";
|
||||||
|
int oldlocale;
|
||||||
|
|
||||||
/* Warnings are displayed in the user's locale. */
|
/* Warnings are displayed in the user's locale. */
|
||||||
sudoers_setlocale(SUDOERS_LOCALE_USER, &oldlocale);
|
sudoers_setlocale(SUDOERS_LOCALE_USER, &oldlocale);
|
||||||
if (sudo_conv != NULL) {
|
sudo_printf(SUDO_CONV_ERROR_MSG, _(fmt), sudoers, _(s), sudolineno);
|
||||||
struct sudo_conv_message msg;
|
|
||||||
struct sudo_conv_reply repl;
|
|
||||||
char *str;
|
|
||||||
|
|
||||||
easprintf(&str, _(fmt), sudoers, _(s), sudolineno);
|
|
||||||
|
|
||||||
memset(&msg, 0, sizeof(repl));
|
|
||||||
memset(&repl, 0, sizeof(repl));
|
|
||||||
msg.msg_type = SUDO_CONV_ERROR_MSG;
|
|
||||||
msg.msg = str;
|
|
||||||
sudo_conv(1, &msg, &repl);
|
|
||||||
efree(str);
|
|
||||||
} else {
|
|
||||||
fprintf(stderr, _(fmt), sudoers, _(s), sudolineno);
|
|
||||||
}
|
|
||||||
sudoers_setlocale(oldlocale, NULL);
|
sudoers_setlocale(oldlocale, NULL);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -467,9 +467,7 @@ sudoers_io_open(unsigned int version, sudo_conv_t conversation,
|
|||||||
int rval = -1;
|
int rval = -1;
|
||||||
debug_decl(sudoers_io_open, SUDO_DEBUG_PLUGIN)
|
debug_decl(sudoers_io_open, SUDO_DEBUG_PLUGIN)
|
||||||
|
|
||||||
if (!sudo_conv)
|
|
||||||
sudo_conv = conversation;
|
sudo_conv = conversation;
|
||||||
if (!sudo_printf)
|
|
||||||
sudo_printf = plugin_printf;
|
sudo_printf = plugin_printf;
|
||||||
|
|
||||||
/* If we have no command (because -V was specified) just return. */
|
/* If we have no command (because -V was specified) just return. */
|
||||||
|
@@ -44,8 +44,6 @@ static void _warning(int, const char *, va_list);
|
|||||||
static sigjmp_buf error_jmp;
|
static sigjmp_buf error_jmp;
|
||||||
static bool setjmp_enabled = false;
|
static bool setjmp_enabled = false;
|
||||||
|
|
||||||
extern sudo_conv_t sudo_conv;
|
|
||||||
|
|
||||||
void
|
void
|
||||||
error2(int eval, const char *fmt, ...)
|
error2(int eval, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
@@ -133,47 +131,23 @@ static void
|
|||||||
_warning(int use_errno, const char *fmt, va_list ap)
|
_warning(int use_errno, const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
int serrno = errno;
|
int serrno = errno;
|
||||||
|
|
||||||
if (sudo_conv != NULL) {
|
|
||||||
struct sudo_conv_message msg[6];
|
|
||||||
struct sudo_conv_reply repl[6];
|
|
||||||
int nmsgs = 4;
|
|
||||||
char *str;
|
char *str;
|
||||||
|
|
||||||
evasprintf(&str, _(fmt), ap);
|
evasprintf(&str, fmt, ap);
|
||||||
|
|
||||||
/* Call conversation function */
|
|
||||||
memset(&msg, 0, sizeof(msg));
|
|
||||||
msg[0].msg_type = SUDO_CONV_ERROR_MSG;
|
|
||||||
msg[0].msg = getprogname();
|
|
||||||
msg[1].msg_type = SUDO_CONV_ERROR_MSG;
|
|
||||||
msg[1].msg = _(": ");
|
|
||||||
msg[2].msg_type = SUDO_CONV_ERROR_MSG;
|
|
||||||
msg[2].msg = str;
|
|
||||||
if (use_errno) {
|
if (use_errno) {
|
||||||
msg[3].msg_type = SUDO_CONV_ERROR_MSG;
|
|
||||||
msg[3].msg = _(": ");
|
|
||||||
msg[4].msg_type = SUDO_CONV_ERROR_MSG;
|
|
||||||
msg[4].msg = strerror(errno);
|
|
||||||
nmsgs = 6;
|
|
||||||
}
|
|
||||||
msg[nmsgs - 1].msg_type = SUDO_CONV_ERROR_MSG;
|
|
||||||
msg[nmsgs - 1].msg = "\n";
|
|
||||||
memset(&repl, 0, sizeof(repl));
|
|
||||||
sudo_conv(nmsgs, msg, repl);
|
|
||||||
efree(str);
|
|
||||||
} else {
|
|
||||||
fputs(getprogname(), stderr);
|
|
||||||
if (fmt != NULL) {
|
if (fmt != NULL) {
|
||||||
fputs(_(": "), stderr);
|
sudo_printf(SUDO_CONV_ERROR_MSG,
|
||||||
vfprintf(stderr, _(fmt), ap);
|
_("%s: %s: %s\n"), getprogname(), str, strerror(serrno));
|
||||||
|
} else {
|
||||||
|
sudo_printf(SUDO_CONV_ERROR_MSG,
|
||||||
|
_("%s: %s\n"), getprogname(), strerror(serrno));
|
||||||
}
|
}
|
||||||
if (use_errno) {
|
} else {
|
||||||
fputs(_(": "), stderr);
|
sudo_printf(SUDO_CONV_ERROR_MSG,
|
||||||
fputs(strerror(serrno), stderr);
|
_("%s: %s\n"), getprogname(), str ? str : "(null)");
|
||||||
}
|
|
||||||
putc('\n', stderr);
|
|
||||||
}
|
}
|
||||||
|
efree(str);
|
||||||
|
errno = serrno;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int oldlocale;
|
static int oldlocale;
|
||||||
|
@@ -458,9 +458,7 @@ sudoers_policy_open(unsigned int version, sudo_conv_t conversation,
|
|||||||
debug_decl(sudoers_policy_open, SUDO_DEBUG_PLUGIN)
|
debug_decl(sudoers_policy_open, SUDO_DEBUG_PLUGIN)
|
||||||
|
|
||||||
sudo_version = version;
|
sudo_version = version;
|
||||||
if (!sudo_conv)
|
|
||||||
sudo_conv = conversation;
|
sudo_conv = conversation;
|
||||||
if (!sudo_printf)
|
|
||||||
sudo_printf = plugin_printf;
|
sudo_printf = plugin_printf;
|
||||||
|
|
||||||
/* Plugin args are only specified for API version 1.2 and higher. */
|
/* Plugin args are only specified for API version 1.2 and higher. */
|
||||||
|
@@ -116,7 +116,7 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cleanup(int gotsig)
|
sudoers_cleanup(int gotsig)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -47,7 +47,6 @@
|
|||||||
|
|
||||||
struct sudo_user sudo_user;
|
struct sudo_user sudo_user;
|
||||||
struct passwd *list_pw;
|
struct passwd *list_pw;
|
||||||
sudo_conv_t sudo_conv; /* NULL in non-plugin */
|
|
||||||
|
|
||||||
static char sessid[7];
|
static char sessid[7];
|
||||||
|
|
||||||
@@ -205,7 +204,7 @@ void io_nextid(char *iolog_dir, char *fallback, char id[7])
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cleanup(int gotsig)
|
sudoers_cleanup(int gotsig)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -42,8 +42,6 @@
|
|||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "sudo_plugin.h"
|
#include "sudo_plugin.h"
|
||||||
|
|
||||||
sudo_conv_t sudo_conv; /* NULL in non-plugin */
|
|
||||||
|
|
||||||
extern void writeln_wrap(FILE *fp, char *line, size_t len, size_t maxlen);
|
extern void writeln_wrap(FILE *fp, char *line, size_t len, size_t maxlen);
|
||||||
|
|
||||||
__dso_public int main(int argc, char *argv[]);
|
__dso_public int main(int argc, char *argv[]);
|
||||||
@@ -108,7 +106,7 @@ main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
cleanup(int gotsig)
|
sudoers_cleanup(int gotsig)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -56,8 +56,6 @@ __dso_public int main(int argc, char *argv[]);
|
|||||||
struct interface *interfaces;
|
struct interface *interfaces;
|
||||||
sudo_printf_t sudo_printf = check_addr_printf;
|
sudo_printf_t sudo_printf = check_addr_printf;
|
||||||
|
|
||||||
sudo_conv_t sudo_conv; /* NULL in non-plugin */
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
check_addr(char *input)
|
check_addr(char *input)
|
||||||
{
|
{
|
||||||
@@ -156,7 +154,7 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
/* STUB */
|
/* STUB */
|
||||||
void
|
void
|
||||||
cleanup(int gotsig)
|
sudoers_cleanup(int gotsig)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -42,6 +42,7 @@
|
|||||||
|
|
||||||
#define SUDO_ERROR_WRAP 0
|
#define SUDO_ERROR_WRAP 0
|
||||||
|
|
||||||
|
#include "missing.h"
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
#include "parse.h"
|
#include "parse.h"
|
||||||
#include "toke.h"
|
#include "toke.h"
|
||||||
@@ -54,8 +55,6 @@ __dso_public int main(int argc, char *argv[]);
|
|||||||
* TODO: test realloc
|
* TODO: test realloc
|
||||||
*/
|
*/
|
||||||
|
|
||||||
sudo_conv_t sudo_conv; /* NULL in non-plugin */
|
|
||||||
|
|
||||||
YYSTYPE sudoerslval;
|
YYSTYPE sudoerslval;
|
||||||
|
|
||||||
struct fill_test {
|
struct fill_test {
|
||||||
@@ -186,7 +185,7 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
/* STUB */
|
/* STUB */
|
||||||
void
|
void
|
||||||
cleanup(int gotsig)
|
sudoers_cleanup(int gotsig)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@@ -108,7 +108,6 @@ extern char *errorfile;
|
|||||||
char *login_style;
|
char *login_style;
|
||||||
#endif /* HAVE_BSD_AUTH_H */
|
#endif /* HAVE_BSD_AUTH_H */
|
||||||
sudo_conv_t sudo_conv;
|
sudo_conv_t sudo_conv;
|
||||||
sudo_printf_t sudo_printf;
|
|
||||||
int sudo_mode;
|
int sudo_mode;
|
||||||
|
|
||||||
static char *prev_user;
|
static char *prev_user;
|
||||||
|
@@ -179,8 +179,6 @@ struct search_node {
|
|||||||
} u;
|
} u;
|
||||||
} *search_expr;
|
} *search_expr;
|
||||||
|
|
||||||
sudo_conv_t sudo_conv; /* NULL in non-plugin */
|
|
||||||
|
|
||||||
#define STACK_NODE_SIZE 32
|
#define STACK_NODE_SIZE 32
|
||||||
static struct search_node *node_stack[32];
|
static struct search_node *node_stack[32];
|
||||||
static int stack_top;
|
static int stack_top;
|
||||||
|
@@ -82,7 +82,6 @@ void sudoers_cleanup(int);
|
|||||||
static void set_runaspw(const char *);
|
static void set_runaspw(const char *);
|
||||||
static void set_runasgr(const char *);
|
static void set_runasgr(const char *);
|
||||||
static int cb_runas_default(const char *);
|
static int cb_runas_default(const char *);
|
||||||
static int testsudoers_printf(int msg_type, const char *fmt, ...);
|
|
||||||
static int testsudoers_print(const char *msg);
|
static int testsudoers_print(const char *msg);
|
||||||
|
|
||||||
extern void setgrfile(const char *);
|
extern void setgrfile(const char *);
|
||||||
@@ -109,8 +108,6 @@ static char *runas_group, *runas_user;
|
|||||||
extern int errorlineno;
|
extern int errorlineno;
|
||||||
extern bool parse_error;
|
extern bool parse_error;
|
||||||
extern char *errorfile;
|
extern char *errorfile;
|
||||||
sudo_printf_t sudo_printf = testsudoers_printf;
|
|
||||||
sudo_conv_t sudo_conv; /* NULL in non-plugin */
|
|
||||||
|
|
||||||
/* For getopt(3) */
|
/* For getopt(3) */
|
||||||
extern char *optarg;
|
extern char *optarg;
|
||||||
@@ -663,32 +660,6 @@ print_userspecs(void)
|
|||||||
debug_return;
|
debug_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
testsudoers_printf(int msg_type, const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
FILE *fp;
|
|
||||||
debug_decl(testsudoers_printf, SUDO_DEBUG_UTIL)
|
|
||||||
|
|
||||||
switch (msg_type) {
|
|
||||||
case SUDO_CONV_INFO_MSG:
|
|
||||||
fp = stdout;
|
|
||||||
break;
|
|
||||||
case SUDO_CONV_ERROR_MSG:
|
|
||||||
fp = stderr;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
errno = EINVAL;
|
|
||||||
debug_return_int(-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
vfprintf(fp, fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
|
|
||||||
debug_return_int(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
dump_sudoers(void)
|
dump_sudoers(void)
|
||||||
{
|
{
|
||||||
|
@@ -90,8 +90,6 @@ struct sudoersfile {
|
|||||||
};
|
};
|
||||||
TQ_DECLARE(sudoersfile)
|
TQ_DECLARE(sudoersfile)
|
||||||
|
|
||||||
sudo_conv_t sudo_conv; /* NULL in non-plugin */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Function prototypes
|
* Function prototypes
|
||||||
*/
|
*/
|
||||||
@@ -107,7 +105,6 @@ static bool install_sudoers(struct sudoersfile *, bool);
|
|||||||
static int print_unused(void *, void *);
|
static int print_unused(void *, void *);
|
||||||
static void reparse_sudoers(char *, char *, bool, bool);
|
static void reparse_sudoers(char *, char *, bool, bool);
|
||||||
static int run_command(char *, char **);
|
static int run_command(char *, char **);
|
||||||
static int visudo_printf(int msg_type, const char *fmt, ...);
|
|
||||||
static void setup_signals(void);
|
static void setup_signals(void);
|
||||||
static void help(void) __attribute__((__noreturn__));
|
static void help(void) __attribute__((__noreturn__));
|
||||||
static void usage(int);
|
static void usage(int);
|
||||||
@@ -134,7 +131,6 @@ extern int optind;
|
|||||||
*/
|
*/
|
||||||
struct sudo_user sudo_user;
|
struct sudo_user sudo_user;
|
||||||
struct passwd *list_pw;
|
struct passwd *list_pw;
|
||||||
sudo_printf_t sudo_printf = visudo_printf;
|
|
||||||
static struct sudoersfile_list sudoerslist;
|
static struct sudoersfile_list sudoerslist;
|
||||||
static struct rbtree *alias_freelist;
|
static struct rbtree *alias_freelist;
|
||||||
static bool checkonly;
|
static bool checkonly;
|
||||||
@@ -1310,28 +1306,3 @@ help(void)
|
|||||||
" -V display version information and exit"));
|
" -V display version information and exit"));
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
|
||||||
visudo_printf(int msg_type, const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
FILE *fp;
|
|
||||||
|
|
||||||
switch (msg_type) {
|
|
||||||
case SUDO_CONV_INFO_MSG:
|
|
||||||
fp = stdout;
|
|
||||||
break;
|
|
||||||
case SUDO_CONV_ERROR_MSG:
|
|
||||||
fp = stderr;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
errno = EINVAL;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
vfprintf(fp, fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
@@ -175,7 +175,7 @@ env_hooks.o: $(srcdir)/env_hooks.c $(top_builddir)/config.h \
|
|||||||
$(incdir)/sudo_plugin.h
|
$(incdir)/sudo_plugin.h
|
||||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/env_hooks.c
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/env_hooks.c
|
||||||
error.o: $(srcdir)/error.c $(top_builddir)/config.h $(incdir)/missing.h \
|
error.o: $(srcdir)/error.c $(top_builddir)/config.h $(incdir)/missing.h \
|
||||||
$(incdir)/alloc.h $(incdir)/error.h $(incdir)/gettext.h
|
$(incdir)/error.h $(incdir)/gettext.h
|
||||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/error.c
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(DEFS) $(srcdir)/error.c
|
||||||
exec.o: $(srcdir)/exec.c $(top_builddir)/config.h $(srcdir)/sudo.h \
|
exec.o: $(srcdir)/exec.c $(top_builddir)/config.h $(srcdir)/sudo.h \
|
||||||
$(top_builddir)/pathnames.h $(top_srcdir)/compat/stdbool.h \
|
$(top_builddir)/pathnames.h $(top_srcdir)/compat/stdbool.h \
|
||||||
|
@@ -51,10 +51,6 @@
|
|||||||
|
|
||||||
extern int tgetpass_flags; /* XXX */
|
extern int tgetpass_flags; /* XXX */
|
||||||
|
|
||||||
#if defined(HAVE_DLOPEN) || defined(HAVE_SHL_LOAD)
|
|
||||||
sudo_conv_t sudo_conv; /* NULL in sudo front-end */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sudo conversation function.
|
* Sudo conversation function.
|
||||||
*/
|
*/
|
||||||
@@ -120,29 +116,3 @@ err:
|
|||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
_sudo_printf(int msg_type, const char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list ap;
|
|
||||||
FILE *fp;
|
|
||||||
int len;
|
|
||||||
|
|
||||||
switch (msg_type) {
|
|
||||||
case SUDO_CONV_INFO_MSG:
|
|
||||||
fp = stdout;
|
|
||||||
break;
|
|
||||||
case SUDO_CONV_ERROR_MSG:
|
|
||||||
fp = stderr;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
errno = EINVAL;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
|
||||||
len = vfprintf(fp, fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
|
|
||||||
return len;
|
|
||||||
}
|
|
||||||
|
@@ -40,8 +40,6 @@
|
|||||||
#include "sudo_exec.h"
|
#include "sudo_exec.h"
|
||||||
#include "sudo_plugin.h"
|
#include "sudo_plugin.h"
|
||||||
|
|
||||||
sudo_conv_t sudo_conv; /* NULL in non-plugin */
|
|
||||||
|
|
||||||
__dso_public int main(int argc, char *argv[], char *envp[]);
|
__dso_public int main(int argc, char *argv[], char *envp[]);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Reference in New Issue
Block a user