Skip to content

Commit

Permalink
Revert "Addresses comments from #45. Feel free to squash."
Browse files Browse the repository at this point in the history
This reverts commit 932fe34.
  • Loading branch information
jprider63 committed Oct 14, 2015
1 parent 932fe34 commit 296535e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
14 changes: 7 additions & 7 deletions System/Process/Internals.hs
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,12 @@ data CreateProcess = CreateProcess{
--
-- Default: @Nothing@
--
-- @since 1.4.0.0
-- @since X.X.X.X
child_user :: Maybe UserID -- ^ Use posix setuid to set child process's user id; does nothing on other platforms.
--
-- Default: @Nothing@
--
-- @since 1.4.0.0
-- @since X.X.X.X
}

data CmdSpec
Expand Down Expand Up @@ -295,8 +295,8 @@ createProcess_ fun CreateProcess{ cmdspec = cmdsp,
alloca $ \ pFailedDoing ->
maybeWith withCEnvironment mb_env $ \pEnv ->
maybeWith withFilePath mb_cwd $ \pWorkDir ->
let childGroup = maybe (-1) id mb_child_group in
let childUser = maybe (-1) id mb_child_user in
maybeWith with mb_child_group $ \pChildGroup ->
maybeWith with mb_child_user $ \pChildUser ->
withMany withFilePath (cmd:args) $ \cstrs ->
withArray0 nullPtr cstrs $ \pargs -> do

Expand All @@ -315,7 +315,7 @@ createProcess_ fun CreateProcess{ cmdspec = cmdsp,
c_runInteractiveProcess pargs pWorkDir pEnv
fdin fdout fderr
pfdStdInput pfdStdOutput pfdStdError
childGroup childUser
pChildGroup pChildUser
(if mb_delegate_ctlc then 1 else 0)
((if mb_close_fds then RUN_PROCESS_IN_CLOSE_FDS else 0)
.|.(if mb_create_group then RUN_PROCESS_IN_NEW_GROUP else 0)
Expand Down Expand Up @@ -429,8 +429,8 @@ foreign import ccall unsafe "runInteractiveProcess"
-> Ptr FD
-> Ptr FD
-> Ptr FD
-> CGid
-> CUid
-> Ptr CGid
-> Ptr CUid
-> CInt -- reset child's SIGINT & SIGQUIT handlers
-> CInt -- flags
-> Ptr CString
Expand Down
10 changes: 5 additions & 5 deletions cbits/runProcess.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ runInteractiveProcess (char *const args[],
char *workingDirectory, char **environment,
int fdStdIn, int fdStdOut, int fdStdErr,
int *pfdStdInput, int *pfdStdOutput, int *pfdStdError,
gid_t childGroup, uid_t childUser,
gid_t *childGroup, uid_t *childUser,
int reset_int_quit_handlers,
int flags,
char **failed_doing)
Expand Down Expand Up @@ -150,15 +150,15 @@ runInteractiveProcess (char *const args[],
setpgid(0, 0);
}

if ( childGroup != -1) {
if ( setgid( childGroup) != 0) {
if ( childGroup) {
if ( setgid( *childGroup) != 0) {
// ERROR
childFailed(forkCommunicationFds[1], forkSetgidFailed);
}
}

if ( childUser != -1) {
if ( setuid( childUser) != 0) {
if ( childUser) {
if ( setuid( *childUser) != 0) {
// ERROR
childFailed(forkCommunicationFds[1], forkSetuidFailed);
}
Expand Down
4 changes: 2 additions & 2 deletions include/runProcess.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ extern ProcHandle runInteractiveProcess( char *const args[],
int *pfdStdInput,
int *pfdStdOutput,
int *pfdStdError,
gid_t childGroup,
uid_t childUser,
gid_t *childGroup,
uid_t *childUser,
int reset_int_quit_handlers,
int flags,
char **failed_doing);
Expand Down

0 comments on commit 296535e

Please sign in to comment.