@@ -2344,33 +2344,65 @@ func (d *lxc) startCommon() (string, []func() error, error) {
2344
2344
}
2345
2345
2346
2346
// Configure the entry point.
2347
- if len (config .Process .Args ) > 0 && slices .Contains ([]string {"/init" , "/sbin/init" , "/s6-init" }, config .Process .Args [0 ]) {
2347
+ entrypoint := config .Process .Args
2348
+ if d .expandedConfig ["oci.entrypoint" ] != "" {
2349
+ entrypoint , err = shellquote .Split (d .expandedConfig ["oci.entrypoint" ])
2350
+ if err != nil {
2351
+ return "" , nil , err
2352
+ }
2353
+ }
2354
+
2355
+ if len (entrypoint ) > 0 && slices .Contains ([]string {"/init" , "/sbin/init" , "/s6-init" }, entrypoint [0 ]) {
2348
2356
// For regular init systems, call them directly as PID1.
2349
- err = lxcSetConfigItem (cc , "lxc.init.cmd" , shellquote .Join (config . Process . Args ... ))
2357
+ err = lxcSetConfigItem (cc , "lxc.init.cmd" , shellquote .Join (entrypoint ... ))
2350
2358
if err != nil {
2351
2359
return "" , nil , err
2352
2360
}
2353
2361
} else {
2354
2362
// For anything else, run them under our own PID1.
2355
- err = lxcSetConfigItem (cc , "lxc.execute.cmd" , shellquote .Join (config . Process . Args ... ))
2363
+ err = lxcSetConfigItem (cc , "lxc.execute.cmd" , shellquote .Join (entrypoint ... ))
2356
2364
if err != nil {
2357
2365
return "" , nil , err
2358
2366
}
2359
2367
}
2360
2368
2361
- err = lxcSetConfigItem (cc , "lxc.init.cwd" , config .Process .Cwd )
2362
- if err != nil {
2363
- return "" , nil , err
2369
+ // Configure the cwd.
2370
+ if d .expandedConfig ["oci.cwd" ] != "" {
2371
+ err = lxcSetConfigItem (cc , "lxc.init.cwd" , d .expandedConfig ["oci.cwd" ])
2372
+ if err != nil {
2373
+ return "" , nil , err
2374
+ }
2375
+ } else {
2376
+ err = lxcSetConfigItem (cc , "lxc.init.cwd" , config .Process .Cwd )
2377
+ if err != nil {
2378
+ return "" , nil , err
2379
+ }
2364
2380
}
2365
2381
2366
- err = lxcSetConfigItem (cc , "lxc.init.uid" , fmt .Sprintf ("%d" , config .Process .User .UID ))
2367
- if err != nil {
2368
- return "" , nil , err
2382
+ // Configure the UID
2383
+ if d .expandedConfig ["oci.uid" ] != "" {
2384
+ err = lxcSetConfigItem (cc , "lxc.init.uid" , d .expandedConfig ["oci.uid" ])
2385
+ if err != nil {
2386
+ return "" , nil , err
2387
+ }
2388
+ } else {
2389
+ err = lxcSetConfigItem (cc , "lxc.init.uid" , fmt .Sprintf ("%d" , config .Process .User .UID ))
2390
+ if err != nil {
2391
+ return "" , nil , err
2392
+ }
2369
2393
}
2370
2394
2371
- err = lxcSetConfigItem (cc , "lxc.init.gid" , fmt .Sprintf ("%d" , config .Process .User .GID ))
2372
- if err != nil {
2373
- return "" , nil , err
2395
+ // Configure the GID
2396
+ if d .expandedConfig ["oci.gid" ] != "" {
2397
+ err = lxcSetConfigItem (cc , "lxc.init.gid" , d .expandedConfig ["oci.gid" ])
2398
+ if err != nil {
2399
+ return "" , nil , err
2400
+ }
2401
+ } else {
2402
+ err = lxcSetConfigItem (cc , "lxc.init.gid" , fmt .Sprintf ("%d" , config .Process .User .GID ))
2403
+ if err != nil {
2404
+ return "" , nil , err
2405
+ }
2374
2406
}
2375
2407
2376
2408
// Get all mounts so far.
0 commit comments