Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge branch 'jb47634_datetime_permissions' into 'master'
Limit settings change to sailfish-datetime group members

See merge request mer-core/timed!15
  • Loading branch information
spiiroin committed Nov 21, 2019
2 parents da63f85 + a14c42e commit 01946ba
Show file tree
Hide file tree
Showing 23 changed files with 178 additions and 153 deletions.
5 changes: 4 additions & 1 deletion rpm/timed-qt5.spec
Expand Up @@ -13,7 +13,7 @@ Requires: tzdata-timed
Requires: systemd
Requires: oneshot
Requires: statefs
Requires: sailfish-setup >= 0.1.7
Requires: sailfish-setup >= 0.1.8
%{_oneshot_groupadd_requires_pre}
%{_oneshot_requires_post}
%{_oneshot_groupadd_requires_post}
Expand Down Expand Up @@ -95,6 +95,7 @@ chmod 755 %{buildroot}%{_oneshotdir}/setcaps-%{name}.sh
install -d %{buildroot}/var/lib/timed
touch %{buildroot}/var/lib/timed/localtime
install -d %{buildroot}/var/lib/timed/shared_events
install -d %{buildroot}/var/lib/timed/shared_settings
# Make /etc/localtime a link to /var/lib/timed/localtime to make system time zone follow timed.
install -d %{buildroot}%{_sysconfdir}
ln -sf /var/lib/timed/localtime %{buildroot}%{_sysconfdir}/localtime
Expand Down Expand Up @@ -153,8 +154,10 @@ fi
%{_oneshotdir}/setcaps-%{name}.sh
%dir %attr(0775,-,timed) /var/lib/timed
%dir %attr(02770,root,sailfish-alarms) /var/lib/timed/shared_events
%dir %attr(02775,root,sailfish-datetime) /var/lib/timed/shared_settings
%ghost /var/lib/timed/localtime
%ghost /var/lib/timed/shared_events/events.data
%ghost /var/lib/timed/shared_settings/settings.data

%files tests
%defattr(-,root,root,-)
Expand Down
4 changes: 0 additions & 4 deletions src/lib/event
@@ -1,6 +1,2 @@
#include <QtGlobal>
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <timed-qt5/event-declarations.h>
#else
#include <timed/event-declarations.h>
#endif
4 changes: 0 additions & 4 deletions src/lib/hidden/exception
@@ -1,6 +1,2 @@
#include <QtGlobal>
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <timed-qt5/exception.h>
#else
#include <timed/exception.h>
#endif
5 changes: 0 additions & 5 deletions src/lib/interface
@@ -1,7 +1,2 @@

#include <QtGlobal>
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <timed-qt5/interface.h>
#else
#include <timed/interface.h>
#endif
5 changes: 0 additions & 5 deletions src/lib/wallclock
@@ -1,7 +1,2 @@

#include <QtGlobal>
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <timed-qt5/wall-declarations.h>
#else
#include <timed/wall-declarations.h>
#endif
6 changes: 6 additions & 0 deletions src/server/adaptor.h
Expand Up @@ -109,6 +109,12 @@ public slots:
{
Q_UNUSED(message);
log_notice("DBUS::com.nokia.time.wall_clock_settings(%s) by %s", p.SQC, PEER) ;
if (!timed->permissions_shared_settings(true)) {
/* Settings application should hide relevant controls, so we do not
* normally expect to see requests that would need to be denied. */
log_warning("changing settings denied");
return false;
}
// log_debug("%s", string_std_to_q(p.str()).c_str()) ;
return timed->settings->wall_clock_settings(p) ;
}
Expand Down
6 changes: 0 additions & 6 deletions src/server/backup.cpp
Expand Up @@ -25,15 +25,9 @@
***************************************************************************/

#include <QtGlobal>
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <iodata-qt5/iodata>
#include <iodata-qt5/validator>
#include <iodata-qt5/storage>
#else
#include <iodata/iodata>
#include <iodata/validator>
#include <iodata/storage>
#endif

#include "queue.type.h"
#include "settings.type.h"
Expand Down
1 change: 1 addition & 0 deletions src/server/config.type
Expand Up @@ -18,6 +18,7 @@ config_t =
{ name = "queue_threshold_short", type = $integer, value = 1000 },
{ name = "data_directory", type = $bytes, value = ".timed" },
{ name = "shared_events_directory", type = $bytes, value = "/var/lib/timed/shared_events" },
{ name = "shared_settings_directory", type = $bytes, value = "/var/lib/timed/shared_settings" },
{ name = "settings_file", type = $bytes, value = "settings.data" },
{ name = "events_file", type = $bytes, value = "events.data" },

Expand Down
4 changes: 0 additions & 4 deletions src/server/credentials.h
Expand Up @@ -36,11 +36,7 @@ using namespace std ;
#include <QDBusMessage>
#include <QDBusConnection>

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <iodata-qt5/iodata>
#else
#include <iodata/iodata>
#endif

uint32_t get_name_owner_from_dbus_sync(const QDBusConnection &bus, const QString &name) ;

Expand Down
4 changes: 0 additions & 4 deletions src/server/event.h
Expand Up @@ -34,11 +34,7 @@ using namespace std ;

#include <QDBusPendingCallWatcher>

#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <iodata-qt5/iodata>
#else
#include <iodata/iodata>
#endif

#include "../lib/event-declarations.h"
#include "../lib/event-pimple.h"
Expand Down
21 changes: 10 additions & 11 deletions src/server/settings.cpp
Expand Up @@ -133,17 +133,16 @@ source_settings::source_settings(Timed *owner) : QObject(owner)
// new options:
alarms_are_enabled = false ;
default_snooze_value = 300 ;
#define _creat(xxx) src[#xxx] = xxx = new xxx##_t ;
_creat(manual_utc) ;
_creat(nitz_utc) ;
_creat(gps_utc) ;
_creat(ntp_utc) ;
_creat(manual_offset) ;
_creat(nitz_offset) ;
_creat(manual_zone) ;
_creat(cellular_zone) ;
_creat(app_snooze) ;
#undef _creat // spell it without 'e' ;-)

src["manual_utc"] = manual_utc = new manual_utc_t;
src["nitz_utc"] = nitz_utc = new nitz_utc_t;
src["gps_utc"] = gps_utc = new gps_utc_t;
src["ntp_utc"] = ntp_utc = new ntp_utc_t;
src["manual_offset"] = manual_offset = new manual_offset_t;
src["nitz_offset"] = nitz_offset = new nitz_offset_t;
src["manual_zone"] = manual_zone = new manual_zone_t;
src["cellular_zone"] = cellular_zone = new cellular_zone_t;
src["app_snooze"] = app_snooze = new app_snooze_t;
}

source_settings::~source_settings()
Expand Down
4 changes: 0 additions & 4 deletions src/server/settings.h
Expand Up @@ -27,11 +27,7 @@
#include <string>

#include <QtGlobal>
#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0)
#include <iodata-qt5/iodata>
#else
#include <iodata/iodata>
#endif

#include "../lib/nanotime.h"
#include "../lib/wall-declarations.h"
Expand Down
1 change: 1 addition & 0 deletions src/server/timed-qt5.rc
@@ -1,4 +1,5 @@
data_directory = ".timed",
shared_events_directory = "/var/lib/timed/shared_events",
shared_settings_directory = "/var/lib/timed/shared_settings",
events_file = "events.data",
settings_file = "settings.data" .

0 comments on commit 01946ba

Please sign in to comment.