summaryrefslogtreecommitdiffstats
path: root/fakechroot-2.8-relchroot.patch
blob: 4d2b0930777bc18128f9c34ca574e2ae0aa0b721 (plain)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
This patch must be applied to fakechroot 2.8 or SVN in order to
enable correct handling of relative chroots, for rpm and yum.

Note this patch has been included in upstream fakechroot >= 2.9

Index: src/libfakechroot.c
===================================================================
--- src/libfakechroot.c	(revision 311)
+++ src/libfakechroot.c	(working copy)
@@ -1147,7 +1147,7 @@
 {
     char *ptr, *ld_library_path, *tmp, *fakechroot_path;
     int status, len;
-    char dir[FAKECHROOT_MAXPATH], cwd[FAKECHROOT_MAXPATH], full_path[FAKECHROOT_MAXPATH];
+    char dir[FAKECHROOT_MAXPATH], cwd[FAKECHROOT_MAXPATH];
 #if !defined(HAVE_SETENV)
     char *envbuf;
 #endif
@@ -1162,7 +1162,9 @@
         return -1;
     }
     if (*path != '/') {
-        if (getcwd(cwd, FAKECHROOT_MAXPATH) == NULL) {
+        if (next_getcwd == NULL) fakechroot_init();
+
+        if (next_getcwd(cwd, FAKECHROOT_MAXPATH) == NULL) {
             errno = ENAMETOOLONG;
             return -1;
         }
@@ -1171,24 +1173,22 @@
             return -1;
         }
         if (strcmp(cwd, "/") == 0) {
-            snprintf(full_path, FAKECHROOT_MAXPATH, "/%s", path);
+            snprintf(dir, FAKECHROOT_MAXPATH, "/%s", path);
         }
         else {
-            snprintf(full_path, FAKECHROOT_MAXPATH, "%s/%s", cwd, path);
+            snprintf(dir, FAKECHROOT_MAXPATH, "%s/%s", cwd, path);
         }
     }
     else {
-        snprintf(full_path, FAKECHROOT_MAXPATH, "%s", path);
-    }
+	fakechroot_path = getenv("FAKECHROOT_BASE");
 
-    fakechroot_path = getenv("FAKECHROOT_BASE");
-
-    if (fakechroot_path != NULL) {
-        snprintf(dir, FAKECHROOT_MAXPATH, "%s%s", fakechroot_path, full_path);
+	if (fakechroot_path != NULL) {
+	    snprintf(dir, FAKECHROOT_MAXPATH, "%s%s", fakechroot_path, path);
+	}
+	else {
+	    snprintf(dir, FAKECHROOT_MAXPATH, "%s", path);
+	}
     }
-    else {
-        snprintf(dir, FAKECHROOT_MAXPATH, "%s", full_path);
-    }
 
 #if defined(HAVE___XSTAT) && defined(_STAT_VER)
     if ((status = next___xstat(_STAT_VER, dir, &sb)) != 0) {