Merge lp:~ycheng-twn/powerd/powerd_allow-non-root-dbus-cmd into lp:powerd

Proposed by Yuan-Chen Cheng
Status: Merged
Approved by: Ricardo Salveti
Approved revision: 117
Merged at revision: 117
Proposed branch: lp:~ycheng-twn/powerd/powerd_allow-non-root-dbus-cmd
Merge into: lp:powerd
Diff against target: 83 lines (+46/-9)
2 files modified
cli/powerd-cli.c (+1/-2)
debian/powerd.conf (+45/-7)
To merge this branch: bzr merge lp:~ycheng-twn/powerd/powerd_allow-non-root-dbus-cmd
Reviewer Review Type Date Requested Status
Ricardo Salveti (community) Approve
Review via email: mp+209199@code.launchpad.net

Commit message

Allow non-root to talk to powerd.

Description of the change

allow non-root to talk to powerd.

To post a comment you must log in.
Revision history for this message
Ricardo Salveti (rsalveti) wrote :

19 --- debian/changelog 2014-01-29 11:24:39 +0000
20 +++ debian/changelog 2014-03-04 09:18:20 +0000

Please don't change the changelog directly, this will be done by the CI train (please make sure the MR commit message contains whatever you wanted in the changelog though).

34 --- debian/powerd.conf 2013-05-20 17:33:44 +0000
35 +++ debian/powerd.conf 2014-03-04 09:18:20 +0000

I'd prefer if we could only open a few dbus properties and methods, instead of everything. We don't want an app to be able to request a suspend blocker, but we can allow the user to use a custom value for brightness.

I changed the powerd.conf file to only export a few interfaces by default, check http://paste.ubuntu.com/7154678/ (already tested).

8 - myeuid = geteuid();
9 - if (myeuid != 0) {
10 - fprintf(stderr,"You must be root to run %s\n",argv[0]);
11 - return -1;
12 - }

As we might just be exporting a few interfaces, I'd just remove the line with 'return -1', and change the error message saying that running as user is not fully supported.

review: Needs Fixing
Revision history for this message
Ricardo Salveti (rsalveti) wrote :

Looks good, thanks!

review: Approve
Revision history for this message
Ricardo Salveti (rsalveti) wrote :

10 + fprintf(stderr,"%s: Running as user is not fully supported.", argv[0]);

Minor fix, please add '\n' in the end.

$ powerd-cli list
powerd-cli: Running as user is not fully supported.System State Requests:
...

review: Needs Fixing
116. By Yuan-Chen Cheng

add newline

117. By Yuan-Chen Cheng

typo fix

Revision history for this message
Ricardo Salveti (rsalveti) wrote :

Looks good, thanks!

review: Approve
Revision history for this message
Oliver Grawert (ogra) wrote :

Just a FYI, i had to add the "at_console" policy back since it broke all autopilot image tests (scripts need to unlock the screen via adb shell before running)

https://code.launchpad.net/~ogra/powerd/fix-1298869 has the change

Bug #1298869 has details

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'cli/powerd-cli.c'
--- cli/powerd-cli.c 2013-09-24 14:49:49 +0000
+++ cli/powerd-cli.c 2014-03-26 04:58:12 +0000
@@ -1035,8 +1035,7 @@
10351035
1036 myeuid = geteuid();1036 myeuid = geteuid();
1037 if (myeuid != 0) {1037 if (myeuid != 0) {
1038 fprintf(stderr,"You must be root to run %s\n",argv[0]);1038 fprintf(stderr,"%s: Running as user is not fully supported.\n", argv[0]);
1039 return -1;
1040 }1039 }
10411040
1042 signal(SIGINT, sigint_quit);1041 signal(SIGINT, sigint_quit);
10431042
=== modified file 'debian/powerd.conf'
--- debian/powerd.conf 2013-05-20 17:33:44 +0000
+++ debian/powerd.conf 2014-03-26 04:58:12 +0000
@@ -5,20 +5,58 @@
5 "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">5 "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
6<busconfig>6<busconfig>
77
8 <!-- ../system.conf have denied everything, so we just punch some holes -->8 <!-- Only the root user can own the powerd name -->
9
10 <policy user="root">9 <policy user="root">
11 <allow own="com.canonical.powerd"/>10 <allow own="com.canonical.powerd"/>
11 </policy>
12
13 <!-- Permit the root user to invoke all of the methods on powerd,
14 and to get and set properties. -->
15 <policy user="root">
12 <allow send_destination="com.canonical.powerd"/>16 <allow send_destination="com.canonical.powerd"/>
13 <allow send_interface="com.canonical.powerd"/>17 <allow send_interface="com.canonical.powerd"/>
14 </policy>18 </policy>
1519
16 <policy at_console="true">20 <!-- Allow any user to introspect powerd's interfaces, to obtain the
17 <allow send_destination="com.canonical.powerd"/>21 values of properties and only set some of them (brightness). -->
18 </policy>
19
20 <policy context="default">22 <policy context="default">
21 <deny send_destination="com.canonical.powerd"/>23 <allow send_destination="com.canonical.powerd"
24 send_interface="org.freedesktop.DBus.Introspectable" />
25 <allow send_destination="com.canonical.powerd"
26 send_interface="org.freedesktop.DBus.Properties"
27 send_type="method_call" send_member="Get" />
28 <allow send_destination="com.canonical.powerd"
29 send_interface="org.freedesktop.DBus.Properties"
30 send_type="method_call" send_member="GetAll" />
31
32 <allow send_destination="com.canonical.powerd"
33 send_interface="com.canonical.powerd"
34 send_type="method_call" send_member="userAutobrightnessEnable" />
35 <allow send_destination="com.canonical.powerd"
36 send_interface="com.canonical.powerd"
37 send_type="method_call" send_member="getBrightnessParams" />
38 <allow send_destination="com.canonical.powerd"
39 send_interface="com.canonical.powerd"
40 send_type="method_call" send_member="setUserBrightness" />
41
42 <allow send_destination="com.canonical.powerd"
43 send_interface="com.canonical.powerd"
44 send_type="method_call" send_member="listSysRequests" />
45 <allow send_destination="com.canonical.powerd"
46 send_interface="com.canonical.powerd"
47 send_type="method_call" send_member="listDisplayRequests" />
48
49 <allow send_destination="com.canonical.powerd"
50 send_interface="com.canonical.powerd"
51 send_type="method_call" send_member="getSysRequestStats" />
52 <allow send_destination="com.canonical.powerd"
53 send_interface="com.canonical.powerd"
54 send_type="method_call" send_member="getDispRequestStats" />
55
56 <allow send_destination="com.canonical.powerd"
57 send_interface="com.canonical.powerd"
58 send_type="method_call" send_member="userAutobrightnessEnable" />
59
22 </policy>60 </policy>
2361
24</busconfig>62</busconfig>

Subscribers

People subscribed via source and target branches