]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
* Apply upstream fix to use a single high-numbered group for the PAG on
authorRuss Allbery <rra@debian.org>
Thu, 15 Mar 2007 01:34:20 +0000 (01:34 +0000)
committerRuss Allbery <rra@debian.org>
Thu, 15 Mar 2007 01:34:20 +0000 (01:34 +0000)
  2.6 kernels and sort the group properly.  Fixes AFS-caused group
  ordering problems that could lead the kernel to ignore some group
  membership for users.  (Closes: #414911)

debian/changelog
src/afs/LINUX/osi_groups.c
src/afs/LINUX/osi_machdep.h
src/afs/afs_osi_pag.c
src/afs/afs_prototypes.h

index 6c778c710d22e5b09d122d9d16347956436d5a94..8e40169b86dea7afdaad2662d2ac919e78d493ec 100644 (file)
@@ -1,5 +1,9 @@
-openafs (1.4.2-6) unstable; urgency=low
+openafs (1.4.2-6) unstable; urgency=medium
 
+  * Apply upstream fix to use a single high-numbered group for the PAG on
+    2.6 kernels and sort the group properly.  Fixes AFS-caused group
+    ordering problems that could lead the kernel to ignore some group
+    membership for users.  (Closes: #414911)
   * Apply upstream fix for segfaults in pts rename.  (Closes: #409184)
   * Translation updates:
     - Dutch, thanks cobaco.  (Closes: #413701)
index 3aee872cb377a9b00e422b8ba8f1e06b015aa91b..d345e3f96c412508f2892b32503ba74284c729b8 100644 (file)
@@ -29,6 +29,12 @@ RCSID
 #include "h/smp_lock.h"
 #endif
 
+#ifdef AFS_LINUX26_ONEGROUP_ENV
+#define NUMPAGGROUPS 1
+#else
+#define NUMPAGGROUPS 2
+#endif
+
 #if defined(AFS_LINUX26_ENV)
 static int
 afs_setgroups(cred_t **cr, struct group_info *group_info, int change_parent)
@@ -160,26 +166,54 @@ __setpag(cred_t **cr, afs_uint32 pagvalue, afs_uint32 *newpag,
     gid_t g0, g1;
     struct group_info *tmp;
     int i;
+#ifdef AFS_LINUX26_ONEGROUP_ENV
+    int j;
+#endif
+
     int need_space = 0;
 
     group_info = afs_getgroups(*cr);
-    if (group_info->ngroups < 2
-       ||  afs_get_pag_from_groups(GROUP_AT(group_info, 0),
-                                   GROUP_AT(group_info, 1)) == NOPAG) 
+    if (group_info->ngroups < NUMPAGGROUPS
+       ||  afs_get_pag_from_groups(
+#ifdef AFS_LINUX26_ONEGROUP_ENV
+           group_info
+#else
+           GROUP_AT(group_info, 0) ,GROUP_AT(group_info, 1)
+#endif
+                                   ) == NOPAG) 
        /* We will have to make sure group_info is big enough for pag */
-      need_space = 2;
+       need_space = NUMPAGGROUPS;
 
     tmp = groups_alloc(group_info->ngroups + need_space);
     
+    *newpag = (pagvalue == -1 ? genpag() : pagvalue);
+#ifdef AFS_LINUX26_ONEGROUP_ENV
+    for (i = 0, j = 0; i < group_info->ngroups; ++i) {
+       int ths = GROUP_AT(group_info, i);
+       int last = i > 0 ? GROUP_AT(group_info, i-1) : 0;
+       if ((ths >> 24) == 'A')
+           continue;
+       if (last <= *newpag && ths > *newpag) {
+          GROUP_AT(tmp, j) = *newpag;
+          j++;
+       }
+       GROUP_AT(tmp, j) = ths;
+       j++;
+    }
+    if (j != i + need_space)
+        GROUP_AT(tmp, j) = *newpag;
+#else
     for (i = 0; i < group_info->ngroups; ++i)
       GROUP_AT(tmp, i + need_space) = GROUP_AT(group_info, i);
+#endif
     put_group_info(group_info);
     group_info = tmp;
 
-    *newpag = (pagvalue == -1 ? genpag() : pagvalue);
+#ifndef AFS_LINUX26_ONEGROUP_ENV
     afs_get_groups_from_pag(*newpag, &g0, &g1);
     GROUP_AT(group_info, 0) = g0;
     GROUP_AT(group_info, 1) = g1;
+#endif
 
     afs_setgroups(cr, group_info, change_parent);
 
@@ -524,15 +558,19 @@ static int afs_pag_instantiate(struct key *key, const void *data, size_t datalen
     if (datalen != sizeof(afs_uint32) || !data)
        goto error;
 
-    if (current->group_info->ngroups < 2)
+    if (current->group_info->ngroups < NUMPAGGROUPS)
        goto error;
 
     /* ensure key being set matches current pag */
 
+#ifdef AFS_LINUX26_ONEGROUP_ENV
+    pag = afs_get_pag_from_groups(current->group_info);
+#else
     g0 = GROUP_AT(current->group_info, 0);
     g1 = GROUP_AT(current->group_info, 1);
 
     pag = afs_get_pag_from_groups(g0, g1);
+#endif
     if (pag == NOPAG)
        goto error;
 
index 23d5b95f2ecb4567dc7073d3ff581dbe0183c71a..c2cbe0ea2ce4fea57e94f3cc2097d8410fd0fc4d 100644 (file)
 #ifndef OSI_MACHDEP_H_
 #define OSI_MACHDEP_H_
 
+#include <linux/version.h>
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,4)
+#define AFS_LINUX26_ONEGROUP_ENV 1
+#endif
+
 /* Only needed for xdr.h in glibc 2.1.x */
 #ifndef quad_t
 #define quad_t __quad_t
index 2c3de0db05cf54e9678b9fd99b6da4717494ece9..3f0543dd9ec146cd7026e3c22300111b1e108eee 100644 (file)
@@ -44,7 +44,13 @@ afs_uint32 pagCounter = 1;
 afs_uint32 pagCounter = 0;
 #endif /* UKERNEL && AFS_WEB_ENHANCEMENTS */
 
-/* Local variables */
+#ifdef AFS_LINUX26_ONEGROUP_ENV
+#define NUMPAGGROUPS 1
+#else
+#define NUMPAGGROUPS 2
+#endif
+
+ /* Local variables */
 
 /*
  * Pags are implemented as follows: the set of groups whose long
@@ -363,6 +369,7 @@ afs_setpag_val(int pagval)
     return (code);
 }
 
+#ifndef AFS_LINUX26_ONEGROUP_ENV
 int
 afs_getpag_val()
 {
@@ -375,9 +382,9 @@ afs_getpag_val()
     pagvalue = afs_get_pag_from_groups(gidset0, gidset1);
     return pagvalue;
 }
+#endif
 #endif /* UKERNEL && AFS_WEB_ENHANCEMENTS */
 
-
 /* Note - needs to be available on AIX, others can be static - rework this */
 #if defined(AFS_OSF_ENV) || defined(AFS_DARWIN_ENV) || defined(AFS_XBSD_ENV)
 int
@@ -430,7 +437,22 @@ afs_InitReq(register struct vrequest *av, struct AFS_UCRED *acred)
     return 0;
 }
 
+#ifdef AFS_LINUX26_ONEGROUP_ENV
+afs_uint32
+afs_get_pag_from_groups(struct group_info *group_info)
+{
+    afs_uint32 g0 = 0;
+    afs_uint32 i;
+    AFS_STATCNT(afs_get_pag_from_groups);
+    for (i = 0; (i < group_info->ngroups && 
+                (g0 = GROUP_AT(group_info, i)) != (gid_t) NOGROUP); i++) {
+       if (((g0 >> 24) & 0xff) == 'A')
+           return g0;
+    }
+    return NOPAG;
+}
 
+#else
 
 afs_uint32
 afs_get_pag_from_groups(gid_t g0a, gid_t g1a)
@@ -457,7 +479,7 @@ afs_get_pag_from_groups(gid_t g0a, gid_t g1a)
     }
     return NOPAG;
 }
-
+#endif /* AFS_LINUX26_ONEGROUP_ENV */
 
 void
 afs_get_groups_from_pag(afs_uint32 pag, gid_t * g0p, gid_t * g1p)
@@ -466,6 +488,10 @@ afs_get_groups_from_pag(afs_uint32 pag, gid_t * g0p, gid_t * g1p)
 
 
     AFS_STATCNT(afs_get_groups_from_pag);
+#ifdef AFS_LINUX26_ONEGROUP_ENV
+    *g0p = pag;
+    *g1p = 0;
+#else
 #if !defined(UKERNEL) || !defined(AFS_WEB_ENHANCEMENTS)
     pag &= 0x7fffffff;
 #endif /* UKERNEL && AFS_WEB_ENHANCEMENTS */
@@ -475,6 +501,7 @@ afs_get_groups_from_pag(afs_uint32 pag, gid_t * g0p, gid_t * g1p)
     g1 |= ((pag >> 28) % 3) << 14;
     *g0p = g0 + 0x3f00;
     *g1p = g1 + 0x3f00;
+#endif
 }
 
 
@@ -507,7 +534,7 @@ PagInCred(const struct AFS_UCRED *cred)
        return NOPAG;
     }
 #elif defined(AFS_LINUX26_ENV)
-    if (cred->cr_group_info->ngroups < 2) {
+    if (cred->cr_group_info->ngroups < NUMPAGGROUPS) {
        pag = NOPAG;
        goto out;
     }
@@ -520,6 +547,7 @@ PagInCred(const struct AFS_UCRED *cred)
 #if defined(AFS_AIX51_ENV)
     g0 = cred->cr_groupset.gs_union.un_groups[0];
     g1 = cred->cr_groupset.gs_union.un_groups[1];
+#elif defined(AFS_LINUX26_ONEGROUP_ENV)
 #elif defined(AFS_LINUX26_ENV)
     g0 = GROUP_AT(cred->cr_group_info, 0);
     g1 = GROUP_AT(cred->cr_group_info, 1);
@@ -528,7 +556,11 @@ PagInCred(const struct AFS_UCRED *cred)
     g1 = cred->cr_groups[1];
 #endif
 #endif
+#if defined(AFS_LINUX26_ONEGROUP_ENV)
+    pag = (afs_int32) afs_get_pag_from_groups(cred->cr_group_info);
+#else
     pag = (afs_int32) afs_get_pag_from_groups(g0, g1);
+#endif
 out:
 #if defined(AFS_LINUX26_ENV) && defined(LINUX_KEYRING_SUPPORT)
     if (pag == NOPAG) {
index 188b11845faa49f978c058b35f4fbecf8e6fff0b..74d7c6c74efb62bcd04781473f5a21f6b5667081 100644 (file)
@@ -508,7 +508,13 @@ extern int AddPag(struct proc *p, afs_int32 aval, struct AFS_UCRED **credpp);
 extern int AddPag(afs_int32 aval, struct AFS_UCRED **credpp);
 #endif
 extern int afs_InitReq(register struct vrequest *av, struct AFS_UCRED *acred);
+#if defined(UKERNEL) && defined(AFS_WEB_ENHANCEMENTS)
 extern afs_uint32 afs_get_pag_from_groups(gid_t g0a, gid_t g1a);
+#else
+#ifdef AFS_LINUX26_ONEGROUP_ENV
+extern afs_uint32 afs_get_pag_from_groups(struct group_info *gi);
+#endif
+#endif
 extern void afs_get_groups_from_pag(afs_uint32 pag, gid_t * g0p, gid_t * g1p);
 extern afs_int32 PagInCred(const struct AFS_UCRED *cred);