audit: remove static local realms
[openafs.git] / src / viced / viced.c
index f150d25..f03ac08 100644 (file)
 #include <afs/dir.h>
 #ifndef AFS_NT40_ENV
 # include <afs/netutils.h>
+# include <afs/softsig.h>
 #endif
 #include "viced_prototypes.h"
 #include "viced.h"
 #include "host.h"
-#include <afs/softsig.h>
 #if defined(AFS_SGI_ENV)
 # include "sys/schedctl.h"
 # include "sys/lock.h"
@@ -286,6 +286,25 @@ fs_rxstat_userok(struct rx_call *call)
     return afsconf_SuperUser(confDir, call, NULL);
 }
 
+/**
+ * Return true if this name is a member of the local realm.
+ */
+int
+fs_IsLocalRealmMatch(void *rock, char *name, char *inst, char *cell)
+{
+    struct afsconf_dir *dir = (struct afsconf_dir *)rock;
+    afs_int32 islocal = 0;     /* default to no */
+    int code;
+
+    code = afsconf_IsLocalRealmMatch(dir, &islocal, name, inst, cell);
+    if (code) {
+       ViceLog(0,
+               ("Failed local realm check; code=%d, name=%s, inst=%s, cell=%s\n",
+                code, name, inst, cell));
+    }
+    return islocal;
+}
+
 static void
 ResetCheckSignal(void)
 {
@@ -1362,8 +1381,6 @@ ParseArgs(int argc, char *argv[])
     /* rxkad options */
     cmd_OptionAsFlag(opts, OPT_dotted, &rxkadDisableDotCheck);
     if (cmd_OptionAsList(opts, OPT_realm, &optlist) == 0) {
-       extern char local_realms[AFS_NUM_LREALMS][AFS_REALM_SZ];
-       extern int num_lrealms;
 
        for (; optlist != NULL; optlist=optlist->next) {
            if (strlen(optlist->data) >= AFS_REALM_SZ) {
@@ -1371,17 +1388,7 @@ ParseArgs(int argc, char *argv[])
                       "characters.\n", AFS_REALM_SZ);
                return -1;
            }
-
-           if (num_lrealms == -1)
-               num_lrealms = 0;
-           if (num_lrealms >= AFS_NUM_LREALMS) {
-               printf("a maximum of %d -realm arguments can be "
-                      "specified.\n", AFS_NUM_LREALMS);
-               return -1;
-           }
-
-           strncpy(local_realms[num_lrealms++], optlist->data, AFS_REALM_SZ);
-           optlist = optlist->next;
+           afsconf_SetLocalRealm(optlist->data); /* overrides krb.conf file, if one */
        }
     }
 
@@ -1843,6 +1850,9 @@ main(int argc, char *argv[])
        exit(-1);
     }
 
+    /* initialize audit user check */
+    osi_audit_set_user_check(confDir, fs_IsLocalRealmMatch);
+
     /* Open FileLog on stdout, stderr, fd 1 and fd2 (for perror), sigh. */
 #ifndef AFS_NT40_ENV
     serverLogSyslogTag = "fileserver";