aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/.gitignore1
-rw-r--r--include/applets.src.h15
-rw-r--r--include/bb_archive.h7
-rw-r--r--include/libbb.h33
-rw-r--r--include/platform.h5
-rw-r--r--include/usage.src.h3
6 files changed, 56 insertions, 8 deletions
diff --git a/include/.gitignore b/include/.gitignore
index 75afff9ca..13a96e018 100644
--- a/include/.gitignore
+++ b/include/.gitignore
@@ -5,6 +5,7 @@
5/autoconf.h 5/autoconf.h
6/bbconfigopts_bz2.h 6/bbconfigopts_bz2.h
7/bbconfigopts.h 7/bbconfigopts.h
8/embedded_scripts.h
8/NUM_APPLETS.h 9/NUM_APPLETS.h
9/usage_compressed.h 10/usage_compressed.h
10/usage.h 11/usage.h
diff --git a/include/applets.src.h b/include/applets.src.h
index 2ddf120ad..60968cec7 100644
--- a/include/applets.src.h
+++ b/include/applets.src.h
@@ -27,36 +27,49 @@ s - suid type:
27# define APPLET_ODDNAME(name,main,l,s,help) int main##_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 27# define APPLET_ODDNAME(name,main,l,s,help) int main##_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
28# define APPLET_NOEXEC(name,main,l,s,help) int main##_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 28# define APPLET_NOEXEC(name,main,l,s,help) int main##_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
29# define APPLET_NOFORK(name,main,l,s,help) int main##_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 29# define APPLET_NOFORK(name,main,l,s,help) int main##_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
30# define APPLET_SCRIPTED(name,main,l,s,help)
30 31
31#elif defined(NAME_MAIN) 32#elif defined(NAME_MAIN)
32# define APPLET(name,l,s) name name##_main 33# define APPLET(name,l,s) name name##_main
33# define APPLET_ODDNAME(name,main,l,s,help) name main##_main 34# define APPLET_ODDNAME(name,main,l,s,help) name main##_main
34# define APPLET_NOEXEC(name,main,l,s,help) name main##_main 35# define APPLET_NOEXEC(name,main,l,s,help) name main##_main
35# define APPLET_NOFORK(name,main,l,s,help) name main##_main 36# define APPLET_NOFORK(name,main,l,s,help) name main##_main
37# define APPLET_SCRIPTED(name,main,l,s,help) name scripted_main
36 38
37#elif defined(MAKE_USAGE) && ENABLE_FEATURE_VERBOSE_USAGE 39#elif defined(MAKE_USAGE) && ENABLE_FEATURE_VERBOSE_USAGE
38# define APPLET(name,l,s) MAKE_USAGE(#name, name##_trivial_usage name##_full_usage) 40# define APPLET(name,l,s) MAKE_USAGE(#name, name##_trivial_usage name##_full_usage)
39# define APPLET_ODDNAME(name,main,l,s,help) MAKE_USAGE(#name, help##_trivial_usage help##_full_usage) 41# define APPLET_ODDNAME(name,main,l,s,help) MAKE_USAGE(#name, help##_trivial_usage help##_full_usage)
40# define APPLET_NOEXEC(name,main,l,s,help) MAKE_USAGE(#name, help##_trivial_usage help##_full_usage) 42# define APPLET_NOEXEC(name,main,l,s,help) MAKE_USAGE(#name, help##_trivial_usage help##_full_usage)
41# define APPLET_NOFORK(name,main,l,s,help) MAKE_USAGE(#name, help##_trivial_usage help##_full_usage) 43# define APPLET_NOFORK(name,main,l,s,help) MAKE_USAGE(#name, help##_trivial_usage help##_full_usage)
44# define APPLET_SCRIPTED(name,main,l,s,help) MAKE_USAGE(#name, help##_trivial_usage help##_full_usage)
42 45
43#elif defined(MAKE_USAGE) && !ENABLE_FEATURE_VERBOSE_USAGE 46#elif defined(MAKE_USAGE) && !ENABLE_FEATURE_VERBOSE_USAGE
44# define APPLET(name,l,s) MAKE_USAGE(#name, name##_trivial_usage) 47# define APPLET(name,l,s) MAKE_USAGE(#name, name##_trivial_usage)
45# define APPLET_ODDNAME(name,main,l,s,help) MAKE_USAGE(#name, help##_trivial_usage) 48# define APPLET_ODDNAME(name,main,l,s,help) MAKE_USAGE(#name, help##_trivial_usage)
46# define APPLET_NOEXEC(name,main,l,s,help) MAKE_USAGE(#name, help##_trivial_usage) 49# define APPLET_NOEXEC(name,main,l,s,help) MAKE_USAGE(#name, help##_trivial_usage)
47# define APPLET_NOFORK(name,main,l,s,help) MAKE_USAGE(#name, help##_trivial_usage) 50# define APPLET_NOFORK(name,main,l,s,help) MAKE_USAGE(#name, help##_trivial_usage)
51# define APPLET_SCRIPTED(name,main,l,s,help) MAKE_USAGE(#name, help##_trivial_usage)
48 52
49#elif defined(MAKE_LINKS) 53#elif defined(MAKE_LINKS)
50# define APPLET(name,l,c) LINK l name 54# define APPLET(name,l,c) LINK l name
51# define APPLET_ODDNAME(name,main,l,s,help) LINK l name 55# define APPLET_ODDNAME(name,main,l,s,help) LINK l name
52# define APPLET_NOEXEC(name,main,l,s,help) LINK l name 56# define APPLET_NOEXEC(name,main,l,s,help) LINK l name
53# define APPLET_NOFORK(name,main,l,s,help) LINK l name 57# define APPLET_NOFORK(name,main,l,s,help) LINK l name
58# define APPLET_SCRIPTED(name,main,l,s,help) LINK l name
54 59
55#elif defined(MAKE_SUID) 60#elif defined(MAKE_SUID)
56# define APPLET(name,l,s) SUID s l name 61# define APPLET(name,l,s) SUID s l name
57# define APPLET_ODDNAME(name,main,l,s,help) SUID s l name 62# define APPLET_ODDNAME(name,main,l,s,help) SUID s l name
58# define APPLET_NOEXEC(name,main,l,s,help) SUID s l name 63# define APPLET_NOEXEC(name,main,l,s,help) SUID s l name
59# define APPLET_NOFORK(name,main,l,s,help) SUID s l name 64# define APPLET_NOFORK(name,main,l,s,help) SUID s l name
65# define APPLET_SCRIPTED(name,main,l,s,help) SUID s l name
66
67#elif defined(MAKE_SCRIPTS)
68# define APPLET(name,l,s)
69# define APPLET_ODDNAME(name,main,l,s,help)
70# define APPLET_NOEXEC(name,main,l,s,help)
71# define APPLET_NOFORK(name,main,l,s,help)
72# define APPLET_SCRIPTED(name,main,l,s,help) SCRIPT name
60 73
61#else 74#else
62 static struct bb_applet applets[] = { /* name, main, location, need_suid */ 75 static struct bb_applet applets[] = { /* name, main, location, need_suid */
@@ -64,6 +77,7 @@ s - suid type:
64# define APPLET_ODDNAME(name,main,l,s,help) { #name, #main, l, s }, 77# define APPLET_ODDNAME(name,main,l,s,help) { #name, #main, l, s },
65# define APPLET_NOEXEC(name,main,l,s,help) { #name, #main, l, s, 1 }, 78# define APPLET_NOEXEC(name,main,l,s,help) { #name, #main, l, s, 1 },
66# define APPLET_NOFORK(name,main,l,s,help) { #name, #main, l, s, 1, 1 }, 79# define APPLET_NOFORK(name,main,l,s,help) { #name, #main, l, s, 1, 1 },
80# define APPLET_SCRIPTED(name,main,l,s,help) { #name, #main, l, s },
67#endif 81#endif
68 82
69#if ENABLE_INSTALL_NO_USR 83#if ENABLE_INSTALL_NO_USR
@@ -84,3 +98,4 @@ INSERT
84#undef APPLET_ODDNAME 98#undef APPLET_ODDNAME
85#undef APPLET_NOEXEC 99#undef APPLET_NOEXEC
86#undef APPLET_NOFORK 100#undef APPLET_NOFORK
101#undef APPLET_SCRIPTED
diff --git a/include/bb_archive.h b/include/bb_archive.h
index ace9c8e23..5abcdcb44 100644
--- a/include/bb_archive.h
+++ b/include/bb_archive.h
@@ -228,12 +228,7 @@ const llist_t *find_list_entry(const llist_t *list, const char *filename) FAST_F
228const llist_t *find_list_entry2(const llist_t *list, const char *filename) FAST_FUNC; 228const llist_t *find_list_entry2(const llist_t *list, const char *filename) FAST_FUNC;
229 229
230/* A bit of bunzip2 internals are exposed for compressed help support: */ 230/* A bit of bunzip2 internals are exposed for compressed help support: */
231typedef struct bunzip_data bunzip_data; 231char *unpack_bz2_data(const char *packed, int packed_len, int unpacked_len) FAST_FUNC;
232int start_bunzip(void *, bunzip_data **bdp, int in_fd, const void *inbuf, int len) FAST_FUNC;
233/* NB: read_bunzip returns < 0 on error, or the number of *unfilled* bytes
234 * in outbuf. IOW: on EOF returns len ("all bytes are not filled"), not 0: */
235int read_bunzip(bunzip_data *bd, char *outbuf, int len) FAST_FUNC;
236void dealloc_bunzip(bunzip_data *bd) FAST_FUNC;
237 232
238/* Meaning and direction (input/output) of the fields are transformer-specific */ 233/* Meaning and direction (input/output) of the fields are transformer-specific */
239typedef struct transformer_state_t { 234typedef struct transformer_state_t {
diff --git a/include/libbb.h b/include/libbb.h
index 90fdd1178..405c929a2 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -777,18 +777,25 @@ struct hostent *xgethostbyname(const char *name) FAST_FUNC;
777// + inet_common.c has additional IPv4-only stuff 777// + inet_common.c has additional IPv4-only stuff
778 778
779 779
780struct tls_aes {
781 uint32_t key[60];
782 unsigned rounds;
783};
780#define TLS_MAX_MAC_SIZE 32 784#define TLS_MAX_MAC_SIZE 32
781#define TLS_MAX_KEY_SIZE 32 785#define TLS_MAX_KEY_SIZE 32
786#define TLS_MAX_IV_SIZE 4
782struct tls_handshake_data; /* opaque */ 787struct tls_handshake_data; /* opaque */
783typedef struct tls_state { 788typedef struct tls_state {
789 unsigned flags;
790
784 int ofd; 791 int ofd;
785 int ifd; 792 int ifd;
786 793
787 unsigned min_encrypted_len_on_read; 794 unsigned min_encrypted_len_on_read;
788 uint16_t cipher_id; 795 uint16_t cipher_id;
789 uint8_t encrypt_on_write;
790 unsigned MAC_size; 796 unsigned MAC_size;
791 unsigned key_size; 797 unsigned key_size;
798 unsigned IV_size;
792 799
793 uint8_t *outbuf; 800 uint8_t *outbuf;
794 int outbuf_size; 801 int outbuf_size;
@@ -810,12 +817,21 @@ typedef struct tls_state {
810 /*uint64_t read_seq64_be;*/ 817 /*uint64_t read_seq64_be;*/
811 uint64_t write_seq64_be; 818 uint64_t write_seq64_be;
812 819
820 /*uint8_t *server_write_MAC_key;*/
813 uint8_t *client_write_key; 821 uint8_t *client_write_key;
814 uint8_t *server_write_key; 822 uint8_t *server_write_key;
823 uint8_t *client_write_IV;
824 uint8_t *server_write_IV;
815 uint8_t client_write_MAC_key[TLS_MAX_MAC_SIZE]; 825 uint8_t client_write_MAC_key[TLS_MAX_MAC_SIZE];
816 uint8_t server_write_MAC_k__[TLS_MAX_MAC_SIZE]; 826 uint8_t server_write_MAC_k__[TLS_MAX_MAC_SIZE];
817 uint8_t client_write_k__[TLS_MAX_KEY_SIZE]; 827 uint8_t client_write_k__[TLS_MAX_KEY_SIZE];
818 uint8_t server_write_k__[TLS_MAX_KEY_SIZE]; 828 uint8_t server_write_k__[TLS_MAX_KEY_SIZE];
829 uint8_t client_write_I_[TLS_MAX_IV_SIZE];
830 uint8_t server_write_I_[TLS_MAX_IV_SIZE];
831
832 struct tls_aes aes_encrypt;
833 struct tls_aes aes_decrypt;
834 uint8_t H[16]; //used by AES_GCM
819} tls_state_t; 835} tls_state_t;
820 836
821static inline tls_state_t *new_tls_state(void) 837static inline tls_state_t *new_tls_state(void)
@@ -1366,9 +1382,22 @@ void bb_logenv_override(void) FAST_FUNC;
1366#define MAIN_EXTERNALLY_VISIBLE 1382#define MAIN_EXTERNALLY_VISIBLE
1367#endif 1383#endif
1368 1384
1385/* Embedded script support */
1386char *get_script_content(unsigned n) FAST_FUNC;
1387int scripted_main(int argc, char** argv);
1369 1388
1370/* Applets which are useful from another applets */ 1389/* Applets which are useful from another applets */
1371int bb_cat(char** argv) FAST_FUNC; 1390int bb_cat(char** argv) FAST_FUNC;
1391int ash_main(int argc, char** argv)
1392#if ENABLE_ASH || ENABLE_SH_IS_ASH || ENABLE_BASH_IS_ASH
1393 MAIN_EXTERNALLY_VISIBLE
1394#endif
1395;
1396int hush_main(int argc, char** argv)
1397#if ENABLE_HUSH || ENABLE_SH_IS_HUSH || ENABLE_BASH_IS_HUSH
1398 MAIN_EXTERNALLY_VISIBLE
1399#endif
1400;
1372/* If shell needs them, they exist even if not enabled as applets */ 1401/* If shell needs them, they exist even if not enabled as applets */
1373int echo_main(int argc, char** argv) IF_ECHO(MAIN_EXTERNALLY_VISIBLE); 1402int echo_main(int argc, char** argv) IF_ECHO(MAIN_EXTERNALLY_VISIBLE);
1374int printf_main(int argc, char **argv) IF_PRINTF(MAIN_EXTERNALLY_VISIBLE); 1403int printf_main(int argc, char **argv) IF_PRINTF(MAIN_EXTERNALLY_VISIBLE);
@@ -2041,7 +2070,7 @@ typedef struct bb_progress_t {
2041 (p)->curfile = NULL; \ 2070 (p)->curfile = NULL; \
2042} while (0) 2071} while (0)
2043void bb_progress_init(bb_progress_t *p, const char *curfile) FAST_FUNC; 2072void bb_progress_init(bb_progress_t *p, const char *curfile) FAST_FUNC;
2044void bb_progress_update(bb_progress_t *p, 2073int bb_progress_update(bb_progress_t *p,
2045 uoff_t beg_range, 2074 uoff_t beg_range,
2046 uoff_t transferred, 2075 uoff_t transferred,
2047 uoff_t totalsize) FAST_FUNC; 2076 uoff_t totalsize) FAST_FUNC;
diff --git a/include/platform.h b/include/platform.h
index 0d17062da..afd8cf292 100644
--- a/include/platform.h
+++ b/include/platform.h
@@ -252,6 +252,7 @@ typedef uint64_t bb__aliased_uint64_t FIX_ALIASING;
252# define move_from_unaligned32(v, u32p) ((v) = *(bb__aliased_uint32_t*)(u32p)) 252# define move_from_unaligned32(v, u32p) ((v) = *(bb__aliased_uint32_t*)(u32p))
253# define move_to_unaligned16(u16p, v) (*(bb__aliased_uint16_t*)(u16p) = (v)) 253# define move_to_unaligned16(u16p, v) (*(bb__aliased_uint16_t*)(u16p) = (v))
254# define move_to_unaligned32(u32p, v) (*(bb__aliased_uint32_t*)(u32p) = (v)) 254# define move_to_unaligned32(u32p, v) (*(bb__aliased_uint32_t*)(u32p) = (v))
255# define move_to_unaligned64(u64p, v) (*(bb__aliased_uint64_t*)(u64p) = (v))
255/* #elif ... - add your favorite arch today! */ 256/* #elif ... - add your favorite arch today! */
256#else 257#else
257# define BB_UNALIGNED_MEMACCESS_OK 0 258# define BB_UNALIGNED_MEMACCESS_OK 0
@@ -268,6 +269,10 @@ typedef uint64_t bb__aliased_uint64_t FIX_ALIASING;
268 uint32_t __t = (v); \ 269 uint32_t __t = (v); \
269 memcpy((u32p), &__t, 4); \ 270 memcpy((u32p), &__t, 4); \
270} while (0) 271} while (0)
272# define move_to_unaligned64(u64p, v) do { \
273 uint64_t __t = (v); \
274 memcpy((u64p), &__t, 8); \
275} while (0)
271#endif 276#endif
272 277
273/* Unaligned, fixed-endian accessors */ 278/* Unaligned, fixed-endian accessors */
diff --git a/include/usage.src.h b/include/usage.src.h
index 00369dfb3..d22efd3ba 100644
--- a/include/usage.src.h
+++ b/include/usage.src.h
@@ -14,6 +14,9 @@
14 14
15#define NOUSAGE_STR "\b" 15#define NOUSAGE_STR "\b"
16 16
17#define scripted_trivial_usage NOUSAGE_STR
18#define scripted_full_usage ""
19
17#if !ENABLE_USE_BB_CRYPT || ENABLE_USE_BB_CRYPT_SHA 20#if !ENABLE_USE_BB_CRYPT || ENABLE_USE_BB_CRYPT_SHA
18# define CRYPT_METHODS_HELP_STR "des,md5,sha256/512" \ 21# define CRYPT_METHODS_HELP_STR "des,md5,sha256/512" \
19 " (default "CONFIG_FEATURE_DEFAULT_PASSWD_ALGO")" 22 " (default "CONFIG_FEATURE_DEFAULT_PASSWD_ALGO")"