diff options
| author | Ophestra <cat@gensokyo.uk> | 2024-12-27 18:06:26 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2024-12-27 18:06:26 +0900 |
| commit | 2fdbd6a4dd39355e94fdecd7756d4dbf9763b3f0 (patch) | |
| tree | 03e8b83fc3ce8fdef8bdd036c3e5bc17806d7ecb /fst/config.go | |
| parent | aef847b5ae055d5f89e00c19bc341b7464164139 (diff) | |
fst/config: alternative /etc directory
This is useful for static /etc directories provided by self-contained application packages, or in cases where autoetc is useful for paths other than /etc.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'fst/config.go')
| -rw-r--r-- | fst/config.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/fst/config.go b/fst/config.go index d7d31451..73809a86 100644 --- a/fst/config.go +++ b/fst/config.go @@ -70,6 +70,8 @@ type SandboxConfig struct { Filesystem []*FilesystemConfig `json:"filesystem"` // symlinks created inside the sandbox Link [][2]string `json:"symlink"` + // read-only /etc directory + Etc string `json:"etc,omitempty"` // automatically set up /etc symlinks AutoEtc bool `json:"auto_etc"` // paths to override by mounting tmpfs over them @@ -127,7 +129,11 @@ func (s *SandboxConfig) Bwrap(os linux.System) (*bwrap.Config, error) { } if !s.AutoEtc { - conf.Dir("/etc") + if s.Etc == "" { + conf.Dir("/etc") + } else { + conf.Bind(s.Etc, "/etc") + } } for _, c := range s.Filesystem { @@ -147,7 +153,11 @@ func (s *SandboxConfig) Bwrap(os linux.System) (*bwrap.Config, error) { } if s.AutoEtc { - conf.Bind("/etc", Tmp+"/etc") + if s.Etc == "" { + conf.Bind("/etc", Tmp+"/etc") + } else { + conf.Bind(s.Etc, Tmp+"/etc") + } // link host /etc contents to prevent passwd/group from being overwritten if d, err := os.ReadDir("/etc"); err != nil { |
