-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gpkg/libogg gpkg/libopus gpkg/libflac gpkg/libvorbis gpkg/libmpg123 gpkg/libmp3lame gpkg/libsndfile gpkg/libpulse gpkg/libxtst gpkg/dbus Other changes (by @Maxython): gpkg/glibc: disable syscalls `__NR_setresgid`, `__NR_setuid`, `__NR_setgid` and `__NR_symlink` gpkg/glibc: adding user/group verification according to the android standard and access changing user/group information
- Loading branch information
1 parent
5087005
commit c814809
Showing
40 changed files
with
1,441 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
TERMUX_PKG_HOMEPAGE=https://dbus.freedesktop.org | ||
TERMUX_PKG_DESCRIPTION="Freedesktop.org message bus system" | ||
TERMUX_PKG_LICENSE="GPL-2.0" | ||
TERMUX_PKG_MAINTAINER="@termux-pacman" | ||
TERMUX_PKG_VERSION=1.15.6 | ||
TERMUX_PKG_SRCURL="https://dbus.freedesktop.org/releases/dbus/dbus-$TERMUX_PKG_VERSION.tar.xz" | ||
TERMUX_PKG_SHA256=f97f5845f9c4a5a1fb3df67dfa9e16b5a3fd545d348d6dc850cb7ccc9942bd8c | ||
TERMUX_PKG_DEPENDS="libexpat-glibc, libx11-glibc" | ||
TERMUX_PKG_BUILD_IN_SRC=true | ||
TERMUX_PKG_EXTRA_CONFIGURE_ARGS=" | ||
--disable-libaudit | ||
--disable-systemd | ||
--disable-tests | ||
--disable-xml-docs | ||
--enable-inotify | ||
--enable-x11-autolaunch | ||
--with-test-socket-dir=$TERMUX_PREFIX_CLASSICAL/tmp | ||
--with-session-socket-dir=$TERMUX_PREFIX_CLASSICAL/tmp | ||
--with-x=auto | ||
" | ||
|
||
termux_step_create_debscripts() { | ||
{ | ||
echo "#!${TERMUX_PREFIX}/bin/sh" | ||
echo "if [ ! -e ${TERMUX_PREFIX}/var/lib/dbus/machine-id ]; then" | ||
echo "mkdir -p ${TERMUX_PREFIX}/var/lib/dbus" | ||
echo "dbus-uuidgen > ${TERMUX_PREFIX}/var/lib/dbus/machine-id" | ||
echo "fi" | ||
echo "exit 0" | ||
} > postinst | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
diff -uNr dbus-1.12.16/dbus/dbus-sysdeps-unix.c dbus-1.12.16.mod/dbus/dbus-sysdeps-unix.c | ||
--- dbus-1.12.16/dbus/dbus-sysdeps-unix.c 2019-05-13 12:33:56.000000000 +0300 | ||
+++ dbus-1.12.16.mod/dbus/dbus-sysdeps-unix.c 2019-08-15 02:15:37.825982953 +0300 | ||
@@ -3602,7 +3602,7 @@ | ||
|
||
/* And this is the sane fallback. */ | ||
if (tmpdir == NULL) | ||
- tmpdir = "/tmp"; | ||
+ tmpdir = "@TERMUX_PREFIX_CLASSICAL@/tmp"; | ||
} | ||
|
||
_DBUS_UNLOCK (sysdeps); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,284 @@ | ||
/* This script stores functions similar to those from | ||
the bionic library, thanks to which passwd/group | ||
structures are created. | ||
*/ | ||
|
||
#ifndef _ANDROID_PASSWD_GROUP | ||
#define _ANDROID_PASSWD_GROUP | ||
|
||
#include <stdio.h> | ||
#include <unistd.h> | ||
#include <stdlib.h> | ||
#include <string.h> | ||
#include <ctype.h> | ||
#include "android_passwd_group.h" | ||
|
||
struct android_id_info * find_android_id_info_by_id(unsigned id) { | ||
for (size_t n = 0; n < android_id_count; ++n) | ||
if (android_ids[n].aid == id) | ||
return &android_ids[n]; | ||
return NULL; | ||
} | ||
|
||
struct android_id_info * find_android_id_info_by_name(const char* name) { | ||
for (size_t n = 0; n < android_id_count; ++n) | ||
if (!strcmp(android_ids[n].name, name)) | ||
return &android_ids[n]; | ||
return NULL; | ||
} | ||
|
||
int is_oem_id_android(id_t id) { | ||
if (id >= AID_OEM_RESERVED_START && id < AID_EVERYBODY && find_android_id_info_by_id(id) == NULL) | ||
return 1; | ||
|
||
return (id >= AID_OEM_RESERVED_START && id <= AID_OEM_RESERVED_END) || | ||
(id >= AID_OEM_RESERVED_2_START && id <= AID_OEM_RESERVED_2_END); | ||
} | ||
|
||
int is_valid_id_android(id_t id, int is_group) { | ||
if (id >= AID_USER_OFFSET) | ||
return 0; | ||
|
||
struct IdRange * ranges; | ||
size_t ranges_size; | ||
id_t appid = id % AID_USER_OFFSET; | ||
|
||
if (appid == AID_OVERFLOWUID) | ||
return 0; | ||
|
||
if (is_group) { | ||
ranges_size = sizeof(group_ranges)/sizeof(group_ranges[0]); | ||
ranges = group_ranges; | ||
} else { | ||
ranges_size = sizeof(user_ranges)/sizeof(user_ranges[0]); | ||
ranges = user_ranges; | ||
} | ||
|
||
if (appid < ranges[0].start) | ||
return 1; | ||
|
||
if (appid >= AID_SHARED_GID_START && appid <= AID_SHARED_GID_END && appid != id) | ||
return 0; | ||
|
||
for (size_t i = 0; i < ranges_size; ++i) | ||
if (appid >= ranges[i].start && appid <= ranges[i].end) | ||
return 1; | ||
|
||
return 0; | ||
} | ||
|
||
static id_t oem_id_from_name_android(const char* name) { | ||
unsigned int id; | ||
if (sscanf(name, "oem_%u", &id) != 1) { | ||
return 0; | ||
} | ||
if (!is_oem_id_android(id)) { | ||
return 0; | ||
} | ||
return (id_t)id; | ||
} | ||
|
||
static id_t app_id_from_name_android(const char* name, int is_group) { | ||
char* end; | ||
unsigned long userid; | ||
struct android_id_info* info; | ||
int is_shared_gid = 0; | ||
|
||
if (is_group && name[0] == 'a' && name[1] == 'l' && name[2] == 'l') { | ||
end = malloc(strlen(name)); | ||
for (int i=3; i<strlen(name); i++) | ||
sprintf(end, "%s%c", end, name[i]); | ||
userid = 0; | ||
is_shared_gid = 1; | ||
} else if (name[0] == 'u' && isdigit(name[1])) { | ||
userid = strtoul(name+1, &end, 10); | ||
} else { | ||
return 0; | ||
} | ||
|
||
if (end[0] != '_' || end[1] == 0) { | ||
return 0; | ||
} | ||
|
||
unsigned long appid = 0; | ||
if (end[1] == 'a' && isdigit(end[2])) { | ||
if (is_shared_gid) { | ||
appid = strtoul(end+2, &end, 10) + AID_SHARED_GID_START; | ||
if (appid > AID_SHARED_GID_END) { | ||
return 0; | ||
} | ||
} else { | ||
appid = strtoul(end+2, &end, 10); | ||
if (is_group) { | ||
if (!strcmp(end, "_ext_cache")) { | ||
end += 10; | ||
appid += AID_EXT_CACHE_GID_START; | ||
} else if (!strcmp(end, "_ext")) { | ||
end += 4; | ||
appid += AID_EXT_GID_START; | ||
} else if (!strcmp(end, "_cache")) { | ||
end += 6; | ||
appid += AID_CACHE_GID_START; | ||
} else { | ||
appid += AID_APP_START; | ||
} | ||
} else { | ||
appid += AID_APP_START; | ||
} | ||
} | ||
} else if (end[1] == 'i' && isdigit(end[2])) { | ||
appid = strtoul(end+2, &end, 10) + AID_ISOLATED_START; | ||
} else if ((info = find_android_id_info_by_name(end + 1)) != NULL) { | ||
appid = info->aid; | ||
end += strlen(info->name) + 1; | ||
} | ||
|
||
if (end[0] != 0) { | ||
return 0; | ||
} | ||
|
||
if (userid > 1000) { | ||
return 0; | ||
} | ||
|
||
if (appid >= AID_USER_OFFSET) { | ||
return 0; | ||
} | ||
|
||
return (appid + userid*AID_USER_OFFSET); | ||
} | ||
|
||
void get_name_by_uid_android(uid_t uid, char *name_u) { | ||
uid_t appid = uid % AID_USER_OFFSET; | ||
uid_t userid = uid / AID_USER_OFFSET; | ||
struct android_id_info* info; | ||
|
||
if (appid >= AID_ISOLATED_START) { | ||
sprintf(name_u, "u%u_i%u", userid, appid - AID_ISOLATED_START); | ||
} else if (appid < AID_APP_START) { | ||
if ((info = find_android_id_info_by_id(appid)) != NULL) | ||
sprintf(name_u, "%s", info->name); | ||
} else { | ||
sprintf(name_u, "u%u_a%u", userid, appid - AID_APP_START); | ||
} | ||
} | ||
|
||
void get_name_by_gid_android(gid_t gid, char *name_g) { | ||
uid_t appid = gid % AID_USER_OFFSET; | ||
uid_t userid = gid / AID_USER_OFFSET; | ||
struct android_id_info* info; | ||
|
||
if (appid >= AID_ISOLATED_START) { | ||
sprintf(name_g, "u%u_i%u", userid, appid - AID_ISOLATED_START); | ||
} else if (userid == 0 && appid >= AID_SHARED_GID_START && appid <= AID_SHARED_GID_END) { | ||
sprintf(name_g, "all_a%u", appid - AID_SHARED_GID_START); | ||
} else if (appid >= AID_EXT_CACHE_GID_START && appid <= AID_EXT_CACHE_GID_END) { | ||
sprintf(name_g, "u%u_a%u_ext_cache", userid, appid - AID_EXT_CACHE_GID_START); | ||
} else if (appid >= AID_EXT_GID_START && appid <= AID_EXT_GID_END) { | ||
sprintf(name_g, "u%u_a%u_ext", userid, appid - AID_EXT_GID_START); | ||
} else if (appid >= AID_CACHE_GID_START && appid <= AID_CACHE_GID_END) { | ||
sprintf(name_g, "u%u_a%u_cache", userid, appid - AID_CACHE_GID_START); | ||
} else if (appid < AID_APP_START) { | ||
if ((info = find_android_id_info_by_id(appid)) != NULL) | ||
sprintf(name_g, "%s", info->name); | ||
} else { | ||
sprintf(name_g, "u%u_a%u", userid, appid - AID_APP_START); | ||
} | ||
} | ||
|
||
struct passwd * get_passwd_android(char* name, uid_t uid) { | ||
static struct passwd res; | ||
|
||
res.pw_name = name; | ||
res.pw_passwd = "*"; | ||
res.pw_uid = uid; | ||
res.pw_gid = uid; | ||
res.pw_gecos = ""; | ||
res.pw_dir = APP_HOME_DIR; | ||
res.pw_shell = APP_PREFIX_DIR "/bin/login"; | ||
|
||
return &res; | ||
} | ||
|
||
struct group * get_group_android(char* name, gid_t gid) { | ||
static struct group res; | ||
|
||
res.gr_name = name; | ||
res.gr_passwd = NULL; | ||
res.gr_gid = gid; | ||
res.gr_mem = (char *[2]){(char *)name, NULL}; | ||
|
||
return &res; | ||
} | ||
|
||
struct passwd * getpwuid_android(uid_t uid) { | ||
char* name_res = malloc(64); | ||
|
||
if (is_oem_id_android(uid)) | ||
sprintf(name_res, "oem_%u", uid); | ||
else { | ||
if (!is_valid_id_android(uid, 0)) | ||
return NULL; | ||
get_name_by_uid_android(uid, name_res); | ||
if (strlen(name_res) == 0) | ||
return NULL; | ||
} | ||
|
||
return get_passwd_android(name_res, uid); | ||
} | ||
|
||
struct group * getgrgid_android(gid_t gid) { | ||
char* name_res = malloc(64); | ||
|
||
if (is_oem_id_android(gid)) | ||
sprintf(name_res, "oem_%u", gid); | ||
else { | ||
if (!is_valid_id_android(gid, 1)) | ||
return NULL; | ||
get_name_by_gid_android(gid, name_res); | ||
if (strlen(name_res) == 0) | ||
return NULL; | ||
} | ||
|
||
return get_group_android(name_res, gid); | ||
} | ||
|
||
struct passwd * getpwnam_android(char* name) { | ||
uid_t uid; | ||
struct android_id_info* info; | ||
|
||
uid = app_id_from_name_android(name, 0); | ||
if (uid != 0) | ||
return get_passwd_android(name, uid); | ||
|
||
uid = oem_id_from_name_android(name); | ||
if (uid != 0) | ||
return get_passwd_android(name, uid); | ||
|
||
info = find_android_id_info_by_name(name); | ||
if (info != NULL) | ||
return get_passwd_android(name, info->aid); | ||
|
||
return NULL; | ||
} | ||
|
||
struct group * getgrnam_android(char* name) { | ||
gid_t gid; | ||
struct android_id_info* info; | ||
|
||
gid = app_id_from_name_android(name, 1); | ||
if (gid != 0) | ||
return get_group_android(name, gid); | ||
|
||
gid = oem_id_from_name_android(name); | ||
if (gid != 0) | ||
return get_group_android(name, gid); | ||
|
||
info = find_android_id_info_by_name(name); | ||
if (info != NULL) | ||
return get_group_android(name, info->aid); | ||
|
||
return NULL; | ||
} | ||
|
||
#endif // _ANDROID_PASSWD_GROUP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#ifndef _ANDROID_PASSWD_GROUP_H | ||
#define _ANDROID_PASSWD_GROUP_H | ||
|
||
#include <pwd.h> | ||
#include <grp.h> | ||
#include "android_ids.h" | ||
|
||
struct android_id_info * find_android_id_info_by_id(unsigned id); | ||
struct android_id_info * find_android_id_info_by_name(const char* name); | ||
int is_oem_id_android(id_t id); | ||
int is_valid_id_android(id_t id, int is_group); | ||
static id_t oem_id_from_name_android(const char* name); | ||
static id_t app_id_from_name_android(const char* name, int is_group); | ||
void get_name_by_uid_android(uid_t uid, char *name_u); | ||
void get_name_by_gid_android(gid_t gid, char *name_g); | ||
struct passwd * get_passwd_android(char* name, uid_t uid); | ||
struct group * get_group_android(char* name, gid_t gid); | ||
struct passwd * getpwuid_android(uid_t uid); | ||
struct group * getgrgid_android(gid_t gid); | ||
struct passwd * getpwnam_android(char* name); | ||
struct group * getgrnam_android(char* name); | ||
|
||
#endif // _ANDROID_PASSWD_GROUP_H |
Oops, something went wrong.