[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
How to add a user/group and verify that the UID/GID is free?
- From: Johannes Puschmann <puschl puschl at>
- To: rpm-list redhat com
- Subject: How to add a user/group and verify that the UID/GID is free?
- Date: Sun, 7 Jul 2002 22:03:38 +0200
Hi!
I poking around hours with a specfile.
I must add a new User/group and will verify that the UID/GID is unique
and if not print a error message whats going on.
Is there a better way as grep the /etc/passwd such as getent?
I have tried getent, but when the uid is free, rpm fails with bad exit code.
The code:
die(){ %whinge "$*"; exit 1; }
getent passwd %{gid}
#getent bring retval 2 and we have bad exit status.
#Any way to catch this ?
if [ $? != 2 ] ; then die \
'An existing group is using GID %{gid}, we need it. ' \
'Aborting build process.'
/usr/sbin/groupadd -g %{gid} -r %{group} || die \
'Unexpected error adding group "%{group}" (GID %gid}). Aborting build \
process.'
else
auid=`getent group %{group}`
echo $auid | grep %{gid}
if [ $? != 0 ] ; then die \
'"%{group}" group already exist but GID is not %{gid}. ' \
'Aborting build process.'
fi
fi
System is an RH 7.3
BTW:
Does somebody know, where the %whinge macro does came from ?
It not under /usr/lib/rpm
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
[]