Path: utzoo!mnetor!uunet!lll-winken!lll-tis!ames!nrl-cmf!cmcl2!rutgers!columbia!read.columbia.edu!ji From: ji@read.columbia.edu (John Ioannidis) Newsgroups: comp.unix.wizards Subject: Re: How can a group id, be droped? Message-ID: <5365@columbia.edu> Date: 1 Mar 88 20:12:54 GMT References: <104@cui.UUCP> Sender: nobody@columbia.edu Reply-To: ji@read.UUCP (John Ioannidis) Organization: Columbia University Department of Computer Science Lines: 42 I once wrote a pair of system calls that allowed an unprivileged user to add a group to their list of groups, based on authorization granted by a setuid root program. Anyway, just removing a group should not ask for any special authorization, so I guess the easiest way to do it is the following: Basically, you have to add a simple system call. Let's say you'll call it rmgroup(), and it will take one numeric argument, the gid to remove from the list. TO add a system call, add a declaration for it in $SYS/sys/init_sysent.c and put it at the end of struct sysent sysent[] in the same file. You'll also have to include it in syscallnames[] in file $SYS/sys/syscalls.c. Now, in $SYS/sys/kern_prot.c there is a function called leavegroup() which does exaclty what you want. To package it into a syscall, add the following code in kern_prot.c: rmgroup() { struct a { long groupname; } *uap = (struct a *)u.u_ap; leavegroup(a->groupname); } After that, recompile the kernel and you''l be all set. TO call the rmgrp syscall, just call syscall(SYSCALL_rmgrp, groupid), where SYSCALL_rmgrp is the number of the system call (you'll know that because that's where you added it in the struct sysent initially). I haven't tested the code (obviously), but it's too simple not to work. Good luck /ji #include VOICE: +1 212 280 5510 INET: ji@garfield.columbia.EDU USnail: John Ioannidis