#!/bin/sh #---------------------------------------------------------------------------- # show-user-additional-group - show additional groups of user # # Creation: 2003-07-20 fm # Last Update: $Id$ # # Copyright (c) 2003-@@YEAR@@ the eisfair team, team(at)eisfair(dot)org # # 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 #debug=true if ${debug:-false} then exec 2>/tmp/$(basename ${0})-trace$$.log set -x ask_debug=true export ask_debug fi interactive=true ASK=/var/install/bin/ask MKTEMP=/usr/bin/mktemp RM=/usr/bin/rm GREP=/usr/bin/grep #---------------------------------------------------------------------------- # do exit #---------------------------------------------------------------------------- do_exit() { if "${interactive:-false}" then mecho anykey fi exit $1 } #---------------------------------------------------------------------------- # myecho, do output to tty #---------------------------------------------------------------------------- myecho() { if ${interactive:-false} then mecho ${1} "${2}" else mecho "${2}" >&2 fi } #---------------------------------------------------------------------------- # main #---------------------------------------------------------------------------- main() { clrhome mecho --info "Show additional groups of user" mecho mecho _ask_tmpfile=$(${MKTEMP} -t XXXXXXXXXXXXX) ${ASK} "User:" '' '*' > ${_ask_tmpfile} rc=${?} read user < ${_ask_tmpfile} ${RM} -f ${_ask_tmpfile} if [ ${rc} = 255 ] then exit 1 fi if [ -z "${user}" ] then mecho myecho --warn "Command aborted" do_exit 1 fi mecho line=$(${GREP} "^$user:" /etc/passwd) if [ -z "${line}" ] then mecho myecho --warn "User ${user} does not exist!" do_exit 1 fi myecho " Additional groups of user ${user}:" mecho oldifs="${IFS}" IFS=':' while read line do set -- ${line} g="${1}" u="${4}" IFS=',' set -- ${u} for j in ${*} do if [ ${j} = ${user} ] then mecho " ${g}" break fi done IFS=':' done