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 159 160 161 162 163 164
|
#!/bin/sh -e
## 10_usermapprefix.dpatch by Mark Smith & Adam D. Barratt
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Add UserMapPrefix option (bug#228059)
if [ $# -lt 1 ]; then
echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
exit 1
fi
[ -f debian/patches/00patch-opts ] && . debian/patches/00patch-opts
patch_opts="${patch_opts:--f --no-backup-if-mismatch}"
case "$1" in
-patch) patch $patch_opts -p1 < $0;;
-unpatch) patch $patch_opts -p1 -R < $0;;
*)
echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
exit 1;;
esac
exit 0
@DPATCH@
diff -urNad solid-pop3d.old/man/spop3d.8 solid-pop3d/man/spop3d.8
--- solid-pop3d.old/man/spop3d.8 2004-01-29 21:11:32.000000000 +0100
+++ solid-pop3d/man/spop3d.8 2004-01-29 21:11:33.000000000 +0100
@@ -59,6 +59,15 @@
.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 -urNad solid-pop3d.old/man/spop3d.conf.5 solid-pop3d/man/spop3d.conf.5
--- solid-pop3d.old/man/spop3d.conf.5 2004-01-29 21:11:33.000000000 +0100
+++ solid-pop3d/man/spop3d.conf.5 2004-01-29 21:11:33.000000000 +0100
@@ -149,6 +149,16 @@
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 -urNad solid-pop3d.old/src/configfile.h solid-pop3d/src/configfile.h
--- solid-pop3d.old/src/configfile.h 2004-01-29 21:11:33.000000000 +0100
+++ solid-pop3d/src/configfile.h 2004-01-29 21:11:33.000000000 +0100
@@ -68,6 +68,7 @@
extern int reqmapping;
extern int authmappeduser;
extern char sp_mapfile[];
+extern char sp_usermapprefix[];
extern char mapfileowner[];
#endif
#ifdef NONIPVIRTUALS
diff -urNad solid-pop3d.old/src/const.h solid-pop3d/src/const.h
--- solid-pop3d.old/src/const.h 2004-01-29 21:11:32.000000000 +0100
+++ solid-pop3d/src/const.h 2004-01-29 21:11:33.000000000 +0100
@@ -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 -urNad solid-pop3d.old/src/main.c solid-pop3d/src/main.c
--- solid-pop3d.old/src/main.c 2004-01-29 21:11:33.000000000 +0100
+++ solid-pop3d/src/main.c 2004-01-29 21:11:33.000000000 +0100
@@ -177,6 +177,7 @@
{"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 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 @@
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 @@
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 @@
#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 @@
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
|