summaryrefslogtreecommitdiff
path: root/sysutils
diff options
context:
space:
mode:
authorobache <obache@pkgsrc.org>2013-03-07 12:25:06 +0000
committerobache <obache@pkgsrc.org>2013-03-07 12:25:06 +0000
commita6737518b3d5a2d35e8493bee98a59381eb2ac58 (patch)
tree404643a81c6f6c47fa3af3ff01540d1e014f1cc8 /sysutils
parent92136f395c35b611a47004e41eedac2cc3136877 (diff)
downloadpkgsrc-a6737518b3d5a2d35e8493bee98a59381eb2ac58.tar.gz
Update cygwin_user to 20130307.
allow to add/del group-as-user.
Diffstat (limited to 'sysutils')
-rw-r--r--sysutils/user_cygwin/Makefile4
-rwxr-xr-xsysutils/user_cygwin/files/useradd.sh20
-rwxr-xr-xsysutils/user_cygwin/files/userdel.sh11
3 files changed, 22 insertions, 13 deletions
diff --git a/sysutils/user_cygwin/Makefile b/sysutils/user_cygwin/Makefile
index c272bb6cdca..98637a85c9f 100644
--- a/sysutils/user_cygwin/Makefile
+++ b/sysutils/user_cygwin/Makefile
@@ -1,7 +1,7 @@
-# $NetBSD: Makefile,v 1.1 2013/03/06 12:37:15 obache Exp $
+# $NetBSD: Makefile,v 1.2 2013/03/07 12:25:06 obache Exp $
#
-DISTNAME= user-20130306
+DISTNAME= user-20130307
CATEGORIES= sysutils
MASTER_SITES= # empty
DISTFILES= # empty
diff --git a/sysutils/user_cygwin/files/useradd.sh b/sysutils/user_cygwin/files/useradd.sh
index c42968766b9..6038821631e 100755
--- a/sysutils/user_cygwin/files/useradd.sh
+++ b/sysutils/user_cygwin/files/useradd.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-# $NetBSD: useradd.sh,v 1.1 2013/03/06 12:37:16 obache Exp $
+# $NetBSD: useradd.sh,v 1.2 2013/03/07 12:25:06 obache Exp $
export PATH=/bin:$PATH
@@ -22,6 +22,7 @@ create_homedir=false
gecos=
group=Users
home_dir=
+user_is_group=false
show_defaults () {
printf 'base_dir\t%s\n' "$base_dir"
@@ -86,12 +87,15 @@ if $create_homedir && [ -d "$home_dir" ]; then
create_homedir=false
fi
-### add the user
+### add the user if it same name one is not in groups
-run_cmd net user $1 /add /fullname:"$gecos" /comment:"User added by Cygwin useradd command" || exit 1
-
-### regenerate cygwin /etc/passwd
-(/bin/flock -x -n 9 || exit 1; /bin/mkpasswd -l -u "$1" >&9 ) 9>> /etc/passwd
+if ! net localgroup "$1" >/dev/null 2>&1; then
+ run_cmd net user $1 /add /fullname:"$gecos" /comment:"User added by Cygwin useradd command" || exit 1
+ (/bin/flock -x -n 9 || exit 1; /bin/mkpasswd -l -u "$1" >&9 ) 9>> /etc/passwd
+else
+ user_is_group=true;
+ (/bin/flock -x -n 9 || exit 1; /bin/mkgroup -l -g "$1" | /bin/awk -F : -v home_dir=$home_dir '{printf "%s:*:%d:%d:,%s:%s:\n",$1,$3,$3,$2,home_dir}' >&9 ) 9>> /etc/passwd
+fi
### put user in groups
@@ -100,7 +104,7 @@ if [ "${group}" != "Users" ]; then
run_cmd net localgroup "Users" $1 /delete || exit 1
# Under Windows, a user *is* a group. Do nothing if =uid is given.
- if [ "$group" != "=uid" ]; then
+ if [ "$group" != "=uid" -a "$group" != "$1" ]; then
run_cmd net localgroup "${group}" $1 /add || exit 1
fi
fi
@@ -124,6 +128,6 @@ if [ "$home_dir" != "" ]; then
run_cmd /bin/setfacl -r -m d:u:"$1":rwx,u:SYSTEM:rwx,u:Administrators:rwx "$home_dir" || exit 1
fi
- run_cmd net user "$1" /homedir:"$home_dir_nt" || exit 1
+ $user_is_group || run_cmd net user "$1" /homedir:"$home_dir_nt" || exit 1
fi
diff --git a/sysutils/user_cygwin/files/userdel.sh b/sysutils/user_cygwin/files/userdel.sh
index 444b6ae9a4c..36c2df95010 100755
--- a/sysutils/user_cygwin/files/userdel.sh
+++ b/sysutils/user_cygwin/files/userdel.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-# $NetBSD: userdel.sh,v 1.1 2013/03/06 12:37:16 obache Exp $
+# $NetBSD: userdel.sh,v 1.2 2013/03/07 12:25:06 obache Exp $
export PATH=/bin:$PATH
@@ -15,6 +15,7 @@ run_cmd () {
}
remove_home_dir=false
+user_is_group=false
while getopts 'prv' f; do
case $f in
@@ -30,7 +31,11 @@ if [ $# -ne 1 ]; then show_usage; fi
$verbose || exec >/dev/null
if ! net user $1 >/dev/null 2>&1; then
- echo "$0: user $1 does not exist" >&2; exit 1
+ if ! net localgroup $1 >/dev/null 2>&1; then
+ echo "$0: user $1 does not exist" >&2; exit 1
+ else
+ user_is_group=true
+ fi
fi
if $remove_home_dir; then
@@ -43,5 +48,5 @@ if $remove_home_dir; then
esac
fi
-run_cmd net user $1 /delete
+$user_is_group || run_cmd net user $1 /delete
/bin/sed -i -e "/^$1.*/d" /etc/passwd