make a few struct bb_applet members conditional
rename sllep_and_die -> xfunc_die
make fflush_stdout_and_exit NOFORK-safe
fix some buglets found by randomconfig
diff --git a/include/applets.h b/include/applets.h
index b59d331..d05299b 100644
--- a/include/applets.h
+++ b/include/applets.h
@@ -52,12 +52,12 @@
# define APPLET_NOFORK(name,main,l,s,name2) LINK l name
#else
- const struct BB_applet applets[] = { /* name,main,location,need_suid */
-# define APPLET(name,l,s) {#name,name##_main,l,s},
-# define APPLET_NOUSAGE(name,main,l,s) {#name,main##_main,l,s},
-# define APPLET_ODDNAME(name,main,l,s,name2) {#name,main##_main,l,s},
-# define APPLET_NOEXEC(name,main,l,s,name2) {#name,main##_main,l,s,1},
-# define APPLET_NOFORK(name,main,l,s,name2) {#name,main##_main,l,s,1,1},
+ const struct bb_applet applets[] = { /* name, main, location, need_suid */
+# define APPLET(name,l,s) { #name, name##_main USE_FEATURE_INSTALLER(,l) USE_FEATURE_SUID(,s) },
+# define APPLET_NOUSAGE(name,main,l,s) { #name, main##_main USE_FEATURE_INSTALLER(,l) USE_FEATURE_SUID(,s) },
+# define APPLET_ODDNAME(name,main,l,s,name2) { #name, main##_main USE_FEATURE_INSTALLER(,l) USE_FEATURE_SUID(,s) },
+# define APPLET_NOEXEC(name,main,l,s,name2) { #name, main##_main USE_FEATURE_INSTALLER(,l) USE_FEATURE_SUID(,s) USE_FEATURE_EXEC_PREFER_APPLETS(,1) },
+# define APPLET_NOFORK(name,main,l,s,name2) { #name, main##_main USE_FEATURE_INSTALLER(,l) USE_FEATURE_SUID(,s) USE_FEATURE_EXEC_PREFER_APPLETS(,1 ,1) },
#endif
#if ENABLE_INSTALL_NO_USR
@@ -355,7 +355,7 @@
USE_ZCIP(APPLET(zcip, _BB_DIR_SBIN, _BB_SUID_NEVER))
#if !defined(PROTOTYPES) && !defined(MAKE_USAGE)
- { 0, NULL, 0, 0 }
+ { NULL }
};
#endif
diff --git a/include/busybox.h b/include/busybox.h
index 6f48087..380de9a 100644
--- a/include/busybox.h
+++ b/include/busybox.h
@@ -9,26 +9,35 @@
#include "libbb.h"
+#if ENABLE_FEATURE_INSTALLER
/* order matters: used as index into "install_dir[]" in busybox.c */
-enum Location {
+typedef enum bb_install_loc_t {
_BB_DIR_ROOT = 0,
_BB_DIR_BIN,
_BB_DIR_SBIN,
_BB_DIR_USR_BIN,
_BB_DIR_USR_SBIN
-};
+} bb_install_loc_t;
+#endif
-enum SUIDRoot {
+#if ENABLE_FEATURE_SUID
+typedef enum bb_suid_t {
_BB_SUID_NEVER = 0,
_BB_SUID_MAYBE,
_BB_SUID_ALWAYS
-};
+} bb_suid_t;
+#endif
-struct BB_applet {
+struct bb_applet {
const char *name;
int (*main) (int argc, char **argv);
- __extension__ enum Location location:8;
- __extension__ enum SUIDRoot need_suid:8;
+#if ENABLE_FEATURE_INSTALLER
+ __extension__ enum bb_install_loc_t install_loc:8;
+#endif
+#if ENABLE_FEATURE_SUID
+ __extension__ enum bb_suid_t need_suid:8;
+#endif
+#if ENABLE_FEATURE_EXEC_PREFER_APPLETS
/* true if instead if fork(); exec("applet"); waitpid();
* one can do fork(); exit(applet_main(argc,argv)); waitpid(); */
unsigned char noexec;
@@ -36,10 +45,11 @@
/* true if instead if fork(); exec("applet"); waitpid();
* one can simply call applet_main(argc,argv); */
unsigned char nofork;
+#endif
};
/* Defined in applet.c */
-extern const struct BB_applet applets[];
+extern const struct bb_applet applets[];
extern const unsigned short NUM_APPLETS;
#endif /* _BB_INTERNAL_H_ */
diff --git a/include/libbb.h b/include/libbb.h
index 3919524..6fff441 100644
--- a/include/libbb.h
+++ b/include/libbb.h
@@ -608,7 +608,7 @@
int write_pidfile(const char *path);
#define remove_pidfile(f) ((void)unlink(f))
#else
-#define write_pidfile(f) 1
+#define write_pidfile(f) TRUE
#define remove_pidfile(f) ((void)0)
#endif
@@ -623,7 +623,7 @@
extern int die_sleep;
extern int xfunc_error_retval;
extern jmp_buf die_jmp;
-extern void sleep_and_die(void) ATTRIBUTE_NORETURN;
+extern void xfunc_die(void) ATTRIBUTE_NORETURN;
extern void bb_show_usage(void) ATTRIBUTE_NORETURN ATTRIBUTE_EXTERNALLY_VISIBLE;
extern void bb_error_msg(const char *s, ...) __attribute__ ((format (printf, 1, 2)));
extern void bb_error_msg_and_die(const char *s, ...) __attribute__ ((noreturn, format (printf, 1, 2)));
@@ -670,8 +670,8 @@
#ifndef BUILD_INDIVIDUAL
-struct BB_applet;
-extern const struct BB_applet *find_applet_by_name(const char *name);
+struct bb_applet;
+extern const struct bb_applet *find_applet_by_name(const char *name);
/* Returns only if applet is not found. */
extern void run_applet_by_name(const char *name, int argc, char **argv);
extern void run_current_applet_and_exit(int argc, char **argv) ATTRIBUTE_NORETURN;
@@ -880,7 +880,7 @@
};
#define FILEUTILS_CP_OPTSTR "pdRfils" USE_SELINUX("c")
-extern const struct BB_applet *current_applet;
+extern const struct bb_applet *current_applet;
extern const char *applet_name;
extern const char BB_BANNER[];