Merge pull request #34 from mcodd/user-gid-change-bug
fix for changing a user's group by name
This commit is contained in:
commit
5d6e55d074
1 changed files with 17 additions and 5 deletions
|
@ -28,6 +28,7 @@ cd "$__object/parameter"
|
||||||
if grep -q "^${name}:" "$__object/explorer/passwd"; then
|
if grep -q "^${name}:" "$__object/explorer/passwd"; then
|
||||||
for property in $(ls .); do
|
for property in $(ls .); do
|
||||||
new_value="$(cat "$property")"
|
new_value="$(cat "$property")"
|
||||||
|
unset current_value
|
||||||
|
|
||||||
file="$__object/explorer/passwd"
|
file="$__object/explorer/passwd"
|
||||||
|
|
||||||
|
@ -36,9 +37,16 @@ if grep -q "^${name}:" "$__object/explorer/passwd"; then
|
||||||
if $(echo "$new_value" | grep -q '^[0-9][0-9]*$'); then
|
if $(echo "$new_value" | grep -q '^[0-9][0-9]*$'); then
|
||||||
field=4
|
field=4
|
||||||
else
|
else
|
||||||
# group name
|
# We were passed a group name. Compare the gid in
|
||||||
file="$__object/explorer/group"
|
# the user's /etc/passwd entry with the gid of the
|
||||||
field=1
|
# group returned by the group explorer.
|
||||||
|
gid_from_group=$(awk -F: '{ print $3 }' "$__object/explorer/group")
|
||||||
|
gid_from_passwd=$(awk -F: '{ print $4 }' "$file")
|
||||||
|
if [ "$gid_from_group" != "$gid_from_passwd" ]; then
|
||||||
|
current_value="$gid_from_passwd"
|
||||||
|
else
|
||||||
|
current_value="$new_value"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
password)
|
password)
|
||||||
|
@ -51,8 +59,12 @@ if grep -q "^${name}:" "$__object/explorer/passwd"; then
|
||||||
uid) field=3 ;;
|
uid) field=3 ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# If we haven't already set $current_value above, pull it from the
|
||||||
|
# appropriate file/field.
|
||||||
|
if [ -z "$current_value" ]; then
|
||||||
export field
|
export field
|
||||||
current_value="$(awk -F: '{ print $ENVIRON["field"] }' < "$file")"
|
current_value="$(awk -F: '{ print $ENVIRON["field"] }' < "$file")"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$new_value" != "$current_value" ]; then
|
if [ "$new_value" != "$current_value" ]; then
|
||||||
set -- "$@" "--$property" \'$new_value\'
|
set -- "$@" "--$property" \'$new_value\'
|
||||||
|
|
Loading…
Reference in a new issue