*
* 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
*
*/
#include <pwd.h>
#include <grp.h>
+#include <dbus/dbus-misc.h>
#include <dbus/dbus-shell.h>
#include <dbus/dbus-marshal-validate.h>
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 ())
"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;
uid = 0;
euid = 0;
-#ifndef ACTIVATION_LAUNCHER_TEST
/* bail out unless the dbus user is invoking the helper */
pw = getpwnam(dbus_user);
if (!pw)
}
static dbus_bool_t
-check_bus_name (const char *bus_name, DBusError *error)
+check_bus_name (const char *bus_name,
+ DBusError *error)
{
- if (!_dbus_check_is_valid_bus_name (bus_name))
+ DBusString str;
+
+ _dbus_string_init_const (&str, bus_name);
+ if (!_dbus_validate_bus_name (&str, 0, _dbus_string_get_length (&str)))
{
dbus_set_error (error, DBUS_ERROR_SPAWN_SERVICE_NOT_FOUND,
- "bus name '%s' not found\n", bus_name);
+ "bus name '%s' is not a valid bus name\n",
+ bus_name);
return FALSE;
}
+
return TRUE;
}
{
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())
}
dbus_bool_t
-run_launch_helper (const char *bus_name, DBusError *error)
+run_launch_helper (const char *bus_name,
+ DBusError *error)
{
BusConfigParser *parser;
dbus_bool_t retval;