revert the whole SUID situation
authorDennis Groenen <tj.groenen@gmail.com>
Tue, 10 Apr 2012 16:28:09 +0000 (18:28 +0200)
committerDennis Groenen <tj.groenen@gmail.com>
Tue, 10 Apr 2012 16:28:09 +0000 (18:28 +0200)
debian/busybox-power.postinst
debian/patches/0001-appletlib-parse-etc-environment-prior-to-applet-laun.patch [deleted file]
debian/patches/series
debian/rules
debian/scripts/environment [deleted file]

index 9c4a8c0..74c57df 100644 (file)
@@ -9,7 +9,12 @@ if ! grep -F -q "$line" /etc/profile; then
   echo "$line" >> /etc/profile
 fi
 
-# Set SUID bit on /bin/busybox. Privileges are automatically dropped for 
-# applets that do not require the SUID bit to be set
-chmod u+s /bin/busybox 
+# Clean up conffile (from busybox-power 1.19.3power4 & 1.19.3power5)
+if test -e /etc/environment; then
+  ORIGCONFIG_MD5="d23caa13476e0d872d23e7290b52f544"
+  INSTCONFIG_MD5=`md5sum /etc/environment | awk '{ print $1 }'`
+  if test "$INSTCONFIG_MD5" == "$ORIGCONFIG_MD5"; then
+    rm /etc/environment
+  fi
+fi
 
