Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
daemon,debian: add PolicyKit support to snapd #409
Conversation
robert-ancell
added some commits
Feb 2, 2016
|
Can one of the admins verify this patch? |
|
The parts of this patch I'm not 100% sure about:
|
robert-ancell
added some commits
Feb 2, 2016
zyga
reviewed
Feb 2, 2016
| + UserOK: true, | ||
| + GET: getSnapsInfo, | ||
| + POST: sideloadSnap, | ||
| + PolicyKitAction: "com.ubuntu.snappy.sideload-snap", |
zyga
Feb 2, 2016
Contributor
Personally I'd prefer to have a few documented constants that are referenced from all the Command objects.
zyga
reviewed
Feb 2, 2016
| + // 14207 (gnome-terminal-) S 3399 3741 3741 0 -1 4194304 95756 7917395 23 857 6850 942 29913 2486 20 0 4 0 545930 692899840 12642 18446744073709551615 4194304 4486204 140735647896976 140735647896432 139643272960061 0 0 4096 65536 0 0 0 17 3 0 0 1 0 0 6585664 6596840 22155264 140735647901892 140735647901938 140735647901938 140735647903690 0 | ||
| + | ||
| + // Find the end of the name field, search from the right in case the name contains a ')'. | ||
| + for (i = strlen (line) - 1; i > 0 && line[i] != ')'; i--); |
robert-ancell
Feb 2, 2016
Contributor
It has to be i > 0 otherwise the following line will fail:
if (line[i] != ')')
zyga
reviewed
Feb 2, 2016
| + | ||
| + // A line looks like this (the 22nd field is the start time - 545930 in this case): | ||
| + // 14207 (gnome-terminal-) S 3399 3741 3741 0 -1 4194304 95756 7917395 23 857 6850 942 29913 2486 20 0 4 0 545930 692899840 12642 18446744073709551615 4194304 4486204 140735647896976 140735647896432 139643272960061 0 0 4096 65536 0 0 0 17 3 0 0 1 0 0 6585664 6596840 22155264 140735647901892 140735647901938 140735647901938 140735647903690 0 | ||
| + |
robert-ancell
Feb 2, 2016
Contributor
strrchr? Yes. I think initially I was using that and it had too much pointer arithmetic but it looks better now.
zyga
reviewed
Feb 2, 2016
| @@ -79,8 +177,13 @@ func (c *Command) canAccess(r *http.Request) bool { | ||
| isUser = true | ||
| } | ||
| - // only superuser can modify | ||
| + logger.Debugf("canAccess %s %d %d '%s'", r.Method, pid, uid, c.PolicyKitAction) |
zyga
reviewed
Feb 2, 2016
| const ucrednetNobody = uint32((1 << 32) - 1) | ||
| -func ucrednetGetUID(remoteAddr string) (uint32, error) { | ||
| +func ucrednetGet(remoteAddr string) (uint64, uint32, error) { |
zyga
Feb 2, 2016
Contributor
Personally I'd replace all of the parsing below with a simple generic (and easier to verify) code that splits elements on ';' and then parses each as a key=value. Then the code below could just look up the key uid or pid, convert it to a number and do what it has to do.
Specifically, I'd use: https://golang.org/pkg/strings/#Split
zyga
reviewed
Feb 2, 2016
| + | ||
| + <action id="com.ubuntu.snappy.service-snap"> | ||
| + <description gettext-domain="system-service">Service snaps</description> | ||
| + <message gettext-domain="system-service">Authentication is required to service snaps</message> |
robert-ancell
Feb 2, 2016
Contributor
I don't know - I added policy for all the write operations. I don't know what service means exactly for a snap - ideas for better names welcome.
|
A few comments below but nothing terrible. I would love to see a check that this still builds and works fine on architectures which build go with gccgo as we had a few quirks around C interactions there. |
niemeyer
changed the title from
Add PolicyKit support to snapd
to
daemon,debian: add PolicyKit support to snapd
Feb 2, 2016
|
Before reviewing this, can we have some more context for the proposal? This is likely a good idea, but it's not yet clear if it is a good idea right now. |
chipaca
reviewed
Feb 2, 2016
| + if (reply) | ||
| + sd_bus_message_unref (reply); | ||
| + if (bus) | ||
| + sd_bus_close (bus); |
chipaca
Feb 2, 2016
Member
There doesn't seem to be a manpage for sd_bus_close, does it also do sd_bus_unref?
robert-ancell
added some commits
Feb 2, 2016
|
@niemeyer the purpose of this change is to allow non-root users to install and remove snaps if the system policy allows. For example, a GUI application. |
|
Okay, let's catch up live somewhere to discuss details of this work. |
|
@robert-ancell and we need a user test for this. Talk to me or @fgimenez if you need a hand with this. |
sergiusens
reviewed
Feb 3, 2016
| @@ -66,6 +66,12 @@ var api = []*Command{ | ||
| assertsFindManyCmd, | ||
| } | ||
| +// PolicyKit action names | ||
| +const sideloadSnapAction = "com.ubuntu.snappy.sideload-snap" |
sergiusens
Feb 3, 2016
Contributor
sideload these days means install from somewhere different than the store and provide all the required assertions. I think you are referring to developer snaps here, right?
robert-ancell
Feb 4, 2016
Contributor
I just copied the associated method name sideloadSnap() - if there's a more appropriate name then happy to switch to that.
robert-ancell
added some commits
Feb 12, 2016
|
I close this pull-request temporarily because we discussed various options at the recent sprint in SC and its not clear that this branch is the one we need. |
robert-ancell commentedFeb 2, 2016
Use PolicyKit to authorize write access on the the snapd interface.