ListNames and ListQueuedOwners updated to work with new kdbus
[platform/upstream/dbus.git] / bus / activation-helper.c
index 36006a4..e3b3323 100644 (file)
@@ -18,7 +18,7 @@
  *
  * You should have received a copy of the GNU General Public License
  * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
  *
  */
 
@@ -40,6 +40,7 @@
 #include <pwd.h>
 #include <grp.h>
 
+#include <dbus/dbus-misc.h>
 #include <dbus/dbus-shell.h>
 #include <dbus/dbus-marshal-validate.h>
 
@@ -140,21 +141,12 @@ out_all:
   return desktop_file;
 }
 
-/* Cleares the environment, except for DBUS_VERBOSE and DBUS_STARTER_x */
+/* Clears the environment, except for DBUS_STARTER_x,
+ * which we hardcode to the system bus.
+ */
 static dbus_bool_t
 clear_environment (DBusError *error)
 {
-  const char *debug_env = NULL;
-  const char *starter_env = NULL;
-
-#ifdef DBUS_ENABLE_VERBOSE_MODE
-  /* are we debugging */
-  debug_env = _dbus_getenv ("DBUS_VERBOSE");
-#endif
-
-  /* we save the starter */
-  starter_env = _dbus_getenv ("DBUS_STARTER_ADDRESS");
-
 #ifndef ACTIVATION_LAUNCHER_TEST
   /* totally clear the environment */
   if (!_dbus_clearenv ())
@@ -163,27 +155,19 @@ clear_environment (DBusError *error)
                       "could not clear environment\n");
       return FALSE;
     }
-#endif
 
-#ifdef DBUS_ENABLE_VERBOSE_MODE
-  /* restore the debugging environment setting if set */
-  if (debug_env)
-    _dbus_setenv ("DBUS_VERBOSE", debug_env);
+  /* Ensure the bus is set to system */
+  dbus_setenv ("DBUS_STARTER_ADDRESS", DBUS_SYSTEM_BUS_DEFAULT_ADDRESS);
+  dbus_setenv ("DBUS_STARTER_BUS_TYPE", "system");
 #endif
 
-  /* restore the starter */
-  if (starter_env)
-    _dbus_setenv ("DBUS_STARTER_ADDRESS", starter_env);
-
-  /* set the type, which must be system if we got this far */
-  _dbus_setenv ("DBUS_STARTER_BUS_TYPE", "system");
-
   return TRUE;
 }
 
 static dbus_bool_t
 check_permissions (const char *dbus_user, DBusError *error)
 {
+#ifndef ACTIVATION_LAUNCHER_TEST
   uid_t uid, euid;
   struct passwd *pw;
 
@@ -191,7 +175,6 @@ check_permissions (const char *dbus_user, DBusError *error)
   uid = 0;
   euid = 0;
 
-#ifndef ACTIVATION_LAUNCHER_TEST
   /* bail out unless the dbus user is invoking the helper */
   pw = getpwnam(dbus_user);
   if (!pw)
@@ -403,12 +386,15 @@ get_correct_parser (BusConfigParser **parser, DBusError *error)
 {
   DBusString config_file;
   dbus_bool_t retval;
+#ifdef ACTIVATION_LAUNCHER_TEST
   const char *test_config_file;
+#endif
 
   retval = FALSE;
-  test_config_file = NULL;
 
 #ifdef ACTIVATION_LAUNCHER_TEST
+  test_config_file = NULL;
+
   /* there is no _way_ we should be setuid if this define is set.
    * but we should be doubly paranoid and check... */
   if (getuid() != geteuid())