Avoid using exiting allocators in the front end.
This commit is contained in:
@@ -796,8 +796,8 @@ match_addr.lo: $(srcdir)/match_addr.c $(devdir)/def_data.h \
|
|||||||
$(LIBTOOL) --mode=compile $(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/match_addr.c
|
$(LIBTOOL) --mode=compile $(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/match_addr.c
|
||||||
match_addr.o: match_addr.lo
|
match_addr.o: match_addr.lo
|
||||||
net_ifs.o: $(top_srcdir)/src/net_ifs.c $(incdir)/compat/stdbool.h \
|
net_ifs.o: $(top_srcdir)/src/net_ifs.c $(incdir)/compat/stdbool.h \
|
||||||
$(incdir)/sudo_alloc.h $(incdir)/sudo_compat.h \
|
$(incdir)/sudo_compat.h $(incdir)/sudo_conf.h \
|
||||||
$(incdir)/sudo_conf.h $(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
|
$(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
|
||||||
$(incdir)/sudo_gettext.h $(incdir)/sudo_queue.h \
|
$(incdir)/sudo_gettext.h $(incdir)/sudo_queue.h \
|
||||||
$(top_builddir)/config.h
|
$(top_builddir)/config.h
|
||||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(top_srcdir)/src/net_ifs.c
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(top_srcdir)/src/net_ifs.c
|
||||||
|
178
src/Makefile.in
178
src/Makefile.in
@@ -225,169 +225,165 @@ cleandir: realclean
|
|||||||
|
|
||||||
# Autogenerated dependencies, do not modify
|
# Autogenerated dependencies, do not modify
|
||||||
check_ttyname.o: $(srcdir)/regress/ttyname/check_ttyname.c \
|
check_ttyname.o: $(srcdir)/regress/ttyname/check_ttyname.c \
|
||||||
$(incdir)/compat/stdbool.h $(incdir)/sudo_alloc.h \
|
$(incdir)/compat/stdbool.h $(incdir)/sudo_compat.h \
|
||||||
$(incdir)/sudo_compat.h $(incdir)/sudo_debug.h \
|
$(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
|
||||||
$(incdir)/sudo_fatal.h $(incdir)/sudo_queue.h \
|
$(incdir)/sudo_queue.h $(incdir)/sudo_util.h \
|
||||||
$(incdir)/sudo_util.h $(top_builddir)/config.h
|
$(top_builddir)/config.h
|
||||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/regress/ttyname/check_ttyname.c
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/regress/ttyname/check_ttyname.c
|
||||||
conversation.o: $(srcdir)/conversation.c $(incdir)/compat/stdbool.h \
|
conversation.o: $(srcdir)/conversation.c $(incdir)/compat/stdbool.h \
|
||||||
$(incdir)/sudo_alloc.h $(incdir)/sudo_compat.h \
|
$(incdir)/sudo_compat.h $(incdir)/sudo_conf.h \
|
||||||
$(incdir)/sudo_conf.h $(incdir)/sudo_debug.h \
|
$(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
|
||||||
$(incdir)/sudo_fatal.h $(incdir)/sudo_gettext.h \
|
$(incdir)/sudo_gettext.h $(incdir)/sudo_plugin.h \
|
||||||
$(incdir)/sudo_plugin.h $(incdir)/sudo_queue.h \
|
$(incdir)/sudo_queue.h $(incdir)/sudo_util.h $(srcdir)/sudo.h \
|
||||||
$(incdir)/sudo_util.h $(srcdir)/sudo.h \
|
|
||||||
$(srcdir)/sudo_plugin_int.h $(top_builddir)/config.h \
|
$(srcdir)/sudo_plugin_int.h $(top_builddir)/config.h \
|
||||||
$(top_builddir)/pathnames.h
|
$(top_builddir)/pathnames.h
|
||||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/conversation.c
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/conversation.c
|
||||||
env_hooks.o: $(srcdir)/env_hooks.c $(incdir)/compat/stdbool.h \
|
env_hooks.o: $(srcdir)/env_hooks.c $(incdir)/compat/stdbool.h \
|
||||||
$(incdir)/sudo_alloc.h $(incdir)/sudo_compat.h \
|
$(incdir)/sudo_compat.h $(incdir)/sudo_conf.h \
|
||||||
$(incdir)/sudo_conf.h $(incdir)/sudo_debug.h $(incdir)/sudo_dso.h \
|
$(incdir)/sudo_debug.h $(incdir)/sudo_dso.h \
|
||||||
$(incdir)/sudo_fatal.h $(incdir)/sudo_gettext.h \
|
$(incdir)/sudo_fatal.h $(incdir)/sudo_gettext.h \
|
||||||
$(incdir)/sudo_plugin.h $(incdir)/sudo_queue.h \
|
$(incdir)/sudo_plugin.h $(incdir)/sudo_queue.h \
|
||||||
$(incdir)/sudo_util.h $(srcdir)/sudo.h $(top_builddir)/config.h \
|
$(incdir)/sudo_util.h $(srcdir)/sudo.h $(top_builddir)/config.h \
|
||||||
$(top_builddir)/pathnames.h
|
$(top_builddir)/pathnames.h
|
||||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/env_hooks.c
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/env_hooks.c
|
||||||
exec.o: $(srcdir)/exec.c $(incdir)/compat/stdbool.h $(incdir)/sudo_alloc.h \
|
exec.o: $(srcdir)/exec.c $(incdir)/compat/stdbool.h $(incdir)/sudo_compat.h \
|
||||||
$(incdir)/sudo_compat.h $(incdir)/sudo_conf.h $(incdir)/sudo_debug.h \
|
$(incdir)/sudo_conf.h $(incdir)/sudo_debug.h $(incdir)/sudo_event.h \
|
||||||
$(incdir)/sudo_event.h $(incdir)/sudo_fatal.h $(incdir)/sudo_gettext.h \
|
$(incdir)/sudo_fatal.h $(incdir)/sudo_gettext.h \
|
||||||
$(incdir)/sudo_plugin.h $(incdir)/sudo_queue.h $(incdir)/sudo_util.h \
|
$(incdir)/sudo_plugin.h $(incdir)/sudo_queue.h $(incdir)/sudo_util.h \
|
||||||
$(srcdir)/sudo.h $(srcdir)/sudo_exec.h $(srcdir)/sudo_plugin_int.h \
|
$(srcdir)/sudo.h $(srcdir)/sudo_exec.h $(srcdir)/sudo_plugin_int.h \
|
||||||
$(top_builddir)/config.h $(top_builddir)/pathnames.h
|
$(top_builddir)/config.h $(top_builddir)/pathnames.h
|
||||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/exec.c
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/exec.c
|
||||||
exec_common.o: $(srcdir)/exec_common.c $(incdir)/compat/stdbool.h \
|
exec_common.o: $(srcdir)/exec_common.c $(incdir)/compat/stdbool.h \
|
||||||
$(incdir)/sudo_alloc.h $(incdir)/sudo_compat.h \
|
$(incdir)/sudo_compat.h $(incdir)/sudo_conf.h \
|
||||||
$(incdir)/sudo_conf.h $(incdir)/sudo_debug.h \
|
$(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
|
||||||
$(incdir)/sudo_fatal.h $(incdir)/sudo_gettext.h \
|
$(incdir)/sudo_gettext.h $(incdir)/sudo_queue.h \
|
||||||
$(incdir)/sudo_queue.h $(incdir)/sudo_util.h $(srcdir)/sudo.h \
|
$(incdir)/sudo_util.h $(srcdir)/sudo.h $(srcdir)/sudo_exec.h \
|
||||||
$(srcdir)/sudo_exec.h $(top_builddir)/config.h \
|
$(top_builddir)/config.h $(top_builddir)/pathnames.h
|
||||||
$(top_builddir)/pathnames.h
|
|
||||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/exec_common.c
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/exec_common.c
|
||||||
exec_pty.o: $(srcdir)/exec_pty.c $(incdir)/compat/stdbool.h \
|
exec_pty.o: $(srcdir)/exec_pty.c $(incdir)/compat/stdbool.h \
|
||||||
$(incdir)/sudo_alloc.h $(incdir)/sudo_compat.h \
|
$(incdir)/sudo_compat.h $(incdir)/sudo_conf.h \
|
||||||
$(incdir)/sudo_conf.h $(incdir)/sudo_debug.h \
|
$(incdir)/sudo_debug.h $(incdir)/sudo_event.h \
|
||||||
$(incdir)/sudo_event.h $(incdir)/sudo_fatal.h \
|
$(incdir)/sudo_fatal.h $(incdir)/sudo_gettext.h \
|
||||||
$(incdir)/sudo_gettext.h $(incdir)/sudo_plugin.h \
|
$(incdir)/sudo_plugin.h $(incdir)/sudo_queue.h \
|
||||||
$(incdir)/sudo_queue.h $(incdir)/sudo_util.h $(srcdir)/sudo.h \
|
$(incdir)/sudo_util.h $(srcdir)/sudo.h $(srcdir)/sudo_exec.h \
|
||||||
$(srcdir)/sudo_exec.h $(srcdir)/sudo_plugin_int.h \
|
$(srcdir)/sudo_plugin_int.h $(top_builddir)/config.h \
|
||||||
$(top_builddir)/config.h $(top_builddir)/pathnames.h
|
$(top_builddir)/pathnames.h
|
||||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/exec_pty.c
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/exec_pty.c
|
||||||
get_pty.o: $(srcdir)/get_pty.c $(incdir)/compat/stdbool.h \
|
get_pty.o: $(srcdir)/get_pty.c $(incdir)/compat/stdbool.h \
|
||||||
$(incdir)/sudo_alloc.h $(incdir)/sudo_compat.h \
|
$(incdir)/sudo_compat.h $(incdir)/sudo_conf.h \
|
||||||
$(incdir)/sudo_conf.h $(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
|
$(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
|
||||||
$(incdir)/sudo_gettext.h $(incdir)/sudo_queue.h \
|
$(incdir)/sudo_gettext.h $(incdir)/sudo_queue.h \
|
||||||
$(incdir)/sudo_util.h $(srcdir)/sudo.h $(top_builddir)/config.h \
|
$(incdir)/sudo_util.h $(srcdir)/sudo.h $(top_builddir)/config.h \
|
||||||
$(top_builddir)/pathnames.h
|
$(top_builddir)/pathnames.h
|
||||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/get_pty.c
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/get_pty.c
|
||||||
hooks.o: $(srcdir)/hooks.c $(incdir)/compat/stdbool.h $(incdir)/sudo_alloc.h \
|
hooks.o: $(srcdir)/hooks.c $(incdir)/compat/stdbool.h $(incdir)/sudo_compat.h \
|
||||||
$(incdir)/sudo_compat.h $(incdir)/sudo_conf.h $(incdir)/sudo_debug.h \
|
$(incdir)/sudo_conf.h $(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
|
||||||
$(incdir)/sudo_fatal.h $(incdir)/sudo_gettext.h \
|
$(incdir)/sudo_gettext.h $(incdir)/sudo_plugin.h \
|
||||||
$(incdir)/sudo_plugin.h $(incdir)/sudo_queue.h $(incdir)/sudo_util.h \
|
$(incdir)/sudo_queue.h $(incdir)/sudo_util.h $(srcdir)/sudo.h \
|
||||||
$(srcdir)/sudo.h $(srcdir)/sudo_plugin_int.h $(top_builddir)/config.h \
|
$(srcdir)/sudo_plugin_int.h $(top_builddir)/config.h \
|
||||||
$(top_builddir)/pathnames.h
|
$(top_builddir)/pathnames.h
|
||||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/hooks.c
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/hooks.c
|
||||||
load_plugins.o: $(srcdir)/load_plugins.c $(incdir)/compat/stdbool.h \
|
load_plugins.o: $(srcdir)/load_plugins.c $(incdir)/compat/stdbool.h \
|
||||||
$(incdir)/sudo_alloc.h $(incdir)/sudo_compat.h \
|
$(incdir)/sudo_compat.h $(incdir)/sudo_conf.h \
|
||||||
$(incdir)/sudo_conf.h $(incdir)/sudo_debug.h \
|
$(incdir)/sudo_debug.h $(incdir)/sudo_dso.h \
|
||||||
$(incdir)/sudo_dso.h $(incdir)/sudo_fatal.h \
|
$(incdir)/sudo_fatal.h $(incdir)/sudo_gettext.h \
|
||||||
$(incdir)/sudo_gettext.h $(incdir)/sudo_plugin.h \
|
$(incdir)/sudo_plugin.h $(incdir)/sudo_queue.h \
|
||||||
$(incdir)/sudo_queue.h $(incdir)/sudo_util.h $(srcdir)/sudo.h \
|
$(incdir)/sudo_util.h $(srcdir)/sudo.h \
|
||||||
$(srcdir)/sudo_plugin_int.h $(top_builddir)/config.h \
|
$(srcdir)/sudo_plugin_int.h $(top_builddir)/config.h \
|
||||||
$(top_builddir)/pathnames.h
|
$(top_builddir)/pathnames.h
|
||||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/load_plugins.c
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/load_plugins.c
|
||||||
net_ifs.o: $(srcdir)/net_ifs.c $(incdir)/compat/stdbool.h \
|
net_ifs.o: $(srcdir)/net_ifs.c $(incdir)/compat/stdbool.h \
|
||||||
$(incdir)/sudo_alloc.h $(incdir)/sudo_compat.h \
|
$(incdir)/sudo_compat.h $(incdir)/sudo_conf.h \
|
||||||
$(incdir)/sudo_conf.h $(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
|
$(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
|
||||||
$(incdir)/sudo_gettext.h $(incdir)/sudo_queue.h \
|
$(incdir)/sudo_gettext.h $(incdir)/sudo_queue.h \
|
||||||
$(top_builddir)/config.h
|
$(top_builddir)/config.h
|
||||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/net_ifs.c
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/net_ifs.c
|
||||||
openbsd.o: $(srcdir)/openbsd.c $(incdir)/compat/stdbool.h \
|
openbsd.o: $(srcdir)/openbsd.c $(incdir)/compat/stdbool.h \
|
||||||
$(incdir)/sudo_alloc.h $(incdir)/sudo_compat.h \
|
$(incdir)/sudo_compat.h $(incdir)/sudo_conf.h \
|
||||||
$(incdir)/sudo_conf.h $(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
|
$(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
|
||||||
$(incdir)/sudo_gettext.h $(incdir)/sudo_queue.h \
|
$(incdir)/sudo_gettext.h $(incdir)/sudo_queue.h \
|
||||||
$(incdir)/sudo_util.h $(srcdir)/sudo.h $(top_builddir)/config.h \
|
$(incdir)/sudo_util.h $(srcdir)/sudo.h $(top_builddir)/config.h \
|
||||||
$(top_builddir)/pathnames.h
|
$(top_builddir)/pathnames.h
|
||||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/openbsd.c
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/openbsd.c
|
||||||
parse_args.o: $(srcdir)/parse_args.c $(incdir)/compat/getopt.h \
|
parse_args.o: $(srcdir)/parse_args.c $(incdir)/compat/getopt.h \
|
||||||
$(incdir)/compat/stdbool.h $(incdir)/sudo_alloc.h \
|
$(incdir)/compat/stdbool.h $(incdir)/sudo_compat.h \
|
||||||
$(incdir)/sudo_compat.h $(incdir)/sudo_conf.h \
|
$(incdir)/sudo_conf.h $(incdir)/sudo_debug.h \
|
||||||
$(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
|
$(incdir)/sudo_fatal.h $(incdir)/sudo_gettext.h \
|
||||||
$(incdir)/sudo_gettext.h $(incdir)/sudo_lbuf.h \
|
$(incdir)/sudo_lbuf.h $(incdir)/sudo_queue.h \
|
||||||
$(incdir)/sudo_queue.h $(incdir)/sudo_util.h $(srcdir)/sudo.h \
|
$(incdir)/sudo_util.h $(srcdir)/sudo.h $(top_builddir)/config.h \
|
||||||
$(top_builddir)/config.h $(top_builddir)/pathnames.h \
|
$(top_builddir)/pathnames.h ./sudo_usage.h
|
||||||
./sudo_usage.h
|
|
||||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/parse_args.c
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/parse_args.c
|
||||||
preload.o: $(srcdir)/preload.c $(incdir)/sudo_compat.h $(incdir)/sudo_dso.h \
|
preload.o: $(srcdir)/preload.c $(incdir)/sudo_compat.h $(incdir)/sudo_dso.h \
|
||||||
$(incdir)/sudo_plugin.h $(top_builddir)/config.h
|
$(incdir)/sudo_plugin.h $(top_builddir)/config.h
|
||||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/preload.c
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/preload.c
|
||||||
preserve_fds.o: $(srcdir)/preserve_fds.c $(incdir)/compat/stdbool.h \
|
preserve_fds.o: $(srcdir)/preserve_fds.c $(incdir)/compat/stdbool.h \
|
||||||
$(incdir)/sudo_alloc.h $(incdir)/sudo_compat.h \
|
$(incdir)/sudo_compat.h $(incdir)/sudo_conf.h \
|
||||||
$(incdir)/sudo_conf.h $(incdir)/sudo_debug.h \
|
$(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
|
||||||
$(incdir)/sudo_fatal.h $(incdir)/sudo_gettext.h \
|
$(incdir)/sudo_gettext.h $(incdir)/sudo_queue.h \
|
||||||
$(incdir)/sudo_queue.h $(incdir)/sudo_util.h $(srcdir)/sudo.h \
|
$(incdir)/sudo_util.h $(srcdir)/sudo.h \
|
||||||
$(top_builddir)/config.h $(top_builddir)/pathnames.h
|
$(top_builddir)/config.h $(top_builddir)/pathnames.h
|
||||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/preserve_fds.c
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/preserve_fds.c
|
||||||
selinux.o: $(srcdir)/selinux.c $(incdir)/compat/stdbool.h \
|
selinux.o: $(srcdir)/selinux.c $(incdir)/compat/stdbool.h \
|
||||||
$(incdir)/sudo_alloc.h $(incdir)/sudo_compat.h \
|
$(incdir)/sudo_compat.h $(incdir)/sudo_conf.h \
|
||||||
$(incdir)/sudo_conf.h $(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
|
$(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
|
||||||
$(incdir)/sudo_gettext.h $(incdir)/sudo_queue.h \
|
$(incdir)/sudo_gettext.h $(incdir)/sudo_queue.h \
|
||||||
$(incdir)/sudo_util.h $(srcdir)/sudo.h $(srcdir)/sudo_exec.h \
|
$(incdir)/sudo_util.h $(srcdir)/sudo.h $(srcdir)/sudo_exec.h \
|
||||||
$(top_builddir)/config.h $(top_builddir)/pathnames.h
|
$(top_builddir)/config.h $(top_builddir)/pathnames.h
|
||||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/selinux.c
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/selinux.c
|
||||||
sesh.o: $(srcdir)/sesh.c $(incdir)/compat/stdbool.h $(incdir)/sudo_alloc.h \
|
sesh.o: $(srcdir)/sesh.c $(incdir)/compat/stdbool.h $(incdir)/sudo_compat.h \
|
||||||
$(incdir)/sudo_compat.h $(incdir)/sudo_conf.h $(incdir)/sudo_debug.h \
|
$(incdir)/sudo_conf.h $(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
|
||||||
$(incdir)/sudo_fatal.h $(incdir)/sudo_gettext.h \
|
$(incdir)/sudo_gettext.h $(incdir)/sudo_plugin.h \
|
||||||
$(incdir)/sudo_plugin.h $(incdir)/sudo_queue.h $(incdir)/sudo_util.h \
|
$(incdir)/sudo_queue.h $(incdir)/sudo_util.h $(srcdir)/sudo_exec.h \
|
||||||
$(srcdir)/sudo_exec.h $(top_builddir)/config.h
|
$(top_builddir)/config.h
|
||||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/sesh.c
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/sesh.c
|
||||||
signal.o: $(srcdir)/signal.c $(incdir)/compat/stdbool.h $(incdir)/sudo_alloc.h \
|
signal.o: $(srcdir)/signal.c $(incdir)/compat/stdbool.h \
|
||||||
$(incdir)/sudo_compat.h $(incdir)/sudo_conf.h $(incdir)/sudo_debug.h \
|
$(incdir)/sudo_compat.h $(incdir)/sudo_conf.h $(incdir)/sudo_debug.h \
|
||||||
$(incdir)/sudo_fatal.h $(incdir)/sudo_gettext.h \
|
$(incdir)/sudo_fatal.h $(incdir)/sudo_gettext.h \
|
||||||
$(incdir)/sudo_queue.h $(incdir)/sudo_util.h $(srcdir)/sudo.h \
|
$(incdir)/sudo_queue.h $(incdir)/sudo_util.h $(srcdir)/sudo.h \
|
||||||
$(top_builddir)/config.h $(top_builddir)/pathnames.h
|
$(top_builddir)/config.h $(top_builddir)/pathnames.h
|
||||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/signal.c
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/signal.c
|
||||||
solaris.o: $(srcdir)/solaris.c $(incdir)/compat/stdbool.h \
|
solaris.o: $(srcdir)/solaris.c $(incdir)/compat/stdbool.h \
|
||||||
$(incdir)/sudo_alloc.h $(incdir)/sudo_compat.h \
|
$(incdir)/sudo_compat.h $(incdir)/sudo_conf.h \
|
||||||
$(incdir)/sudo_conf.h $(incdir)/sudo_debug.h $(incdir)/sudo_dso.h \
|
$(incdir)/sudo_debug.h $(incdir)/sudo_dso.h $(incdir)/sudo_fatal.h \
|
||||||
$(incdir)/sudo_fatal.h $(incdir)/sudo_gettext.h \
|
$(incdir)/sudo_gettext.h $(incdir)/sudo_queue.h \
|
||||||
$(incdir)/sudo_queue.h $(incdir)/sudo_util.h $(srcdir)/sudo.h \
|
$(incdir)/sudo_util.h $(srcdir)/sudo.h $(top_builddir)/config.h \
|
||||||
$(top_builddir)/config.h $(top_builddir)/pathnames.h
|
$(top_builddir)/pathnames.h
|
||||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/solaris.c
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/solaris.c
|
||||||
sudo.o: $(srcdir)/sudo.c $(incdir)/compat/stdbool.h $(incdir)/sudo_alloc.h \
|
sudo.o: $(srcdir)/sudo.c $(incdir)/compat/stdbool.h $(incdir)/sudo_compat.h \
|
||||||
$(incdir)/sudo_compat.h $(incdir)/sudo_conf.h $(incdir)/sudo_debug.h \
|
$(incdir)/sudo_conf.h $(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
|
||||||
$(incdir)/sudo_fatal.h $(incdir)/sudo_gettext.h \
|
$(incdir)/sudo_gettext.h $(incdir)/sudo_plugin.h \
|
||||||
$(incdir)/sudo_plugin.h $(incdir)/sudo_queue.h $(incdir)/sudo_util.h \
|
$(incdir)/sudo_queue.h $(incdir)/sudo_util.h $(srcdir)/sudo.h \
|
||||||
$(srcdir)/sudo.h $(srcdir)/sudo_plugin_int.h $(top_builddir)/config.h \
|
$(srcdir)/sudo_plugin_int.h $(top_builddir)/config.h \
|
||||||
$(top_builddir)/pathnames.h ./sudo_usage.h
|
$(top_builddir)/pathnames.h ./sudo_usage.h
|
||||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/sudo.c
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/sudo.c
|
||||||
sudo_edit.o: $(srcdir)/sudo_edit.c $(incdir)/compat/stdbool.h \
|
sudo_edit.o: $(srcdir)/sudo_edit.c $(incdir)/compat/stdbool.h \
|
||||||
$(incdir)/compat/timespec.h $(incdir)/sudo_alloc.h \
|
$(incdir)/compat/timespec.h $(incdir)/sudo_compat.h \
|
||||||
$(incdir)/sudo_compat.h $(incdir)/sudo_conf.h \
|
$(incdir)/sudo_conf.h $(incdir)/sudo_debug.h \
|
||||||
$(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
|
$(incdir)/sudo_fatal.h $(incdir)/sudo_gettext.h \
|
||||||
$(incdir)/sudo_gettext.h $(incdir)/sudo_queue.h \
|
$(incdir)/sudo_queue.h $(incdir)/sudo_util.h $(srcdir)/sudo.h \
|
||||||
$(incdir)/sudo_util.h $(srcdir)/sudo.h $(srcdir)/sudo_exec.h \
|
$(srcdir)/sudo_exec.h $(top_builddir)/config.h \
|
||||||
$(top_builddir)/config.h $(top_builddir)/pathnames.h
|
$(top_builddir)/pathnames.h
|
||||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/sudo_edit.c
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/sudo_edit.c
|
||||||
sudo_noexec.lo: $(srcdir)/sudo_noexec.c $(incdir)/sudo_compat.h \
|
sudo_noexec.lo: $(srcdir)/sudo_noexec.c $(incdir)/sudo_compat.h \
|
||||||
$(top_builddir)/config.h
|
$(top_builddir)/config.h
|
||||||
$(LIBTOOL) --mode=compile $(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/sudo_noexec.c
|
$(LIBTOOL) --mode=compile $(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/sudo_noexec.c
|
||||||
tgetpass.o: $(srcdir)/tgetpass.c $(incdir)/compat/stdbool.h \
|
tgetpass.o: $(srcdir)/tgetpass.c $(incdir)/compat/stdbool.h \
|
||||||
$(incdir)/sudo_alloc.h $(incdir)/sudo_compat.h \
|
$(incdir)/sudo_compat.h $(incdir)/sudo_conf.h \
|
||||||
$(incdir)/sudo_conf.h $(incdir)/sudo_debug.h \
|
$(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
|
||||||
$(incdir)/sudo_fatal.h $(incdir)/sudo_gettext.h \
|
$(incdir)/sudo_gettext.h $(incdir)/sudo_plugin.h \
|
||||||
$(incdir)/sudo_plugin.h $(incdir)/sudo_queue.h \
|
$(incdir)/sudo_queue.h $(incdir)/sudo_util.h $(srcdir)/sudo.h \
|
||||||
$(incdir)/sudo_util.h $(srcdir)/sudo.h $(top_builddir)/config.h \
|
$(top_builddir)/config.h $(top_builddir)/pathnames.h
|
||||||
$(top_builddir)/pathnames.h
|
|
||||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/tgetpass.c
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/tgetpass.c
|
||||||
ttyname.o: $(srcdir)/ttyname.c $(incdir)/compat/stdbool.h \
|
ttyname.o: $(srcdir)/ttyname.c $(incdir)/compat/stdbool.h \
|
||||||
$(incdir)/sudo_alloc.h $(incdir)/sudo_compat.h \
|
$(incdir)/sudo_compat.h $(incdir)/sudo_conf.h \
|
||||||
$(incdir)/sudo_conf.h $(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
|
$(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
|
||||||
$(incdir)/sudo_gettext.h $(incdir)/sudo_queue.h \
|
$(incdir)/sudo_gettext.h $(incdir)/sudo_queue.h \
|
||||||
$(incdir)/sudo_util.h $(srcdir)/sudo.h $(top_builddir)/config.h \
|
$(incdir)/sudo_util.h $(srcdir)/sudo.h $(top_builddir)/config.h \
|
||||||
$(top_builddir)/pathnames.h
|
$(top_builddir)/pathnames.h
|
||||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/ttyname.c
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/ttyname.c
|
||||||
utmp.o: $(srcdir)/utmp.c $(incdir)/compat/stdbool.h $(incdir)/sudo_alloc.h \
|
utmp.o: $(srcdir)/utmp.c $(incdir)/compat/stdbool.h $(incdir)/sudo_compat.h \
|
||||||
$(incdir)/sudo_compat.h $(incdir)/sudo_conf.h $(incdir)/sudo_debug.h \
|
$(incdir)/sudo_conf.h $(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
|
||||||
$(incdir)/sudo_fatal.h $(incdir)/sudo_gettext.h $(incdir)/sudo_queue.h \
|
$(incdir)/sudo_gettext.h $(incdir)/sudo_queue.h $(incdir)/sudo_util.h \
|
||||||
$(incdir)/sudo_util.h $(srcdir)/sudo.h $(srcdir)/sudo_exec.h \
|
$(srcdir)/sudo.h $(srcdir)/sudo_exec.h $(top_builddir)/config.h \
|
||||||
$(top_builddir)/config.h $(top_builddir)/pathnames.h
|
$(top_builddir)/pathnames.h
|
||||||
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/utmp.c
|
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/utmp.c
|
||||||
|
@@ -80,7 +80,8 @@ sudo_conversation(int num_msgs, const struct sudo_conv_message msgs[],
|
|||||||
pass = tgetpass(msg->msg, msg->timeout, flags);
|
pass = tgetpass(msg->msg, msg->timeout, flags);
|
||||||
if (pass == NULL)
|
if (pass == NULL)
|
||||||
goto err;
|
goto err;
|
||||||
repl->reply = sudo_estrdup(pass);
|
if ((repl->reply = strdup(pass)) == NULL)
|
||||||
|
sudo_fatalx_nodebug(U_("unable to allocate memory"));
|
||||||
memset_s(pass, SUDO_CONV_REPL_MAX, 0, strlen(pass));
|
memset_s(pass, SUDO_CONV_REPL_MAX, 0, strlen(pass));
|
||||||
break;
|
break;
|
||||||
case SUDO_CONV_INFO_MSG:
|
case SUDO_CONV_INFO_MSG:
|
||||||
|
@@ -115,7 +115,9 @@ rpl_putenv(PUTENV_CONST char *string)
|
|||||||
/* Append at the end if not already found. */
|
/* Append at the end if not already found. */
|
||||||
if (!found) {
|
if (!found) {
|
||||||
size_t env_len = (size_t)(ep - environ);
|
size_t env_len = (size_t)(ep - environ);
|
||||||
char **envp = sudo_ereallocarray(priv_environ, env_len + 2, sizeof(char *));
|
char **envp = reallocarray(priv_environ, env_len + 2, sizeof(char *));
|
||||||
|
if (envp == NULL)
|
||||||
|
return -1;
|
||||||
if (environ != priv_environ)
|
if (environ != priv_environ)
|
||||||
memcpy(envp, environ, env_len * sizeof(char *));
|
memcpy(envp, environ, env_len * sizeof(char *));
|
||||||
envp[env_len++] = (char *)string;
|
envp[env_len++] = (char *)string;
|
||||||
@@ -190,7 +192,11 @@ rpl_setenv(const char *var, const char *val, int overwrite)
|
|||||||
free(envstr);
|
free(envstr);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return rpl_putenv(envstr);
|
if (rpl_putenv(envstr) == -1) {
|
||||||
|
free(envstr);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef int (*sudo_fn_setenv_t)(const char *, const char *, int);
|
typedef int (*sudo_fn_setenv_t)(const char *, const char *, int);
|
||||||
|
@@ -527,7 +527,7 @@ sudo_execute(struct command_details *details, struct command_status *cstat)
|
|||||||
sudo_ev_free(signal_event);
|
sudo_ev_free(signal_event);
|
||||||
sudo_ev_free(backchannel_event);
|
sudo_ev_free(backchannel_event);
|
||||||
TAILQ_FOREACH_SAFE(sigfwd, &sigfwd_list, entries, sigfwd_next) {
|
TAILQ_FOREACH_SAFE(sigfwd, &sigfwd_list, entries, sigfwd_next) {
|
||||||
sudo_efree(sigfwd);
|
free(sigfwd);
|
||||||
}
|
}
|
||||||
TAILQ_INIT(&sigfwd_list);
|
TAILQ_INIT(&sigfwd_list);
|
||||||
done:
|
done:
|
||||||
@@ -833,7 +833,7 @@ forward_signals(int sock, int what, void *v)
|
|||||||
nsent = send(sock, &cstat, sizeof(cstat), 0);
|
nsent = send(sock, &cstat, sizeof(cstat), 0);
|
||||||
} while (nsent == -1 && errno == EINTR);
|
} while (nsent == -1 && errno == EINTR);
|
||||||
TAILQ_REMOVE(&sigfwd_list, sigfwd, entries);
|
TAILQ_REMOVE(&sigfwd_list, sigfwd, entries);
|
||||||
sudo_efree(sigfwd);
|
free(sigfwd);
|
||||||
if (nsent != sizeof(cstat)) {
|
if (nsent != sizeof(cstat)) {
|
||||||
if (errno == EPIPE) {
|
if (errno == EPIPE) {
|
||||||
struct sigforward *sigfwd_next;
|
struct sigforward *sigfwd_next;
|
||||||
@@ -841,7 +841,7 @@ forward_signals(int sock, int what, void *v)
|
|||||||
"broken pipe writing to child over backchannel");
|
"broken pipe writing to child over backchannel");
|
||||||
/* Other end of socket gone, empty out sigfwd_list. */
|
/* Other end of socket gone, empty out sigfwd_list. */
|
||||||
TAILQ_FOREACH_SAFE(sigfwd, &sigfwd_list, entries, sigfwd_next) {
|
TAILQ_FOREACH_SAFE(sigfwd, &sigfwd_list, entries, sigfwd_next) {
|
||||||
sudo_efree(sigfwd);
|
free(sigfwd);
|
||||||
}
|
}
|
||||||
TAILQ_INIT(&sigfwd_list);
|
TAILQ_INIT(&sigfwd_list);
|
||||||
/* XXX - child (monitor) is dead, we should exit too? */
|
/* XXX - child (monitor) is dead, we should exit too? */
|
||||||
@@ -869,7 +869,8 @@ schedule_signal(struct sudo_event_base *evbase, int signo)
|
|||||||
snprintf(signame, sizeof(signame), "%d", signo);
|
snprintf(signame, sizeof(signame), "%d", signo);
|
||||||
sudo_debug_printf(SUDO_DEBUG_DIAG, "scheduled SIG%s for child", signame);
|
sudo_debug_printf(SUDO_DEBUG_DIAG, "scheduled SIG%s for child", signame);
|
||||||
|
|
||||||
sigfwd = sudo_ecalloc(1, sizeof(*sigfwd));
|
if ((sigfwd = calloc(1, sizeof(*sigfwd))) == NULL)
|
||||||
|
sudo_fatalx(U_("unable to allocate memory"));
|
||||||
sigfwd->signo = signo;
|
sigfwd->signo = signo;
|
||||||
TAILQ_INSERT_TAIL(&sigfwd_list, sigfwd, entries);
|
TAILQ_INSERT_TAIL(&sigfwd_list, sigfwd, entries);
|
||||||
|
|
||||||
|
@@ -100,7 +100,9 @@ disable_execute(char *const envp[])
|
|||||||
if (!enabled)
|
if (!enabled)
|
||||||
env_size++;
|
env_size++;
|
||||||
#endif
|
#endif
|
||||||
nenvp = sudo_emallocarray(env_size, sizeof(*envp));
|
nenvp = reallocarray(NULL, env_size, sizeof(*envp));
|
||||||
|
if (nenvp == NULL)
|
||||||
|
sudo_fatalx(U_("unable to allocate memory"));
|
||||||
memcpy(nenvp, envp, env_len * sizeof(*envp));
|
memcpy(nenvp, envp, env_len * sizeof(*envp));
|
||||||
nenvp[env_len] = NULL;
|
nenvp[env_len] = NULL;
|
||||||
|
|
||||||
@@ -112,11 +114,14 @@ disable_execute(char *const envp[])
|
|||||||
preload = sudo_new_key_val(RTLD_PRELOAD_VAR, sudo_conf_noexec_path());
|
preload = sudo_new_key_val(RTLD_PRELOAD_VAR, sudo_conf_noexec_path());
|
||||||
# endif
|
# endif
|
||||||
if (preload == NULL)
|
if (preload == NULL)
|
||||||
sudo_fatal(NULL);
|
sudo_fatalx(U_("unable to allocate memory"));
|
||||||
nenvp[env_len++] = preload;
|
nenvp[env_len++] = preload;
|
||||||
nenvp[env_len] = NULL;
|
nenvp[env_len] = NULL;
|
||||||
} else {
|
} else {
|
||||||
sudo_easprintf(&preload, "%s=%s%s%s", RTLD_PRELOAD_VAR, sudo_conf_noexec_path(), RTLD_PRELOAD_DELIM, nenvp[preload_idx]);
|
int len = asprintf(&preload, "%s=%s%s%s", RTLD_PRELOAD_VAR,
|
||||||
|
sudo_conf_noexec_path(), RTLD_PRELOAD_DELIM, nenvp[preload_idx]);
|
||||||
|
if (len == -1)
|
||||||
|
sudo_fatalx(U_("unable to allocate memory"));
|
||||||
nenvp[preload_idx] = preload;
|
nenvp[preload_idx] = preload;
|
||||||
}
|
}
|
||||||
# ifdef RTLD_PRELOAD_ENABLE_VAR
|
# ifdef RTLD_PRELOAD_ENABLE_VAR
|
||||||
@@ -151,12 +156,14 @@ sudo_execve(const char *path, char *const argv[], char *const envp[], bool noexe
|
|||||||
|
|
||||||
for (argc = 0; argv[argc] != NULL; argc++)
|
for (argc = 0; argv[argc] != NULL; argc++)
|
||||||
continue;
|
continue;
|
||||||
nargv = sudo_emallocarray(argc + 2, sizeof(char *));
|
nargv = reallocarray(NULL, argc + 2, sizeof(char *));
|
||||||
nargv[0] = "sh";
|
if (nargv != NULL) {
|
||||||
nargv[1] = (char *)path;
|
nargv[0] = "sh";
|
||||||
memcpy(nargv + 2, argv + 1, argc * sizeof(char *));
|
nargv[1] = (char *)path;
|
||||||
execve(_PATH_SUDO_BSHELL, nargv, envp);
|
memcpy(nargv + 2, argv + 1, argc * sizeof(char *));
|
||||||
sudo_efree(nargv);
|
execve(_PATH_SUDO_BSHELL, nargv, envp);
|
||||||
|
free(nargv);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@@ -695,7 +695,8 @@ io_buf_new(int rfd, int wfd, bool (*action)(const char *, unsigned int, struct i
|
|||||||
(void) fcntl(wfd, F_SETFL, n | O_NONBLOCK);
|
(void) fcntl(wfd, F_SETFL, n | O_NONBLOCK);
|
||||||
|
|
||||||
/* Allocate and add to head of list. */
|
/* Allocate and add to head of list. */
|
||||||
iob = sudo_emalloc(sizeof(*iob));
|
if ((iob = malloc(sizeof(*iob))) == NULL)
|
||||||
|
sudo_fatalx(U_("unable to allocate memory"));
|
||||||
iob->revent = sudo_ev_alloc(rfd, SUDO_EV_READ, io_callback, iob);
|
iob->revent = sudo_ev_alloc(rfd, SUDO_EV_READ, io_callback, iob);
|
||||||
iob->wevent = sudo_ev_alloc(wfd, SUDO_EV_WRITE, io_callback, iob);
|
iob->wevent = sudo_ev_alloc(wfd, SUDO_EV_WRITE, io_callback, iob);
|
||||||
iob->len = 0;
|
iob->len = 0;
|
||||||
@@ -703,7 +704,7 @@ io_buf_new(int rfd, int wfd, bool (*action)(const char *, unsigned int, struct i
|
|||||||
iob->action = action;
|
iob->action = action;
|
||||||
iob->buf[0] = '\0';
|
iob->buf[0] = '\0';
|
||||||
if (iob->revent == NULL || iob->wevent == NULL)
|
if (iob->revent == NULL || iob->wevent == NULL)
|
||||||
sudo_fatal(NULL);
|
sudo_fatalx(U_("unable to allocate memory"));
|
||||||
SLIST_INSERT_HEAD(head, iob, entries);
|
SLIST_INSERT_HEAD(head, iob, entries);
|
||||||
|
|
||||||
debug_return;
|
debug_return;
|
||||||
@@ -907,7 +908,7 @@ pty_close(struct command_status *cstat)
|
|||||||
/* Free I/O buffers. */
|
/* Free I/O buffers. */
|
||||||
while ((iob = SLIST_FIRST(&iobufs)) != NULL) {
|
while ((iob = SLIST_FIRST(&iobufs)) != NULL) {
|
||||||
SLIST_REMOVE_HEAD(&iobufs, entries);
|
SLIST_REMOVE_HEAD(&iobufs, entries);
|
||||||
sudo_efree(iob);
|
free(iob);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Restore terminal settings. */
|
/* Restore terminal settings. */
|
||||||
|
30
src/hooks.c
30
src/hooks.c
@@ -35,6 +35,7 @@
|
|||||||
#ifdef HAVE_UNISTD_H
|
#ifdef HAVE_UNISTD_H
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
#endif /* HAVE_UNISTD_H */
|
#endif /* HAVE_UNISTD_H */
|
||||||
|
#include <errno.h>
|
||||||
|
|
||||||
#include "sudo.h"
|
#include "sudo.h"
|
||||||
#include "sudo_plugin.h"
|
#include "sudo_plugin.h"
|
||||||
@@ -132,51 +133,54 @@ process_hooks_unsetenv(const char *name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Hook registration internals. */
|
/* Hook registration internals. */
|
||||||
static void
|
static int
|
||||||
register_hook_internal(struct sudo_hook_list *head,
|
register_hook_internal(struct sudo_hook_list *head,
|
||||||
int (*hook_fn)(), void *closure)
|
int (*hook_fn)(), void *closure)
|
||||||
{
|
{
|
||||||
struct sudo_hook_entry *hook;
|
struct sudo_hook_entry *hook;
|
||||||
debug_decl(register_hook_internal, SUDO_DEBUG_HOOKS)
|
debug_decl(register_hook_internal, SUDO_DEBUG_HOOKS)
|
||||||
|
|
||||||
hook = sudo_ecalloc(1, sizeof(*hook));
|
if ((hook = calloc(1, sizeof(*hook))) == NULL)
|
||||||
|
debug_return_int(-1);
|
||||||
hook->u.generic_fn = hook_fn;
|
hook->u.generic_fn = hook_fn;
|
||||||
hook->closure = closure;
|
hook->closure = closure;
|
||||||
SLIST_INSERT_HEAD(head, hook, entries);
|
SLIST_INSERT_HEAD(head, hook, entries);
|
||||||
|
|
||||||
debug_return;
|
debug_return_int(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Register the specified hook. */
|
/* Register the specified hook. */
|
||||||
int
|
int
|
||||||
register_hook(struct sudo_hook *hook)
|
register_hook(struct sudo_hook *hook)
|
||||||
{
|
{
|
||||||
int rval = 0;
|
int rval;
|
||||||
debug_decl(register_hook, SUDO_DEBUG_HOOKS)
|
debug_decl(register_hook, SUDO_DEBUG_HOOKS)
|
||||||
|
|
||||||
if (SUDO_HOOK_VERSION_GET_MAJOR(hook->hook_version) != SUDO_HOOK_VERSION_MAJOR) {
|
if (SUDO_HOOK_VERSION_GET_MAJOR(hook->hook_version) != SUDO_HOOK_VERSION_MAJOR) {
|
||||||
/* Major versions must match. */
|
/* Major versions must match. */
|
||||||
|
errno = EINVAL;
|
||||||
rval = -1;
|
rval = -1;
|
||||||
} else {
|
} else {
|
||||||
switch (hook->hook_type) {
|
switch (hook->hook_type) {
|
||||||
case SUDO_HOOK_GETENV:
|
case SUDO_HOOK_GETENV:
|
||||||
register_hook_internal(&sudo_hook_getenv_list, hook->hook_fn,
|
rval = register_hook_internal(&sudo_hook_getenv_list,
|
||||||
hook->closure);
|
hook->hook_fn, hook->closure);
|
||||||
break;
|
break;
|
||||||
case SUDO_HOOK_PUTENV:
|
case SUDO_HOOK_PUTENV:
|
||||||
register_hook_internal(&sudo_hook_putenv_list, hook->hook_fn,
|
rval = register_hook_internal(&sudo_hook_putenv_list,
|
||||||
hook->closure);
|
hook->hook_fn, hook->closure);
|
||||||
break;
|
break;
|
||||||
case SUDO_HOOK_SETENV:
|
case SUDO_HOOK_SETENV:
|
||||||
register_hook_internal(&sudo_hook_setenv_list, hook->hook_fn,
|
rval = register_hook_internal(&sudo_hook_setenv_list,
|
||||||
hook->closure);
|
hook->hook_fn, hook->closure);
|
||||||
break;
|
break;
|
||||||
case SUDO_HOOK_UNSETENV:
|
case SUDO_HOOK_UNSETENV:
|
||||||
register_hook_internal(&sudo_hook_unsetenv_list, hook->hook_fn,
|
rval = register_hook_internal(&sudo_hook_unsetenv_list,
|
||||||
hook->closure);
|
hook->hook_fn, hook->closure);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* XXX - use define for unknown value */
|
/* XXX - use define for unknown value */
|
||||||
|
errno = ENOTSUP;
|
||||||
rval = 1;
|
rval = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -200,7 +204,7 @@ deregister_hook_internal(struct sudo_hook_list *head,
|
|||||||
SLIST_REMOVE_HEAD(head, entries);
|
SLIST_REMOVE_HEAD(head, entries);
|
||||||
else
|
else
|
||||||
SLIST_REMOVE_AFTER(prev, entries);
|
SLIST_REMOVE_AFTER(prev, entries);
|
||||||
sudo_efree(hook);
|
free(hook);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
prev = hook;
|
prev = hook;
|
||||||
|
@@ -155,16 +155,15 @@ static bool
|
|||||||
sudo_load_plugin(struct plugin_container *policy_plugin,
|
sudo_load_plugin(struct plugin_container *policy_plugin,
|
||||||
struct plugin_container_list *io_plugins, struct plugin_info *info)
|
struct plugin_container_list *io_plugins, struct plugin_info *info)
|
||||||
{
|
{
|
||||||
struct plugin_container *container;
|
struct plugin_container *container = NULL;
|
||||||
struct generic_plugin *plugin;
|
struct generic_plugin *plugin;
|
||||||
char path[PATH_MAX];
|
char path[PATH_MAX];
|
||||||
bool rval = false;
|
void *handle = NULL;
|
||||||
void *handle;
|
|
||||||
debug_decl(sudo_load_plugin, SUDO_DEBUG_PLUGIN)
|
debug_decl(sudo_load_plugin, SUDO_DEBUG_PLUGIN)
|
||||||
|
|
||||||
/* Sanity check plugin and fill in path */
|
/* Sanity check plugin and fill in path */
|
||||||
if (!sudo_check_plugin(info, path, sizeof(path)))
|
if (!sudo_check_plugin(info, path, sizeof(path)))
|
||||||
goto done;
|
goto bad;
|
||||||
|
|
||||||
/* Open plugin and map in symbol */
|
/* Open plugin and map in symbol */
|
||||||
handle = sudo_dso_load(path, SUDO_DSO_LAZY|SUDO_DSO_GLOBAL);
|
handle = sudo_dso_load(path, SUDO_DSO_LAZY|SUDO_DSO_GLOBAL);
|
||||||
@@ -172,21 +171,21 @@ sudo_load_plugin(struct plugin_container *policy_plugin,
|
|||||||
sudo_warnx(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);
|
_PATH_SUDO_CONF, info->lineno, info->symbol_name);
|
||||||
sudo_warnx(U_("unable to load %s: %s"), path, sudo_dso_strerror());
|
sudo_warnx(U_("unable to load %s: %s"), path, sudo_dso_strerror());
|
||||||
goto done;
|
goto bad;
|
||||||
}
|
}
|
||||||
plugin = sudo_dso_findsym(handle, info->symbol_name);
|
plugin = sudo_dso_findsym(handle, info->symbol_name);
|
||||||
if (!plugin) {
|
if (!plugin) {
|
||||||
sudo_warnx(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);
|
_PATH_SUDO_CONF, info->lineno, info->symbol_name);
|
||||||
sudo_warnx(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;
|
goto bad;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin->type != SUDO_POLICY_PLUGIN && plugin->type != SUDO_IO_PLUGIN) {
|
if (plugin->type != SUDO_POLICY_PLUGIN && plugin->type != SUDO_IO_PLUGIN) {
|
||||||
sudo_warnx(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);
|
_PATH_SUDO_CONF, info->lineno, info->symbol_name);
|
||||||
sudo_warnx(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;
|
goto bad;
|
||||||
}
|
}
|
||||||
if (SUDO_API_VERSION_GET_MAJOR(plugin->version) != SUDO_API_VERSION_MAJOR) {
|
if (SUDO_API_VERSION_GET_MAJOR(plugin->version) != SUDO_API_VERSION_MAJOR) {
|
||||||
sudo_warnx(U_("error in %s, line %d while loading plugin `%s'"),
|
sudo_warnx(U_("error in %s, line %d while loading plugin `%s'"),
|
||||||
@@ -194,25 +193,28 @@ sudo_load_plugin(struct plugin_container *policy_plugin,
|
|||||||
sudo_warnx(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_GET_MAJOR(plugin->version),
|
||||||
SUDO_API_VERSION_MAJOR, path);
|
SUDO_API_VERSION_MAJOR, path);
|
||||||
goto done;
|
goto bad;
|
||||||
}
|
}
|
||||||
if (plugin->type == SUDO_POLICY_PLUGIN) {
|
if (plugin->type == SUDO_POLICY_PLUGIN) {
|
||||||
if (policy_plugin->handle) {
|
if (policy_plugin->handle != NULL) {
|
||||||
/* Ignore duplicate entries. */
|
/* Ignore duplicate entries. */
|
||||||
if (strcmp(policy_plugin->name, info->symbol_name) != 0) {
|
if (strcmp(policy_plugin->name, info->symbol_name) != 0) {
|
||||||
sudo_warnx(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);
|
info->symbol_name, _PATH_SUDO_CONF, info->lineno);
|
||||||
sudo_warnx(U_("only a single policy plugin may be specified"));
|
sudo_warnx(U_("only a single policy plugin may be specified"));
|
||||||
goto done;
|
goto bad;
|
||||||
}
|
}
|
||||||
sudo_warnx(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);
|
info->symbol_name, _PATH_SUDO_CONF, info->lineno);
|
||||||
sudo_dso_unload(handle);
|
goto bad;
|
||||||
handle = NULL;
|
|
||||||
}
|
}
|
||||||
if (handle != NULL) {
|
if (handle != NULL) {
|
||||||
policy_plugin->handle = handle;
|
policy_plugin->handle = handle;
|
||||||
policy_plugin->path = sudo_estrdup(path);
|
policy_plugin->path = strdup(path);
|
||||||
|
if (policy_plugin->path == NULL) {
|
||||||
|
sudo_warnx(U_("unable to allocate memory"));
|
||||||
|
goto bad;
|
||||||
|
}
|
||||||
policy_plugin->name = info->symbol_name;
|
policy_plugin->name = info->symbol_name;
|
||||||
policy_plugin->options = info->options;
|
policy_plugin->options = info->options;
|
||||||
policy_plugin->debug_instance = SUDO_DEBUG_INSTANCE_INITIALIZER;
|
policy_plugin->debug_instance = SUDO_DEBUG_INSTANCE_INITIALIZER;
|
||||||
@@ -231,9 +233,12 @@ sudo_load_plugin(struct plugin_container *policy_plugin,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (handle != NULL) {
|
if (handle != NULL) {
|
||||||
container = sudo_ecalloc(1, sizeof(*container));
|
container = calloc(1, sizeof(*container));
|
||||||
|
if (container == NULL || (container->path = strdup(path)) == NULL) {
|
||||||
|
sudo_warnx(U_("unable to allocate memory"));
|
||||||
|
goto bad;
|
||||||
|
}
|
||||||
container->handle = handle;
|
container->handle = handle;
|
||||||
container->path = sudo_estrdup(path);
|
|
||||||
container->name = info->symbol_name;
|
container->name = info->symbol_name;
|
||||||
container->options = info->options;
|
container->options = info->options;
|
||||||
container->debug_instance = SUDO_DEBUG_INSTANCE_INITIALIZER;
|
container->debug_instance = SUDO_DEBUG_INSTANCE_INITIALIZER;
|
||||||
@@ -247,18 +252,21 @@ sudo_load_plugin(struct plugin_container *policy_plugin,
|
|||||||
info->symbol_name = NULL;
|
info->symbol_name = NULL;
|
||||||
info->options = NULL;
|
info->options = NULL;
|
||||||
|
|
||||||
rval = true;
|
debug_return_bool(true);
|
||||||
done:
|
bad:
|
||||||
debug_return_bool(rval);
|
free(container);
|
||||||
|
if (handle != NULL)
|
||||||
|
sudo_dso_unload(handle);
|
||||||
|
debug_return_bool(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
free_plugin_info(struct plugin_info *info)
|
free_plugin_info(struct plugin_info *info)
|
||||||
{
|
{
|
||||||
sudo_efree(info->path);
|
free(info->path);
|
||||||
sudo_efree(info->options);
|
free(info->options);
|
||||||
sudo_efree(info->symbol_name);
|
free(info->symbol_name);
|
||||||
sudo_efree(info);
|
free(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -290,23 +298,31 @@ sudo_load_plugins(struct plugin_container *policy_plugin,
|
|||||||
*/
|
*/
|
||||||
if (policy_plugin->handle == NULL) {
|
if (policy_plugin->handle == NULL) {
|
||||||
/* Default policy plugin */
|
/* Default policy plugin */
|
||||||
info = sudo_ecalloc(1, sizeof(*info));
|
info = calloc(1, sizeof(*info));
|
||||||
|
if (info == NULL) {
|
||||||
|
sudo_warnx(U_("unable to allocate memory"));
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
info->symbol_name = "sudoers_policy";
|
info->symbol_name = "sudoers_policy";
|
||||||
info->path = SUDOERS_PLUGIN;
|
info->path = SUDOERS_PLUGIN;
|
||||||
/* info->options = NULL; */
|
/* info->options = NULL; */
|
||||||
rval = sudo_load_plugin(policy_plugin, io_plugins, info);
|
rval = sudo_load_plugin(policy_plugin, io_plugins, info);
|
||||||
sudo_efree(info);
|
free(info);
|
||||||
if (!rval)
|
if (!rval)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
/* Default I/O plugin */
|
/* Default I/O plugin */
|
||||||
if (TAILQ_EMPTY(io_plugins)) {
|
if (TAILQ_EMPTY(io_plugins)) {
|
||||||
info = sudo_ecalloc(1, sizeof(*info));
|
info = calloc(1, sizeof(*info));
|
||||||
|
if (info == NULL) {
|
||||||
|
sudo_warnx(U_("unable to allocate memory"));
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
info->symbol_name = "sudoers_io";
|
info->symbol_name = "sudoers_io";
|
||||||
info->path = SUDOERS_PLUGIN;
|
info->path = SUDOERS_PLUGIN;
|
||||||
/* info->options = NULL; */
|
/* info->options = NULL; */
|
||||||
rval = sudo_load_plugin(policy_plugin, io_plugins, info);
|
rval = sudo_load_plugin(policy_plugin, io_plugins, info);
|
||||||
sudo_efree(info);
|
free(info);
|
||||||
if (!rval)
|
if (!rval)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
@@ -90,7 +90,6 @@ struct rtentry;
|
|||||||
#include "sudo_gettext.h" /* must be included before sudo_compat.h */
|
#include "sudo_gettext.h" /* must be included before sudo_compat.h */
|
||||||
|
|
||||||
#include "sudo_compat.h"
|
#include "sudo_compat.h"
|
||||||
#include "sudo_alloc.h"
|
|
||||||
#include "sudo_fatal.h"
|
#include "sudo_fatal.h"
|
||||||
#include "sudo_conf.h"
|
#include "sudo_conf.h"
|
||||||
#include "sudo_debug.h"
|
#include "sudo_debug.h"
|
||||||
@@ -111,7 +110,7 @@ struct rtentry;
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Fill in the interfaces string with the machine's ip addresses and netmasks
|
* Fill in the interfaces string with the machine's ip addresses and netmasks
|
||||||
* and return the number of interfaces found.
|
* and return the number of interfaces found. Returns -1 on error.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
get_net_ifs(char **addrinfo)
|
get_net_ifs(char **addrinfo)
|
||||||
@@ -128,9 +127,12 @@ get_net_ifs(char **addrinfo)
|
|||||||
char *cp;
|
char *cp;
|
||||||
debug_decl(get_net_ifs, SUDO_DEBUG_NETIF)
|
debug_decl(get_net_ifs, SUDO_DEBUG_NETIF)
|
||||||
|
|
||||||
if (!sudo_conf_probe_interfaces() || getifaddrs(&ifaddrs) != 0)
|
if (!sudo_conf_probe_interfaces())
|
||||||
debug_return_int(0);
|
debug_return_int(0);
|
||||||
|
|
||||||
|
if (getifaddrs(&ifaddrs) == -1)
|
||||||
|
debug_return_int(-1);
|
||||||
|
|
||||||
/* Allocate space for the interfaces info string. */
|
/* Allocate space for the interfaces info string. */
|
||||||
for (ifa = ifaddrs; ifa != NULL; ifa = ifa -> ifa_next) {
|
for (ifa = ifaddrs; ifa != NULL; ifa = ifa -> ifa_next) {
|
||||||
/* Skip interfaces marked "down" and "loopback". */
|
/* Skip interfaces marked "down" and "loopback". */
|
||||||
@@ -150,7 +152,9 @@ get_net_ifs(char **addrinfo)
|
|||||||
if (num_interfaces == 0)
|
if (num_interfaces == 0)
|
||||||
debug_return_int(0);
|
debug_return_int(0);
|
||||||
ailen = num_interfaces * 2 * INET6_ADDRSTRLEN;
|
ailen = num_interfaces * 2 * INET6_ADDRSTRLEN;
|
||||||
*addrinfo = cp = sudo_emalloc(ailen);
|
if ((cp = malloc(ailen)) == NULL)
|
||||||
|
debug_return_int(-1);
|
||||||
|
*addrinfo = cp;
|
||||||
|
|
||||||
/* Store the IP addr/netmask pairs. */
|
/* Store the IP addr/netmask pairs. */
|
||||||
for (ifa = ifaddrs; ifa != NULL; ifa = ifa -> ifa_next) {
|
for (ifa = ifaddrs; ifa != NULL; ifa = ifa -> ifa_next) {
|
||||||
@@ -201,7 +205,7 @@ done:
|
|||||||
#ifdef HAVE_FREEIFADDRS
|
#ifdef HAVE_FREEIFADDRS
|
||||||
freeifaddrs(ifaddrs);
|
freeifaddrs(ifaddrs);
|
||||||
#else
|
#else
|
||||||
sudo_efree(ifaddrs);
|
free(ifaddrs);
|
||||||
#endif
|
#endif
|
||||||
debug_return_int(num_interfaces);
|
debug_return_int(num_interfaces);
|
||||||
}
|
}
|
||||||
@@ -209,8 +213,8 @@ done:
|
|||||||
#elif defined(SIOCGIFCONF) && !defined(STUB_LOAD_INTERFACES)
|
#elif defined(SIOCGIFCONF) && !defined(STUB_LOAD_INTERFACES)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allocate and fill in the interfaces global variable with the
|
* Fill in the interfaces string with the machine's ip addresses and netmasks
|
||||||
* machine's ip addresses and netmasks.
|
* and return the number of interfaces found. Returns -1 on error.
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
get_net_ifs(char **addrinfo)
|
get_net_ifs(char **addrinfo)
|
||||||
@@ -233,13 +237,16 @@ get_net_ifs(char **addrinfo)
|
|||||||
|
|
||||||
sock = socket(AF_INET, SOCK_DGRAM, 0);
|
sock = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
if (sock < 0)
|
if (sock < 0)
|
||||||
sudo_fatal(U_("unable to open socket"));
|
debug_return_int(-1);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Get interface configuration or return.
|
* Get interface configuration or return.
|
||||||
*/
|
*/
|
||||||
for (;;) {
|
for (;;) {
|
||||||
ifconf_buf = sudo_emalloc(buflen);
|
if ((ifconf_buf = malloc(buflen)) == NULL) {
|
||||||
|
num_interfaces = -1;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
ifconf = (struct ifconf *) ifconf_buf;
|
ifconf = (struct ifconf *) ifconf_buf;
|
||||||
ifconf->ifc_len = buflen - sizeof(struct ifconf);
|
ifconf->ifc_len = buflen - sizeof(struct ifconf);
|
||||||
ifconf->ifc_buf = (caddr_t) (ifconf_buf + sizeof(struct ifconf));
|
ifconf->ifc_buf = (caddr_t) (ifconf_buf + sizeof(struct ifconf));
|
||||||
@@ -257,14 +264,18 @@ get_net_ifs(char **addrinfo)
|
|||||||
if (ifconf->ifc_len + sizeof(struct ifreq) < buflen)
|
if (ifconf->ifc_len + sizeof(struct ifreq) < buflen)
|
||||||
break;
|
break;
|
||||||
buflen += BUFSIZ;
|
buflen += BUFSIZ;
|
||||||
sudo_efree(ifconf_buf);
|
free(ifconf_buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate space for the maximum number of interfaces that could exist. */
|
/* Allocate space for the maximum number of interfaces that could exist. */
|
||||||
if ((n = ifconf->ifc_len / sizeof(struct ifreq)) == 0)
|
if ((n = ifconf->ifc_len / sizeof(struct ifreq)) == 0)
|
||||||
debug_return_int(0);
|
goto done;
|
||||||
ailen = n * 2 * INET6_ADDRSTRLEN;
|
ailen = n * 2 * INET6_ADDRSTRLEN;
|
||||||
*addrinfo = cp = sudo_emalloc(ailen);
|
if ((cp = malloc(ailen)) == NULL) {
|
||||||
|
num_interfaces = -1;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
*addrinfo = cp;
|
||||||
|
|
||||||
/* For each interface, store the ip address and netmask. */
|
/* For each interface, store the ip address and netmask. */
|
||||||
for (i = 0; i < ifconf->ifc_len; ) {
|
for (i = 0; i < ifconf->ifc_len; ) {
|
||||||
@@ -333,7 +344,7 @@ get_net_ifs(char **addrinfo)
|
|||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
sudo_efree(ifconf_buf);
|
free(ifconf_buf);
|
||||||
(void) close(sock);
|
(void) close(sock);
|
||||||
|
|
||||||
debug_return_int(num_interfaces);
|
debug_return_int(num_interfaces);
|
||||||
|
@@ -184,7 +184,9 @@ parse_args(int argc, char **argv, int *nargc, char ***nargv,
|
|||||||
if (argc <= 0)
|
if (argc <= 0)
|
||||||
usage(1);
|
usage(1);
|
||||||
|
|
||||||
env_add = sudo_emallocarray(env_size, sizeof(char *));
|
env_add = reallocarray(NULL, env_size, sizeof(char *));
|
||||||
|
if (env_add == NULL)
|
||||||
|
sudo_fatalx(U_("unable to allocate memory"));
|
||||||
|
|
||||||
/* Pass progname to plugin so it can call initprogname() */
|
/* Pass progname to plugin so it can call initprogname() */
|
||||||
progname = getprogname();
|
progname = getprogname();
|
||||||
@@ -205,7 +207,8 @@ parse_args(int argc, char **argv, int *nargc, char ***nargv,
|
|||||||
/* Set max_groups from sudo.conf. */
|
/* Set max_groups from sudo.conf. */
|
||||||
i = sudo_conf_max_groups();
|
i = sudo_conf_max_groups();
|
||||||
if (i != -1) {
|
if (i != -1) {
|
||||||
sudo_easprintf(&cp, "%d", i);
|
if (asprintf(&cp, "%d", i) == -1)
|
||||||
|
sudo_fatalx(U_("unable to allocate memory"));
|
||||||
sudo_settings[ARG_MAX_GROUPS].value = cp;
|
sudo_settings[ARG_MAX_GROUPS].value = cp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -369,8 +372,13 @@ parse_args(int argc, char **argv, int *nargc, char ***nargv,
|
|||||||
}
|
}
|
||||||
} else if (!got_end_of_args && is_envar) {
|
} else if (!got_end_of_args && is_envar) {
|
||||||
if (nenv == env_size - 2) {
|
if (nenv == env_size - 2) {
|
||||||
|
char **tmp;
|
||||||
|
|
||||||
|
tmp = reallocarray(env_add, env_size, 2 * sizeof(char *));
|
||||||
|
if (tmp == NULL)
|
||||||
|
sudo_fatalx(U_("unable to allocate memory"));
|
||||||
|
env_add = tmp;
|
||||||
env_size *= 2;
|
env_size *= 2;
|
||||||
env_add = sudo_ereallocarray(env_add, env_size, sizeof(char *));
|
|
||||||
}
|
}
|
||||||
env_add[nenv++] = argv[optind];
|
env_add[nenv++] = argv[optind];
|
||||||
|
|
||||||
@@ -462,7 +470,9 @@ parse_args(int argc, char **argv, int *nargc, char ***nargv,
|
|||||||
size_t cmnd_size = (size_t) (argv[argc - 1] - argv[0]) +
|
size_t cmnd_size = (size_t) (argv[argc - 1] - argv[0]) +
|
||||||
strlen(argv[argc - 1]) + 1;
|
strlen(argv[argc - 1]) + 1;
|
||||||
|
|
||||||
cmnd = dst = sudo_emallocarray(cmnd_size, 2);
|
cmnd = dst = reallocarray(NULL, cmnd_size, 2);
|
||||||
|
if (cmnd == NULL)
|
||||||
|
sudo_fatalx(U_("unable to allocate memory"));
|
||||||
for (av = argv; *av != NULL; av++) {
|
for (av = argv; *av != NULL; av++) {
|
||||||
for (src = *av; *src != '\0'; src++) {
|
for (src = *av; *src != '\0'; src++) {
|
||||||
/* quote potential meta characters */
|
/* quote potential meta characters */
|
||||||
@@ -479,7 +489,9 @@ parse_args(int argc, char **argv, int *nargc, char ***nargv,
|
|||||||
ac += 2; /* -c cmnd */
|
ac += 2; /* -c cmnd */
|
||||||
}
|
}
|
||||||
|
|
||||||
av = sudo_emallocarray(ac + 1, sizeof(char *));
|
av = reallocarray(NULL, ac + 1, sizeof(char *));
|
||||||
|
if (av == NULL)
|
||||||
|
sudo_fatalx(U_("unable to allocate memory"));
|
||||||
av[0] = (char *)user_details.shell; /* plugin may override shell */
|
av[0] = (char *)user_details.shell; /* plugin may override shell */
|
||||||
if (cmnd != NULL) {
|
if (cmnd != NULL) {
|
||||||
av[1] = "-c";
|
av[1] = "-c";
|
||||||
|
@@ -59,12 +59,14 @@ add_preserved_fd(struct preserved_fd_list *pfds, int fd)
|
|||||||
struct preserved_fd *pfd, *pfd_new;
|
struct preserved_fd *pfd, *pfd_new;
|
||||||
debug_decl(add_preserved_fd, SUDO_DEBUG_UTIL)
|
debug_decl(add_preserved_fd, SUDO_DEBUG_UTIL)
|
||||||
|
|
||||||
pfd_new = sudo_emalloc(sizeof(*pfd));
|
pfd_new = malloc(sizeof(*pfd));
|
||||||
|
if (pfd_new == NULL)
|
||||||
|
sudo_fatalx(U_("unable to allocate memory"));
|
||||||
pfd_new->lowfd = fd;
|
pfd_new->lowfd = fd;
|
||||||
pfd_new->highfd = fd;
|
pfd_new->highfd = fd;
|
||||||
pfd_new->flags = fcntl(fd, F_GETFD);
|
pfd_new->flags = fcntl(fd, F_GETFD);
|
||||||
if (pfd_new->flags == -1) {
|
if (pfd_new->flags == -1) {
|
||||||
sudo_efree(pfd_new);
|
free(pfd_new);
|
||||||
debug_return_int(-1);
|
debug_return_int(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -73,7 +75,7 @@ add_preserved_fd(struct preserved_fd_list *pfds, int fd)
|
|||||||
/* already preserved */
|
/* already preserved */
|
||||||
sudo_debug_printf(SUDO_DEBUG_DEBUG|SUDO_DEBUG_LINENO,
|
sudo_debug_printf(SUDO_DEBUG_DEBUG|SUDO_DEBUG_LINENO,
|
||||||
"fd %d already preserved", fd);
|
"fd %d already preserved", fd);
|
||||||
sudo_efree(pfd_new);
|
free(pfd_new);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (fd < pfd->highfd) {
|
if (fd < pfd->highfd) {
|
||||||
@@ -140,7 +142,9 @@ closefrom_except(int startfd, struct preserved_fd_list *pfds)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Create bitmap of preserved (relocated) fds. */
|
/* Create bitmap of preserved (relocated) fds. */
|
||||||
fdsp = sudo_ecalloc(howmany(lastfd + 1, NFDBITS), sizeof(fd_mask));
|
fdsp = calloc(howmany(lastfd + 1, NFDBITS), sizeof(fd_mask));
|
||||||
|
if (fdsp == NULL)
|
||||||
|
sudo_fatalx(U_("unable to allocate memory"));
|
||||||
TAILQ_FOREACH(pfd, pfds, entries) {
|
TAILQ_FOREACH(pfd, pfds, entries) {
|
||||||
FD_SET(pfd->lowfd, fdsp);
|
FD_SET(pfd->lowfd, fdsp);
|
||||||
}
|
}
|
||||||
|
@@ -39,7 +39,6 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#include "sudo_compat.h"
|
#include "sudo_compat.h"
|
||||||
#include "sudo_alloc.h"
|
|
||||||
#include "sudo_fatal.h"
|
#include "sudo_fatal.h"
|
||||||
#include "sudo_util.h"
|
#include "sudo_util.h"
|
||||||
#include "sudo_debug.h"
|
#include "sudo_debug.h"
|
||||||
@@ -89,6 +88,6 @@ main(int argc, char *argv[])
|
|||||||
tty_sudo ? tty_sudo : "none", tty_libc ? tty_libc : "none");
|
tty_sudo ? tty_sudo : "none", tty_libc ? tty_libc : "none");
|
||||||
}
|
}
|
||||||
|
|
||||||
sudo_efree(tty_sudo);
|
free(tty_sudo);
|
||||||
exit(rval);
|
exit(rval);
|
||||||
}
|
}
|
||||||
|
@@ -79,13 +79,15 @@ audit_role_change(const security_context_t old_context,
|
|||||||
sudo_fatal(U_("unable to open audit system"));
|
sudo_fatal(U_("unable to open audit system"));
|
||||||
} else {
|
} else {
|
||||||
/* audit role change using the same format as newrole(1) */
|
/* audit role change using the same format as newrole(1) */
|
||||||
sudo_easprintf(&message, "newrole: old-context=%s new-context=%s",
|
rc = asprintf(&message, "newrole: old-context=%s new-context=%s",
|
||||||
old_context, new_context);
|
old_context, new_context);
|
||||||
|
if (rc == -1)
|
||||||
|
sudo_fatalx(U_("unable to allocate memory"));
|
||||||
rc = audit_log_user_message(au_fd, AUDIT_USER_ROLE_CHANGE,
|
rc = audit_log_user_message(au_fd, AUDIT_USER_ROLE_CHANGE,
|
||||||
message, NULL, NULL, ttyn, result);
|
message, NULL, NULL, ttyn, result);
|
||||||
if (rc <= 0)
|
if (rc <= 0)
|
||||||
sudo_warn(U_("unable to send audit message"));
|
sudo_warn(U_("unable to send audit message"));
|
||||||
sudo_efree(message);
|
free(message);
|
||||||
close(au_fd);
|
close(au_fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -286,7 +288,10 @@ get_exec_context(security_context_t old_context, const char *role, const char *t
|
|||||||
/*
|
/*
|
||||||
* Convert "context" back into a string and verify it.
|
* Convert "context" back into a string and verify it.
|
||||||
*/
|
*/
|
||||||
new_context = sudo_estrdup(context_str(context));
|
if ((new_context = strdup(context_str(context))) == NULL) {
|
||||||
|
sudo_warnx(U_("unable to allocate memory"));
|
||||||
|
goto bad;
|
||||||
|
}
|
||||||
if (security_check_context(new_context) < 0) {
|
if (security_check_context(new_context) < 0) {
|
||||||
sudo_warnx(U_("%s is not a valid context"), new_context);
|
sudo_warnx(U_("%s is not a valid context"), new_context);
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
@@ -301,7 +306,7 @@ get_exec_context(security_context_t old_context, const char *role, const char *t
|
|||||||
debug_return_ptr(new_context);
|
debug_return_ptr(new_context);
|
||||||
|
|
||||||
bad:
|
bad:
|
||||||
sudo_efree(typebuf);
|
free(typebuf);
|
||||||
context_free(context);
|
context_free(context);
|
||||||
freecon(new_context);
|
freecon(new_context);
|
||||||
debug_return_ptr(NULL);
|
debug_return_ptr(NULL);
|
||||||
@@ -405,7 +410,11 @@ selinux_execve(const char *path, char *const argv[], char *const envp[],
|
|||||||
*/
|
*/
|
||||||
for (argc = 0; argv[argc] != NULL; argc++)
|
for (argc = 0; argv[argc] != NULL; argc++)
|
||||||
continue;
|
continue;
|
||||||
nargv = sudo_emallocarray(argc + 2, sizeof(char *));
|
nargv = reallocarray(NULL, argc + 2, sizeof(char *));
|
||||||
|
if (nargv == NULL) {
|
||||||
|
sudo_warnx(U_("unable to allocate memory"));
|
||||||
|
debug_return;
|
||||||
|
}
|
||||||
if (noexec)
|
if (noexec)
|
||||||
nargv[0] = *argv[0] == '-' ? "-sesh-noexec" : "sesh-noexec";
|
nargv[0] = *argv[0] == '-' ? "-sesh-noexec" : "sesh-noexec";
|
||||||
else
|
else
|
||||||
|
@@ -41,7 +41,6 @@
|
|||||||
#include "sudo_gettext.h" /* must be included before sudo_compat.h */
|
#include "sudo_gettext.h" /* must be included before sudo_compat.h */
|
||||||
|
|
||||||
#include "sudo_compat.h"
|
#include "sudo_compat.h"
|
||||||
#include "sudo_alloc.h"
|
|
||||||
#include "sudo_fatal.h"
|
#include "sudo_fatal.h"
|
||||||
#include "sudo_conf.h"
|
#include "sudo_conf.h"
|
||||||
#include "sudo_debug.h"
|
#include "sudo_debug.h"
|
||||||
@@ -98,7 +97,8 @@ main(int argc, char *argv[], char *envp[])
|
|||||||
/* Shift argv and make a copy of the command to execute. */
|
/* Shift argv and make a copy of the command to execute. */
|
||||||
argv++;
|
argv++;
|
||||||
argc--;
|
argc--;
|
||||||
cmnd = sudo_estrdup(argv[0]);
|
if ((cmnd = strdup(argv[0])) == NULL)
|
||||||
|
sudo_fatalx(U_("unable to allocate memory"));
|
||||||
|
|
||||||
/* If invoked as a login shell, modify argv[0] accordingly. */
|
/* If invoked as a login shell, modify argv[0] accordingly. */
|
||||||
if (login_shell) {
|
if (login_shell) {
|
||||||
|
119
src/sudo.c
119
src/sudo.c
@@ -189,8 +189,8 @@ main(int argc, char *argv[], char *envp[])
|
|||||||
sudo_conf_read(NULL, SUDO_CONF_ALL & ~SUDO_CONF_DEBUG);
|
sudo_conf_read(NULL, SUDO_CONF_ALL & ~SUDO_CONF_DEBUG);
|
||||||
|
|
||||||
/* Fill in user_info with user name, uid, cwd, etc. */
|
/* Fill in user_info with user name, uid, cwd, etc. */
|
||||||
memset(&user_details, 0, sizeof(user_details));
|
if ((user_info = get_user_info(&user_details)) == NULL)
|
||||||
user_info = get_user_info(&user_details);
|
sudo_fatalx(U_("unable to allocate memory"));
|
||||||
|
|
||||||
/* Disable core dumps if not enabled in sudo.conf. */
|
/* Disable core dumps if not enabled in sudo.conf. */
|
||||||
disable_coredumps();
|
disable_coredumps();
|
||||||
@@ -365,7 +365,11 @@ fill_group_list(struct user_details *ud, int system_maxgroups)
|
|||||||
*/
|
*/
|
||||||
ud->ngroups = sudo_conf_max_groups();
|
ud->ngroups = sudo_conf_max_groups();
|
||||||
if (ud->ngroups > 0) {
|
if (ud->ngroups > 0) {
|
||||||
ud->groups = sudo_emallocarray(ud->ngroups, sizeof(GETGROUPS_T));
|
ud->groups = reallocarray(NULL, ud->ngroups, sizeof(GETGROUPS_T));
|
||||||
|
if (ud->groups == NULL) {
|
||||||
|
sudo_warnx(U_("unable to allocate memory"));
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
/* No error on insufficient space if user specified max_groups. */
|
/* No error on insufficient space if user specified max_groups. */
|
||||||
(void)getgrouplist(ud->username, ud->gid, ud->groups, &ud->ngroups);
|
(void)getgrouplist(ud->username, ud->gid, ud->groups, &ud->ngroups);
|
||||||
rval = 0;
|
rval = 0;
|
||||||
@@ -379,11 +383,16 @@ fill_group_list(struct user_details *ud, int system_maxgroups)
|
|||||||
ud->ngroups = system_maxgroups << 1;
|
ud->ngroups = system_maxgroups << 1;
|
||||||
for (tries = 0; tries < 10 && rval == -1; tries++) {
|
for (tries = 0; tries < 10 && rval == -1; tries++) {
|
||||||
ud->ngroups <<= 1;
|
ud->ngroups <<= 1;
|
||||||
sudo_efree(ud->groups);
|
free(ud->groups);
|
||||||
ud->groups = sudo_emallocarray(ud->ngroups, sizeof(GETGROUPS_T));
|
ud->groups = reallocarray(NULL, ud->ngroups, sizeof(GETGROUPS_T));
|
||||||
|
if (ud->groups == NULL) {
|
||||||
|
sudo_warnx(U_("unable to allocate memory"));
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
rval = getgrouplist(ud->username, ud->gid, ud->groups, &ud->ngroups);
|
rval = getgrouplist(ud->username, ud->gid, ud->groups, &ud->ngroups);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
done:
|
||||||
debug_return_int(rval);
|
debug_return_int(rval);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -395,6 +404,8 @@ get_user_groups(struct user_details *ud)
|
|||||||
int i, len, maxgroups, group_source;
|
int i, len, maxgroups, group_source;
|
||||||
debug_decl(get_user_groups, SUDO_DEBUG_UTIL)
|
debug_decl(get_user_groups, SUDO_DEBUG_UTIL)
|
||||||
|
|
||||||
|
memset(ud, 0, sizeof(*ud));
|
||||||
|
|
||||||
maxgroups = (int)sysconf(_SC_NGROUPS_MAX);
|
maxgroups = (int)sysconf(_SC_NGROUPS_MAX);
|
||||||
if (maxgroups < 0)
|
if (maxgroups < 0)
|
||||||
maxgroups = NGROUPS_MAX;
|
maxgroups = NGROUPS_MAX;
|
||||||
@@ -405,9 +416,11 @@ get_user_groups(struct user_details *ud)
|
|||||||
if ((ud->ngroups = getgroups(0, NULL)) > 0) {
|
if ((ud->ngroups = getgroups(0, NULL)) > 0) {
|
||||||
/* Use groups from kernel if not too many or source is static. */
|
/* Use groups from kernel if not too many or source is static. */
|
||||||
if (ud->ngroups < maxgroups || group_source == GROUP_SOURCE_STATIC) {
|
if (ud->ngroups < maxgroups || group_source == GROUP_SOURCE_STATIC) {
|
||||||
ud->groups = sudo_emallocarray(ud->ngroups, sizeof(GETGROUPS_T));
|
ud->groups = reallocarray(NULL, ud->ngroups, sizeof(GETGROUPS_T));
|
||||||
|
if (ud->groups == NULL)
|
||||||
|
goto oom;
|
||||||
if (getgroups(ud->ngroups, ud->groups) < 0) {
|
if (getgroups(ud->ngroups, ud->groups) < 0) {
|
||||||
sudo_efree(ud->groups);
|
free(ud->groups);
|
||||||
ud->groups = NULL;
|
ud->groups = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -426,16 +439,20 @@ get_user_groups(struct user_details *ud)
|
|||||||
* Format group list as a comma-separated string of gids.
|
* Format group list as a comma-separated string of gids.
|
||||||
*/
|
*/
|
||||||
glsize = sizeof("groups=") - 1 + (ud->ngroups * (MAX_UID_T_LEN + 1));
|
glsize = sizeof("groups=") - 1 + (ud->ngroups * (MAX_UID_T_LEN + 1));
|
||||||
gid_list = sudo_emalloc(glsize);
|
if ((gid_list = malloc(glsize)) == NULL)
|
||||||
|
goto oom;
|
||||||
memcpy(gid_list, "groups=", sizeof("groups=") - 1);
|
memcpy(gid_list, "groups=", sizeof("groups=") - 1);
|
||||||
cp = gid_list + sizeof("groups=") - 1;
|
cp = gid_list + sizeof("groups=") - 1;
|
||||||
for (i = 0; i < ud->ngroups; i++) {
|
for (i = 0; i < ud->ngroups; i++) {
|
||||||
/* XXX - check rval */
|
|
||||||
len = snprintf(cp, glsize - (cp - gid_list), "%s%u",
|
len = snprintf(cp, glsize - (cp - gid_list), "%s%u",
|
||||||
i ? "," : "", (unsigned int)ud->groups[i]);
|
i ? "," : "", (unsigned int)ud->groups[i]);
|
||||||
|
if (len <= 0 || (size_t)len >= glsize - (cp - gid_list))
|
||||||
|
sudo_fatalx(U_("internal error, %s overflow"), __func__);
|
||||||
cp += len;
|
cp += len;
|
||||||
}
|
}
|
||||||
debug_return_str(gid_list);
|
debug_return_str(gid_list);
|
||||||
|
oom:
|
||||||
|
sudo_fatalx(U_("unable to allocate memory"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -451,7 +468,9 @@ get_user_info(struct user_details *ud)
|
|||||||
debug_decl(get_user_info, SUDO_DEBUG_UTIL)
|
debug_decl(get_user_info, SUDO_DEBUG_UTIL)
|
||||||
|
|
||||||
/* XXX - bound check number of entries */
|
/* XXX - bound check number of entries */
|
||||||
user_info = sudo_emallocarray(32, sizeof(char *));
|
user_info = reallocarray(NULL, 32, sizeof(char *));
|
||||||
|
if (user_info == NULL)
|
||||||
|
goto bad;
|
||||||
|
|
||||||
ud->pid = getpid();
|
ud->pid = getpid();
|
||||||
ud->ppid = getppid();
|
ud->ppid = getppid();
|
||||||
@@ -475,25 +494,34 @@ get_user_info(struct user_details *ud)
|
|||||||
|
|
||||||
user_info[i] = sudo_new_key_val("user", pw->pw_name);
|
user_info[i] = sudo_new_key_val("user", pw->pw_name);
|
||||||
if (user_info[i] == NULL)
|
if (user_info[i] == NULL)
|
||||||
sudo_fatal(NULL);
|
goto bad;
|
||||||
ud->username = user_info[i] + sizeof("user=") - 1;
|
ud->username = user_info[i] + sizeof("user=") - 1;
|
||||||
|
|
||||||
/* Stash user's shell for use with the -s flag; don't pass to plugin. */
|
/* Stash user's shell for use with the -s flag; don't pass to plugin. */
|
||||||
if ((ud->shell = getenv("SHELL")) == NULL || ud->shell[0] == '\0') {
|
if ((ud->shell = getenv("SHELL")) == NULL || ud->shell[0] == '\0') {
|
||||||
ud->shell = pw->pw_shell[0] ? pw->pw_shell : _PATH_SUDO_BSHELL;
|
ud->shell = pw->pw_shell[0] ? pw->pw_shell : _PATH_SUDO_BSHELL;
|
||||||
}
|
}
|
||||||
ud->shell = sudo_estrdup(ud->shell);
|
if ((ud->shell = strdup(ud->shell)) == NULL)
|
||||||
|
goto bad;
|
||||||
|
|
||||||
sudo_easprintf(&user_info[++i], "pid=%d", (int)ud->pid);
|
if (asprintf(&user_info[++i], "pid=%d", (int)ud->pid) == -1)
|
||||||
sudo_easprintf(&user_info[++i], "ppid=%d", (int)ud->ppid);
|
goto bad;
|
||||||
sudo_easprintf(&user_info[++i], "pgid=%d", (int)ud->pgid);
|
if (asprintf(&user_info[++i], "ppid=%d", (int)ud->ppid) == -1)
|
||||||
sudo_easprintf(&user_info[++i], "tcpgid=%d", (int)ud->tcpgid);
|
goto bad;
|
||||||
sudo_easprintf(&user_info[++i], "sid=%d", (int)ud->sid);
|
if (asprintf(&user_info[++i], "pgid=%d", (int)ud->pgid) == -1)
|
||||||
|
goto bad;
|
||||||
sudo_easprintf(&user_info[++i], "uid=%u", (unsigned int)ud->uid);
|
if (asprintf(&user_info[++i], "tcpgid=%d", (int)ud->tcpgid) == -1)
|
||||||
sudo_easprintf(&user_info[++i], "euid=%u", (unsigned int)ud->euid);
|
goto bad;
|
||||||
sudo_easprintf(&user_info[++i], "gid=%u", (unsigned int)ud->gid);
|
if (asprintf(&user_info[++i], "sid=%d", (int)ud->sid) == -1)
|
||||||
sudo_easprintf(&user_info[++i], "egid=%u", (unsigned int)ud->egid);
|
goto bad;
|
||||||
|
if (asprintf(&user_info[++i], "uid=%u", (unsigned int)ud->uid) == -1)
|
||||||
|
goto bad;
|
||||||
|
if (asprintf(&user_info[++i], "euid=%u", (unsigned int)ud->euid) == -1)
|
||||||
|
goto bad;
|
||||||
|
if (asprintf(&user_info[++i], "gid=%u", (unsigned int)ud->gid) == -1)
|
||||||
|
goto bad;
|
||||||
|
if (asprintf(&user_info[++i], "egid=%u", (unsigned int)ud->egid) == -1)
|
||||||
|
goto bad;
|
||||||
|
|
||||||
if ((cp = get_user_groups(ud)) != NULL)
|
if ((cp = get_user_groups(ud)) != NULL)
|
||||||
user_info[++i] = cp;
|
user_info[++i] = cp;
|
||||||
@@ -501,32 +529,43 @@ get_user_info(struct user_details *ud)
|
|||||||
if (getcwd(cwd, sizeof(cwd)) != NULL) {
|
if (getcwd(cwd, sizeof(cwd)) != NULL) {
|
||||||
user_info[++i] = sudo_new_key_val("cwd", cwd);
|
user_info[++i] = sudo_new_key_val("cwd", cwd);
|
||||||
if (user_info[i] == NULL)
|
if (user_info[i] == NULL)
|
||||||
sudo_fatal(NULL);
|
goto bad;
|
||||||
ud->cwd = user_info[i] + sizeof("cwd=") - 1;
|
ud->cwd = user_info[i] + sizeof("cwd=") - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((cp = get_process_ttyname()) != NULL) {
|
if ((cp = get_process_ttyname()) == NULL) {
|
||||||
|
/* tty may not always be present */
|
||||||
|
if (errno == ENOMEM)
|
||||||
|
goto bad;
|
||||||
|
} else {
|
||||||
user_info[++i] = sudo_new_key_val("tty", cp);
|
user_info[++i] = sudo_new_key_val("tty", cp);
|
||||||
if (user_info[i] == NULL)
|
if (user_info[i] == NULL)
|
||||||
sudo_fatal(NULL);
|
goto bad;
|
||||||
ud->tty = user_info[i] + sizeof("tty=") - 1;
|
ud->tty = user_info[i] + sizeof("tty=") - 1;
|
||||||
sudo_efree(cp);
|
free(cp);
|
||||||
}
|
}
|
||||||
|
|
||||||
cp = sudo_gethostname();
|
cp = sudo_gethostname();
|
||||||
user_info[++i] = sudo_new_key_val("host", cp ? cp : "localhost");
|
user_info[++i] = sudo_new_key_val("host", cp ? cp : "localhost");
|
||||||
if (user_info[i] == NULL)
|
if (user_info[i] == NULL)
|
||||||
sudo_fatal(NULL);
|
goto bad;
|
||||||
ud->host = user_info[i] + sizeof("host=") - 1;
|
ud->host = user_info[i] + sizeof("host=") - 1;
|
||||||
sudo_efree(cp);
|
free(cp);
|
||||||
|
|
||||||
sudo_get_ttysize(&ud->ts_lines, &ud->ts_cols);
|
sudo_get_ttysize(&ud->ts_lines, &ud->ts_cols);
|
||||||
sudo_easprintf(&user_info[++i], "lines=%d", ud->ts_lines);
|
if (asprintf(&user_info[++i], "lines=%d", ud->ts_lines) == -1)
|
||||||
sudo_easprintf(&user_info[++i], "cols=%d", ud->ts_cols);
|
goto bad;
|
||||||
|
if (asprintf(&user_info[++i], "cols=%d", ud->ts_cols) == -1)
|
||||||
|
goto bad;
|
||||||
|
|
||||||
user_info[++i] = NULL;
|
user_info[++i] = NULL;
|
||||||
|
|
||||||
debug_return_ptr(user_info);
|
debug_return_ptr(user_info);
|
||||||
|
bad:
|
||||||
|
while (i--)
|
||||||
|
free(user_info[i]);
|
||||||
|
free(user_info);
|
||||||
|
debug_return_ptr(NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -751,14 +790,14 @@ sudo_check_suid(const char *sudo)
|
|||||||
if (!qualified) {
|
if (!qualified) {
|
||||||
char *path = getenv_unhooked("PATH");
|
char *path = getenv_unhooked("PATH");
|
||||||
if (path != NULL) {
|
if (path != NULL) {
|
||||||
int len;
|
const char *cp, *ep;
|
||||||
char *cp, *colon;
|
const char *pathend = path + strlen(path);
|
||||||
|
|
||||||
cp = path = sudo_estrdup(path);
|
for (cp = sudo_strsplit(path, pathend, ":", &ep); cp != NULL;
|
||||||
do {
|
cp = sudo_strsplit(NULL, pathend, ":", &ep)) {
|
||||||
if ((colon = strchr(cp, ':')))
|
|
||||||
*colon = '\0';
|
int len = snprintf(pathbuf, sizeof(pathbuf), "%.*s/%s",
|
||||||
len = snprintf(pathbuf, sizeof(pathbuf), "%s/%s", cp, sudo);
|
(int)(ep - cp), cp, sudo);
|
||||||
if (len <= 0 || (size_t)len >= sizeof(pathbuf))
|
if (len <= 0 || (size_t)len >= sizeof(pathbuf))
|
||||||
continue;
|
continue;
|
||||||
if (access(pathbuf, X_OK) == 0) {
|
if (access(pathbuf, X_OK) == 0) {
|
||||||
@@ -766,9 +805,7 @@ sudo_check_suid(const char *sudo)
|
|||||||
qualified = true;
|
qualified = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
cp = colon + 1;
|
}
|
||||||
} while (colon);
|
|
||||||
sudo_efree(path);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1378,7 +1415,7 @@ iolog_unlink(struct plugin_container *plugin)
|
|||||||
}
|
}
|
||||||
/* Remove from io_plugins list and free. */
|
/* Remove from io_plugins list and free. */
|
||||||
TAILQ_REMOVE(&io_plugins, plugin, entries);
|
TAILQ_REMOVE(&io_plugins, plugin, entries);
|
||||||
sudo_efree(plugin);
|
free(plugin);
|
||||||
|
|
||||||
debug_return;
|
debug_return;
|
||||||
}
|
}
|
||||||
|
@@ -33,7 +33,6 @@
|
|||||||
#include "sudo_gettext.h" /* must be included before sudo_compat.h */
|
#include "sudo_gettext.h" /* must be included before sudo_compat.h */
|
||||||
|
|
||||||
#include "sudo_compat.h"
|
#include "sudo_compat.h"
|
||||||
#include "sudo_alloc.h"
|
|
||||||
#include "sudo_fatal.h"
|
#include "sudo_fatal.h"
|
||||||
#include "sudo_conf.h"
|
#include "sudo_conf.h"
|
||||||
#include "sudo_debug.h"
|
#include "sudo_debug.h"
|
||||||
|
@@ -144,7 +144,7 @@ static int
|
|||||||
sudo_edit_mktemp(const char *ofile, char **tfile)
|
sudo_edit_mktemp(const char *ofile, char **tfile)
|
||||||
{
|
{
|
||||||
const char *cp, *suff;
|
const char *cp, *suff;
|
||||||
int tfd;
|
int len, tfd;
|
||||||
debug_decl(sudo_edit_mktemp, SUDO_DEBUG_EDIT)
|
debug_decl(sudo_edit_mktemp, SUDO_DEBUG_EDIT)
|
||||||
|
|
||||||
if ((cp = strrchr(ofile, '/')) != NULL)
|
if ((cp = strrchr(ofile, '/')) != NULL)
|
||||||
@@ -153,11 +153,13 @@ sudo_edit_mktemp(const char *ofile, char **tfile)
|
|||||||
cp = ofile;
|
cp = ofile;
|
||||||
suff = strrchr(cp, '.');
|
suff = strrchr(cp, '.');
|
||||||
if (suff != NULL) {
|
if (suff != NULL) {
|
||||||
sudo_easprintf(tfile, "%s/%.*sXXXXXXXX%s", edit_tmpdir,
|
len = asprintf(tfile, "%s/%.*sXXXXXXXX%s", edit_tmpdir,
|
||||||
(int)(size_t)(suff - cp), cp, suff);
|
(int)(size_t)(suff - cp), cp, suff);
|
||||||
} else {
|
} else {
|
||||||
sudo_easprintf(tfile, "%s/%s.XXXXXXXX", edit_tmpdir, cp);
|
len = asprintf(tfile, "%s/%s.XXXXXXXX", edit_tmpdir, cp);
|
||||||
}
|
}
|
||||||
|
if (len == -1)
|
||||||
|
sudo_fatalx(U_("unable to allocate memory"));
|
||||||
tfd = mkstemps(*tfile, suff ? strlen(suff) : 0);
|
tfd = mkstemps(*tfile, suff ? strlen(suff) : 0);
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,
|
sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,
|
||||||
"%s -> %s, fd %d", ofile, *tfile, tfd);
|
"%s -> %s, fd %d", ofile, *tfile, tfd);
|
||||||
@@ -376,7 +378,11 @@ selinux_edit_create_tfiles(struct command_details *command_details,
|
|||||||
command_details->flags |= CD_SUDOEDIT_COPY;
|
command_details->flags |= CD_SUDOEDIT_COPY;
|
||||||
|
|
||||||
sesh_nargs = 3 + (nfiles * 2) + 1;
|
sesh_nargs = 3 + (nfiles * 2) + 1;
|
||||||
sesh_args = sesh_ap = sudo_emallocarray(sesh_nargs, sizeof(char *));
|
sesh_args = sesh_ap = reallocarray(NULL, sesh_nargs, sizeof(char *));
|
||||||
|
if (sesh_args == NULL) {
|
||||||
|
sudo_warnx(U_("unable to allocate memory"));
|
||||||
|
debug_return_int(-1);
|
||||||
|
}
|
||||||
*sesh_ap++ = "sesh";
|
*sesh_ap++ = "sesh";
|
||||||
*sesh_ap++ = "-e";
|
*sesh_ap++ = "-e";
|
||||||
*sesh_ap++ = "0";
|
*sesh_ap++ = "0";
|
||||||
@@ -397,8 +403,8 @@ selinux_edit_create_tfiles(struct command_details *command_details,
|
|||||||
tfd = sudo_edit_mktemp(ofile, &tfile);
|
tfd = sudo_edit_mktemp(ofile, &tfile);
|
||||||
if (tfd == -1) {
|
if (tfd == -1) {
|
||||||
sudo_warn("mkstemps");
|
sudo_warn("mkstemps");
|
||||||
sudo_efree(tfile);
|
free(tfile);
|
||||||
sudo_efree(sesh_args);
|
free(sesh_args);
|
||||||
debug_return_int(-1);
|
debug_return_int(-1);
|
||||||
}
|
}
|
||||||
/* Helper will re-create temp file with proper security context. */
|
/* Helper will re-create temp file with proper security context. */
|
||||||
@@ -437,7 +443,7 @@ selinux_edit_create_tfiles(struct command_details *command_details,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Contents of tf will be freed by caller. */
|
/* Contents of tf will be freed by caller. */
|
||||||
sudo_efree(sesh_args);
|
free(sesh_args);
|
||||||
|
|
||||||
return (nfiles);
|
return (nfiles);
|
||||||
}
|
}
|
||||||
@@ -467,7 +473,11 @@ selinux_edit_copy_tfiles(struct command_details *command_details,
|
|||||||
command_details->flags |= CD_SUDOEDIT_COPY;
|
command_details->flags |= CD_SUDOEDIT_COPY;
|
||||||
|
|
||||||
sesh_nargs = 3 + (nfiles * 2) + 1;
|
sesh_nargs = 3 + (nfiles * 2) + 1;
|
||||||
sesh_args = sesh_ap = sudo_emallocarray(sesh_nargs, sizeof(char *));
|
sesh_args = sesh_ap = reallocarray(NULL, sesh_nargs, sizeof(char *));
|
||||||
|
if (sesh_args == NULL) {
|
||||||
|
sudo_warnx(U_("unable to allocate memory"));
|
||||||
|
debug_return_int(-1);
|
||||||
|
}
|
||||||
*sesh_ap++ = "sesh";
|
*sesh_ap++ = "sesh";
|
||||||
*sesh_ap++ = "-e";
|
*sesh_ap++ = "-e";
|
||||||
*sesh_ap++ = "1";
|
*sesh_ap++ = "1";
|
||||||
@@ -575,7 +585,11 @@ sudo_edit(struct command_details *command_details)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Copy editor files to temporaries. */
|
/* Copy editor files to temporaries. */
|
||||||
tf = sudo_ecalloc(nfiles, sizeof(*tf));
|
tf = calloc(nfiles, sizeof(*tf));
|
||||||
|
if (tf == NULL) {
|
||||||
|
sudo_warnx(U_("unable to allocate memory"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
#ifdef HAVE_SELINUX
|
#ifdef HAVE_SELINUX
|
||||||
if (ISSET(command_details->flags, CD_RBAC_ENABLED))
|
if (ISSET(command_details->flags, CD_RBAC_ENABLED))
|
||||||
nfiles = selinux_edit_create_tfiles(command_details, tf, files, nfiles);
|
nfiles = selinux_edit_create_tfiles(command_details, tf, files, nfiles);
|
||||||
@@ -591,7 +605,11 @@ sudo_edit(struct command_details *command_details)
|
|||||||
* to create a new argv.
|
* to create a new argv.
|
||||||
*/
|
*/
|
||||||
nargc = editor_argc + nfiles;
|
nargc = editor_argc + nfiles;
|
||||||
nargv = sudo_emallocarray(nargc + 1, sizeof(char *));
|
nargv = reallocarray(NULL, nargc + 1, sizeof(char *));
|
||||||
|
if (nargv == NULL) {
|
||||||
|
sudo_warnx(U_("unable to allocate memory"));
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
for (ac = 0; ac < editor_argc; ac++)
|
for (ac = 0; ac < editor_argc; ac++)
|
||||||
nargv[ac] = command_details->argv[ac];
|
nargv[ac] = command_details->argv[ac];
|
||||||
for (i = 0; i < nfiles && ac < nargc; )
|
for (i = 0; i < nfiles && ac < nargc; )
|
||||||
@@ -637,8 +655,8 @@ sudo_edit(struct command_details *command_details)
|
|||||||
#endif
|
#endif
|
||||||
errors = sudo_edit_copy_tfiles(command_details, tf, nfiles, times);
|
errors = sudo_edit_copy_tfiles(command_details, tf, nfiles, times);
|
||||||
|
|
||||||
sudo_efree(tf);
|
free(tf);
|
||||||
sudo_efree(nargv);
|
free(nargv);
|
||||||
debug_return_int(errors ? 1 : rval);
|
debug_return_int(errors ? 1 : rval);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
@@ -649,8 +667,8 @@ cleanup:
|
|||||||
unlink(tf[i].tfile);
|
unlink(tf[i].tfile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sudo_efree(tf);
|
free(tf);
|
||||||
sudo_efree(nargv);
|
free(nargv);
|
||||||
debug_return_int(1);
|
debug_return_int(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -132,13 +132,17 @@ sudo_ttyname_dev(dev_t tdev)
|
|||||||
if (*dev != '/') {
|
if (*dev != '/') {
|
||||||
/* devname() doesn't use the /dev/ prefix, add one... */
|
/* devname() doesn't use the /dev/ prefix, add one... */
|
||||||
size_t len = sizeof(_PATH_DEV) + strlen(dev);
|
size_t len = sizeof(_PATH_DEV) + strlen(dev);
|
||||||
tty = sudo_emalloc(len);
|
if ((tty = malloc(len)) != NULL) {
|
||||||
strlcpy(tty, _PATH_DEV, len);
|
strlcpy(tty, _PATH_DEV, len);
|
||||||
strlcat(tty, dev, len);
|
strlcat(tty, dev, len);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
/* Should not happen but just in case... */
|
/* Should not happen but just in case... */
|
||||||
tty = sudo_estrdup(dev);
|
tty = strdup(dev);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
/* Not all versions of devname() set errno. */
|
||||||
|
errno = ENOENT;
|
||||||
}
|
}
|
||||||
debug_return_str(tty);
|
debug_return_str(tty);
|
||||||
}
|
}
|
||||||
@@ -158,7 +162,7 @@ sudo_ttyname_dev(dev_t tdev)
|
|||||||
|
|
||||||
tty = _ttyname_dev(tdev, buf, sizeof(buf));
|
tty = _ttyname_dev(tdev, buf, sizeof(buf));
|
||||||
|
|
||||||
debug_return_str(sudo_estrdup(tty));
|
debug_return_str(tty ? strdup(tty) : NULL);
|
||||||
}
|
}
|
||||||
#elif defined(HAVE_STRUCT_PSINFO_PR_TTYDEV) || defined(HAVE_PSTAT_GETPROC) || defined(__linux__)
|
#elif defined(HAVE_STRUCT_PSINFO_PR_TTYDEV) || defined(HAVE_PSTAT_GETPROC) || defined(__linux__)
|
||||||
/*
|
/*
|
||||||
@@ -262,15 +266,24 @@ sudo_ttyname_scan(const char *dir, dev_t rdev, bool builtin)
|
|||||||
if (!builtin) {
|
if (!builtin) {
|
||||||
/* Add to list of subdirs to search. */
|
/* Add to list of subdirs to search. */
|
||||||
if (num_subdirs + 1 > max_subdirs) {
|
if (num_subdirs + 1 > max_subdirs) {
|
||||||
|
char **new_subdirs;
|
||||||
|
|
||||||
|
new_subdirs = reallocarray(subdirs, max_subdirs + 64,
|
||||||
|
sizeof(char *));
|
||||||
|
if (new_subdirs == NULL)
|
||||||
|
goto done;
|
||||||
|
subdirs = new_subdirs;
|
||||||
max_subdirs += 64;
|
max_subdirs += 64;
|
||||||
subdirs = sudo_ereallocarray(subdirs, max_subdirs, sizeof(char *));
|
|
||||||
}
|
}
|
||||||
subdirs[num_subdirs++] = sudo_estrdup(pathbuf);
|
subdirs[num_subdirs] = strdup(pathbuf);
|
||||||
|
if (subdirs[num_subdirs] == NULL)
|
||||||
|
goto done;
|
||||||
|
num_subdirs++;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (S_ISCHR(sb.st_mode) && sb.st_rdev == rdev) {
|
if (S_ISCHR(sb.st_mode) && sb.st_rdev == rdev) {
|
||||||
devname = sudo_estrdup(pathbuf);
|
devname = strdup(pathbuf);
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO, "resolved dev %u as %s",
|
sudo_debug_printf(SUDO_DEBUG_INFO, "resolved dev %u as %s",
|
||||||
(unsigned int)rdev, pathbuf);
|
(unsigned int)rdev, pathbuf);
|
||||||
goto done;
|
goto done;
|
||||||
@@ -285,8 +298,8 @@ done:
|
|||||||
if (d != NULL)
|
if (d != NULL)
|
||||||
closedir(d);
|
closedir(d);
|
||||||
for (i = 0; i < num_subdirs; i++)
|
for (i = 0; i < num_subdirs; i++)
|
||||||
sudo_efree(subdirs[i]);
|
free(subdirs[i]);
|
||||||
sudo_efree(subdirs);
|
free(subdirs);
|
||||||
debug_return_str(devname);
|
debug_return_str(devname);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -306,7 +319,7 @@ sudo_ttyname_dev(dev_t rdev)
|
|||||||
/*
|
/*
|
||||||
* First check search_devs for common tty devices.
|
* First check search_devs for common tty devices.
|
||||||
*/
|
*/
|
||||||
for (sd = search_devs; tty == NULL && (devname = *sd) != NULL; sd++) {
|
for (sd = search_devs; (devname = *sd) != NULL; sd++) {
|
||||||
len = strlen(devname);
|
len = strlen(devname);
|
||||||
if (devname[len - 1] == '/') {
|
if (devname[len - 1] == '/') {
|
||||||
if (strcmp(devname, "/dev/pts/") == 0) {
|
if (strcmp(devname, "/dev/pts/") == 0) {
|
||||||
@@ -314,19 +327,25 @@ sudo_ttyname_dev(dev_t rdev)
|
|||||||
(void)snprintf(buf, sizeof(buf), "%spts/%u", _PATH_DEV,
|
(void)snprintf(buf, sizeof(buf), "%spts/%u", _PATH_DEV,
|
||||||
(unsigned int)minor(rdev));
|
(unsigned int)minor(rdev));
|
||||||
if (stat(buf, &sb) == 0) {
|
if (stat(buf, &sb) == 0) {
|
||||||
if (S_ISCHR(sb.st_mode) && sb.st_rdev == rdev)
|
if (S_ISCHR(sb.st_mode) && sb.st_rdev == rdev) {
|
||||||
tty = sudo_estrdup(buf);
|
tty = strdup(buf);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
sudo_debug_printf(SUDO_DEBUG_INFO, "comparing dev %u to %s: %s",
|
sudo_debug_printf(SUDO_DEBUG_INFO, "comparing dev %u to %s: %s",
|
||||||
(unsigned int)rdev, buf, tty ? "yes" : "no");
|
(unsigned int)rdev, buf, tty ? "yes" : "no");
|
||||||
} else {
|
} else {
|
||||||
/* Traverse directory */
|
/* Traverse directory */
|
||||||
tty = sudo_ttyname_scan(devname, rdev, true);
|
tty = sudo_ttyname_scan(devname, rdev, true);
|
||||||
|
if (tty != NULL || errno == ENOMEM)
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (stat(devname, &sb) == 0) {
|
if (stat(devname, &sb) == 0) {
|
||||||
if (S_ISCHR(sb.st_mode) && sb.st_rdev == rdev)
|
if (S_ISCHR(sb.st_mode) && sb.st_rdev == rdev) {
|
||||||
tty = sudo_estrdup(devname);
|
tty = strdup(devname);
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -334,9 +353,9 @@ sudo_ttyname_dev(dev_t rdev)
|
|||||||
/*
|
/*
|
||||||
* Not found? Do a breadth-first traversal of /dev/.
|
* Not found? Do a breadth-first traversal of /dev/.
|
||||||
*/
|
*/
|
||||||
if (tty == NULL)
|
tty = sudo_ttyname_scan(_PATH_DEV, rdev, false);
|
||||||
tty = sudo_ttyname_scan(_PATH_DEV, rdev, false);
|
|
||||||
|
|
||||||
|
done:
|
||||||
debug_return_str(tty);
|
debug_return_str(tty);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -366,8 +385,14 @@ get_process_ttyname(void)
|
|||||||
mib[4] = sizeof(*ki_proc);
|
mib[4] = sizeof(*ki_proc);
|
||||||
mib[5] = 1;
|
mib[5] = 1;
|
||||||
do {
|
do {
|
||||||
|
struct sudo_kinfo_proc *kp;
|
||||||
|
|
||||||
size += size / 10;
|
size += size / 10;
|
||||||
ki_proc = sudo_erealloc(ki_proc, size);
|
if ((kp = realloc(ki_proc, size)) == NULL) {
|
||||||
|
rc = -1;
|
||||||
|
break; /* really out of memory. */
|
||||||
|
}
|
||||||
|
ki_proc = kp;
|
||||||
rc = sysctl(mib, sudo_kp_namelen, ki_proc, &size, NULL, 0);
|
rc = sysctl(mib, sudo_kp_namelen, ki_proc, &size, NULL, 0);
|
||||||
} while (rc == -1 && errno == ENOMEM);
|
} while (rc == -1 && errno == ENOMEM);
|
||||||
if (rc != -1) {
|
if (rc != -1) {
|
||||||
@@ -383,7 +408,7 @@ get_process_ttyname(void)
|
|||||||
sudo_debug_printf(SUDO_DEBUG_WARN,
|
sudo_debug_printf(SUDO_DEBUG_WARN,
|
||||||
"unable to resolve tty via KERN_PROC: %s", strerror(errno));
|
"unable to resolve tty via KERN_PROC: %s", strerror(errno));
|
||||||
}
|
}
|
||||||
sudo_efree(ki_proc);
|
free(ki_proc);
|
||||||
|
|
||||||
debug_return_str(tty);
|
debug_return_str(tty);
|
||||||
}
|
}
|
||||||
@@ -417,6 +442,10 @@ get_process_ttyname(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tty == NULL)
|
||||||
|
sudo_debug_printf(SUDO_DEBUG_WARN,
|
||||||
|
"unable to resolve tty via %s: %s", path, strerror(errno));
|
||||||
|
|
||||||
debug_return_str(tty);
|
debug_return_str(tty);
|
||||||
}
|
}
|
||||||
#elif defined(__linux__)
|
#elif defined(__linux__)
|
||||||
@@ -461,9 +490,13 @@ get_process_ttyname(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sudo_efree(line);
|
free(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (tty == NULL)
|
||||||
|
sudo_debug_printf(SUDO_DEBUG_WARN,
|
||||||
|
"unable to resolve tty via %s: %s", path, strerror(errno));
|
||||||
|
|
||||||
debug_return_str(tty);
|
debug_return_str(tty);
|
||||||
}
|
}
|
||||||
#elif defined(HAVE_PSTAT_GETPROC)
|
#elif defined(HAVE_PSTAT_GETPROC)
|
||||||
@@ -490,6 +523,10 @@ get_process_ttyname(void)
|
|||||||
pstat.pst_term.psd_minor));
|
pstat.pst_term.psd_minor));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (tty == NULL)
|
||||||
|
sudo_debug_printf(SUDO_DEBUG_WARN,
|
||||||
|
"unable to resolve tty via pstat: %s", strerror(errno));
|
||||||
|
|
||||||
debug_return_str(tty);
|
debug_return_str(tty);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -507,7 +544,12 @@ get_process_ttyname(void)
|
|||||||
if ((tty = ttyname(STDOUT_FILENO)) == NULL)
|
if ((tty = ttyname(STDOUT_FILENO)) == NULL)
|
||||||
tty = ttyname(STDERR_FILENO);
|
tty = ttyname(STDERR_FILENO);
|
||||||
}
|
}
|
||||||
|
if (tty == NULL) {
|
||||||
|
sudo_debug_printf(SUDO_DEBUG_WARN,
|
||||||
|
"unable to resolve tty via ttyname: %s", strerror(errno));
|
||||||
|
debug_return_str(NULL);
|
||||||
|
}
|
||||||
|
|
||||||
debug_return_str(sudo_estrdup(tty));
|
debug_return_str(strdup(tty));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user