aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/bb_archive.h4
-rw-r--r--include/libbb.h70
-rw-r--r--include/platform.h5
3 files changed, 58 insertions, 21 deletions
diff --git a/include/bb_archive.h b/include/bb_archive.h
index c118fa7ec..acb3c3cbd 100644
--- a/include/bb_archive.h
+++ b/include/bb_archive.h
@@ -74,9 +74,6 @@ typedef struct archive_handle_t {
74 /* Currently processed file's header */ 74 /* Currently processed file's header */
75 file_header_t *file_header; 75 file_header_t *file_header;
76 76
77 /* List of symlink placeholders */
78 llist_t *symlink_placeholders;
79
80 /* Process the header component, e.g. tar -t */ 77 /* Process the header component, e.g. tar -t */
81 void FAST_FUNC (*action_header)(const file_header_t *); 78 void FAST_FUNC (*action_header)(const file_header_t *);
82 79
@@ -210,6 +207,7 @@ void seek_by_jump(int fd, off_t amount) FAST_FUNC;
210void seek_by_read(int fd, off_t amount) FAST_FUNC; 207void seek_by_read(int fd, off_t amount) FAST_FUNC;
211 208
212const char *strip_unsafe_prefix(const char *str) FAST_FUNC; 209const char *strip_unsafe_prefix(const char *str) FAST_FUNC;
210int unsafe_symlink_target(const char *target) FAST_FUNC;
213 211
214void data_align(archive_handle_t *archive_handle, unsigned boundary) FAST_FUNC; 212void data_align(archive_handle_t *archive_handle, unsigned boundary) FAST_FUNC;
215const llist_t *find_list_entry(const llist_t *list, const char *filename) FAST_FUNC; 213const llist_t *find_list_entry(const llist_t *list, const char *filename) FAST_FUNC;
diff --git a/include/libbb.h b/include/libbb.h
index 61ceb6085..6073cbf4a 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -365,7 +365,7 @@ unsigned long long monotonic_ms(void) FAST_FUNC;
365unsigned monotonic_sec(void) FAST_FUNC; 365unsigned monotonic_sec(void) FAST_FUNC;
366 366
367extern void chomp(char *s) FAST_FUNC; 367extern void chomp(char *s) FAST_FUNC;
368extern void trim(char *s) FAST_FUNC; 368extern char *trim(char *s) FAST_FUNC;
369extern char *skip_whitespace(const char *) FAST_FUNC; 369extern char *skip_whitespace(const char *) FAST_FUNC;
370extern char *skip_non_whitespace(const char *) FAST_FUNC; 370extern char *skip_non_whitespace(const char *) FAST_FUNC;
371extern char *skip_dev_pfx(const char *tty_name) FAST_FUNC; 371extern char *skip_dev_pfx(const char *tty_name) FAST_FUNC;
@@ -886,7 +886,7 @@ unsigned bb_clk_tck(void) FAST_FUNC;
886 886
887#if SEAMLESS_COMPRESSION 887#if SEAMLESS_COMPRESSION
888/* Autodetects gzip/bzip2 formats. fd may be in the middle of the file! */ 888/* Autodetects gzip/bzip2 formats. fd may be in the middle of the file! */
889extern int setup_unzip_on_fd(int fd, int fail_if_not_compressed) FAST_FUNC; 889int setup_unzip_on_fd(int fd, int fail_if_not_compressed) FAST_FUNC;
890/* Autodetects .gz etc */ 890/* Autodetects .gz etc */
891extern int open_zipped(const char *fname, int fail_if_not_compressed) FAST_FUNC; 891extern int open_zipped(const char *fname, int fail_if_not_compressed) FAST_FUNC;
892extern void *xmalloc_open_zipped_read_close(const char *fname, size_t *maxsz_p) FAST_FUNC RETURNS_MALLOC; 892extern void *xmalloc_open_zipped_read_close(const char *fname, size_t *maxsz_p) FAST_FUNC RETURNS_MALLOC;
@@ -895,6 +895,8 @@ extern void *xmalloc_open_zipped_read_close(const char *fname, size_t *maxsz_p)
895# define open_zipped(fname, fail_if_not_compressed) open((fname), O_RDONLY); 895# define open_zipped(fname, fail_if_not_compressed) open((fname), O_RDONLY);
896# define xmalloc_open_zipped_read_close(fname, maxsz_p) xmalloc_open_read_close((fname), (maxsz_p)) 896# define xmalloc_open_zipped_read_close(fname, maxsz_p) xmalloc_open_read_close((fname), (maxsz_p))
897#endif 897#endif
898/* lzma has no signature, need a little helper. NB: exist only for ENABLE_FEATURE_SEAMLESS_LZMA=y */
899void setup_lzma_on_fd(int fd) FAST_FUNC;
898 900
899extern ssize_t safe_write(int fd, const void *buf, size_t count) FAST_FUNC; 901extern ssize_t safe_write(int fd, const void *buf, size_t count) FAST_FUNC;
900// NB: will return short write on error, not -1, 902// NB: will return short write on error, not -1,
@@ -1138,9 +1140,15 @@ int wait_for_exitstatus(pid_t pid) FAST_FUNC;
1138int spawn_and_wait(char **argv) FAST_FUNC; 1140int spawn_and_wait(char **argv) FAST_FUNC;
1139/* Does NOT check that applet is NOFORK, just blindly runs it */ 1141/* Does NOT check that applet is NOFORK, just blindly runs it */
1140int run_nofork_applet(int applet_no, char **argv) FAST_FUNC; 1142int run_nofork_applet(int applet_no, char **argv) FAST_FUNC;
1143void run_noexec_applet_and_exit(int a, const char *name, char **argv) NORETURN FAST_FUNC;
1141#ifndef BUILD_INDIVIDUAL 1144#ifndef BUILD_INDIVIDUAL
1142extern int find_applet_by_name(const char *name) FAST_FUNC; 1145int find_applet_by_name(const char *name) FAST_FUNC;
1143extern void run_applet_no_and_exit(int a, const char *name, char **argv) NORETURN FAST_FUNC; 1146void run_applet_no_and_exit(int a, const char *name, char **argv) NORETURN FAST_FUNC;
1147#endif
1148#if defined(__linux__)
1149void set_task_comm(const char *comm) FAST_FUNC;
1150#else
1151# define set_task_comm(name) ((void)0)
1144#endif 1152#endif
1145#if ENABLE_PLATFORM_MINGW32 && ENABLE_FEATURE_SH_NOFORK 1153#if ENABLE_PLATFORM_MINGW32 && ENABLE_FEATURE_SH_NOFORK
1146extern int long_running_applet(int applet_no) FAST_FUNC; 1154extern int long_running_applet(int applet_no) FAST_FUNC;
@@ -1198,21 +1206,26 @@ enum {
1198#endif 1206#endif
1199void bb_daemonize_or_rexec(int flags, char **argv) FAST_FUNC; 1207void bb_daemonize_or_rexec(int flags, char **argv) FAST_FUNC;
1200void bb_sanitize_stdio(void) FAST_FUNC; 1208void bb_sanitize_stdio(void) FAST_FUNC;
1209#define bb_daemon_helper(arg) bb_daemonize_or_rexec((arg) | DAEMON_ONLY_SANITIZE, NULL)
1201/* Clear dangerous stuff, set PATH. Return 1 if was run by different user. */ 1210/* Clear dangerous stuff, set PATH. Return 1 if was run by different user. */
1202int sanitize_env_if_suid(void) FAST_FUNC; 1211int sanitize_env_if_suid(void) FAST_FUNC;
1203 1212
1204 1213
1214/* For top, ps. Some argv[i] are replaced by malloced "-opt" strings */
1215void make_all_argv_opts(char **argv) FAST_FUNC;
1205char* single_argv(char **argv) FAST_FUNC; 1216char* single_argv(char **argv) FAST_FUNC;
1206extern const char *const bb_argv_dash[]; /* "-", NULL */ 1217extern const char *const bb_argv_dash[]; /* { "-", NULL } */
1207extern const char *opt_complementary;
1208#if ENABLE_LONG_OPTS || ENABLE_FEATURE_GETOPT_LONG
1209#define No_argument "\0"
1210#define Required_argument "\001"
1211#define Optional_argument "\002"
1212extern const char *applet_long_options;
1213#endif
1214extern uint32_t option_mask32; 1218extern uint32_t option_mask32;
1215extern uint32_t getopt32(char **argv, const char *applet_opts, ...) FAST_FUNC; 1219uint32_t getopt32(char **argv, const char *applet_opts, ...) FAST_FUNC;
1220# define No_argument "\0"
1221# define Required_argument "\001"
1222# define Optional_argument "\002"
1223#if ENABLE_LONG_OPTS
1224uint32_t getopt32long(char **argv, const char *optstring, const char *longopts, ...) FAST_FUNC;
1225#else
1226#define getopt32long(argv,optstring,longopts,...) \
1227 getopt32(argv,optstring,##__VA_ARGS__)
1228#endif
1216/* BSD-derived getopt() functions require that optind be set to 1 in 1229/* BSD-derived getopt() functions require that optind be set to 1 in
1217 * order to reset getopt() state. This used to be generally accepted 1230 * order to reset getopt() state. This used to be generally accepted
1218 * way of resetting getopt(). However, glibc's getopt() 1231 * way of resetting getopt(). However, glibc's getopt()
@@ -1429,6 +1442,11 @@ enum {
1429 // keep a copy of current line 1442 // keep a copy of current line
1430 PARSE_KEEP_COPY = 0x00200000 * ENABLE_FEATURE_CROND_D, 1443 PARSE_KEEP_COPY = 0x00200000 * ENABLE_FEATURE_CROND_D,
1431 PARSE_EOL_COMMENTS = 0x00400000, // comments are recognized even if they aren't the first char 1444 PARSE_EOL_COMMENTS = 0x00400000, // comments are recognized even if they aren't the first char
1445 PARSE_ALT_COMMENTS = 0x00800000, // delim[0] and delim[1] are two different allowed comment chars
1446 // (so far, delim[0] will only work as comment char for full-line comment)
1447 // (IOW: it works as if PARSE_EOL_COMMENTS is not set. sysctl applet is okay with this)
1448 PARSE_WS_COMMENTS = 0x01000000, // comments are recognized even if there is whitespace before
1449 // ("line start><space><tab><space>#comment" is also comment, not only "line start>#comment")
1432 // NORMAL is: 1450 // NORMAL is:
1433 // * remove leading and trailing delimiters and collapse 1451 // * remove leading and trailing delimiters and collapse
1434 // multiple delimiters into one 1452 // multiple delimiters into one
@@ -1484,6 +1502,21 @@ extern void run_shell(const char *shell, int loginshell, const char **args) NORE
1484 */ 1502 */
1485const char *get_shell_name(void) FAST_FUNC; 1503const char *get_shell_name(void) FAST_FUNC;
1486 1504
1505unsigned cap_name_to_number(const char *cap) FAST_FUNC;
1506void printf_cap(const char *pfx, unsigned cap_no) FAST_FUNC;
1507void drop_capability(int cap_ordinal) FAST_FUNC;
1508/* Structures inside "struct caps" are Linux-specific and libcap-specific: */
1509#define DEFINE_STRUCT_CAPS \
1510struct caps { \
1511 struct __user_cap_header_struct header; \
1512 unsigned u32s; \
1513 struct __user_cap_data_struct data[2]; \
1514}
1515void getcaps(void *caps) FAST_FUNC;
1516
1517unsigned cap_name_to_number(const char *name) FAST_FUNC;
1518void printf_cap(const char *pfx, unsigned cap_no) FAST_FUNC;
1519
1487#if ENABLE_SELINUX 1520#if ENABLE_SELINUX
1488extern void renew_current_security_context(void) FAST_FUNC; 1521extern void renew_current_security_context(void) FAST_FUNC;
1489extern void set_current_security_context(security_context_t sid) FAST_FUNC; 1522extern void set_current_security_context(security_context_t sid) FAST_FUNC;
@@ -1668,9 +1701,9 @@ enum {
1668 * buffer[0] is used as a counter of buffered chars and must be 0 1701 * buffer[0] is used as a counter of buffered chars and must be 0
1669 * on first call. 1702 * on first call.
1670 * timeout: 1703 * timeout:
1671 * -2: do not poll for input; 1704 * -2: do not poll(-1) for input - read() it, return on EAGAIN at once
1672 * -1: poll(-1) (i.e. block); 1705 * -1: poll(-1) (i.e. block even on NONBLOCKed fd)
1673 * >=0: poll for TIMEOUT milliseconds, return -1/EAGAIN on timeout 1706 * >=0: poll() for TIMEOUT milliseconds, return -1/EAGAIN on timeout
1674 */ 1707 */
1675int64_t read_key(int fd, char *buffer, int timeout) FAST_FUNC; 1708int64_t read_key(int fd, char *buffer, int timeout) FAST_FUNC;
1676void read_key_ungets(char *buffer, const char *str, unsigned len) FAST_FUNC; 1709void read_key_ungets(char *buffer, const char *str, unsigned len) FAST_FUNC;
@@ -1686,6 +1719,7 @@ unsigned size_from_HISTFILESIZE(const char *hp) FAST_FUNC;
1686# endif 1719# endif
1687typedef struct line_input_t { 1720typedef struct line_input_t {
1688 int flags; 1721 int flags;
1722 int timeout;
1689 const char *path_lookup; 1723 const char *path_lookup;
1690# if MAX_HISTORY 1724# if MAX_HISTORY
1691 int cnt_history; 1725 int cnt_history;
@@ -1721,7 +1755,7 @@ line_input_t *new_line_input_t(int flags) FAST_FUNC;
1721 * 0 on ctrl-C (the line entered is still returned in 'command'), 1755 * 0 on ctrl-C (the line entered is still returned in 'command'),
1722 * >0 length of input string, including terminating '\n' 1756 * >0 length of input string, including terminating '\n'
1723 */ 1757 */
1724int read_line_input(line_input_t *st, const char *prompt, char *command, int maxsize, int timeout) FAST_FUNC; 1758int read_line_input(line_input_t *st, const char *prompt, char *command, int maxsize) FAST_FUNC;
1725void show_history(const line_input_t *st) FAST_FUNC; 1759void show_history(const line_input_t *st) FAST_FUNC;
1726# if ENABLE_FEATURE_EDITING_SAVE_ON_EXIT 1760# if ENABLE_FEATURE_EDITING_SAVE_ON_EXIT
1727void save_history(line_input_t *st); 1761void save_history(line_input_t *st);
@@ -1729,7 +1763,7 @@ void save_history(line_input_t *st);
1729#else 1763#else
1730#define MAX_HISTORY 0 1764#define MAX_HISTORY 0
1731int read_line_input(const char* prompt, char* command, int maxsize) FAST_FUNC; 1765int read_line_input(const char* prompt, char* command, int maxsize) FAST_FUNC;
1732#define read_line_input(state, prompt, command, maxsize, timeout) \ 1766#define read_line_input(state, prompt, command, maxsize) \
1733 read_line_input(prompt, command, maxsize) 1767 read_line_input(prompt, command, maxsize)
1734#endif 1768#endif
1735 1769
diff --git a/include/platform.h b/include/platform.h
index 749169b0c..cc22f4fc9 100644
--- a/include/platform.h
+++ b/include/platform.h
@@ -277,6 +277,11 @@ typedef uint64_t bb__aliased_uint64_t FIX_ALIASING;
277#define put_unaligned_le32(val, buf) move_to_unaligned32(buf, SWAP_LE32(val)) 277#define put_unaligned_le32(val, buf) move_to_unaligned32(buf, SWAP_LE32(val))
278#define put_unaligned_be32(val, buf) move_to_unaligned32(buf, SWAP_BE32(val)) 278#define put_unaligned_be32(val, buf) move_to_unaligned32(buf, SWAP_BE32(val))
279 279
280/* unxz needs an aligned fixed-endian accessor.
281 * (however, the compiler does not realize it's aligned, the cast is still necessary)
282 */
283#define get_le32(u32p) ({ uint32_t v = *(bb__aliased_uint32_t*)(u32p); SWAP_LE32(v); })
284
280 285
281/* ---- Size-saving "small" ints (arch-dependent) ----------- */ 286/* ---- Size-saving "small" ints (arch-dependent) ----------- */
282 287