@@ -19,6 +19,7 @@ type LsOpts struct {
19
19
RuntimeEndpoint string
20
20
RuntimeId string
21
21
InitTracingPort string
22
+ User string
22
23
CodeArchives string
23
24
HotReloadingPaths []string
24
25
EnableDnsServer string
@@ -40,6 +41,7 @@ func InitLsOpts() *LsOpts {
40
41
// optional with default
41
42
InteropPort : GetenvWithDefault ("LOCALSTACK_INTEROP_PORT" , "9563" ),
42
43
InitTracingPort : GetenvWithDefault ("LOCALSTACK_RUNTIME_TRACING_PORT" , "9564" ),
44
+ User : GetenvWithDefault ("LOCALSTACK_USER" , "sbx_user1051" ),
43
45
// optional or empty
44
46
CodeArchives : os .Getenv ("LOCALSTACK_CODE_ARCHIVES" ),
45
47
HotReloadingPaths : strings .Split (GetenvWithDefault ("LOCALSTACK_HOT_RELOADING_PATHS" , "" ), "," ),
@@ -60,13 +62,14 @@ func main() {
60
62
log .SetLevel (log .DebugLevel )
61
63
log .SetReportCaller (true )
62
64
63
- // Switch to sbx user and drop root privileges
64
- if IsRootUser () {
65
- UserLogger ().Debugln ("Drop privileges and switch user." )
66
- user := "sbx_user1051"
67
- AddUser (user )
68
- DropPrivileges (user )
69
- UserLogger ().Debugln ("Process running as sbx user." )
65
+ // Switch to non-root user and drop root privileges
66
+ if IsRootUser () && lsOpts .User != "" {
67
+ uid := 993
68
+ gid := 990
69
+ AddUser (lsOpts .User , uid , gid )
70
+ UserLogger ().Debugln ("Process running as root user." )
71
+ DropPrivileges (lsOpts .User )
72
+ UserLogger ().Debugln ("Process running as non-root user." )
70
73
}
71
74
72
75
// download code archive if env variable is set
0 commit comments