Browse Source

apk-tools: don't set ownership and xattrs

Such functionality causes 'permission denied' errors in Termux as
we don't require root permissions for installing packages.
android-5
Leonid Plyushch 6 years ago
committed by Fredrik Fornwall
parent
commit
1bc661ce86
  1. 47
      disabled-packages/apk-tools/src-archive.c.patch
  2. 27
      disabled-packages/apk-tools/src-database.c.patch
  3. 16
      disabled-packages/apk-tools/src-io.c.patch

47
disabled-packages/apk-tools/src-archive.c.patch

@ -1,6 +1,6 @@
diff -u -r ../apk-tools-2.10.1/src/archive.c ./src/archive.c
--- ../apk-tools-2.10.1/src/archive.c 2018-09-10 08:04:03.000000000 +0000
+++ ./src/archive.c 2018-09-10 21:48:51.234399333 +0000
diff -uNr apk-tools-2.10.3/src/archive.c apk-tools-2.10.3.mod/src/archive.c
--- apk-tools-2.10.3/src/archive.c 2018-11-15 15:09:07.000000000 +0200
+++ apk-tools-2.10.3.mod/src/archive.c 2018-11-18 14:39:33.811301837 +0200
@@ -20,6 +20,7 @@
#include <sysexits.h>
#include <sys/wait.h>
@ -9,3 +9,44 @@ diff -u -r ../apk-tools-2.10.1/src/archive.c ./src/archive.c
#include <sys/xattr.h>
#include <limits.h>
#include <stdint.h>
@@ -441,7 +442,9 @@
struct apk_istream *is,
apk_progress_cb cb, void *cb_ctx)
{
+#ifndef __ANDROID__
struct apk_xattr *xattr;
+#endif
const char *fn = extract_name ?: ae->name;
int fd, r = -1, atflags = 0, ret = 0;
@@ -487,12 +490,14 @@
return ret;
}
+#ifndef __ANDROID__
r = fchownat(atfd, fn, ae->uid, ae->gid, atflags);
if (r < 0) {
apk_error("Failed to set ownership on %s: %s",
fn, strerror(errno));
if (!ret) ret = -errno;
}
+#endif
/* chown resets suid bit so we need set it again */
if (ae->mode & 07000) {
@@ -506,6 +511,7 @@
}
/* extract xattrs */
+#ifndef __ANDROID__
if (!S_ISLNK(ae->mode) && ae->xattrs && ae->xattrs->num) {
r = 0;
fd = openat(atfd, fn, O_RDWR);
@@ -527,6 +533,7 @@
if (!ret) ret = r;
}
}
+#endif
if (!S_ISLNK(ae->mode)) {
/* preserve modification time */

27
disabled-packages/apk-tools/src-database.c.patch

@ -1,6 +1,6 @@
diff -u -r ../apk-tools-2.10.3/src/database.c ./src/database.c
--- ../apk-tools-2.10.3/src/database.c 2018-11-15 13:09:07.000000000 +0000
+++ ./src/database.c 2018-11-18 01:05:38.568983268 +0000
diff -uNr apk-tools-2.10.3/src/database.c apk-tools-2.10.3.mod/src/database.c
--- apk-tools-2.10.3/src/database.c 2018-11-15 15:09:07.000000000 +0200
+++ apk-tools-2.10.3.mod/src/database.c 2018-11-18 19:16:02.755222559 +0200
@@ -1332,10 +1332,11 @@
static int apk_db_create(struct apk_database *db)
{
@ -23,3 +23,24 @@ diff -u -r ../apk-tools-2.10.3/src/database.c ./src/database.c
db->root_fd = openat(AT_FDCWD, db->root, O_RDONLY | O_CLOEXEC);
if (db->root_fd < 0 && (dbopts->open_flags & APK_OPENF_CREATE)) {
mkdirat(AT_FDCWD, db->root, 0755);
@@ -1931,7 +1932,7 @@
int status;
pid_t pid;
static char * const environment[] = {
- "PATH=/usr/sbin:/usr/bin:/sbin:/bin",
+ "PATH=@TERMUX_PREFIX@/bin:@TERMUX_PREFIX@/bin/applets",
NULL
};
@@ -1968,9 +1969,10 @@
r = fstatat(db->root_fd, dir->name, &st, AT_SYMLINK_NOFOLLOW);
if (r < 0 || (st.st_mode & 07777) != (dir->mode & 07777))
fchmodat(db->root_fd, dir->name, dir->mode, 0);
+#ifndef __ANDROID__
if (r < 0 || st.st_uid != dir->uid || st.st_gid != dir->gid)
fchownat(db->root_fd, dir->name, dir->uid, dir->gid, 0);
-
+#endif
return 0;
}

16
disabled-packages/apk-tools/src-io.c.patch

@ -1,7 +1,7 @@
diff -u -r ../apk-tools-2.10.1/src/io.c ./src/io.c
--- ../apk-tools-2.10.1/src/io.c 2018-09-10 08:04:03.000000000 +0000
+++ ./src/io.c 2018-09-10 21:56:03.349469566 +0000
@@ -1005,6 +1005,7 @@
diff -uNr apk-tools-2.10.3/src/io.c apk-tools-2.10.3.mod/src/io.c
--- apk-tools-2.10.3/src/io.c 2018-11-15 15:09:07.000000000 +0200
+++ apk-tools-2.10.3.mod/src/io.c 2018-11-18 19:15:25.081674847 +0200
@@ -1012,6 +1012,7 @@
.delete_item = (apk_hash_delete_f) free,
};
@ -9,7 +9,7 @@ diff -u -r ../apk-tools-2.10.1/src/io.c ./src/io.c
static struct cache_item *resolve_cache_item(struct apk_hash *hash, apk_blob_t name)
{
struct cache_item *ci;
@@ -1025,6 +1026,7 @@
@@ -1032,6 +1033,7 @@
return ci;
}
@ -17,7 +17,7 @@ diff -u -r ../apk-tools-2.10.1/src/io.c ./src/io.c
void apk_id_cache_init(struct apk_id_cache *idc, int root_fd)
{
@@ -1049,6 +1051,9 @@
@@ -1056,6 +1058,9 @@
uid_t apk_resolve_uid(struct apk_id_cache *idc, const char *username, uid_t default_uid)
{
@ -27,7 +27,7 @@ diff -u -r ../apk-tools-2.10.1/src/io.c ./src/io.c
#ifdef HAVE_FGETPWENT_R
char buf[1024];
struct passwd pwent;
@@ -1088,10 +1093,14 @@
@@ -1095,10 +1100,14 @@
return ci->uid;
return default_uid;
@ -42,7 +42,7 @@ diff -u -r ../apk-tools-2.10.1/src/io.c ./src/io.c
#ifdef HAVE_FGETGRENT_R
char buf[1024];
struct group grent;
@@ -1131,4 +1140,5 @@
@@ -1138,4 +1147,5 @@
return ci->gid;
return default_gid;

Loading…
Cancel
Save