这是indexloc提供的服务,不要输入任何密码
Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
237 changes: 237 additions & 0 deletions disabled-packages/elogind/0001-polyfill.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
Bionic libc doesn't have the following symbols:
- `secure_getenv`
- `program_invocation[_short]_name`
- `get_current_dir_name`
- `RLIMIT_NLIMITS`
- `sigisemptyset`
- `malloc_trim`
- `semctl`/`msgctl`
- `exp10`
- `fputs_unlocked`/`fputc_unlocked` (Available from API 28)
- `syncfs` (Available from API 28)
- `pthread_setaffinity_np`

--- a/src/basic/musl_missing.h
+++ b/src/basic/musl_missing.h
@@ -16,6 +16,10 @@
*
****************************************************************/

+#if HAVE_PROGRAM_INVOCATION_NAME == 0
+extern char *program_invocation_name;
+extern char *program_invocation_short_name;
+#endif

void elogind_set_program_name(const char* pcall);

@@ -30,7 +30,9 @@
#include <unistd.h>
#include <pthread.h> /* for pthread_atfork */

+#ifndef __ANDROID__
#define strerror_r(e, m, k) (strerror_r(e, m, k) < 0 ? strdup("strerror_r() failed") : m);
+#endif

/*
* Possibly TODO according to http://man7.org/linux/man-pages/man3/getenv.3.html
@@ -37,12 +37,18 @@
* + test if the effective capability bit was set on the executable file
* + test if the process has a nonempty permitted capability set
*/
+#ifndef __ANDROID__
#if ! HAVE_SECURE_GETENV && ! HAVE___SECURE_GETENV
# define secure_getenv(name) \
(issetugid() ? NULL : getenv(name))
# undef HAVE_SECURE_GETENV
# define HAVE_SECURE_GETENV 1
#endif // HAVE_[__]SECURE_GETENV
+#else
+#define secure_getenv(name) getenv(name)
+#undef HAVE_SECURE_GETENV
+#define HAVE_SECURE_GETENV 1
+#endif

#if ! HAVE_BASENAME
/* Poor man's basename */
--- a/src/basic/macro.h
+++ b/src/basic/macro.h
@@ -390,3 +390,4 @@
_current_++)

#include "log.h"
+#include "musl_missing.h"
--- a/src/basic/path-util.c
+++ b/src/basic/path-util.c
@@ -55,6 +55,17 @@
return path_join(prefix, p);
}

+#ifdef __ANDROID__
+static char *get_current_dir_name(void) {
+ char pwd[PATH_MAX];
+ char *ret = getcwd(pwd, sizeof(pwd));
+ if (ret == NULL) {
+ return NULL;
+ }
+ return strdup(pwd);
+}
+#endif
+
int safe_getcwd(char **ret) {
_cleanup_free_ char *cwd = NULL;

--- a/src/basic/process-util.c
+++ b/src/basic/process-util.c
@@ -5,7 +5,7 @@
//#include <limits.h>
//#include <linux/oom.h>
#include <pthread.h>
-#include <spawn.h>
+// #include <spawn.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
--- a/src/basic/missing_resource.h
+++ b/src/basic/missing_resource.h
@@ -7,5 +7,9 @@
#define RLIMIT_RTTIME 15
#endif

+#ifndef RLIMIT_NLIMITS
+#define RLIMIT_NLIMITS RLIMIT_RTTIME
+#endif
+
/* If RLIMIT_RTTIME is not defined, then we cannot use RLIMIT_NLIMITS as is */
#define _RLIMIT_MAX (RLIMIT_RTTIME+1 > RLIMIT_NLIMITS ? RLIMIT_RTTIME+1 : RLIMIT_NLIMITS)
--- a/src/libelogind/sd-journal/journal-file.h
+++ b/src/libelogind/sd-journal/journal-file.h
@@ -4,6 +4,7 @@
#include <fcntl.h>
#include <inttypes.h>
//#include <sys/uio.h>
+#include <sys/stat.h>

#if HAVE_GCRYPT
# include <gcrypt.h>
--- a/src/libelogind/sd-event/sd-event.c
+++ b/src/libelogind/sd-event/sd-event.c
@@ -790,6 +790,14 @@
return r;
}

+#ifdef __ANDROID__
+static int sigisemptyset(sigset_t* __set) {
+ struct sigaction sact;
+ sigemptyset(&sact.sa_mask);
+ return memcmp(__set, &sact.sa_mask, sizeof(sigset_t));
+}
+#endif
+
static void event_unmask_signal_data(sd_event *e, struct signal_data *d, int sig) {
assert(e);
assert(d);
@@ -1873,6 +1881,10 @@
return 0;
}

+#ifdef __ANDROID__
+#define malloc_trim(pad) (0)
+#endif
+
_public_ int sd_event_trim_memory(void) {
int r;

--- a/src/shared/clean-ipc.c
+++ b/src/shared/clean-ipc.c
@@ -8,8 +8,14 @@
#include <stdio.h>
#include <sys/ipc.h>
#include <sys/msg.h>
-#include <sys/sem.h>
-#include <sys/shm.h>
+// #include <sys/sem.h>
+// #include <sys/shm.h>
+#ifdef __ANDROID__
+// Doesn't work on Android, so just stub them.
+#define shmctl(...) (-1)
+#define semctl(...) (-1)
+#define msgctl(...) (-1)
+#endif
#include <sys/stat.h>
#include <unistd.h>

--- a/src/shared/json.c
+++ b/src/shared/json.c
@@ -2712,6 +2712,10 @@

*p = c;

+#ifdef __ANDROID__
+#define exp10(x) (pow(10.0, x))
+#endif
+
if (is_real) {
ret->real = ((negative ? -1.0 : 1.0) * (x + (y / shift))) * exp10((exponent_negative ? -1.0 : 1.0) * exponent);
return JSON_TOKEN_REAL;
--- a/src/basic/string-table.h
+++ b/src/basic/string-table.h
@@ -102,6 +102,11 @@
#define DEFINE_PRIVATE_STRING_TABLE_LOOKUP_FROM_STRING_FALLBACK(name,type,max) \
_DEFINE_STRING_TABLE_LOOKUP_FROM_STRING_FALLBACK(name,type,max,static)

+#if defined(__ANDROID__) && __ANDROID_API__ < 28
+#define fputs_unlocked(c, f) (fputs(c, f))
+#define fputc_unlocked(c, f) (fputc(c, f))
+#endif
+
#define DUMP_STRING_TABLE(name,type,max) \
do { \
flockfile(stdout); \
--- a/src/shared/rm-rf.c
+++ b/src/shared/rm-rf.c
@@ -6,6 +6,11 @@
#include <stddef.h>
#include <unistd.h>

+#if defined __ANDROID__ && __ANDROID_API__ < 28
+#include <sys/syscall.h>
+#define syncfs(fd) (syscall(SYS_syncfs, fd))
+#endif
+
#include "alloc-util.h"
#include "btrfs-util.h"
#include "cgroup-util.h"
@@ -20,6 +25,7 @@
#include "stat-util.h"
#include "string-util.h"

+
/* We treat tmpfs/ramfs + cgroupfs as non-physical file systems. cgroupfs is similar to tmpfs in a way
* after all: we can create arbitrary directory hierarchies in it, and hence can also use rm_rf() on it
* to remove those again. */
--- a/src/libelogind/sd-bus/test-bus-benchmark.c
+++ b/src/libelogind/sd-bus/test-bus-benchmark.c
@@ -290,7 +290,11 @@
if (pid == 0) {
CPU_ZERO(&cpuset);
CPU_SET(0, &cpuset);
+#ifndef __ANDROID__
pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
+#else
+ sched_setaffinity(pthread_gettid_np(pthread_self()), sizeof(cpu_set_t), &cpuset);
+#endif

safe_close(bus_ref);
sd_bus_unref(b);
@@ -310,7 +314,11 @@

CPU_ZERO(&cpuset);
CPU_SET(1, &cpuset);
+#ifndef __ANDROID__
pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
+#else
+ sched_setaffinity(pthread_gettid_np(pthread_self()), sizeof(cpu_set_t), &cpuset);
+#endif

server(b, &result);

100 changes: 100 additions & 0 deletions disabled-packages/elogind/0002-disable-shadow.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
--- a/src/shared/user-record-nss.h
+++ b/src/shared/user-record-nss.h
@@ -2,9 +2,15 @@
#pragma once

#include <grp.h>
+#ifdef ENABLE_GSHADOW
#include <gshadow.h>
+#endif
#include <pwd.h>
+#ifndef __ANDROID__
#include <shadow.h>
+#else
+struct spwd {};
+#endif

//#include "group-record.h"
#include "user-record.h"
--- a/src/shared/user-record-nss.c
+++ b/src/shared/user-record-nss.c
@@ -50,8 +50,13 @@
if (isempty(pwd->pw_name))
return -EINVAL;

+#ifndef __ANDROID__
if (spwd && !streq_ptr(spwd->sp_namp, pwd->pw_name))
return -EINVAL;
+#else
+ if (spwd)
+ return -EINVAL;
+#endif

hr = user_record_new();
if (!hr)
@@ -92,6 +97,7 @@
hr->uid = pwd->pw_uid;
hr->gid = pwd->pw_gid;

+#ifndef __ANDROID__
if (spwd &&
looks_like_hashed_password(utf8_only(spwd->sp_pwdp))) { /* Ignore locked, disabled, and mojibake passwords */
strv_free_erase(hr->hashed_password);
@@ -137,6 +143,7 @@
SET_IF(hr->password_change_inactive_usec,
spwd && spwd->sp_inact > 0 && (uint64_t) spwd->sp_inact <= (UINT64_MAX-1)/USEC_PER_DAY,
spwd->sp_inact * USEC_PER_DAY, UINT64_MAX);
+#endif

hr->json = json_variant_unref(hr->json);
r = json_build(&hr->json, JSON_BUILD_OBJECT(
@@ -168,6 +175,9 @@
}

int nss_spwd_for_passwd(const struct passwd *pwd, struct spwd *ret_spwd, char **ret_buffer) {
+#ifdef __ANDROID__
+ return -EIO;
+#else
size_t buflen = 4096;
int r;

@@ -203,6 +213,7 @@
buflen *= 2;
buf = mfree(buf);
}
+#endif
}

int nss_user_record_by_name(
@@ -244,6 +255,7 @@
buf = mfree(buf);
}

+#ifndef __ANDROID__
if (with_shadow) {
r = nss_spwd_for_passwd(result, &spwd, &sbuf);
if (r < 0) {
@@ -252,6 +264,7 @@
} else
sresult = &spwd;
} else
+#endif
incomplete = true;

r = nss_passwd_to_user_record(result, sresult, ret);
@@ -299,6 +312,7 @@
buf = mfree(buf);
}

+#ifndef __ANDROID__
if (with_shadow) {
r = nss_spwd_for_passwd(result, &spwd, &sbuf);
if (r < 0) {
@@ -307,6 +321,7 @@
} else
sresult = &spwd;
} else
+#endif
incomplete = true;

r = nss_passwd_to_user_record(result, sresult, ret);
33 changes: 33 additions & 0 deletions disabled-packages/elogind/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
TERMUX_PKG_HOMEPAGE=https://github.com/elogind/elogind
TERMUX_PKG_DESCRIPTION="The systemd project's logind, extracted to a standalone package"
TERMUX_PKG_LICENSE="GPL-2.0-or-later, LGPL-2.1-or-later"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=255.17
TERMUX_PKG_SRCURL=https://github.com/elogind/elogind/archive/refs/tags/v$TERMUX_PKG_VERSION.tar.gz
TERMUX_PKG_SHA256=a9725ae3f73f8d910de84c108bc11bfd4c782bef6a4190b2ec70c5d2f22344db
TERMUX_PKG_DEPENDS="libcap, libmount, libudev-zero"
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
-Dmode=release
-Dsysconfdir=$TERMUX_PREFIX/etc
-Dlocalstatedir=$TERMUX_PREFIX/var
-Dhalt-path=$TERMUX_PREFIX/bin/false
-Dpoweroff-path=$TERMUX_PREFIX/bin/false
-Dreboot-path=$TERMUX_PREFIX/bin/false
-Dkexec-path=$TERMUX_PREFIX/bin/false
-Dnologin-path=$TERMUX_PREFIX/bin/false
-Ddefault-user-shell=$TERMUX_PREFIX/bin/bash
-Duser-path=$TERMUX_PREFIX/bin:/system/bin
-Ddefault-kill-user-processes=false
-Dsplit-bin=false
-Dutmp=false
-Defi=false
"

termux_step_post_get_source() {
# Prefer meson build
rm -f configure
}

termux_step_pre_configure() {
termux_setup_meson
}
11 changes: 11 additions & 0 deletions disabled-packages/libudev-zero/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
TERMUX_PKG_HOMEPAGE=https://github.com/adriancable/8086tiny
TERMUX_PKG_DESCRIPTION="Daemonless replacement for libudev"
TERMUX_PKG_LICENSE="ISC"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=1.0.3
TERMUX_PKG_SRCURL=https://github.com/illiliti/libudev-zero/archive/refs/tags/$TERMUX_PKG_VERSION.tar.gz
TERMUX_PKG_SHA256=0bd89b657d62d019598e6c7ed726ff8fed80e8ba092a83b484d66afb80b77da5
TERMUX_PKG_BUILD_IN_SRC=true
TERMUX_PKG_EXTRA_MAKE_ARGS="
PREFIX=$TERMUX_PREFIX
"
Loading