From 6cf4d6d4d189587ed2594fbd39dfdb8daaaa4ad9 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Fri, 17 Jun 2022 17:26:16 -0500 Subject: [PATCH] Switch shadow.h and utmpx.h from compile time probes to __has_include(). This does mean "make defconfig" can't automatically drop them out, but the platforms that don't have this aren't building defconfig anyway. --- lib/portability.h | 4 ++-- scripts/genconfig.sh | 21 --------------------- toys/lsb/passwd.c | 1 - toys/lsb/su.c | 1 - toys/other/login.c | 1 - toys/other/uptime.c | 1 - toys/other/w.c | 1 - toys/pending/sulogin.c | 1 - toys/posix/who.c | 1 - 9 files changed, 2 insertions(+), 30 deletions(-) diff --git a/lib/portability.h b/lib/portability.h index a0e64ac4..40314aeb 100644 --- a/lib/portability.h +++ b/lib/portability.h @@ -240,10 +240,10 @@ static inline long statfs_frsize(struct statfs *sf) { return sf->f_frsize; } // Android is missing some headers and functions // "generated/config.h" is included first -#if CFG_TOYBOX_SHADOW +#if __has_include() #include #endif -#if CFG_TOYBOX_UTMPX +#if __has_include() #include #else struct utmpx {int ut_type;}; diff --git a/scripts/genconfig.sh b/scripts/genconfig.sh index 2c1a242b..1108f609 100755 --- a/scripts/genconfig.sh +++ b/scripts/genconfig.sh @@ -23,27 +23,6 @@ probesymbol() probeconfig() { - # Android and some other platforms miss utmpx - probesymbol TOYBOX_UTMPX -c << EOF - #include - #ifndef BOOT_TIME - #error nope - #endif - int main(int argc, char *argv[]) { - struct utmpx *a; - if (0 != (a = getutxent())) return 0; - return 1; - } -EOF - - # Android is missing shadow.h - probesymbol TOYBOX_SHADOW -c << EOF - #include - int main(int argc, char *argv[]) { - struct spwd *a = getspnam("root"); return 0; - } -EOF - # Some commands are android-specific probesymbol TOYBOX_ON_ANDROID -c << EOF #ifndef __ANDROID__ diff --git a/toys/lsb/passwd.c b/toys/lsb/passwd.c index 8c17dc6d..6c822e88 100644 --- a/toys/lsb/passwd.c +++ b/toys/lsb/passwd.c @@ -10,7 +10,6 @@ USE_PASSWD(NEWTOY(passwd, ">1a:dlu", TOYFLAG_STAYROOT|TOYFLAG_USR|TOYFLAG_BIN)) config PASSWD bool "passwd" default y - depends on TOYBOX_SHADOW help usage: passwd [-a ALGO] [-dlu] [USER] diff --git a/toys/lsb/su.c b/toys/lsb/su.c index 136e81ed..74a87dbd 100644 --- a/toys/lsb/su.c +++ b/toys/lsb/su.c @@ -12,7 +12,6 @@ USE_SU(NEWTOY(su, "^lmpu:g:c:s:[!lmp]", TOYFLAG_BIN|TOYFLAG_ROOTONLY)) config SU bool "su" default y - depends on TOYBOX_SHADOW help usage: su [-lp] [-u UID] [-g GID,...] [-s SHELL] [-c CMD] [USER [COMMAND...]] diff --git a/toys/other/login.c b/toys/other/login.c index 5214b937..46fe0f67 100644 --- a/toys/other/login.c +++ b/toys/other/login.c @@ -10,7 +10,6 @@ USE_LOGIN(NEWTOY(login, ">1f:ph:", TOYFLAG_BIN|TOYFLAG_NEEDROOT)) config LOGIN bool "login" default y - depends on TOYBOX_SHADOW help usage: login [-p] [-h host] [-f USERNAME] [USERNAME] diff --git a/toys/other/uptime.c b/toys/other/uptime.c index 6c0c8052..237bba63 100644 --- a/toys/other/uptime.c +++ b/toys/other/uptime.c @@ -9,7 +9,6 @@ USE_UPTIME(NEWTOY(uptime, ">0ps", TOYFLAG_USR|TOYFLAG_BIN)) config UPTIME bool "uptime" default y - depends on TOYBOX_UTMPX help usage: uptime [-ps] diff --git a/toys/other/w.c b/toys/other/w.c index a76c82f5..c271e8bd 100644 --- a/toys/other/w.c +++ b/toys/other/w.c @@ -7,7 +7,6 @@ USE_W(NEWTOY(w, NULL, TOYFLAG_USR|TOYFLAG_BIN)) config W bool "w" default y - depends on TOYBOX_UTMPX help usage: w diff --git a/toys/pending/sulogin.c b/toys/pending/sulogin.c index c773e639..f58754bc 100644 --- a/toys/pending/sulogin.c +++ b/toys/pending/sulogin.c @@ -13,7 +13,6 @@ USE_SULOGIN(NEWTOY(sulogin, "t#<0=0", TOYFLAG_SBIN|TOYFLAG_NEEDROOT)) config SULOGIN bool "sulogin" default n - depends on TOYBOX_SHADOW help usage: sulogin [-t time] [tty] diff --git a/toys/posix/who.c b/toys/posix/who.c index 2515af38..24353852 100644 --- a/toys/posix/who.c +++ b/toys/posix/who.c @@ -16,7 +16,6 @@ USE_WHO(NEWTOY(who, "a", TOYFLAG_USR|TOYFLAG_BIN)) config WHO bool "who" default y - depends on TOYBOX_UTMPX help usage: who -- 2.39.2