diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2006-01-05 15:35:42 +0000 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2006-01-05 15:35:42 +0000 |
commit | c815ab17f2e6cffac850160b33de99c0450a5433 (patch) | |
tree | c43c159066818145ffbc196bfb5516ac87196205 | |
parent | 809d88fd22a0b0a43befd376a1717b0cb4fb4fa8 (diff) | |
download | mailfromd-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.c | 36 |
1 files changed, 24 insertions, 12 deletions
@@ -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); |