[611] in arla-drinkers
Updated setgroups patch
daemon@ATHENA.MIT.EDU (Nathan Neulinger)
Wed Feb 17 22:09:27 1999
From owner-arla-drinkers@stacken.kth.se Thu Feb 18 03:09:26 1999
Return-Path: <owner-arla-drinkers@stacken.kth.se>
Delivered-To: arla-drinkers-mtg@bloom-picayune.mit.edu
Received: (qmail 9867 invoked from network); 18 Feb 1999 03:09:25 -0000
Received: from unknown (HELO sundance.stacken.kth.se) (130.237.234.41)
by bloom-picayune.mit.edu with SMTP; 18 Feb 1999 03:09:25 -0000
Received: (from majordom@localhost)
by sundance.stacken.kth.se (8.8.8/8.8.8) id EAA22634
for arla-drinkers-list; Thu, 18 Feb 1999 04:02:00 +0100 (MET)
Received: from sigma.rollanet.org (sigma.rollanet.org [192.55.114.7])
by sundance.stacken.kth.se (8.8.8/8.8.8) with SMTP id EAA22629
for <arla-drinkers@stacken.kth.se>; Thu, 18 Feb 1999 04:01:46 +0100 (MET)
Received: (qmail 7159 invoked from network); 18 Feb 1999 03:01:38 -0000
Received: from static-nneul.rollanet.org (HELO umr.edu) (nneul@192.55.114.233)
by mx.rollanet.org with SMTP; 18 Feb 1999 03:01:38 -0000
Message-ID: <36CB828F.4C9A070E@umr.edu>
Date: Wed, 17 Feb 1999 21:01:35 -0600
From: Nathan Neulinger <nneul@umr.edu>
X-Mailer: Mozilla 4.5 [en] (X11; I; Linux 2.2.0-pre7 i686)
X-Accept-Language: en
MIME-Version: 1.0
To: arla-drinkers@stacken.kth.se
Subject: Updated setgroups patch
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Sender: owner-arla-drinkers@stacken.kth.se
Precedence: bulk
This is based off the 1999-02-13 snapshot. This also has Magnus's
requested changes to better conform to existing coding standards and
patch minimization.
Effect of the patch:
@ARLA_KNFS@ option in configure.in and xfs/bsd/Makefile.in changed to
XFS_CFLAGS
support for transarc style setgroups behavior. This causes the
setgroups system
call (and therefore the initgroups and setgroups library calls) to
retain the current pag. This is needed for programs like 'su' and
'ksu' to
be able to continue to access afs. The necessary code has been added
to the xfs_syscalls.c file for linux only, but should be easy enough
to
adapt for other kernels.
configure option --enable-setgroups added to add support for transarc
style
setgroups behavior
added XFS_CFLAGS to DEFS in xfs/linux/Makefile.in
-- Nathan
-----CUT HERE-----
diff --exclude=configure -ur arla-1999-02-13/configure.in
arla-1999-02-13-patched/configure.in
--- arla-1999-02-13/configure.in Fri Feb 12 19:56:27 1999
+++ arla-1999-02-13-patched/configure.in Wed Feb 17 20:31:31 1999
@@ -46,6 +46,12 @@
AC_MSG_RESULT(none)
fi
+dnl
+dnl Initially no extra options for xfs compile
+dnl
+XFS_CFLAGS=""
+AC_SUBST(XFS_CFLAGS)
+
dnl
dnl See if there is any X11 present
dnl
@@ -355,11 +361,18 @@
# Do we want knfs ?
-ARLA_KNFS=""
AC_ARG_ENABLE(knfs,
[ --enable-knfs make afs nfs-mountable],
-[ARLA_KNFS="-DARLA_KNFS"])
-AC_SUBST(ARLA_KNFS)
+[XFS_CFLAGS="$XFS_CFLAGS -DARLA_KNFS"
+AC_SUBST(XFS_CFLAGS)])
+
+dnl
+dnl If we want transarc style setgroups behavior
+dnl
+AC_ARG_ENABLE(setgroups,
+[ --enable-setgroups make setgroups system call retain PAG],
+[XFS_CFLAGS="$XFS_CFLAGS -DARLA_SETGROUPS"
+AC_SUBST(XFS_CFLAGS)])
dnl
dnl If we want to use pthreads
diff --exclude=configure -ur arla-1999-02-13/xfs/bsd/Makefile.in
arla-1999-02-13-patched/xfs/bsd/Makefile.in
--- arla-1999-02-13/xfs/bsd/Makefile.in Thu Feb 4 15:08:42 1999
+++ arla-1999-02-13-patched/xfs/bsd/Makefile.in Wed Feb 17 20:41:26 1999
@@ -36,7 +36,7 @@
-I$(srcdir)/../include \
@KRB_INC_FLAGS@
-DEFS = @DEFS@ $(INCDEFS) -DXFS_DEBUG @ARLA_KNFS@
+DEFS = @DEFS@ $(INCDEFS) -DXFS_DEBUG @XFS_CFLAGS@
@OSF1_TRUE@CFLAGS= @KERNEL_CFLAGS@
@OSF1_FALSE@CFLAGS = @CFLAGS@ @KERNEL_CFLAGS@ -Wno-unused
diff --exclude=configure -ur arla-1999-02-13/xfs/linux/Makefile.in
arla-1999-02-13-patched/xfs/linux/Makefile.in
--- arla-1999-02-13/xfs/linux/Makefile.in Fri Jan 1 23:46:39 1999
+++ arla-1999-02-13-patched/xfs/linux/Makefile.in Wed Feb 17 20:41:44
1999
@@ -28,7 +28,7 @@
XFS_BIN = $(MODULE)
-DEFS = @DEFS@ @KERNEL_CFLAGS@ -DDEBUG
+DEFS = @DEFS@ @KERNEL_CFLAGS@ -DDEBUG @XFS_CFLAGS@
INC = -I$(srcdir)/../include \
-I../../include \
-I$(srcdir)/../../include
diff --exclude=configure -ur arla-1999-02-13/xfs/linux/xfs_syscalls.c
arla-1999-02-13-patched/xfs/linux/xfs_syscalls.c
--- arla-1999-02-13/xfs/linux/xfs_syscalls.c Sun Jan 24 16:53:56 1999
+++ arla-1999-02-13-patched/xfs/linux/xfs_syscalls.c Wed Feb 17 20:43:49
1999
@@ -106,7 +106,8 @@
}
static int
-xfs_setpag_call(void)
+xfs_set_pag(int part_one,
+ int part_two)
{
int i ;
@@ -152,8 +153,16 @@
}
- current->groups[0] = pag_part_one ;
- current->groups[1] = pag_part_two++ ;
+ current->groups[0] = part_one ;
+ current->groups[1] = part_two ;
+
+ return 0;
+}
+
+static int
+xfs_setpag_call(void)
+{
+ xfs_set_pag(pag_part_one, pag_part_two++);
if (pag_part_two > XFS_PAG2_ULIM) {
pag_part_one++ ;
@@ -541,21 +550,54 @@
return error;
}
-typedef int (*sys_call_routine)(int operation,
+typedef int (*afs_sys_call_routine)(int operation,
char *a_pathP,
int a_opcode,
struct ViceIoctl *a_paramsP,
int a_followSymlinks);
+static afs_sys_call_routine *old_afs_syscall=NULL;
-extern sys_call_routine sys_call_table[];
+#if defined(ARLA_SETGROUPS)
+typedef int (*setgroups_sys_call_routine)(int gidsetsize,
+ gid_t *grouplist);
+setgroups_sys_call_routine old_setgroups_syscall=NULL;
+#endif
-static sys_call_routine old_afs_syscall=NULL;
+extern void *sys_call_table[];
+
+#if defined(ARLA_SETGROUPS)
+asmlinkage int
+sys_pag_setgroups (int gidsetsize,
+ gid_t *grouplist)
+{
+ int res = 0;
+ pag_t oldpag = 0;
+
+ if (xfs_is_pag()) {
+ oldpag = xfs_get_pag();
+ }
+ if (old_setgroups_syscall) {
+ res = old_setgroups_syscall(gidsetsize, grouplist);
+ } else {
+ printk(KERN_EMERG "XFS Panic: Old setgroups syscall is NULL");
+ res = -EINVAL;
+ }
+
+ if ( oldpag )
+ xfs_set_pag((oldpag>>16) & 0x0000FFFF, oldpag & 0x0000FFFF);
+ return res;
+}
+#endif
void
install_afs_syscall (void)
{
old_afs_syscall = sys_call_table[__NR_afs_syscall];
sys_call_table[__NR_afs_syscall] = &sys_afs;
+#if defined(ARLA_SETGROUPS)
+ old_setgroups_syscall = sys_call_table[__NR_setgroups];
+ sys_call_table[__NR_setgroups] = &sys_pag_setgroups;
+#endif
}
void
@@ -565,4 +607,13 @@
sys_call_table[__NR_afs_syscall] = old_afs_syscall;
old_afs_syscall = NULL;
}
+#if defined(ARLA_SETGROUPS)
+ if (old_setgroups_syscall) {
+ /* check to make sure no-one else overloaded setgroups call */
+ if ( sys_call_table[__NR_setgroups] != &sys_pag_setgroups )
+ printk(KERN_EMERG "XFS Panic: setgroups syscall did not
match.");
+ sys_call_table[__NR_setgroups] = old_setgroups_syscall;
+ old_setgroups_syscall = NULL;
+ }
+#endif
}
-----CUT HERE-----