commit b1b77502f03c4a1034ef7feebad9b43abf01da33 Author: Halton Huo Date: Fri Jan 15 14:06:32 2010 +0800 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 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..b2e5628 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 @@ -661,6 +664,26 @@ ck_seat_add_session (CkSeat *seat, return TRUE; } +is_VT_enabled () +{ +#ifdef HAVE_SYS_VT_H + 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 FALSE; +#endif /* HAVE_SYS_VT_H */ +} + gboolean ck_seat_can_activate_sessions (CkSeat *seat, gboolean *can_activate, @@ -669,7 +692,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;