Updated setgroups patch
Nathan Neulinger
nneul at umr.edu
Thu Feb 18 04:02:00 CET 1999
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 at CFLAGS= @KERNEL_CFLAGS@
@OSF1_FALSE at 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-----
More information about the Arla-drinkers
mailing list