~mmach/netext73/busybox

« back to all changes in this revision

Viewing changes to .pc/shell-ash-export-HOME.patch/include/libbb.h

  • Committer: mmach
  • Date: 2023-07-06 04:40:25 UTC
  • Revision ID: netbit73@gmail.com-20230706044025-2ia9985i8wzdn2a7
1.36.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
429
429
        xrealloc_vector_helper((vector), (sizeof((vector)[0]) << 8) + (shift), (idx))
430
430
void* xrealloc_vector_helper(void *vector, unsigned sizeof_and_shift, int idx) FAST_FUNC;
431
431
char *xstrdup(const char *s) FAST_FUNC RETURNS_MALLOC;
432
 
char *xstrndup(const char *s, int n) FAST_FUNC RETURNS_MALLOC;
433
 
void *xmemdup(const void *s, int n) FAST_FUNC RETURNS_MALLOC;
 
432
char *xstrndup(const char *s, size_t n) FAST_FUNC RETURNS_MALLOC;
 
433
void *xmemdup(const void *s, size_t n) FAST_FUNC RETURNS_MALLOC;
434
434
void *mmap_read(int fd, size_t size) FAST_FUNC;
435
435
void *mmap_anon(size_t size) FAST_FUNC;
436
436
void *xmmap_anon(size_t size) FAST_FUNC;
645
645
void xsetuid(uid_t uid) FAST_FUNC;
646
646
void xsetegid(gid_t egid) FAST_FUNC;
647
647
void xseteuid(uid_t euid) FAST_FUNC;
 
648
int chdir_or_warn(const char *path) FAST_FUNC;
648
649
void xchdir(const char *path) FAST_FUNC;
649
650
void xfchdir(int fd) FAST_FUNC;
650
651
void xchroot(const char *path) FAST_FUNC;
1054
1055
void die_if_ferror_stdout(void) FAST_FUNC;
1055
1056
int fflush_all(void) FAST_FUNC;
1056
1057
void fflush_stdout_and_exit(int retval) NORETURN FAST_FUNC;
 
1058
void fflush_stdout_and_exit_SUCCESS(void) NORETURN FAST_FUNC;
1057
1059
int fclose_if_not_stdin(FILE *file) FAST_FUNC;
1058
1060
FILE* xfopen(const char *filename, const char *mode) FAST_FUNC;
1059
1061
/* Prints warning to stderr and returns NULL on failure: */
1277
1279
# define re_execed_comm() 0
1278
1280
# define set_task_comm(name) ((void)0)
1279
1281
#endif
 
1282
void exit_SUCCESS(void) NORETURN FAST_FUNC;
 
1283
void _exit_SUCCESS(void) NORETURN FAST_FUNC;
1280
1284
 
1281
1285
/* Helpers for daemonization.
1282
1286
 *
1506
1510
int hush_main(int argc, char** argv) IF_SHELL_HUSH(MAIN_EXTERNALLY_VISIBLE);
1507
1511
/* If shell needs them, they exist even if not enabled as applets */
1508
1512
int echo_main(int argc, char** argv) IF_ECHO(MAIN_EXTERNALLY_VISIBLE);
 
1513
int sleep_main(int argc, char **argv) IF_SLEEP(MAIN_EXTERNALLY_VISIBLE);
1509
1514
int printf_main(int argc, char **argv) IF_PRINTF(MAIN_EXTERNALLY_VISIBLE);
1510
1515
int test_main(int argc, char **argv)
1511
1516
#if ENABLE_TEST || ENABLE_TEST1 || ENABLE_TEST2
1723
1728
 
1724
1729
 
1725
1730
/* setup_environment:
1726
 
 * if chdir pw->pw_dir: ok: else if to_tmp == 1: goto /tmp else: goto / or die
1727
 
 * if clear_env = 1: cd(pw->pw_dir), clear environment, then set
 
1731
 * if SETUP_ENV_CHDIR:
 
1732
 *   if cd(pw->pw_dir): ok: else if SETUP_ENV_TO_TMP: cd(/tmp) else: cd(/) or die
 
1733
 * if SETUP_ENV_CLEARENV: cd(pw->pw_dir), clear environment, then set
1728
1734
 *   TERM=(old value)
1729
1735
 *   USER=pw->pw_name, LOGNAME=pw->pw_name
1730
1736
 *   PATH=bb_default_[root_]path
1731
1737
 *   HOME=pw->pw_dir
1732
1738
 *   SHELL=shell
1733
 
 * else if change_env = 1:
1734
 
 *   if not root (if pw->pw_uid != 0):
 
1739
 * else if SETUP_ENV_CHANGEENV | SETUP_ENV_CHANGEENV_LOGNAME:
 
1740
 *   if not root (if pw->pw_uid != 0) or if SETUP_ENV_CHANGEENV_LOGNAME:
1735
1741
 *     USER=pw->pw_name, LOGNAME=pw->pw_name
1736
1742
 *   HOME=pw->pw_dir
1737
1743
 *   SHELL=shell
1740
1746
 * NB: CHANGEENV and CLEARENV use setenv() - this leaks memory!
1741
1747
 * If setup_environment() is used is vforked child, this leaks memory _in parent too_!
1742
1748
 */
1743
 
