11diff --git a/include/pathnames.h b/include/pathnames.h
2- index 34ba11ca3..a7d3278c8 100644
2+ index 6dcfced22..d60e24dea 100644
33--- a/include/pathnames.h
44+++ b/include/pathnames.h
5- @@ -19,77 +19,78 @@
5+ @@ -19,72 +19,73 @@
66 /* DEFPATHs from <paths.h> don't include /usr/local */
77 #undef _PATH_DEFPATH
88
@@ -62,18 +62,20 @@ index 34ba11ca3..a7d3278c8 100644
6262- #define _PATH_GROUP "/etc/group"
6363- #define _PATH_SHADOW_PASSWD "/etc/shadow"
6464- #define _PATH_SHELLS "/etc/shells"
65- + // Termux doesn't support multiuser environment .
66- + // Some Android versions support /etc/passwd and /etc/group but files
67- + // /etc/shadow and /etc/gshadow are not supported.
65+ + // Termux doesn't support multiuser environments .
66+ + // Some Android versions support /etc/passwd and /etc/group
67+ + // but files /etc/shadow and /etc/gshadow are not supported.
6868+ #define _PATH_PASSWD "/system/etc/passwd"
6969+ #define _PATH_GSHADOW "/system/etc/gshadow"
7070+ #define _PATH_GROUP "/system/etc/group"
7171+ #define _PATH_SHADOW_PASSWD "/system/etc/shadow"
7272+ // Ignored in Termux.
7373+ #define _PATH_SHELLS "@TERMUX_PREFIX@/etc/shells"
74+ #define _PATH_PASSWDBAK_SUFFIX "-"
7475
7576 #ifndef _PATH_TMP
76- # define _PATH_TMP "/tmp/"
77+ - # define _PATH_TMP "/tmp/"
78+ + # define _PATH_TMP "@TERMUX_PREFIX@/tmp/"
7779 #endif
7880
7981+ // btmp, (and utmp/wtmp) files are unsupported.
@@ -82,14 +84,6 @@ index 34ba11ca3..a7d3278c8 100644
8284+ # define _PATH_BTMP "@TERMUX_PREFIX@/var/log/btmp"
8385 #endif
8486
85- #define _PATH_ISSUE_FILENAME "issue"
86- #define _PATH_ISSUE_DIRNAME _PATH_ISSUE_FILENAME ".d"
87-
88- - #define _PATH_ISSUE "/etc/" _PATH_ISSUE_FILENAME
89- - #define _PATH_ISSUEDIR "/etc/" _PATH_ISSUE_DIRNAME
90- + #define _PATH_ISSUE "@TERMUX_PREFIX@/etc/" _PATH_ISSUE_FILENAME
91- + #define _PATH_ISSUEDIR "@TERMUX_PREFIX@/etc/" _PATH_ISSUE_DIRNAME
92-
9387- #define _PATH_OS_RELEASE_ETC "/etc/os-release"
9488- #define _PATH_OS_RELEASE_USR "/usr/lib/os-release"
9589+ // os release definition is not available in Termux.
@@ -115,7 +109,7 @@ index 34ba11ca3..a7d3278c8 100644
115109 #define _PATH_PROC "/proc"
116110 #define _PATH_PROC_SWAPS "/proc/swaps"
117111 #define _PATH_PROC_FILESYSTEMS "/proc/filesystems"
118- @@ -132 ,7 +133 ,7 @@
112+ @@ -129 ,7 +130 ,7 @@
119113 # ifdef MOUNTED /* deprecated */
120114 # define _PATH_MOUNTED MOUNTED
121115 # else
@@ -124,7 +118,7 @@ index 34ba11ca3..a7d3278c8 100644
124118 # endif
125119 #endif
126120
127- @@ -140 ,7 +141 ,8 @@
121+ @@ -137 ,7 +138 ,8 @@
128122 # ifdef MNTTAB /* deprecated */
129123 # define _PATH_MNTTAB MNTTAB
130124 # else
@@ -134,7 +128,7 @@ index 34ba11ca3..a7d3278c8 100644
134128 # endif
135129 #endif
136130
137- @@ -155 ,22 +157 ,22 @@
131+ @@ -152 ,22 +154 ,22 @@
138132
139133 #define _PATH_DEV_MEM "/dev/mem"
140134
@@ -165,21 +159,8 @@ index 34ba11ca3..a7d3278c8 100644
165159 #endif
166160
167161 #ifdef __ia64__
168- diff --git a/lib/exec_shell.c b/lib/exec_shell.c
169- index 96d3e95a8..46840a53e 100644
170- --- a/lib/exec_shell.c
171- +++ b/lib/exec_shell.c
172- @@ -28,7 +28,7 @@
173-
174- #include "exec_shell.h"
175-
176- - #define DEFAULT_SHELL "/bin/sh"
177- + #define DEFAULT_SHELL "@TERMUX_PREFIX@/bin/sh"
178-
179- void __attribute__((__noreturn__)) exec_shell(void)
180- {
181162diff --git a/lib/loopdev.c b/lib/loopdev.c
182- index 2359bf781..056ac6e75 100644
163+ index 57479ccb4..4f8a7eaf5 100644
183164--- a/lib/loopdev.c
184165+++ b/lib/loopdev.c
185166@@ -128,13 +128,13 @@ int loopcxt_set_device(struct loopdev_cxt *lc, const char *device)
@@ -222,42 +203,40 @@ index fa2379c4d..f11996748 100644
222203 #define BLKID_ERR_IO 5
223204 #define BLKID_ERR_SYSFS 9
224205diff --git a/libblkid/src/topology/dm.c b/libblkid/src/topology/dm.c
225- index 7687e327a..6d510abaf 100644
206+ index 7687e327a..3d4a29857 100644
226207--- a/libblkid/src/topology/dm.c
227208+++ b/libblkid/src/topology/dm.c
228- @@ -30,9 +30,8 @@ static int probe_dm_tp(blkid_probe pr,
209+ @@ -30,9 +30,7 @@ static int probe_dm_tp(blkid_probe pr,
229210 const struct blkid_idmag *mag __attribute__((__unused__)))
230211 {
231212 const char * const paths[] = {
232213- "/usr/local/sbin/dmsetup",
233214- "/usr/sbin/dmsetup",
234215- "/sbin/dmsetup"
235- + "@TERMUX_PREFIX@/bin/dmsetup",
236- + "@TERMUX_PREFIX@/sbin/dmsetup"
216+ + "@TERMUX_PREFIX@/bin/dmsetup"
237217 };
238218 int dmpipe[] = { -1, -1 }, stripes = 0, stripesize = 0;
239219 const char *cmd = NULL;
240220diff --git a/libblkid/src/topology/lvm.c b/libblkid/src/topology/lvm.c
241- index f5c3d484b..80be642a1 100644
221+ index f5c3d484b..7a952fdbf 100644
242222--- a/libblkid/src/topology/lvm.c
243223+++ b/libblkid/src/topology/lvm.c
244- @@ -36,9 +36,8 @@ static int probe_lvm_tp(blkid_probe pr,
224+ @@ -36,9 +36,7 @@ static int probe_lvm_tp(blkid_probe pr,
245225 const struct blkid_idmag *mag __attribute__((__unused__)))
246226 {
247227 const char * const paths[] = {
248228- "/usr/local/sbin/lvdisplay",
249229- "/usr/sbin/lvdisplay",
250230- "/sbin/lvdisplay"
251- + "@TERMUX_PREFIX@/bin/lvdisplay",
252- + "@TERMUX_PREFIX@/sbin/lvdisplay"
231+ + "@TERMUX_PREFIX@/bin/lvdisplay"
253232 };
254233 int lvpipe[] = { -1, -1 }, stripes = 0, stripesize = 0;
255234 FILE *stream = NULL;
256235diff --git a/libmount/src/cache.c b/libmount/src/cache.c
257- index b7956346f..ffe3dc103 100644
236+ index 4d2a20f23..167ece9bd 100644
258237--- a/libmount/src/cache.c
259238+++ b/libmount/src/cache.c
260- @@ -654 ,7 +654 ,7 @@ char *mnt_pretty_path(const char *path, struct libmnt_cache *cache)
239+ @@ -762 ,7 +762 ,7 @@ char *mnt_pretty_path(const char *path, struct libmnt_cache *cache)
261240 /* users assume backing file name rather than /dev/loopN in
262241 * output if the device has been initialized by mount(8).
263242 */
@@ -267,7 +246,7 @@ index b7956346f..ffe3dc103 100644
267246
268247 if (loopcxt_init(&lc, 0) || loopcxt_set_device(&lc, pretty))
269248diff --git a/libmount/src/hook_loopdev.c b/libmount/src/hook_loopdev.c
270- index 444d69d6f..54ca0ebf3 100644
249+ index 114d055ba..8b70a633e 100644
271250--- a/libmount/src/hook_loopdev.c
272251+++ b/libmount/src/hook_loopdev.c
273252@@ -105,7 +105,7 @@ is_mounted_same_loopfile(struct libmnt_context *cxt,
@@ -280,7 +259,7 @@ index 444d69d6f..54ca0ebf3 100644
280259
281260 } else if (opts && (flags & MNT_MS_LOOP) &&
282261diff --git a/libmount/src/tab.c b/libmount/src/tab.c
283- index 4209d697a..fb0e59731 100644
262+ index 0d2b0ecd4..f1bac6801 100644
284263--- a/libmount/src/tab.c
285264+++ b/libmount/src/tab.c
286265@@ -1948,7 +1948,7 @@ int __mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_f
@@ -305,50 +284,11 @@ index f76acc8b2..14b1c2c12 100644
305284
306285 #define UUIDD_OP_GETPID 0
307286 #define UUIDD_OP_GET_MAXOP 1
308- diff --git a/login-utils/su-common.c b/login-utils/su-common.c
309- index ae0621de3..57b01f77e 100644
310- --- a/login-utils/su-common.c
311- +++ b/login-utils/su-common.c
312- @@ -106,7 +106,7 @@ UL_DEBUG_DEFINE_MASKNAMES(su) = UL_DEBUG_EMPTY_MASKNAMES;
313- #define is_pam_failure(_rc) ((_rc) != PAM_SUCCESS)
314-
315- /* The shell to run if none is given in the user's passwd entry. */
316- - #define DEFAULT_SHELL "/bin/sh"
317- + #define DEFAULT_SHELL "@TERMUX_PREFIX@/bin/sh"
318-
319- /* The user to become if none is specified. */
320- #define DEFAULT_USER "root"
321- diff --git a/login-utils/sulogin.c b/login-utils/sulogin.c
322- index aeaa3f11f..ba0e13d4b 100644
323- --- a/login-utils/sulogin.c
324- +++ b/login-utils/sulogin.c
325- @@ -893,7 +893,7 @@ static void sushell(struct passwd *pwd, struct console *con)
326- if (pwd->pw_shell[0])
327- su_shell = pwd->pw_shell;
328- else
329- - su_shell = "/bin/sh";
330- + su_shell = "@TERMUX_PREFIX@/bin/sh";
331- }
332- if ((p = strrchr(su_shell, '/')) == NULL)
333- p = su_shell;
334- @@ -942,9 +942,9 @@ static void sushell(struct passwd *pwd, struct console *con)
335- execl(su_shell, shell, (char *)NULL);
336- warn(_("failed to execute %s"), su_shell);
337-
338- - xsetenv("SHELL", "/bin/sh", 1);
339- - execl("/bin/sh", profile ? "-sh" : "sh", (char *)NULL);
340- - warn(_("failed to execute %s"), "/bin/sh");
341- + xsetenv("SHELL", "@TERMUX_PREFIX@/bin/sh", 1);
342- + execl("@TERMUX_PREFIX@/bin/sh", profile ? "-sh" : "sh", (char *)NULL);
343- + warn(_("failed to execute %s"), "@TERMUX_PREFIX@/bin/sh");
344- }
345-
346- #ifdef HAVE_LIBSELINUX
347287diff --git a/misc-utils/whereis.c b/misc-utils/whereis.c
348- index b575e57ae..40b2d34cc 100644
288+ index 2e2ecda9e..0b44018b3 100644
349289--- a/misc-utils/whereis.c
350290+++ b/misc-utils/whereis.c
351- @@ -101 ,84 +101 ,18 @@ struct wh_dirlist {
291+ @@ -102 ,84 +102 ,18 @@ struct wh_dirlist {
352292 };
353293
354294 static const char *const bindirs[] = {
@@ -438,45 +378,31 @@ index b575e57ae..40b2d34cc 100644
438378 };
439379
440380diff --git a/sys-utils/setarch.c b/sys-utils/setarch.c
441- index 4bcb5e69e..a61db097d 100644
381+ index 3a86f2ee9..a0fef02f0 100644
442382--- a/sys-utils/setarch.c
443383+++ b/sys-utils/setarch.c
444- @@ -482,7 +482,7 @@ int main(int argc, char *argv[])
445- /* Don't use ifdef sparc here, we get "Unrecognized architecture"
446- * error message later if necessary */
447- if (strcmp(arch, "sparc32bash") == 0) {
448- - shell = "/bin/bash";
449- + shell = "@TERMUX_PREFIX@/bin/bash";
450- shell_arg = "";
451- goto set_arch;
452- }
453- @@ -605,7 +605,7 @@ set_arch:
384+ @@ -32,6 +32,7 @@
385+ #include <getopt.h>
386+ #include <limits.h>
387+ #include <sys/utsname.h>
388+ + #include <paths.h>
389+ #include "nls.h"
390+ #include "c.h"
391+ #include "closestream.h"
392+ @@ -652,7 +653,7 @@ set_arch:
454393 verify_arch_domain(doms, target, arch);
455394
456395 if (!argc) {
457396- shell = "/bin/sh";
458- + shell = "@TERMUX_PREFIX@/bin/sh" ;
397+ + shell = _PATH_BSHELL ;
459398 shell_arg = "-sh";
460399 }
461400 if (verbose) {
462- diff --git a/sys-utils/setpriv.c b/sys-utils/setpriv.c
463- index 7242c333d..67b7b422d 100644
464- --- a/sys-utils/setpriv.c
465- +++ b/sys-utils/setpriv.c
466- @@ -56,7 +56,7 @@
467- #define SETPRIV_EXIT_PRIVERR 127 /* how we exit when we fail to set privs */
468-
469- /* The shell to set SHELL env.variable if none is given in the user's passwd entry. */
470- - #define DEFAULT_SHELL "/bin/sh"
471- + #define DEFAULT_SHELL "@TERMUX_PREFIX@/bin/sh"
472-
473- static gid_t get_group(const char *s, const char *err);
474-
475401diff --git a/text-utils/more.c b/text-utils/more.c
476- index 13b1b0bb9..936abf11c 100644
402+ index bc04064cf..c37ce7025 100644
477403--- a/text-utils/more.c
478404+++ b/text-utils/more.c
479- @@ -81 ,6 +81 ,7 @@
405+ @@ -83 ,6 +83 ,7 @@
480406 # include <magic.h>
481407 #endif
482408
@@ -485,15 +411,23 @@ index 13b1b0bb9..936abf11c 100644
485411 #include "nls.h"
486412 #include "xalloc.h"
487413diff --git a/text-utils/pg.c b/text-utils/pg.c
488- index 3623f3f78..6c68dc16e 100644
414+ index 939086bc8..b7990d909 100644
489415--- a/text-utils/pg.c
490416+++ b/text-utils/pg.c
491- @@ -1371,7 +1371,7 @@ static void pgfile(FILE *f, const char *name)
417+ @@ -58,6 +58,7 @@
418+ #include <unistd.h>
419+ #include <signal.h>
420+ #include <setjmp.h>
421+ + #include <paths.h>
422+
423+ #if defined(HAVE_NCURSESW_NCURSES_H)
424+ # include <ncursesw/ncurses.h>
425+ @@ -1372,7 +1373,7 @@ static void pgfile(FILE *f, const char *name)
492426 {
493427 const char *sh = getenv("SHELL");
494428 if (!sh)
495429- sh = "/bin/sh";
496- + sh = "@TERMUX_PREFIX@/bin/sh" ;
430+ + sh = _PATH_BSHELL ;
497431 if (!nobuf)
498432 fclose(fbuf);
499433 fclose(find);
0 commit comments