Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
snap-confine: cleanup incorrectly created nvidia udev tags #4042
Conversation
mvo5
added this to the 2.28 milestone
Oct 13, 2017
zyga
requested a review
from
jdstrand
Oct 13, 2017
codecov-io
commented
Oct 13, 2017
•
Codecov Report
@@ Coverage Diff @@
## master #4042 +/- ##
==========================================
- Coverage 75.86% 75.84% -0.02%
==========================================
Files 431 431
Lines 36922 36922
==========================================
- Hits 28010 28005 -5
- Misses 6958 6962 +4
- Partials 1954 1955 +1
Continue to review full report at Codecov.
|
zyga
approved these changes
Oct 13, 2017
LGTM with one remark about approach in case jdstrand has some concerns about glob.
| +// See also: | ||
| +// https://forum.snapcraft.io/t/weird-udev-enumerate-error/2360/17 | ||
| +void sc_maybe_fixup_udev() | ||
| +{ |
zyga
Oct 13, 2017
Contributor
I would probably prefer a simple list of calls tounlinkat(tag_dir_fd, "+nvidia-foo"); (there are about 4 or 5 of files to unlink) that is less sophisticated and operates only on the tags affecting the snap we are dealing with but I don't have strong opinions about it.
jdstrand
approved these changes
Oct 13, 2017
I'm going to approve this in the interest of time, but I'd like to see the initialization comment addressed and I would like to see a test case (ie spread) that proves this is working correctly when the files are there and when they are not. Both should be addressed before merging.
As for the other comment , I have a small preference that is listed inline. I also wouldn't mind the suggestion @zyga has if others agree. Both of these could happen in a follow-up PR.
| +void sc_maybe_fixup_udev() | ||
| +{ | ||
| + glob_t glob_res SC_CLEANUP(globfree) = { | ||
| + .gl_pathv = NULL}; |
zyga
Oct 13, 2017
Contributor
Hmm, aren't those set by the C standard? We set one field, the rest is initialized to zero.
| + // killem'all | ||
| + for (size_t i = 0; i < glob_res.gl_pathc; ++i) { | ||
| + unlink(glob_res.gl_pathv[i]); | ||
| + } |
jdstrand
Oct 13, 2017
Contributor
While it would seem to make logical sense for glob() to set gl_pathc to 0 when GLOB_NOMATCH, I don't see in the man page that this is strictly guaranteed. I suspect your observed behavior is that it will be zero if not found. I'd feel slightly more comfortable and we'd get a teensy optimization if you only ran "killem'all" when err == GLOB_NOMATCH.
|
All that said, I'm now wondering why we are fixing this here, rather than in, say, snapd.core-fixup.sh... |
|
@jdstrand I'm not sure |
|
@zyga and @mvo - I should've said like |
|
@jdstrand I agree, when we initially discussed this with @mvo5 we considered putting this in udev backend initialization code so that snapd does the cleanup. For opengl (desktop) apps this seems like a reasonable compromise and it has the advantage of not needing snap-confine changes and it may be removed with the next epoch hop |
|
BTW, if using snap-confine, the apparmor profile will need to be adjusted for:
|
|
To be clear, my approval is that the code is doing what it is advertising (with my recommendation for a teensy code change) so if you decide that is the best path forward, I'm not in your way (considering the urgency of the fix). I do think there needs to be some (more?) discussion if snap-confine is the right place. If you decide it is, I won't block. We could have this only in 2.28.5 and not include it in 2.29 or master if you think that is best, for example. |
|
Oh, right, it calls out to the udev helper directly so needs to be able to write:
|
|
I like the idea of not having this in master. |
mvo5 commentedOct 13, 2017
See https://forum.snapcraft.io/t/weird-udev-enumerate-error/2360/17