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 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
|
From: "Adam D. Barratt" <debian-bts@adam-barratt.org.uk>
Date: Thu, 22 Jan 2004 09:27:04 +0000
Subject: 10 usermapprefix
Add UserMapPrefix option (bug#228059) by Mark Smith & Adam D. Barratt
---
man/spop3d.8 | 9 +++++++++
man/spop3d.conf.5 | 10 ++++++++++
src/configfile.h | 1 +
src/const.h | 1 +
src/main.c | 30 ++++++++++++++++++++++++++++--
5 files changed, 49 insertions(+), 2 deletions(-)
diff --git a/man/spop3d.8 b/man/spop3d.8
index bb34bea..8b3d7e5 100644
--- a/man/spop3d.8
+++ b/man/spop3d.8
@@ -59,6 +59,15 @@ character
.TP
.B %m
replace it with mapped user name (read VIRTUALS file)
+.TP
+.B %o
+replace it with the "original" user name. This is the user name with any
+.BR UserMapPrefix
+removed. Unless
+.BR DoMapping
+is enabled, and a
+.BR UserMapPrefix
+is supplied, this will be a blank string.
.PP
If specified path is not absolute it is treated as relative to user home
directory. For example:
diff --git a/man/spop3d.conf.5 b/man/spop3d.conf.5
index 76fd136..7dd016d 100644
--- a/man/spop3d.conf.5
+++ b/man/spop3d.conf.5
@@ -149,6 +149,16 @@ Option is disabled by default.
Specify path to user names mapping file (read VIRTUALS file).
There is no default value.
.TP
+.B UserMapPrefix string
+Specify a set of characters which should be prefixed to the username before
+it is looked up in the user mapping file.
+.br
+For example, given a username of "bar", and a \fBUserMapPrefix\fP of
+"foo-", there should be an entry in the user mapping file for "foo-bar".
+.br
+This option has no effect when DoMapping is disabled, and is a blank
+string by default.
+.TP
.B AllowNonIP boolean
If enabled user is allowed to specify virtual domain name in when logging.
Read VIRTUALS file for details. Option is enabled by default.
diff --git a/src/configfile.h b/src/configfile.h
index 39c01e7..f297977 100644
--- a/src/configfile.h
+++ b/src/configfile.h
@@ -68,6 +68,7 @@ extern int domapping;
extern int reqmapping;
extern int authmappeduser;
extern char sp_mapfile[];
+extern char sp_usermapprefix[];
extern char mapfileowner[];
#endif
#ifdef NONIPVIRTUALS
diff --git a/src/const.h b/src/const.h
index 9379fd4..75de5b0 100644
--- a/src/const.h
+++ b/src/const.h
@@ -26,6 +26,7 @@
#define MAXRESPLN 512
#define MAXCMDLN 255
#define MAXARGLN 40
+#define MAXPREFIX 16
#define AUTH_STATE 0
#define TRANSACTION_STATE 1
diff --git a/src/main.c b/src/main.c
index 9788030..8ec9867 100644
--- a/src/main.c
+++ b/src/main.c
@@ -177,6 +177,7 @@ struct str_option options_set[] =
{"DoMapping", OP_BOOLEAN, &domapping, 0, NULL},
{"AuthMappedUser", OP_BOOLEAN, &authmappeduser, 1, NULL},
{"RequiredMapping", OP_BOOLEAN, &reqmapping, 0, NULL},
+ {"UserMapPrefix", OP_STRING, &sp_usermapprefix, MAXPREFIX, NULL},
#endif
#ifdef NONIPVIRTUALS
{"AllowNonIP", OP_BOOLEAN, &allownonip, 0, NULL},
@@ -213,6 +214,9 @@ char maildrop_type[MAXMDTYPENAMELENGTH];
char sp_mapfile[PATH_MAX];
int domapping = 0, reqmapping = 1, authmappeduser = 1;
char mapusername[MAXARGLN + 1];
+char origusername[MAXARGLN + 1];
+char usernamebuf[MAXARGLN + 1];
+char sp_usermapprefix[MAXPREFIX];
#endif
#ifdef APOP
char apop_secret[MAXARGLN + 1];
@@ -312,6 +316,16 @@ int expand_dir(char *dir, char *homedir) {
strcat(filename, mapusername);
tmp = tmp2 + 2;
break;
+ case 'o':
+ *tmp2 = 0;
+ if ((strlen(filename) + strlen(tmp) + strlen(origusername) + 1) > sizeof(filename)) {
+ breakwhile = 1;
+ break;
+ };
+ strcat(filename, tmp);
+ strcat(filename, origusername);
+ tmp = tmp2 + 2;
+ break;
#endif
case 'd':
if ((tmp2[2] < '1') || (tmp2[2] > '8')) {
@@ -1047,9 +1061,11 @@ int main(int argc, char **argv)
signal(SIGUSR1, sig_handler);
signal(SIGUSR2, sig_handler);
memset(username, 0, sizeof(username));
- memset(password, 0, sizeof(username));
+ memset(password, 0, sizeof(password));
#ifdef MAPPING
memset(mapusername, 0, sizeof(mapusername));
+ memset(origusername, 0, sizeof(origusername));
+ memset(usernamebuf, 0, sizeof(usernamebuf));
#endif
alarm(0);
umask(0077);
@@ -1216,6 +1232,10 @@ int main(int argc, char **argv)
#ifdef MAPPING
mapusername[0] = 0;
if (domapping) {
+ if (sp_usermapprefix[0] != '\0') {
+ snprintf(usernamebuf, MAXARGLN, "%s%s", sp_usermapprefix, username);
+ strcpy(username,usernamebuf);
+ }
/* map_finduser() doesn't overflow mapusername - sizeof(mapusername) = MAXARGLN + 1 */
if (((tmp = map_finduser(sp_mapfile, username, mapusername)) < 0) && \
(reqmapping)) {
@@ -1348,8 +1368,14 @@ int main(int argc, char **argv)
wait(NULL);
check_logpriority(logpriority);
#ifdef MAPPING
- if (domapping)
+ if (domapping) {
+ strcpy(origusername,username);
+ if (sp_usermapprefix[0] != '\0') {
+ snprintf(usernamebuf, MAXARGLN, "%s%s", sp_usermapprefix, username);
+ strcpy(username,usernamebuf);
+ }
userentry = getpwnam(mapusername);
+ }
else
userentry = getpwnam(username);
#else
--
|