Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.package
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Alain Takoudjou
slapos.package
Commits
9649237c
Commit
9649237c
authored
Jul 18, 2013
by
Jondy Zhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
useradd: support many other groups; try to grp_name if name doesn't exist.
parent
d097597a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
6 deletions
+7
-6
windows/scripts/useradd
windows/scripts/useradd
+7
-6
No files found.
windows/scripts/useradd
View file @
9649237c
...
@@ -62,7 +62,7 @@ fi
...
@@ -62,7 +62,7 @@ fi
# Creates a new (unprivileged) user as specified by $1.
# Creates a new (unprivileged) user as specified by $1.
# Useful for running services that do not require elevated privileges,
# Useful for running services that do not require elevated privileges,
# or running servers like sshd in "privilege separation" mode.
# or running servers like sshd in "privilege separation" mode.
#
#
# Exits on catastrophic error
# Exits on catastrophic error
# Returns 0 on total success
# Returns 0 on total success
# Returns 1 on failure
# Returns 1 on failure
...
@@ -135,7 +135,7 @@ function create_unprivileged_user()
...
@@ -135,7 +135,7 @@ function create_unprivileged_user()
# Routine: add_member_to_group
# Routine: add_member_to_group
# Add a member $1 to a group $2, there is a special for slapos:
# Add a member $1 to a group $2, there is a special for slapos:
# if $2 is not a group name, we'll try grp_$2 as group name
# if $2 is not a group name, we'll try grp_$2 as group name
#
#
# Exits on catastrophic error
# Exits on catastrophic error
# Returns 0 on total success
# Returns 0 on total success
# Returns 1 on failure
# Returns 1 on failure
...
@@ -150,10 +150,11 @@ function add_member_to_group()
...
@@ -150,10 +150,11 @@ function add_member_to_group()
{
{
local
name
=
$1
local
name
=
$1
local
grpname
=
$2
local
grpname
=
$2
net localgroup
$grpname
>
/dev/null 2>&1
||
grpname
=
"grp_
$grpname
"
net localgroup
$grpname
>
/dev/null 2>&1
||
return
1
if
!
net localgroup
$grpname
|
grep
-q
-e
"^
$name
$"
;
then
if
!
net localgroup
$grpname
|
grep
-q
-e
"^
$name
$"
;
then
net localgroup
$grpname
$name
/add
net localgroup
$grpname
$name
/add
fi
fi
net localgroup
$grpname
|
grep
-q
-e
"^
$name
$"
}
# === End of add_member_to_group() === #
}
# === End of add_member_to_group() === #
while
getopts
"Dd:g:G:p:s:r"
opt
;
do
while
getopts
"Dd:g:G:p:s:r"
opt
;
do
...
@@ -165,7 +166,7 @@ while getopts "Dd:g:G:p:s:r" opt ; do
...
@@ -165,7 +166,7 @@ while getopts "Dd:g:G:p:s:r" opt ; do
USER_INIT_GROUP
=
$OPTARG
USER_INIT_GROUP
=
$OPTARG
;;
;;
G
)
G
)
USER_OTHER_GROUP
=
$OPTARG
USER_OTHER_GROUP
=
"
$USER_OTHER_GROUP
$OPTARG
"
;;
;;
p
)
p
)
USER_PASSWORD
=
$OPTARG
USER_PASSWORD
=
$OPTARG
...
@@ -194,11 +195,11 @@ create_unprivileged_user ${USER_NAME} $USER_HOME ||
...
@@ -194,11 +195,11 @@ create_unprivileged_user ${USER_NAME} $USER_HOME ||
(
echo
"Failed to create user
${
USER_NAME
}
"
;
exit
1
)
(
echo
"Failed to create user
${
USER_NAME
}
"
;
exit
1
)
for
grpname
in
${
USER_INIT_GROUP
}
${
USER_OTHER_GROUP
}
;
do
for
grpname
in
${
USER_INIT_GROUP
}
${
USER_OTHER_GROUP
}
;
do
[[
-z
"
$grpname
"
]]
&&
continue
[[
-z
"
$grpname
"
]]
&&
continue
add_member_to_group
${
USER_NAME
}
$grpname
||
add_member_to_group
${
USER_NAME
}
$grpname
||
(
echo
"Failed to add
${
USER_NAME
}
to group
$group
"
;
exit
1
)
(
echo
"Failed to add
${
USER_NAME
}
to group
$group
"
;
exit
1
)
done
done
# net user "${USER_NAME}" /delete ||
# net user "${USER_NAME}" /delete ||
# (echo "Faild to delete user ${USER_NAME}" ; exit 1)
# (echo "Faild to delete user ${USER_NAME}" ; exit 1)
# sed -i -e "/^${USER_NAME}/d" /etc/passwd
# sed -i -e "/^${USER_NAME}/d" /etc/passwd
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment