Merge lp:~azzar1/unity/lp-1413790 into lp:unity

Proposed by Andrea Azzarone
Status: Merged
Approved by: Stephen M. Webb
Approved revision: no longer in the source branch.
Merged at revision: 3913
Proposed branch: lp:~azzar1/unity/lp-1413790
Merge into: lp:unity
Diff against target: 54 lines (+18/-1)
2 files modified
UnityCore/GnomeSessionManager.cpp (+16/-1)
UnityCore/GnomeSessionManagerImpl.h (+2/-0)
To merge this branch: bzr merge lp:~azzar1/unity/lp-1413790
Reviewer Review Type Date Requested Status
Stephen M. Webb (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+247397@code.launchpad.net

Commit message

Make unity unlockable if user is in nopsswdlogin group. On super+l the screensaver is activated.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Stephen M. Webb (bregma) wrote :

Approved as discussed.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'UnityCore/GnomeSessionManager.cpp'
2--- UnityCore/GnomeSessionManager.cpp 2015-01-14 00:10:20 +0000
3+++ UnityCore/GnomeSessionManager.cpp 2015-01-24 00:58:29 +0000
4@@ -22,6 +22,8 @@
5 #include <NuxCore/Logger.h>
6 #include "Variant.h"
7
8+#include <grp.h>
9+
10 namespace unity
11 {
12 namespace session
13@@ -483,6 +485,18 @@
14 return inhibitors.GetBool();
15 }
16
17+bool GnomeManager::Impl::IsUserInGroup(std::string const& user_name, std::string const& group_name)
18+{
19+ auto group = getgrnam(group_name.c_str());
20+
21+ if (group && group->gr_mem)
22+ for (int i = 0; group->gr_mem[i]; ++i)
23+ if (g_strcmp0(group->gr_mem[i], user_name.c_str()) == 0)
24+ return true;
25+
26+ return false;
27+}
28+
29 // Public implementation
30
31 GnomeManager::GnomeManager()
32@@ -654,7 +668,8 @@
33 glib::Object<GSettings> lockdown_settings(g_settings_new(GNOME_LOCKDOWN_OPTIONS.c_str()));
34
35 if (g_settings_get_boolean(lockdown_settings, DISABLE_LOCKSCREEN_KEY.c_str()) ||
36- UserName().find("guest-") == 0 || is_locked())
37+ UserName().find("guest-") == 0 ||
38+ impl_->IsUserInGroup(UserName(), "nopasswdlogin"))
39 {
40 return false;
41 }
42
43=== modified file 'UnityCore/GnomeSessionManagerImpl.h'
44--- UnityCore/GnomeSessionManagerImpl.h 2014-05-16 04:24:05 +0000
45+++ UnityCore/GnomeSessionManagerImpl.h 2015-01-24 00:58:29 +0000
46@@ -64,6 +64,8 @@
47 bool InteractiveMode();
48 void UpdateHaveOtherOpenSessions();
49
50+ bool IsUserInGroup(std::string const& user_name, std::string const& group_name);
51+
52 GnomeManager* manager_;
53 bool test_mode_;
54 bool can_shutdown_;