Skip to content

Commit f0ca482

Browse files
committed
pacman: allow explicit alternate roots under MSYS
1 parent 859b2bf commit f0ca482

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

patches/pacman/0001-allow-writable-non-root-installation-roots.patch

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ for alternate roots the caller cannot write. When extracting as a non-root
66
user, preserve the package permissions but let the filesystem assign the
77
caller's UID and GID instead of attempting a privileged chown.
88

9+
MSYS has no Unix privilege boundary and cannot reliably apply access(2) to a
10+
Win32 path supplied by the native frontend. There, accept only an explicit
11+
alternate root and let the transaction's filesystem operations reject a path
12+
the current Windows user cannot write.
13+
914
Based on pacman 7.1.0 commit 5683f8477a0afcc6b331766175a83445b2dcfe89.
1015

1116
--- a/lib/libalpm/add.c
@@ -34,15 +39,20 @@ Based on pacman 7.1.0 commit 5683f8477a0afcc6b331766175a83445b2dcfe89.
3439

3540
--- a/src/pacman/pacman.c
3641
+++ b/src/pacman/pacman.c
37-
@@ -1168,6 +1168,13 @@ static void cl_to_log(int argc, char *argv[])
42+
@@ -1168,6 +1168,18 @@ static void cl_to_log(int argc, char *argv[])
3843
}
3944
}
4045

4146
+static int has_writable_alternate_root(void)
4247
+{
43-
+ return config->rootdir != NULL
44-
+ && strcmp(config->rootdir, "/") != 0
45-
+ && access(config->rootdir, W_OK | X_OK) == 0;
48+
+ if(config->rootdir == NULL || strcmp(config->rootdir, "/") == 0) {
49+
+ return 0;
50+
+ }
51+
+#ifdef __MSYS__
52+
+ return 1;
53+
+#else
54+
+ return access(config->rootdir, W_OK | X_OK) == 0;
55+
+#endif
4656
+}
4757
+
4858
/** Main function.

0 commit comments

Comments
 (0)