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
Boxiang Sun
slapos.package
Commits
cb84afec
Commit
cb84afec
authored
Aug 28, 2013
by
Jondy Zhao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
support to switch user by slapos node command
parent
a9a9707d
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
2 deletions
+61
-2
windows/patches/supervisor-cygwin.patch
windows/patches/supervisor-cygwin.patch
+24
-0
windows/scripts/regpwd.c
windows/scripts/regpwd.c
+29
-0
windows/scripts/useradd
windows/scripts/useradd
+8
-2
No files found.
windows/patches/supervisor-cygwin.patch
0 → 100755
View file @
cb84afec
diff --git a/options.py~ b/options.py
old mode 100644
new mode 100755
index 3ccab60..e220c10
--- a/options.py~
+++ b/options.py
@@ -1197,7 +1197,7 @@
class ServerOptions(Options):
return
if current_uid != 0:
- return "Can't drop privilege as nonroot user"
+ pass # return "Can't drop privilege as nonroot user"
gid = pwrec[3]
if hasattr(os, 'setgroups'):
@@ -1219,7 +1219,7 @@
class ServerOptions(Options):
os.setgid(gid)
except OSError:
return 'Could not set group id of effective user'
- os.setuid(uid)
+ os.setreuid(-1, uid)
def waitpid(self):
# need pthread_sigmask here to avoid concurrent sigchild, but
windows/scripts/regpwd.c
0 → 100644
View file @
cb84afec
#include <sys/unistd.h>
#include <sys/cygwin.h>
#include <stdio.h>
#include <errno.h>
int
main
(
int
argc
,
char
*
argv
[])
{
const
char
*
username
=
NULL
;
const
char
*
newpwd
=
NULL
;
if
(
argc
==
1
||
argc
>
3
)
{
fprintf
(
stderr
,
"Usage: regpwd username [password]
\n
"
);
return
1
;
}
username
=
argv
[
1
];
if
(
argc
==
3
)
newpwd
=
argv
[
2
];
if
(
!
strcmp
(
username
,
getlogin
()))
username
=
NULL
;
if
(
cygwin_internal
(
CW_SET_PRIV_KEY
,
newpwd
,
username
))
{
fprintf
(
stderr
,
"Storing password failed: %s"
,
strerror
(
errno
));
return
1
;
}
return
0
;
}
windows/scripts/useradd
View file @
cb84afec
...
...
@@ -38,6 +38,9 @@
# -s
# Shell used by user
#
# This script will set password for each new user, the password is
# same as the account, and will be saved in the registry.
#
export
PATH
=
/usr/local/bin:/usr/bin:/usr/sbin:/sbin:/bin:
$PATH
if
!
source
/usr/share/csih/cygwin-service-installation-helper.sh
;
then
echo
"Error: Download the csih package at first, I need this file:"
...
...
@@ -92,8 +95,8 @@ function create_unprivileged_user()
if
[
"
${
unpriv_user_in_sam
}
"
!=
"yes"
]
then
dos_var_empty
=
$(
/usr/bin/cygpath
-w
${
2
-
${
LOCALSTATEDIR
}
/empty
}
)
csih_call_winsys32 net user
"
${
unpriv_user
}
"
/add /fullname:
"
${
unpriv_user
}
nexedi slapos"
\
"/homedir:
${
dos_var_empty
}
"
/active:no
>
/dev/null 2>&1
&&
unpriv_user_in_sam
=
yes
csih_call_winsys32 net user
"
${
unpriv_user
}
"
"
${
unpriv_user
}
"
/add
\
/fullname:
"
${
unpriv_user
}
Nexedi Slapos"
>
/dev/null 2>&1
&&
unpriv_user_in_sam
=
yes
if
[
"
${
unpriv_user_in_sam
}
"
!=
"yes"
]
then
csih_warning
"Creation of user '
${
unpriv_user
}
' failed!"
...
...
@@ -194,6 +197,9 @@ fi
create_unprivileged_user
${
USER_NAME
}
$USER_HOME
||
(
echo
"Failed to create user
${
USER_NAME
}
"
;
exit
1
)
regpwd
${
USER_NAME
}
${
USER_NAME
}
||
(
echo
"Save
${
USER_NAME
}
's password failed"
;
exit
1
)
for
grpname
in
${
USER_INIT_GROUP
}
${
USER_OTHER_GROUP
}
;
do
[[
-z
"
$grpname
"
]]
&&
continue
add_member_to_group
${
USER_NAME
}
$grpname
||
...
...
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