Skip to content

Commit 830a6a8

Browse files
committed
java: only set nobody user on Unix
In #25496 we introduced the ability to have `task.user` set for on Windows, so long as the user ID fits a particular shape. But this uncovered a 7 year old bug in the `java` driver introduced in #5143, where we set the `task.user` to the non-existent Unix user `nobody`, even if we're running on Windows. Prior to the change in #25496 we always ignored the `task.user`, so this was not a problem. We don't set the `task.user` in the `raw_exec` driver, and the otherwise very similar `exec` driver is Linux-only, so we never see the problem there. Fix the bug in the `java` driver by gating the change to the `task.user` on not being Windows. Also add a check to the new code path that the user is non-empty before parsing it, so that any third party drivers that might be borrowing the executor code don't hit the same probem on Windows. Ref: #5143 Ref: #25496 Fixes: #25638
1 parent 87aabc9 commit 830a6a8

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-1
lines changed

.changelog/25648.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
java: Fixed a bug where the default task user was set to 'nobody' on Windows
3+
```

drivers/java/driver.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (handle *drivers.TaskHandle,
468468
}
469469

470470
user := cfg.User
471-
if user == "" {
471+
if user == "" && runtime.GOOS != "windows" {
472472
user = "nobody"
473473
}
474474

drivers/shared/executor/executor_windows.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ func withNetworkIsolation(f func() error, _ *drivers.NetworkIsolationSpec) error
4444
}
4545

4646
func setCmdUser(cmd *exec.Cmd, user string) error {
47+
if user == "" {
48+
return nil
49+
}
4750
nameParts := strings.Split(user, "\\")
4851
if len(nameParts) != 2 {
4952
return errors.New("user name must contain domain")

0 commit comments

Comments
 (0)