Alan,

I wrote the patch also for radzap. You will find it below. I patched the 
man also.

I send you again the radwho patch with the correct path.

Regards,
Andrea


--- src/main/radwho.c.orig      2002-08-16 10:25:24.780004000 +0200
+++ src/main/radwho.c   2002-08-16 14:59:59.210005000 +0200
@@ -91,6 +91,15 @@
  int log_stripped_names;
  struct main_config_t mainconfig;

+struct radutmp_config_t {
+  char *radutmp_fn;
+} radutmpconfig;
+
+static CONF_PARSER module_config[] = {
+  { "filename", PW_TYPE_STRING_PTR, 0, &radutmpconfig.radutmp_fn,  RADUTMP },
+  { NULL, -1, 0, NULL, NULL }
+};
+
  /*
   *     A mapping of configuration file names to internal variables
   */
@@ -363,7 +372,6 @@
         int c, portno;

         radius_dir = strdup(RADIUS_DIR);
-       radutmp_file = strdup(RADUTMP);

         while((c = getopt(argc, argv, "d:flhnsipcr")) != EOF) switch(c) {
                 case 'd':
@@ -418,6 +426,19 @@
         }
         cf_section_parse(cs, NULL, server_config);

+       /* Read the radutmp section of radiusd.conf */
+       cs = cf_section_sub_find(cf_section_find("modules"), "radutmp");
+       if(!cs) {
+               fprintf(stderr, "%s: No configuration information in 
radutmp section of radiusd.conf!\n",
+                       argv[0]);
+               exit(1);
+       }
+
+       cf_section_parse(cs, NULL, module_config);
+
+       /* Assign the correct path for the radutmp file */
+       radutmp_file = radutmpconfig.radutmp_fn;
+
         /*
          *      See if we are "fingerd".
          */
@@ -500,7 +521,7 @@
         /*
          *      Show the users logged in on the terminal server(s).
          */
-       if ((fp = fopen(RADUTMP, "r")) == NULL)
+       if ((fp = fopen(radutmp_file, "r")) == NULL)
                 return 0;

         if (!hdrdone) {

--- src/main/radzap.c.orig      2002-08-17 19:14:37.980004000 +0200
+++ src/main/radzap.c   2002-08-17 19:35:40.630003000 +0200
@@ -58,10 +58,20 @@
  int proxy_dead_time;
  int log_stripped_names;
  radlog_dest_t radlog_dest = RADLOG_FILES;
+const char *radutmp_file = NULL;
  struct main_config_t mainconfig;
  uint32_t radiusip = INADDR_NONE;
  static void usage(void);

+struct radutmp_config_t {
+  char *radutmp_fn;
+} radutmpconfig;
+
+static CONF_PARSER module_config[] = {
+  { "filename", PW_TYPE_STRING_PTR, 0, &radutmpconfig.radutmp_fn,  RADUTMP },
+  { NULL, -1, 0, NULL, NULL }
+};
+
  /*
   *      A mapping of configuration file names to internal variables
   */
@@ -77,7 +87,7 @@
  {
         int fd;

-       if ((fd = open(RADUTMP, O_RDONLY|O_CREAT, 0644)) >= 0) {
+       if ((fd = open(radutmp_file, O_RDONLY|O_CREAT, 0644)) >= 0) {
                 /*
                  *      Lock the utmp file.
                  */
@@ -112,8 +122,9 @@
  static void usage(void)
  {
          fprintf(stderr,
-                        "Usage: %s [-p acct_port] [-r servername|serverip] 
termserver [port] [user]\n", progname);
+                        "Usage: %s [-d raddb] [-p acct_port] [-r 
servername|serverip] termserver [port] [user]\n", progname);
          fprintf(stderr, "Options:\n\n");
+       fprintf(stderr, "  -d raddb        Set the raddb directory (default 
is %s)\n", RADIUS_DIR);
          fprintf(stderr, "  -p acct_port    Accounting port on radius 
server\n");
          fprintf(stderr, "  -r radserver    Radius server name or IP 
address\n");
          fprintf(stderr, "  termserver      Terminal Server (NAS) name or 
IP address to match, can be '' for any\n");
@@ -140,11 +151,17 @@

         progname = argv[0];

+       radius_dir = strdup(RADIUS_DIR);
+
          /*  Process the options.  */
-        while ((argval = getopt(argc, argv, "p:r:")) != EOF) {
+        while ((argval = getopt(argc, argv, "d:p:r:")) != EOF) {

                  switch(argval) {

+                       case 'd':
+                               if (radius_dir) free(radius_dir);
+                               radius_dir = strdup(optarg);
+                               break;
                          case 'p':
                                 acct_port = atoi(optarg);
                                  break;
@@ -191,8 +208,7 @@
         if (nas != NULL)
                 ip = nas->ipaddr;

-       radius_dir = strdup(RADIUS_DIR);
-
+        /* Read radiusd.conf */
         if(read_radius_conf_file() < 0) {
                 fprintf(stderr, "%s: Error reading radiusd.conf.\n", argv[0]);
                 exit(1);
@@ -206,6 +222,18 @@
         }
         cf_section_parse(cs, NULL, server_config);

+        /* Read the radutmp section of radiusd.conf */
+        cs = cf_section_sub_find(cf_section_find("modules"), "radutmp");
+        if(!cs) {
+                fprintf(stderr, "%s: No configuration information in 
radutmp section of radiusd.conf!\n",
+                        argv[0]);
+                exit(1);
+        }
+
+        cf_section_parse(cs, NULL, module_config);
+
+        /* Assign the correct path for the radutmp file */
+        radutmp_file = radutmpconfig.radutmp_fn;

         printf("%s: zapping termserver %s, port %u",
                 progname, ip_hostname(buf, sizeof(buf), ip), nas_port);

--- man/man1/radzap.1.orig      2002-08-17 20:51:03.050004000 +0200
+++ man/man1/radzap.1   2002-08-17 21:05:50.990002000 +0200
@@ -3,6 +3,8 @@
  radzap - remove rogue entries from the active sessions database
  .SH SYNOPSIS
  .B radzap
+.RB [ \-d
+.IR raddb_directory ]
  .RB [ \-r
  .IR radius_server ]
  .RB [ \-p
@@ -18,6 +20,8 @@
  then it might contain rogue entries. \fBradzap\fP can clean up this
  database.
  .SH OPTIONS
+.IP \-d\ \fIraddb_directory\fP
+The directory that contains the RADIUS configuration files.
  .IP \-r\ \fIradius_server\fP
  Host name or IP address of the RADIUS server.
  .IP \-p\ \fIaccounting_port\fP




- 
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html

Reply via email to