From 32b10e9e33c10dd3223fde2541bbfea0852c2af5 Mon Sep 17 00:00:00 2001 From: "Eric S. Raymond" Date: Mon, 14 Oct 1996 05:12:35 +0000 Subject: Try to change permissions when delivering from root. svn path=/trunk/; revision=330 --- fetchmail.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'fetchmail.c') 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) -- cgit v1.2.3