diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2017-04-17 11:05:23 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2017-05-15 19:09:20 -0400 |
commit | 0b296562d46fe6a8af0ad50df08d3000f89867e1 (patch) | |
tree | cc71fa7bf49e830bec823a1a002a65aff44bae06 /sd_login/util_valid.go | |
parent | e750d7fab32b0c48b606f296d2fef5ffc618baf3 (diff) |
sd_login: Write notes on cgroup structure; realize how to simplify the code.
I'm not sure that the most appropriate error is returned in all cases.
Diffstat (limited to 'sd_login/util_valid.go')
-rw-r--r-- | sd_login/util_valid.go | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/sd_login/util_valid.go b/sd_login/util_valid.go index 46493b3..1837a8f 100644 --- a/sd_login/util_valid.go +++ b/sd_login/util_valid.go @@ -15,21 +15,23 @@ package sd_login import ( + "strconv" "strings" ) -func valid_session_name(id string) bool { - if id == "" { - return false - } - - return strings.TrimLeft(id, letters+digits) == "" -} - func valid_slice_name(s string) bool { return strings.HasSuffix(s, ".slice") && valid_unit_name(s) == unit_name_plain } +func valid_user_tree(unit string) bool { + sessStr, sessOk := trimPrefixSuffix(unit, "session-", ".scope") + + ownerStr, ownerOk := trimPrefixSuffix(unit, "user@", ".service") + _, ownerErr := strconv.Atoi(ownerStr) + + return (sessOk && (SessionName(sessStr).isValid())) || (ownerOk && ownerErr == nil) +} + func valid_filename(s string) bool { switch s { case "", ".", "..": |