summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/spawn.cc
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/spawn.cc')
-rw-r--r--winsup/cygwin/spawn.cc14
1 files changed, 8 insertions, 6 deletions
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
index f9660d93d..c12882c1f 100644
--- a/winsup/cygwin/spawn.cc
+++ b/winsup/cygwin/spawn.cc
@@ -536,6 +536,12 @@ skip_arg_parsing:
else
system_printf ("GetTokenInformation: %E");
+ /* Retrieve security attributes before setting psid to NULL
+ since it's value is needed by `sec_user'. */
+ PSECURITY_ATTRIBUTES sec_attribs = allow_ntsec && sid
+ ? sec_user (sa_buf, sid)
+ : &sec_all_nih;
+
/* Remove impersonation */
uid_t uid = geteuid();
if (myself->impersonated && myself->token != INVALID_HANDLE_VALUE)
@@ -553,12 +559,8 @@ skip_arg_parsing:
rc = CreateProcessAsUser (hToken,
real_path, /* image name - with full path */
one_line.buf, /* what was passed to exec */
- /* process security attrs */
- allow_ntsec && sid ? sec_user (sa_buf, sid)
- : &sec_all_nih,
- /* thread security attrs */
- allow_ntsec && sid ? sec_user (sa_buf, sid)
- : &sec_all_nih,
+ sec_attribs, /* process security attrs */
+ sec_attribs, /* thread security attrs */
TRUE, /* inherit handles from parent */
flags,
envblock,/* environment */