diff --git a/debian/patches/0001-appletlib-parse-etc-environment-prior-to-applet-laun.patch b/debian/patches/0001-appletlib-parse-etc-environment-prior-to-applet-laun.patch
deleted file mode 100644 (file)
index 4e446b3..0000000
+++ /dev/null
@@ -1,150 +0,0 @@
-From 92c63984fc28ea1bb0939acfcb551f65d7bfddf7 Mon Sep 17 00:00:00 2001
-From: Dennis Groenen <tj.groenen@gmail.com>
-Date: Fri, 23 Dec 2011 20:34:22 +0100
-Subject: [PATCH] appletlib: parse /etc/environment prior to applet launch
-
----
- libbb/appletlib.c |  117 +++++++++++++++++++++++++++++++++++++++++++++++++++++
- 1 files changed, 117 insertions(+), 0 deletions(-)
-
-diff --git a/libbb/appletlib.c b/libbb/appletlib.c
-index 8157b4f..d13aee5 100644
---- a/libbb/appletlib.c
-+++ b/libbb/appletlib.c
-@@ -474,6 +474,121 @@ static inline void parse_config_file(void)
- }
- # endif /* FEATURE_SUID_CONFIG */
-+/* We do not want to allow all characters in environment variables.
-+ * Function based on patch by Tito.
-+ * http://lists.busybox.net/pipermail/busybox/2011-August/076364.html */
-+static bool bad_env_var(const char *name)
-+{
-+      const char *s = name;
-+
-+      do {
-+              /* We don't use isalnum  as it will allow locale-specific non-ASCII */
-+              /* letters in legacy 8-bit locales. */
-+              if (((*name >= 48 && *name <= 57) && name != s) /* no numeric values as first char */
-+               || *name == '_' /* allow underscores */
-+               || (*name >= 65 && *name <= 90)  /* allow A-Z */
-+               || (*name >= 97 && *name <= 122) /* allow a-z */
-+              ) {
-+                      continue;
-+              }
-+              return true;
-+      } while (*++name);
-+      return false;
-+}
-+
-+static void load_env_vars(void)
-+{
-+      /* Don't depend on the tools to combine strings. */
-+      static const char config_file[] ALIGN1 = "/etc/environment";
-+
-+      FILE *f;
-+      const char *errmsg;
-+      unsigned lc;
-+      struct stat st;
-+
-+      if ((stat(config_file, &st) != 0)       /* No config file? */
-+       || !S_ISREG(st.st_mode)                /* Not a regular file? */
-+       || (st.st_uid != 0)                    /* Not owned by root? */
-+       || (st.st_mode & (S_IWGRP | S_IWOTH))  /* Writable by non-root? */
-+       || !(f = fopen_for_read(config_file))  /* Cannot open? */
-+      ) {
-+              return;
-+      }
-+
-+      lc = 0;
-+
-+      while (1) {
-+              char buffer[256];
-+              char *key;
-+              char *val;
-+              char *e;
-+
-+              if (!fgets(buffer, sizeof(buffer), f)) { /* Are we done? */
-+                      fclose(f);
-+                      return;
-+              }
-+
-+              key = buffer;
-+              lc++;                                   /* Got a (partial) line. */
-+
-+              /* If a line is too long for our buffer, we consider it an error.
-+               * The following test does mistreat one corner case though.
-+               * If the final line of the file does not end with a newline and
-+               * yet exactly fills the buffer, it will be treated as too long
-+               * even though there isn't really a problem.  But it isn't really
-+               * worth adding code to deal with such an unlikely situation, and
-+               * we do err on the side of caution.  Besides, the line would be
-+               * too long if it did end with a newline. */
-+              if (!strchr(key, '\n') && !feof(f)) {
-+                      errmsg = "line too long";
-+                      goto pe_label;
-+              }
-+
-+              /* Trim leading and trailing whitespace, ignoring comments, and
-+               * check if the resulting string is empty. */
-+              key = get_trimmed_slice(key, strchrnul(key, '#'));
-+              if (!*key) {
-+                      continue;
-+              }
-+
-+              /* Get the key */
-+              e = strchr(key, '=');
-+
-+              if (e) {
-+                      key = get_trimmed_slice(key, e);
-+              }
-+
-+              if (!e || !*key) {      /* Missing '=' or empty key. */
-+                      errmsg = "keyword";
-+                      goto pe_label;
-+              }
-+              if (bad_env_var(key)) { /* Check for illegal characters */
-+                      errmsg = "illegal character";
-+                      goto pe_label;
-+              }
-+
-+              /* Get the value */
-+              val = skip_whitespace(e+1); /* What's after the equal sign? */
-+
-+              if (!*val) { /* Empty value */
-+                      errmsg = "value";
-+                      goto pe_label;
-+              }
-+              if (*val == '"' && val[(strlen(val)-1)] == '"') {
-+                      /* We do not want to pass quoted strings to setenv. */
-+                      val++; 
-+                      val[strlen(val)-1] = 0;
-+              }
-+
-+              if (!getenv(key)) /* User vars > config vars */
-+                      xsetenv(key, val);
-+              continue;
-+      } /* while (1) */
-+
-+ pe_label:
-+      fclose(f);
-+      bb_error_msg("parse error in %s, line %u: %s", config_file, lc, errmsg);
-+}
- # if ENABLE_FEATURE_SUID
- static void check_suid(int applet_no)
-@@ -802,9 +917,11 @@ int main(int argc UNUSED_PARAM, char **argv)
-       }
-       /* applet_names in this case is just "applet\0\0" */
-       lbb_prepare(applet_names IF_FEATURE_INDIVIDUAL(, argv));
-+      load_env_vars();
-       return SINGLE_APPLET_MAIN(argc, argv);
- #else
-       lbb_prepare("busybox" IF_FEATURE_INDIVIDUAL(, argv));
-+      load_env_vars();
-       applet_name = argv[0];
-       if (applet_name[0] == '-')
--- 
-1.7.8
-
index cf503d1..989211e 100644 (file)
@@ -19,7 +19,6 @@ ps-accept-and-ignore-missing-options.patch
 
 #New patches as per reported issues by users
 showkey-default-option.patch
-0001-appletlib-parse-etc-environment-prior-to-applet-laun.patch
 0001-vi-implement-p-go-to-previous-file.patch
 
 #Hotfixes
index 476ccf7..fddeb41 100755 (executable)
@@ -86,7 +86,6 @@ binary-arch_busybox: $(STAMPS_DIR)/build_busybox
        install -D -m755 debian/scripts/install-binary.sh debian/busybox-power/opt/busybox-power/install-binary.sh
        install -D -m755 debian/scripts/uninstall-binary.sh debian/busybox-power/opt/busybox-power/uninstall-binary.sh
        install -D -m755 $(DIR)/busybox_unstripped debian/busybox-power/opt/busybox-power/busybox.power
-       install -D -m600 debian/scripts/environment debian/busybox-power/etc/environment
 
 binary-arch_all:
        dh_installdirs
diff --git a/debian/scripts/environment b/debian/scripts/environment
deleted file mode 100644 (file)
index 7bb0cb8..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-#
-# This file is parsed by busybox-power
-# Already set environment variables take precedence over those
-# listed in this file
-#
-# Syntax: simple "KEY=VAL" pairs on separate lines
-#
-
-TMPDIR=/var/tmp
-