]> arthur.barton.de Git - netatalk.git/commitdiff
NGROUPS is not always the maximum number of groups for a user, use a 'calloced'
authordidg <didg>
Tue, 11 Jan 2005 20:58:42 +0000 (20:58 +0000)
committerdidg <didg>
Tue, 11 Jan 2005 20:58:42 +0000 (20:58 +0000)
array, not freed but afpd exit on logout.

etc/afpd/auth.c
etc/afpd/auth.h

index ef92c64d3c7a89cc88077846f1e8a3c742e8aed8..2470133202a2ab5ae8ae917f996a22dc9c5391e4 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: auth.c,v 1.44.2.3.2.15 2004-07-01 01:27:34 didg Exp $
+ * $Id: auth.c,v 1.44.2.3.2.15.2.1 2005-01-11 20:58:42 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -52,17 +52,18 @@ int afp_version = 11;
 static int afp_version_index;
 
 uid_t  uuid;
-#if defined( __svr4__ ) && !defined( NGROUPS )
-#define NGROUPS NGROUPS_MAX
-#endif /* __svr4__ NGROUPS */
+
 #if defined( sun ) && !defined( __svr4__ ) || defined( ultrix )
-int    groups[ NGROUPS ];
+
+int    *groups;
+#define GROUPS_SIZE sizeof(int)
+
 #else /* sun __svr4__ ultrix */
-#if defined( __svr4__ ) && !defined( NGROUPS )
-#define NGROUPS        NGROUPS_MAX
-#endif /* __svr4__ NGROUPS */
-gid_t  groups[ NGROUPS ];
+
+gid_t  *groups;
+#define GROUPS_SIZE sizeof(gid_t)
 #endif /* sun ultrix */
+
 int    ngroups;
 
 /*
@@ -281,7 +282,17 @@ static int login(AFPObj *obj, struct passwd *pwd, void (*logout)(void), int expi
 
     /* Basically if the user is in the admin group, we stay root */
 
-    if (( ngroups = getgroups( NGROUPS, groups )) < 0 ) {
+    if (( ngroups = getgroups( 0, NULL )) < 0 ) {
+        LOG(log_error, logtype_afpd, "login: %s getgroups: %s", pwd->pw_name, strerror(errno) );
+        return AFPERR_BADUAM;
+    }
+    
+    if ( NULL == (groups = calloc(ngroups, GROUPS_SIZE)) ) {
+        LOG(log_error, logtype_afpd, "login: %s calloc: %d", ngroups);
+        return AFPERR_BADUAM;
+    }
+
+    if (( ngroups = getgroups( ngroups, groups )) < 0 ) {
         LOG(log_error, logtype_afpd, "login: %s getgroups: %s", pwd->pw_name, strerror(errno) );
         return AFPERR_BADUAM;
     }
index cb6bd5077f58f2e09e2673c847cbea1d2d8be202..9f6adb7312eec24eaa8da8817022942f8eb7f451 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: auth.h,v 1.5 2003-03-12 15:07:02 didg Exp $
+ * $Id: auth.h,v 1.5.8.1 2005-01-11 20:58:42 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * All Rights Reserved.  See COPYRIGHT.
@@ -29,13 +29,10 @@ struct afp_versions {
 #define USERIBIT_ALL   (USERIBIT_USER | USERIBIT_GROUP)
 
 extern uid_t    uuid;
-#if defined( __svr4__ ) && !defined( NGROUPS )
-#define NGROUPS        NGROUPS_MAX
-#endif /*__svr4__ NGROUPS*/
 #if defined( sun ) && !defined( __svr4__ ) || defined( ultrix )
-extern int     groups[ NGROUPS ];
+extern int     *groups;
 #else /*sun __svr4__ ultrix*/
-extern gid_t   groups[ NGROUPS ];
+extern gid_t   *groups;
 #endif /*sun __svr4__ ultrix*/
 extern int     ngroups;