File 0001-firstboot-fix-permission-bits-initialisation-done-on.patch of Package systemd.1472

From 6b5d7a00e0411bbd06cb6ec4618a368a6b548ccb Mon Sep 17 00:00:00 2001
From: Franck Bui <fbui@suse.com>
Date: Mon, 24 Aug 2015 16:22:50 +0200
Subject: [PATCH] firstboot: fix permission bits initialisation done on
 /etc/locale.conf target file

The bit initialisation was incorrectly placed since chmod() was called after
locale.conf target copy failed.

It was also wrongly done on the host file.

Also did some coding style cleanups.
---
 src/firstboot/firstboot.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/src/firstboot/firstboot.c b/src/firstboot/firstboot.c
index d145a8c..8aed609 100644
--- a/src/firstboot/firstboot.c
+++ b/src/firstboot/firstboot.c
@@ -843,21 +843,20 @@ static int process_locale(void) {
                 mkdir_parents(etc_localeconf, 0755);
                 r = copy_file("/etc/locale.conf", etc_localeconf, 0);
                 if (r != -ENOENT) {
-                        if (r < 0)
-                        {
-                            log_error("Failed to copy %s: %s", etc_localeconf,strerror(-r));
-                            return r;
+                        if (r < 0) {
+                                log_error("Failed to copy %s: %s", etc_localeconf, strerror(-r));
+                                return r;
+                        }
+
+                        r = chmod(etc_localeconf, 0644);
+                        if (r < 0) {
+                                log_error("Failed to chmod 0644 %s: %s", etc_localeconf, strerror(-r));
+                                return r;
                         }
 
                         log_info("%s copied.", etc_localeconf);
                         return 0;
                 }
-                r = chmod ("/etc/locale.conf", S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
-                if (r < 0)
-                {
-                    log_error("Failed to chmod 0644 %s: %s", etc_localeconf,strerror(-r));
-                    return r;
-                }
         }
 
         r = prompt_locale();
@@ -876,10 +875,9 @@ static int process_locale(void) {
 
         mkdir_parents(etc_localeconf, 0755);
         r = write_env_file(etc_localeconf, locales);
-        if (r < 0)
-        {
-            log_error("Failed to write %s: %s", etc_localeconf,strerror(-r));
-            return r;
+        if (r < 0) {
+                log_error("Failed to write %s: %s", etc_localeconf,strerror(-r));
+                return r;
         }
 
         log_info("%s written.", etc_localeconf);
-- 
2.1.4

openSUSE Build Service is sponsored by