ryantimwilson / rpms / systemd

Forked from rpms/systemd a month ago
Clone
Zbigniew Jędrzejewski-Szmek 64282b
From eadc5d94950a04f9fb64cb3906644af04de81970 Mon Sep 17 00:00:00 2001
Zbigniew Jędrzejewski-Szmek 64282b
From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= <zbyszek@in.waw.pl>
Zbigniew Jędrzejewski-Szmek 64282b
Date: Sat, 10 Sep 2016 12:07:51 +0100
Zbigniew Jędrzejewski-Szmek 64282b
Subject: [PATCH] shared/install: fix set-default with empty root (#4118)
Zbigniew Jędrzejewski-Szmek 64282b
Zbigniew Jędrzejewski-Szmek 64282b
https://bugzilla.redhat.com/show_bug.cgi?id=1374371
Zbigniew Jędrzejewski-Szmek 64282b
Zbigniew Jędrzejewski-Szmek 64282b
When root was empty or equal to "/", chroot_symlinks_same was called with
Zbigniew Jędrzejewski-Szmek 64282b
root==NULL, and strjoina returned "", so the code thought both paths are equal
Zbigniew Jędrzejewski-Szmek 64282b
even if they were not. Fix that by always providing a non-null first argument
Zbigniew Jędrzejewski-Szmek 64282b
to strjoina.
Zbigniew Jędrzejewski-Szmek 64282b
(cherry picked from commit ae9efab711e7478b4f035edd00824d518bcf0d3c)
Zbigniew Jędrzejewski-Szmek 64282b
---
Zbigniew Jędrzejewski-Szmek 64282b
 src/shared/install.c | 3 +++
Zbigniew Jędrzejewski-Szmek 64282b
 1 file changed, 3 insertions(+)
Zbigniew Jędrzejewski-Szmek 64282b
Zbigniew Jędrzejewski-Szmek 64282b
diff --git a/src/shared/install.c b/src/shared/install.c
Zbigniew Jędrzejewski-Szmek 64282b
index cb2a2e7e0d..cf1e8349d7 100644
Zbigniew Jędrzejewski-Szmek 64282b
--- a/src/shared/install.c
Zbigniew Jędrzejewski-Szmek 64282b
+++ b/src/shared/install.c
Zbigniew Jędrzejewski-Szmek 64282b
@@ -403,6 +403,9 @@ static bool chroot_symlinks_same(const char *root, const char *wd, const char *a
Zbigniew Jędrzejewski-Szmek 64282b
         /* This will give incorrect results if the paths are relative and go outside
Zbigniew Jędrzejewski-Szmek 64282b
          * of the chroot. False negatives are possible. */
Zbigniew Jędrzejewski-Szmek 64282b
 
Zbigniew Jędrzejewski-Szmek 64282b
+        if (!root)
Zbigniew Jędrzejewski-Szmek 64282b
+                root = "/";
Zbigniew Jędrzejewski-Szmek 64282b
+
Zbigniew Jędrzejewski-Szmek 64282b
         a = strjoina(path_is_absolute(a) ? root : wd, "/", a);
Zbigniew Jędrzejewski-Szmek 64282b
         b = strjoina(path_is_absolute(b) ? root : wd, "/", b);
Zbigniew Jędrzejewski-Szmek 64282b
         return path_equal_or_files_same(a, b);