Compare commits
No commits in common. "b5f01ef20b69e155db299f824ad48c9955deedcf" and "6a6d30af1f15b0aa1b79174ecb08b59bd77dabb0" have entirely different histories.
b5f01ef20b
...
6a6d30af1f
|
@ -2,6 +2,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -45,9 +46,18 @@ func main() {
|
||||||
fmsg.Fatalf("cannot create output: %v", err)
|
fmsg.Fatalf("cannot create output: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type payload struct {
|
||||||
|
UserName string `json:"userName"`
|
||||||
|
Uid int `json:"uid"`
|
||||||
|
Gid int `json:"gid"`
|
||||||
|
RealName string `json:"realName"`
|
||||||
|
HomeDirectory string `json:"homeDirectory"`
|
||||||
|
Shell string `json:"shell"`
|
||||||
|
}
|
||||||
|
|
||||||
for _, u := range users {
|
for _, u := range users {
|
||||||
fidString := strconv.Itoa(u.fid)
|
fidString := strconv.Itoa(u.fid)
|
||||||
for aid := 0; aid < 10000; aid++ {
|
for aid := 0; aid < 9999; aid++ {
|
||||||
userName := fmt.Sprintf("u%d_a%d", u.fid, aid)
|
userName := fmt.Sprintf("u%d_a%d", u.fid, aid)
|
||||||
uid := 1000000 + u.fid*10000 + aid
|
uid := 1000000 + u.fid*10000 + aid
|
||||||
us := strconv.Itoa(uid)
|
us := strconv.Itoa(uid)
|
||||||
|
@ -59,11 +69,27 @@ func main() {
|
||||||
homeDirectory = varEmpty
|
homeDirectory = varEmpty
|
||||||
}
|
}
|
||||||
|
|
||||||
writeUser(userName, uid, us, realName, homeDirectory, *shell, *out)
|
fileName := userName + ".user"
|
||||||
writeGroup(userName, uid, us, nil, *out)
|
if f, err := os.OpenFile(path.Join(*out, fileName), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644); err != nil {
|
||||||
|
fmsg.Fatalf("cannot create %s: %v", userName, err)
|
||||||
|
} else if err = json.NewEncoder(f).Encode(&payload{
|
||||||
|
UserName: userName,
|
||||||
|
Uid: uid,
|
||||||
|
Gid: uid,
|
||||||
|
RealName: realName,
|
||||||
|
HomeDirectory: homeDirectory,
|
||||||
|
Shell: *shell,
|
||||||
|
}); err != nil {
|
||||||
|
fmsg.Fatalf("cannot serialise %s: %v", userName, err)
|
||||||
|
} else if err = f.Close(); err != nil {
|
||||||
|
fmsg.Printf("cannot close %s: %v", userName, err)
|
||||||
|
}
|
||||||
|
if err := os.Symlink(fileName, path.Join(*out, us+".user")); err != nil {
|
||||||
|
fmsg.Fatalf("cannot link %s: %v", userName, err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fmsg.Printf("created %d entries", len(users)*2*10000)
|
fmsg.Printf("created %d entries", len(users)*10000)
|
||||||
fmsg.Exit(0)
|
fmsg.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,64 +0,0 @@
|
||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"encoding/json"
|
|
||||||
"os"
|
|
||||||
"path"
|
|
||||||
|
|
||||||
"git.ophivana.moe/security/fortify/internal/fmsg"
|
|
||||||
)
|
|
||||||
|
|
||||||
type payloadU struct {
|
|
||||||
UserName string `json:"userName"`
|
|
||||||
Uid int `json:"uid"`
|
|
||||||
Gid int `json:"gid"`
|
|
||||||
MemberOf []string `json:"memberOf,omitempty"`
|
|
||||||
RealName string `json:"realName"`
|
|
||||||
HomeDirectory string `json:"homeDirectory"`
|
|
||||||
Shell string `json:"shell"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func writeUser(userName string, uid int, us string, realName, homeDirectory, shell string, out string) {
|
|
||||||
userFileName := userName + ".user"
|
|
||||||
if f, err := os.OpenFile(path.Join(out, userFileName), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644); err != nil {
|
|
||||||
fmsg.Fatalf("cannot create %s: %v", userName, err)
|
|
||||||
} else if err = json.NewEncoder(f).Encode(&payloadU{
|
|
||||||
UserName: userName,
|
|
||||||
Uid: uid,
|
|
||||||
Gid: uid,
|
|
||||||
RealName: realName,
|
|
||||||
HomeDirectory: homeDirectory,
|
|
||||||
Shell: shell,
|
|
||||||
}); err != nil {
|
|
||||||
fmsg.Fatalf("cannot serialise %s: %v", userName, err)
|
|
||||||
} else if err = f.Close(); err != nil {
|
|
||||||
fmsg.Printf("cannot close %s: %v", userName, err)
|
|
||||||
}
|
|
||||||
if err := os.Symlink(userFileName, path.Join(out, us+".user")); err != nil {
|
|
||||||
fmsg.Fatalf("cannot link %s: %v", userName, err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
type payloadG struct {
|
|
||||||
GroupName string `json:"groupName"`
|
|
||||||
Gid int `json:"gid"`
|
|
||||||
Members []string `json:"members,omitempty"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func writeGroup(groupName string, gid int, gs string, members []string, out string) {
|
|
||||||
groupFileName := groupName + ".group"
|
|
||||||
if f, err := os.OpenFile(path.Join(out, groupFileName), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644); err != nil {
|
|
||||||
fmsg.Fatalf("cannot create %s: %v", groupName, err)
|
|
||||||
} else if err = json.NewEncoder(f).Encode(&payloadG{
|
|
||||||
GroupName: groupName,
|
|
||||||
Gid: gid,
|
|
||||||
Members: members,
|
|
||||||
}); err != nil {
|
|
||||||
fmsg.Fatalf("cannot serialise %s: %v", groupName, err)
|
|
||||||
} else if err = f.Close(); err != nil {
|
|
||||||
fmsg.Printf("cannot close %s: %v", groupName, err)
|
|
||||||
}
|
|
||||||
if err := os.Symlink(groupFileName, path.Join(out, gs+".group")); err != nil {
|
|
||||||
fmsg.Fatalf("cannot link %s: %v", groupName, err)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -58,7 +58,7 @@ func (seal *appSeal) shareDisplay(os linux.System) error {
|
||||||
return fmsg.WrapError(ErrXDisplay,
|
return fmsg.WrapError(ErrXDisplay,
|
||||||
"DISPLAY is not set")
|
"DISPLAY is not set")
|
||||||
} else {
|
} else {
|
||||||
seal.sys.ChangeHosts("#" + seal.sys.user.us)
|
seal.sys.ChangeHosts(seal.sys.user.us)
|
||||||
seal.sys.bwrap.SetEnv[display] = d
|
seal.sys.bwrap.SetEnv[display] = d
|
||||||
seal.sys.bwrap.Bind("/tmp/.X11-unix", "/tmp/.X11-unix")
|
seal.sys.bwrap.Bind("/tmp/.X11-unix", "/tmp/.X11-unix")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue