aboutsummaryrefslogtreecommitdiffstats
path: root/community/openrc-settingsd/0002-Ensure-0664-permissions-on-etc-localtime.patch
blob: 345f76d410dd500dd33600029c6ac42ed8e6d13d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
From fdeef40875bebf3970d1365dc92cb893a0298097 Mon Sep 17 00:00:00 2001
From: Rasmus Thomsen <oss@cogitri.dev>
Date: Fri, 3 Jul 2020 12:19:52 +0200
Subject: [PATCH 2/2] Ensure 0664 permissions on /etc/localtime

Otherwise the timezone couldn't be read by other users
---
 src/timedated.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/src/timedated.c b/src/timedated.c
index a6779f9..77d12ee 100644
--- a/src/timedated.c
+++ b/src/timedated.c
@@ -26,6 +26,7 @@
 
 #include <dbus/dbus-protocol.h>
 #include <glib.h>
+#include <glib/gstdio.h>
 #include <gio/gio.h>
 
 #if HAVE_OPENRC
@@ -135,6 +136,9 @@ set_timezone (const gchar *_timezone_name,
         g_prefix_error (error, "Unable to write '%s':", timezone_filename);
         goto out;
     }
+    if(g_chmod (timezone_filename, 0664) != 0) {
+        g_set_error (error, G_IO_ERROR, G_IO_ERROR_PERMISSION_DENIED, "Unable to set 0664 permissions on timezone file '%s'", timezone_filename);
+    }
 
     localtime_filename = g_file_get_path (localtime_file);
     localtime2_filename = g_strdup_printf (DATADIR "/zoneinfo/%s", _timezone_name);
@@ -158,6 +162,9 @@ set_timezone (const gchar *_timezone_name,
             g_prefix_error (error, "Unable to write '%s':", localtime_filename);
             goto out;
         }
+        if(g_chmod (localtime_filename, 0664) != 0) {
+            g_set_error (error, G_IO_ERROR, G_IO_ERROR_PERMISSION_DENIED, "Unable to set 0664 permissions on localtime file '%s'", localtime_filename);
+        }
     } else {
         // File doesn't exist yet -> make a new symlink
         if (!g_file_make_symbolic_link (localtime_file, localtime2_filename, NULL, error)) {
-- 
2.26.2