]> arthur.barton.de Git - netatalk.git/blobdiff - etc/afpd/auth.c
Merge from 2-1
[netatalk.git] / etc / afpd / auth.c
index 3af6d6660d7c6e57eed172f13d69ee1805c53d2b..8dc59ec2ed926665fbb8dcb8eaf3d278878a5612 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: auth.c,v 1.70 2009-11-22 11:52:38 franklahm Exp $
+ * $Id: auth.c,v 1.71 2009-11-30 15:30:47 franklahm Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -48,7 +48,7 @@ extern void afp_get_cmdline( int *ac, char ***av );
 #include "status.h"
 #include "fork.h"
 #include "extattrs.h"
-#ifdef HAVE_NFSv4_ACLS
+#ifdef HAVE_ACLS
 #include "acls.h"
 #endif
 
@@ -210,11 +210,11 @@ static int set_auth_switch(int expired)
         afp_switch = postauth_switch;
         switch (afp_version) {
         case 32:
-#ifdef HAVE_NFSv4_ACLS
+#ifdef HAVE_ACLS
             uam_afpserver_action(AFP_GETACL, UAM_AFPSERVER_POSTAUTH, afp_getacl, NULL);
             uam_afpserver_action(AFP_SETACL, UAM_AFPSERVER_POSTAUTH, afp_setacl, NULL);
             uam_afpserver_action(AFP_ACCESS, UAM_AFPSERVER_POSTAUTH, afp_access, NULL);
-#endif
+#endif /* HAVE_ACLS */
             uam_afpserver_action(AFP_GETEXTATTR, UAM_AFPSERVER_POSTAUTH, afp_getextattr, NULL);
             uam_afpserver_action(AFP_SETEXTATTR, UAM_AFPSERVER_POSTAUTH, afp_setextattr, NULL);
             uam_afpserver_action(AFP_REMOVEATTR, UAM_AFPSERVER_POSTAUTH, afp_remextattr, NULL);
@@ -389,11 +389,33 @@ static int login(AFPObj *obj, struct passwd *pwd, void (*logout)(void), int expi
     }
 #endif /* TRU64 */
 
-    /* There's probably a better way to do this, but for now, we just
-       play root */
+    if (ngroups > 0) {
+        #define GROUPSTR_BUFSIZE 1024
+        char groupsstr[GROUPSTR_BUFSIZE];
+        char *s = groupsstr;
+        int j = GROUPSTR_BUFSIZE;
+
+        int n = snprintf(groupsstr, GROUPSTR_BUFSIZE, "%u", groups[0]);
+        j -= n;
+        s += n;
+
+        for (int i = 1; i < ngroups; i++) {
+            n = snprintf(s, j, ", %u", groups[i]);
+            if (n == j) {
+                /* Buffer full */
+                LOG(log_debug, logtype_afpd, "login: group string buffer overflow");
+                break;
+            }
+            j -= n;
+            s += n;
+        }
+        LOG(log_debug, logtype_afpd, "login: %u supplementary groups: %s", ngroups, groupsstr);
+    }
 
+    /* There's probably a better way to do this, but for now, we just play root */
 #ifdef ADMIN_GRP
-    if (admin) uuid = 0;
+    if (admin)
+        uuid = 0;
     else
 #endif /* ADMIN_GRP */
         uuid = pwd->pw_uid;
@@ -977,10 +999,10 @@ int afp_getuserinfo(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *rbuf,
         *rbuflen += sizeof(id);
     }
 
-#ifdef HAVE_NFSv4_ACLS
+#ifdef HAVE_ACLS
     if (bitmap & USERIBIT_UUID) {
         int ret;
-        uuid_t uuid;
+        atalk_uuid_t uuid;
         char *uuidstring;
 
         if ( ! (obj->options.flags & OPTION_UUID))
@@ -999,7 +1021,7 @@ int afp_getuserinfo(AFPObj *obj _U_, char *ibuf, size_t ibuflen _U_, char *rbuf,
         rbuf += UUID_BINSIZE;
         *rbuflen += UUID_BINSIZE;
     }
-#endif
+#endif /* HAVE_ACLS */
 
     LOG(log_debug, logtype_afpd, "END afp_getuserinfo:");
     return AFP_OK;