Skip to content

Commit aaa59d9

Browse files
committed
[refactor] Make changes for SFOS4
1 parent 98a1399 commit aaa59d9

File tree

6 files changed

+23
-66
lines changed

6 files changed

+23
-66
lines changed

rpm/patchmanager.spec

Lines changed: 11 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
%define theme sailfish-default
22

3-
%{!?qtc_qmake:%define qtc_qmake %qmake}
43
%{!?qtc_qmake5:%define qtc_qmake5 %qmake5}
54
%{!?qtc_make:%define qtc_make make}
6-
%{?qtc_builddir:%define _builddir %qtc_builddir}
75

86
Name: patchmanager
97

@@ -16,12 +14,6 @@ URL: https://github.com/sailfishos-patches/patchmanager
1614
Source0: %{name}-%{version}.tar.bz2
1715
Requires: unzip
1816
Requires: patch
19-
Conflicts: jolla-settings-%{name}
20-
Obsoletes: jolla-settings-%{name}
21-
Conflicts: %{name}-ui
22-
Obsoletes: %{name}-ui
23-
Conflicts: prepatch
24-
Obsoletes: prepatch
2517
BuildRequires: pkgconfig(Qt5Core)
2618
BuildRequires: pkgconfig(Qt5DBus)
2719
BuildRequires: pkgconfig(Qt5Qml)
@@ -31,7 +23,8 @@ BuildRequires: pkgconfig(sailfishapp) >= 0.0.10
3123
BuildRequires: sailfish-svg2png >= 0.1.5
3224
BuildRequires: pkgconfig(nemonotifications-qt5)
3325
BuildRequires: qt5-qtdeclarative-devel-tools
34-
BuildRequires: pkgconfig(libsystemd-journal)
26+
BuildRequires: pkgconfig(libshadowutils)
27+
BuildRequires: pkgconfig(systemd)
3528
BuildRequires: qt5-qttools-linguist
3629
BuildRequires: pkgconfig(rpm)
3730

@@ -55,11 +48,11 @@ rm -rf %{buildroot}
5548
/usr/lib/qt5/bin/qmlplugindump -v -noinstantiate -nonrelocatable org.SfietKonstantin.patchmanager 2.0 %{buildroot}%{_libdir}/qt5/qml > %{buildroot}%{_libdir}/qt5/qml/org/SfietKonstantin/%{name}/plugin.qmltypes |:
5649
sed -i 's#%{buildroot}##g' %{buildroot}%{_libdir}/qt5/qml/org/SfietKonstantin/%{name}/plugin.qmltypes
5750

58-
mkdir -p %{buildroot}/lib/systemd/system/multi-user.target.wants/
59-
ln -s ../dbus-org.SfietKonstantin.patchmanager.service %{buildroot}/lib/systemd/system/multi-user.target.wants/
51+
mkdir -p %{buildroot}%{_unitdir}/multi-user.target.wants/
52+
ln -s ../dbus-org.SfietKonstantin.patchmanager.service %{buildroot}%{_unitdir}/multi-user.target.wants/
6053

61-
mkdir -p %{buildroot}/lib/systemd/system/timers.target.wants/
62-
ln -s ../checkForUpdates-org.SfietKonstantin.patchmanager.timer %{buildroot}/lib/systemd/system/timers.target.wants/
54+
mkdir -p %{buildroot}%{_unitdir}/timers.target.wants/
55+
ln -s ../checkForUpdates-org.SfietKonstantin.patchmanager.timer %{buildroot}%{_unitdir}/timers.target.wants/
6356

6457
mkdir -p %{buildroot}/usr/lib/systemd/user/lipstick.service.wants/
6558
ln -s ../lipstick-patchmanager.service %{buildroot}/usr/lib/systemd/user/lipstick.service.wants/
@@ -96,9 +89,6 @@ export NO_PM_PRELOAD=1
9689
case "$*" in
9790
0)
9891
echo Uninstalling package
99-
#if [ -d /var/lib/patchmanager/ausmt/patches/sailfishos-patchmanager-unapplyall ]; then
100-
#/usr/sbin/patchmanager -u sailfishos-patchmanager-unapplyall || true
101-
#fi
10292

