gdm r5640 - in trunk: . gui/simple-greeter



Author: bcameron
Date: Tue Jan 29 00:33:55 2008
New Revision: 5640
URL: http://svn.gnome.org/viewvc/gdm?rev=5640&view=rev

Log:
2008-01-28  Brian Cameron  <brian cameron sun com>

        * acconfig.h, configure.ac, gui/simple-greeter/Makefile.am,
          gui/simple-greeter/gdm-greeter-login-window.c:  Make
          polkit-gnome an optional dependency.  Also support
          RBAC for shutdown/reboot if the --enable-rbac-shutdown
          configure option is provided.
        * configure.ac: Remove old RBAC configuration options that
          were used in the GDM 2.20 branch.
        * gui/simple-greeter/gdm-chooser-widget.c: Fix a null string
          argument problem causing core dumping on Solaris.


Modified:
   trunk/ChangeLog
   trunk/acconfig.h
   trunk/configure.ac
   trunk/gui/simple-greeter/Makefile.am
   trunk/gui/simple-greeter/gdm-chooser-widget.c
   trunk/gui/simple-greeter/gdm-greeter-login-window.c

Modified: trunk/acconfig.h
==============================================================================
--- trunk/acconfig.h	(original)
+++ trunk/acconfig.h	Tue Jan 29 00:33:55 2008
@@ -9,7 +9,6 @@
 #undef ENABLE_NLS
 #undef ALWAYS_RESTART_SERVER
 #undef GDM_USER_PATH
-#undef GDM_RBAC_SYSCMD_KEYS
 #undef HAVE_ADT
 #undef HAVE_CATGETS
 #undef HAVE_CHKAUTHATTR

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Tue Jan 29 00:33:55 2008
@@ -87,11 +87,20 @@
         gtk+-2.0 >= $GTK_REQUIRED_VERSION
         libglade-2.0 >= $LIBGLADE_REQUIRED_VERSION
         gnome-vfs-2.0 >= $GNOME_VFS_REQUIRED_VERSION
-        polkit-gnome >= $POLICYKIT_REQUIRED_VERSION
 )
 AC_SUBST(SIMPLE_GREETER_CFLAGS)
 AC_SUBST(SIMPLE_GREETER_LIBS)
 
+PKG_CHECK_MODULES(POLKIT_GNOME,
+  polkit >= $POLICYKIT_REQUIRED_VERSION,
+  have_polkit=yes,
+  have_polkit=no)
+if test "x$have_polkit" = "xyes" ; then
+       AC_DEFINE(HAVE_POLKIT_GNOME, [], [Define if we have polkit])
+fi
+AM_CONDITIONAL(HAVE_POLKIT_GNOME, test x$have_polkit = xyes)
+AC_SUBST(HAVE_POLKIT_GNOME)
+
 PKG_CHECK_MODULES(SIMPLE_CHOOSER,
         dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION
         gtk+-2.0 >= $GTK_REQUIRED_VERSION
@@ -862,6 +871,24 @@
 
 
 dnl ---------------------------------------------------------------------------
+dnl check for RBAC
+dnl ---------------------------------------------------------------------------
+
+msg_rbac_shutdown=no
+AC_ARG_ENABLE(rbac-shutdown,
+        [AC_HELP_STRING([--enable-rbac-shutdown=<key>],
+        [Build with RBAC support specifying shutdown/reboot RBAC authentication key])],
+        enable_rbac_shutdown=$enableval,enable_rbac_shutdown=no)
+if test "x$enable_rbac_shutdown" != "xno"; then
+        RBAC_LIBS="-lsecdb -lsocket -lnsl"
+        AC_DEFINE(ENABLE_RBAC_SHUTDOWN, [], [Set if we build with RBAC support])
+        AC_DEFINE_UNQUOTED(RBAC_SHUTDOWN_KEY, "$enable_rbac_shutdown", [Set if we build with RBAC support])
+        msg_rbac_shutdown="yes, using key $enable_rbac_shutdown"
+fi
+AC_SUBST(RBAC_LIBS)
+
+
+dnl ---------------------------------------------------------------------------
 dnl - Define some variables to represent the directories we use.
 dnl ---------------------------------------------------------------------------
 
@@ -977,15 +1004,6 @@
 		     	AC_DEFINE(HAVE_LOGINDEVPERM)
 			    EXTRA_DAEMON_LIBS="$EXTRA_DAEMON_LIBS -ldevinfo" ])
 
-# Check for RBAC support (chkauthattr
-#
-AC_MSG_CHECKING(for RBAC support - chkauthattr)
-AC_CHECK_LIB(secdb, chkauthattr, [
-		     	AC_DEFINE(HAVE_CHKAUTHATTR)
-			    EXTRA_DAEMON_LIBS="$EXTRA_DAEMON_LIBS -lsecdb"
-			    EXTRA_GREETER_LIBS="$EXTRA_GREETER_LIBS -lsecdb"])
-
-
 dnl ---------------------------------------------------------------------------
 dnl - Check for Halt, and Reboot commands
 dnl ---------------------------------------------------------------------------
