aboutsummaryrefslogtreecommitdiffhomepage
path: root/cmd/hsu/parse.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2026-03-28 18:06:12 +0900
committerOphestra <cat@gensokyo.uk>2026-03-28 18:17:31 +0900
commit62002efd08158512f6015d47461d264a14961553 (patch)
tree723cb027a3aac2eb8e61062826884505479370bf /cmd/hsu/parse.go
parente33294db9c334530582215b2c5dd23c0730bc162 (diff)
cmd/hsu: document hsurc format and internals
This was previously only documented via an unexported function. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'cmd/hsu/parse.go')
-rw-r--r--cmd/hsu/parse.go21
1 files changed, 10 insertions, 11 deletions
diff --git a/cmd/hsu/parse.go b/cmd/hsu/parse.go
index 6003f6cf..d4f7df43 100644
--- a/cmd/hsu/parse.go
+++ b/cmd/hsu/parse.go
@@ -18,8 +18,9 @@ const (
useridEnd = useridStart + rangeSize - 1
)
-// parseUint32Fast parses a string representation of an unsigned 32-bit integer value
-// using the fast path only. This limits the range of values it is defined in.
+// parseUint32Fast parses a string representation of an unsigned 32-bit integer
+// value using the fast path only. This limits the range of values it is defined
+// in but is perfectly adequate for this use case.
func parseUint32Fast(s string) (uint32, error) {
sLen := len(s)
if sLen < 1 {
@@ -40,12 +41,14 @@ func parseUint32Fast(s string) (uint32, error) {
return n, nil
}
-// parseConfig reads a list of allowed users from r until it encounters puid or [io.EOF].
+// parseConfig reads a list of allowed users from r until it encounters puid or
+// [io.EOF].
//
-// Each line of the file specifies a hakurei userid to kernel uid mapping. A line consists
-// of the string representation of the uid of the user wishing to start hakurei containers,
-// followed by a space, followed by the string representation of its userid. Duplicate uid
-// entries are ignored, with the first occurrence taking effect.
+// Each line of the file specifies a hakurei userid to kernel uid mapping. A
+// line consists of the string representation of the uid of the user wishing to
+// start hakurei containers, followed by a space, followed by the string
+// representation of its userid. Duplicate uid entries are ignored, with the
+// first occurrence taking effect.
//
// All string representations are parsed by calling parseUint32Fast.
func parseConfig(r io.Reader, puid uint32) (userid uint32, ok bool, err error) {
@@ -112,10 +115,6 @@ func mustParseConfig(puid int) (userid uint32) {
return
}
-// envIdentity is the name of the environment variable holding a
-// string representation of the current application identity.
-var envIdentity = "HAKUREI_IDENTITY"
-
// mustReadIdentity calls parseUint32Fast to interpret the value stored in envIdentity,
// terminating the program if the value is not set, malformed, or out of bounds.
func mustReadIdentity() uint32 {