10393
systemctl stop dbus-org.SfietKonstantin.patchmanager.service
10494
;;
@@ -113,11 +103,9 @@ export NO_PM_PRELOAD=1
113103
case "$*" in
114104
1)
115105
echo Installing package
116-
#/usr/sbin/patchmanager -a sailfishos-patchmanager-unapplyall || true
117106
;;
118107
2)
119108
echo Upgrading package
120-
#/usr/sbin/patchmanager -a sailfishos-patchmanager-unapplyall || true
121109
;;
122110
*) echo case "$*" not handled in post
123111
esac
@@ -162,14 +150,12 @@ systemctl-user daemon-reload
162150
%{_datadir}/%{name}/tools
163151
%{_datadir}/dbus-1/
164152
%{_sysconfdir}/dbus-1/system.d/
165-
/lib/systemd/system/dbus-org.SfietKonstantin.patchmanager.service
166-
/lib/systemd/system/multi-user.target.wants/dbus-org.SfietKonstantin.patchmanager.service
167-
/lib/systemd/system/checkForUpdates-org.SfietKonstantin.patchmanager.service
168-
/lib/systemd/system/checkForUpdates-org.SfietKonstantin.patchmanager.timer
169-
/lib/systemd/system/timers.target.wants/checkForUpdates-org.SfietKonstantin.patchmanager.timer
153+
%{_unitdir}/dbus-org.SfietKonstantin.patchmanager.service
154+
%{_unitdir}/multi-user.target.wants/dbus-org.SfietKonstantin.patchmanager.service
155+
%{_unitdir}/checkForUpdates-org.SfietKonstantin.patchmanager.service
156+
%{_unitdir}/checkForUpdates-org.SfietKonstantin.patchmanager.timer
157+
%{_unitdir}/timers.target.wants/checkForUpdates-org.SfietKonstantin.patchmanager.timer
170158
%{_sharedstatedir}/environment/patchmanager/10-dbus.conf
171-
#%{_datadir}/patchmanager/patches/sailfishos-patchmanager-unapplyall/patch.json
172-
#%{_datadir}/patchmanager/patches/sailfishos-patchmanager-unapplyall/unified_diff.patch
173159
%{_libdir}/systemd/user/dbus-org.SfietKonstantin.patchmanager.service
174160
%{_libdir}/systemd/user/lipstick-patchmanager.service
175161
%{_libdir}/systemd/user/lipstick.service.wants/lipstick-patchmanager.service
@@ -184,7 +170,6 @@ systemctl-user daemon-reload
184170
%{_datadir}/jolla-settings/pages/%{name}
185171
%{_datadir}/jolla-settings/entries/%{name}.json
186172
%{_datadir}/%{name}/icons/icon-m-patchmanager.png
187-
%attr(644,nemo,nemo) %ghost /home/nemo/.config/patchmanager2.conf
188173