@@ -995,7 +1013,6 @@
 # On Solaris/bin is a symlink to /usr/bin, so don't include it in
 # GDM_USER_PATH.
 GDM_USER_PATH=""
-GDM_RBAC_SYSCMD_KEYS=""
 
 case "$host" in
 *solaris*)
@@ -1006,7 +1023,6 @@
         SUSPEND_COMMAND="/usr/openwin/bin/sys-suspend -n"
         XSESSION_SHELL=/bin/ksh
         SOUND_PROGRAM=/usr/bin/audioplay
-        GDM_RBAC_SYSCMD_KEYS="HALT:solaris.system.shutdown;REBOOT:solaris.system.shutdown"
         ;;
 *freebsd*)
 	GDM_USER_PATH="/bin:/usr/bin"
@@ -1201,16 +1217,6 @@
 AC_SUBST(GDM_WORKING_DIR)
 
 dnl ---------------------------------------------------------------------------
-dnl - Allow configure to specify RBAC keys.
-dnl ---------------------------------------------------------------------------
-
-AC_ARG_WITH(rbac-system-command-keys,    [  --with-rbac-system-command-keys=<keys>     RBAC system command keys])
-
-if ! test -z "$with_system_command_keys"; then
-   GDM_RBAC_SYSCMD_KEYS=$with_system_command_keys
-fi
-
-dnl ---------------------------------------------------------------------------
 dnl - Finish
 dnl ---------------------------------------------------------------------------
 
@@ -1288,8 +1294,6 @@
 AC_DEFINE_UNQUOTED(GDM_USER_PATH,"$GDM_USER_PATH")
 AC_SUBST(SOUND_PROGRAM)
 AC_DEFINE_UNQUOTED(SOUND_PROGRAM,"$SOUND_PROGRAM")
-AC_SUBST(GDM_RBAC_SYSCMD_KEYS)
-AC_DEFINE_UNQUOTED(GDM_RBAC_SYSCMD_KEYS,"$GDM_RBAC_SYSCMD_KEYS")
 
 AC_SUBST(X_PATH)
 AC_SUBST(X_SERVER)
@@ -1371,6 +1375,7 @@
 	echo \
 "        TCP Wrappers support:     no"
 else
+	echo \
 "        TCP Wrappers support:     yes"
 fi
 
@@ -1379,4 +1384,5 @@
         XDMCP support:            ${XDMCP_SUPPORT}
         SELinux support:          ${with_selinux}
         ConsoleKit support:       ${use_console_kit}
+        Build with RBAC:          ${msg_rbac_shutdown}
 "

Modified: trunk/gui/simple-greeter/Makefile.am
==============================================================================
--- trunk/gui/simple-greeter/Makefile.am	(original)
+++ trunk/gui/simple-greeter/Makefile.am	Tue Jan 29 00:33:55 2008
@@ -19,6 +19,7 @@
 	-DAT_SPI_REGISTRYD_DIR="\"$(AT_SPI_REGISTRYD_DIR)\""	\
 	$(GTK_CFLAGS)					\
 	$(SIMPLE_GREETER_CFLAGS)			\
+	$(POLKIT_GNOME_CFLAGS)				\
 	$(NULL)
 
 @INTLTOOL_SCHEMAS_RULE@
@@ -58,6 +59,9 @@
 
 test_greeter_login_window_LDADD =	\
 	$(SIMPLE_GREETER_LIBS)		\
+	$(POLKIT_GNOME_LIBS)		\
+	$(RBAC_LIBS)			\
+	$(top_builddir)/common/libgdmcommon.la	\
 	$(NULL)
 
 test_greeter_panel_SOURCES = 	\
@@ -125,6 +129,7 @@
 
 test_user_chooser_LDADD =	\
 	$(SIMPLE_GREETER_LIBS)	\
+	$(POLKIT_GNOME_LIBS)	\
 	$(NULL)
 
 test_user_manager_SOURCES = 	\
@@ -138,6 +143,7 @@
 
 test_user_manager_LDADD =	\
 	$(SIMPLE_GREETER_LIBS)	\
+	$(POLKIT_GNOME_LIBS)	\
 	$(NULL)
 
 libexec_PROGRAMS =			\
@@ -177,6 +183,9 @@
 	$(top_builddir)/common/libgdmcommon.la	\
 	$(top_builddir)/gui/simple-greeter/libnotificationarea/libnotificationarea.la	\
 	$(SIMPLE_GREETER_LIBS)		\
+	$(POLKIT_GNOME_LIBS)		\
+	$(RBAC_LIBS)			\
+	$(top_builddir)/common/libgdmcommon.la	\
 	$(NULL)
 
 gladedir = $(pkgdatadir)

Modified: trunk/gui/simple-greeter/gdm-chooser-widget.c
==============================================================================
--- trunk/gui/simple-greeter/gdm-chooser-widget.c	(original)
+++ trunk/gui/simple-greeter/gdm-chooser-widget.c	Tue Jan 29 00:33:55 2008
@@ -1321,9 +1321,9 @@
         if (is_in_use) {
                 markup = g_strdup_printf ("<b>%s</b>\n"
                                           "<i><span size=\"x-small\">%s</span></i>",
-                                          name, widget->priv->in_use_message);
+                                          name ? name : "(null)", widget->priv->in_use_message);
         } else {
-                markup = g_strdup_printf ("<b>%s</b>", name);
+                markup = g_strdup_printf ("<b>%s</b>", name ? name : "(null)");
         }
         g_free (name);
 

Modified: trunk/gui/simple-greeter/gdm-greeter-login-window.c
==============================================================================
--- trunk/gui/simple-greeter/gdm-greeter-login-window.c	(original)
+++ trunk/gui/simple-greeter/gdm-greeter-login-window.c	Tue Jan 29 00:33:55 2008
@@ -33,6 +33,11 @@
 #include <errno.h>
 #include <pwd.h>
 
+#ifdef ENABLE_RBAC_SHUTDOWN
+#include <auth_attr.h>
+#include <secdb.h>
+#endif
+
 #include <glib.h>
 #include <glib/gi18n.h>
 #include <glib/gstdio.h>
@@ -49,7 +54,9 @@
 #include <dbus/dbus-glib.h>
 #include <dbus/dbus-glib-lowlevel.h>
 
+#if HAVE_POLKIT_GNOME
 #include <polkit-gnome/polkit-gnome.h>
+#endif
 
 #include "gdm-greeter-login-window.h"
 #include "gdm-user-chooser-widget.h"
@@ -196,6 +203,25 @@
         }
 }
 
+#ifdef ENABLE_RBAC_SHUTDOWN
+static char *
+get_user_name (uid_t uid)
+{
+        struct passwd *pwent;
+        char          *name;
+
+        name = NULL;
+
+        pwent = getpwuid (uid);
+
+        if (pwent != NULL) {
+                name = g_strdup (pwent->pw_name);
+        }
+
+        return name;
+}
+#endif
+
 static void
 switch_mode (GdmGreeterLoginWindow *login_window,
              int                    number)
@@ -203,16 +229,35 @@
         const char *default_name;
         GtkWidget  *user_chooser;
         GtkWidget  *box;
+        gchar      *username;
+        gboolean    show_restart_shutdown = TRUE;
+        uid_t       uid;
 
         /* FIXME: do animation */
         default_name = NULL;
 
+#ifdef ENABLE_RBAC_SHUTDOWN
+        uid      = getuid ();
+        username = get_user_name (uid);
+
+        if (username == NULL || !chkauthattr (RBAC_SHUTDOWN_KEY, username)) {
+                show_restart_shutdown = FALSE;
+                g_debug ("Not showing stop/restart buttons for user %s due to RBAC key %s",
+                         username, RBAC_SHUTDOWN_KEY);
+        } else {
+                g_debug ("Showing stop/restart buttons for user %s due to RBAC key %s",
+                         username, RBAC_SHUTDOWN_KEY);
+        }
+#endif
+
         switch (number) {
         case MODE_SELECTION:
                 show_widget (login_window, "log-in-button", FALSE);
                 show_widget (login_window, "cancel-button", FALSE);
-                show_widget (login_window, "shutdown-button", login_window->priv->display_is_local);
-                show_widget (login_window, "restart-button", login_window->priv->display_is_local);
+                show_widget (login_window, "shutdown-button",
+                             login_window->priv->display_is_local && show_restart_shutdown);
+                show_widget (login_window, "restart-button",
+                             login_window->priv->display_is_local && show_restart_shutdown);
                 show_widget (login_window, "suspend-button", login_window->priv->display_is_local);
                 show_widget (login_window, "disconnect-button", ! login_window->priv->display_is_local);
                 show_widget (login_window, "auth-input-box", FALSE);
@@ -525,6 +570,7 @@
         return res;
 }
 
+#ifdef HAVE_POLKIT_GNOME
 static void
 system_restart_auth_cb (PolKitAction          *action,
                         gboolean               gained_privilege,
@@ -613,6 +659,7 @@
 
         return action;
 }
+#endif
 
 static void
 do_system_restart (GdmGreeterLoginWindow *login_window)
@@ -630,6 +677,7 @@
         }
 
         res = try_system_restart (connection, &error);
+#ifdef HAVE_POLKIT_GNOME
         if (! res) {
                 g_debug ("GdmGreeterLoginWindow: unable to restart system: %s: %s",
                          dbus_g_error_get_name (error),
@@ -662,7 +710,7 @@
 
                 }
         }
-
+#endif
 }
 
 static void
@@ -681,6 +729,7 @@
         }
 
         res = try_system_stop (connection, &error);
+#ifdef HAVE_POLKIT_GNOME
         if (! res) {
                 g_debug ("GdmGreeterLoginWindow: unable to stop system: %s: %s",
                          dbus_g_error_get_name (error),
@@ -713,7 +762,7 @@
 
                 }
         }
-
+#endif
 }
 
 static void



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]