Merge lp:~mvo/click/lp1394256-run-user-hooks-on-remove-too into lp:click/devel

Proposed by Michael Vogt on 2014-12-05
Status: Merged
Merged at revision: 553
Proposed branch: lp:~mvo/click/lp1394256-run-user-hooks-on-remove-too
Merge into: lp:click/devel
Prerequisite: lp:~mvo/click/lp1394256-run-user-hooks
Diff against target: 68 lines (+29/-7)
1 file modified
lib/click/user.vala (+29/-7)
To merge this branch: bzr merge lp:~mvo/click/lp1394256-run-user-hooks-on-remove-too
Reviewer Review Type Date Requested Status
click hackers 2014-12-05 Pending
Review via email: mp+243812@code.launchpad.net

This proposal supersedes a proposal from 2014-12-05.

Description of the change

This branch runs the click remove user hooks for all logged in users.
Based on lp:~mvo/click/lp1394256-run-user-hooks

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/click/user.vala'
2--- lib/click/user.vala 2014-12-05 15:11:52 +0000
3+++ lib/click/user.vala 2014-12-05 15:11:52 +0000
4@@ -612,13 +612,13 @@
5
6 // run user hooks for all logged in users
7 if (name == ALL_USERS)
8- run_user_hooks_for_all_logged_in_users (package, old_version, version);
9+ run_user_install_hooks_for_all_logged_in_users (package, old_version, version);
10 }
11
12- private void
13- run_user_hooks_for_all_logged_in_users (string package, string? old_version,
14- string version) throws IOError
15+ private string[]
16+ get_logged_in_users()
17 {
18+ string[] logged_in_users = {};
19 try {
20 LogindManager logind = Bus.get_proxy_sync (
21 BusType.SYSTEM,
22@@ -630,14 +630,32 @@
23 // FIXME: ideally we would read from /etc/adduser.conf
24 if(user.uid >= 1000 && user.uid <= 30000)
25 {
26- package_install_hooks (db, package,
27- old_version, version, user.name);
28+ logged_in_users += user.name;
29 }
30 }
31 } catch (Error e) {
32 warning ("Can not connect to logind");
33- return;
34 }
35+ return logged_in_users;
36+ }
37+
38+ private void
39+ run_user_install_hooks_for_all_logged_in_users (string package,
40+ string? old_version,
41+ string version) throws IOError
42+ {
43+ foreach (string username in get_logged_in_users())
44+ package_install_hooks (db, package,
45+ old_version, version, username);
46+ }
47+
48+ private void
49+ run_user_remove_hooks_for_all_logged_in_users (string package,
50+ string old_version) throws IOError
51+ {
52+ foreach (string username in get_logged_in_users())
53+ package_remove_hooks (db, package,
54+ old_version, username);
55 }
56
57 private bool
58@@ -730,6 +748,10 @@
59
60 if (! is_pseudo_user)
61 package_remove_hooks (db, package, old_version, name);
62+
63+ // run user hooks for all logged in users
64+ if (name == ALL_USERS)
65+ run_user_remove_hooks_for_all_logged_in_users (package, old_version);
66 }
67
68 /**

Subscribers

People subscribed via source and target branches

to all changes: