aboutsummaryrefslogtreecommitdiffstats
path: root/init-sh/grpuser.sh
diff options
context:
space:
mode:
authorYoann Vandoorselaere <yoann@mandriva.com>1999-12-16 16:21:28 +0000
committerYoann Vandoorselaere <yoann@mandriva.com>1999-12-16 16:21:28 +0000
commit5a2662e03d6d2206105e7c87343c17ac9d1f28b1 (patch)
tree6b54746bcc663259417d8e200d766950e036f18a /init-sh/grpuser.sh
parent5e3ce5426b211ff83c92f561fc940bee3b0877ce (diff)
downloadmsec-5a2662e03d6d2206105e7c87343c17ac9d1f28b1.tar
msec-5a2662e03d6d2206105e7c87343c17ac9d1f28b1.tar.gz
msec-5a2662e03d6d2206105e7c87343c17ac9d1f28b1.tar.bz2
msec-5a2662e03d6d2206105e7c87343c17ac9d1f28b1.tar.xz
msec-5a2662e03d6d2206105e7c87343c17ac9d1f28b1.zip
*** empty log message ***
Diffstat (limited to 'init-sh/grpuser.sh')
-rwxr-xr-xinit-sh/grpuser.sh30
1 files changed, 14 insertions, 16 deletions
diff --git a/init-sh/grpuser.sh b/init-sh/grpuser.sh
index d2f2daf..85c303b 100755
--- a/init-sh/grpuser.sh
+++ b/init-sh/grpuser.sh
@@ -20,22 +20,19 @@ Usage() {
}
ModifyFile() {
- cp /etc/${file} /tmp/${file}.old
+ tmpfile=`mktemp /tmp/grpuser.XXXXXX`
+ cp /etc/${file} ${tmpfile}
- head -$((group_line_number - 1)) /tmp/${file}.old > /etc/${file}
+ head -$((group_line_number - 1)) ${tmpfile} > /etc/${file}
echo "${new_group_line}" >> /etc/${file}
- tail +$((group_line_number + 1)) /tmp/${file}.old >> /etc/${file}
-
- new_group_line=""
+ tail +$((group_line_number + 1)) ${tmpfile} >> /etc/${file}
- rm -f /tmp/${file}.old
+ rm -f ${tmpfile}
}
RemoveUserFromGroup() {
new_group_line=${group}`echo ${group_users} |
sed -e s/,${user_name}$//g -e s/${user_name},//g -e s/${user_name}$//g`
-
- echo ${new_group_line}
}
AppendUserToGroup() {
@@ -87,27 +84,28 @@ RefreshAdd() {
exit 1;
fi
- cat /etc/security/msec/group.conf | while read group_name; do
+ cat /etc/security/msec/group.conf | grep -v "^$" | while read group_name; do
IsGroupExisting;
if [[ $? != 0 ]]; then
echo "Group \"${group_name}\" doesn't exist. skiping it."
else
- cat /etc/security/msec/user.conf | while read user_name; do
+ cat /etc/security/msec/user.conf | grep -v "^$" | while read user_name; do
IsUserExisting;
if [[ $? != 0 ]]; then
# user doesn't exist
echo "Can't add user \"${user_name}\" to group \"${group_name}\" user doesn't exist. skiping."
IsUserAlreadyInGroup;
if [[ $? == 0 ]]; then
- echo "User doesn't exist but is in a group... delete user from this group."
+ #User doesn't exist but is in a group... delete user from this group.
+ IsGroupExisting;
RemoveUserFromGroup;
ModifyFile;
fi
else
echo "Adding user \"${user_name}\" to group \"${group_name}\"."
- #AppendUserToGroup;
- #ModifyFile;
- usermod -G ${group_name} ${user_name}
+ IsGroupExisting;
+ AppendUserToGroup;
+ ModifyFile;
fi
done
fi
@@ -115,12 +113,12 @@ RefreshAdd() {
}
RefreshDel() {
- cat /etc/security/msec/group.conf | while read group_name; do
+ cat /etc/security/msec/group.conf | grep -v "^$" | while read group_name; do
IsGroupExisting;
if [[ $? != 0 ]]; then
echo "Group \"${group_name}\" doesn't exist. skiping it."
else
- cat /etc/security/msec/user.conf | while read user_name; do
+ cat /etc/security/msec/user.conf | grep -v "^$" | while read user_name; do
IsGroupExisting; # We need some variable at each turn.
IsUserAlreadyInGroup;
if [[ $? == 0 ]]; then