static dbus_bool_t get_parameters_for_service (BusDesktopFile *desktop_file, const char *service_name, char **exec, char **user, DBusError *error) { char *exec_tmp; char *user_tmp; exec_tmp = NULL; user_tmp = NULL; /* check the name of the service */ if (!check_service_name (desktop_file, service_name, error)) goto failed; /* get the complete path of the executable */ if (!bus_desktop_file_get_string (desktop_file, DBUS_SERVICE_SECTION, DBUS_SERVICE_EXEC, &exec_tmp, error)) { _DBUS_ASSERT_ERROR_IS_SET (error); goto failed; } /* get the user that should run this service - user is compulsary for system activation */ if (!bus_desktop_file_get_string (desktop_file, DBUS_SERVICE_SECTION, DBUS_SERVICE_USER, &user_tmp, error)) { _DBUS_ASSERT_ERROR_IS_SET (error); goto failed; } /* only assign if all the checks passed */ *exec = exec_tmp; *user = user_tmp; return TRUE; failed: dbus_free (exec_tmp); dbus_free (user_tmp); return FALSE; }
static dbus_bool_t get_parameters_for_service (BusDesktopFile *desktop_file, const char *service_name, char **exec, char **user, char **alias, DBusError *error) { char *exec_tmp; char *user_tmp; char *alias_tmp; exec_tmp = NULL; user_tmp = NULL; alias_tmp = NULL; /* check the name of the service */ if (!check_service_name (desktop_file, service_name, error)) goto failed; /* look up if the service is an alias to another service */ if (bus_desktop_file_get_string (desktop_file, DBUS_SERVICE_SECTION, DBUS_SERVICE_ALIAS, &alias_tmp, error)) { /* TODO: Should we check for Exec and User field in the file and warn / error if they are set? They don't make sense when a service is an alias to another service, and may be misleading. */ /* if (bus_desktop_file_has_string (desktop_file, DBUS_SERVICE_SECTION, DBUS_SERVICE_EXEC))) { dbus_set_error (error, DBUS_ERROR_SPAWN_SETUP_FAILED, "You can't set Alias and Exec together"); goto failed; } if (bus_desktop_file_has_string (desktop_file, DBUS_SERVICE_SECTION, DBUS_SERVICE_USER))) { dbus_set_error (error, DBUS_ERROR_SPAWN_SETUP_FAILED, "You can't set Alias and User together"); goto failed; } */ *alias = alias_tmp; return TRUE; } else { /* TODO: Notify of OOM errors, or you'll see confusing error messages. */ dbus_error_free (error); } /* get the complete path of the executable */ if (!bus_desktop_file_get_string (desktop_file, DBUS_SERVICE_SECTION, DBUS_SERVICE_EXEC, &exec_tmp, error)) { _DBUS_ASSERT_ERROR_IS_SET (error); goto failed; } /* get the user that should run this service - user is compulsary for system activation */ if (!bus_desktop_file_get_string (desktop_file, DBUS_SERVICE_SECTION, DBUS_SERVICE_USER, &user_tmp, error)) { _DBUS_ASSERT_ERROR_IS_SET (error); goto failed; } /* only assign if all the checks passed */ *exec = exec_tmp; *user = user_tmp; return TRUE; failed: dbus_free (exec_tmp); dbus_free (user_tmp); dbus_free (alias_tmp); return FALSE; }