Move changing of uid to separate function.
git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@4797 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
@@ -12,6 +12,22 @@ RCSID("$Id$");
|
|||||||
* save a stream pointer for it.
|
* save a stream pointer for it.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
void
|
||||||
|
changeuser(POP *p, struct passwd *pwd)
|
||||||
|
{
|
||||||
|
/* Now we run as the user. */
|
||||||
|
if (pwd) {
|
||||||
|
setuid(pwd->pw_uid);
|
||||||
|
setgid(pwd->pw_gid);
|
||||||
|
}
|
||||||
|
#ifdef DEBUG
|
||||||
|
if(p->debug)
|
||||||
|
pop_log(p, POP_DEBUG,"uid = %u, gid = %u",
|
||||||
|
(unsigned)getuid(),
|
||||||
|
(unsigned)getgid());
|
||||||
|
#endif /* DEBUG */
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
pop_dropcopy(POP *p, struct passwd *pwp)
|
pop_dropcopy(POP *p, struct passwd *pwp)
|
||||||
{
|
{
|
||||||
@@ -65,17 +81,7 @@ pop_dropcopy(POP *p, struct passwd *pwp)
|
|||||||
fclose(tf);
|
fclose(tf);
|
||||||
unlink(template);
|
unlink(template);
|
||||||
|
|
||||||
/* Now we run as the user. */
|
changeuser(p, pwp);
|
||||||
if (pwp) {
|
|
||||||
setuid(pwp->pw_uid);
|
|
||||||
setgid(pwp->pw_gid);
|
|
||||||
}
|
|
||||||
#ifdef DEBUG
|
|
||||||
if(p->debug)
|
|
||||||
pop_log(p, POP_DEBUG,"uid = %u, gid = %u",
|
|
||||||
(unsigned)getuid(),
|
|
||||||
(unsigned)getgid());
|
|
||||||
#endif /* DEBUG */
|
|
||||||
|
|
||||||
/* Open for append, this solves the crash recovery problem */
|
/* Open for append, this solves the crash recovery problem */
|
||||||
if ((dfd = open(p->temp_drop,O_RDWR|O_APPEND|O_CREAT,0600)) == -1){
|
if ((dfd = open(p->temp_drop,O_RDWR|O_APPEND|O_CREAT,0600)) == -1){
|
||||||
|
Reference in New Issue
Block a user