]> arthur.barton.de Git - netatalk.git/commitdiff
seteuid back to our login user in logout in case there're volumes' prexec_close scripts.
authordidg <didg>
Sun, 25 Oct 2009 07:18:11 +0000 (07:18 +0000)
committerdidg <didg>
Sun, 25 Oct 2009 07:18:11 +0000 (07:18 +0000)
etc/afpd/afp_asp.c
etc/afpd/afp_dsi.c
etc/afpd/auth.c
etc/afpd/globals.h

index 23669c642a9444284db5802f1956aac8d26c5f08..dddb3da5030032b4d68cc3265ee0b306da58da66 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: afp_asp.c,v 1.26 2009-10-14 02:24:05 didg Exp $
+ * $Id: afp_asp.c,v 1.27 2009-10-25 07:18:11 didg Exp $
  *
  * Copyright (c) 1997 Adrian Sun (asun@zoology.washington.edu)
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
@@ -51,6 +51,10 @@ static void afp_asp_close(AFPObj *obj)
 {
     ASP asp = obj->handle;
 
+    if (seteuid( obj->uid ) < 0) {
+        LOG(log_error, logtype_afpd, "can't seteuid back %s", strerror(errno));
+        exit(EXITERR_SYS);
+    }
     close_all_vol();
     if (obj->options.authprintdir) afp_authprint_remove(obj);
 
index 3a73159aed1bf8c3ad08786f60ac42f9844ef566..390a2aecbec04c5b96166c53a83f47683da33e7a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: afp_dsi.c,v 1.46 2009-10-25 06:12:51 didg Exp $
+ * $Id: afp_dsi.c,v 1.47 2009-10-25 07:18:12 didg Exp $
  *
  * Copyright (c) 1999 Adrian Sun (asun@zoology.washington.edu)
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
@@ -59,7 +59,14 @@ static void afp_dsi_close(AFPObj *obj)
 {
     DSI *dsi = obj->handle;
 
-    /* XXX we have to check we are not root here */
+    /* we may have been called from a signal handler caught when afpd was running
+     * as uid 0, that's the wrong user for volume's prexec_close scripts if any,
+     * restore our login user
+     */
+    if (seteuid( obj->uid ) < 0) {
+        LOG(log_error, logtype_afpd, "can't seteuid back %s", strerror(errno));
+        exit(EXITERR_SYS);
+    }
     close_all_vol();
     if (obj->logout)
         (*obj->logout)();
index b3748f839103fd5ce55dc37711e908ffa03d1c54..52eb0b59496dea864290fb6940f59db0b89a8841 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: auth.c,v 1.68 2009-10-15 10:43:13 didg Exp $
+ * $Id: auth.c,v 1.69 2009-10-25 07:18:12 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -384,7 +384,8 @@ static int login(AFPObj *obj, struct passwd *pwd, void (*logout)(void), int expi
         uuid = pwd->pw_uid;
 
     set_auth_switch(expired);
-
+    /* save our euid, we need it for preexec_close */
+    obj->uid = geteuid();
     obj->logout = logout;
 
 #ifdef FORCE_UIDGID
index 76ffc07eda90dda0afae1d90047bf099f3a502c3..2ab33e6606aafa196053bd2a432755be1e293522 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: globals.h,v 1.28 2009-10-15 10:43:13 didg Exp $
+ * $Id: globals.h,v 1.29 2009-10-25 07:18:12 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -101,6 +101,7 @@ typedef struct _AFPObj {
     char oldtmp[AFPOBJ_TMPSIZ + 1], newtmp[AFPOBJ_TMPSIZ + 1];
     void *uam_cookie; /* cookie for uams */
     struct session_info  sinfo;
+    uid_t uid;         /* client running user id */
 
 #ifdef FORCE_UIDGID
     int                 force_uid;