#! /bin/sh #---------------------------------------------------------------------------- # /var/install/bin/remove-user-from-additional-group - remove user from additional group # # Copyright (c) 2001-2005 The Eisfair Team, c/o Frank Meyer, frank(at)eisfair(dot)org # # Creation: 20.07.2003 fm # Last Update: $Id$ # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------- # include eislib . /var/install/include/eislib clrhome mecho -info "Remove user from additional group" echo tty=`tty` echo echo /var/install/bin/ask "User:" '' '*' > /tmp/ask.$$ rc=$? user=`cat /tmp/ask.$$` rm -f /tmp/ask.$$ if [ $rc = 255 ] then exit 1 fi oldifs="$IFS" if [ "$user" != "" ] then mecho line=`grep "^$user:" /etc/passwd` if [ "$line" != "" ] then groups='' mecho " Additional groups of user $user:" echo IFS=':' while read line do set -- $line g="$1" u="$4" IFS=',' set -- $u for j in $* do if [ $j = $user ] then echo " $g" if [ "$groups" = "" ] then groups="$g" else groups="$groups "$g fi break fi done IFS=':' done /tmp/ask.$$ rc=$? rg=`cat /tmp/ask.$$` rm -f /tmp/ask.$$ if [ $rc = 255 ] then exit 1 fi echo if [ "$rg" != "" ] then group_found=false for j in $groups do if [ $rg = $j ] then group_found=true break fi done if [ $group_found = true ] then g='' for j in $groups do if [ $j != $rg ] then if [ "$g" = "" ] then g=$j else g="$g,$j" fi fi done /usr/sbin/usermod -G "$g" $user else mecho -warn "additional group $rg for user $user not found!" fi else mecho -warn "Command aborted" fi else mecho -warn "No additional group for $user found!" fi else mecho -warn "User $user does not exist!" fi else echo mecho -warn "Command aborted" fi echo anykey