aboutsummaryrefslogtreecommitdiff
path: root/ftp/proftpd/files/patch-contrib_mod_wrap2_file.c
blob: 68a46bb616ef2e8219aa3ab032cb00d583aab5c1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
--- contrib/mod_wrap2_file.c.orig	2007-08-03 06:52:06.000000000 -0800
+++ contrib/mod_wrap2_file.c	2008-03-03 12:33:19.000000000 -0900
@@ -2,7 +2,7 @@
  * ProFTPD: mod_wrap2_file -- a mod_wrap2 sub-module for supplying IP-based
  *                            access control data via file-based tables
  *
- * Copyright (c) 2002-2007 TJ Saunders
+ * Copyright (c) 2002-2008 TJ Saunders
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -22,12 +22,12 @@
  * with OpenSSL, and distribute the resulting executable, without including
  * the source code for OpenSSL in the source distribution.
  *
- * $Id: mod_wrap2_file.c,v 1.4 2007/08/03 14:52:06 castaglia Exp $
+ * $Id: mod_wrap2_file.c,v 1.6 2008/03/03 16:26:28 castaglia Exp $
  */
 
 #include "mod_wrap2.h"
 
-#define MOD_WRAP2_FILE_VERSION		"mod_wrap2_file/1.1"
+#define MOD_WRAP2_FILE_VERSION		"mod_wrap2_file/1.2"
 
 static const char *filetab_service_name = NULL;
 
@@ -74,7 +74,9 @@
     service = pstrndup(filetab->tab_pool, buf, (res - buf));
 
     if (filetab_service_name &&
-        strcasecmp(filetab_service_name, service) == 0) {
+        (strcasecmp(filetab_service_name, service) == 0 ||
+         strcasecmp("ALL", service) == 0)) {
+      char *tmp = NULL;
 
       if (filetab_daemons_list == NULL)
         filetab_daemons_list = make_array(filetab->tab_pool, 0, sizeof(char *));
@@ -91,9 +93,31 @@
       if (filetab_clients_list == NULL)
         filetab_clients_list = make_array(filetab->tab_pool, 0, sizeof(char *));
 
-      *((char **) push_array(filetab_clients_list)) =
-        pstrdup(filetab->tab_pool, res);
-    
+      /* If there are commas in the line, parse them as separate client
+       * names.  Otherwise, a comma-delimited list of names will be treated
+       * as a single name, and violate the principal of least surprise
+       * for the site admin.
+       */
+      tmp = strchr(res, ',');
+      if (tmp != NULL) {
+        char *dup = pstrdup(filetab->tab_pool, res);
+        char *word;
+
+        while ((word = pr_str_get_word(&dup, 0)) != NULL) {
+          size_t wordlen = strlen(word);
+
+          /* Remove any trailing comma */
+          if (word[wordlen-1] == ',')
+            word[wordlen-1] = '\0';
+
+          *((char **) push_array(filetab_clients_list)) = word;
+        }
+
+      } else {
+        *((char **) push_array(filetab_clients_list)) =
+          pstrdup(filetab->tab_pool, res);
+      }
+ 
       res = wrap2_strsplit(res, ':');    
       if (res) {
         if (filetab_options_list == NULL)