mirror of
https://github.com/sudo-project/sudo.git
synced 2025-08-22 01:49:11 +00:00
Add a separate file for visudo callbacks.
This commit is contained in:
parent
c277e55f42
commit
3a77314373
1
MANIFEST
1
MANIFEST
@ -1191,6 +1191,7 @@ plugins/sudoers/tsgetgrpw.c
|
|||||||
plugins/sudoers/tsgetgrpw.h
|
plugins/sudoers/tsgetgrpw.h
|
||||||
plugins/sudoers/unesc_str.c
|
plugins/sudoers/unesc_str.c
|
||||||
plugins/sudoers/visudo.c
|
plugins/sudoers/visudo.c
|
||||||
|
plugins/sudoers/visudo_cb.c
|
||||||
plugins/system_group/Makefile.in
|
plugins/system_group/Makefile.in
|
||||||
plugins/system_group/system_group.c
|
plugins/system_group/system_group.c
|
||||||
plugins/system_group/system_group.exp
|
plugins/system_group/system_group.exp
|
||||||
|
@ -197,7 +197,7 @@ SUDOERS_IOBJS = $(SUDOERS_OBJS:.lo=.i)
|
|||||||
|
|
||||||
VISUDO_OBJS = check_aliases.o editor.lo find_path.lo gc.lo goodpath.lo \
|
VISUDO_OBJS = check_aliases.o editor.lo find_path.lo gc.lo goodpath.lo \
|
||||||
locale.lo sethost.lo stubs.o sudo_printf.o sudoers_ctx_free.lo \
|
locale.lo sethost.lo stubs.o sudo_printf.o sudoers_ctx_free.lo \
|
||||||
visudo.o
|
visudo.o visudo_cb.o
|
||||||
|
|
||||||
VISUDO_IOBJS = sudo_printf.i visudo.i
|
VISUDO_IOBJS = sudo_printf.i visudo.i
|
||||||
|
|
||||||
@ -3471,3 +3471,27 @@ visudo.i: $(srcdir)/visudo.c $(devdir)/def_data.h $(devdir)/gram.h \
|
|||||||
$(CC) -E -o $@ $(CPPFLAGS) $<
|
$(CC) -E -o $@ $(CPPFLAGS) $<
|
||||||
visudo.plog: visudo.i
|
visudo.plog: visudo.i
|
||||||
rm -f $@; pvs-studio --cfg $(PVS_CFG) --sourcetree-root $(top_srcdir) --skip-cl-exe yes --source-file $(srcdir)/visudo.c --i-file $< --output-file $@
|
rm -f $@; pvs-studio --cfg $(PVS_CFG) --sourcetree-root $(top_srcdir) --skip-cl-exe yes --source-file $(srcdir)/visudo.c --i-file $< --output-file $@
|
||||||
|
visudo_cb.o: $(srcdir)/visudo_cb.c $(devdir)/def_data.h \
|
||||||
|
$(incdir)/compat/stdbool.h $(incdir)/sudo_compat.h \
|
||||||
|
$(incdir)/sudo_conf.h $(incdir)/sudo_debug.h \
|
||||||
|
$(incdir)/sudo_eventlog.h $(incdir)/sudo_fatal.h \
|
||||||
|
$(incdir)/sudo_gettext.h $(incdir)/sudo_plugin.h \
|
||||||
|
$(incdir)/sudo_queue.h $(incdir)/sudo_util.h $(srcdir)/defaults.h \
|
||||||
|
$(srcdir)/logging.h $(srcdir)/parse.h $(srcdir)/pivot.h \
|
||||||
|
$(srcdir)/sudo_nss.h $(srcdir)/sudoers.h \
|
||||||
|
$(srcdir)/sudoers_debug.h $(top_builddir)/config.h \
|
||||||
|
$(top_builddir)/pathnames.h
|
||||||
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(ASAN_CFLAGS) $(PIE_CFLAGS) $(HARDENING_CFLAGS) $(srcdir)/visudo_cb.c
|
||||||
|
visudo_cb.i: $(srcdir)/visudo_cb.c $(devdir)/def_data.h \
|
||||||
|
$(incdir)/compat/stdbool.h $(incdir)/sudo_compat.h \
|
||||||
|
$(incdir)/sudo_conf.h $(incdir)/sudo_debug.h \
|
||||||
|
$(incdir)/sudo_eventlog.h $(incdir)/sudo_fatal.h \
|
||||||
|
$(incdir)/sudo_gettext.h $(incdir)/sudo_plugin.h \
|
||||||
|
$(incdir)/sudo_queue.h $(incdir)/sudo_util.h $(srcdir)/defaults.h \
|
||||||
|
$(srcdir)/logging.h $(srcdir)/parse.h $(srcdir)/pivot.h \
|
||||||
|
$(srcdir)/sudo_nss.h $(srcdir)/sudoers.h \
|
||||||
|
$(srcdir)/sudoers_debug.h $(top_builddir)/config.h \
|
||||||
|
$(top_builddir)/pathnames.h
|
||||||
|
$(CC) -E -o $@ $(CPPFLAGS) $<
|
||||||
|
visudo_cb.plog: visudo_cb.i
|
||||||
|
rm -f $@; pvs-studio --cfg $(PVS_CFG) --sourcetree-root $(top_srcdir) --skip-cl-exe yes --source-file $(srcdir)/visudo_cb.c --i-file $< --output-file $@
|
||||||
|
@ -156,11 +156,9 @@ main(int argc, char *argv[])
|
|||||||
if (argc < 1)
|
if (argc < 1)
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
/* Register fatal/fatalx callback. */
|
/* Register callbacks. */
|
||||||
sudo_fatal_callback_register(visudo_cleanup);
|
sudo_fatal_callback_register(visudo_cleanup);
|
||||||
|
set_callbacks();
|
||||||
/* Set sudoers locale callback. */
|
|
||||||
sudo_defs_table[I_SUDOERS_LOCALE].callback = sudoers_locale_callback;
|
|
||||||
|
|
||||||
/* Read debug and plugin sections of sudo.conf. */
|
/* Read debug and plugin sections of sudo.conf. */
|
||||||
if (sudo_conf_read(NULL, SUDO_CONF_DEBUG|SUDO_CONF_PLUGINS) == -1)
|
if (sudo_conf_read(NULL, SUDO_CONF_DEBUG|SUDO_CONF_PLUGINS) == -1)
|
||||||
|
40
plugins/sudoers/visudo_cb.c
Normal file
40
plugins/sudoers/visudo_cb.c
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-License-Identifier: ISC
|
||||||
|
*
|
||||||
|
* Copyright (c) 2023 Todd C. Miller <Todd.Miller@sudo.ws>
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This is an open source non-commercial project. Dear PVS-Studio, please check it.
|
||||||
|
* PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#include "sudoers.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set visudo Defaults callbacks.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
set_callbacks(void)
|
||||||
|
{
|
||||||
|
debug_decl(set_callbacks, SUDOERS_DEBUG_UTIL);
|
||||||
|
|
||||||
|
/* Set locale callback. */
|
||||||
|
sudo_defs_table[I_SUDOERS_LOCALE].callback = sudoers_locale_callback;
|
||||||
|
|
||||||
|
debug_return;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user