MCPcopy Create free account
hub / github.com/coder/envbuilder / setEnvFromEtcEnvironment

Function setEnvFromEtcEnvironment

envbuilder.go:1350–1367  ·  view source on GitHub ↗
(logf log.Func)

Source from the content-addressed store, hash-verified

1348}
1349
1350func setEnvFromEtcEnvironment(logf log.Func) error {
1351 environ, err := os.ReadFile("/etc/environment")
1352 if errors.Is(err, os.ErrNotExist) {
1353 logf(log.LevelDebug, "Not loading environment from /etc/environment, file does not exist")
1354 return nil
1355 }
1356 if err != nil {
1357 return err
1358 }
1359 for _, env := range strings.Split(string(environ), "\n") {
1360 pair := strings.SplitN(env, "=", 2)
1361 if len(pair) != 2 {
1362 continue
1363 }
1364 os.Setenv(pair[0], pair[1])
1365 }
1366 return nil
1367}
1368
1369type userInfo struct {
1370 uid int

Callers 1

runFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected