From: Todd C. Miller Date: Thu, 25 Oct 2012 17:15:52 +0000 (-0400) Subject: Make interfaces pointer private to interfaces.c and add get_interfaces() X-Git-Tag: SUDO_1_8_7~1^2~366 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=929aef07545c88fae810b2f78ca1bc88484a0185;p=sudo Make interfaces pointer private to interfaces.c and add get_interfaces() accessor. --- diff --git a/plugins/sudoers/interfaces.c b/plugins/sudoers/interfaces.c index 624882e27..df390cd81 100644 --- a/plugins/sudoers/interfaces.c +++ b/plugins/sudoers/interfaces.c @@ -52,6 +52,8 @@ # define INADDR_NONE ((unsigned int)-1) #endif +static struct interface *interfaces; + /* * Parse a space-delimited list of IP address/netmask pairs and * store in a list of interface structures. @@ -101,6 +103,12 @@ set_interfaces(const char *ai) debug_return; } +struct interface * +get_interfaces(void) +{ + return interfaces; +} + void dump_interfaces(const char *ai) { diff --git a/plugins/sudoers/interfaces.h b/plugins/sudoers/interfaces.h index e3a13bfd6..00e69b441 100644 --- a/plugins/sudoers/interfaces.h +++ b/plugins/sudoers/interfaces.h @@ -48,12 +48,6 @@ struct interface { int get_net_ifs(char **addrinfo); void dump_interfaces(const char *); void set_interfaces(const char *); - -/* - * Definitions for external variables. - */ -#ifndef _SUDO_MAIN -extern struct interface *interfaces; -#endif +struct interface *get_interfaces(void); #endif /* _SUDO_INTERFACES_H */ diff --git a/plugins/sudoers/match_addr.c b/plugins/sudoers/match_addr.c index 23e686779..b6aea7063 100644 --- a/plugins/sudoers/match_addr.c +++ b/plugins/sudoers/match_addr.c @@ -71,7 +71,7 @@ addr_matches_if(char *n) addr.ip4.s_addr = inet_addr(n); } - for (ifp = interfaces; ifp != NULL; ifp = ifp->next) { + for (ifp = get_interfaces(); ifp != NULL; ifp = ifp->next) { if (ifp->family != family) continue; switch (family) { @@ -154,7 +154,7 @@ addr_matches_if_netmask(char *n, char *m) } #endif /* HAVE_STRUCT_IN6_ADDR */ - for (ifp = interfaces; ifp != NULL; ifp = ifp->next) { + for (ifp = get_interfaces(); ifp != NULL; ifp = ifp->next) { if (ifp->family != family) continue; switch (family) { diff --git a/plugins/sudoers/sudoers.c b/plugins/sudoers/sudoers.c index 3ce8f5135..594796095 100644 --- a/plugins/sudoers/sudoers.c +++ b/plugins/sudoers/sudoers.c @@ -109,7 +109,6 @@ static void create_admin_success_flag(void); */ struct sudo_user sudo_user; struct passwd *list_pw; -struct interface *interfaces; int long_list; uid_t timestamp_uid; extern int errorlineno; diff --git a/plugins/sudoers/testsudoers.c b/plugins/sudoers/testsudoers.c index ef96f0dd8..837545750 100644 --- a/plugins/sudoers/testsudoers.c +++ b/plugins/sudoers/testsudoers.c @@ -106,7 +106,6 @@ extern int (*trace_print)(const char *msg); /* * Globals */ -struct interface *interfaces; struct sudo_user sudo_user; struct passwd *list_pw; static char *runas_group, *runas_user; diff --git a/plugins/sudoers/visudo.c b/plugins/sudoers/visudo.c index ff30eb261..6b01d6ccc 100644 --- a/plugins/sudoers/visudo.c +++ b/plugins/sudoers/visudo.c @@ -76,7 +76,6 @@ #endif #include "sudoers.h" -#include "interfaces.h" #include "parse.h" #include "redblack.h" #include "gettext.h" @@ -136,7 +135,6 @@ extern int optind; /* * Globals */ -struct interface *interfaces; struct sudo_user sudo_user; struct passwd *list_pw; sudo_printf_t sudo_printf = visudo_printf; @@ -693,6 +691,12 @@ group_plugin_query(const char *user, const char *group, const struct passwd *pw) return false; } +/* STUB */ +struct interface *get_interfaces(void) +{ + return NULL; +} + /* * Assuming a parse error occurred, prompt the user for what they want * to do now. Returns the first letter of their choice.