]> granicus.if.org Git - sudo/commitdiff
Make interfaces pointer private to interfaces.c and add get_interfaces()
authorTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 25 Oct 2012 17:15:52 +0000 (13:15 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Thu, 25 Oct 2012 17:15:52 +0000 (13:15 -0400)
accessor.

plugins/sudoers/interfaces.c
plugins/sudoers/interfaces.h
plugins/sudoers/match_addr.c
plugins/sudoers/sudoers.c
plugins/sudoers/testsudoers.c
plugins/sudoers/visudo.c

index 624882e2735383260ce36b9e920c2a537030caa2..df390cd813bde4e992156580766f2bae178060d5 100644 (file)
@@ -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)
 {
index e3a13bfd6bc2ab656f90b2dfd7bf38b25ba59350..00e69b441a1a07d6b30e1f6761888ccfa01f8348 100644 (file)
@@ -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 */
index 23e68677933e29f8421075c67d66ba4a24e50369..b6aea7063403dd6e1e47639da08e4fbcd17ba7b1 100644 (file)
@@ -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) {
index 3ce8f5135c8f30094e9b9e0c134ddc1ec4a05921..594796095a19f151e351437c49ad54b9b74f4cb0 100644 (file)
@@ -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;
index ef96f0dd8a6a023b1074bb355f24189f1f24502f..837545750d6836f5fac079377eebcb7d43f53143 100644 (file)
@@ -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;
index ff30eb2610274ff0372cb7f4fc906a967dda0042..6b01d6ccce846d1d19ffcfc779426472ea63e97b 100644 (file)
@@ -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.