forked from taskcluster/taskcluster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathos_groups_windows.go
34 lines (31 loc) · 1.09 KB
/
os_groups_windows.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
package main
import (
"fmt"
)
func (osGroups *OSGroups) Start() *CommandExecutionError {
groups := osGroups.Task.Payload.OSGroups
if len(groups) == 0 {
return nil
}
if config.RunTasksAsCurrentUser {
osGroups.Task.Infof("Not adding task user to group(s) %v since we are running as current user.", groups)
return nil
}
updatedGroups, notUpdatedGroups := osGroups.Task.addUserToGroups(groups)
osGroups.AddedGroups = updatedGroups
if len(notUpdatedGroups) > 0 {
return MalformedPayloadError(fmt.Errorf("Could not add task user to os group(s): %v", notUpdatedGroups))
}
taskContext.pd.RefreshLoginSession(taskContext.User.Name, taskContext.User.Password)
for _, command := range osGroups.Task.Commands {
command.SysProcAttr.Token = taskContext.pd.LoginInfo.AccessToken()
}
return nil
}
func (osGroups *OSGroups) Stop(err *ExecutionErrors) {
groups := osGroups.AddedGroups
_, notUpdatedGroups := osGroups.Task.removeUserFromGroups(groups)
if len(notUpdatedGroups) > 0 {
err.add(MalformedPayloadError(fmt.Errorf("Could not remove task user from os group(s): %v", notUpdatedGroups)))
}
}