#define SETUP_ENV_CHANGEENV (1 << 0)
1744
 
#define SETUP_ENV_CLEARENV  (1 << 1)
1745
 
#define SETUP_ENV_TO_TMP    (1 << 2)
1746
 
#define SETUP_ENV_NO_CHDIR  (1 << 4)
 
1749
#define SETUP_ENV_CHANGEENV         (1 << 0)
 
1750
#define SETUP_ENV_CHANGEENV_LOGNAME (1 << 1)
 
1751
#define SETUP_ENV_CLEARENV          (1 << 2)
 
1752
#define SETUP_ENV_TO_TMP            (1 << 3)
 
1753
#define SETUP_ENV_CHDIR             (1 << 4)
1747
1754
void setup_environment(const char *shell, int flags, const struct passwd *pw) FAST_FUNC;
1748
1755
void nuke_str(char *str) FAST_FUNC;
1749
1756
#if ENABLE_FEATURE_SECURETTY && !ENABLE_PAM
1894
1901
 * (unless fd is in non-blocking mode),
1895
1902
 * subsequent reads will time out after a few milliseconds.
1896
1903
 * Return of -1 means EOF or error (errno == 0 on EOF).
 
1904
 * Nonzero errno is not preserved across the call:
 
1905
 * if there was no error, errno will be cleared to 0.
1897
1906
 * buffer[0] is used as a counter of buffered chars and must be 0
1898
1907
 * on first call.
1899
1908
 * timeout:
1902
1911
 * >=0: poll() for TIMEOUT milliseconds, return -1/EAGAIN on timeout
1903
1912
 */
1904
1913
int64_t read_key(int fd, char *buffer, int timeout) FAST_FUNC;
 
1914
/* This version loops on EINTR: */
 
1915
int64_t safe_read_key(int fd, char *buffer, int timeout) FAST_FUNC;
1905
1916
void read_key_ungets(char *buffer, const char *str, unsigned len) FAST_FUNC;
1906
1917
 
1907
1918
 
1914
1925
#  define MAX_HISTORY 0
1915
1926
# endif
1916
1927
typedef const char *get_exe_name_t(int i) FAST_FUNC;
 
1928
typedef const char *sh_get_var_t(const char *name) FAST_FUNC;
1917
1929
typedef struct line_input_t {
1918
1930
        int flags;
1919
1931
        int timeout;
1927
1939
#  if ENABLE_SHELL_ASH || ENABLE_SHELL_HUSH
1928
1940
        /* function to fetch additional application-specific names to match */
1929
1941
        get_exe_name_t *get_exe_name;
1930
 
#   define EDITING_HAS_get_exe_name 1
1931
 
#  else
1932
 
#   define EDITING_HAS_get_exe_name 0
1933
1942
#  endif
1934
1943
# endif
 
1944
# if (ENABLE_FEATURE_USERNAME_COMPLETION || ENABLE_FEATURE_EDITING_FANCY_PROMPT) \
 
1945
  && (ENABLE_SHELL_ASH || ENABLE_SHELL_HUSH)
 
1946
        /* function to fetch value of shell variable */
 
1947
        sh_get_var_t *sh_get_var;
 
1948
#  define EDITING_HAS_sh_get_var 1
 
1949
# else
 
1950
#  define EDITING_HAS_sh_get_var 0
 
1951
# endif
1935
1952
# if MAX_HISTORY
1936
1953
        int cnt_history;
1937
1954
        int cur_history;
1955
1972
        USERNAME_COMPLETION = 4 * ENABLE_FEATURE_USERNAME_COMPLETION,
1956
1973
        VI_MODE          = 8 * ENABLE_FEATURE_EDITING_VI,
1957
1974
        WITH_PATH_LOOKUP = 0x10,
1958
 
        FOR_SHELL        = DO_HISTORY | TAB_COMPLETION | USERNAME_COMPLETION,
 
1975
        LI_INTERRUPTIBLE = 0x20,
 
1976
        FOR_SHELL        = DO_HISTORY | TAB_COMPLETION | USERNAME_COMPLETION | LI_INTERRUPTIBLE,
1959
1977
};
1960
1978
line_input_t *new_line_input_t(int flags) FAST_FUNC;
1961
1979
#if ENABLE_FEATURE_EDITING_SAVEHISTORY
1982
2000
        read_line_input(prompt, command, maxsize)
1983
2001
#endif
1984
2002
 
1985
 
#ifndef EDITING_HAS_get_exe_name
1986
 
# define EDITING_HAS_get_exe_name 0
1987
 
#endif
1988
 
 
1989
 
 
1990
2003
#ifndef COMM_LEN
1991
2004
# ifdef TASK_COMM_LEN
1992
2005
enum { COMM_LEN = TASK_COMM_LEN };
2281
2294
/* '*const' ptr makes gcc optimize code much better.
2282
2295
 * Magic prevents ptr_to_globals from going into rodata.
2283
2296
 * If you want to assign a value, use SET_PTR_TO_GLOBALS(x) */
2284
 
extern struct globals *const ptr_to_globals;
 
2297
extern struct globals *BB_GLOBAL_CONST ptr_to_globals;
2285
2298
 
2286
2299
#define barrier() asm volatile ("":::"memory")
2287
2300