[BusyBox] [PATCH] devfsd

Allen Chan allen at developers.alyz.com
Mon Nov 15 19:44:20 UTC 2004


In BusyBox 1.00, with CONFIG_DEVFSD_VERBOSE=y, devfsd sometimes 
generate incorrect error messages.  For example, after adding 
'/sbin/devfsd /dev" to a startup script in /etc/init.d, I get the 
following output in dmesg even though /etc/devfsd.conf exists and 
devfsd creates all the symlinks as defined in the config file:

 devfsd v1.3.25  started for /dev
 devfsd: read config file: /etc/devfsd.conf: No such file or directory

The problem is due to the possible corruption of the global errno 
variable while inside the msg_logger function, possibly causing 
arbitrary messages to be displayed.  The value of errno needs to be 
saved and restored as described on the errno man page.

diff -Npur orig/miscutils/devfsd.c new/miscutils/devfsd.c
--- orig/miscutils/devfsd.c 2004-10-13 02:25:52.000000000 -0400
+++ new/miscutils/devfsd.c 2004-11-15 14:08:12.000000000 -0500
@@ -306,19 +306,24 @@ const char * const bb_msg_variable_not_f
 #if defined(CONFIG_DEVFSD_VERBOSE) || defined(CONFIG_DEBUG)
 static void msg_logger(int die, int pri, const char * fmt, ... )
 {
+ int errno_save = errno;
  va_list ap;
 
  va_start(ap, fmt);
  if (access ("/dev/log", F_OK) == 0)
  {
   openlog(bb_applet_name, 0, LOG_DAEMON);
+  errno = errno_save;
   vsyslog( pri , fmt , ap);
   closelog();
   }
 #ifndef CONFIG_DEBUG
  else
 #endif
+ {
+  errno = errno_save;
   bb_verror_msg(fmt, ap);
+ }
  va_end(ap);
  if(die==DIE)
   exit(EXIT_FAILURE);
----- end of patch -----

-- 
Allen Chan
allen at developers.alyz.com
http://www.alyz.com



More information about the busybox mailing list