From c3db90f7f8f0b5ba7421302c0ccefb4ac4d64702 Mon Sep 17 00:00:00 2001 From: Halton Huo Date: Fri, 15 Jan 2010 14:06:32 +0800 Subject: [PATCH] Enhancement CanActivateSessions for OpenSolaris. VT switching is always enabled on Linux, but for OpenSolaris VT switching can be truned of by 'svcadm disable vtdaemon'. So we should also check whether the service vtdaemon is online on OpenSolaris. https://bugs.freedesktop.org/show_bug.cgi?id=26055 --- configure.ac | 13 +++++++++++++ src/Makefile.am | 1 + src/ck-seat.c | 27 ++++++++++++++++++++++++++- 3 files changed, 40 insertions(+), 1 deletions(-) diff --git a/configure.ac b/configure.ac index 117d788..8619f31 100644 --- a/configure.ac +++ b/configure.ac @@ -320,6 +320,19 @@ fi AC_SUBST(RBAC_LIBS) dnl --------------------------------------------------------------------------- +dnl check for SCF (Only avail on solaris) +dnl --------------------------------------------------------------------------- + +AC_CHECK_LIB(scf, smf_get_state, + [SCF_LIBS=-lscf + AC_DEFINE(HAVE_SCF,1,[Define to 1 if the libscf library is present.])], + [AC_MSG_WARN([[ +*** +*** libscf was not found. +]])]) +AC_SUBST(SCF_LIBS) + +dnl --------------------------------------------------------------------------- dnl Finish dnl --------------------------------------------------------------------------- diff --git a/src/Makefile.am b/src/Makefile.am index 6ab05c8..4788fe1 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -139,6 +139,7 @@ console_kit_daemon_LDADD = \ $(CONSOLE_KIT_LIBS) \ $(POLKIT_LIBS) \ $(RBAC_LIBS) \ + $(SCF_LIBS) \ libck.la \ libck-event-log.la \ $(NULL) diff --git a/src/ck-seat.c b/src/ck-seat.c index af7db59..03231ee 100644 --- a/src/ck-seat.c +++ b/src/ck-seat.c @@ -25,6 +25,9 @@ #include #include #include +#ifdef HAVE_SCF +#include +#endif #include #include @@ -662,6 +665,27 @@ ck_seat_add_session (CkSeat *seat, } gboolean +is_vt_enabled () +{ +#ifdef HAVE_SCF + char *state = NULL; + gboolean vt_enabled; + + state = smf_get_state ("svc:/system/vtdaemon:default"); + if (state && g_str_equal (state, SCF_STATE_STRING_ONLINE)) { + vt_enabled = TRUE; + } else { + vt_enabled = FALSE; + } + + g_free (state); + return vt_enabled; +#else + return TRUE; +#endif /* HAVE_SCF */ +} + +gboolean ck_seat_can_activate_sessions (CkSeat *seat, gboolean *can_activate, GError **error) @@ -669,7 +693,8 @@ ck_seat_can_activate_sessions (CkSeat *seat, g_return_val_if_fail (CK_IS_SEAT (seat), FALSE); if (can_activate != NULL) { - *can_activate = (seat->priv->kind == CK_SEAT_KIND_STATIC); + *can_activate = (seat->priv->kind == CK_SEAT_KIND_STATIC) + && is_vt_enabled (); } return TRUE; -- 1.5.6.5