and cvtsudoers.c and into stubs.c.
plugins/sudoers/solaris_audit.h
plugins/sudoers/sssd.c
plugins/sudoers/starttime.c
+plugins/sudoers/stubs.c
plugins/sudoers/sudo_nss.c
plugins/sudoers/sudo_nss.h
plugins/sudoers/sudo_printf.c
set_perms.lo starttime.lo sudo_nss.lo sudoers.lo \
timestamp.lo @SUDOERS_OBJS@
-VISUDO_OBJS = editor.o find_path.o goodpath.o locale.o sudo_printf.o visudo.o
+VISUDO_OBJS = editor.o find_path.o goodpath.o locale.o stubs.o sudo_printf.o visudo.o
-CVTSUDOERS_OBJS = cvtsudoers.o cvtsudoers_json.o locale.o sudo_printf.o
+CVTSUDOERS_OBJS = cvtsudoers.o cvtsudoers_json.o locale.o stubs.o sudo_printf.o
REPLAY_OBJS = getdate.o sudoreplay.o
$(top_builddir)/pathnames.h
$(LIBTOOL) $(LTFLAGS) --mode=compile $(CC) -c $(CPPFLAGS) $(CFLAGS) $(ASAN_CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(srcdir)/starttime.c
starttime.o: starttime.lo
+stubs.o: $(srcdir)/stubs.c $(devdir)/def_data.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_plugin.h $(incdir)/sudo_queue.h $(incdir)/sudo_util.h \
+ $(srcdir)/defaults.h $(srcdir)/interfaces.h $(srcdir)/logging.h \
+ $(srcdir)/sudo_nss.h $(srcdir)/sudoers.h $(srcdir)/sudoers_debug.h \
+ $(top_builddir)/config.h $(top_builddir)/pathnames.h
+ $(CC) -c $(CPPFLAGS) $(CFLAGS) $(ASAN_CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(srcdir)/stubs.c
sudo_auth.lo: $(authdir)/sudo_auth.c $(devdir)/def_data.h \
$(incdir)/compat/stdbool.h $(incdir)/sudo_compat.h \
$(incdir)/sudo_conf.h $(incdir)/sudo_debug.h \
#endif /* HAVE_GETOPT_LONG */
extern bool convert_sudoers_json(const char *, const char *);
+extern void get_hostname(void);
/*
* Globals
};
__dso_public int main(int argc, char *argv[]);
-static void get_hostname(void);
static void help(void) __attribute__((__noreturn__));
static void usage(int);
return fopen(sudoers, "r");
}
-/* XXX - Common stubs belong in their own file */
-
-/* STUB */
-bool
-init_envtables(void)
-{
- return true;
-}
-
-/* STUB */
-bool
-user_is_exempt(void)
-{
- return false;
-}
-
-/* STUB */
-void
-sudo_setspent(void)
-{
- return;
-}
-
-/* STUB */
-void
-sudo_endspent(void)
-{
- return;
-}
-
-/* STUB */
-int
-group_plugin_query(const char *user, const char *group, const struct passwd *pw)
-{
- return false;
-}
-
-/* STUB */
-struct interface_list *
-get_interfaces(void)
-{
- static struct interface_list dummy = SLIST_HEAD_INITIALIZER(interfaces);
- return &dummy;
-}
-
-/*
- * Look up the hostname and set user_host and user_shost.
- */
-static void
-get_hostname(void)
-{
- char *p;
- debug_decl(get_hostname, SUDOERS_DEBUG_UTIL)
-
- if ((user_host = sudo_gethostname()) != NULL) {
- if ((p = strchr(user_host, '.'))) {
- *p = '\0';
- if ((user_shost = strdup(user_host)) == NULL)
- sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
- *p = '.';
- } else {
- user_shost = user_host;
- }
- } else {
- user_host = user_shost = "localhost";
- }
- user_runhost = user_host;
- user_srunhost = user_shost;
- debug_return;
-}
-
static void
usage(int fatal)
{
--- /dev/null
+/*
+ * Copyright (c) 2018 Todd C. Miller <Todd.Miller@sudo.ws>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+ * Stub versions of functions needed by the parser.
+ * Required to link cvtsudoers and visudo.
+ */
+
+#include <config.h>
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <stdlib.h>
+#ifdef HAVE_STRING_H
+# include <string.h>
+#endif /* HAVE_STRING_H */
+#ifdef HAVE_STRINGS_H
+# include <strings.h>
+#endif /* HAVE_STRINGS_H */
+
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include "sudoers.h"
+#include "interfaces.h"
+
+/* STUB */
+bool
+init_envtables(void)
+{
+ return true;
+}
+
+/* STUB */
+bool
+user_is_exempt(void)
+{
+ return false;
+}
+
+/* STUB */
+void
+sudo_setspent(void)
+{
+ return;
+}
+
+/* STUB */
+void
+sudo_endspent(void)
+{
+ return;
+}
+
+/* STUB */
+int
+group_plugin_query(const char *user, const char *group, const struct passwd *pw)
+{
+ return false;
+}
+
+/* STUB */
+struct interface_list *
+get_interfaces(void)
+{
+ static struct interface_list dummy = SLIST_HEAD_INITIALIZER(interfaces);
+ return &dummy;
+}
+
+/*
+ * Look up the hostname and set user_host and user_shost.
+ */
+void
+get_hostname(void)
+{
+ char *cp;
+ debug_decl(get_hostname, SUDOERS_DEBUG_UTIL)
+
+ if ((user_host = sudo_gethostname()) != NULL) {
+ if ((cp = strchr(user_host, '.'))) {
+ *cp = '\0';
+ if ((user_shost = strdup(user_host)) == NULL)
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
+ *cp = '.';
+ } else {
+ user_shost = user_host;
+ }
+ } else {
+ user_host = user_shost = strdup("localhost");
+ if (user_host == NULL)
+ sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
+ }
+ user_runhost = user_host;
+ user_srunhost = user_shost;
+
+ debug_return;
+}
* Function prototypes
*/
static void quit(int);
-static void get_hostname(void);
static int whatnow(void);
static int check_aliases(bool strict, bool quiet);
static char *get_editor(int *editor_argc, char ***editor_argv);
static void usage(int);
static void visudo_cleanup(void);
+extern void get_hostname(void);
extern void sudoersrestart(FILE *);
/*
debug_return_bool(ret);
}
-/* STUB */
-bool
-init_envtables(void)
-{
- return true;
-}
-
-/* STUB */
-bool
-user_is_exempt(void)
-{
- return false;
-}
-
-/* STUB */
-void
-sudo_setspent(void)
-{
- return;
-}
-
-/* STUB */
-void
-sudo_endspent(void)
-{
- return;
-}
-
-/* STUB */
-int
-group_plugin_query(const char *user, const char *group, const struct passwd *pw)
-{
- return false;
-}
-
-/* STUB */
-struct interface_list *
-get_interfaces(void)
-{
- static struct interface_list dummy = SLIST_HEAD_INITIALIZER(interfaces);
- return &dummy;
-}
-
/*
* Assuming a parse error occurred, prompt the user for what they want
* to do now. Returns the first letter of their choice.
debug_return_ptr(fp);
}
-/*
- * Look up the hostname and set user_host and user_shost.
- */
-static void
-get_hostname(void)
-{
- char *p;
- debug_decl(get_hostname, SUDOERS_DEBUG_UTIL)
-
- if ((user_host = sudo_gethostname()) != NULL) {
- if ((p = strchr(user_host, '.'))) {
- *p = '\0';
- if ((user_shost = strdup(user_host)) == NULL)
- sudo_fatalx(U_("%s: %s"), __func__, U_("unable to allocate memory"));
- *p = '.';
- } else {
- user_shost = user_host;
- }
- } else {
- user_host = user_shost = "localhost";
- }
- user_runhost = user_host;
- user_srunhost = user_shost;
- debug_return;
-}
-
static bool
alias_remove_recursive(char *name, int type)
{