diff options
author | gshapiro <gshapiro@FreeBSD.org> | 2015-07-09 05:23:17 +0000 |
---|---|---|
committer | gshapiro <gshapiro@FreeBSD.org> | 2015-07-09 05:23:17 +0000 |
commit | 574e70a7ab89c27012f2e53ff74c081ef90091e1 (patch) | |
tree | d72b291cbd1817d0c82d74e0443d43d3086fb304 /contrib/sendmail/makemap/makemap.c | |
parent | 6fbe38a3cd2c5a390bea25327ee11f7e89fac99d (diff) | |
download | FreeBSD-src-574e70a7ab89c27012f2e53ff74c081ef90091e1.zip FreeBSD-src-574e70a7ab89c27012f2e53ff74c081ef90091e1.tar.gz |
MFC: Merge sendmail 8.15.2
Approved by: re (gjb)
Diffstat (limited to 'contrib/sendmail/makemap/makemap.c')
-rw-r--r-- | contrib/sendmail/makemap/makemap.c | 100 |
1 files changed, 48 insertions, 52 deletions
diff --git a/contrib/sendmail/makemap/makemap.c b/contrib/sendmail/makemap/makemap.c index fa88944..cf1f62c 100644 --- a/contrib/sendmail/makemap/makemap.c +++ b/contrib/sendmail/makemap/makemap.c @@ -234,71 +234,67 @@ main(argc, argv) } #if HASFCHOWN - if (!unmake && geteuid() == 0) + /* Find TrustedUser value in sendmail.cf */ + if ((cfp = sm_io_open(SmFtStdio, SM_TIME_DEFAULT, cfile, SM_IO_RDONLY, + NULL)) == NULL) { - /* Find TrustedUser value in sendmail.cf */ - if ((cfp = sm_io_open(SmFtStdio, SM_TIME_DEFAULT, cfile, - SM_IO_RDONLY, NULL)) == NULL) - { - sm_io_fprintf(smioerr, SM_TIME_DEFAULT, - "makemap: %s: %s\n", - cfile, sm_errstring(errno)); - exit(EX_NOINPUT); - } - while (sm_io_fgets(cfp, SM_TIME_DEFAULT, buf, sizeof(buf)) >= 0) - { - register char *b; + sm_io_fprintf(smioerr, SM_TIME_DEFAULT, "makemap: %s: %s\n", + cfile, sm_errstring(errno)); + exit(EX_NOINPUT); + } + while (sm_io_fgets(cfp, SM_TIME_DEFAULT, buf, sizeof(buf)) >= 0) + { + register char *b; - if ((b = strchr(buf, '\n')) != NULL) - *b = '\0'; + if ((b = strchr(buf, '\n')) != NULL) + *b = '\0'; - b = buf; - switch (*b++) + b = buf; + switch (*b++) + { + case 'O': /* option */ + if (strncasecmp(b, " TrustedUser", 12) == 0 && + !(isascii(b[12]) && isalnum(b[12]))) { - case 'O': /* option */ - if (strncasecmp(b, " TrustedUser", 12) == 0 && - !(isascii(b[12]) && isalnum(b[12]))) + b = strchr(b, '='); + if (b == NULL) + continue; + while (isascii(*++b) && isspace(*b)) + continue; + if (isascii(*b) && isdigit(*b)) + TrustedUid = atoi(b); + else { - b = strchr(b, '='); - if (b == NULL) - continue; - while (isascii(*++b) && isspace(*b)) - continue; - if (isascii(*b) && isdigit(*b)) - TrustedUid = atoi(b); + TrustedUid = 0; + pw = getpwnam(b); + if (pw == NULL) + (void) sm_io_fprintf(smioerr, + SM_TIME_DEFAULT, + "TrustedUser: unknown user %s\n", b); else - { - TrustedUid = 0; - pw = getpwnam(b); - if (pw == NULL) - (void) sm_io_fprintf(smioerr, - SM_TIME_DEFAULT, - "TrustedUser: unknown user %s\n", b); - else - TrustedUid = pw->pw_uid; - } + TrustedUid = pw->pw_uid; + } # ifdef UID_MAX - if (TrustedUid > UID_MAX) - { - (void) sm_io_fprintf(smioerr, - SM_TIME_DEFAULT, - "TrustedUser: uid value (%ld) > UID_MAX (%ld)", - (long) TrustedUid, - (long) UID_MAX); - TrustedUid = 0; - } -# endif /* UID_MAX */ - break; + if (TrustedUid > UID_MAX) + { + (void) sm_io_fprintf(smioerr, + SM_TIME_DEFAULT, + "TrustedUser: uid value (%ld) > UID_MAX (%ld)", + (long) TrustedUid, + (long) UID_MAX); + TrustedUid = 0; } +# endif /* UID_MAX */ + break; + } - default: - continue; - } + default: + continue; } - (void) sm_io_close(cfp, SM_TIME_DEFAULT); } + (void) sm_io_close(cfp, SM_TIME_DEFAULT); #endif /* HASFCHOWN */ if (!params.smdbp_allow_dup && !allowreplace) |