aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTed Gould <ted@canonical.com>2009-07-20 12:44:32 -0500
committerTed Gould <ted@canonical.com>2009-07-20 12:44:32 -0500
commitc1b327315d06e8082dad23380d360a22a0542c4b (patch)
tree92d9091c31f35d023550af08f7f39ea2c0e603c2 /src
parent015f1c1636e6c3b3d84375121ed14a760d76ee8e (diff)
downloadayatana-indicator-session-c1b327315d06e8082dad23380d360a22a0542c4b.tar.gz
ayatana-indicator-session-c1b327315d06e8082dad23380d360a22a0542c4b.tar.bz2
ayatana-indicator-session-c1b327315d06e8082dad23380d360a22a0542c4b.zip
Setting the menu item to activate the guest user session
Diffstat (limited to 'src')
-rw-r--r--src/users-service.c32
1 files changed, 27 insertions, 5 deletions
diff --git a/src/users-service.c b/src/users-service.c
index 66dc86e..39c30bb 100644
--- a/src/users-service.c
+++ b/src/users-service.c
@@ -9,13 +9,33 @@
#include "dbus-shared-names.h"
+#define GUEST_SESSION_LAUNCHER "/usr/share/gdm/guest-session/guest-session-launch"
+
static DbusmenuMenuitem * root_menuitem = NULL;
static GMainLoop * mainloop = NULL;
+static gboolean
+check_guest_session (void)
+{
+ if (geteuid() < 500) {
+ /* System users shouldn't have guest account shown. Mosly
+ this would be the case of the guest user itself. */
+ return FALSE;
+ }
+ if (!g_file_test(GUEST_SESSION_LAUNCHER, G_FILE_TEST_IS_EXECUTABLE)) {
+ /* It doesn't appear that the Guest session stuff is
+ installed. So let's not use it then! */
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
static void
activate_guest_session (DbusmenuMenuitem * mi, gpointer user_data)
{
-
+ gchar *argv[] = {GUEST_SESSION_LAUNCHER, NULL };
+ g_spawn_sync (NULL, argv, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL);
}
static void
@@ -28,10 +48,12 @@ static void
create_items (DbusmenuMenuitem * root) {
DbusmenuMenuitem * mi = NULL;
- mi = dbusmenu_menuitem_new();
- dbusmenu_menuitem_property_set(mi, "label", _("Guest Session"));
- dbusmenu_menuitem_child_append(root, mi);
- g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(activate_guest_session), NULL);
+ if (check_guest_session()) {
+ mi = dbusmenu_menuitem_new();
+ dbusmenu_menuitem_property_set(mi, "label", _("Guest Session"));
+ dbusmenu_menuitem_child_append(root, mi);
+ g_signal_connect(G_OBJECT(mi), DBUSMENU_MENUITEM_SIGNAL_ITEM_ACTIVATED, G_CALLBACK(activate_guest_session), NULL);
+ }
mi = dbusmenu_menuitem_new();
dbusmenu_menuitem_property_set(mi, "label", _("New Session..."));