int sigaction_set(int sig, const struct sigaction *act) FAST_FUNC;
/* SIG_BLOCK/SIG_UNBLOCK all signals: */
int sigprocmask_allsigs(int how) FAST_FUNC;
+/* Return old set in the same set: */
+int sigprocmask2(int how, sigset_t *set) FAST_FUNC;
/* Standard handler which just records signo */
extern smallint bb_got_signal;
void record_signo(int signo); /* not FAST_FUNC! */
// + inet_common.c has additional IPv4-only stuff
+struct tls_aes {
+ uint32_t key[60];
+ unsigned rounds;
+};
#define TLS_MAX_MAC_SIZE 32
#define TLS_MAX_KEY_SIZE 32
+#define TLS_MAX_IV_SIZE 4
struct tls_handshake_data; /* opaque */
typedef struct tls_state {
+ unsigned flags;
+
int ofd;
int ifd;
unsigned min_encrypted_len_on_read;
uint16_t cipher_id;
- uint8_t encrypt_on_write;
unsigned MAC_size;
unsigned key_size;
+ unsigned IV_size;
uint8_t *outbuf;
int outbuf_size;
/*uint64_t read_seq64_be;*/
uint64_t write_seq64_be;
+ /*uint8_t *server_write_MAC_key;*/
uint8_t *client_write_key;
uint8_t *server_write_key;
+ uint8_t *client_write_IV;
+ uint8_t *server_write_IV;
uint8_t client_write_MAC_key[TLS_MAX_MAC_SIZE];
uint8_t server_write_MAC_k__[TLS_MAX_MAC_SIZE];
uint8_t client_write_k__[TLS_MAX_KEY_SIZE];
uint8_t server_write_k__[TLS_MAX_KEY_SIZE];
+ uint8_t client_write_I_[TLS_MAX_IV_SIZE];
+ uint8_t server_write_I_[TLS_MAX_IV_SIZE];
+
+ struct tls_aes aes_encrypt;
+ struct tls_aes aes_decrypt;
+ uint8_t H[16]; //used by AES_GCM
} tls_state_t;
static inline tls_state_t *new_tls_state(void)
#if ENABLE_FLOAT_DURATION
typedef double duration_t;
void sleep_for_duration(duration_t duration) FAST_FUNC;
+#define DURATION_FMT "f"
#else
typedef unsigned duration_t;
#define sleep_for_duration(duration) sleep(duration)
+#define DURATION_FMT "u"
#endif
duration_t parse_duration_str(char *str) FAST_FUNC;
* to /dev/null if they are not.
*/
enum {
- DAEMON_CHDIR_ROOT = 1,
- DAEMON_DEVNULL_STDIO = 2,
- DAEMON_CLOSE_EXTRA_FDS = 4,
- DAEMON_ONLY_SANITIZE = 8, /* internal use */
- DAEMON_DOUBLE_FORK = 16, /* double fork to avoid controlling tty */
+ DAEMON_CHDIR_ROOT = 1 << 0,
+ DAEMON_DEVNULL_STDIO = 1 << 1,
+ DAEMON_CLOSE_EXTRA_FDS = 1 << 2,
+ DAEMON_ONLY_SANITIZE = 1 << 3, /* internal use */
+ //DAEMON_DOUBLE_FORK = 1 << 4, /* double fork to avoid controlling tty */
};
#if BB_MMU
enum { re_execed = 0 };
/* True only if we created pidfile which is *file*, not /dev/null etc */
extern smallint wrote_pidfile;
void write_pidfile(const char *path) FAST_FUNC;
+void write_pidfile_std_path_and_ext(const char *path) FAST_FUNC;
+void remove_pidfile_std_path_and_ext(const char *path) FAST_FUNC;
#define remove_pidfile(path) do { if (wrote_pidfile) unlink(path); } while (0)
#else
enum { wrote_pidfile = 0 };
+#define write_pidfile_std_path_and_ext(path) ((void)0)
+#define remove_pidfile_std_path_and_ext(path) ((void)0)
#define write_pidfile(path) ((void)0)
#define remove_pidfile(path) ((void)0)
#endif
LOGMODE_BOTH = LOGMODE_SYSLOG + LOGMODE_STDIO,
};
extern const char *msg_eol;
-extern smallint syslog_level;
extern smallint logmode;
extern uint8_t xfunc_error_retval;
extern void (*die_func)(void);
void bb_die_memory_exhausted(void) NORETURN FAST_FUNC;
void bb_logenv_override(void) FAST_FUNC;
+#if ENABLE_FEATURE_SYSLOG_INFO
+void bb_info_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2))) FAST_FUNC;
+void bb_vinfo_msg(const char *s, va_list p) FAST_FUNC;
+#else
+#define bb_info_msg bb_error_msg
+#define bb_vinfo_msg(s,p) bb_verror_msg(s,p,NULL)
+#endif
+
/* We need to export XXX_main from libbusybox
* only if we build "individual" binaries
*/
#endif
/* Embedded script support */
-//int find_script_by_name(const char *arg IF_FEATURE_SH_STANDALONE(, int offset)) FAST_FUNC;
char *get_script_content(unsigned n) FAST_FUNC;
+int scripted_main(int argc, char** argv) MAIN_EXTERNALLY_VISIBLE;
/* Applets which are useful from another applets */
int bb_cat(char** argv) FAST_FUNC;
MAIN_EXTERNALLY_VISIBLE
#endif
;
+int hush_main(int argc, char** argv)
+#if ENABLE_HUSH || ENABLE_SH_IS_HUSH || ENABLE_BASH_IS_HUSH
+ MAIN_EXTERNALLY_VISIBLE
+#endif
+;
/* If shell needs them, they exist even if not enabled as applets */
int echo_main(int argc, char** argv) IF_ECHO(MAIN_EXTERNALLY_VISIBLE);
int printf_main(int argc, char **argv) IF_PRINTF(MAIN_EXTERNALLY_VISIBLE);
const char *empty_str;
smallint all, nonempty;
};
-void print_numbered_lines(struct number_state *ns, const char *filename) FAST_FUNC;
+int print_numbered_lines(struct number_state *ns, const char *filename) FAST_FUNC;
/* Networking */
FOR_SHELL = DO_HISTORY | TAB_COMPLETION | USERNAME_COMPLETION,
};
line_input_t *new_line_input_t(int flags) FAST_FUNC;
-/* So far static: void free_line_input_t(line_input_t *n) FAST_FUNC; */
+void free_line_input_t(line_input_t *n) FAST_FUNC;
/*
* maxsize must be >= 2.
* Returns:
unsigned long stack;
unsigned long smap_pss, smap_swap;
unsigned long smap_size;
- unsigned long smap_start;
+ // For mixed 32/64 userspace, 32-bit pmap still needs
+ // 64-bit field here to correctly show 64-bit processes:
+ unsigned long long smap_start;
+ // (strictly speaking, other fields need to be wider too,
+ // but they are in kbytes, not bytes, and they hold sizes,
+ // not start addresses, sizes tend to be less than 4 terabytes)
char smap_mode[5];
char *smap_name;
};
(p)->curfile = NULL; \
} while (0)
void bb_progress_init(bb_progress_t *p, const char *curfile) FAST_FUNC;
-void bb_progress_update(bb_progress_t *p,
+int bb_progress_update(bb_progress_t *p,
uoff_t beg_range,
uoff_t transferred,
uoff_t totalsize) FAST_FUNC;