aboutsummaryrefslogtreecommitdiffstats
path: root/fetchmail.c
diff options
context:
space:
mode:
authorEric S. Raymond <esr@thyrsus.com>1996-10-14 05:12:35 +0000
committerEric S. Raymond <esr@thyrsus.com>1996-10-14 05:12:35 +0000
commit32b10e9e33c10dd3223fde2541bbfea0852c2af5 (patch)
tree1c19d2fce7dcf75617c2fc17455d801ddf0279c3 /fetchmail.c
parent2bdac43bdd6dbcc9bcd03083bf7384e3c64e2cfc (diff)
downloadfetchmail-32b10e9e33c10dd3223fde2541bbfea0852c2af5.tar.gz
fetchmail-32b10e9e33c10dd3223fde2541bbfea0852c2af5.tar.bz2
fetchmail-32b10e9e33c10dd3223fde2541bbfea0852c2af5.zip
Try to change permissions when delivering from root.
svn path=/trunk/; revision=330
Diffstat (limited to 'fetchmail.c')
-rw-r--r--fetchmail.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/fetchmail.c b/fetchmail.c
index b21cdaef..b3a8046a 100644
--- a/fetchmail.c
+++ b/fetchmail.c
@@ -86,6 +86,7 @@ char **argv;
struct hostrec def_opts;
int parsestatus, implicitmode;
char *servername, *user, *home, *tmpdir, tmpbuf[BUFSIZ];
+ struct passwd *pw;
FILE *lockfp;
pid_t pid;
@@ -96,8 +97,6 @@ char **argv;
if ((user == (char *)NULL) || (home = getenv("HOME")) == (char *)NULL)
{
- struct passwd *pw;
-
if ((pw = getpwuid(getuid())) != NULL)
{
user = pw->pw_name;
@@ -194,7 +193,13 @@ char **argv;
/* if rc file didn't supply a localname, default appropriately */
if (!hostp->localname[0])
- strcpy(hostp->localname, hostp->remotename);
+ strcpy(hostp->localname, user);
+
+ /* check that delivery is going to a real local user */
+ if ((pw = getpwnam(user)) == (struct passwd *)NULL)
+ exit(PS_SYNTAX); /* has to be from bad rc file */
+ else
+ hostp->uid = pw->pw_uid;
/* sanity checks */
if (hostp->port < 0)