File tree Expand file tree Collapse file tree 2 files changed +13
-0
lines changed
internal/orchestrator/config Expand file tree Collapse file tree 2 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -81,6 +81,11 @@ func main() {
8181 if err != nil {
8282 feedback .Fatal (fmt .Sprintf ("invalid config: %s" , err ), feedback .ErrGeneric )
8383 }
84+
85+ if os .Geteuid () == 0 && ! configuration .AllowRoot {
86+ feedback .Fatal ("arduino-app-cli must not be run as root. Try `su - arduino` before this command." , feedback .ErrGeneric )
87+ }
88+
8489 if err := run (configuration ); err != nil {
8590 feedback .FatalError (err , 1 )
8691 }
Original file line number Diff line number Diff line change 55 "log/slog"
66 "os"
77 "path"
8+ "strconv"
89 "strings"
910
1011 "github.com/arduino/go-paths-helper"
@@ -22,6 +23,7 @@ type Configuration struct {
2223 PythonImage string
2324 UsedPythonImageTag string
2425 RunnerVersion string
26+ AllowRoot bool
2527}
2628
2729func NewFromEnv () (Configuration , error ) {
@@ -90,6 +92,11 @@ func NewFromEnv() (Configuration, error) {
9092 pythonImage , usedPythonImageTag := getPythonImageAndTag ()
9193 slog .Debug ("Using pythonImage" , slog .String ("image" , pythonImage ))
9294
95+ allowRoot , err := strconv .ParseBool (os .Getenv ("ARDUINO_APP_CLI__ALLOW_ROOT" ))
96+ if err != nil {
97+ allowRoot = false
98+ }
99+
93100 c := Configuration {
94101 appsDir : appsDir ,
95102 configDir : configDir ,
@@ -99,6 +106,7 @@ func NewFromEnv() (Configuration, error) {
99106 PythonImage : pythonImage ,
100107 UsedPythonImageTag : usedPythonImageTag ,
101108 RunnerVersion : runnerVersion ,
109+ AllowRoot : allowRoot ,
102110 }
103111 if err := c .init (); err != nil {
104112 return Configuration {}, err
You can’t perform that action at this time.
0 commit comments