aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2006-01-05 15:35:42 +0000
committerSergey Poznyakoff <gray@gnu.org.ua>2006-01-05 15:35:42 +0000
commitc815ab17f2e6cffac850160b33de99c0450a5433 (patch)
treec43c159066818145ffbc196bfb5516ac87196205
parent809d88fd22a0b0a43befd376a1717b0cb4fb4fa8 (diff)
downloadmailfromd-c815ab17f2e6cffac850160b33de99c0450a5433.tar.gz
mailfromd-c815ab17f2e6cffac850160b33de99c0450a5433.tar.bz2
(check_portspec): New function.
git-svn-id: file:///svnroot/mailfromd/trunk@184 7a8a7f39-df28-0410-adc6-e0d955640f24
-rw-r--r--src/main.c36
1 files changed, 24 insertions, 12 deletions
diff --git a/src/main.c b/src/main.c
index 5fec5914..3ad4f1b2 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1,5 +1,5 @@
/* This file is part of mailfrom filter.
- Copyright (C) 2005, Sergey Poznyakoff
+ Copyright (C) 2005, 2006 Sergey Poznyakoff
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
@@ -1412,6 +1412,24 @@ check_local_portspec(char *p)
}
}
+void
+check_portspec(char *portspec)
+{
+ static char *proto[] = { "unix", "local", NULL };
+ int i;
+
+ for (i = 0; i < sizeof(proto)/sizeof(proto[0]); i++) {
+ int len = strlen(proto[i]);
+ if (strlen(portspec) > len+1
+ && strncasecmp(portspec, proto[i], len) == 0
+ && portspec[len] == ':') {
+ check_local_portspec(portspec + len + 1);
+ umask(007);
+ break;
+ }
+ }
+}
+
/* Switch to the given UID/GID */
int
switch_to_privs(uid_t uid, gid_t gid)
@@ -1542,20 +1560,20 @@ check_pidfile(char *name)
static char *license =
" This is mailfromd filter.\n"
- " Copyright (C) 2005, Sergey Poznyakoff\n"
+ " Copyright (C) 2005, 2006 Sergey Poznyakoff\n"
"\n"
" ls is free software; you can redistribute it and/or modify\n"
" it under the terms of the GNU General Public License as published by\n"
" the Free Software Foundation; either version 2 of the License, or\n"
" (at your option) any later version.\n"
"\n"
- " GNU Mailutils is distributed in the hope that it will be useful,\n"
+ " This program is distributed in the hope that it will be useful,\n"
" but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
" GNU General Public License for more details.\n"
"\n"
" You should have received a copy of the GNU General Public License along\n"
- " with GNU Mailutils; if not, write to the Free Software Foundation,\n"
+ " with this program; if not, write to the Free Software Foundation,\n"
" Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n\n";
void
@@ -1600,15 +1618,9 @@ mailfromd_daemon()
if (!foreground)
check_pidfile(pidfile);
-
- if (strncasecmp(portspec, "unix:", 5) == 0) {
- check_local_portspec(portspec + 5);
- umask(007);
- } else if (strncasecmp(portspec, "local:", 6) == 0) {
- check_local_portspec(portspec + 6);
- umask(007);
- }
+ check_portspec(portspec);
+
if (smfi_setconn(portspec) == MI_FAILURE) {
mu_error("smfi_setconn: %s", mu_strerror(errno));
exit(EX_SOFTWARE);

Return to:

Send suggestions and report system problems to the System administrator.