diff options
Diffstat (limited to 'kdm')
30 files changed, 1149 insertions, 220 deletions
diff --git a/kdm/backend/Imakefile b/kdm/backend/Imakefile index 75efcb45a..f3b4e0050 100644 --- a/kdm/backend/Imakefile +++ b/kdm/backend/Imakefile @@ -155,13 +155,13 @@ PROCTITLE_DEFINES = -DHAS_SETPROCTITLE netaddr.c reset.c resource.c protodpy.c policy.c \ session.c socket.c streams.c util.c xdmcp.c \ process.c mitauth.c \ - genauth.c access.c choose.c \ + genauth.c access.c choose.c consolekit.c \ $(XDMAUTHSRCS) $(RPCSRCS) $(KRB5SRCS) COMMOBJS = auth.o daemon.o server.o dpylist.o dm.o error.o \ netaddr.o reset.o resource.o protodpy.o policy.o \ session.o socket.o streams.o util.o xdmcp.o \ process.o mitauth.o \ - genauth.o access.o choose.o \ + genauth.o access.o choose.o consolekit.o \ $(XDMAUTHOBJS) $(RPCOBJS) $(KRB5OBJS) SRCS1 = $(COMMSRCS) client.c diff --git a/kdm/backend/Makefile.am b/kdm/backend/Makefile.am index 81dc2702f..58c2a9e43 100644 --- a/kdm/backend/Makefile.am +++ b/kdm/backend/Makefile.am @@ -1,9 +1,9 @@ # forcibly remove thread-related defines & flags AUTOMAKE_OPTIONS = foreign -CPPFLAGS = $(USER_INCLUDES) $(X_INCLUDES) $(KRB4_INCS) $(KRB5_INCS) -I.. -I../.. +CPPFLAGS = $(USER_INCLUDES) $(X_INCLUDES) $(KRB4_INCS) $(KRB5_INCS) $(DBUS_INCS) -I.. -I../.. LDFLAGS = $(USER_LDFLAGS) $(X_LDFLAGS) $(X_RPATH) $(KRB4_RPATH) $(KRB5_RPATH) LDADD = $(LIB_X11) -lXau $(LIBXDMCP) $(PASSWDLIBS) $(LIBSHADOW) $(LIBGEN) \ - $(LIB_LIBS) $(KRB4_LIBS) $(KRB5_LIBS) $(LIBSOCKET) $(LIBRESOLV) \ + $(LIB_LIBS) $(KRB4_LIBS) $(KRB5_LIBS) $(DBUS_LIBS) $(LIBSOCKET) $(LIBRESOLV) \ $(LIBUCB) $(LIBUTIL) $(LIBPOSIX4) bin_PROGRAMS = kdm @@ -13,6 +13,7 @@ kdm_SOURCES = \ bootman.c \ choose.c \ client.c \ + consolekit.c \ ctrl.c \ daemon.c \ dm.c \ diff --git a/kdm/backend/auth.c b/kdm/backend/auth.c index fa7afac01..21b3c5d48 100644 --- a/kdm/backend/auth.c +++ b/kdm/backend/auth.c @@ -942,7 +942,7 @@ setAuthNumber( Xauth *auth, const char *name ) colon = strrchr( name, ':' ); if (colon) { ++colon; - dot = strchr( colon, '.' ); + dot = (char*)strchr( colon, '.' ); if (dot) auth->number_length = dot - colon; else diff --git a/kdm/backend/bootman.c b/kdm/backend/bootman.c index c6ac968a2..291164ea7 100644 --- a/kdm/backend/bootman.c +++ b/kdm/backend/bootman.c @@ -82,7 +82,7 @@ getGrub( char ***opts, int *def, int *cur ) int len; char line[1000]; - if (!grub && !(grub = locate( "grub" ))) + if (!grub && !(grub = locate( "grub-set-default" ))) return BO_NOMAN; *def = 0; @@ -132,19 +132,14 @@ setGrub( const char *opt, SdRec *sdr ) static void commitGrub( void ) { - FILE *f; - int pid; - static const char *args[] = { 0, "--batch", "--no-floppy", 0 }; + char command[256]; if (sdRec.bmstamp != mTime( GRUB_MENU ) && setGrub( sdRec.osname, &sdRec ) != BO_OK) return; - args[0] = grub; - if ((f = pOpen( (char **)args, 'w', &pid ))) { - fprintf( f, "savedefault --default=%d --once\n", sdRec.osindex ); - pClose( f, pid ); - } + sprintf(command, "%s %d", grub, sdRec.osindex); + system(command); } static char *lilo; diff --git a/kdm/backend/client.c b/kdm/backend/client.c index c807b6e15..b2e7ebbc7 100644 --- a/kdm/backend/client.c +++ b/kdm/backend/client.c @@ -83,6 +83,10 @@ extern int loginsuccess( const char *User, const char *Host, const char *Tty, ch #endif #include <signal.h> +#ifdef WITH_CONSOLE_KIT +#include "consolekit.h" +#endif + /* * Session data, mostly what struct verify_info was for */ @@ -310,7 +314,7 @@ doPAMAuth( const char *psrv, struct pam_data *pdata ) V_RET_FAIL( 0 ); } if ((td->displayType & d_location) == dForeign) { - char *cp = strchr( td->name, ':' ); + char *cp = (char*)strchr( td->name, ':' ); *cp = 0; pretc = pam_set_item( pamh, PAM_RHOST, td->name ); *cp = ':'; @@ -495,7 +499,7 @@ Verify( GConvFunc gconv, int rootok ) char *tmpch; strncpy( hostname, td->name, sizeof(hostname) - 1 ); hostname[sizeof(hostname)-1] = '\0'; - if ((tmpch = strchr( hostname, ':' ))) + if ((tmpch = (char*)strchr( hostname, ':' ))) *tmpch = '\0'; } else hostname[0] = '\0'; @@ -1121,8 +1125,13 @@ static int removeSession; static int removeCreds; #endif +#ifdef WITH_CONSOLE_KIT +int +StartClient( const char *ck_session_cookie ) +#else int StartClient() +#endif { const char *home, *sessargs, *desksess; char **env, *xma; @@ -1218,6 +1227,11 @@ StartClient() if (krbtkfile[0] != '\0') env = setEnv( env, "KRBTKFILE", krbtkfile ); #endif +#ifdef WITH_CONSOLE_KIT + if (ck_session_cookie != NULL) { + env = setEnv ( env, "XDG_SESSION_COOKIE", ck_session_cookie ); + } +#endif userEnviron = inheritEnv( env, envvars ); env = systemEnv( p->pw_name ); systemEnviron = setEnv( env, "HOME", p->pw_dir ); diff --git a/kdm/backend/consolekit.c b/kdm/backend/consolekit.c new file mode 100644 index 000000000..cb59b7369 --- /dev/null +++ b/kdm/backend/consolekit.c @@ -0,0 +1,557 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Copyright (C) 2006-2007 William Jon McCann <[email protected]> + * Copyright (C) 2007 Kevin Kofler <[email protected]> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + +#include "dm.h" +#include "dm_auth.h" +#include "dm_error.h" + +#include <stdlib.h> +#include <string.h> +#include <pwd.h> + +#define DBUS_API_SUBJECT_TO_CHANGE +#include <dbus/dbus.h> + +#include "consolekit.h" + + +#define CK_NAME "org.freedesktop.ConsoleKit" +#define CK_PATH "/org/freedesktop/ConsoleKit" +#define CK_INTERFACE "org.freedesktop.ConsoleKit" +#define CK_MANAGER_PATH "/org/freedesktop/ConsoleKit/Manager" +#define CK_MANAGER_INTERFACE "org.freedesktop.ConsoleKit.Manager" +#define CK_SESSION_INTERFACE "org.freedesktop.ConsoleKit.Session" + +static DBusConnection *private_connection = NULL; + +static void +add_param_int (DBusMessageIter *iter_struct, + const char *key, + int value) +{ + DBusMessageIter iter_struct_entry; + DBusMessageIter iter_var; + + dbus_message_iter_open_container (iter_struct, + DBUS_TYPE_STRUCT, + NULL, + &iter_struct_entry); + + dbus_message_iter_append_basic (&iter_struct_entry, + DBUS_TYPE_STRING, + &key); + + dbus_message_iter_open_container (&iter_struct_entry, + DBUS_TYPE_VARIANT, + DBUS_TYPE_INT32_AS_STRING, + &iter_var); + + dbus_message_iter_append_basic (&iter_var, + DBUS_TYPE_INT32, + &value); + + dbus_message_iter_close_container (&iter_struct_entry, + &iter_var); + + dbus_message_iter_close_container (iter_struct, &iter_struct_entry); +} + +static void +add_param_boolean (DBusMessageIter *iter_struct, + const char *key, + int value) +{ + DBusMessageIter iter_struct_entry; + DBusMessageIter iter_var; + + dbus_message_iter_open_container (iter_struct, + DBUS_TYPE_STRUCT, + NULL, + &iter_struct_entry); + + dbus_message_iter_append_basic (&iter_struct_entry, + DBUS_TYPE_STRING, + &key); + + dbus_message_iter_open_container (&iter_struct_entry, + DBUS_TYPE_VARIANT, + DBUS_TYPE_BOOLEAN_AS_STRING, + &iter_var); + + dbus_message_iter_append_basic (&iter_var, + DBUS_TYPE_BOOLEAN, + &value); + + dbus_message_iter_close_container (&iter_struct_entry, + &iter_var); + + dbus_message_iter_close_container (iter_struct, &iter_struct_entry); +} + +static void +add_param_string (DBusMessageIter *iter_struct, + const char *key, + const char *value) +{ + DBusMessageIter iter_struct_entry; + DBusMessageIter iter_var; + + dbus_message_iter_open_container (iter_struct, + DBUS_TYPE_STRUCT, + NULL, + &iter_struct_entry); + + dbus_message_iter_append_basic (&iter_struct_entry, + DBUS_TYPE_STRING, + &key); + + dbus_message_iter_open_container (&iter_struct_entry, + DBUS_TYPE_VARIANT, + DBUS_TYPE_STRING_AS_STRING, + &iter_var); + + dbus_message_iter_append_basic (&iter_var, + DBUS_TYPE_STRING, + &value); + + dbus_message_iter_close_container (&iter_struct_entry, + &iter_var); + + dbus_message_iter_close_container (iter_struct, &iter_struct_entry); +} + +static int +session_get_x11_display (DBusConnection *connection, + const char *ssid, + char **str) +{ + DBusError error; + DBusMessage *message; + DBusMessage *reply; + DBusMessageIter iter; + const char *value; + + if (str != NULL) { + *str = NULL; + } + + message = dbus_message_new_method_call (CK_NAME, + ssid, + CK_SESSION_INTERFACE, + "GetX11Display"); + if (message == NULL) { + Debug ("ConsoleKit: Couldn't allocate the D-Bus message"); + return FALSE; + } + + dbus_error_init (&error); + reply = dbus_connection_send_with_reply_and_block (connection, + message, + -1, &error); + if (dbus_error_is_set (&error)) { + Debug ("ConsoleKit: %s raised:\n %s\n\n", error.name, error.message); + reply = NULL; + } + + dbus_connection_flush (connection); + dbus_message_unref (message); + + if (reply == NULL) { + return FALSE; + } + + dbus_message_iter_init (reply, &iter); + dbus_message_iter_get_basic (&iter, &value); + if (str != NULL) { + *str = strdup (value); + } + dbus_message_unref (reply); + + return TRUE; +} + +static int +session_unlock (DBusConnection *connection, + const char *ssid) +{ + DBusError error; + DBusMessage *message; + DBusMessage *reply; + + Debug ("ConsoleKit: Unlocking session %s", ssid); + message = dbus_message_new_method_call (CK_NAME, + ssid, + CK_SESSION_INTERFACE, + "Unlock"); + if (message == NULL) { + Debug ("ConsoleKit: Couldn't allocate the D-Bus message"); + return FALSE; + } + + dbus_error_init (&error); + reply = dbus_connection_send_with_reply_and_block (connection, + message, + -1, &error); + dbus_message_unref (message); + dbus_message_unref (reply); + dbus_connection_flush (connection); + + if (dbus_error_is_set (&error)) { + Debug ("ConsoleKit: %s raised:\n %s\n\n", error.name, error.message); + return FALSE; + } + + return TRUE; +} + +/* from libhal */ +static char ** +get_path_array_from_iter (DBusMessageIter *iter, + int *num_elements) +{ + int count; + char **buffer; + + count = 0; + buffer = (char **)malloc (sizeof (char *) * 8); + + if (buffer == NULL) + goto oom; + + buffer[0] = NULL; + while (dbus_message_iter_get_arg_type (iter) == DBUS_TYPE_OBJECT_PATH) { + const char *value; + char *str; + + if ((count % 8) == 0 && count != 0) { + buffer = realloc (buffer, sizeof (char *) * (count + 8)); + if (buffer == NULL) + goto oom; + } + + dbus_message_iter_get_basic (iter, &value); + str = strdup (value); + if (str == NULL) + goto oom; + + buffer[count] = str; + + dbus_message_iter_next (iter); + count++; + } + + if ((count % 8) == 0) { + buffer = realloc (buffer, sizeof (char *) * (count + 1)); + if (buffer == NULL) + goto oom; + } + + buffer[count] = NULL; + if (num_elements != NULL) + *num_elements = count; + return buffer; + +oom: + LogWarn ("%s %d : error allocating memory\n", __FILE__, __LINE__); + return NULL; + +} + +static char ** +get_sessions_for_user (DBusConnection *connection, + const char *user, + const char *x11_display) +{ + DBusError error; + DBusMessage *message; + DBusMessage *reply; + DBusMessageIter iter; + DBusMessageIter iter_reply; + DBusMessageIter iter_array; + struct passwd *pwent; + char **sessions; + + sessions = NULL; + message = NULL; + reply = NULL; + + pwent = getpwnam (user); + + dbus_error_init (&error); + message = dbus_message_new_method_call (CK_NAME, + CK_MANAGER_PATH, + CK_MANAGER_INTERFACE, + "GetSessionsForUser"); + if (message == NULL) { + Debug ("ConsoleKit: Couldn't allocate the D-Bus message"); + goto out; + } + + dbus_message_iter_init_append (message, &iter); + dbus_message_iter_append_basic (&iter, + DBUS_TYPE_UINT32, + &pwent->pw_uid); + + dbus_error_init (&error); + reply = dbus_connection_send_with_reply_and_block (connection, + message, + -1, &error); + dbus_connection_flush (connection); + + if (dbus_error_is_set (&error)) { + Debug ("ConsoleKit: %s raised:\n %s\n\n", error.name, error.message); + goto out; + } + + if (reply == NULL) { + Debug ("ConsoleKit: No reply for GetSessionsForUser"); + goto out; + } + + dbus_message_iter_init (reply, &iter_reply); + if (dbus_message_iter_get_arg_type (&iter_reply) != DBUS_TYPE_ARRAY) { + Debug ("ConsoleKit: Wrong reply for GetSessionsForUser - expecting an array."); + goto out; + } + + dbus_message_iter_recurse (&iter_reply, &iter_array); + sessions = get_path_array_from_iter (&iter_array, NULL); + + out: + if (message != NULL) { + dbus_message_unref (message); + } + if (reply != NULL) { + dbus_message_unref (reply); + } + + return sessions; +} + +void +unlock_ck_session (const char *user, + const char *x11_display) +{ + DBusError error; + DBusConnection *connection; + char **sessions; + int i; + + Debug ("ConsoleKit: Unlocking session for %s on %s", user, x11_display); + + dbus_error_init (&error); + connection = dbus_bus_get (DBUS_BUS_SYSTEM, &error); + if (connection == NULL) { + Debug ("ConsoleKit: Failed to connect to the D-Bus daemon: %s", error.message); + dbus_error_free (&error); + return; + } + + sessions = get_sessions_for_user (connection, user, x11_display); + if (sessions == NULL || sessions[0] == NULL) { + Debug ("ConsoleKit: no sessions found"); + return; + } + + for (i = 0; sessions[i] != NULL; i++) { + char *ssid; + char *xdisplay; + + ssid = sessions[i]; + session_get_x11_display (connection, ssid, &xdisplay); + Debug ("ConsoleKit: session %s has DISPLAY %s", ssid, xdisplay); + + if (xdisplay != NULL + && x11_display != NULL + && strcmp (xdisplay, x11_display) == 0) { + int res; + + res = session_unlock (connection, ssid); + if (! res) { + LogError ("ConsoleKit: Unable to unlock %s", ssid); + } + } + + free (xdisplay); + } + + freeStrArr (sessions); +} + +char * +open_ck_session (struct passwd *pwent, + struct display *d) +{ + DBusConnection *connection; + DBusError error; + DBusMessage *message; + DBusMessage *reply; + DBusMessageIter iter; + DBusMessageIter iter_struct; + char *cookie; + + cookie = NULL; + + if (pwent == NULL) { + Debug ("ConsoleKit: NULL user passed as parameter"); + return NULL; + } + + Debug ("ConsoleKit: Opening session for %s", pwent->pw_name); + + dbus_error_init (&error); + connection = dbus_bus_get_private (DBUS_BUS_SYSTEM, &error); + private_connection = connection; + + if (connection == NULL) { + Debug ("ConsoleKit: Failed to connect to the D-Bus daemon: %s", error.message); + dbus_error_free (&error); + return NULL; + } + + dbus_connection_set_exit_on_disconnect (connection, FALSE); + /* FIXME: What to do about these? + dbus_connection_set_watch_functions( connection, + dbusAddWatch, + dbusRemoveWatch, + dbusToggleWatch, + data, 0 ); + dbus_connection_set_timeout_functions( connection, + dbusAddTimeout, + dbusRemoveTimeout, + dbusToggleTimeout, + data, 0 ); + dbus_connection_set_wakeup_main_function( connection, + dbusWakeupMain, + data, 0 ); */ + + dbus_error_init (&error); + message = dbus_message_new_method_call (CK_NAME, + CK_MANAGER_PATH, + CK_MANAGER_INTERFACE, + "OpenSessionWithParameters"); + if (message == NULL) { + Debug ("ConsoleKit: Couldn't allocate the D-Bus message"); + return NULL; + } + + dbus_message_iter_init_append (message, &iter); + dbus_message_iter_open_container (&iter, + DBUS_TYPE_ARRAY, + DBUS_STRUCT_BEGIN_CHAR_AS_STRING + DBUS_TYPE_STRING_AS_STRING + DBUS_TYPE_VARIANT_AS_STRING + DBUS_STRUCT_END_CHAR_AS_STRING, + &iter_struct); + + add_param_int (&iter_struct, "user", pwent->pw_uid); + add_param_string (&iter_struct, "x11-display", d->name); + add_param_boolean (&iter_struct, "is-local", ((d->displayType & d_location) == dLocal)); +#ifdef XDMCP + if ((d->displayType & d_location) != dLocal) { + add_param_string (&iter_struct, "remote-host-name", d->remoteHost); + } +#endif + +#ifdef HAVE_VTS + if (d->serverVT > 0) { + char device[20]; + + /* FIXME: how does xorg construct this */ + sprintf(device, "/dev/tty%d", d->serverVT); + add_param_string (&iter_struct, "x11-display-device", device); + } +#endif + + dbus_message_iter_close_container (&iter, &iter_struct); + + reply = dbus_connection_send_with_reply_and_block (connection, + message, + -1, &error); + if (dbus_error_is_set (&error)) { + Debug ("ConsoleKit: %s raised:\n %s\n\n", error.name, error.message); + reply = NULL; + } + + dbus_connection_flush (connection); + + dbus_message_unref (message); + dbus_error_free (&error); + + if (reply != NULL) { + const char *value; + + dbus_message_iter_init (reply, &iter); + dbus_message_iter_get_basic (&iter, &value); + cookie = strdup (value); + dbus_message_unref (reply); + } + + return cookie; +} + +void +close_ck_session (const char *cookie) +{ + DBusError error; + DBusMessage *message; + DBusMessage *reply; + DBusMessageIter iter; + + if (cookie == NULL) { + return; + } + + if (private_connection == NULL) { + return; + } + + dbus_error_init (&error); + message = dbus_message_new_method_call (CK_NAME, + CK_MANAGER_PATH, + CK_MANAGER_INTERFACE, + "CloseSession"); + if (message == NULL) { + Debug ("ConsoleKit: Couldn't allocate the D-Bus message"); + return; + } + + dbus_message_iter_init_append (message, &iter); + dbus_message_iter_append_basic (&iter, + DBUS_TYPE_STRING, + &cookie); + + reply = dbus_connection_send_with_reply_and_block (private_connection, + message, + -1, &error); + if (dbus_error_is_set (&error)) { + Debug ("ConsoleKit: %s raised:\n %s\n\n", error.name, error.message); + reply = NULL; + } + + dbus_connection_flush (private_connection); + + dbus_message_unref (message); + dbus_error_free (&error); + + dbus_connection_close (private_connection); + private_connection = NULL; +} diff --git a/kdm/backend/consolekit.h b/kdm/backend/consolekit.h new file mode 100644 index 000000000..f1cbddb54 --- /dev/null +++ b/kdm/backend/consolekit.h @@ -0,0 +1,36 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Copyright (C) 2006 William Jon McCann <[email protected]> + * Copyright (C) 2007 Kevin Kofler <[email protected]> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * + */ + + +#ifndef __CONSOLE_KIT_H +#define __CONSOLE_KIT_H + +#include <pwd.h> + +struct display; + +char * open_ck_session (struct passwd *pwent, + struct display *display); +void close_ck_session (const char *cookie); +void unlock_ck_session (const char *user, + const char *x11_display); + +#endif /* __CONSOLE_KIT_H */ diff --git a/kdm/backend/dm.c b/kdm/backend/dm.c index e696a1a5e..a372686df 100644 --- a/kdm/backend/dm.c +++ b/kdm/backend/dm.c @@ -39,6 +39,7 @@ from the copyright holder. #include "dm_error.h" #include <stdio.h> +#include <stdlib.h> #include <string.h> #include <unistd.h> #include <stdarg.h> @@ -122,7 +123,8 @@ main( int argc, char **argv ) StrApp( &progpath, directory, "/", argv[0], (char *)0 ); else { int len; - char *path, *pathe, *name, *thenam, nambuf[PATH_MAX+1]; + char *path, *name, *thenam, nambuf[PATH_MAX+1]; + char *pathe; if (!(path = getenv( "PATH" ))) Panic( "Can't find myself (no PATH)" ); @@ -131,7 +133,7 @@ main( int argc, char **argv ) memcpy( name, argv[0], len + 1 ); *--name = '/'; do { - if (!(pathe = strchr( path, ':' ))) + if (!(pathe = (char*)strchr( path, ':' ))) pathe = path + strlen( path ); len = pathe - path; if (!len || (len == 1 && *path == '.')) { @@ -564,6 +566,21 @@ StartRemoteLogin( struct display *d ) Debug( "exec %\"[s\n", argv ); (void)execv( argv[0], argv ); LogError( "X server %\"s cannot be executed\n", argv[0] ); + + /* Let's try again with some standard paths */ + argv[0] = (char *)realloc(argv[0], strlen("/usr/X11R6/bin/X") + 1); + if (argv[0] != NULL) { + argv[0] = "/usr/X11R6/bin/X"; + Debug( "exec %\"[s\n", argv ); + (void)execv( argv[0], argv ); + LogError( "X server %\"s cannot be executed\n", argv[0] ); + + argv[0] = "/usr/bin/X"; /* Shorter than the previous file name */ + Debug( "exec %\"[s\n", argv ); + (void)execv( argv[0], argv ); + LogError( "X server %\"s cannot be executed\n", argv[0] ); + } + exit( 1 ); case -1: LogError( "Forking X server for remote login failed: %m" ); diff --git a/kdm/backend/dm.h b/kdm/backend/dm.h index 6d2f59768..664d2cf1a 100644 --- a/kdm/backend/dm.h +++ b/kdm/backend/dm.h @@ -37,6 +37,8 @@ from the copyright holder. #ifndef _DM_H_ #define _DM_H_ 1 +#define WITH_CONSOLE_KIT + #include "greet.h" #include <config.ci> @@ -476,7 +478,11 @@ char **GRecvArgv( void ); #define GCONV_BINARY 5 typedef char *(*GConvFunc)( int what, const char *prompt ); int Verify( GConvFunc gconv, int rootok ); +#ifdef WITH_CONSOLE_KIT +int StartClient( const char *ck_session_cookie ); +#else int StartClient( void ); +#endif void SessionExit( int status ) ATTR_NORETURN; int ReadDmrc( void ); extern char **userEnviron, **systemEnviron; diff --git a/kdm/backend/process.c b/kdm/backend/process.c index 30dca096d..8e21d789b 100644 --- a/kdm/backend/process.c +++ b/kdm/backend/process.c @@ -264,7 +264,8 @@ char * locate( const char *exe ) { int len; - char *path, *pathe, *name, *thenam, nambuf[PATH_MAX+1]; + char *path, *name, *thenam, nambuf[PATH_MAX+1]; + char *pathe; if (!(path = getenv( "PATH" ))) { LogError( "Can't execute %'s: $PATH not set.\n", exe ); @@ -275,7 +276,7 @@ locate( const char *exe ) memcpy( name, exe, len + 1 ); *--name = '/'; do { - if (!(pathe = strchr( path, ':' ))) + if (!(pathe = (char*)strchr( path, ':' ))) pathe = path + strlen( path ); len = pathe - path; if (len && !(len == 1 && *path == '.')) { diff --git a/kdm/backend/server.c b/kdm/backend/server.c index 129c8bfe1..e78d8a66c 100644 --- a/kdm/backend/server.c +++ b/kdm/backend/server.c @@ -41,6 +41,7 @@ from the copyright holder. #include <X11/Xlib.h> #include <stdio.h> +#include <stdlib.h> #include <signal.h> @@ -94,6 +95,21 @@ StartServerOnce( void ) (void)Signal( SIGUSR1, SIG_IGN ); (void)execv( argv[0], argv ); LogError( "X server %\"s cannot be executed\n", argv[0] ); + + /* Let's try again with some standard paths */ + argv[0] = (char *)realloc(argv[0], strlen("/usr/X11R6/bin/X") + 1); + if (argv[0] != NULL) { + argv[0] = "/usr/X11R6/bin/X"; + Debug( "exec %\"[s\n", argv ); + (void)execv( argv[0], argv ); + LogError( "X server %\"s cannot be executed\n", argv[0] ); + + argv[0] = "/usr/bin/X"; /* Shorter than the previous file name */ + Debug( "exec %\"[s\n", argv ); + (void)execv( argv[0], argv ); + LogError( "X server %\"s cannot be executed\n", argv[0] ); + } + exit( 47 ); case -1: LogError( "X server fork failed\n" ); diff --git a/kdm/backend/session.c b/kdm/backend/session.c index 72da0a820..9a12ce312 100644 --- a/kdm/backend/session.c +++ b/kdm/backend/session.c @@ -45,6 +45,10 @@ from the copyright holder. #include <ctype.h> #include <signal.h> +#ifdef WITH_CONSOLE_KIT +#include "consolekit.h" +#endif + struct display *td; const char *td_setup = "auto"; @@ -530,6 +534,10 @@ ManageSession( struct display *d ) int ex, cmd; volatile int clientPid = 0; volatile Time_t tdiff = 0; +#ifdef WITH_CONSOLE_KIT + char *ck_session_cookie; +#endif + td = d; Debug( "ManageSession %s\n", d->name ); @@ -626,7 +634,12 @@ ManageSession( struct display *d ) if (td_setup) SetupDisplay( td_setup ); +#ifdef WITH_CONSOLE_KIT + ck_session_cookie = open_ck_session (getpwnam(curuser), d); + if (!(clientPid = StartClient(ck_session_cookie))) { +#else if (!(clientPid = StartClient())) { +#endif LogError( "Client start failed\n" ); SessionExit( EX_NORMAL ); /* XXX maybe EX_REMANAGE_DPY? -- enable in dm.c! */ } @@ -648,6 +661,14 @@ ManageSession( struct display *d ) catchTerm( SIGTERM ); } } + +#ifdef WITH_CONSOLE_KIT + if (ck_session_cookie != NULL) { + close_ck_session (ck_session_cookie); + free (ck_session_cookie); + } +#endif + /* * Sometimes the Xsession somehow manages to exit before * a server crash is noticed - so we sleep a bit and wait diff --git a/kdm/backend/sessreg.c b/kdm/backend/sessreg.c index 03a46e992..e603ff4c6 100644 --- a/kdm/backend/sessreg.c +++ b/kdm/backend/sessreg.c @@ -102,7 +102,7 @@ crc32s( const unsigned char *str ) void sessreg( struct display *d, int pid, const char *user, int uid ) { - const char *dot, *colon; + char *dot, *colon; int left, clen; #ifdef BSD_UTMP FILE *ttys; @@ -134,7 +134,7 @@ sessreg( struct display *d, int pid, const char *user, int uid ) } ut_ent.ut_time = time( 0 ); - colon = strchr( d->name, ':' ); + colon = (char*)strchr( d->name, ':' ); clen = strlen( colon ); if (clen > (int)(sizeof(ut_ent.ut_line) - UTL_OFF) - 2) return; /* uhm, well ... */ @@ -175,7 +175,7 @@ sessreg( struct display *d, int pid, const char *user, int uid ) colon = d->name; left = 0; } else { - dot = strchr( d->name, '.' ); + dot = (char*)strchr( d->name, '.' ); if (dot && dot - d->name < left) { memcpy( ut_ent.ut_line + UTL_OFF, d->name, left - 1 ); ut_ent.ut_line[UTL_OFF + left - 1] = '~'; diff --git a/kdm/backend/util.c b/kdm/backend/util.c index a5358cd65..c3e9a520c 100644 --- a/kdm/backend/util.c +++ b/kdm/backend/util.c @@ -409,9 +409,10 @@ setEnv( char **e, const char *name, const char *value ) char ** putEnv( const char *string, char **env ) { - char *b, *n; + char *n; + char *b; - if (!(b = strchr( string, '=' ))) + if (!(b = (char*)strchr( string, '=' ))) return NULL; if (!StrNDup( &n, string, b - string )) return NULL; diff --git a/kdm/backend/xdmcp.c b/kdm/backend/xdmcp.c index 2925a6bbc..e82305f89 100644 --- a/kdm/backend/xdmcp.c +++ b/kdm/backend/xdmcp.c @@ -386,7 +386,8 @@ NetworkAddressToName( CARD16 connectionType, ARRAY8Ptr connectionAddress, ASPrintf( &name, "localhost:%d", displayNumber ); else { if (removeDomainname) { - char *localDot, *remoteDot; + char *remoteDot; + char *localDot; /* check for a common domain name. This * could reduce names by recognising common @@ -394,8 +395,8 @@ NetworkAddressToName( CARD16 connectionType, ARRAY8Ptr connectionAddress, * this is as useful, and will confuse more * people */ - if ((localDot = strchr( localhost, '.' )) && - (remoteDot = strchr( hostname, '.' ))) + if ((localDot = (char*)strchr( localhost, '.' )) && + (remoteDot = (char*)strchr( hostname, '.' ))) { /* smash the name in place; it won't * be needed later. @@ -924,6 +925,9 @@ manage( struct sockaddr *from, int fromlen, int length, int fd ) } d->clientAddr = clientAddress; d->connectionType = connectionType; + d->remoteHost = NetworkAddressToHostname (pdpy->connectionType, + &pdpy->connectionAddress); + XdmcpDisposeARRAY8( &clientPort ); if (pdpy->fileAuthorization) { d->authorizations = (Xauth **)Malloc( sizeof(Xauth *) ); @@ -1048,7 +1052,8 @@ NetworkAddressToHostname( CARD16 connectionType, ARRAY8Ptr connectionAddress ) #endif { struct hostent *he; - char *myDot, *name, *lname; + char *name, *lname; + char *myDot; int af_type; #if defined(IPv6) && defined(AF_INET6) char dotted[INET6_ADDRSTRLEN]; @@ -1094,7 +1099,7 @@ NetworkAddressToHostname( CARD16 connectionType, ARRAY8Ptr connectionAddress ) oki: if (StrDup( &name, he->h_name ) && !strchr( name, '.' ) && - (myDot = strchr( localHostname(), '.' ))) + (myDot = (char*)strchr( localHostname(), '.' ))) { if (ASPrintf( &lname, "%s%s", name, myDot )) { #if defined(IPv6) && defined(AF_INET6) diff --git a/kdm/config.def b/kdm/config.def index ae026ba52..f8d1f1c87 100644 --- a/kdm/config.def +++ b/kdm/config.def @@ -42,16 +42,16 @@ # define HALT_CMD "/usr/sbin/halt" # define REBOOT_CMD "/usr/sbin/reboot" #else -# define HALT_CMD "/sbin/halt" +# define HALT_CMD "/sbin/poweroff" # define REBOOT_CMD "/sbin/reboot" #endif #if defined(BSD) || defined(__linux__) -# define DEF_USER_PATH "/usr/local/bin:/usr/bin:/bin:" XBINDIR ":/usr/games" -# define DEF_SYSTEM_PATH "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:" XBINDIR +# define DEF_USER_PATH "/usr/local/bin:/opt/kde3/bin:/usr/bin:/bin:/opt/kde3/games:/usr/games" +# define DEF_SYSTEM_PATH "/usr/local/sbin:/usr/local/bin:/opt/kde3/sbin:/usr/sbin:/opt/kde3/bin:/usr/bin:/sbin:/bin" #else -# define DEF_USER_PATH "/usr/local/bin:/usr/bin:/bin:" XBINDIR ":/usr/games:/usr/ucb" -# define DEF_SYSTEM_PATH "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:" XBINDIR ":/etc:/usr/ucb" +# define DEF_USER_PATH "/usr/local/bin:/opt/kde3/bin:/usr/bin:/bin:/opt/kde3/games:/usr/games:/usr/ucb" +# define DEF_SYSTEM_PATH "/usr/local/sbin:/usr/local/bin:/opt/kde3/sbin:/usr/sbin:/opt/kde3/bin:/usr/bin:/sbin:/bin:/etc:/usr/ucb" #endif #if 0 /*def HASXDMAUTH*/ @@ -91,6 +91,12 @@ <kdmrc> &kdm; master configuration file _ + Please note: Settings in this file are sometimes ignored (overridden). + The default KDM startup script /etc/init.d/kdm looks in /etc/default/kdm.d + for theme-related settings which, if found, take precedence. The possibly + overridden settings are: UseBackground, BackgroundCfg, UseTheme, Theme. + See /usr/share/doc/kdm/README.Debian for details + _ Definition: the greeter is the login dialog, i.e., the part of &kdm; which the user sees. _ @@ -1355,7 +1361,7 @@ Description: This string is subject to word splitting. </para><para> The default is something reasonable for the system on which &kdm; was built, - like <command>/usr/X11R6/bin/X</command>. + like <command>/usr/bin/X</command>. Key: ServerArgsLocal Type: string @@ -1921,10 +1927,10 @@ Description: Key: SessionsDirs Type: list -Default: KDMDATA "/sessions" +Default: "/usr/share/xsessions,/var/lib/menu-xdg/xsessions,/usr/share/apps/kdm/sessions" User: core User: greeter-c -Instance: #*/"/etc/X11/sessions,/usr/share/xsessions" +Instance: #*/"/usr/share/xsessions,/var/lib/menu-xdg/xsessions,/usr/share/apps/kdm/sessions" Comment: The directories containing session type definitions in .desktop format. Description: @@ -1948,7 +1954,7 @@ Description: Key: UseSessReg Type: bool -Default: true +Default: false User: core Instance: #*/! Comment: @@ -2044,9 +2050,9 @@ Description: Key: GreetString Type: string -Default: "Welcome to %s at %n" +Default: "Welcome to Kubuntu at %n" User: greeter -Instance: #*/"K Desktop Environment (%n)" +Instance: #*/"Welcome to Kubuntu at %n" Comment: The headline in the greeter. The following character pairs are replaced: - %d -> current display @@ -2096,19 +2102,19 @@ Description: # This needs to come _in front_ of the font settings to be effective! Key: AntiAliasing Type: bool -Default: false +Default: true User: greeter -Instance: #*/! +Instance: */ Comment: & Description: Whether the fonts used in the greeter should be antialiased. Key: GreetFont Type: string -Default: "Serif,20,5,0,50,0" +Default: "Sans Serif,22,5,0,50,0" CDefault: "Serif,20,bold" User: greeter:font -Instance: #*/"Serif,20,5,0,50,0" +Instance: #*/"Sans Serif,22,5,0,50,0" Comment: & Description: The font for the greeter headline. @@ -2482,7 +2488,6 @@ Type: int Default: 0 User: greeter Instance: #*/ -Update: upd_forgingseed Comment: Random seed for forging saved session types, etc. of unknown users. This value should be random but constant across the login domain. @@ -2579,7 +2584,7 @@ Key: AllowClose Type: bool Default: true User: greeter -Instance: :*/false +Instance: :*/true Comment: & Description: Show the <guilabel>Restart X Server</guilabel>/<guilabel>Close Connection</guilabel> action in the greeter. @@ -2608,7 +2613,7 @@ Key: Theme Type: string Default: "" User: greeter -Instance: */KDMDATA "/themes/circles" +Instance: */ "@@@ToBeReplacedByDesktopBase@@@" Comment: & Description: The theme to use for the greeter. Can point to either a directory or an XML diff --git a/kdm/configure.in.in b/kdm/configure.in.in index 4f3ff82d7..4b6972178 100644 --- a/kdm/configure.in.in +++ b/kdm/configure.in.in @@ -11,10 +11,10 @@ AC_CACHE_VAL(kde_cv_defines_imake, [ cat > Imakefile <<'EOF'[ acimake: - @echo "XBINDIR=\"$(BINDIR)\" XLIBDIR=\"$(LIBDIR)\"" + @echo "XBINDIR=\"/usr/bin\" XLIBDIR=\"$(LIBDIR)\"" ]EOF - if $XMKMF >&5 2>&1 && test -f Makefile; then + if imake -I/usr/lib/X11/config -DTOPDIR=/etc/X11 -DCURDIR=. /etc/X11 >&5 2>&1 && test -f Makefile; then kde_cv_defines_imake=`${MAKE-make} acimake 2> /dev/null | grep -v "^make"` kde_cv_defines_imake_version=$imkv else @@ -240,4 +240,51 @@ if test "x$with_kdm_xconsole" = xyes; then AC_DEFINE(WITH_KDM_XCONSOLE, 1, [Build kdm with built-in xconsole]) fi +########### Check for DBus + + AC_MSG_CHECKING(for DBus) + + dbus_inc=NOTFOUND + dbus_lib=NOTFOUND + dbus=NOTFOUND + + search_incs="$kde_includes $kde_extra_includes /usr/include /usr/include/dbus-1.0 /usr/local/include /usr/local/include/dbus-1.0" + AC_FIND_FILE(dbus/dbus.h, $search_incs, dbus_incdir) + + search_incs_arch_deps="$kde_includes $kde_extra_includes /usr/lib$kdelibsuff/dbus-1.0/include /usr/local/lib$kdelibsuff/dbus-1.0/include" + AC_FIND_FILE(dbus/dbus-arch-deps.h, $search_incs_arch_deps, dbus_incdir_arch_deps) + + if test -r $dbus_incdir/dbus/dbus.h && test -r $dbus_incdir_arch_deps/dbus/dbus-arch-deps.h ; then + DBUS_INCS="-I$dbus_incdir -I$dbus_incdir_arch_deps" + dbus_inc=FOUND + fi + + search_libs="$kde_libraries $kde_extra_libs /usr/lib$kdelibsuff /usr/local/lib$kdelibsuff" + AC_FIND_FILE(libdbus-1.so, $search_libs, dbus_libdir) + + if test -r $dbus_libdir/libdbus-1.so ; then + DBUS_LIBS="-L$dbus_libdir -ldbus-1" + dbus_lib=FOUND + fi + + if test $dbus_inc != FOUND || test $dbus_lib != FOUND ; then + KDE_PKG_CHECK_MODULES( DBUS, "dbus-1", [ DBUS_INCS=$DBUS_CFLAGS; dbus_inc=FOUND; dbus_lib=FOUND; ] , AC_MSG_RESULT( Nothing found on PKG_CONFIG_PATH ) ) + fi + + dbus_bus_var=`pkg-config --variable=system_bus_default_address dbus-1 2>/dev/null` + if test -z "$dbus_bus_var"; then + dbus_bus_var="unix:path=/var/run/dbus/system_bus_socket" + fi + AC_DEFINE_UNQUOTED(DBUS_SYSTEM_BUS, "$dbus_bus_var", [Define the unix domain path for dbus system bus]) + + if test $dbus_inc = FOUND && test $dbus_lib = FOUND ; then + AC_MSG_RESULT(headers $DBUS_INCS libraries $DBUS_LIBS) + dbus=FOUND + else + AC_MSG_RESULT(searched but not found) + fi + + AC_SUBST(DBUS_INCS) + AC_SUBST(DBUS_LIBS) + dnl AC_OUTPUT(kdm/kfrontend/sessions/kde.desktop) diff --git a/kdm/kfrontend/Makefile.am b/kdm/kfrontend/Makefile.am index 8f123509d..5c5dfd61a 100644 --- a/kdm/kfrontend/Makefile.am +++ b/kdm/kfrontend/Makefile.am @@ -1,5 +1,5 @@ # use 'make GENKDMCONF_FLAGS=... install' to override -GENKDMCONF_FLAGS = +GENKDMCONF_FLAGS = --no-old SUBDIRS = themer themes pics sessions diff --git a/kdm/kfrontend/genkdmconf.c b/kdm/kfrontend/genkdmconf.c index 5c0cb91e0..631561d17 100644 --- a/kdm/kfrontend/genkdmconf.c +++ b/kdm/kfrontend/genkdmconf.c @@ -322,7 +322,8 @@ static char * locate( const char *exe ) { int len; - char *path, *pathe, *name, *thenam, nambuf[PATH_MAX+1]; + char *path, *name, *thenam, nambuf[PATH_MAX+1]; + char *pathe; if (!(path = getenv( "PATH" ))) return 0; @@ -331,7 +332,7 @@ locate( const char *exe ) memcpy( name, exe, len + 1 ); *--name = '/'; do { - if (!(pathe = strchr( path, ':' ))) + if (!(pathe = (char*)strchr( path, ':' ))) pathe = path + strlen( path ); len = pathe - path; if (len && !(len == 1 && *path == '.')) { @@ -531,7 +532,7 @@ static const char def_xaccess[] = "# right hand sides can match.\n" "#\n" "\n" -"* #any host can get a login window\n" +"#* #any host can get a login window\n" "\n" "#\n" "# To hardwire a specific terminal to a specific host, you can\n" @@ -549,7 +550,7 @@ static const char def_xaccess[] = "# so this may not work in all environments.\n" "#\n" "\n" -"* CHOOSER BROADCAST #any indirect host can get a chooser\n" +"#* CHOOSER BROADCAST #any indirect host can get a chooser\n" "\n" "#\n" "# If you'd prefer to configure the set of hosts each terminal sees,\n" @@ -585,35 +586,25 @@ static const char def_startup[] = "#! /bin/sh\n" "# Xstartup - run as root before session starts\n" "\n" -"# By convention, both xconsole and xterm -C check that the\n" -"# console is owned by the invoking user and is readable before attaching\n" -"# the console output. This way a random user can invoke xterm -C without\n" -"# causing serious grief; still, it can cause havoc, so xconsole is started\n" -"# by Xsetup usually.\n" -"# This is not required if you use PAM with the pam_console module.\n" -"#\n" -"#chown $USER /dev/console\n" "\n" -#ifdef _AIX -"# We create a pseudodevice for finger. (host:0 becomes xdm/host_0)\n" -"# Without it, finger errors out with \"Can't stat /dev/host:0\".\n" -"#\n" -"#devname=`echo $DISPLAY | cut -c1-8`\n" -"#if [ ! -d /dev/xdm ]; then\n" -"# mkdir /dev/xdm\n" -"# chmod 755 /dev/xdm\n" -"#fi\n" -"#touch /dev/xdm/$devname\n" -"#chmod 644 /dev/xdm/$devname\n" -"#exec sessreg -a -l xdm/$devname -h \"`echo $DISPLAY | cut -d: -f1`\"" -#else -"#exec sessreg -a -l $DISPLAY -h \"`echo $DISPLAY | cut -d: -f1`\"" -# ifdef BSD -" -x " KDMCONF "/Xservers" -# endif -#endif /* _AIX */ -" $USER\n" -"\n# NOTE: The session is aborted if the last command returns non-zero.\n"; +"\n" +"if [ -e /etc/nologin ]; then\n" +" # always display the nologin message, if possible\n" +" if [ -s /etc/nologin ] && which xmessage > /dev/null 2>&1; then\n" +" xmessage -file /etc/nologin -geometry 640x480\n" +" fi\n" +" if [ \"$(id -u)\" != \"0\" ] && \\\n" +" ! grep -qs '^ignore-nologin' /etc/kde3/kdm/kdm.options; then\n" +" exit 1\n" +" fi\n" +"fi\n" +"\n" +"if grep -qs '^use-sessreg' /etc/kde3/kdm/kdm.options && \\\n" +" which sessreg > /dev/null 2>&1; then\n" +" exec sessreg -a -l \"$DISPLAY\" -u /var/run/utmp \\\n" +" -h \"`echo $DISPLAY | cut -d: -f1`\" \"$USER\"\n" +" # NOTREACHED\n" +"fi\n"; static const char def_reset[] = "#! /bin/sh\n" @@ -629,12 +620,13 @@ static const char def_reset[] = "#devname=`echo $DISPLAY | cut -c1-8`\n" "#exec sessreg -d -l xdm/$devname -h \"`echo $DISPLAY | cut -d: -f1`\"" #else -"#exec sessreg -d -l $DISPLAY -h \"`echo $DISPLAY | cut -d: -f1`\"" -# ifdef BSD -" -x " KDMCONF "/Xservers" -# endif +"if grep -qs '^use-sessreg' /etc/kde3/kdm/kdm.options && \\\n" +" which sessreg > /dev/null 2>&1; then\n" +" exec sessreg -d -l \"$DISPLAY\" -u /var/run/utmp \\\n" +" -h \"`echo $DISPLAY | cut -d: -f1`\" \"$USER\"\n" +" # NOTREACHED\n" +"fi\n"; #endif /* _AIX */ -" $USER\n"; static const char def_session1[] = "#! /bin/sh\n" @@ -666,6 +658,7 @@ static const char def_session1[] = " [ -f $zhome/.zprofile ] && . $zhome/.zprofile\n" " [ -f $zdir/zlogin ] && . $zdir/zlogin\n" " [ -f $zhome/.zlogin ] && . $zhome/.zlogin\n" +" setopt shwordsplit noextendedglob\n" " ;;\n" " */csh|*/tcsh)\n" " # [t]cshrc is always sourced automatically.\n" @@ -682,28 +675,8 @@ static const char def_session2[] = " [ -f $HOME/.profile ] && . $HOME/.profile\n" " ;;\n" "esac\n" -"\n" -"[ -f /etc/xprofile ] && . /etc/xprofile\n" -"[ -f $HOME/.xprofile ] && . $HOME/.xprofile\n" -"\n" -"case $session in\n" -" \"\")\n" -" exec xmessage -center -buttons OK:0 -default OK \"Sorry, $DESKTOP_SESSION is no valid session.\"\n" -" ;;\n" -" failsafe)\n" -" exec xterm -geometry 80x24-0-0\n" -" ;;\n" -" custom)\n" -" exec $HOME/.xsession\n" -" ;;\n" -" default)\n" -" exec " KDE_BINDIR "/startkde\n" -" ;;\n" -" *)\n" -" eval exec \"$session\"\n" -" ;;\n" -"esac\n" -"exec xmessage -center -buttons OK:0 -default OK \"Sorry, cannot execute $session. Check $DESKTOP_SESSION.desktop.\"\n"; +"# invoke global X session script\n" +". /etc/X11/Xsession\n"; static const char def_background[] = "[Desktop0]\n" @@ -978,29 +951,6 @@ getInitTab( void ) if (maxTTY) return; - if (readFile( &it, "/etc/inittab" )) { - usedFile( "/etc/inittab" ); - for (p = it.buf; p < it.eof; p = eol + 1) { - for (eol = p; eol < it.eof && *eol != '\n'; eol++); - if (*p != '#') { - if ((ep = mem_mem( p, eol - p, " tty", 4 )) && - ep < eol && isdigit( *ep )) - { - if (ep + 1 == eol || isspace( *(ep + 1) )) - tty = *ep - '0'; - else if (isdigit( *(ep + 1) ) && - (ep + 2 == eol || isspace( *(ep + 2) ))) - tty = (*ep - '0') * 10 + (*(ep + 1) - '0'); - else - continue; - TTYmask |= 1 << (tty - 1); - if (tty > maxTTY) - maxTTY = tty; - } - } - } - freeBuf( &it ); - } if (!maxTTY) { maxTTY = 6; TTYmask = 0x3f; @@ -1390,12 +1340,12 @@ mk_xaccess( Entry *ce, Section *cs ATTR_UNUSED ) static void mk_willing( Entry *ce, Section *cs ATTR_UNUSED ) { - const char *fname; + char *fname; if (!ce->active) /* there is only the Global one */ goto dflt; else { - if (!(fname = strchr( ce->value, '/' ))) + if (!(fname = (char*)strchr( ce->value, '/' ))) return; /* obviously in-line (or empty) */ if (old_scripts || inNewDir( fname )) dlinkfile( fname ); diff --git a/kdm/kfrontend/kdmctl.c b/kdm/kfrontend/kdmctl.c index 72e133162..82a12e653 100644 --- a/kdm/kfrontend/kdmctl.c +++ b/kdm/kfrontend/kdmctl.c @@ -219,7 +219,7 @@ main( int argc, char **argv ) fprintf( stderr, "Cannot create UNIX socket\n" ); return 1; } - if (dpy && (ptr = strchr( dpy, ':' )) && (ptr = strchr( ptr, '.' ))) + if (dpy && (ptr = (char*)strchr( dpy, ':' )) && (ptr = (char*)strchr( ptr, '.' ))) *ptr = 0; if (ctl && *ctl) { if (!openctl( fd, 1, ctl, dpy )) diff --git a/kdm/kfrontend/kdmshutdown.cpp b/kdm/kfrontend/kdmshutdown.cpp index dfd8558e2..74f62550e 100644 --- a/kdm/kfrontend/kdmshutdown.cpp +++ b/kdm/kfrontend/kdmshutdown.cpp @@ -34,6 +34,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include <kdialog.h> #include <kstandarddirs.h> #include <kuser.h> +#include <kconfig.h> +#include <kiconloader.h> #include <qcombobox.h> #include <qvbuttongroup.h> @@ -48,6 +50,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include <qlistview.h> #include <qheader.h> #include <qdatetime.h> +#include <qregexp.h> #define KDmh KDialog::marginHint() #define KDsh KDialog::spacingHint() @@ -459,76 +462,152 @@ void KDMDelayedPushButton::slotTimeout() setDown( false ); } - KDMSlimShutdown::KDMSlimShutdown( QWidget *_parent ) : inherited( _parent ) , targetList( 0 ) { - QHBoxLayout *hbox = new QHBoxLayout( this, KDmh, KDsh ); - - QFrame *lfrm = new QFrame( this ); - lfrm->setFrameStyle( QFrame::Panel | QFrame::Sunken ); - hbox->addWidget( lfrm, AlignCenter ); - QLabel *icon = new QLabel( lfrm ); - icon->setPixmap( QPixmap( locate( "data", "kdm/pics/shutdown.jpg" ) ) ); - QVBoxLayout *iconlay = new QVBoxLayout( lfrm ); - iconlay->addWidget( icon ); - - QVBoxLayout *buttonlay = new QVBoxLayout( hbox, KDsh ); - - buttonlay->addStretch( 1 ); - - KPushButton *btnHalt = new - KPushButton( KGuiItem( i18n("&Turn Off Computer"), "exit" ), this ); - buttonlay->addWidget( btnHalt ); - connect( btnHalt, SIGNAL(clicked()), SLOT(slotHalt()) ); - - buttonlay->addSpacing( KDialog::spacingHint() ); - KDMDelayedPushButton *btnReboot = new - KDMDelayedPushButton( KGuiItem( i18n("&Restart Computer"), "reload" ), this ); - buttonlay->addWidget( btnReboot ); - connect( btnReboot, SIGNAL(clicked()), SLOT(slotReboot()) ); + bool doUbuntuLogout = KConfigGroup(KGlobal::config(), "Shutdown").readBoolEntry("doUbuntuLogout", false); - GSet( 1 ); - GSendInt( G_ListBootOpts ); - if (GRecvInt() == BO_OK) { - targetList = GRecvStrArr( 0 ); - /*int def =*/ GRecvInt(); - int cur = GRecvInt(); - QPopupMenu *targets = new QPopupMenu( this ); - for (int i = 0; targetList[i]; i++) { - QString t( QString::fromLocal8Bit( targetList[i] ) ); - targets->insertItem( i == cur ? - i18n("current option in boot loader", - "%1 (current)").arg( t ) : - t, i ); + QVBoxLayout* vbox = new QVBoxLayout( this ); + QHBoxLayout *hbox = new QHBoxLayout( this, KDmh, KDsh ); + QFrame* lfrm = new QFrame( this ); + QHBoxLayout* hbuttonbox; + + if(doUbuntuLogout) + { + lfrm->setFrameStyle( QFrame::StyledPanel | QFrame::Raised ); + lfrm->setLineWidth( style().pixelMetric( QStyle::PM_DefaultFrameWidth, lfrm ) ); + // we need to set the minimum size for the logout box, since it + // gets too small if there isn't all options available + lfrm->setMinimumSize(300,120); + vbox->addWidget( lfrm ); + vbox = new QVBoxLayout( lfrm, 2 * KDialog::marginHint(), + 2 * KDialog::spacingHint() ); + + // first line of buttons + hbuttonbox = new QHBoxLayout( vbox, 8 * KDialog::spacingHint() ); + hbuttonbox->setAlignment( Qt::AlignHCenter ); + + // Reboot + FlatButton* btnReboot = new FlatButton( lfrm ); + btnReboot->setTextLabel( i18n("&Restart"), false ); + btnReboot->setPixmap( DesktopIcon( "reload") ); + int i = btnReboot->textLabel().find( QRegExp("\\&"), 0 ); // i == 1 + btnReboot->setAccel( "ALT+" + btnReboot->textLabel().lower()[i+1] ) ; + hbuttonbox->addWidget ( btnReboot); + connect(btnReboot, SIGNAL(clicked()), SLOT(slotReboot())); + + // Copied completely from the standard restart/shutdown dialog + GSet( 1 ); + GSendInt( G_ListBootOpts ); + if (GRecvInt() == BO_OK) { + targetList = GRecvStrArr( 0 ); + /*int def =*/ GRecvInt(); + int cur = GRecvInt(); + QPopupMenu *targets = new QPopupMenu( this ); + btnReboot->setPopupDelay(300); // visually add dropdown + for (int i = 0; targetList[i]; i++) { + QString t( QString::fromLocal8Bit( targetList[i] ) ); + targets->insertItem( i == cur ? + i18n("current option in boot loader", + "%1 (current)").arg( t ) : + t, i ); + } + btnReboot->setPopup( targets ); + connect( targets, SIGNAL(activated(int)), SLOT(slotReboot(int)) ); } - btnReboot->setPopup( targets ); - connect( targets, SIGNAL(activated(int)), SLOT(slotReboot(int)) ); + GSet( 0 ); + // Copied completely from the standard restart/shutdown dialog + + // Shutdown + FlatButton* btnHalt = new FlatButton( lfrm ); + btnHalt->setTextLabel( i18n("&Turn Off"), false ); + btnHalt->setPixmap( DesktopIcon( "exit") ); + i = btnHalt->textLabel().find( QRegExp("\\&"), 0 ); // i == 1 + btnHalt->setAccel( "ALT+" + btnHalt->textLabel().lower()[i+1] ) ; + hbuttonbox->addWidget ( btnHalt ); + connect(btnHalt, SIGNAL(clicked()), SLOT(slotHalt())); + + // cancel buttonbox + QHBoxLayout* hbuttonbox2 = new QHBoxLayout( vbox, 8 * KDialog::spacingHint() ); + hbuttonbox2->setAlignment( Qt::AlignRight ); + + // Back to kdm + KSMPushButton* btnBack = new KSMPushButton( KStdGuiItem::cancel(), lfrm ); + hbuttonbox2->addWidget( btnBack ); + connect(btnBack, SIGNAL(clicked()), SLOT(reject())); + + } - GSet( 0 ); - - buttonlay->addStretch( 1 ); - - if (_scheduledSd != SHUT_NEVER) { - KPushButton *btnSched = new - KPushButton( KGuiItem( i18n("&Schedule...") ), this ); - buttonlay->addWidget( btnSched ); - connect( btnSched, SIGNAL(clicked()), SLOT(slotSched()) ); - + else + { + lfrm->setFrameStyle( QFrame::Panel | QFrame::Sunken ); + hbox->addWidget( lfrm, AlignCenter ); + QLabel *icon = new QLabel( lfrm ); + icon->setPixmap( QPixmap( locate( "data", "kdm/pics/shutdown.jpg" ) ) ); + QVBoxLayout *iconlay = new QVBoxLayout( lfrm ); + iconlay->addWidget( icon ); + + QVBoxLayout *buttonlay = new QVBoxLayout( hbox, KDsh ); + + buttonlay->addStretch( 1 ); + + KPushButton *btnHalt = new + KPushButton( KGuiItem( i18n("&Turn Off Computer"), "exit" ), this ); + buttonlay->addWidget( btnHalt ); + connect( btnHalt, SIGNAL(clicked()), SLOT(slotHalt()) ); + + buttonlay->addSpacing( KDialog::spacingHint() ); + + KDMDelayedPushButton *btnReboot = new + KDMDelayedPushButton( KGuiItem( i18n("&Restart Computer"), "reload" ), this ); + buttonlay->addWidget( btnReboot ); + connect( btnReboot, SIGNAL(clicked()), SLOT(slotReboot()) ); + + GSet( 1 ); + GSendInt( G_ListBootOpts ); + if (GRecvInt() == BO_OK) { + targetList = GRecvStrArr( 0 ); + /*int def =*/ GRecvInt(); + int cur = GRecvInt(); + QPopupMenu *targets = new QPopupMenu( this ); + for (int i = 0; targetList[i]; i++) { + QString t( QString::fromLocal8Bit( targetList[i] ) ); + targets->insertItem( i == cur ? + i18n("current option in boot loader", + "%1 (current)").arg( t ) : + t, i ); + } + btnReboot->setPopup( targets ); + connect( targets, SIGNAL(activated(int)), SLOT(slotReboot(int)) ); + } + GSet( 0 ); + buttonlay->addStretch( 1 ); + + if (_scheduledSd != SHUT_NEVER) { + KPushButton *btnSched = new + KPushButton( KGuiItem( i18n("&Schedule...") ), this ); + buttonlay->addWidget( btnSched ); + connect( btnSched, SIGNAL(clicked()), SLOT(slotSched()) ); + + buttonlay->addStretch( 1 ); + } + + buttonlay->addWidget( new KSeparator( this ) ); + + buttonlay->addSpacing( 0 ); + + KPushButton *btnBack = new KPushButton( KStdGuiItem::cancel(), this ); + buttonlay->addWidget( btnBack ); + connect( btnBack, SIGNAL(clicked()), SLOT(reject()) ); + + buttonlay->addSpacing( KDialog::spacingHint() ); + + } - buttonlay->addWidget( new KSeparator( this ) ); - - buttonlay->addSpacing( 0 ); - - KPushButton *btnBack = new KPushButton( KStdGuiItem::cancel(), this ); - buttonlay->addWidget( btnBack ); - connect( btnBack, SIGNAL(clicked()), SLOT(reject()) ); - - buttonlay->addSpacing( KDialog::spacingHint() ); } KDMSlimShutdown::~KDMSlimShutdown() @@ -593,6 +672,129 @@ KDMSlimShutdown::externShutdown( int type, const char *os, int uid ) } +KSMPushButton::KSMPushButton( const KGuiItem &item, + QWidget *parent, + const char *name) + : KPushButton( item, parent, name), + m_pressed(false) +{ + setDefault( false ); + setAutoDefault ( false ); +} + +void KSMPushButton::keyPressEvent( QKeyEvent* e ) +{ + switch ( e->key() ) + { + case Key_Enter: + case Key_Return: + case Key_Space: + m_pressed = TRUE; + setDown(true); + emit pressed(); + break; + case Key_Escape: + e->ignore(); + break; + default: + e->ignore(); + } + + QPushButton::keyPressEvent(e); +} + + +void KSMPushButton::keyReleaseEvent( QKeyEvent* e ) +{ + switch ( e->key() ) + { + case Key_Space: + case Key_Enter: + case Key_Return: + if ( m_pressed ) + { + setDown(false); + m_pressed = FALSE; + emit released(); + emit clicked(); + } + break; + case Key_Escape: + e->ignore(); + break; + default: + e->ignore(); + + } +} + +FlatButton::FlatButton( QWidget *parent, const char *name ) + : QToolButton( parent, name/*, WNoAutoErase*/ ), + m_pressed(false) +{ + init(); +} + + +FlatButton::~FlatButton() {} + +void FlatButton::init() +{ + setUsesTextLabel(true); + setUsesBigPixmap(true); + setAutoRaise(true); + setTextPosition( QToolButton::Under ); + setFocusPolicy(QWidget::StrongFocus); + } + + +void FlatButton::keyPressEvent( QKeyEvent* e ) +{ + switch ( e->key() ) + { + case Key_Enter: + case Key_Return: + case Key_Space: + m_pressed = TRUE; + setDown(true); + emit pressed(); + break; + case Key_Escape: + e->ignore(); + break; + default: + e->ignore(); + } + + QToolButton::keyPressEvent(e); +} + +void FlatButton::keyReleaseEvent( QKeyEvent* e ) +{ + switch ( e->key() ) + { + case Key_Space: + case Key_Enter: + case Key_Return: + if ( m_pressed ) + { + setDown(false); + m_pressed = FALSE; + emit released(); + emit clicked(); + } + break; + case Key_Escape: + e->ignore(); + break; + default: + e->ignore(); + } + +} + + + KDMConfShutdown::KDMConfShutdown( int _uid, dpySpec *sess, int type, const char *os, QWidget *_parent ) : inherited( _uid, _parent ) diff --git a/kdm/kfrontend/kdmshutdown.h b/kdm/kfrontend/kdmshutdown.h index 9020b1513..98877fcbb 100644 --- a/kdm/kfrontend/kdmshutdown.h +++ b/kdm/kfrontend/kdmshutdown.h @@ -32,6 +32,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include <kpushbutton.h> #include <qradiobutton.h> +#include <qtoolbutton.h> +#include <qpixmap.h> class QLabel; class KPushButton; @@ -193,4 +195,46 @@ class KDMCancelShutdown : public KDMShutdownBase { const char *os, QWidget *_parent ); }; +class KSMPushButton : public KPushButton +{ + Q_OBJECT + +public: + + KSMPushButton( const KGuiItem &item, QWidget *parent, const char *name = 0 ); + +protected: + virtual void keyPressEvent(QKeyEvent*e); + virtual void keyReleaseEvent(QKeyEvent*e); + +private: + + bool m_pressed; + +}; + +class FlatButton : public QToolButton +{ + Q_OBJECT + + public: + + FlatButton( QWidget *parent = 0, const char *name = 0 ); + ~FlatButton(); + + protected: + virtual void keyPressEvent(QKeyEvent*e); + virtual void keyReleaseEvent(QKeyEvent*e); + + private slots: + + private: + void init(); + + bool m_pressed; + QString m_text; + QPixmap m_pixmap; + +}; + #endif /* KDMSHUTDOWN_H */ diff --git a/kdm/kfrontend/kgapp.cpp b/kdm/kfrontend/kgapp.cpp index 711853c37..a5bb667ef 100644 --- a/kdm/kfrontend/kgapp.cpp +++ b/kdm/kfrontend/kgapp.cpp @@ -38,6 +38,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include <ksimpleconfig.h> #include <qtimer.h> +#include <qstring.h> #include <qcursor.h> #include <qpalette.h> @@ -124,6 +125,8 @@ xIOErr( Display * ) exit( EX_RESERVER_DPY ); } +//KSimpleConfig *iccconfig; + void kg_main( const char *argv0 ) { @@ -141,6 +144,17 @@ kg_main( const char *argv0 ) if (!_GUIStyle.isEmpty()) app.setStyle( _GUIStyle ); + // Load up the systemwide ICC profile + QString iccConfigFile = QString(KDE_CONFDIR); + iccConfigFile += "/kicc/kiccconfigrc"; + KSimpleConfig iccconfig(iccConfigFile, true); + if (iccconfig.readBoolEntry("EnableICC", false) == true) { + QString iccCommand = QString("/usr/bin/xcalib "); + iccCommand += iccconfig.readEntry("ICCFile"); + iccCommand += QString(" &"); + system(iccCommand.ascii()); + } + _colorScheme = locate( "data", "kdisplay/color-schemes/" + _colorScheme + ".kcsrc" ); if (!_colorScheme.isEmpty()) { KSimpleConfig config( _colorScheme, true ); diff --git a/kdm/kfrontend/kgreeter.cpp b/kdm/kfrontend/kgreeter.cpp index 574f4e340..407b3d879 100644 --- a/kdm/kfrontend/kgreeter.cpp +++ b/kdm/kfrontend/kgreeter.cpp @@ -55,6 +55,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include <qpushbutton.h> #include <qtooltip.h> #include <qaccel.h> +#include <qstring.h> #include <qeventloop.h> #include <pwd.h> @@ -173,6 +174,13 @@ void KGreeter::insertUser( const QImage &default_pix, const QString &username, struct passwd *ps ) { + if (setegid( ps->pw_gid )) + return; + if (seteuid( ps->pw_uid )) { + setegid(0); + return; + } + if (userList) userList->append( username ); if (!userView) @@ -236,6 +244,9 @@ KGreeter::insertUser( const QImage &default_pix, realname.append( "\n" ).append( username ); new UserListViewItem( userView, realname, QPixmap( p ), username ); } + + seteuid( 0 ); + setegid( 0 ); } class KCStringList : public QValueList<QCString> { @@ -282,15 +293,8 @@ KGreeter::insertUsers() { struct passwd *ps; - // XXX remove seteuid-voodoo when we run as nobody if (!(ps = getpwnam( "nobody" ))) return; - if (setegid( ps->pw_gid )) - return; - if (seteuid( ps->pw_uid )) { - setegid(0); - return; - } QImage default_pix; if (userView) { @@ -354,17 +358,12 @@ KGreeter::insertUsers() if (userList) userList->sort(); } - - // XXX remove seteuid-voodoo when we run as nobody - seteuid( 0 ); - setegid( 0 ); } void KGreeter::putSession( const QString &type, const QString &name, bool hid, const char *exe ) { int prio = exe ? (!strcmp( exe, "default" ) ? 0 : - !strcmp( exe, "custom" ) ? 1 : !strcmp( exe, "failsafe" ) ? 3 : 2) : 2; for (uint i = 0; i < sessionTypes.size(); i++) if (sessionTypes[i].type == type) { @@ -392,7 +391,6 @@ KGreeter::insertSessions() } } putSession( "default", i18n("Default"), false, "default" ); - putSession( "custom", i18n("Custom"), false, "custom" ); putSession( "failsafe", i18n("Failsafe"), false, "failsafe" ); qBubbleSort( sessionTypes ); for (uint i = 0; i < sessionTypes.size() && !sessionTypes[i].hid; i++) { @@ -610,7 +608,6 @@ KGreeter::verifySetUser( const QString &user ) slotUserEntered(); } - KStdGreeter::KStdGreeter() : KGreeter() , clock( 0 ) diff --git a/kdm/kfrontend/sessions/kde.desktop.in b/kdm/kfrontend/sessions/kde.desktop.in index b032d395a..cf91472ae 100644 --- a/kdm/kfrontend/sessions/kde.desktop.in +++ b/kdm/kfrontend/sessions/kde.desktop.in @@ -3,7 +3,7 @@ Encoding=UTF-8 Type=XSession Exec=@KDE_BINDIR@/startkde TryExec=@KDE_BINDIR@/startkde -Name=KDE +Name=KDE3 Name[hi]=केडीई Name[mn]=КДЭ Name[ta]=Kஏற்றக் காவலன் diff --git a/kdm/kfrontend/sessions/matchbox.desktop b/kdm/kfrontend/sessions/matchbox.desktop index 8c6e2fd52..3bec343b0 100644 --- a/kdm/kfrontend/sessions/matchbox.desktop +++ b/kdm/kfrontend/sessions/matchbox.desktop @@ -1,7 +1,7 @@ [Desktop Entry] Type=XSession -Exec=matchbox -TryExec=matchbox +Exec=matchbox-window-manager +TryExec=matchbox-window-manager Name=Matchbox Name[bn]=ম্যাচবক্স Name[eo]=Alumetujo diff --git a/kdm/kfrontend/sessions/olvwm.desktop b/kdm/kfrontend/sessions/olvwm.desktop index e181331bc..23dee1169 100644 --- a/kdm/kfrontend/sessions/olvwm.desktop +++ b/kdm/kfrontend/sessions/olvwm.desktop @@ -1,7 +1,7 @@ [Desktop Entry] Type=XSession -Exec= -TryExec= +Exec=olvwm-x-window-manager +TryExec=olvwm-x-window-manager Name=OLVWM Name[br]=OVLWM Name[eo]=OLVFA diff --git a/kdm/kfrontend/sessions/olwm.desktop b/kdm/kfrontend/sessions/olwm.desktop index e3368af74..32612eaa3 100644 --- a/kdm/kfrontend/sessions/olwm.desktop +++ b/kdm/kfrontend/sessions/olwm.desktop @@ -1,7 +1,7 @@ [Desktop Entry] Type=XSession -Exec=olwm -TryExec=olwm +Exec=olwm-x-window-manager +TryExec=olwm-x-window-manager Name=OLWM Name[eo]=OLFA Name[hi]=ओएलडबल्यूएम diff --git a/kdm/kfrontend/sessions/pwm.desktop b/kdm/kfrontend/sessions/pwm.desktop index 036c9bff4..5d967c0c0 100644 --- a/kdm/kfrontend/sessions/pwm.desktop +++ b/kdm/kfrontend/sessions/pwm.desktop @@ -1,7 +1,7 @@ [Desktop Entry] Type=XSession -Exec=pwm -TryExec=pwm +Exec=pwm1 +TryExec=pwm1 Name=PWM Name[eo]=UnuFA Name[hi]=पीडबल्यूएम diff --git a/kdm/kfrontend/sessions/ude.desktop b/kdm/kfrontend/sessions/ude.desktop index fb451da1a..108a493e4 100644 --- a/kdm/kfrontend/sessions/ude.desktop +++ b/kdm/kfrontend/sessions/ude.desktop @@ -1,7 +1,7 @@ [Desktop Entry] Type=XSession -Exec=ude -TryExec=ude +Exec=uwm +TryExec=uwm Name=UDE Name[eo]=ULĈ Name[hi]=यूडीई |