189174
%{_datadir}/themes/%{theme}/meegotouch/z1.0/icons/*.png
190175
%{_datadir}/themes/%{theme}/meegotouch/z1.25/icons/*.png

src/bin/dialog/main.cpp

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,6 @@
1111
#include <QDBusReply>
1212
#include <QTimer>
1313

14-
QString getLang()
15-
{
16-
QString lang = QStringLiteral("en_US.utf8");
17-
18-
QFile localeConfig(QStringLiteral("/var/lib/environment/nemo/locale.conf"));
19-
20-
if (!localeConfig.exists() || !localeConfig.open(QFile::ReadOnly)) {
21-
return lang;
22-
}
23-
24-
while (!localeConfig.atEnd()) {
25-
QString line = localeConfig.readLine().trimmed();
26-
if (line.startsWith(QStringLiteral("LANG="))) {
27-
lang = line.mid(5);
28-
break;
29-
}
30-
}
31-
32-
qDebug() << Q_FUNC_INFO << lang;
33-
34-
return lang;
35-
}
36-
3714
int main(int argc, char *argv[])
3815
{
3916
qputenv("NO_PM_PRELOAD", "1");
@@ -47,7 +24,7 @@ int main(int argc, char *argv[])
4724
QScopedPointer<QGuiApplication> app(SailfishApp::application(argc, argv));
4825

4926
QTranslator translator;
50-
bool success = translator.load(QLocale(getLang()),
27+
bool success = translator.load(QLocale(),
5128
QStringLiteral("settings-patchmanager"),
5229
QStringLiteral("-"),
5330
QStringLiteral("/usr/share/translations/"),

src/bin/dialog/systemd/lipstick-patchmanager.service

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ PartOf=lipstick.service
44

55
[Service]
66
ExecStart=/bin/sleep infinity
7-
ExecStartPost=/bin/dbus-send --print-reply --system --dest=org.SfietKonstantin.patchmanager /org/SfietKonstantin/patchmanager org.SfietKonstantin.patchmanager.lipstickChanged "string:started"
8-
ExecStop=/bin/dbus-send --print-reply --system --dest=org.SfietKonstantin.patchmanager /org/SfietKonstantin/patchmanager org.SfietKonstantin.patchmanager.lipstickChanged "string:stopped"
9-
ExecReload=/bin/dbus-send --print-reply --system --dest=org.SfietKonstantin.patchmanager /org/SfietKonstantin/patchmanager org.SfietKonstantin.patchmanager.lipstickChanged "string:reloaded"
7+
ExecStartPost=/usr/bin/env dbus-send --print-reply --system --dest=org.SfietKonstantin.patchmanager /org/SfietKonstantin/patchmanager org.SfietKonstantin.patchmanager.lipstickChanged "string:started"
8+
ExecStop=/usr/bin/env dbus-send --print-reply --system --dest=org.SfietKonstantin.patchmanager /org/SfietKonstantin/patchmanager org.SfietKonstantin.patchmanager.lipstickChanged "string:stopped"
9+
ExecReload=/usr/bin/env dbus-send --print-reply --system --dest=org.SfietKonstantin.patchmanager /org/SfietKonstantin/patchmanager org.SfietKonstantin.patchmanager.lipstickChanged "string:reloaded"
1010

1111
[Install]
1212
WantedBy=lipstick.service

src/bin/patchmanager-daemon/patchmanager-daemon.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ TARGET = patchmanager
44
QT = core dbus network
55
CONFIG += link_pkgconfig
66
PKGCONFIG += nemonotifications-qt5
7-
PKGCONFIG += libsystemd-journal
7+
PKGCONFIG += systemd
88
PKGCONFIG += rpm
99

1010
INCLUDEPATH += "/home/OMP/a.kozhevnikov/SailfishOS2/mersdk/targets/SailfishOS-2.2.1.7-armv7hl/usr/include/"

src/preload/preload.pro

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
TEMPLATE = lib
22
QT =
33
CONFIG += plugin
4+
CONFIG += link_pkgconfig
5+
PKGCONFIG += libshadowutils
6+
INCLUDEPATH += /usr/include/libshadowutils
47
QMAKE_CFLAGS += -std=c11
58

69
LIBS = -ldl

src/preload/src/preloadpatchmanager.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ static orig_open_f_type orig_open64 = NULL;
2626
#include <limits.h>
2727
#include <libgen.h>
2828

29+
#include <getdef.h>
2930
#include <pwd.h>
3031

3132
#define SERVER_PATH "/tmp/patchmanager-socket"
@@ -95,26 +96,17 @@ static void pm_name(char new_name[]) {
9596
close(sockfd);
9697
}
9798

98-
static uid_t nemo_uid()
99+
inline uid_t user_uid()
99100
{
100-
static struct passwd *nemo_pwd;
101-
102-
if (!nemo_pwd) {
103-
nemo_pwd = getpwnam("nemo");
104-
if (!nemo_pwd) {
105-
return 100000;
106-
}
107-
}
108-
109-
return nemo_pwd->pw_uid;
101+
return getdef_num("UID_MIN", 100000);
110102
}
111103

112104
static int pm_validate_uid(uid_t uid)
113105
{
114106
#ifdef ALLOW_ALL_USERS
115107
return 1;
116108
#else // #ifdef ALLOW_ALL_USERS
117-
return uid == nemo_uid();
109+
return uid >= user_uid();
118110
#endif // #ifdef ALLOW_ALL_USERS
119111
}
120112

0 commit comments

Comments
 (0)