-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1156 from hashicorp/f-x-sys-unix
Use x/sys/unix vs syscall package where appropriate
- Loading branch information
Showing
36 changed files
with
5,899 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// +build !darwin,!dragonfly,!freebsd,!linux,!netbsd,!openbsd,!solaris | ||
|
||
package driver | ||
|
||
import ( | ||
"github.com/hashicorp/nomad/client/config" | ||
"github.com/hashicorp/nomad/nomad/structs" | ||
) | ||
|
||
func (d *ExecDriver) Fingerprint(cfg *config.Config, node *structs.Node) (bool, error) { | ||
return false, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris | ||
|
||
package driver | ||
|
||
import ( | ||
"github.com/hashicorp/nomad/client/config" | ||
"github.com/hashicorp/nomad/nomad/structs" | ||
"golang.org/x/sys/unix" | ||
) | ||
|
||
func (d *ExecDriver) Fingerprint(cfg *config.Config, node *structs.Node) (bool, error) { | ||
// Get the current status so that we can log any debug messages only if the | ||
// state changes | ||
_, currentlyEnabled := node.Attributes[execDriverAttr] | ||
|
||
// Only enable if cgroups are available and we are root | ||
if _, ok := node.Attributes["unique.cgroup.mountpoint"]; !ok { | ||
if currentlyEnabled { | ||
d.logger.Printf("[DEBUG] driver.exec: cgroups unavailable, disabling") | ||
} | ||
delete(node.Attributes, execDriverAttr) | ||
return false, nil | ||
} else if unix.Geteuid() != 0 { | ||
if currentlyEnabled { | ||
d.logger.Printf("[DEBUG] driver.exec: must run as root user, disabling") | ||
} | ||
delete(node.Attributes, execDriverAttr) | ||
return false, nil | ||
} | ||
|
||
if !currentlyEnabled { | ||
d.logger.Printf("[DEBUG] driver.exec: exec driver is enabled") | ||
} | ||
node.Attributes[execDriverAttr] = "1" | ||
return true, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
client/driver/executor/checks_linux.go → client/driver/executor/checks_unix.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris | ||
|
||
package executor | ||
|
||
import ( | ||
|
6 changes: 2 additions & 4 deletions
6
client/driver/executor/checks_basic.go → client/driver/executor/checks_windows.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,8 @@ | ||
// +build !linux | ||
// +build windows | ||
|
||
package executor | ||
|
||
import ( | ||
"os/exec" | ||
) | ||
import "os/exec" | ||
|
||
func (e *ExecScriptCheck) setChroot(cmd *exec.Cmd) { | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
client/driver/executor/executor_posix.go → client/driver/executor/executor_unix.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// +build !windows | ||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris | ||
|
||
package executor | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
client/driver/logging/syslog_parser.go → client/driver/logging/syslog_parser_unix.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// +build !windows | ||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris | ||
|
||
package logging | ||
|
||
|
2 changes: 1 addition & 1 deletion
2
client/driver/logging/syslog_parser_test.go → ...driver/logging/syslog_parser_unix_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// +build !windows | ||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris | ||
|
||
package logging | ||
|
||
|
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
client/driver/logging/universal_collector.go → ...river/logging/universal_collector_unix.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// +build !windows | ||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris | ||
|
||
package logging | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
// +build !linux,!windows | ||
// +build darwin dragonfly freebsd linux netbsd openbsd solaris | ||
|
||
package driver | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.