Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
cmd/snap-seccomp,osutil: make user/group lookup functions public #3966
Conversation
zyga
added some commits
Sep 26, 2017
codecov-io
commented
Sep 26, 2017
•
Codecov Report
@@ Coverage Diff @@
## master #3966 +/- ##
=========================================
- Coverage 75.96% 75.8% -0.16%
=========================================
Files 423 424 +1
Lines 36525 36577 +52
=========================================
- Hits 27748 27729 -19
- Misses 6836 6904 +68
- Partials 1941 1944 +3
Continue to review full report at Codecov.
|
| -// | ||
| -// Use implementation from upcoming releases: | ||
| -// https://golang.org/src/os/user/lookup_unix.go | ||
| -func lookupGroup(groupname string) (string, error) { |
chipaca
Sep 26, 2017
Member
why are we doing it this way instead of using go's LookupGroup? it's a lot simpler fwiw
chipaca
Sep 26, 2017
Member
I understand that, but we can copy the LookupGroup function from go 1.9 or whatever, as we've done before for similar things
zyga
Sep 26, 2017
Contributor
This is exactly that. I just took the existing copy @jdstrand added to snap-confine and made it public.
zyga
requested a review
from
mvo5
Sep 26, 2017
|
@mvo5 please consider merging this soon as it will help me out with other PRs |
zyga
referenced this pull request
Sep 28, 2017
Merged
interfaces/mount: add support for parsing x-snapd.{mode,uid,gid}= #3965
| + | ||
| +// FindUid returns the identifier of the given UNIX user name. | ||
| +func FindUid(username string) (uint64, error) { | ||
| + if !userGroupNamePattern.MatchString(username) { |
mvo5
Sep 28, 2017
Collaborator
I think now that this is a public method the check for userGroupNamePattern is misleading. This is about finding the user on the system and not longer about the usernames/groups specified in the policy. I think we need to move the check itself back into snap-seccomp but we need to remove it here.
zyga commentedSep 26, 2017
This branch moves the
Find{Uid,Gid}functions out of the cmd/snap-seccompprogram and into the osutil package where they can also be used by other parts
of snapd. Sadly golang 1.6 doesn't implement user.LookupGroup yet so we need
this kind of hackery.
Signed-off-by: Zygmunt Krynicki zygmunt.krynicki@canonical.com