Changeset View
Changeset View
Standalone View
Standalone View
greeter/greeterapp.cpp
Show All 17 Lines | |||||
18 | You should have received a copy of the GNU General Public License | 18 | You should have received a copy of the GNU General Public License | ||
19 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 19 | along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
20 | *********************************************************************/ | 20 | *********************************************************************/ | ||
21 | #include "greeterapp.h" | 21 | #include "greeterapp.h" | ||
22 | #include "kscreensaversettings.h" | 22 | #include "kscreensaversettings.h" | ||
23 | #include "authenticator.h" | 23 | #include "authenticator.h" | ||
24 | #include "noaccessnetworkaccessmanagerfactory.h" | 24 | #include "noaccessnetworkaccessmanagerfactory.h" | ||
25 | #include "wallpaper_integration.h" | 25 | #include "wallpaper_integration.h" | ||
26 | #include <config-kscreenlocker.h> | ||||
26 | 27 | | |||
27 | // KDE | 28 | // KDE | ||
28 | #include <KAuthorized> | 29 | #include <KAuthorized> | ||
29 | #include <KCrash> | 30 | #include <KCrash> | ||
30 | #include <kdeclarative/kdeclarative.h> | 31 | #include <kdeclarative/kdeclarative.h> | ||
31 | #include <KDeclarative/KQuickAddons/QuickViewSharedEngine> | 32 | #include <KDeclarative/KQuickAddons/QuickViewSharedEngine> | ||
32 | #include <KDeclarative/QmlObjectSharedEngine> | 33 | #include <KDeclarative/QmlObjectSharedEngine> | ||
33 | #include <KUser> | 34 | #include <KUser> | ||
Show All 28 Lines | |||||
62 | #include <wayland-ksld-client-protocol.h> | 63 | #include <wayland-ksld-client-protocol.h> | ||
63 | // X11 | 64 | // X11 | ||
64 | #include <X11/Xatom.h> | 65 | #include <X11/Xatom.h> | ||
65 | #include <X11/Xlib.h> | 66 | #include <X11/Xlib.h> | ||
66 | #include <fixx11h.h> | 67 | #include <fixx11h.h> | ||
67 | // | 68 | // | ||
68 | #include <xcb/xcb.h> | 69 | #include <xcb/xcb.h> | ||
69 | 70 | | |||
71 | #if HAVE_SECCOMP | ||||
72 | #include <sys/stat.h> | ||||
73 | #include <unistd.h> | ||||
74 | #endif | ||||
75 | | ||||
70 | // this is usable to fake a "screensaver" installation for testing | 76 | // this is usable to fake a "screensaver" installation for testing | ||
71 | // *must* be "0" for every public commit! | 77 | // *must* be "0" for every public commit! | ||
72 | #define TEST_SCREENSAVER 0 | 78 | #define TEST_SCREENSAVER 0 | ||
73 | 79 | | |||
74 | namespace ScreenLocker | 80 | namespace ScreenLocker | ||
75 | { | 81 | { | ||
76 | 82 | | |||
77 | class FocusOutEventFilter : public QAbstractNativeEventFilter | 83 | class FocusOutEventFilter : public QAbstractNativeEventFilter | ||
Show All 15 Lines | |||||
93 | // App | 99 | // App | ||
94 | UnlockApp::UnlockApp(int &argc, char **argv) | 100 | UnlockApp::UnlockApp(int &argc, char **argv) | ||
95 | : QGuiApplication(argc, argv) | 101 | : QGuiApplication(argc, argv) | ||
96 | , m_resetRequestIgnoreTimer(new QTimer(this)) | 102 | , m_resetRequestIgnoreTimer(new QTimer(this)) | ||
97 | , m_delayedLockTimer(0) | 103 | , m_delayedLockTimer(0) | ||
98 | , m_testing(false) | 104 | , m_testing(false) | ||
99 | , m_ignoreRequests(false) | 105 | , m_ignoreRequests(false) | ||
100 | , m_immediateLock(false) | 106 | , m_immediateLock(false) | ||
101 | , m_authenticator(new Authenticator(Authenticator::AuthenticationMode::Direct, this)) | | |||
102 | , m_graceTime(0) | 107 | , m_graceTime(0) | ||
103 | , m_noLock(false) | 108 | , m_noLock(false) | ||
104 | , m_defaultToSwitchUser(false) | 109 | , m_defaultToSwitchUser(false) | ||
105 | , m_wallpaperIntegration(new WallpaperIntegration(this)) | 110 | , m_wallpaperIntegration(new WallpaperIntegration(this)) | ||
106 | { | 111 | { | ||
112 | m_authenticator = createAuthenticator(); | ||||
107 | connect(m_authenticator, &Authenticator::succeeded, this, &QCoreApplication::quit); | 113 | connect(m_authenticator, &Authenticator::succeeded, this, &QCoreApplication::quit); | ||
108 | initialize(); | 114 | initialize(); | ||
109 | connect(this, &UnlockApp::screenAdded, this, &UnlockApp::desktopResized); | 115 | connect(this, &UnlockApp::screenAdded, this, &UnlockApp::desktopResized); | ||
110 | connect(this, &UnlockApp::screenRemoved, this, &UnlockApp::desktopResized); | 116 | connect(this, &UnlockApp::screenRemoved, this, &UnlockApp::desktopResized); | ||
111 | 117 | | |||
112 | if (QX11Info::isPlatformX11()) { | 118 | if (QX11Info::isPlatformX11()) { | ||
113 | installNativeEventFilter(new FocusOutEventFilter); | 119 | installNativeEventFilter(new FocusOutEventFilter); | ||
114 | } | 120 | } | ||
Show All 11 Lines | 124 | { | |||
126 | } | 132 | } | ||
127 | if (m_ksldConnection) { | 133 | if (m_ksldConnection) { | ||
128 | m_ksldConnection->deleteLater(); | 134 | m_ksldConnection->deleteLater(); | ||
129 | m_ksldConnectionThread->quit(); | 135 | m_ksldConnectionThread->quit(); | ||
130 | m_ksldConnectionThread->wait(); | 136 | m_ksldConnectionThread->wait(); | ||
131 | } | 137 | } | ||
132 | } | 138 | } | ||
133 | 139 | | |||
140 | Authenticator *UnlockApp::createAuthenticator() | ||||
141 | { | ||||
142 | #if HAVE_SECCOMP | ||||
143 | struct stat buf; | ||||
144 | stat(KCHECKPASS_BIN, &buf); | ||||
145 | if (!(buf.st_mode & S_ISUID)) { | ||||
146 | m_supportsSeccomp = true; | ||||
147 | return new Authenticator(Authenticator::AuthenticationMode::Delayed, this); | ||||
148 | } | ||||
broulik: Might lead to an unreachable code warning? | |||||
why should it? The code looks quite reachable to me. If kcheckpass is setuid it uses the code from line 151. graesslin: why should it? The code looks quite reachable to me. If kcheckpass is setuid it uses the code… | |||||
Yeah but it will lead to code in the form of return new Authenticator(Authenticator::AuthenticationMode::Delayed, this); return new Authenticator(Authenticator::AuthenticationMode::Direct, this); the latter being unreachable. Just being picky here, though, feel free to ignore. broulik: Yeah but it will lead to code in the form of
```
return new Authenticator(Authenticator… | |||||
That is totally fine. Having different return values in different paths is quite common. E.g. an early exit with a return nullptr. graesslin: That is totally fine. Having different return values in different paths is quite common. E.g. | |||||
149 | #endif | ||||
150 | return new Authenticator(Authenticator::AuthenticationMode::Direct, this); | ||||
151 | } | ||||
152 | | ||||
134 | void UnlockApp::initialize() | 153 | void UnlockApp::initialize() | ||
135 | { | 154 | { | ||
136 | initializeWayland(); | 155 | initializeWayland(); | ||
137 | // set up the request ignore timeout, so that multiple requests to sleep/suspend/shutdown | 156 | // set up the request ignore timeout, so that multiple requests to sleep/suspend/shutdown | ||
138 | // are not processed in quick (and confusing) succession) | 157 | // are not processed in quick (and confusing) succession) | ||
139 | m_resetRequestIgnoreTimer->setSingleShot(true); | 158 | m_resetRequestIgnoreTimer->setSingleShot(true); | ||
140 | m_resetRequestIgnoreTimer->setInterval(2000); | 159 | m_resetRequestIgnoreTimer->setInterval(2000); | ||
141 | connect(m_resetRequestIgnoreTimer, &QTimer::timeout, this, &UnlockApp::resetRequestIgnore); | 160 | connect(m_resetRequestIgnoreTimer, &QTimer::timeout, this, &UnlockApp::resetRequestIgnore); | ||
▲ Show 20 Lines • Show All 564 Lines • Show Last 20 Lines |
Might lead to an unreachable code warning?