$(LIBTOOL) --mode=compile $(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/match_addr.c
match_addr.o: match_addr.lo
net_ifs.o: $(top_srcdir)/src/net_ifs.c $(incdir)/compat/stdbool.h \
- $(incdir)/sudo_alloc.h $(incdir)/sudo_compat.h \
- $(incdir)/sudo_conf.h $(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
+ $(incdir)/sudo_compat.h $(incdir)/sudo_conf.h \
+ $(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
$(incdir)/sudo_gettext.h $(incdir)/sudo_queue.h \
$(top_builddir)/config.h
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(top_srcdir)/src/net_ifs.c
# Autogenerated dependencies, do not modify
check_ttyname.o: $(srcdir)/regress/ttyname/check_ttyname.c \
- $(incdir)/compat/stdbool.h $(incdir)/sudo_alloc.h \
- $(incdir)/sudo_compat.h $(incdir)/sudo_debug.h \
- $(incdir)/sudo_fatal.h $(incdir)/sudo_queue.h \
- $(incdir)/sudo_util.h $(top_builddir)/config.h
+ $(incdir)/compat/stdbool.h $(incdir)/sudo_compat.h \
+ $(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
+ $(incdir)/sudo_queue.h $(incdir)/sudo_util.h \
+ $(top_builddir)/config.h
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/regress/ttyname/check_ttyname.c
conversation.o: $(srcdir)/conversation.c $(incdir)/compat/stdbool.h \
- $(incdir)/sudo_alloc.h $(incdir)/sudo_compat.h \
- $(incdir)/sudo_conf.h $(incdir)/sudo_debug.h \
- $(incdir)/sudo_fatal.h $(incdir)/sudo_gettext.h \
- $(incdir)/sudo_plugin.h $(incdir)/sudo_queue.h \
- $(incdir)/sudo_util.h $(srcdir)/sudo.h \
+ $(incdir)/sudo_compat.h $(incdir)/sudo_conf.h \
+ $(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
+ $(incdir)/sudo_gettext.h $(incdir)/sudo_plugin.h \
+ $(incdir)/sudo_queue.h $(incdir)/sudo_util.h $(srcdir)/sudo.h \
$(srcdir)/sudo_plugin_int.h $(top_builddir)/config.h \
$(top_builddir)/pathnames.h
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/conversation.c
env_hooks.o: $(srcdir)/env_hooks.c $(incdir)/compat/stdbool.h \
- $(incdir)/sudo_alloc.h $(incdir)/sudo_compat.h \
- $(incdir)/sudo_conf.h $(incdir)/sudo_debug.h $(incdir)/sudo_dso.h \
+ $(incdir)/sudo_compat.h $(incdir)/sudo_conf.h \
+ $(incdir)/sudo_debug.h $(incdir)/sudo_dso.h \
$(incdir)/sudo_fatal.h $(incdir)/sudo_gettext.h \
$(incdir)/sudo_plugin.h $(incdir)/sudo_queue.h \
$(incdir)/sudo_util.h $(srcdir)/sudo.h $(top_builddir)/config.h \
$(top_builddir)/pathnames.h
$(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 \
- $(incdir)/sudo_compat.h $(incdir)/sudo_conf.h $(incdir)/sudo_debug.h \
- $(incdir)/sudo_event.h $(incdir)/sudo_fatal.h $(incdir)/sudo_gettext.h \
+exec.o: $(srcdir)/exec.c $(incdir)/compat/stdbool.h $(incdir)/sudo_compat.h \
+ $(incdir)/sudo_conf.h $(incdir)/sudo_debug.h $(incdir)/sudo_event.h \
+ $(incdir)/sudo_fatal.h $(incdir)/sudo_gettext.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 \
$(top_builddir)/config.h $(top_builddir)/pathnames.h
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/exec.c
exec_common.o: $(srcdir)/exec_common.c $(incdir)/compat/stdbool.h \
- $(incdir)/sudo_alloc.h $(incdir)/sudo_compat.h \
- $(incdir)/sudo_conf.h $(incdir)/sudo_debug.h \
- $(incdir)/sudo_fatal.h $(incdir)/sudo_gettext.h \
- $(incdir)/sudo_queue.h $(incdir)/sudo_util.h $(srcdir)/sudo.h \
- $(srcdir)/sudo_exec.h $(top_builddir)/config.h \
- $(top_builddir)/pathnames.h
+ $(incdir)/sudo_compat.h $(incdir)/sudo_conf.h \
+ $(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
+ $(incdir)/sudo_gettext.h $(incdir)/sudo_queue.h \
+ $(incdir)/sudo_util.h $(srcdir)/sudo.h $(srcdir)/sudo_exec.h \
+ $(top_builddir)/config.h $(top_builddir)/pathnames.h
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/exec_common.c
exec_pty.o: $(srcdir)/exec_pty.c $(incdir)/compat/stdbool.h \
- $(incdir)/sudo_alloc.h $(incdir)/sudo_compat.h \
- $(incdir)/sudo_conf.h $(incdir)/sudo_debug.h \
- $(incdir)/sudo_event.h $(incdir)/sudo_fatal.h \
- $(incdir)/sudo_gettext.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 \
- $(top_builddir)/config.h $(top_builddir)/pathnames.h
+ $(incdir)/sudo_compat.h $(incdir)/sudo_conf.h \
+ $(incdir)/sudo_debug.h $(incdir)/sudo_event.h \
+ $(incdir)/sudo_fatal.h $(incdir)/sudo_gettext.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 $(top_builddir)/config.h \
+ $(top_builddir)/pathnames.h
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/exec_pty.c
get_pty.o: $(srcdir)/get_pty.c $(incdir)/compat/stdbool.h \
- $(incdir)/sudo_alloc.h $(incdir)/sudo_compat.h \
- $(incdir)/sudo_conf.h $(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
+ $(incdir)/sudo_compat.h $(incdir)/sudo_conf.h \
+ $(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
$(incdir)/sudo_gettext.h $(incdir)/sudo_queue.h \
$(incdir)/sudo_util.h $(srcdir)/sudo.h $(top_builddir)/config.h \
$(top_builddir)/pathnames.h
$(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 \
- $(incdir)/sudo_compat.h $(incdir)/sudo_conf.h $(incdir)/sudo_debug.h \
- $(incdir)/sudo_fatal.h $(incdir)/sudo_gettext.h \
- $(incdir)/sudo_plugin.h $(incdir)/sudo_queue.h $(incdir)/sudo_util.h \
- $(srcdir)/sudo.h $(srcdir)/sudo_plugin_int.h $(top_builddir)/config.h \
+hooks.o: $(srcdir)/hooks.c $(incdir)/compat/stdbool.h $(incdir)/sudo_compat.h \
+ $(incdir)/sudo_conf.h $(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
+ $(incdir)/sudo_gettext.h $(incdir)/sudo_plugin.h \
+ $(incdir)/sudo_queue.h $(incdir)/sudo_util.h $(srcdir)/sudo.h \
+ $(srcdir)/sudo_plugin_int.h $(top_builddir)/config.h \
$(top_builddir)/pathnames.h
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/hooks.c
load_plugins.o: $(srcdir)/load_plugins.c $(incdir)/compat/stdbool.h \
- $(incdir)/sudo_alloc.h $(incdir)/sudo_compat.h \
- $(incdir)/sudo_conf.h $(incdir)/sudo_debug.h \
- $(incdir)/sudo_dso.h $(incdir)/sudo_fatal.h \
- $(incdir)/sudo_gettext.h $(incdir)/sudo_plugin.h \
- $(incdir)/sudo_queue.h $(incdir)/sudo_util.h $(srcdir)/sudo.h \
+ $(incdir)/sudo_compat.h $(incdir)/sudo_conf.h \
+ $(incdir)/sudo_debug.h $(incdir)/sudo_dso.h \
+ $(incdir)/sudo_fatal.h $(incdir)/sudo_gettext.h \
+ $(incdir)/sudo_plugin.h $(incdir)/sudo_queue.h \
+ $(incdir)/sudo_util.h $(srcdir)/sudo.h \
$(srcdir)/sudo_plugin_int.h $(top_builddir)/config.h \
$(top_builddir)/pathnames.h
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/load_plugins.c
net_ifs.o: $(srcdir)/net_ifs.c $(incdir)/compat/stdbool.h \
- $(incdir)/sudo_alloc.h $(incdir)/sudo_compat.h \
- $(incdir)/sudo_conf.h $(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
+ $(incdir)/sudo_compat.h $(incdir)/sudo_conf.h \
+ $(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
$(incdir)/sudo_gettext.h $(incdir)/sudo_queue.h \
$(top_builddir)/config.h
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/net_ifs.c
openbsd.o: $(srcdir)/openbsd.c $(incdir)/compat/stdbool.h \
- $(incdir)/sudo_alloc.h $(incdir)/sudo_compat.h \
- $(incdir)/sudo_conf.h $(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
+ $(incdir)/sudo_compat.h $(incdir)/sudo_conf.h \
+ $(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
$(incdir)/sudo_gettext.h $(incdir)/sudo_queue.h \
$(incdir)/sudo_util.h $(srcdir)/sudo.h $(top_builddir)/config.h \
$(top_builddir)/pathnames.h
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/openbsd.c
parse_args.o: $(srcdir)/parse_args.c $(incdir)/compat/getopt.h \
- $(incdir)/compat/stdbool.h $(incdir)/sudo_alloc.h \
- $(incdir)/sudo_compat.h $(incdir)/sudo_conf.h \
- $(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
- $(incdir)/sudo_gettext.h $(incdir)/sudo_lbuf.h \
- $(incdir)/sudo_queue.h $(incdir)/sudo_util.h $(srcdir)/sudo.h \
- $(top_builddir)/config.h $(top_builddir)/pathnames.h \
- ./sudo_usage.h
+ $(incdir)/compat/stdbool.h $(incdir)/sudo_compat.h \
+ $(incdir)/sudo_conf.h $(incdir)/sudo_debug.h \
+ $(incdir)/sudo_fatal.h $(incdir)/sudo_gettext.h \
+ $(incdir)/sudo_lbuf.h $(incdir)/sudo_queue.h \
+ $(incdir)/sudo_util.h $(srcdir)/sudo.h $(top_builddir)/config.h \
+ $(top_builddir)/pathnames.h ./sudo_usage.h
$(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 \
$(incdir)/sudo_plugin.h $(top_builddir)/config.h
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/preload.c
preserve_fds.o: $(srcdir)/preserve_fds.c $(incdir)/compat/stdbool.h \
- $(incdir)/sudo_alloc.h $(incdir)/sudo_compat.h \
- $(incdir)/sudo_conf.h $(incdir)/sudo_debug.h \
- $(incdir)/sudo_fatal.h $(incdir)/sudo_gettext.h \
- $(incdir)/sudo_queue.h $(incdir)/sudo_util.h $(srcdir)/sudo.h \
+ $(incdir)/sudo_compat.h $(incdir)/sudo_conf.h \
+ $(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
+ $(incdir)/sudo_gettext.h $(incdir)/sudo_queue.h \
+ $(incdir)/sudo_util.h $(srcdir)/sudo.h \
$(top_builddir)/config.h $(top_builddir)/pathnames.h
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/preserve_fds.c
selinux.o: $(srcdir)/selinux.c $(incdir)/compat/stdbool.h \
- $(incdir)/sudo_alloc.h $(incdir)/sudo_compat.h \
- $(incdir)/sudo_conf.h $(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
+ $(incdir)/sudo_compat.h $(incdir)/sudo_conf.h \
+ $(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
$(incdir)/sudo_gettext.h $(incdir)/sudo_queue.h \
$(incdir)/sudo_util.h $(srcdir)/sudo.h $(srcdir)/sudo_exec.h \
$(top_builddir)/config.h $(top_builddir)/pathnames.h
$(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 \
- $(incdir)/sudo_compat.h $(incdir)/sudo_conf.h $(incdir)/sudo_debug.h \
- $(incdir)/sudo_fatal.h $(incdir)/sudo_gettext.h \
- $(incdir)/sudo_plugin.h $(incdir)/sudo_queue.h $(incdir)/sudo_util.h \
- $(srcdir)/sudo_exec.h $(top_builddir)/config.h
+sesh.o: $(srcdir)/sesh.c $(incdir)/compat/stdbool.h $(incdir)/sudo_compat.h \
+ $(incdir)/sudo_conf.h $(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
+ $(incdir)/sudo_gettext.h $(incdir)/sudo_plugin.h \
+ $(incdir)/sudo_queue.h $(incdir)/sudo_util.h $(srcdir)/sudo_exec.h \
+ $(top_builddir)/config.h
$(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_fatal.h $(incdir)/sudo_gettext.h \
$(incdir)/sudo_queue.h $(incdir)/sudo_util.h $(srcdir)/sudo.h \
$(top_builddir)/config.h $(top_builddir)/pathnames.h
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/signal.c
solaris.o: $(srcdir)/solaris.c $(incdir)/compat/stdbool.h \
- $(incdir)/sudo_alloc.h $(incdir)/sudo_compat.h \
- $(incdir)/sudo_conf.h $(incdir)/sudo_debug.h $(incdir)/sudo_dso.h \
- $(incdir)/sudo_fatal.h $(incdir)/sudo_gettext.h \
- $(incdir)/sudo_queue.h $(incdir)/sudo_util.h $(srcdir)/sudo.h \
- $(top_builddir)/config.h $(top_builddir)/pathnames.h
+ $(incdir)/sudo_compat.h $(incdir)/sudo_conf.h \
+ $(incdir)/sudo_debug.h $(incdir)/sudo_dso.h $(incdir)/sudo_fatal.h \
+ $(incdir)/sudo_gettext.h $(incdir)/sudo_queue.h \
+ $(incdir)/sudo_util.h $(srcdir)/sudo.h $(top_builddir)/config.h \
+ $(top_builddir)/pathnames.h
$(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 \
- $(incdir)/sudo_compat.h $(incdir)/sudo_conf.h $(incdir)/sudo_debug.h \
- $(incdir)/sudo_fatal.h $(incdir)/sudo_gettext.h \
- $(incdir)/sudo_plugin.h $(incdir)/sudo_queue.h $(incdir)/sudo_util.h \
- $(srcdir)/sudo.h $(srcdir)/sudo_plugin_int.h $(top_builddir)/config.h \
+sudo.o: $(srcdir)/sudo.c $(incdir)/compat/stdbool.h $(incdir)/sudo_compat.h \
+ $(incdir)/sudo_conf.h $(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
+ $(incdir)/sudo_gettext.h $(incdir)/sudo_plugin.h \
+ $(incdir)/sudo_queue.h $(incdir)/sudo_util.h $(srcdir)/sudo.h \
+ $(srcdir)/sudo_plugin_int.h $(top_builddir)/config.h \
$(top_builddir)/pathnames.h ./sudo_usage.h
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/sudo.c
sudo_edit.o: $(srcdir)/sudo_edit.c $(incdir)/compat/stdbool.h \
- $(incdir)/compat/timespec.h $(incdir)/sudo_alloc.h \
- $(incdir)/sudo_compat.h $(incdir)/sudo_conf.h \
- $(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
- $(incdir)/sudo_gettext.h $(incdir)/sudo_queue.h \
- $(incdir)/sudo_util.h $(srcdir)/sudo.h $(srcdir)/sudo_exec.h \
- $(top_builddir)/config.h $(top_builddir)/pathnames.h
+ $(incdir)/compat/timespec.h $(incdir)/sudo_compat.h \
+ $(incdir)/sudo_conf.h $(incdir)/sudo_debug.h \
+ $(incdir)/sudo_fatal.h $(incdir)/sudo_gettext.h \
+ $(incdir)/sudo_queue.h $(incdir)/sudo_util.h $(srcdir)/sudo.h \
+ $(srcdir)/sudo_exec.h $(top_builddir)/config.h \
+ $(top_builddir)/pathnames.h
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/sudo_edit.c
sudo_noexec.lo: $(srcdir)/sudo_noexec.c $(incdir)/sudo_compat.h \
$(top_builddir)/config.h
$(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 \
- $(incdir)/sudo_alloc.h $(incdir)/sudo_compat.h \
- $(incdir)/sudo_conf.h $(incdir)/sudo_debug.h \
- $(incdir)/sudo_fatal.h $(incdir)/sudo_gettext.h \
- $(incdir)/sudo_plugin.h $(incdir)/sudo_queue.h \
- $(incdir)/sudo_util.h $(srcdir)/sudo.h $(top_builddir)/config.h \
- $(top_builddir)/pathnames.h
+ $(incdir)/sudo_compat.h $(incdir)/sudo_conf.h \
+ $(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
+ $(incdir)/sudo_gettext.h $(incdir)/sudo_plugin.h \
+ $(incdir)/sudo_queue.h $(incdir)/sudo_util.h $(srcdir)/sudo.h \
+ $(top_builddir)/config.h $(top_builddir)/pathnames.h
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/tgetpass.c
ttyname.o: $(srcdir)/ttyname.c $(incdir)/compat/stdbool.h \
- $(incdir)/sudo_alloc.h $(incdir)/sudo_compat.h \
- $(incdir)/sudo_conf.h $(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
+ $(incdir)/sudo_compat.h $(incdir)/sudo_conf.h \
+ $(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
$(incdir)/sudo_gettext.h $(incdir)/sudo_queue.h \
$(incdir)/sudo_util.h $(srcdir)/sudo.h $(top_builddir)/config.h \
$(top_builddir)/pathnames.h
$(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 \
- $(incdir)/sudo_compat.h $(incdir)/sudo_conf.h $(incdir)/sudo_debug.h \
- $(incdir)/sudo_fatal.h $(incdir)/sudo_gettext.h $(incdir)/sudo_queue.h \
- $(incdir)/sudo_util.h $(srcdir)/sudo.h $(srcdir)/sudo_exec.h \
- $(top_builddir)/config.h $(top_builddir)/pathnames.h
+utmp.o: $(srcdir)/utmp.c $(incdir)/compat/stdbool.h $(incdir)/sudo_compat.h \
+ $(incdir)/sudo_conf.h $(incdir)/sudo_debug.h $(incdir)/sudo_fatal.h \
+ $(incdir)/sudo_gettext.h $(incdir)/sudo_queue.h $(incdir)/sudo_util.h \
+ $(srcdir)/sudo.h $(srcdir)/sudo_exec.h $(top_builddir)/config.h \
+ $(top_builddir)/pathnames.h
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(DEFS) $(srcdir)/utmp.c
pass = tgetpass(msg->msg, msg->timeout, flags);
if (pass == NULL)
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));
break;
case SUDO_CONV_INFO_MSG:
/* Append at the end if not already found. */
if (!found) {
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)
memcpy(envp, environ, env_len * sizeof(char *));
envp[env_len++] = (char *)string;
free(envstr);
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);
sudo_ev_free(signal_event);
sudo_ev_free(backchannel_event);
TAILQ_FOREACH_SAFE(sigfwd, &sigfwd_list, entries, sigfwd_next) {
- sudo_efree(sigfwd);
+ free(sigfwd);
}
TAILQ_INIT(&sigfwd_list);
done:
nsent = send(sock, &cstat, sizeof(cstat), 0);
} while (nsent == -1 && errno == EINTR);
TAILQ_REMOVE(&sigfwd_list, sigfwd, entries);
- sudo_efree(sigfwd);
+ free(sigfwd);
if (nsent != sizeof(cstat)) {
if (errno == EPIPE) {
struct sigforward *sigfwd_next;
"broken pipe writing to child over backchannel");
/* Other end of socket gone, empty out sigfwd_list. */
TAILQ_FOREACH_SAFE(sigfwd, &sigfwd_list, entries, sigfwd_next) {
- sudo_efree(sigfwd);
+ free(sigfwd);
}
TAILQ_INIT(&sigfwd_list);
/* XXX - child (monitor) is dead, we should exit too? */
snprintf(signame, sizeof(signame), "%d", signo);
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;
TAILQ_INSERT_TAIL(&sigfwd_list, sigfwd, entries);
if (!enabled)
env_size++;
#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));
nenvp[env_len] = NULL;
preload = sudo_new_key_val(RTLD_PRELOAD_VAR, sudo_conf_noexec_path());
# endif
if (preload == NULL)
- sudo_fatal(NULL);
+ sudo_fatalx(U_("unable to allocate memory"));
nenvp[env_len++] = preload;
nenvp[env_len] = NULL;
} 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;
}
# ifdef RTLD_PRELOAD_ENABLE_VAR
for (argc = 0; argv[argc] != NULL; argc++)
continue;
- nargv = sudo_emallocarray(argc + 2, sizeof(char *));
- nargv[0] = "sh";
- nargv[1] = (char *)path;
- memcpy(nargv + 2, argv + 1, argc * sizeof(char *));
- execve(_PATH_SUDO_BSHELL, nargv, envp);
- sudo_efree(nargv);
+ nargv = reallocarray(NULL, argc + 2, sizeof(char *));
+ if (nargv != NULL) {
+ nargv[0] = "sh";
+ nargv[1] = (char *)path;
+ memcpy(nargv + 2, argv + 1, argc * sizeof(char *));
+ execve(_PATH_SUDO_BSHELL, nargv, envp);
+ free(nargv);
+ }
}
return -1;
}
(void) fcntl(wfd, F_SETFL, n | O_NONBLOCK);
/* 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->wevent = sudo_ev_alloc(wfd, SUDO_EV_WRITE, io_callback, iob);
iob->len = 0;
iob->action = action;
iob->buf[0] = '\0';
if (iob->revent == NULL || iob->wevent == NULL)
- sudo_fatal(NULL);
+ sudo_fatalx(U_("unable to allocate memory"));
SLIST_INSERT_HEAD(head, iob, entries);
debug_return;
/* Free I/O buffers. */
while ((iob = SLIST_FIRST(&iobufs)) != NULL) {
SLIST_REMOVE_HEAD(&iobufs, entries);
- sudo_efree(iob);
+ free(iob);
}
/* Restore terminal settings. */
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif /* HAVE_UNISTD_H */
+#include <errno.h>
#include "sudo.h"
#include "sudo_plugin.h"
}
/* Hook registration internals. */
-static void
+static int
register_hook_internal(struct sudo_hook_list *head,
int (*hook_fn)(), void *closure)
{
struct sudo_hook_entry *hook;
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->closure = closure;
SLIST_INSERT_HEAD(head, hook, entries);
- debug_return;
+ debug_return_int(0);
}
/* Register the specified hook. */
int
register_hook(struct sudo_hook *hook)
{
- int rval = 0;
+ int rval;
debug_decl(register_hook, SUDO_DEBUG_HOOKS)
if (SUDO_HOOK_VERSION_GET_MAJOR(hook->hook_version) != SUDO_HOOK_VERSION_MAJOR) {
/* Major versions must match. */
+ errno = EINVAL;
rval = -1;
} else {
switch (hook->hook_type) {
case SUDO_HOOK_GETENV:
- register_hook_internal(&sudo_hook_getenv_list, hook->hook_fn,
- hook->closure);
+ rval = register_hook_internal(&sudo_hook_getenv_list,
+ hook->hook_fn, hook->closure);
break;
case SUDO_HOOK_PUTENV:
- register_hook_internal(&sudo_hook_putenv_list, hook->hook_fn,
- hook->closure);
+ rval = register_hook_internal(&sudo_hook_putenv_list,
+ hook->hook_fn, hook->closure);
break;
case SUDO_HOOK_SETENV:
- register_hook_internal(&sudo_hook_setenv_list, hook->hook_fn,
- hook->closure);
+ rval = register_hook_internal(&sudo_hook_setenv_list,
+ hook->hook_fn, hook->closure);
break;
case SUDO_HOOK_UNSETENV:
- register_hook_internal(&sudo_hook_unsetenv_list, hook->hook_fn,
- hook->closure);
+ rval = register_hook_internal(&sudo_hook_unsetenv_list,
+ hook->hook_fn, hook->closure);
break;
default:
/* XXX - use define for unknown value */
+ errno = ENOTSUP;
rval = 1;
break;
}
SLIST_REMOVE_HEAD(head, entries);
else
SLIST_REMOVE_AFTER(prev, entries);
- sudo_efree(hook);
+ free(hook);
break;
}
prev = hook;
sudo_load_plugin(struct plugin_container *policy_plugin,
struct plugin_container_list *io_plugins, struct plugin_info *info)
{
- struct plugin_container *container;
+ struct plugin_container *container = NULL;
struct generic_plugin *plugin;
char path[PATH_MAX];
- bool rval = false;
- void *handle;
+ void *handle = NULL;
debug_decl(sudo_load_plugin, SUDO_DEBUG_PLUGIN)
/* Sanity check plugin and fill in path */
if (!sudo_check_plugin(info, path, sizeof(path)))
- goto done;
+ goto bad;
/* Open plugin and map in symbol */
handle = sudo_dso_load(path, SUDO_DSO_LAZY|SUDO_DSO_GLOBAL);
sudo_warnx(U_("error in %s, line %d while loading plugin `%s'"),
_PATH_SUDO_CONF, info->lineno, info->symbol_name);
sudo_warnx(U_("unable to load %s: %s"), path, sudo_dso_strerror());
- goto done;
+ goto bad;
}
plugin = sudo_dso_findsym(handle, info->symbol_name);
if (!plugin) {
sudo_warnx(U_("error in %s, line %d while loading plugin `%s'"),
_PATH_SUDO_CONF, info->lineno, info->symbol_name);
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) {
sudo_warnx(U_("error in %s, line %d while loading plugin `%s'"),
_PATH_SUDO_CONF, info->lineno, info->symbol_name);
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) {
sudo_warnx(U_("error in %s, line %d while loading plugin `%s'"),
sudo_warnx(U_("incompatible plugin major version %d (expected %d) found in %s"),
SUDO_API_VERSION_GET_MAJOR(plugin->version),
SUDO_API_VERSION_MAJOR, path);
- goto done;
+ goto bad;
}
if (plugin->type == SUDO_POLICY_PLUGIN) {
- if (policy_plugin->handle) {
+ if (policy_plugin->handle != NULL) {
/* Ignore duplicate entries. */
if (strcmp(policy_plugin->name, info->symbol_name) != 0) {
sudo_warnx(U_("ignoring policy plugin `%s' in %s, line %d"),
info->symbol_name, _PATH_SUDO_CONF, info->lineno);
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"),
info->symbol_name, _PATH_SUDO_CONF, info->lineno);
- sudo_dso_unload(handle);
- handle = NULL;
+ goto bad;
}
if (handle != NULL) {
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->options = info->options;
policy_plugin->debug_instance = SUDO_DEBUG_INSTANCE_INITIALIZER;
}
}
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->path = sudo_estrdup(path);
container->name = info->symbol_name;
container->options = info->options;
container->debug_instance = SUDO_DEBUG_INSTANCE_INITIALIZER;
info->symbol_name = NULL;
info->options = NULL;
- rval = true;
-done:
- debug_return_bool(rval);
+ debug_return_bool(true);
+bad:
+ free(container);
+ if (handle != NULL)
+ sudo_dso_unload(handle);
+ debug_return_bool(false);
}
static void
free_plugin_info(struct plugin_info *info)
{
- sudo_efree(info->path);
- sudo_efree(info->options);
- sudo_efree(info->symbol_name);
- sudo_efree(info);
+ free(info->path);
+ free(info->options);
+ free(info->symbol_name);
+ free(info);
}
/*
*/
if (policy_plugin->handle == NULL) {
/* 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->path = SUDOERS_PLUGIN;
/* info->options = NULL; */
rval = sudo_load_plugin(policy_plugin, io_plugins, info);
- sudo_efree(info);
+ free(info);
if (!rval)
goto done;
/* Default I/O plugin */
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->path = SUDOERS_PLUGIN;
/* info->options = NULL; */
rval = sudo_load_plugin(policy_plugin, io_plugins, info);
- sudo_efree(info);
+ free(info);
if (!rval)
goto done;
}
#include "sudo_gettext.h" /* must be included before sudo_compat.h */
#include "sudo_compat.h"
-#include "sudo_alloc.h"
#include "sudo_fatal.h"
#include "sudo_conf.h"
#include "sudo_debug.h"
/*
* 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
get_net_ifs(char **addrinfo)
char *cp;
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);
+ if (getifaddrs(&ifaddrs) == -1)
+ debug_return_int(-1);
+
/* Allocate space for the interfaces info string. */
for (ifa = ifaddrs; ifa != NULL; ifa = ifa -> ifa_next) {
/* Skip interfaces marked "down" and "loopback". */
if (num_interfaces == 0)
debug_return_int(0);
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. */
for (ifa = ifaddrs; ifa != NULL; ifa = ifa -> ifa_next) {
#ifdef HAVE_FREEIFADDRS
freeifaddrs(ifaddrs);
#else
- sudo_efree(ifaddrs);
+ free(ifaddrs);
#endif
debug_return_int(num_interfaces);
}
#elif defined(SIOCGIFCONF) && !defined(STUB_LOAD_INTERFACES)
/*
- * Allocate and fill in the interfaces global variable 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. Returns -1 on error.
*/
int
get_net_ifs(char **addrinfo)
sock = socket(AF_INET, SOCK_DGRAM, 0);
if (sock < 0)
- sudo_fatal(U_("unable to open socket"));
+ debug_return_int(-1);
/*
* Get interface configuration or return.
*/
for (;;) {
- ifconf_buf = sudo_emalloc(buflen);
+ if ((ifconf_buf = malloc(buflen)) == NULL) {
+ num_interfaces = -1;
+ goto done;
+ }
ifconf = (struct ifconf *) ifconf_buf;
ifconf->ifc_len = buflen - sizeof(struct ifconf);
ifconf->ifc_buf = (caddr_t) (ifconf_buf + sizeof(struct ifconf));
if (ifconf->ifc_len + sizeof(struct ifreq) < buflen)
break;
buflen += BUFSIZ;
- sudo_efree(ifconf_buf);
+ free(ifconf_buf);
}
/* Allocate space for the maximum number of interfaces that could exist. */
if ((n = ifconf->ifc_len / sizeof(struct ifreq)) == 0)
- debug_return_int(0);
+ goto done;
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 (i = 0; i < ifconf->ifc_len; ) {
}
done:
- sudo_efree(ifconf_buf);
+ free(ifconf_buf);
(void) close(sock);
debug_return_int(num_interfaces);
if (argc <= 0)
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() */
progname = getprogname();
/* Set max_groups from sudo.conf. */
i = sudo_conf_max_groups();
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;
}
}
} else if (!got_end_of_args && is_envar) {
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_add = sudo_ereallocarray(env_add, env_size, sizeof(char *));
}
env_add[nenv++] = argv[optind];
size_t cmnd_size = (size_t) (argv[argc - 1] - argv[0]) +
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 (src = *av; *src != '\0'; src++) {
/* quote potential meta characters */
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 */
if (cmnd != NULL) {
av[1] = "-c";
struct preserved_fd *pfd, *pfd_new;
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->highfd = fd;
pfd_new->flags = fcntl(fd, F_GETFD);
if (pfd_new->flags == -1) {
- sudo_efree(pfd_new);
+ free(pfd_new);
debug_return_int(-1);
}
/* already preserved */
sudo_debug_printf(SUDO_DEBUG_DEBUG|SUDO_DEBUG_LINENO,
"fd %d already preserved", fd);
- sudo_efree(pfd_new);
+ free(pfd_new);
break;
}
if (fd < pfd->highfd) {
}
/* 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) {
FD_SET(pfd->lowfd, fdsp);
}
#include <errno.h>
#include "sudo_compat.h"
-#include "sudo_alloc.h"
#include "sudo_fatal.h"
#include "sudo_util.h"
#include "sudo_debug.h"
tty_sudo ? tty_sudo : "none", tty_libc ? tty_libc : "none");
}
- sudo_efree(tty_sudo);
+ free(tty_sudo);
exit(rval);
}
sudo_fatal(U_("unable to open audit system"));
} else {
/* 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);
+ if (rc == -1)
+ sudo_fatalx(U_("unable to allocate memory"));
rc = audit_log_user_message(au_fd, AUDIT_USER_ROLE_CHANGE,
message, NULL, NULL, ttyn, result);
if (rc <= 0)
sudo_warn(U_("unable to send audit message"));
- sudo_efree(message);
+ free(message);
close(au_fd);
}
/*
* 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) {
sudo_warnx(U_("%s is not a valid context"), new_context);
errno = EINVAL;
debug_return_ptr(new_context);
bad:
- sudo_efree(typebuf);
+ free(typebuf);
context_free(context);
freecon(new_context);
debug_return_ptr(NULL);
*/
for (argc = 0; argv[argc] != NULL; argc++)
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)
nargv[0] = *argv[0] == '-' ? "-sesh-noexec" : "sesh-noexec";
else
#include "sudo_gettext.h" /* must be included before sudo_compat.h */
#include "sudo_compat.h"
-#include "sudo_alloc.h"
#include "sudo_fatal.h"
#include "sudo_conf.h"
#include "sudo_debug.h"
/* Shift argv and make a copy of the command to execute. */
argv++;
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 (login_shell) {
sudo_conf_read(NULL, SUDO_CONF_ALL & ~SUDO_CONF_DEBUG);
/* Fill in user_info with user name, uid, cwd, etc. */
- memset(&user_details, 0, sizeof(user_details));
- user_info = get_user_info(&user_details);
+ if ((user_info = get_user_info(&user_details)) == NULL)
+ sudo_fatalx(U_("unable to allocate memory"));
/* Disable core dumps if not enabled in sudo.conf. */
disable_coredumps();
*/
ud->ngroups = sudo_conf_max_groups();
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. */
(void)getgrouplist(ud->username, ud->gid, ud->groups, &ud->ngroups);
rval = 0;
ud->ngroups = system_maxgroups << 1;
for (tries = 0; tries < 10 && rval == -1; tries++) {
ud->ngroups <<= 1;
- sudo_efree(ud->groups);
- ud->groups = sudo_emallocarray(ud->ngroups, sizeof(GETGROUPS_T));
+ free(ud->groups);
+ 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);
}
}
+done:
debug_return_int(rval);
}
int i, len, maxgroups, group_source;
debug_decl(get_user_groups, SUDO_DEBUG_UTIL)
+ memset(ud, 0, sizeof(*ud));
+
maxgroups = (int)sysconf(_SC_NGROUPS_MAX);
if (maxgroups < 0)
maxgroups = NGROUPS_MAX;
if ((ud->ngroups = getgroups(0, NULL)) > 0) {
/* Use groups from kernel if not too many or source is 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) {
- sudo_efree(ud->groups);
+ free(ud->groups);
ud->groups = NULL;
}
}
* Format group list as a comma-separated string of gids.
*/
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);
cp = gid_list + sizeof("groups=") - 1;
for (i = 0; i < ud->ngroups; i++) {
- /* XXX - check rval */
len = snprintf(cp, glsize - (cp - gid_list), "%s%u",
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;
}
debug_return_str(gid_list);
+oom:
+ sudo_fatalx(U_("unable to allocate memory"));
}
/*
debug_decl(get_user_info, SUDO_DEBUG_UTIL)
/* 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->ppid = getppid();
user_info[i] = sudo_new_key_val("user", pw->pw_name);
if (user_info[i] == NULL)
- sudo_fatal(NULL);
+ goto bad;
ud->username = user_info[i] + sizeof("user=") - 1;
/* 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') {
ud->shell = pw->pw_shell[0] ? pw->pw_shell : _PATH_SUDO_BSHELL;
}
- ud->shell = sudo_estrdup(ud->shell);
-
- sudo_easprintf(&user_info[++i], "pid=%d", (int)ud->pid);
- sudo_easprintf(&user_info[++i], "ppid=%d", (int)ud->ppid);
- sudo_easprintf(&user_info[++i], "pgid=%d", (int)ud->pgid);
- sudo_easprintf(&user_info[++i], "tcpgid=%d", (int)ud->tcpgid);
- sudo_easprintf(&user_info[++i], "sid=%d", (int)ud->sid);
-
- sudo_easprintf(&user_info[++i], "uid=%u", (unsigned int)ud->uid);
- sudo_easprintf(&user_info[++i], "euid=%u", (unsigned int)ud->euid);
- sudo_easprintf(&user_info[++i], "gid=%u", (unsigned int)ud->gid);
- sudo_easprintf(&user_info[++i], "egid=%u", (unsigned int)ud->egid);
+ if ((ud->shell = strdup(ud->shell)) == NULL)
+ goto bad;
+
+ if (asprintf(&user_info[++i], "pid=%d", (int)ud->pid) == -1)
+ goto bad;
+ if (asprintf(&user_info[++i], "ppid=%d", (int)ud->ppid) == -1)
+ goto bad;
+ if (asprintf(&user_info[++i], "pgid=%d", (int)ud->pgid) == -1)
+ goto bad;
+ if (asprintf(&user_info[++i], "tcpgid=%d", (int)ud->tcpgid) == -1)
+ goto bad;
+ if (asprintf(&user_info[++i], "sid=%d", (int)ud->sid) == -1)
+ 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)
user_info[++i] = cp;
if (getcwd(cwd, sizeof(cwd)) != NULL) {
user_info[++i] = sudo_new_key_val("cwd", cwd);
if (user_info[i] == NULL)
- sudo_fatal(NULL);
+ goto bad;
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);
if (user_info[i] == NULL)
- sudo_fatal(NULL);
+ goto bad;
ud->tty = user_info[i] + sizeof("tty=") - 1;
- sudo_efree(cp);
+ free(cp);
}
cp = sudo_gethostname();
user_info[++i] = sudo_new_key_val("host", cp ? cp : "localhost");
if (user_info[i] == NULL)
- sudo_fatal(NULL);
+ goto bad;
ud->host = user_info[i] + sizeof("host=") - 1;
- sudo_efree(cp);
+ free(cp);
sudo_get_ttysize(&ud->ts_lines, &ud->ts_cols);
- sudo_easprintf(&user_info[++i], "lines=%d", ud->ts_lines);
- sudo_easprintf(&user_info[++i], "cols=%d", ud->ts_cols);
+ if (asprintf(&user_info[++i], "lines=%d", ud->ts_lines) == -1)
+ goto bad;
+ if (asprintf(&user_info[++i], "cols=%d", ud->ts_cols) == -1)
+ goto bad;
user_info[++i] = NULL;
debug_return_ptr(user_info);
+bad:
+ while (i--)
+ free(user_info[i]);
+ free(user_info);
+ debug_return_ptr(NULL);
}
/*
if (!qualified) {
char *path = getenv_unhooked("PATH");
if (path != NULL) {
- int len;
- char *cp, *colon;
-
- cp = path = sudo_estrdup(path);
- do {
- if ((colon = strchr(cp, ':')))
- *colon = '\0';
- len = snprintf(pathbuf, sizeof(pathbuf), "%s/%s", cp, sudo);
+ const char *cp, *ep;
+ const char *pathend = path + strlen(path);
+
+ for (cp = sudo_strsplit(path, pathend, ":", &ep); cp != NULL;
+ cp = sudo_strsplit(NULL, pathend, ":", &ep)) {
+
+ int len = snprintf(pathbuf, sizeof(pathbuf), "%.*s/%s",
+ (int)(ep - cp), cp, sudo);
if (len <= 0 || (size_t)len >= sizeof(pathbuf))
continue;
if (access(pathbuf, X_OK) == 0) {
qualified = true;
break;
}
- cp = colon + 1;
- } while (colon);
- sudo_efree(path);
+ }
}
}
}
/* Remove from io_plugins list and free. */
TAILQ_REMOVE(&io_plugins, plugin, entries);
- sudo_efree(plugin);
+ free(plugin);
debug_return;
}
#include "sudo_gettext.h" /* must be included before sudo_compat.h */
#include "sudo_compat.h"
-#include "sudo_alloc.h"
#include "sudo_fatal.h"
#include "sudo_conf.h"
#include "sudo_debug.h"
sudo_edit_mktemp(const char *ofile, char **tfile)
{
const char *cp, *suff;
- int tfd;
+ int len, tfd;
debug_decl(sudo_edit_mktemp, SUDO_DEBUG_EDIT)
if ((cp = strrchr(ofile, '/')) != NULL)
cp = ofile;
suff = strrchr(cp, '.');
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);
} 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);
sudo_debug_printf(SUDO_DEBUG_INFO|SUDO_DEBUG_LINENO,
"%s -> %s, fd %d", ofile, *tfile, tfd);
command_details->flags |= CD_SUDOEDIT_COPY;
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++ = "-e";
*sesh_ap++ = "0";
tfd = sudo_edit_mktemp(ofile, &tfile);
if (tfd == -1) {
sudo_warn("mkstemps");
- sudo_efree(tfile);
- sudo_efree(sesh_args);
+ free(tfile);
+ free(sesh_args);
debug_return_int(-1);
}
/* Helper will re-create temp file with proper security context. */
}
/* Contents of tf will be freed by caller. */
- sudo_efree(sesh_args);
+ free(sesh_args);
return (nfiles);
}
command_details->flags |= CD_SUDOEDIT_COPY;
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++ = "-e";
*sesh_ap++ = "1";
}
/* 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
if (ISSET(command_details->flags, CD_RBAC_ENABLED))
nfiles = selinux_edit_create_tfiles(command_details, tf, files, nfiles);
* to create a new argv.
*/
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++)
nargv[ac] = command_details->argv[ac];
for (i = 0; i < nfiles && ac < nargc; )
#endif
errors = sudo_edit_copy_tfiles(command_details, tf, nfiles, times);
- sudo_efree(tf);
- sudo_efree(nargv);
+ free(tf);
+ free(nargv);
debug_return_int(errors ? 1 : rval);
cleanup:
unlink(tf[i].tfile);
}
}
- sudo_efree(tf);
- sudo_efree(nargv);
+ free(tf);
+ free(nargv);
debug_return_int(1);
}
if (*dev != '/') {
/* devname() doesn't use the /dev/ prefix, add one... */
size_t len = sizeof(_PATH_DEV) + strlen(dev);
- tty = sudo_emalloc(len);
- strlcpy(tty, _PATH_DEV, len);
- strlcat(tty, dev, len);
+ if ((tty = malloc(len)) != NULL) {
+ strlcpy(tty, _PATH_DEV, len);
+ strlcat(tty, dev, len);
+ }
} else {
/* 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);
}
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__)
/*
if (!builtin) {
/* Add to list of subdirs to search. */
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;
- 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;
}
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",
(unsigned int)rdev, pathbuf);
goto done;
if (d != NULL)
closedir(d);
for (i = 0; i < num_subdirs; i++)
- sudo_efree(subdirs[i]);
- sudo_efree(subdirs);
+ free(subdirs[i]);
+ free(subdirs);
debug_return_str(devname);
}
/*
* 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);
if (devname[len - 1] == '/') {
if (strcmp(devname, "/dev/pts/") == 0) {
(void)snprintf(buf, sizeof(buf), "%spts/%u", _PATH_DEV,
(unsigned int)minor(rdev));
if (stat(buf, &sb) == 0) {
- if (S_ISCHR(sb.st_mode) && sb.st_rdev == rdev)
- tty = sudo_estrdup(buf);
+ if (S_ISCHR(sb.st_mode) && sb.st_rdev == rdev) {
+ tty = strdup(buf);
+ goto done;
+ }
}
sudo_debug_printf(SUDO_DEBUG_INFO, "comparing dev %u to %s: %s",
(unsigned int)rdev, buf, tty ? "yes" : "no");
} else {
/* Traverse directory */
tty = sudo_ttyname_scan(devname, rdev, true);
+ if (tty != NULL || errno == ENOMEM)
+ goto done;
}
} else {
if (stat(devname, &sb) == 0) {
- if (S_ISCHR(sb.st_mode) && sb.st_rdev == rdev)
- tty = sudo_estrdup(devname);
+ if (S_ISCHR(sb.st_mode) && sb.st_rdev == rdev) {
+ tty = strdup(devname);
+ goto done;
+ }
}
}
}
/*
* 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);
}
#endif
mib[4] = sizeof(*ki_proc);
mib[5] = 1;
do {
+ struct sudo_kinfo_proc *kp;
+
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);
} while (rc == -1 && errno == ENOMEM);
if (rc != -1) {
sudo_debug_printf(SUDO_DEBUG_WARN,
"unable to resolve tty via KERN_PROC: %s", strerror(errno));
}
- sudo_efree(ki_proc);
+ free(ki_proc);
debug_return_str(tty);
}
}
}
+ if (tty == NULL)
+ sudo_debug_printf(SUDO_DEBUG_WARN,
+ "unable to resolve tty via %s: %s", path, strerror(errno));
+
debug_return_str(tty);
}
#elif defined(__linux__)
}
}
}
- 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);
}
#elif defined(HAVE_PSTAT_GETPROC)
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);
}
#else
if ((tty = ttyname(STDOUT_FILENO)) == NULL)
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