aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/app/share.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-02-15 03:19:06 +0900
committerOphestra <cat@gensokyo.uk>2025-02-15 03:19:06 +0900
commit0340c679955acedf5db92004420634a565b1c303 (patch)
treeac43a53691a2302647dbbbfdf3635a0490f40650 /internal/app/share.go
parent72b0160aadac590bc479b9ec86e0378a95d2bdc0 (diff)
app: port passwd and group files to copy
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/app/share.go')
-rw-r--r--internal/app/share.go31
1 files changed, 11 insertions, 20 deletions
diff --git a/internal/app/share.go b/internal/app/share.go
index 528cd09f..fbeb0993 100644
--- a/internal/app/share.go
+++ b/internal/app/share.go
@@ -113,34 +113,25 @@ func (seal *appSeal) setupShares(bus [2]*dbus.Config, os linux.System) error {
sh = s
}
- // generate /etc/passwd
- passwdPath := path.Join(seal.share, "passwd")
- username := "chronos"
- if seal.sys.user.username != "" {
- username = seal.sys.user.username
- }
+ // bind home directory
homeDir := "/var/empty"
if seal.sys.user.home != "" {
homeDir = seal.sys.user.home
}
-
- // bind home directory
+ username := "chronos"
+ if seal.sys.user.username != "" {
+ username = seal.sys.user.username
+ }
seal.sys.bwrap.Bind(seal.sys.user.data, homeDir, false, true)
seal.sys.bwrap.Chdir = homeDir
-
- seal.sys.bwrap.SetEnv["USER"] = username
seal.sys.bwrap.SetEnv["HOME"] = homeDir
+ seal.sys.bwrap.SetEnv["USER"] = username
- passwd := username + ":x:" + seal.sys.mappedIDString + ":" + seal.sys.mappedIDString + ":Fortify:" + homeDir + ":" + sh + "\n"
- seal.sys.Write(passwdPath, passwd)
-
- // write /etc/group
- groupPath := path.Join(seal.share, "group")
- seal.sys.Write(groupPath, "fortify:x:"+seal.sys.mappedIDString+":\n")
-
- // bind /etc/passwd and /etc/group
- seal.sys.bwrap.Bind(passwdPath, "/etc/passwd")
- seal.sys.bwrap.Bind(groupPath, "/etc/group")
+ // generate /etc/passwd and /etc/group
+ seal.sys.bwrap.CopyBind("/etc/passwd",
+ []byte(username+":x:"+seal.sys.mappedIDString+":"+seal.sys.mappedIDString+":Fortify:"+homeDir+":"+sh+"\n"))
+ seal.sys.bwrap.CopyBind("/etc/group",
+ []byte("fortify:x:"+seal.sys.mappedIDString+":\n"))
/*
Display servers