patch: allow default PATH extension at build time

Paul Fox pgf at brightstareng.com
Fri Sep 7 08:35:40 PDT 2007


this is a pretty non-intrusive patch.  no code change, no
additional bytes!  :-)

on our product(s), we try and keep locally developed executables
in a bin directory that is separate from the things that
traditionally come with a linux distribution.  this is for our
own convenience, and sanity.  but we want all system programs,
daemons, etc, to be able to get at those local executables
easily -- this is an embedded system, after all.  it's
inconvenient to externally augment the PATH of things started
directly from init, or at boot time, etc, so this patch allows
appending extra text to the default system PATH that's provided
by init (and by the shell).  (this patch is a lot smaller than it
used to be, because all instances of the default PATH have
recently been consolidated to messages.c -- thanks, vda.)

i'll commit in a day or two if no one objects.

paul

p.s.  the patch also rearranges the version text ifdef, for
symmetry with my addition.


Index: libbb/messages.c
===================================================================
--- libbb/messages.c	(revision 19795)
+++ libbb/messages.c	(working copy)
@@ -7,13 +7,21 @@
 
 #include "libbb.h"
 
+/* allow default system PATH to be extended via CFLAGS */
+#ifndef BB_ADDITIONAL_PATH
+#define BB_ADDITIONAL_PATH
+#endif
+
+/* allow version to be extended, via CFLAGS */
 #ifndef BB_EXTRA_VERSION
-#define BANNER "BusyBox v" BB_VER " (" BB_BT ")"
-#else
+#define BB_EXTRA_VERSION BB_BT
+#endif
+
 #define BANNER "BusyBox v" BB_VER " (" BB_EXTRA_VERSION ")"
-#endif
+
 const char bb_banner[] ALIGN1 = BANNER;
 
+
 const char bb_msg_memory_exhausted[] ALIGN1 = "memory exhausted";
 const char bb_msg_invalid_date[] ALIGN1 = "invalid date '%s'";
 const char bb_msg_write_error[] ALIGN1 = "write error";
@@ -39,7 +47,8 @@
 const char bb_default_login_shell[] ALIGN1 = LIBBB_DEFAULT_LOGIN_SHELL;
 /* util-linux manpage says /sbin:/bin:/usr/sbin:/usr/bin,
  * but I want to save a few bytes here. Check libbb.h before changing! */
-const char bb_PATH_root_path[] ALIGN1 = "PATH=/sbin:/usr/sbin:/bin:/usr/bin";
+const char bb_PATH_root_path[] ALIGN1 = 
+	"PATH=/sbin:/usr/sbin:/bin:/usr/bin" BB_ADDITIONAL_PATH;
 
 
 const int const_int_0;

=---------------------
 paul fox, pgf at brightstareng.com


More information about the busybox mailing list