diff options
author | William Jon McCann <mccann@jhu.edu> | 2007-10-04 21:42:29 +0000 |
---|---|---|
committer | William Jon McCann <mccann@src.gnome.org> | 2007-10-04 21:42:29 +0000 |
commit | 14333ef1ffc4d2c5b162d2631c52ab71d88a2641 (patch) | |
tree | 3035ae1a2d72a71eda144c7d8e2b91c35e837337 | |
parent | dae89542cc21cd03bb0debe651b3e30b84289478 (diff) | |
download | gdm-14333ef1ffc4d2c5b162d2631c52ab71d88a2641.tar.gz |
Remove lots of obsolete code. Organize the configure checks a bit.
2007-10-04 William Jon McCann <mccann@jhu.edu>
* common/Makefile.am:
* common/gdm-common.c:
* common/gdm-common.h:
* common/ve-signal.c:
* common/ve-signal.h:
* config/Makefile.am:
* configure.ac:
* daemon/Makefile.am:
* daemon/auth.c:
* daemon/filecheck.c:
* daemon/filecheck.h:
* daemon/gdm-factory-slave.c: (get_script_environment):
* daemon/gdm-greeter-session.c: (get_greeter_environment):
* daemon/gdm-product-slave.c: (get_script_environment):
* daemon/gdm-server.c: (rotate_logs), (server_child_setup),
(gdm_server_start):
* daemon/gdm-simple-slave.c: (get_script_environment):
* daemon/gdm-xdmcp-display-factory.c: (fd_set_close_on_exec),
(open_port), (gdm_xdmcp_handle_request), (gdm_xdmcp_handle_manage):
* libgreeter/Makefile.am:
* libgreeter/gdmlanguages.c:
* libgreeter/gdmlanguages.h:
* libgreeter/gdmsession.c:
* libgreeter/gdmsession.h:
* libgreeter/gdmwm.c:
* libgreeter/gdmwm.h:
* utils/Makefile.am:
* utils/gdm-ssh-session:
* utils/gdmmktemp.c:
* utils/gdmopen.c:
* utils/gdmprefetch.c:
* utils/gdmsetup-pam:
* utils/gdmsetup-security.in:
* utils/gdmtranslate.c:
Remove lots of obsolete code. Organize the configure checks a bit.
svn path=/branches/mccann-gobject/; revision=5339
35 files changed, 403 insertions, 5577 deletions
@@ -1,5 +1,43 @@ 2007-10-04 William Jon McCann <mccann@jhu.edu> + * common/Makefile.am: + * common/gdm-common.c: + * common/gdm-common.h: + * common/ve-signal.c: + * common/ve-signal.h: + * config/Makefile.am: + * configure.ac: + * daemon/Makefile.am: + * daemon/auth.c: + * daemon/filecheck.c: + * daemon/filecheck.h: + * daemon/gdm-factory-slave.c: (get_script_environment): + * daemon/gdm-greeter-session.c: (get_greeter_environment): + * daemon/gdm-product-slave.c: (get_script_environment): + * daemon/gdm-server.c: (rotate_logs), (server_child_setup), + (gdm_server_start): + * daemon/gdm-simple-slave.c: (get_script_environment): + * daemon/gdm-xdmcp-display-factory.c: (fd_set_close_on_exec), + (open_port), (gdm_xdmcp_handle_request), (gdm_xdmcp_handle_manage): + * libgreeter/Makefile.am: + * libgreeter/gdmlanguages.c: + * libgreeter/gdmlanguages.h: + * libgreeter/gdmsession.c: + * libgreeter/gdmsession.h: + * libgreeter/gdmwm.c: + * libgreeter/gdmwm.h: + * utils/Makefile.am: + * utils/gdm-ssh-session: + * utils/gdmmktemp.c: + * utils/gdmopen.c: + * utils/gdmprefetch.c: + * utils/gdmsetup-pam: + * utils/gdmsetup-security.in: + * utils/gdmtranslate.c: + Remove lots of obsolete code. Organize the configure checks a bit. + +2007-10-04 William Jon McCann <mccann@jhu.edu> + * acinclude.m4: * common/Makefile.am: * configure.ac: diff --git a/common/Makefile.am b/common/Makefile.am index 1d3afce1..ec14148e 100644 --- a/common/Makefile.am +++ b/common/Makefile.am @@ -70,8 +70,6 @@ libgdmcommon_la_SOURCES = \ gdm-md5.c \ gdm-signal-handler.h \ gdm-signal-handler.c \ - ve-signal.h \ - ve-signal.c \ $(NULL) libgdmcommon_la_CPPFLAGS = \ diff --git a/common/gdm-common.c b/common/gdm-common.c index 7ea3a488..d3e4fcd8 100644 --- a/common/gdm-common.c +++ b/common/gdm-common.c @@ -2,6 +2,7 @@ * * (c) 2000 Eazel, Inc. * (c) 2001,2002 George Lebl + * Copyright (C) 2007 William Jon McCann <mccann@jhu.edu> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -42,188 +43,6 @@ #include "gdm-common.h" #include "gdm-md5.h" -int -gdm_fdgetc (int fd) -{ - char buf[1]; - int bytes; - - VE_IGNORE_EINTR (bytes = read (fd, buf, 1)); - if (bytes != 1) - return EOF; - else - return (int)buf[0]; -} - -char * -gdm_fdgets (int fd) -{ - int c; - int bytes = 0; - GString *gs = g_string_new (NULL); - for (;;) { - c = gdm_fdgetc (fd); - if (c == '\n') - return g_string_free (gs, FALSE); - /* on EOF */ - if (c < 0) { - if (bytes == 0) { - g_string_free (gs, TRUE); - return NULL; - } else { - return g_string_free (gs, FALSE); - } - } else { - bytes++; - g_string_append_c (gs, c); - } - } -} - -void -gdm_fdprintf (int fd, const gchar *format, ...) -{ - va_list args; - gchar *s; - int written, len; - - va_start (args, format); - s = g_strdup_vprintf (format, args); - va_end (args); - - len = strlen (s); - - if (len == 0) { - g_free (s); - return; - } - - written = 0; - while (written < len) { - int w; - VE_IGNORE_EINTR (w = write (fd, &s[written], len - written)); - if (w < 0) - /* evil! */ - break; - written += w; - } - - g_free (s); -} - -void -gdm_close_all_descriptors (int from, int except, int except2) -{ - DIR *dir; - struct dirent *ent; - GSList *openfds = NULL; - - /* - * Evil, but less evil then going to _SC_OPEN_MAX - * which can be very VERY large - */ - dir = opendir ("/proc/self/fd/"); /* This is the Linux dir */ - if (dir == NULL) - dir = opendir ("/dev/fd/"); /* This is the FreeBSD dir */ - if G_LIKELY (dir != NULL) { - GSList *li; - while ((ent = readdir (dir)) != NULL) { - int fd; - if (ent->d_name[0] == '.') - continue; - fd = atoi (ent->d_name); - if (fd >= from && fd != except && fd != except2) - openfds = g_slist_prepend (openfds, GINT_TO_POINTER (fd)); - } - closedir (dir); - for (li = openfds; li != NULL; li = li->next) { - int fd = GPOINTER_TO_INT (li->data); - VE_IGNORE_EINTR (close (fd)); - } - g_slist_free (openfds); - } else { - int i; - int max = sysconf (_SC_OPEN_MAX); - /* - * Don't go higher then this. This is - * a safety measure to not hang on crazy - * systems - */ - if G_UNLIKELY (max > 4096) { - /* FIXME: warn about this perhaps */ - /* - * Try an open, in case we're really - * leaking fds somewhere badly, this - * should be very high - */ - i = gdm_open_dev_null (O_RDONLY); - max = MAX (i+1, 4096); - } - for (i = from; i < max; i++) { - if G_LIKELY (i != except && i != except2) - VE_IGNORE_EINTR (close (i)); - } - } -} - -void -gdm_signal_ignore (int signal) -{ - struct sigaction ign_signal; - - ign_signal.sa_handler = SIG_IGN; - ign_signal.sa_flags = SA_RESTART; - sigemptyset (&ign_signal.sa_mask); - - if G_UNLIKELY (sigaction (signal, &ign_signal, NULL) < 0) - g_warning (_("%s: Error setting signal %d to %s"), - "gdm_signal_ignore", signal, "SIG_IGN"); -} - -void -gdm_signal_default (int signal) -{ - struct sigaction def_signal; - - def_signal.sa_handler = SIG_DFL; - def_signal.sa_flags = SA_RESTART; - sigemptyset (&def_signal.sa_mask); - - if G_UNLIKELY (sigaction (signal, &def_signal, NULL) < 0) - g_warning (_("%s: Error setting signal %d to %s"), - "gdm_signal_ignore", signal, "SIG_DFL"); -} - -int -gdm_open_dev_null (mode_t mode) -{ - int ret; - VE_IGNORE_EINTR (ret = open ("/dev/null", mode)); - if G_UNLIKELY (ret < 0) { - /* - * Never output anything, we're likely in some - * strange state right now - */ - gdm_signal_ignore (SIGPIPE); - VE_IGNORE_EINTR (close (2)); - g_error ("Cannot open /dev/null, system on crack!"); - } - - return ret; -} - -char * -gdm_make_filename (const char *dir, - const char *name, - const char *extension) -{ - char *base = g_strconcat (name, extension, NULL); - char *full = g_build_filename (dir, base, NULL); - g_free (base); - return full; -} - - static int sigchld_blocked = 0; static sigset_t sigchldblock_mask, sigchldblock_oldmask; @@ -317,80 +136,33 @@ gdm_sigusr2_block_pop (void) /* Like fopen with "w" */ FILE * -gdm_safe_fopen_w (const char *file, mode_t perm) +gdm_safe_fopen_w (const char *file, + mode_t perm) { int fd; FILE *ret; VE_IGNORE_EINTR (g_unlink (file)); do { + int flags; + errno = 0; - fd = open (file, O_EXCL|O_CREAT|O_TRUNC|O_WRONLY + flags = O_EXCL | O_CREAT | O_TRUNC | O_WRONLY; #ifdef O_NOCTTY - |O_NOCTTY + flags |= O_NOCTTY; #endif #ifdef O_NOFOLLOW - |O_NOFOLLOW + flags |= O_NOFOLLOW; #endif - , perm); - } while G_UNLIKELY (errno == EINTR); - if (fd < 0) - return NULL; - VE_IGNORE_EINTR (ret = fdopen (fd, "w")); - return ret; -} -/* Like fopen with "a+" */ -FILE * -gdm_safe_fopen_ap (const char *file, mode_t perm) -{ - int fd; - FILE *ret; + fd = g_open (file, flags, perm); + } while (errno == EINTR); - if (g_access (file, F_OK) == 0) { - do { - errno = 0; - fd = open (file, O_APPEND|O_RDWR -#ifdef O_NOCTTY - |O_NOCTTY -#endif -#ifdef O_NOFOLLOW - |O_NOFOLLOW -#endif - ); - } while G_UNLIKELY (errno == EINTR); - } else { - /* Doesn't exist, open with O_EXCL */ - do { - errno = 0; - fd = open (file, O_EXCL|O_CREAT|O_RDWR -#ifdef O_NOCTTY - |O_NOCTTY -#endif -#ifdef O_NOFOLLOW - |O_NOFOLLOW -#endif - , perm); - } while G_UNLIKELY (errno == EINTR); - } - if (fd < 0) + if (fd < 0) { return NULL; - VE_IGNORE_EINTR (ret = fdopen (fd, "a+")); - return ret; -} - -void -gdm_fd_set_close_on_exec (int fd) -{ - int flags; - - flags = fcntl (fd, F_GETFD, 0); - if (flags < 0) { - return; } - flags |= FD_CLOEXEC; - - fcntl (fd, F_SETFD, flags); + ret = fdopen (fd, "w"); + return ret; } /** @@ -420,151 +192,7 @@ ve_clearenv (void) #endif } -char * -ve_first_word (const char *s) -{ - int argc; - char **argv; - char *ret; - - if (s == NULL) - return NULL; - - if ( ! g_shell_parse_argv (s, &argc, &argv, NULL)) { - char *p; - ret = g_strdup (s); - p = strchr (ret, ' '); - if (p != NULL) - *p = '\0'; - return ret; - } - - ret = g_strdup (argv[0]); - - g_strfreev (argv); - - return ret; -} - -static gboolean -ve_first_word_executable (const char *s, - gboolean only_existance) -{ - char *bin = ve_first_word (s); - if (bin == NULL) - return FALSE; - if (g_access (bin, only_existance ? F_OK : X_OK) == 0) { - g_free (bin); - return TRUE; - } else { - g_free (bin); - return FALSE; - } -} - -char * -ve_get_first_working_command (const char *list, - gboolean only_existance) -{ - int i; - char **vector; - char *ret = NULL; - - if (list == NULL) - return NULL; - - vector = g_strsplit (list, ";", -1); - for (i = 0; vector[i] != NULL; i++) { - if (ve_first_word_executable (vector[i], - only_existance)) { - ret = g_strdup (vector[i]); - break; - } - } - g_strfreev (vector); - return ret; -} - -char * -ve_locale_to_utf8 (const char *str) -{ - char *ret = g_locale_to_utf8 (str, -1, NULL, NULL, NULL); - - if (ret == NULL) { - g_warning ("string not in proper locale encoding: \"%s\"", str); - return g_strdup (str); - } else { - return ret; - } -} - -char * -ve_locale_from_utf8 (const char *str) -{ - char *ret = g_locale_from_utf8 (str, -1, NULL, NULL, NULL); - - if (ret == NULL) { - g_warning ("string not in proper utf8 encoding: \"%s\"", str); - return g_strdup (str); - } else { - return ret; - } -} - -char * -ve_filename_to_utf8 (const char *str) -{ - char *ret = g_filename_to_utf8 (str, -1, NULL, NULL, NULL); - if (ret == NULL) { - g_warning ("string not in proper locale encoding: \"%s\"", str); - return g_strdup (str); - } else { - return ret; - } -} - -char * -ve_filename_from_utf8 (const char *str) -{ - char *ret = g_filename_from_utf8 (str, -1, NULL, NULL, NULL); - if (ret == NULL) { - g_warning ("string not in proper utf8 encoding: \"%s\"", str); - return g_strdup (str); - } else { - return ret; - } -} - -pid_t -ve_waitpid_no_signal (pid_t pid, int *status, int options) -{ - pid_t ret; - - for (;;) { - ret = waitpid (pid, status, options); - if (ret == 0) - return 0; - if (errno != EINTR) - return ret; - } -} - -gboolean -ve_locale_exists (const char *loc) -{ - gboolean ret; - char *old = g_strdup (setlocale (LC_MESSAGES, NULL)); - if (setlocale (LC_MESSAGES, loc) != NULL) - ret = TRUE; - else - ret = FALSE; - setlocale (LC_MESSAGES, old); - g_free (old); - return ret; -} - /* hex conversion adapted from D-Bus */ - /** * Appends a two-character hex digit to a string, where the hex digit * has the value of the given byte. diff --git a/common/gdm-common.h b/common/gdm-common.h index 83c26f7a..1a62641a 100644 --- a/common/gdm-common.h +++ b/common/gdm-common.h @@ -2,6 +2,7 @@ * * (c) 2000 Eazel, Inc. * (c) 2001,2002 George Lebl + * Copyright (C) 2007 William Jon McCann <mccann@jhu.edu> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -28,16 +29,9 @@ #include <errno.h> #include <sys/types.h> #include <sys/wait.h> -#include <sys/socket.h> -#include <locale.h> -#include <netdb.h> - -#include "ve-signal.h" G_BEGIN_DECLS -#define ve_string_empty(x) ((x)==NULL||(x)[0]=='\0') -#define ve_sure_string(x) ((x)!=NULL?(x):"") #define VE_IGNORE_EINTR(expr) \ do { \ errno = 0; \ @@ -78,9 +72,6 @@ G_BEGIN_DECLS /* like fopen with "w" but unlinks and uses O_EXCL */ FILE * gdm_safe_fopen_w (const char *file, mode_t perm); -/* like fopen with "a+" and uses O_EXCL and O_NOFOLLOW */ -FILE * gdm_safe_fopen_ap (const char *file, - mode_t perm); /* This is for race free forks */ void gdm_sigchld_block_push (void); @@ -90,48 +81,7 @@ void gdm_sigterm_block_pop (void); void gdm_sigusr2_block_push (void); void gdm_sigusr2_block_pop (void); -void gdm_fdprintf (int fd, const gchar *format, ...) G_GNUC_PRINTF (2, 3); -int gdm_fdgetc (int fd); -char *gdm_fdgets (int fd); -void gdm_fd_set_close_on_exec (int fd); - - -void gdm_signal_ignore (int signal); -void gdm_signal_default (int signal); - -void gdm_close_all_descriptors (int from, int except, int except2); - -int gdm_open_dev_null (mode_t mode); - -/* somewhat like g_build_filename, but does somet hing like - * <dir> "/" <name> <extension> - */ -char * gdm_make_filename (const char *dir, - const char *name, - const char *extension); - void ve_clearenv (void); -char * ve_first_word (const char *s); - -/* Gets the first existing command out of a list separated by semicolons */ -char * ve_get_first_working_command (const char *list, - gboolean only_existance); - -/* These two functions will ALWAYS return a non-NULL string, - * if there is an error, they return the unconverted string */ -char * ve_locale_to_utf8 (const char *str); -char * ve_locale_from_utf8 (const char *str); - -/* These two functions will ALWAYS return a non-NULL string, - * if there is an error, they return the unconverted string */ -char * ve_filename_to_utf8 (const char *str); -char * ve_filename_from_utf8 (const char *str); - -/* function which doesn't stop on signals */ -pid_t ve_waitpid_no_signal (pid_t pid, int *status, int options); - -/* Testing for existance of a certain locale */ -gboolean ve_locale_exists (const char *loc); gboolean gdm_generate_random_bytes (GString *str, int n_bytes); diff --git a/common/ve-signal.c b/common/ve-signal.c deleted file mode 100644 index 2492b2ff..00000000 --- a/common/ve-signal.c +++ /dev/null @@ -1,160 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- - * - * Signal routines - * - * (c) 2000, 2002 Queen of England - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ -#include "config.h" - -#include <signal.h> -#include <stdlib.h> -#include <unistd.h> -#include <sys/types.h> -#include <sys/stat.h> - -#include <glib.h> -#include <glib/gi18n.h> - -#include "ve-signal.h" - -typedef struct _SignalSource SignalSource; -struct _SignalSource { - GSource source; - - int signal; - guint8 index; - guint8 shift; -}; - -static guint32 signals_notified[8] = { 0, 0, 0, 0, 0, 0, 0, 0 }; - -static gboolean -ve_signal_prepare (GSource *source, - int *timeout) -{ - SignalSource *ss = (SignalSource *)source; - - return signals_notified[ss->index] & (1 << ss->shift); -} - -static gboolean -ve_signal_check (GSource *source) -{ - SignalSource *ss = (SignalSource *)source; - - return signals_notified[ss->index] & (1 << ss->shift); -} - -static gboolean -ve_signal_dispatch (GSource *source, - GSourceFunc callback, - gpointer user_data) -{ - SignalSource *ss = (SignalSource *)source; - - signals_notified[ss->index] &= ~(1 << ss->shift); - - return ((VeSignalFunc)callback) (ss->signal, user_data); -} - -static GSourceFuncs signal_funcs = { - ve_signal_prepare, - ve_signal_check, - ve_signal_dispatch -}; - -guint -ve_signal_add (int signal, - VeSignalFunc function, - gpointer data) -{ - return ve_signal_add_full (G_PRIORITY_DEFAULT, signal, function, data, NULL); -} - -guint -ve_signal_add_full (int priority, - int signal, - VeSignalFunc function, - gpointer data, - GDestroyNotify destroy) -{ - GSource *source; - SignalSource *ss; - guint s = 128 + signal; - - g_return_val_if_fail (function != NULL, 0); - - source = g_source_new (&signal_funcs, sizeof (SignalSource)); - ss = (SignalSource *)source; - - ss->signal = signal; - ss->index = s / 32; - ss->shift = s % 32; - - g_assert (ss->index < 8); - - g_source_set_priority (source, priority); - g_source_set_callback (source, (GSourceFunc)function, data, destroy); - g_source_set_can_recurse (source, TRUE); - - return g_source_attach (source, NULL); -} - -void -ve_signal_notify (int signal) -{ - guint index, shift; - guint s = 128 + signal; - - index = s / 32; - shift = s % 32; - - g_assert (index < 8); - - signals_notified[index] |= 1 << shift; - - g_main_context_wakeup (NULL); -} - -gboolean -ve_signal_was_notified (int signal) -{ - guint index, shift; - guint s = 128 + signal; - - index = s / 32; - shift = s % 32; - - g_assert (index < 8); - - return ((signals_notified[index]) & (1 << shift)) ? TRUE : FALSE; -} - -void -ve_signal_unnotify (int signal) -{ - guint index, shift; - guint s = 128 + signal; - - index = s / 32; - shift = s % 32; - - g_assert (index < 8); - - signals_notified[index] &= ~(1 << shift); -} diff --git a/common/ve-signal.h b/common/ve-signal.h deleted file mode 100644 index c98adcd7..00000000 --- a/common/ve-signal.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- - * - * Signal routines - * - * (c) 2000, 2002 Queen of England - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) any later version. - * - * This library 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 - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License along with this library; if not, write to the - * Free Software Foundation, Inc., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - */ - -#ifndef _VE_SIGNAL_H -#define _VE_SIGNAL_H - -#include <glib.h> - -typedef gboolean (*VeSignalFunc) (int signal, - gpointer data); -guint ve_signal_add (int signal, - VeSignalFunc function, - gpointer data); -guint ve_signal_add_full (int priority, - int signal, - VeSignalFunc function, - gpointer data, - GDestroyNotify destroy); -/* You must handle the signal notify yourself, you add - * this function as the signal notification function - * however */ -void ve_signal_notify (int signal); - -gboolean ve_signal_was_notified (int signal); -void ve_signal_unnotify (int signal); - -#endif /* _VE_CONFIG_H */ diff --git a/config/Makefile.am b/config/Makefile.am index f8782143..4179061c 100644 --- a/config/Makefile.am +++ b/config/Makefile.am @@ -1,3 +1,5 @@ +NULL = + pixmapdir = $(datadir)/pixmaps confdir = $(gdmconfdir) gdmlocaledir = $(gdmconfdir) @@ -11,30 +13,45 @@ predir = $(gdmconfdir)/PreSession postlogindir = $(gdmconfdir)/PostLogin # logdir is set by configure.ac -noinst_DATA = gdm.conf - -DESKTOP_FILES = default.desktop @SSHDESKTOP@ - -EXTRA_DIST = \ - gdm.conf.in \ - gdm.conf-custom.in \ - $(DESKTOP_FILES) \ - default.desktop.in \ - ssh.desktop.in.in \ - Xsession.in \ - gdm \ - gdm-autologin \ - locale.alias \ - Init.in \ - PreSession.in \ - PostSession.in \ - PostLogin \ - XKeepsCrashing \ - gettextfoo.h \ - gdmprefetchlist.in \ - extract-shell.sh - -CLEANFILES = Xsession gdm.conf gdm.conf-custom default.desktop ssh.desktop Init PreSession PostSession gdmprefetchlist +noinst_DATA = \ + gdm.conf \ + $(NULL) + +DESKTOP_FILES = \ + default.desktop \ + $(NULL) + +EXTRA_DIST = \ + gdm.conf.in \ + gdm.conf-custom.in \ + $(DESKTOP_FILES) \ + default.desktop.in \ + ssh.desktop.in.in \ + Xsession.in \ + gdm \ + gdm-autologin \ + locale.alias \ + Init.in \ + PreSession.in \ + PostSession.in \ + PostLogin \ + XKeepsCrashing \ + gettextfoo.h \ + gdmprefetchlist.in \ + extract-shell.sh \ + $(NULL) + +CLEANFILES = \ + Xsession \ + gdm.conf \ + gdm.conf-custom \ + default.desktop \ + ssh.desktop \ + Init \ + PreSession \ + PostSession \ + gdmprefetchlist \ + $(NULL) Xsession: $(srcdir)/Xsession.in sed -e 's,[@]XSESSION_SHELL[@],$(XSESSION_SHELL),g' \ diff --git a/configure.ac b/configure.ac index 97d07542..44f8219a 100644 --- a/configure.ac +++ b/configure.ac @@ -1,3 +1,4 @@ + AC_PREREQ(2.59c) AC_INIT([gdm], [2.99.0], @@ -5,8 +6,11 @@ AC_INIT([gdm], [gdm]) AC_CONFIG_SRCDIR([daemon/gdm-manager.c]) + AM_INIT_AUTOMAKE +AM_MAINTAINER_MODE + AC_ISC_POSIX AC_PROG_CC AC_STDC_HEADERS @@ -18,12 +22,21 @@ AC_SUBST(VERSION) AM_CONFIG_HEADER(config.h) AC_CONFIG_MACRO_DIR([m4]) -AM_MAINTAINER_MODE IT_PROG_INTLTOOL([0.35.0]) GNOME_DOC_INIT +GETTEXT_PACKAGE=gdm +AC_SUBST(GETTEXT_PACKAGE) +AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE") + +AM_GLIB_GNU_GETTEXT + +dnl --------------------------------------------------------------------------- +dnl - Dependencies +dnl --------------------------------------------------------------------------- + X11_REQUIRED_VERSION=1.0.0 DBUS_GLIB_REQUIRED_VERSION=0.74 GLIB_REQUIRED_VERSION=2.13.0 @@ -33,9 +46,61 @@ PANGO_REQUIRED_VERSION=1.3.0 LIBGLADE_REQUIRED_VERSION=1.99.2 SCROLLKEEPER_REQUIRED_VERSION=0.1.4 -dnl -dnl Let the user configure where to look for the configuration files. -dnl +EXTRA_COMPILE_WARNINGS(yes) + +PKG_CHECK_MODULES(COMMON, + dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION + gobject-2.0 >= $GLIB_REQUIRED_VERSION +) +AC_SUBST(COMMON_CFLAGS) +AC_SUBST(COMMON_LIBS) + +PKG_CHECK_MODULES(DAEMON, + dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION + gobject-2.0 >= $GLIB_REQUIRED_VERSION + x11 >= $X11_REQUIRED_VERSION +) +AC_SUBST(DAEMON_CFLAGS) +AC_SUBST(DAEMON_LIBS) + +PKG_CHECK_MODULES(GREETER, + dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION + gtk+-2.0 >= $GTK_REQUIRED_VERSION +) +AC_SUBST(GREETER_CFLAGS) +AC_SUBST(GREETER_LIBS) + +PKG_CHECK_MODULES(SIMPLE_GREETER, + dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION + gtk+-2.0 >= $GTK_REQUIRED_VERSION + libglade-2.0 >= $LIBGLADE_REQUIRED_VERSION + gnome-vfs-2.0 >= $GNOME_VFS_REQUIRED_VERSION +) +AC_SUBST(SIMPLE_GREETER_CFLAGS) +AC_SUBST(SIMPLE_GREETER_LIBS) + +PKG_CHECK_MODULES(CHOOSER, + dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION + gtk+-2.0 >= $GTK_REQUIRED_VERSION +) +AC_SUBST(CHOOSER_CFLAGS) +AC_SUBST(CHOOSER_LIBS) + +PKG_CHECK_MODULES(SIMPLE_CHOOSER, + dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION + gtk+-2.0 >= $GTK_REQUIRED_VERSION + libglade-2.0 >= $LIBGLADE_REQUIRED_VERSION + gnome-vfs-2.0 >= $GNOME_VFS_REQUIRED_VERSION +) +AC_SUBST(SIMPLE_CHOOSER_CFLAGS) +AC_SUBST(SIMPLE_CHOOSER_LIBS) + +AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal) +AC_PATH_XTRA + +dnl --------------------------------------------------------------------------- +dnl - Configuration file stuff +dnl --------------------------------------------------------------------------- AC_ARG_WITH(sysconfsubdir, AC_HELP_STRING([--with-sysconfsubdir], [directory name used under sysconfdir, default=gdm]), @@ -54,9 +119,10 @@ AC_ARG_WITH(dmconfdir, AC_HELP_STRING([--with-dmconfdir], dmconfdir=${withval}, dmconfdir=${sysconfdir}/dm) AC_SUBST(dmconfdir) -dnl -dnl Configure arguments -dnl +dnl --------------------------------------------------------------------------- +dnl - Configure arguments +dnl --------------------------------------------------------------------------- + AC_ARG_ENABLE(console-helper, [ --enable-console-helper=[auto/no/yes] Enable PAM console helper [default=auto]],, enable_console_helper=auto) @@ -128,22 +194,6 @@ else fi AC_SUBST(LANG_CONFIG_FILE) -AC_PATH_PROG(CONSOLE_HELPER,consolehelper,no) -if test "x$CONSOLE_HELPER" = "xno" ; then - if test "x$enable_console_helper" = "xyes" ; then - AC_MSG_ERROR(Console helper requested but consolehelper binary not found) - fi - # if it was no, nothing happens, if it was auto, well then we're out of luck - enable_console_helper=no -else - if test ! "x$enable_console_helper" = "xno" ; then - enable_console_helper=yes - fi -fi - -AC_PATH_PROG(GLIB_GENMARSHAL, glib-genmarshal) -AC_PATH_XTRA - dnl socklen_t may be declared, but not in a "standard" C header location AC_CHECK_HEADERS(sys/socket.h) AC_CHECK_TYPE(socklen_t,, @@ -160,72 +210,6 @@ dnl checks needed for Darwin compatibility to linux **environ. AC_CHECK_HEADERS(crt_externs.h) AC_CHECK_FUNCS(_NSGetEnviron) -EXTRA_COMPILE_WARNINGS(yes) - -PKG_CHECK_MODULES(COMMON, - dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION - gobject-2.0 >= $GLIB_REQUIRED_VERSION -) -AC_SUBST(COMMON_CFLAGS) -AC_SUBST(COMMON_LIBS) - -PKG_CHECK_MODULES(DAEMON, - dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION - gobject-2.0 >= $GLIB_REQUIRED_VERSION - x11 >= $X11_REQUIRED_VERSION -) -AC_SUBST(DAEMON_CFLAGS) -AC_SUBST(DAEMON_LIBS) - -PKG_CHECK_MODULES(GREETER, - dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION - gtk+-2.0 >= $GTK_REQUIRED_VERSION -) -AC_SUBST(GREETER_CFLAGS) -AC_SUBST(GREETER_LIBS) - -PKG_CHECK_MODULES(SIMPLE_GREETER, - dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION - gtk+-2.0 >= $GTK_REQUIRED_VERSION - libglade-2.0 >= $LIBGLADE_REQUIRED_VERSION - gnome-vfs-2.0 >= $GNOME_VFS_REQUIRED_VERSION -) -AC_SUBST(SIMPLE_GREETER_CFLAGS) -AC_SUBST(SIMPLE_GREETER_LIBS) - -PKG_CHECK_MODULES(CHOOSER, - dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION - gtk+-2.0 >= $GTK_REQUIRED_VERSION -) -AC_SUBST(CHOOSER_CFLAGS) -AC_SUBST(CHOOSER_LIBS) - -PKG_CHECK_MODULES(SIMPLE_CHOOSER, - dbus-glib-1 >= $DBUS_GLIB_REQUIRED_VERSION - gtk+-2.0 >= $GTK_REQUIRED_VERSION - libglade-2.0 >= $LIBGLADE_REQUIRED_VERSION - gnome-vfs-2.0 >= $GNOME_VFS_REQUIRED_VERSION -) -AC_SUBST(SIMPLE_CHOOSER_CFLAGS) -AC_SUBST(SIMPLE_CHOOSER_LIBS) - -dnl ========================================================================== - -dnl Allow users to run gdmsetup using the console helper PAM stuff. -if test "x$enable_console_helper" = "xyes"; then - AM_CONDITIONAL(CONSOLE_HELPER, true) -else - AM_CONDITIONAL(CONSOLE_HELPER, false) -fi - -dnl ## Language Support -GETTEXT_PACKAGE=gdm -AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE") -AC_SUBST(GETTEXT_PACKAGE) - -dnl ## internationalization support -AM_GLIB_GNU_GETTEXT - EXTRA_DAEMON_LIBS="" EXTRA_SLAVE_LIBS="" EXTRA_CHOOSER_LIBS="" @@ -259,9 +243,11 @@ AC_CHECK_FUNC(inet_aton,,[ AC_CHECK_LIB(resolv,inet_aton, [ EXTRA_CHOOSER_LIBS="$EXTRA_CHOOSER_LIBS -lresolv"])]) -dnl ***************************** -dnl IPv6 specific checks -dnl ***************************** + +dnl --------------------------------------------------------------------------- +dnl - Check for IPv6 +dnl --------------------------------------------------------------------------- + AC_MSG_CHECKING([whether to enable IPv6]) AC_ARG_ENABLE(ipv6, [ --enable-ipv6=[yes/no] Enables compilation of IPv6 code default=[no]],, enable_ipv6=no) if test x$enable_ipv6 = xyes; then @@ -306,25 +292,17 @@ else AC_MSG_RESULT(no) fi -dnl borrowed from gnu findutils -dnl and relicensed as LGPL by the FSF - -AC_ARG_WITH(prefetch, - [ --with-prefetch=[yes/no] Install GDM library prefetch utility [default=no]],, - with_prefetch=no) - -if test x$with_prefetch != xno ; then - GDMPREFETCH="gdmprefetch" - GDMPREFETCHLIST="gdmprefetchlist" - GDMPREFETCHCMD='${libdir}/gdmprefetch \@${gdmconfdir}/gdmprefetchlist' -fi - AC_ARG_WITH(afs, [ --with-afs support -fstype afs], [ AC_DEFINE(AFS, [], [Define if you have the Andrew File System]) CPPFLAGS="$CPPFLAGS -I/usr/afsws/include" LIBS="$LIBS -L/usr/afsws/lib -L/usr/afsws/lib/afs -lsys -lrx -llwp"]) + +dnl --------------------------------------------------------------------------- +dnl - Check for filesystem type support +dnl --------------------------------------------------------------------------- + AC_MSG_CHECKING(how to get filesystem type) fstype=no # The order of these tests is important. @@ -356,22 +334,11 @@ AC_TRY_CPP([#include <sys/mount.h> fi AC_MSG_RESULT($fstype) -dnl **************************** -dnl IPv6 checks end here -dnl **************************** - -dnl ## gdmopen building -dnl There are perhaps others where this works -GDMOPEN= -AC_CHECK_HEADERS(linux/vt.h, [ - GDMOPEN=gdmopen]) -AC_SUBST(GDMOPEN) dnl --------------------------------------------------------------------------- dnl - Check for PAM stuff dnl --------------------------------------------------------------------------- - dnl PAM prefix withval="" AC_ARG_WITH(pam-prefix, @@ -452,13 +419,16 @@ AC_CHECK_HEADERS(libgen.h, [ AC_DEFINE(HAVE_LIBGEN_H)]) -# +dnl --------------------------------------------------------------------------- +dnl - Check for POSIX version of getpwnam_r +dnl --------------------------------------------------------------------------- + # Checking for a posix version of getpwnam_r # if we are cross compiling and can not run the test # assume getpwnam_r is the posix version # it is up to the person cross compiling to change # this behavior if desired -# + AC_LANG_PUSH(C) AC_CACHE_CHECK([for posix getpwnam_r], ac_cv_func_posix_getpwnam_r, @@ -502,9 +472,11 @@ else fi fi -# -# Check for utmp stuff -# + +dnl --------------------------------------------------------------------------- +dnl - Check for utmp stuff +dnl --------------------------------------------------------------------------- + AC_CHECK_HEADERS(utmp.h utmpx.h libutil.h sys/param.h) AC_CHECK_FUNC(getutmpx updwtmpx) AC_CHECK_LIB(util,login) @@ -525,9 +497,11 @@ if test x$have_ut_syslen = xyes; then fi AC_MSG_RESULT($have_ut_syslen) -# -# Xdmcp checking -# + +dnl --------------------------------------------------------------------------- +dnl - Check for Xdmcp +dnl --------------------------------------------------------------------------- + XDMCP_LIBS="" if test x$with_xdmcp != xno ; then xdmcp_save_CPPFLAGS="$CPPFLAGS" @@ -560,9 +534,11 @@ else fi AC_SUBST(GDMCHOOSER) -# -# TCP Wrappers for XDMCP access control -# + +dnl --------------------------------------------------------------------------- +dnl - Check for TCP Wrappers for XDMCP access control +dnl --------------------------------------------------------------------------- + if test x$with_tcp_wrappers = xno ; then echo "TCP wrappers disabled" else @@ -658,8 +634,10 @@ LIBS="$OLD_LIBS" esac fi -AC_MSG_CHECKING([for corrupt government]) -AC_MSG_RESULT(yes) + +dnl --------------------------------------------------------------------------- +dnl - Check for Xinput +dnl --------------------------------------------------------------------------- have_xinput= AC_CHECK_LIB(Xi, XOpenDevice, XINPUT_LIBS=-lXi) @@ -668,7 +646,7 @@ if test "x$XINPUT_LIBS" = x; then for xinputpath in $x_libraries /usr/X11R6/lib /usr/openwin/lib; do LIBS="-L$xinputpath -lXi" case "$host" in - *solaris*) XINPUT_RPATH_FLAGS="-R$xinputpath" + *solaris*) XINPUT_RPATH_FLAGS="-R$xinputpath" ;; esac AC_MSG_CHECKING(for -lXi in $xinputpath) @@ -688,9 +666,12 @@ if test "x$have_xinput" = xyes; then X_EXTRA_LIBS="$X_EXTRA_LIBS $XINPUT_LIBS" fi -# + +dnl --------------------------------------------------------------------------- +dnl - Check for Xinerama +dnl --------------------------------------------------------------------------- + # X11 Xinerama extension -# # Check for Xinerama extension (Solaris impl or Xfree impl) xinerama_save_cppflags="$CPPFLAGS" CPPFLAGS="$CPPFLAGS $X_CFLAGS" @@ -754,9 +735,11 @@ fi AC_SUBST(XINERAMA_LIBS) CPPFLAGS="$xinerama_save_cppflags" -# -# Distributed Multihead X extension (DMX) -# + +dnl --------------------------------------------------------------------------- +dnl - Check for Distributed Multihead X extension (DMX) +dnl --------------------------------------------------------------------------- + DMX_SUPPORT="" DMX_LIBS="" if test x$with_dmx != xno ; then @@ -776,9 +759,11 @@ fi AC_SUBST(DMX_LIBS) AM_CONDITIONAL(DMX_SUPPORT, test x$DMX_SUPPORT = xyes) -# -# Solaris Trusted Extensions stuff -# + +dnl --------------------------------------------------------------------------- +dnl - Check for Solaris Trusted Extensions stuff +dnl --------------------------------------------------------------------------- + case "$host" in *solaris*) AC_CHECK_HEADERS(sys/tsol/label_macro.h, @@ -794,9 +779,10 @@ if test "x$found_tsol" = "xyes" ; then fi -# -# SELinux stuff -# +dnl --------------------------------------------------------------------------- +dnl - Check for SELinux +dnl --------------------------------------------------------------------------- + if test "x$with_selinux" = "xyes" ; then echo "SELinux support requested (--with-selinux was given), checking prerequisites" if test -d /usr/local/selinux/include ; then @@ -819,7 +805,7 @@ if test "x$with_selinux" = "xyes" ; then fi dnl --------------------------------------------------------------------------- -dnl - ConsoleKit support +dnl - Check for ConsoleKit support dnl --------------------------------------------------------------------------- use_console_kit=no @@ -831,7 +817,7 @@ AM_CONDITIONAL(WITH_CONSOLE_KIT, test x$use_console_kit = xyes) AC_SUBST(WITH_CONSOLE_KIT) dnl --------------------------------------------------------------------------- -dnl - D-Bus +dnl - Check for D-Bus dnl --------------------------------------------------------------------------- dnl - Are we specifying a different dbus root ? @@ -849,7 +835,7 @@ fi AC_SUBST(DBUS_SYS_DIR) dnl --------------------------------------------------------------------------- -dnl - ISO Codes checks +dnl - Check for ISO Codes dnl --------------------------------------------------------------------------- AC_MSG_CHECKING([whether iso-codes has iso-639 domain]) @@ -861,9 +847,11 @@ fi AC_DEFINE_UNQUOTED([ISO_CODES_PREFIX],["`$PKG_CONFIG --variable=prefix iso-codes`"],[ISO codes prefix]) ISO_CODES=iso-codes -# -# Define some variables to represent the directories we use. -# + +dnl --------------------------------------------------------------------------- +dnl - Define some variables to represent the directories we use. +dnl --------------------------------------------------------------------------- + AC_SUBST(authdir, ${localstatedir}/gdm) AC_SUBST(gdmlocaledir, ${gdmconfdir}) AC_SUBST(pixmapdir, ${datadir}/pixmaps) @@ -914,58 +902,9 @@ fi AC_SUBST(GDM_CUSTOM_CONF) AC_SUBST(GDM_OLD_CONF, '${gdmconfdir}/gdm.conf') -AC_ARG_WITH(prefetch, - [ --with-prefetch=[yes/no] Install GDM library prefetch utility [default=no]],, - with_prefetch=no) - -if test x$with_prefetch != xno ; then - GDMPREFETCH="gdmprefetch" - GDMPREFETCHLIST="gdmprefetchlist" - GDMPREFETCHCMD='${libdir}/gdmprefetch \@${gdmconfdir}/gdmprefetchlist' -fi -AC_SUBST(GDMPREFETCH) -AC_SUBST(GDMPREFETCHLIST) -AC_SUBST(GDMPREFETCHCMD) - -AC_ARG_ENABLE(secureremote, - [ --enable-secureremote=[yes/no] Enable to offer a secure X connection through ssh [default=no]],, - enable_secureremote=no) - -AC_PATH_PROG(ZENITY,zenity,no) -if test "x$ZENITY" = "xno" ; then - if test "x$enable_secureremote" = "xyes" ; then - AC_MSG_ERROR(Secure remote connection requested but zenity binary not found) - fi - # if it was no, nothing happens, if it was auto, well then we're out of luck - enable_console_helper=no -else - if test ! "x$enable_secureremote" = "xno" ; then - enable_secureremote=yes - fi -fi - -if test ${exec_prefix} != "NONE"; then - real_gdm_prefix=$exec_prefix -elif test ${prefix} != "NONE"; then - real_gdm_prefix=$prefix -else - real_gdm_prefix=$ac_default_prefix -fi - -if test ${libexecdir} = "\${exec_prefix}/libexec"; then - ssh_libexec="$real_gdm_prefix/libexec" -else - ssh_libexec="${libexecdir}" -fi - -if test x$enable_secureremote != xno ; then - SSHDESKTOP="ssh.desktop" - GDMSSHSESSION="gdm-ssh-session" - GDMSSHSESSIONCMD="${ssh_libexec}/gdm-ssh-session" -fi -AC_SUBST(SSHDESKTOP) -AC_SUBST(GDMSSHSESSION) -AC_SUBST(GDMSSHSESSIONCMD) +dnl --------------------------------------------------------------------------- +dnl - Check for XEvIE extension support +dnl --------------------------------------------------------------------------- AC_ARG_WITH(xevie, [ --with-xevie=[yes/no] Add XEvIE Xserver extension support [default=no]],, @@ -980,6 +919,11 @@ fi AC_SUBST(XEVIE_OPTION) AC_DEFINE_UNQUOTED(XEVIE_OPTION,"$XEVIE_OPTION") + +dnl --------------------------------------------------------------------------- +dnl - Check for Solaris fbconsole +dnl --------------------------------------------------------------------------- + AC_MSG_CHECKING(for Solaris fbconsole) if test -x /usr/openwin/bin/fbconsole; then AC_DEFINE(HAVE_FBCONSOLE) @@ -988,6 +932,10 @@ else AC_MSG_RESULT(no) fi +dnl --------------------------------------------------------------------------- +dnl - Check for audit framework +dnl --------------------------------------------------------------------------- + # Check for Solaris auditing API # Note, Solaris auditing not supported for Solaris 9 or earlier and # should not be used on these versions of Solaris if auditing is @@ -1024,11 +972,15 @@ AC_CHECK_LIB(secdb, chkauthattr, [ EXTRA_DAEMON_LIBS="$EXTRA_DAEMON_LIBS -lsecdb" EXTRA_GREETER_LIBS="$EXTRA_GREETER_LIBS -lsecdb"]) + +dnl --------------------------------------------------------------------------- +dnl - Check for Halt, and Reboot commands +dnl --------------------------------------------------------------------------- + # Define different Halt, and Reboot commands differently for Solaris. # # 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="" @@ -1073,6 +1025,10 @@ AC_SUBST(EXTRA_DYNAMIC_LIBS) AC_SUBST(EXTRA_SETUP_LIBS) AC_SUBST(EXTRA_GREETER_LIBS) +dnl --------------------------------------------------------------------------- +dnl - Check for X Server location +dnl --------------------------------------------------------------------------- + # First check with "! -h" for /usr/X11R6 and /usr/X11 since they often # symlink to each other, and configure should use the more stable # location (the real directory) if possible. @@ -1120,7 +1076,7 @@ elif test -x /usr/X11/bin/X; then GDM_USER_PATH="$GDM_USER_PATH:/usr/X11/bin" X_CONFIG_OPTIONS="-audit 0" elif test -x /usr/openwin/bin/Xsun; then - # Do not add /usr/openwin/bin here because on Solaris you need + # Do not add /usr/openwin/bin here because on Solaris you need # /usr/openwin/bin in your PATH even if you are using the Xorg # Xserver. We add this to the path below. X_PATH="/usr/openwin/bin" @@ -1132,7 +1088,7 @@ elif test -x /opt/X11R6/bin/X; then X_SERVER_PATH="/opt/X11R6/bin" X_SERVER="/opt/X11R6/bin/X" GDM_USER_PATH="$GDM_USER_PATH:/opt/X11R6/bin" - X_CONFIG_OPTIONS="-audit 0" + X_CONFIG_OPTIONS="-audit 0" elif test -x /usr/bin/X; then X_PATH="/usr/bin" X_SERVER_PATH="/usr/bin" @@ -1154,6 +1110,9 @@ if test "x$real_gdm_prefix" != "x/" -a "x$real_gdm_prefix" != "x/usr"; then GDM_USER_PATH="$GDM_USER_PATH:${bindir}" fi +dnl --------------------------------------------------------------------------- +dnl - Check for Xnest / Xephyr support +dnl --------------------------------------------------------------------------- # Use Xephyr if it is available. It works better than Xnest since Xephyr # supports the Xserver extensions, even if on a remote machine. @@ -1187,7 +1146,7 @@ if test "x$USER_POST_PATH" != "x"; then fi dnl --------------------------------------------------------------------------- -dnl Expand vars +dnl - Expand vars dnl --------------------------------------------------------------------------- AS_AC_EXPAND(LOCALSTATEDIR, $localstatedir) @@ -1214,18 +1173,32 @@ AC_SUBST(GDM_PID_FILE) AC_DEFINE_UNQUOTED(GDM_PID_FILE, "$GDM_PID_FILE", [pid file]) dnl --------------------------------------------------------------------------- -dnl - Additional warnings +dnl - Allow configure to specify RBAC keys. dnl --------------------------------------------------------------------------- -AC_ARG_ENABLE(more-warnings, - AC_HELP_STRING([--enable-more-warnings], [Maximum compiler warnings]), -set_more_warnings="$enableval",[ -if test -d $srcdir/.svn; then - set_more_warnings=yes -else - set_more_warnings=no +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 --------------------------------------------------------------------------- + + +# Turn on the additional warnings last, so -Werror doesn't affect other tests. + +AC_ARG_ENABLE(more-warnings, + [AC_HELP_STRING([--enable-more-warnings], + [Maximum compiler warnings])], + set_more_warnings="$enableval",[ + if test -d $srcdir/.svn; then + set_more_warnings=yes + else + set_more_warnings=no + fi + ]) AC_MSG_CHECKING(for more warnings) if test "$GCC" = "yes" -a "$set_more_warnings" != "no"; then AC_MSG_RESULT(yes) @@ -1255,13 +1228,23 @@ else AC_MSG_RESULT(no) fi -# Allow configure to specify RBAC keys. # -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 +# Enable Debug +# +AC_ARG_ENABLE(debug, + [AC_HELP_STRING([--enable-debug], + [turn on debugging])], + , enable_debug=yes) +if test "$enable_debug" = "yes"; then + DEBUG_CFLAGS="-DG_ENABLE_DEBUG" +else + if test "x$enable_debug" = "xno"; then + DEBUG_CFLAGS="-DG_DISABLE_ASSERT -DG_DISABLE_CHECKS" + else + DEBUG_CFLAGS="" + fi fi +AC_SUBST(DEBUG_CFLAGS) # Set configuration choices. # @@ -1333,102 +1316,48 @@ config/gdmprefetchlist config/ssh.desktop.in ]) -dnl add back when help comes back -dnl docs/C/Makefile -dnl omf-install/Makefile - -dnl <= Configuration summary => - -echo "" -echo "GDM2 configuration summary:" -echo "===========================" -echo "" - -dnl <= CFLAGS and LDFLAGS => -echo "CFLAGS : $CFLAGS" -echo "LDFLAGS : $LDFLAGS" -echo "" - -dnl <= Prefixes => -echo "prefix : $prefix" -echo "sysconf : $sysconfdir" -echo "sysconfsubdir : $sysconfsubdir" -echo "gdmconf dir : $gdmconfdir" -echo "dmconf dir : $dmconfdir" -echo "bin dir : $bindir" -echo "sbin dir : $sbindir" -echo "PAM prefix : $PAM_PREFIX" -echo "data dir : $datadir" -echo "X server : $X_SERVER" -echo "" - -dnl <= TCP Wrappers support? => -if test x"$LIBWRAP_PATH" = x ; then - echo "TCP Wrappers support : NO" -else - echo "TCP Wrappers support : YES" -fi - -dnl <= XINERAMA => -if test x"$XINERAMA_SUPPORT" = xyes ; then - echo "Xinerama support : YES" -else - echo "Xinerama support : NO" -fi - -dnl <= XDMCP => -if test x"$XDMCP_SUPPORT" = xyes ; then - echo "XDMCP (remote login) support : YES" -else - echo "XDMCP (remote login) support : NO" -fi - -dnl <= Secure remote connection => -if test x"$enable_secureremote" = xyes ; then - echo "Secure remote connection : YES" -else - echo "Secure remote connection : NO" -fi - - -dnl <= DMX => -if test x"$DMX_SUPPORT" = xyes ; then - echo "DMX (Distributed Multihead X) support : YES" -else - echo "DMX (Distributed Multihead X) support : NO" -fi - -dnl <= Console Helper => -if test "x$enable_console_helper" = "xyes"; then - echo "Console helper : YES" -else - echo "Console helper : NO" -fi - -dnl <= SELinux support => -if test "x$with_selinux" = "xyes" ; then - echo "SELinux support : YES" -else - echo "SELinux support : NO" -fi - -dnl <= Solaris Trusted Extensions support => -if test "x$found_tsol" = "xyes" ; then - echo "Solaris Trusted Extensions support : YES" -else - echo "Solaris Trusted Extensions support : NO" -fi +dnl --------------------------------------------------------------------------- +dnl - Show summary +dnl --------------------------------------------------------------------------- -dnl <= ConsoleKit support => -if test "x$use_console_kit" = "xyes" ; then - echo "ConsoleKit support : YES" +echo " + GDM $VERSION + ============ + + prefix: ${prefix} + exec_prefix: ${exec_prefix} + libdir: ${libdir} + bindir: ${bindir} + sbindir: ${sbindir} + sysconfdir: ${sysconfdir} + sysconfsubdir: ${sysconfsubdir} + gdmconfdir: ${gdmconfdir} + dmconfdir: ${dmconfdir} + localstatedir: ${localstatedir} + datadir: ${datadir} + source code location: ${srcdir} + compiler: ${CC} + cflags: ${CFLAGS} + Maintainer mode: ${USE_MAINTAINER_MODE} + + dbus-1 system.d dir: ${DBUS_SYS_DIR} + PAM prefix: ${PAM_PREFIX} + X server: ${X_SERVER} +" + +dnl TCP Wrappers support? +if test x"$LIBWRAP_PATH" = x ; then + echo \ +" TCP Wrappers support: no" else - echo "ConsoleKit support : NO" +" TCP Wrappers support: yes" fi -dnl <= Utils built => -echo "Extra utilities built : "`echo $GDMOPEN $GDMASKPASS $GDMPREFETCH $GDMSSHSESSION` - -echo "" -dnl <= End of configuration summary => - +echo \ +" Xinerama support: ${XINERAMA_SUPPORT} + XDMCP support: ${XDMCP_SUPPORT} + DMX support: ${DMX_SUPPORT} + SELinux support: ${with_selinux} + Solaris TSOL support: ${found_tsol} + ConsoleKit support: ${use_console_kit} +" diff --git a/daemon/Makefile.am b/daemon/Makefile.am index fdf9b967..9264392f 100644 --- a/daemon/Makefile.am +++ b/daemon/Makefile.am @@ -103,8 +103,6 @@ gdm_simple_slave_SOURCES = \ auth.c \ auth.h \ fstype.c \ - filecheck.c \ - filecheck.h \ $(NULL) gdm_simple_slave_LDFLAGS = \ @@ -133,8 +131,6 @@ gdm_factory_slave_SOURCES = \ gdm-factory-slave.c \ gdm-factory-slave.h \ fstype.c \ - filecheck.c \ - filecheck.h \ $(NULL) gdm_factory_slave_LDFLAGS = \ @@ -161,8 +157,6 @@ gdm_product_slave_SOURCES = \ auth.c \ auth.h \ fstype.c \ - filecheck.c \ - filecheck.h \ $(NULL) gdm_product_slave_LDFLAGS = \ @@ -220,8 +214,6 @@ gdm_binary_SOURCES = \ fstype.c \ choose.c \ choose.h \ - filecheck.c \ - filecheck.h \ $(NULL) XDMCP_SOURCES = \ diff --git a/daemon/auth.c b/daemon/auth.c index 33cbcd1c..1cc1bd8e 100644 --- a/daemon/auth.c +++ b/daemon/auth.c @@ -1,7 +1,7 @@ /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- * - * GDM - The GNOME Display Manager * Copyright (C) 1998, 1999, 2000 Martin K. Petersen <mkp@mkp.net> + * Copyright (C) 2007 William Jon McCann <mccann@jhu.edu> * * 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 @@ -39,7 +39,6 @@ #include <glib.h> #include <glib/gi18n.h> -#include "filecheck.h" #include "auth.h" #include "gdm-common.h" diff --git a/daemon/filecheck.c b/daemon/filecheck.c deleted file mode 100644 index 30bac2d3..00000000 --- a/daemon/filecheck.c +++ /dev/null @@ -1,191 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- - * - * GDM - The GNOME Display Manager - * Copyright (C) 1998, 1999, 2000 Martin K. Petersen <mkp@mkp.net> - * - * 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 "config.h" - -#include <glib/gi18n.h> -#include <sys/stat.h> - -#include "gdm-common.h" - -#include "filecheck.h" - -/** - * gdm_file_check: - * @caller: String to be prepended to error messages. - * @user: User id for the user owning the file/dir. - * @dir: Directory to be examined. - * @file: File to be examined. - * @absentok: Accept absent files if TRUE. - * @absentdirok: Absent directory returns FALSE but without complaining - * @maxsize: Maximum acceptable filesize in KB. 0 to disable. - * @perms: 0 to allow user writable file/dir only. 1 to allow group and 2 to allow global writable file/dir. - * - * Examines a file to determine whether it is safe for the daemon to write to it. - */ - -/* we should be euid the user BTW */ -gboolean -gdm_file_check (const gchar *caller, - uid_t user, - const gchar *dir, - const gchar *file, - gboolean absentok, - gboolean absentdirok, - gint maxsize, - gint perms) -{ - struct stat statbuf; - gchar *fullpath; - gchar *dirautofs; - int r; - - if (ve_string_empty (dir) || - ve_string_empty (file)) - return FALSE; - - - VE_IGNORE_EINTR (r = stat (dir, &statbuf)); - - if (r < 0) { - if ( ! absentdirok) - g_warning (_("%s: Directory %s does not exist."), - caller, dir); - return FALSE; - } - - /* ... if group has write permission ... */ - if G_UNLIKELY (perms < 1 && (statbuf.st_mode & S_IWGRP) == S_IWGRP) { - g_warning (_("%s: %s is writable by group."), caller, dir); - return FALSE; - } - - /* ... and if others have write permission. */ - if G_UNLIKELY (perms < 2 && (statbuf.st_mode & S_IWOTH) == S_IWOTH) { - g_warning (_("%s: %s is writable by other."), caller, dir); - return FALSE; - } - - fullpath = g_build_filename (dir, file, NULL); - - /* Stat file */ - VE_IGNORE_EINTR (r = g_stat (fullpath, &statbuf)); - if (r < 0) { - /* Return true if file does not exist and that is ok */ - if (absentok) { - g_free (fullpath); - return TRUE; - } - else { - g_warning (_("%s: %s does not exist but must exist."), caller, fullpath); - g_free (fullpath); - return FALSE; - } - } - - /* Check that it is a regular file ... */ - if G_UNLIKELY (! S_ISREG (statbuf.st_mode)) { - g_warning (_("%s: %s is not a regular file."), caller, fullpath); - g_free (fullpath); - return FALSE; - } - - /* ... owned by the user ... */ - if G_UNLIKELY (statbuf.st_uid != user) { - g_warning (_("%s: %s is not owned by uid %d."), caller, fullpath, user); - g_free (fullpath); - return FALSE; - } - - /* ... unwritable by group ... */ - if G_UNLIKELY (perms < 1 && (statbuf.st_mode & S_IWGRP) == S_IWGRP) { - g_warning (_("%s: %s is writable by group."), caller, fullpath); - g_free (fullpath); - return FALSE; - } - - /* ... unwritable by others ... */ - if G_UNLIKELY (perms < 2 && (statbuf.st_mode & S_IWOTH) == S_IWOTH) { - g_warning (_("%s: %s is writable by group/other."), caller, fullpath); - g_free (fullpath); - return FALSE; - } - - /* ... and smaller than sysadmin specified limit. */ - if G_UNLIKELY (maxsize && statbuf.st_size > maxsize) { - g_warning (_("%s: %s is bigger than sysadmin specified maximum file size."), - caller, fullpath); - g_free (fullpath); - return FALSE; - } - - g_free (fullpath); - - /* Yeap, this file is ok */ - return TRUE; -} - -/* we should be euid the user BTW */ -gboolean -gdm_auth_file_check (const gchar *caller, - uid_t user, - const gchar *authfile, - gboolean absentok, - struct stat *s) -{ - struct stat statbuf; - gint usermaxfile; - int r; - - if (ve_string_empty (authfile)) - return FALSE; - - /* Stat file */ - VE_IGNORE_EINTR (r = g_lstat (authfile, &statbuf)); - if (s != NULL) - *s = statbuf; - if (r < 0) { - if (absentok) - return TRUE; - g_warning (_("%s: %s does not exist but must exist."), caller, authfile); - return FALSE; - } - - /* Check that it is a regular file ... */ - if G_UNLIKELY (! S_ISREG (statbuf.st_mode)) { - g_warning (_("%s: %s is not a regular file."), caller, authfile); - return FALSE; - } - - /* ... owned by the user ... */ - if G_UNLIKELY (statbuf.st_uid != user) { - g_warning (_("%s: %s is not owned by uid %d."), caller, authfile, user); - return FALSE; - } - - /* ... has right permissions ... */ - if G_UNLIKELY (statbuf.st_mode & 0077) { - g_warning ("%s: %s has wrong permissions (should be 0600)", caller, authfile); - return FALSE; - } - - /* Yeap, this file is ok */ - return TRUE; -} diff --git a/daemon/filecheck.h b/daemon/filecheck.h deleted file mode 100644 index 48a0c1d3..00000000 --- a/daemon/filecheck.h +++ /dev/null @@ -1,33 +0,0 @@ -/* GDM - The GNOME Display Manager - * Copyright (C) 1998, 1999, 2000 Martin K. Petersen <mkp@mkp.net> - * - * 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 GDM_FILECHECK_H -#define GDM_FILECHECK_H - -gboolean gdm_file_check (const gchar *caller, uid_t user, const gchar *dir, - const gchar *file, gboolean absentok, - gboolean absentdirok, gint maxsize, - gint perms); - -/* more paranoid on the file itself, doesn't check directory (for all we know - it could be /tmp) */ -gboolean gdm_auth_file_check (const gchar *caller, uid_t user, const gchar *authfile, gboolean absentok, struct stat *s); - -#endif /* GDM_FILECHECK_H */ - -/* EOF */ diff --git a/daemon/gdm-factory-slave.c b/daemon/gdm-factory-slave.c index 13549486..16656b07 100644 --- a/daemon/gdm-factory-slave.c +++ b/daemon/gdm-factory-slave.c @@ -151,6 +151,7 @@ get_script_environment (GdmFactorySlave *slave, char *display_hostname; char *display_x11_authority_file; gboolean display_is_local; + char *temp; g_object_get (slave, "display-name", &display_name, @@ -192,9 +193,10 @@ get_script_environment (GdmFactorySlave *slave, #endif /* some env for use with the Pre and Post scripts */ - x_servers_file = gdm_make_filename (AUTHDIR, - display_name, - ".Xservers"); + temp = g_strconcat (display_name, ".Xservers", NULL); + x_servers_file = g_build_filename (AUTHDIR, temp, NULL); + g_free (temp); + g_hash_table_insert (hash, g_strdup ("X_SERVERS"), x_servers_file); if (! display_is_local) { @@ -209,10 +211,6 @@ get_script_environment (GdmFactorySlave *slave, g_hash_table_insert (hash, g_strdup ("RUNNING_UNDER_GDM"), g_strdup ("true")); -#if 0 - if ( ! ve_string_empty (d->theme_name)) - g_setenv ("GDM_GTK_THEME", d->theme_name, TRUE); -#endif g_hash_table_remove (hash, "MAIL"); diff --git a/daemon/gdm-greeter-session.c b/daemon/gdm-greeter-session.c index 3446d427..777ca118 100644 --- a/daemon/gdm-greeter-session.c +++ b/daemon/gdm-greeter-session.c @@ -281,37 +281,8 @@ get_greeter_environment (GdmGreeterSession *greeter_session) g_hash_table_insert (hash, g_strdup ("PATH"), g_strdup (g_getenv ("PATH"))); -#if 0 - defaultpath = gdm_daemon_config_get_value_string (GDM_KEY_PATH); - if (ve_string_empty (g_getenv ("PATH"))) { - g_setenv ("PATH", defaultpath, TRUE); - } else if ( ! ve_string_empty (defaultpath)) { - gchar *temp_string = g_strconcat (g_getenv ("PATH"), - ":", defaultpath, NULL); - g_setenv ("PATH", temp_string, TRUE); - g_free (temp_string); - } -#endif - g_hash_table_insert (hash, g_strdup ("RUNNING_UNDER_GDM"), g_strdup ("true")); -#if 0 - if ( ! ve_string_empty (d->theme_name)) - g_setenv ("GDM_GTK_THEME", d->theme_name, TRUE); - if (gdm_daemon_config_get_value_bool (GDM_KEY_DEBUG_GESTURES)) { - g_setenv ("G_DEBUG_GESTURES", "true", TRUE); - } -#endif - -#if 0 - if (SERVER_IS_FLEXI (d)) { - g_setenv ("GDM_FLEXI_SERVER", "yes", TRUE); - } else { - g_unsetenv ("GDM_FLEXI_SERVER"); - } -#endif - - g_hash_table_foreach (hash, (GHFunc)listify_hash, env); g_hash_table_destroy (hash); diff --git a/daemon/gdm-product-slave.c b/daemon/gdm-product-slave.c index fee17a35..7f50956c 100644 --- a/daemon/gdm-product-slave.c +++ b/daemon/gdm-product-slave.c @@ -159,6 +159,7 @@ get_script_environment (GdmProductSlave *slave, char *display_hostname; char *display_x11_authority_file; gboolean display_is_local; + char *temp; g_object_get (slave, "display-name", &display_name, @@ -200,9 +201,10 @@ get_script_environment (GdmProductSlave *slave, #endif /* some env for use with the Pre and Post scripts */ - x_servers_file = gdm_make_filename (AUTHDIR, - display_name, - ".Xservers"); + temp = g_strconcat (display_name, ".Xservers", NULL); + x_servers_file = g_build_filename (AUTHDIR, temp, NULL); + g_free (temp); + g_hash_table_insert (hash, g_strdup ("X_SERVERS"), x_servers_file); if (! display_is_local) { @@ -217,10 +219,6 @@ get_script_environment (GdmProductSlave *slave, g_hash_table_insert (hash, g_strdup ("RUNNING_UNDER_GDM"), g_strdup ("true")); -#if 0 - if ( ! ve_string_empty (d->theme_name)) - g_setenv ("GDM_GTK_THEME", d->theme_name, TRUE); -#endif g_hash_table_remove (hash, "MAIL"); diff --git a/daemon/gdm-server.c b/daemon/gdm-server.c index ab8b3a76..69c2b744 100644 --- a/daemon/gdm-server.c +++ b/daemon/gdm-server.c @@ -286,55 +286,34 @@ gdm_server_resolve_command_line (GdmServer *server, return TRUE; } -/* somewhat safer rename (safer if the log dir is unsafe), may in fact - lose the file though, it guarantees that a is gone, but not that - b exists */ static void -safer_rename (const char *a, const char *b) +rotate_logs (GdmServer *server) { - errno = 0; - if (link (a, b) < 0) { - if (errno == EEXIST) { - VE_IGNORE_EINTR (g_unlink (a)); - return; - } - VE_IGNORE_EINTR (g_unlink (b)); - /* likely this system doesn't support hard links */ - g_rename (a, b); - VE_IGNORE_EINTR (g_unlink (a)); - return; + int n_copies; + int i; + char *filename; + char *path; + + n_copies = 5; + + filename = g_strdup_printf ("%s.log", server->priv->display_name); + path = g_build_filename (server->priv->log_dir, filename, NULL); + g_free (filename); + + for (i = n_copies - 1; i > 0; i--) { + char *name_n; + char *name_n1; + + name_n = g_strdup_printf ("%s.%d", path, i); + name_n1 = g_strdup_printf ("%s.%d", path, i - 1); + g_unlink (name_n); + g_rename (name_n1, name_n); + + g_free (name_n1); + g_free (name_n); } - VE_IGNORE_EINTR (g_unlink (a)); -} -static void -rotate_logs (GdmServer *server) -{ - const char *dname; - const char *logdir; - - dname = server->priv->display_name; - logdir = server->priv->log_dir; - - /* I'm too lazy to write a loop */ - char *fname4 = gdm_make_filename (logdir, dname, ".log.4"); - char *fname3 = gdm_make_filename (logdir, dname, ".log.3"); - char *fname2 = gdm_make_filename (logdir, dname, ".log.2"); - char *fname1 = gdm_make_filename (logdir, dname, ".log.1"); - char *fname = gdm_make_filename (logdir, dname, ".log"); - - /* Rotate the logs (keep 4 last) */ - VE_IGNORE_EINTR (g_unlink (fname4)); - safer_rename (fname3, fname4); - safer_rename (fname2, fname3); - safer_rename (fname1, fname2); - safer_rename (fname, fname1); - - g_free (fname4); - g_free (fname3); - g_free (fname2); - g_free (fname1); - g_free (fname); + g_unlink (path); } static void @@ -396,14 +375,14 @@ server_child_setup (GdmServer *server) int logfd; struct sigaction ign_signal; sigset_t mask; + char *temp; /* Rotate the X server logs */ rotate_logs (server); /* Log all output from spawned programs to a file */ - logfile = gdm_make_filename (server->priv->log_dir, - server->priv->display_name, - ".log"); + temp = g_strconcat (server->priv->display_name, ".log", NULL); + logfile = g_build_filename (server->priv->log_dir, temp, NULL); g_debug ("Opening logfile for server %s", logfile); VE_IGNORE_EINTR (g_unlink (logfile)); @@ -651,34 +630,10 @@ gdm_server_spawn (GdmServer *server, gboolean gdm_server_start (GdmServer *server) { - char *vtarg = NULL; - int vtfd = -1; - int vt = -1; gboolean res; -#if 0 - if (d->type == TYPE_XDMCP_PROXY && - ! connect_to_parent (d)) - return FALSE; -#endif - -#if 0 - if (d->type == TYPE_STATIC || - d->type == TYPE_FLEXI) { - vtarg = gdm_get_empty_vt_argument (&vtfd, &vt); - } -#endif - /* fork X server process */ - res = gdm_server_spawn (server, vtarg); - -#if 0 - /* If we were holding a vt open for the server, close it now as it has - * already taken the bait. */ - if (vtfd > 0) { - VE_IGNORE_EINTR (close (vtfd)); - } -#endif + res = gdm_server_spawn (server, NULL); return res; } diff --git a/daemon/gdm-simple-slave.c b/daemon/gdm-simple-slave.c index 13be3de1..b6e98a08 100644 --- a/daemon/gdm-simple-slave.c +++ b/daemon/gdm-simple-slave.c @@ -167,6 +167,7 @@ get_script_environment (GdmSimpleSlave *slave, char *display_hostname; char *display_x11_authority_file; gboolean display_is_local; + char *temp; display_name = NULL; display_hostname = NULL; @@ -213,9 +214,10 @@ get_script_environment (GdmSimpleSlave *slave, #endif /* some env for use with the Pre and Post scripts */ - x_servers_file = gdm_make_filename (AUTHDIR, - display_name, - ".Xservers"); + temp = g_strconcat (display_name, ".Xservers", NULL); + x_servers_file = g_build_filename (AUTHDIR, temp, NULL); + g_free (temp); + g_hash_table_insert (hash, g_strdup ("X_SERVERS"), x_servers_file); if (! display_is_local) { @@ -230,10 +232,6 @@ get_script_environment (GdmSimpleSlave *slave, g_hash_table_insert (hash, g_strdup ("RUNNING_UNDER_GDM"), g_strdup ("true")); -#if 0 - if ( ! ve_string_empty (d->theme_name)) - g_setenv ("GDM_GTK_THEME", d->theme_name, TRUE); -#endif g_hash_table_remove (hash, "MAIL"); diff --git a/daemon/gdm-xdmcp-display-factory.c b/daemon/gdm-xdmcp-display-factory.c index 862ffb84..75766689 100644 --- a/daemon/gdm-xdmcp-display-factory.c +++ b/daemon/gdm-xdmcp-display-factory.c @@ -548,6 +548,20 @@ setup_multicast (GdmXdmcpDisplayFactory *factory) #endif /* ENABLE_IPV6 */ } +fd_set_close_on_exec (int fd) +{ + int flags; + + flags = fcntl (fd, F_GETFD, 0); + if (flags < 0) { + return; + } + + flags |= FD_CLOEXEC; + + fcntl (fd, F_SETFD, flags); +} + static gboolean open_port (GdmXdmcpDisplayFactory *factory) { @@ -569,7 +583,7 @@ open_port (GdmXdmcpDisplayFactory *factory) return FALSE; } - gdm_fd_set_close_on_exec (factory->priv->socket_fd); + fd_set_close_on_exec (factory->priv->socket_fd); if (factory->priv->use_multicast) { setup_multicast (factory); @@ -1987,7 +2001,7 @@ gdm_xdmcp_handle_request (GdmXdmcpDisplayFactory *factory, factory->priv->max_pending_displays, factory->priv->num_sessions, factory->priv->max_displays, - ve_sure_string (s)); + s != NULL ? s : ""); g_free (s); } @@ -2279,7 +2293,7 @@ gdm_xdmcp_handle_manage (GdmXdmcpDisplayFactory *factory, g_debug ("gdm_xdmcp-handle_manage: Got display=%d, SessionID=%ld Class=%s from %s", (int)clnt_dspnum, (long)clnt_sessid, - ve_sure_string (s), + s != NULL ? s : "", host); g_free (s); diff --git a/libgreeter/Makefile.am b/libgreeter/Makefile.am index cdc71cc7..fc5aaf45 100644 --- a/libgreeter/Makefile.am +++ b/libgreeter/Makefile.am @@ -5,12 +5,6 @@ noinst_LTLIBRARIES = libgreeter.la libgreeter_la_SOURCES = \ gdm-greeter.c \ gdm-greeter.h \ - gdmwm.c \ - gdmwm.h \ - gdmsession.c \ - gdmsession.h \ - gdmlanguages.c \ - gdmlanguages.h \ $(NULL) libgreeter_la_CPPFLAGS = \ diff --git a/libgreeter/gdmlanguages.c b/libgreeter/gdmlanguages.c deleted file mode 100644 index b865bc54..00000000 --- a/libgreeter/gdmlanguages.c +++ /dev/null @@ -1,1154 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- - * - * GDM - The GNOME Display Manager - * Copyright (C) 1998, 1999, 2000 Martin K. Petersen <mkp@mkp.net> - * - * This file Copyright (c) 2001 George Lebl - * - * 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 "config.h" - -#include <gtk/gtk.h> -#include <glib/gi18n.h> -#include <locale.h> -#include <string.h> -#include <stdio.h> - -#include "gdmwm.h" -#include "gdmlanguages.h" - -#define LAST_LANGUAGE "Last" -#define DEFAULT_LANGUAGE "Default" - -static GtkWidget *tv = NULL; -static GtkListStore *lang_model = NULL; -static GtkWidget *dialog = NULL; -static gchar *current_language = NULL; -static gchar *dialog_selected_language = NULL; -static gint savelang = GTK_RESPONSE_NO; -static gboolean always_restart = FALSE; - -#include "gdm-common.h" - -typedef struct _Language Language; -struct _Language { - char *name; - char *code; - char *untranslated; - int found; - - /* extra fields */ - char *collate_key; -}; - -/* FIXME: We need to have a nicer selection of language and country, - * I suppose that we should have a menu of languages and then for each have - * a submenu of countries (and perhaps other variations such as utf8 vs not - * etc...) if there is more then one. */ - -/* Note: these should NOT include the encodings, this is just a translation - * matrix for language_country names. This is NOT a list of available - * languages, just their names and where they are placed in the menu. - * The available languages come from the supplied locale.alias */ -static Language languages [] = { - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Afrikaans"), "af_ZA", NULL, 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Albanian"), "sq_AL", "Shqip", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Amharic"), "am_ET", NULL, 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Arabic (Egypt)"), "ar_EG", NULL, 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Arabic (Lebanon)"), "ar_LB", NULL, 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Arabic (Saudi Arabia)"), "ar_SA", NULL, 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Armenian"), "hy_AM", "Հայերեն", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Azerbaijani"), "az_AZ", "Azərbaycanca", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Basque"), "eu_ES", "Euskara", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Belarusian"), "be_BY", "Беларуская мова", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Bengali"), "bn_BD", "বাংলা", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Bengali (India)"), "bn_IN", "বাংলা", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Bulgarian"), "bg_BG", "Български", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Bosnian"), "bs_BA", "Bosanski", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Catalan"), "ca_ES", "Català", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Chinese (China Mainland)"), "zh_CN", "中文 (中国大陆)", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Chinese (Hong Kong)"), "zh_HK", "中文 (香港)", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Chinese (Singapore)"), "zh_SG", "中文 (新加坡)", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Chinese (Taiwan)"), "zh_TW", "中文 (台灣)", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Croatian"), "hr_HR", "Hrvatski", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Czech"), "cs_CZ", "čeština", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Danish"), "da_DK", "dansk", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Dutch"), "nl_NL", "Nederlands", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Dutch (Belgium)"), "nl_BE", "Nederlands (België)", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|English (USA)"), "en_US", "American English", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|English (Australia)"), "en_AU", "Australian English", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|English (UK)"), "en_GB", "British English", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|English (Canada)"), "en_CA", "Canadian English", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|English (Ireland)"), "en_IE", "Irish English", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|English (Denmark)"), "en_DK", "Danish English", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|English (South Africa)"), "en_ZA", "South African English", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|English (Malta)"), "en_MT", "Maltese English", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|English (New Zealand)"), "en_NZ", "New Zealand English", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Estonian"), "et_EE", "Eesti", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Finnish"), "fi_FI", "Suomi", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|French"), "fr_FR", "Français", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|French (Belgium)"), "fr_BE", "Français (Belgique)", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|French (Canada)"), "fr_CA", "Français (Canada)", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|French (Luxembourg)"), "fr_LU", "Français (Luxembourg)", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|French (Switzerland)"), "fr_CH", "Français (Suisse)", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Galician"), "gl_ES", "Galego", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|German"), "de_DE", "Deutsch", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|German (Austria)"), "de_AT", "Deutsch (Österreich)", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|German (Luxembourg)"), "de_LU", "Deutsch (Luxemburg)", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|German (Switzerland)"), "de_CH", "Deutsch (Schweiz)", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Greek"), "el_GR", "Ελληνικά", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Greek (Cyprus)"), "el_CY", "Ελληνικά (Κύπρος)", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Gujarati"), "gu_IN", "ગુજરાતી", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Hebrew"), "he_IL", "עברית", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Hebrew"), "iw_IL", "עברית", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Hindi"), "hi_IN", "हिंदी", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Hungarian"), "hu_HU", "Magyar", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Icelandic"), "is_IS", NULL, 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Indonesian"), "id_ID", "Bahasa Indonesia", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Interlingua"), "ia", NULL, 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Irish"), "ga_IE", "Gaeilge", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Italian"), "it_IT", "Italiano", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Japanese"), "ja_JP", "日本語", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Kannada"), "kn_IN", "ಕನ್ನಡ", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Kinyarwanda"), "rw_RW", "Kinyarwanda", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Korean"), "ko_KR", "한국어", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Latvian"), "lv_LV", "Latviešu", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Lithuanian"), "lt_LT", "Lietuvių", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Macedonian"), "mk_MK", NULL, 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Malay"), "ms_MY", "Bahasa Melayu", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Malayalam"), "ml_IN", "മലയാളം", 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Maltese"), "mt_MT", NULL, 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Marathi"), "mr_IN", NULL, 0 }, - /*Note translate the A-M to the A-M you used in the group label */ - { N_("A-M|Mongolian"), "mn_MN", "Монгол", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Northern Sotho"), "nso_ZA", "Sesotho sa Leboa", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Norwegian (bokmal)"), "no_NO", "Norsk (bokmål)", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Norwegian (nynorsk)"), "nn_NO", "Norsk (nynorsk)", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Oriya"), "or_IN", NULL, 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Punjabi"), "pa_IN", NULL, 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Persian"), "fa_IR", "فارسی", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Polish"), "pl_PL", "Polski", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Portuguese"), "pt_PT", "Português", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Portuguese (Brazilian)"), "pt_BR", "Português do Brasil", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Romanian"), "ro_RO", "Română", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Russian"), "ru_RU", "русский", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Serbian"), "sr_YU", "српски", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Serbian (Serbia & Montenegro)"), "sr_CS", "српски", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Serbian (Montenegro)"), "sr_ME", "српски", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Serbian (Serbia)"), "sr_RS", "српски", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Serbian (Latin)"), "sr_CS@Latn", "srpski (latinica)", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Serbian (Jekavian)"), "sr_CS@ije", "српски (ијекавски)", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Serbian (Bosnia)"), "sh_BA", "srpski (Bosna i Hercegovina)", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Slovak"), "sk_SK", "Slovenský", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Slovenian"), "sl_SI", "Slovenščina", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Spanish"), "es_ES", "Español", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Spanish (Argentina)"), "es_AR", "Español (Argentina)", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Spanish (Bolivia)"), "es_BO", "Español (Bolivia)", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Spanish (Chile)"), "es_CL", "Español (Chile)", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Spanish (Colombia)"), "es_CO", "Español (Colombia)", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Spanish (Costa Rica)"), "es_CR", "Español (Costa Rica)", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Spanish (Ecuador)"), "es_EC", "Español (Ecuador)", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Spanish (Guatemala)"), "es_GT", "Español (Guatemala)", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Spanish (Mexico)"), "es_MX", "Español (México)", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Spanish (Nicaragua)"), "es_NI", "Español (Nicaragua)", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Spanish (Panama)"), "es_PA", "Español (Panamá)", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Spanish (Peru)"), "es_PE", "Español (Perú)", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Spanish (Paraguay)"), "es_PY", "Español (Paraguay)", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Spanish (El Salvador)"), "es_SV", "Español (El Salvador)", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Spanish (Uruguay)"), "es_UY", "Español (Uruguay)", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Spanish (Venezuela)"), "es_VE", "Español (Venezuela)", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Swedish"), "sv_SE", "Svenska", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Swedish (Finland)"), "sv_FI", "Svenska (Finland)", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Tamil"), "ta_IN", NULL, 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Telugu"), "te_IN", NULL, 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Thai"), "th_TH", "ไทย", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Turkish"), "tr_TR", "Türkçe", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Ukrainian"), "uk_UA", "Українська", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Vietnamese"), "vi_VN", "Việt Nam", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Walloon"), "wa_BE", "Walon", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Welsh"), "cy_GB", "Cymraeg", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Xhosa"), "xh_ZA", "isiXhosa", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Yiddish"), "yi", "ייִדיש", 0 }, - /*Note translate the N-Z to the N-Z you used in the group label */ - { N_("N-Z|Zulu"), "zu_ZA", "isiZulu", 0 }, - /* This is the POSIX/C locale for english, should really be in Other */ - { N_("Other|POSIX/C English"), "C", "POSIX/C English", 0 }, - { NULL, NULL } -}; - -static GHashTable *lang_names = NULL; - -static void -gdm_lang_init (void) -{ - int i; - if (lang_names != NULL) - return; - - lang_names = g_hash_table_new (g_str_hash, g_str_equal); - - for (i = 0; languages[i].name != NULL; i++) { - g_hash_table_insert (lang_names, - languages[i].code, - &languages[i]); - } -} - -static Language * -find_lang (const char *language, gboolean *clean) -{ - char *name, *p; - Language *lang; - - *clean = FALSE; - - lang = g_hash_table_lookup (lang_names, language); - if (lang != NULL) { - *clean = TRUE; - return lang; - } - - name = g_strdup (language); - - p = strrchr (name, '@'); - if (p != NULL) { - char *mod = p+1; - *p = '\0'; - - /* attempt lookup without encoding but with the - modifier first */ - p = strrchr (name, '.'); - if (p != NULL) { - char *noenc; - *p = '\0'; - - noenc = g_strconcat (name, "@", mod, NULL); - lang = g_hash_table_lookup (lang_names, noenc); - if (lang != NULL) { - g_free (name); - g_free (noenc); - return lang; - } - g_free (noenc); - - *p = '.'; - } - - lang = g_hash_table_lookup (lang_names, name); - if (lang != NULL) { - g_free (name); - return lang; - } - } - - p = strrchr (name, '.'); - if (p != NULL) { - *p = '\0'; - lang = g_hash_table_lookup (lang_names, name); - if (lang != NULL) { - g_free (name); - return lang; - } - } - - p = strrchr (name, '_'); - if (p != NULL) { - *p = '\0'; - lang = g_hash_table_lookup (lang_names, name); - if (lang != NULL) { - g_free (name); - return lang; - } - } - - g_free (name); - return NULL; -} - -gboolean -gdm_lang_name_translated (const char *language) -{ - Language *lang; - gboolean clean; - - gdm_lang_init (); - - lang = find_lang (language, &clean); - if (lang == NULL) - return FALSE; - - if (strcmp (lang->name, _(lang->name)) == 0) - return FALSE; - - return TRUE; -} - -char * -gdm_lang_name (const char *language, - gboolean never_encoding, - gboolean no_group, - gboolean untranslated, - gboolean markup) -{ - Language *lang; - char *name; - gboolean clean; - const char *encoding; - - gdm_lang_init (); - - lang = find_lang (language, &clean); - if (lang == NULL) - return g_strdup (language); - - encoding = strchr (language, '.'); - if (encoding == NULL) - encoding = strchr (language, '@'); /* treat a modifier without a codeset as an encoding */ - if (encoding != NULL) - encoding++; - - /* if more then one language in the language file with this - * locale, then hell, include the encoding to differentiate them */ - if (lang->found > 1 && - encoding != NULL && - ! never_encoding) - name = g_strdup_printf ("%s (%s)", _(lang->name), encoding); - else - name = g_strdup (_(lang->name)); - - if (lang->untranslated != NULL && untranslated) { - char *full; - full = g_strdup_printf ("%s (%s)", - name, lang->untranslated); - g_free (name); - name = full; - } - - if (no_group) { - char *p = strchr (name, '|'); - if (p != NULL) { - p = g_strdup (p + 1); - g_free (name); - name = p; - } - } - - return name; -} - -/* NULL if not found */ -char * -gdm_lang_untranslated_name (const char *language, - gboolean markup) -{ - Language *lang; - gboolean clean; - - gdm_lang_init (); - - lang = find_lang (language, &clean); - if (lang == NULL) - return NULL; - - return g_strdup (lang->untranslated); -} - -const char * -gdm_lang_group1 (void) -{ - /* This should be the same as in the front of the language strings - * else the languages will appear in the "Other" submenu */ - return _("A-M"); -} - -const char * -gdm_lang_group2 (void) -{ - /* This should be the same as in the front of the language strings - * else the languages will appear in the "Other" submenu */ - return _("N-Z"); -} - -static int -lang_collate (gconstpointer a, gconstpointer b) -{ - gboolean clean; - Language *l1 = find_lang ((const char *)a, &clean); - Language *l2 = find_lang ((const char *)b, &clean); - - /* paranoia */ - if (l1 == NULL || l2 == NULL) - return 0; - - if (l1->collate_key == NULL) { - const char *name; - name = strchr (_(l1->name), '|'); - if (name != NULL) - name++; - else - name = _(l1->name); - l1->collate_key = g_utf8_collate_key (name, -1); - } - - if (l2->collate_key == NULL) { - const char *name; - name = strchr (_(l2->name), '|'); - if (name != NULL) - name++; - else - name = _(l2->name); - l2->collate_key = g_utf8_collate_key (name, -1); - } - - return strcmp (l1->collate_key, l2->collate_key); -} - -GList * -gdm_lang_read_locale_file (const char *locale_file) -{ - FILE *langlist; - char curline[256]; - GList *langs = NULL; - GHashTable *dupcheck; - gboolean got_english = FALSE; - Language *language; - gboolean clean; - char *getsret; - char *p; - - if (locale_file == NULL) - return NULL; - - VE_IGNORE_EINTR (langlist = fopen (locale_file, "r")); - - if (langlist == NULL) - return NULL; - - gdm_lang_init (); - - dupcheck = g_hash_table_new (g_str_hash, g_str_equal); - - for (;;) { - char *name; - char *lang; - char **lang_list; - int i; - - VE_IGNORE_EINTR (getsret = fgets (curline, sizeof (curline), langlist)); - if (getsret == NULL) - break; - - if (curline[0] <= ' ' || - curline[0] == '#') - continue; - - name = strtok (curline, " \t\r\n"); - if (name == NULL) - continue; - - lang = strtok (NULL, " \t\r\n"); - if (lang == NULL) - continue; - - lang_list = g_strsplit (lang, ",", -1); - if (lang_list == NULL) - continue; - - lang = NULL; - for (i = 0; lang_list[i] != NULL; i++) { - if (ve_locale_exists (lang_list[i])) { - lang = lang_list[i]; - break; - } - } - if (lang == NULL || - g_hash_table_lookup (dupcheck, lang) != NULL) { - g_strfreev (lang_list); - continue; - } - language = find_lang (lang, &clean); - - if (language != NULL) { - language->found++; - } else { - language = g_new0 (Language, 1); - language->found = 1; - /* add a space before an open bracket to match - the style used in the internal list. - e.g. change "English(India)" to "English (India)" */ - p = strchr (name, '('); - if (p != NULL && p > name && *(p-1) != ' ') { - *p = 0; - language->name= g_strconcat (name, " (", p+1, NULL); - } else - language->name = g_strdup (name); - /* only store the "lang_country" part of the locale code, so that we notice - * if there is more than one encoding of this language. See bug 132629. */ - p = strchr (lang, '.'); - if (p == NULL) - p = strchr (lang, '@'); - if (p != NULL) - language->code = g_strndup (lang, (p - lang)); - else - language->code = g_strdup (lang); - language->untranslated = NULL; - g_hash_table_insert (lang_names, - language->code, - language); - } - - langs = g_list_prepend (langs, g_strdup (lang)); - g_hash_table_insert (dupcheck, g_strdup (lang), - GINT_TO_POINTER (1)); - - /* if we have an english locale */ - if (strncmp (lang, "en_", 3) == 0 || - strcmp (lang, "C") == 0) - got_english = TRUE; - - g_strfreev (lang_list); - } - - g_hash_table_foreach (dupcheck, (GHFunc) g_free, NULL); - g_hash_table_destroy (dupcheck); - - /* If we haven't found any english locale, add american - * english as that's as much of a fallback as we can get */ - if ( ! got_english) - langs = g_list_prepend (langs, g_strdup ("en_US")); - - langs = g_list_sort (langs, lang_collate); - - VE_IGNORE_EINTR (fclose (langlist)); - - return langs; -} - -GtkListStore * -gdm_lang_get_model (void) -{ - return lang_model; -} - -void -gdm_lang_initialize_model (gchar * locale_file) -{ - GList *list, *li; - GtkTreeIter iter; - - list = gdm_lang_read_locale_file (locale_file); - - lang_model = gtk_list_store_new (NUM_COLUMNS, - G_TYPE_STRING, - G_TYPE_STRING, - G_TYPE_STRING); - - gtk_list_store_append (lang_model, &iter); - gtk_list_store_set (lang_model, &iter, - TRANSLATED_NAME_COLUMN, _("Last language"), - UNTRANSLATED_NAME_COLUMN, NULL, - LOCALE_COLUMN, LAST_LANGUAGE, - -1); - - gtk_list_store_append (lang_model, &iter); - gtk_list_store_set (lang_model, &iter, - TRANSLATED_NAME_COLUMN, _("System Default"), - UNTRANSLATED_NAME_COLUMN, NULL, - LOCALE_COLUMN, DEFAULT_LANGUAGE, - -1); - - for (li = list; li != NULL; li = li->next) - { - char *lang = li->data; - char *name; - char *untranslated; - - li->data = NULL; - -#if 0 - if (!gdm_common_locale_is_displayable (lang)) { - g_free (lang); - continue; - } -#endif - - name = gdm_lang_name (lang, - FALSE /* never_encoding */, - TRUE /* no_group */, - FALSE /* untranslated */, - FALSE /* markup */); - - untranslated = gdm_lang_untranslated_name (lang, - TRUE /* markup */); - - gtk_list_store_append (lang_model, &iter); - gtk_list_store_set (lang_model, &iter, - TRANSLATED_NAME_COLUMN, name, - UNTRANSLATED_NAME_COLUMN, untranslated, - LOCALE_COLUMN, lang, - -1); - - g_free (name); - g_free (untranslated); - g_free (lang); - } - g_list_free (list); -} - -gint -gdm_lang_get_savelang_setting (void) -{ - return savelang; -} - -gchar * -gdm_lang_check_language (const char *old_language) -{ - gchar *retval = NULL; - - /* Don't save language unless told otherwise */ - savelang = GTK_RESPONSE_NO; - - if (old_language == NULL) - old_language = ""; - - /* If a different language is selected */ - if (current_language != NULL && strcmp (current_language, LAST_LANGUAGE) != 0) - { - if (strcmp (current_language, DEFAULT_LANGUAGE) == 0) - retval = g_strdup (""); - else - retval = g_strdup (current_language); - - /* User's saved language is not the chosen one */ - if (strcmp (old_language, retval) != 0) - { - gchar *primary_message; - gchar *secondary_message; - char *current_name, *saved_name; - - if (strcmp (current_language, DEFAULT_LANGUAGE) == 0) - current_name = g_strdup (_("System Default")); - else - current_name = gdm_lang_name (current_language, - FALSE /* never_encoding */, - TRUE /* no_group */, - TRUE /* untranslated */, - TRUE /* markup */); - if (strcmp (old_language, "") == 0) - saved_name = g_strdup (_("System Default")); - else - saved_name = gdm_lang_name (old_language, - FALSE /* never_encoding */, - TRUE /* no_group */, - TRUE /* untranslated */, - TRUE /* markup */); - - primary_message = g_strdup_printf (_("Do you wish to make %s the default for future sessions?"), - current_name); - secondary_message = g_strdup_printf (_("You have chosen %s for this session, but your default setting is " - "%s."), current_name, saved_name); - g_free (current_name); - g_free (saved_name); - - savelang = gdm_wm_query_dialog (primary_message, secondary_message, - _("Make _Default"), _("Just For _This Session"), TRUE); - g_free (primary_message); - g_free (secondary_message); - } - } - else - { - retval = g_strdup (old_language); - } - - return retval; -} - -static void -selection_changed (GtkTreeSelection *selection, - gpointer data) -{ - GtkTreeIter iter; - - if (gtk_tree_selection_get_selected (selection, NULL, &iter)) - { - g_free (dialog_selected_language); - gtk_tree_model_get (GTK_TREE_MODEL (lang_model), &iter, LOCALE_COLUMN, &dialog_selected_language, -1); - } -} - -static void -tree_row_activated (GtkTreeView *view, - GtkTreePath *path, - GtkTreeViewColumn *column, - gpointer data) -{ - GtkTreeIter iter; - if (gtk_tree_model_get_iter (GTK_TREE_MODEL (lang_model), &iter, path)) - { - g_free (dialog_selected_language); - gtk_tree_model_get (GTK_TREE_MODEL (lang_model), &iter, - LOCALE_COLUMN, &dialog_selected_language, - -1); - gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK); - } -} - -static void -gdm_lang_setup_treeview (void) -{ - if (dialog == NULL) - { - GtkWidget *main_vbox; - GtkWidget *button; - GtkWidget **tmp_p; - GtkWidget *swindow; - GtkWidget *label; - char *s; - - dialog = gtk_dialog_new_with_buttons (_("Select a Language"), -#ifdef TODO - GTK_WINDOW (parent_window), -#endif - NULL, - 0, - GTK_STOCK_CANCEL, - GTK_RESPONSE_CANCEL, - NULL); - - button = gtk_button_new_with_mnemonic (_("Change _Language")); - GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); - gtk_widget_show (button); - gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, - GTK_RESPONSE_OK); - - gtk_dialog_set_has_separator (GTK_DIALOG (dialog), FALSE); - gtk_container_set_border_width (GTK_CONTAINER (dialog), 5); - gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 2); - - main_vbox = gtk_vbox_new (FALSE, 6); - gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 5); - gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox), - main_vbox, TRUE, TRUE, 0); - - gtk_dialog_set_default_response (GTK_DIALOG (dialog), - GTK_RESPONSE_OK); - /* evil gcc warnings */ - tmp_p = &dialog; - g_object_add_weak_pointer (G_OBJECT (dialog), (gpointer *)tmp_p); - s = g_strdup (_("_Select the language for your session to use:")); - label = gtk_label_new_with_mnemonic (s); - gtk_misc_set_alignment (GTK_MISC (label), 0, 0.5); - g_free (s); - gtk_label_set_use_markup (GTK_LABEL (label), TRUE); - gtk_box_pack_start (GTK_BOX (main_vbox), - label, FALSE, FALSE, 0); - tv = gtk_tree_view_new (); - gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (tv), TRUE); - gtk_label_set_mnemonic_widget (GTK_LABEL (label), tv); - /* FIXME: we should handle this better, but things really look - * bad if we aren't always LTR */ - gtk_widget_set_direction (tv, GTK_TEXT_DIR_LTR); - gtk_tree_view_set_headers_visible (GTK_TREE_VIEW (tv), FALSE); - gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tv), - GTK_DIALOG_MODAL, - NULL, - gtk_cell_renderer_text_new (), - "text", TRANSLATED_NAME_COLUMN, - NULL); - gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (tv), - GTK_DIALOG_MODAL, - NULL, - gtk_cell_renderer_text_new (), - "markup", - UNTRANSLATED_NAME_COLUMN, - NULL); - swindow = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (swindow), GTK_SHADOW_IN); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (swindow), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_AUTOMATIC); - gtk_container_add (GTK_CONTAINER (swindow), tv); - gtk_box_pack_start (GTK_BOX (main_vbox), - swindow, TRUE, TRUE, 0); - gtk_window_set_default_size (GTK_WINDOW (dialog), - MIN (400, gdm_wm_screen.width), - MIN (600, gdm_wm_screen.height)); - g_signal_connect (G_OBJECT (gtk_tree_view_get_selection (GTK_TREE_VIEW (tv))), - "changed", - (GCallback) selection_changed, - NULL); - g_signal_connect (G_OBJECT (tv), - "row_activated", - (GCallback) tree_row_activated, - NULL); - gtk_tree_view_set_model (GTK_TREE_VIEW (tv), - GTK_TREE_MODEL (lang_model)); - } -} - -gint -gdm_lang_ask_restart (gchar *language) -{ - gchar *firstmsg; - gchar *secondmsg; - gchar *login; - gint response = GTK_RESPONSE_NO; - - if (always_restart) - return GTK_RESPONSE_YES; - - login = _("the login screen"); - firstmsg = g_strdup_printf (_("Do you wish to restart %s with the chosen language?"), - login); - secondmsg = g_strdup_printf (_("You will restart %s with the %s locale."), - login, - language); - - response = gdm_wm_query_dialog (firstmsg, secondmsg, _("_Yes"), _("_No"), FALSE); - - g_free (firstmsg); - g_free (secondmsg); - - return response; -} - -static gboolean -gdm_lang_get_restart_state (void) -{ - return always_restart; -} - -static void -gdm_lang_set_restart_state (gboolean do_restart) -{ - always_restart = do_restart; -} - -static void -gdm_lang_restart_handler (GtkMenuItem *menu_item, gpointer user_data) -{ - if ((int)user_data == ALWAYS_RESTART) - always_restart = TRUE; - else - always_restart = FALSE; -} - -static gchar * -gdm_lang_get (void) -{ - return (current_language); -} - -void -gdm_lang_set_restart_dialog (char *language) -{ - /* - * Don't do anything if the language is already set to - * this value. - */ - if (current_language == NULL || - (current_language != NULL && - strcmp (current_language, language) != 0)) - { - gint response = GTK_RESPONSE_YES; - - if (strcmp (language, LAST_LANGUAGE)) - response = gdm_lang_ask_restart (language); - - gdm_lang_set (language); - -#if 0 - if (strcmp (language, LAST_LANGUAGE) && - (response == GTK_RESPONSE_YES)) - { - printf ("%c%c%c%c%s\n", STX, - BEL, - GDM_INTERRUPT_SELECT_LANG, - response == GTK_RESPONSE_YES ? 1 : 0, - language); - fflush (stdout); - - } -#endif - - } -} - -void -gdm_lang_set (char *language) -{ - char *locale; - GtkTreeSelection *selection; - GtkTreeIter iter = {0}; - - g_free (current_language); - current_language = g_strdup (language); - - if (dialog == NULL) - gdm_lang_setup_treeview (); - - if (language == NULL) - return; - - lang_set_custom_callback (language); - - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tv)); - gtk_tree_selection_unselect_all (selection); - - if (gtk_tree_model_get_iter_first (GTK_TREE_MODEL (lang_model), &iter)) { - do { - gtk_tree_model_get (GTK_TREE_MODEL (lang_model), &iter, LOCALE_COLUMN, &locale, -1); - if (locale != NULL && strcmp (locale, language) == 0) { - GtkTreePath *path = gtk_tree_model_get_path (GTK_TREE_MODEL (lang_model), &iter); - - gtk_tree_selection_select_iter (selection, &iter); - gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (tv), path, NULL, FALSE, 0.0, 0.0); - gtk_tree_path_free (path); - break; - } - } while (gtk_tree_model_iter_next (GTK_TREE_MODEL (lang_model), &iter)); - } -} - -/* - * The button with this handler appears in the F10 menu, so it - * cannot depend on callback data being passed in. - */ -void -gdm_lang_handler (gpointer user_data) -{ - if (dialog == NULL) - gdm_lang_setup_treeview (); - - gtk_widget_show_all (dialog); - gdm_wm_center_window (GTK_WINDOW (dialog)); - - gdm_wm_no_login_focus_push (); - if (tv != NULL) - { - GtkTreeSelection *selection; - - gtk_widget_show_now (dialog); - selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (tv)); - if (selection == NULL) - gtk_tree_selection_select_path (selection, gtk_tree_path_new_first ()); - else - { - GtkTreeIter iter; - GtkTreePath *path; - GtkTreeModel *tm = GTK_TREE_MODEL (lang_model); - - gtk_tree_selection_get_selected (selection, &tm, &iter); - path = gtk_tree_model_get_path (GTK_TREE_MODEL (lang_model), &iter); - gtk_tree_view_scroll_to_cell (GTK_TREE_VIEW (tv), path, NULL, FALSE, 0.0, 0.0); - gtk_tree_path_free (path); - } - } - switch (gtk_dialog_run (GTK_DIALOG (dialog))) - { - case GTK_RESPONSE_OK: - if (dialog_selected_language) - gdm_lang_set_restart_dialog (dialog_selected_language); - - break; - case GTK_RESPONSE_CANCEL: - default: - break; - } - - gdm_wm_no_login_focus_pop (); - - if (dialog) - gtk_widget_hide (dialog); -} - -void -gdm_lang_op_lang (const gchar *args) -{ - gchar *language = gdm_lang_check_language (args); - -#if 0 - if (gdm_lang_get_savelang_setting () == GTK_RESPONSE_CANCEL) - printf ("%c%s\n", STX, GDM_RESPONSE_CANCEL); - else - printf ("%c%s\n", STX, language); -#endif - - fflush (stdout); - g_free (language); -} - -void -gdm_lang_op_slang (const gchar *args) -{ -#if 0 - if (gdm_lang_get_savelang_setting () == GTK_RESPONSE_YES) - printf ("%cY\n", STX); - else - printf ("%c\n", STX); -#endif - - fflush (stdout); -} - -void -gdm_lang_op_setlang (const gchar *args) -{ - if (args) - gdm_lang_set ((char*)args); - -#if 0 - printf ("%c\n", STX); - fflush (stdout); -#endif -} - -void -gdm_lang_op_always_restart (const gchar *args) -{ - if (args) - { - if (g_ascii_strcasecmp (args, "y") == 0) - gdm_lang_set_restart_state (TRUE); - else if (g_ascii_strcasecmp (args, "n") == 0) - gdm_lang_set_restart_state (FALSE); - } - -#if 0 - printf ("%c\n", STX); - fflush (stdout); -#endif -} - diff --git a/libgreeter/gdmlanguages.h b/libgreeter/gdmlanguages.h deleted file mode 100644 index e46a53e4..00000000 --- a/libgreeter/gdmlanguages.h +++ /dev/null @@ -1,70 +0,0 @@ -/* GDM - The Gnome Display Manager - * Copyright (C) 1998, 1999, 2000 Martin K. Petersen <mkp@mkp.net> - * - * This file Copyright (c) 2001 George Lebl - * - * 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 GDM_LANGUAGES_H -#define GDM_LANGUAGES_H - -#include <glib.h> - -enum { - LOCALE_COLUMN, - TRANSLATED_NAME_COLUMN, - UNTRANSLATED_NAME_COLUMN, - NUM_COLUMNS -}; - -enum { - ASK_RESTART = 0, - ALWAYS_RESTART -}; - -/* This is the interface for translating languages. Language translations - * are now hardocded in, but that may change */ - -const char * gdm_lang_group1 (void); -const char * gdm_lang_group2 (void); - -char * gdm_lang_name (const char *language, - gboolean never_encoding, - gboolean no_group, - gboolean untranslated, - gboolean markup); -gboolean gdm_lang_name_translated (const char *language); - -/* NULL if not found */ -char * gdm_lang_untranslated_name (const char *language, - gboolean markup); - -GList * gdm_lang_read_locale_file (const char *file); - -GtkListStore * gdm_lang_get_model (void); -void gdm_lang_initialize_model (gchar *locale_file); -gchar * gdm_lang_check_language (const char *old_language); -void gdm_lang_set (char *language); -void gdm_lang_set_restart_dialog (char *language); -gint gdm_lang_get_savelang_setting (void); -void gdm_lang_handler (gpointer user_data); -void gdm_lang_op_lang (const gchar *args); -void gdm_lang_op_slang (const gchar *args); -void gdm_lang_op_setlang (const gchar *args); -void gdm_lang_op_always_restart (const gchar *args); -gint gdm_lang_ask_restart (gchar *language); - -#endif /* GDM_LANGUAGES_H */ diff --git a/libgreeter/gdmsession.c b/libgreeter/gdmsession.c deleted file mode 100644 index a7f58f66..00000000 --- a/libgreeter/gdmsession.c +++ /dev/null @@ -1,518 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- - * - * GDM - The GNOME Display Manager - * Copyright (C) 1999, 2000 Martin K. Petersen <mkp@mkp.net> - * - * This file Copyright (c) 2003 George Lebl - * - Common routines for the greeters. - * - * 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 "config.h" - -#include <stdlib.h> -#include <unistd.h> -#include <string.h> -#include <dirent.h> -#include <gtk/gtk.h> -#include <glib/gi18n.h> - -#include "gdmsession.h" - -#include "gdm-common.h" -#include "gdm-settings-client.h" -#include "gdm-settings-keys.h" - -GHashTable *sessnames = NULL; -gchar *default_session = NULL; -const gchar *current_session = NULL; -GList *sessions = NULL; -static gint save_session = GTK_RESPONSE_NO; - - -/* This is true if session dir doesn't exist or is whacked out - * in some way or another */ -gboolean session_dir_whacked_out = FALSE; - -int -gdm_session_sort_func (const char *a, const char *b) -{ - int ret; - char *default_session; - - /* Put default and GNOME sessions at the top */ - default_session = NULL; - if (! gdm_settings_client_get_string (GDM_KEY_DEFAULT_SESSION, &default_session)) { - default_session = g_strdup ("default.desktop"); - } - - if (strcmp (a, default_session) == 0) { - ret = -1; - goto out; - } - - if (strcmp (b, default_session) == 0) { - ret = 1; - goto out; - } - - if (strcmp (a, "default.desktop") == 0) { - ret = -1; - goto out; - } - - if (strcmp (b, "default.desktop") == 0) { - ret = 1; - goto out; - } - - if (strcmp (a, "gnome.desktop") == 0) { - ret = -1; - goto out; - } - - if (strcmp (b, "gnome.desktop") == 0) { - ret = 1; - goto out; - } - - /* put failsafe sessions on the bottom */ - if (strcmp (b, GDM_SESSION_FAILSAFE_XTERM) == 0) { - ret = -1; - goto out; - } - - if (strcmp (a, GDM_SESSION_FAILSAFE_XTERM) == 0) { - ret = 1; - goto out; - } - - if (strcmp (b, GDM_SESSION_FAILSAFE_GNOME) == 0) { - ret = -1; - goto out; - } - - if (strcmp (a, GDM_SESSION_FAILSAFE_GNOME) == 0) { - ret = 1; - goto out; - } - - /* put everything else in the middle in alphabetical order */ - ret = strcmp (a, b); - - out: - g_free (default_session); - - return ret; -} - -const char * -gdm_session_name (const char *name) -{ - GdmSession *session; - - /* eek */ - if G_UNLIKELY (name == NULL) - return "(null)"; - - session = g_hash_table_lookup (sessnames, name); - if (session != NULL && !ve_string_empty (session->name)) - return session->name; - else - return name; -} - -void -gdm_session_list_from_hash_table_func (const char *key, - const char *value, - GList **sessions) -{ - *sessions = g_list_prepend (*sessions, g_strdup (key)); -} - -/* Just a wrapper to ensure compatibility with the - existing code */ -void -gdm_session_list_init () -{ - _gdm_session_list_init (&sessnames, - &sessions, - &default_session, - ¤t_session); -} - -/* The real gdm_session_list_init */ -void -_gdm_session_list_init (GHashTable **sessnames, - GList **sessions, - gchar **default_session, - const gchar **current_session) -{ - - GdmSession *session = NULL; - gboolean some_dir_exists = FALSE; - gboolean searching_for_default = TRUE; - struct dirent *dent; - char **vec; - char *name; - DIR *sessdir; - gboolean show_failsafe; - char *desktop_dir; - int i; - - *sessnames = g_hash_table_new (g_str_hash, g_str_equal); - - show_failsafe = FALSE; - gdm_settings_client_get_boolean (GDM_KEY_SHOW_GNOME_FAILSAFE, &show_failsafe); - - if (show_failsafe) { - session = g_new0 (GdmSession, 1); - session->name = g_strdup (_("Failsafe _GNOME")); - session->clearname = g_strdup (_("Failsafe GNOME")); - session->comment = g_strdup (_("This is a failsafe session that will log you " - "into GNOME. No startup scripts will be read " - "and it is only to be used when you can't log " - "in otherwise. GNOME will use the 'Default' " - "session.")); - g_hash_table_insert (*sessnames, g_strdup (GDM_SESSION_FAILSAFE_GNOME), session); - } - - show_failsafe = FALSE; - gdm_settings_client_get_boolean (GDM_KEY_SHOW_XTERM_FAILSAFE, &show_failsafe); - - if (show_failsafe) { - /* Valgrind complains that the below is leaked */ - session = g_new0 (GdmSession, 1); - session->name = g_strdup (_("Failsafe _Terminal")); - session->clearname = g_strdup (_("Failsafe Terminal")); - session->comment = g_strdup (_("This is a failsafe session that will log you " - "into a terminal. No startup scripts will be read " - "and it is only to be used when you can't log " - "in otherwise. To exit the terminal, " - "type 'exit'.")); - g_hash_table_insert (*sessnames, g_strdup (GDM_SESSION_FAILSAFE_XTERM), - session); - } - - gdm_settings_client_get_string (GDM_KEY_SESSION_DESKTOP_DIR, &desktop_dir); - vec = g_strsplit (desktop_dir, ":", -1); - - for (i = 0; vec != NULL && vec[i] != NULL; i++) { - const char *dir = vec[i]; - - /* Check that session dir is readable */ - if G_UNLIKELY (dir == NULL || access (dir, R_OK|X_OK) != 0) - continue; - - some_dir_exists = TRUE; - - /* Read directory entries in session dir */ - sessdir = opendir (dir); - - if G_LIKELY (sessdir != NULL) - dent = readdir (sessdir); - else - dent = NULL; - - while (dent != NULL) { - GKeyFile *cfg; - char *exec; - char *comment; - char *s; - char *tryexec; - char *ext; - gboolean hidden; - - /* ignore everything but the .desktop files */ - ext = strstr (dent->d_name, ".desktop"); - if (ext == NULL || - strcmp (ext, ".desktop") != 0) { - dent = readdir (sessdir); - continue; - } - - /* already found this session, ignore */ - if (g_hash_table_lookup (*sessnames, dent->d_name) != NULL) { - dent = readdir (sessdir); - continue; - } - - s = g_strconcat (dir, "/", dent->d_name, NULL); - cfg = g_key_file_new (); - g_key_file_load_from_file (cfg, s, 0, NULL); - g_free (s); - - hidden = g_key_file_get_boolean (cfg, "Desktop Entry", "Hidden", NULL); - if (hidden) { - session = g_new0 (GdmSession, 1); - session->name = g_strdup (dent->d_name); - session->clearname = NULL; - g_hash_table_insert (*sessnames, g_strdup (dent->d_name), session); - g_key_file_free (cfg); - dent = readdir (sessdir); - continue; - } - - tryexec = g_key_file_get_string (cfg, "Desktop Entry", "TryExec", NULL); - if ( ! ve_string_empty (tryexec)) { - char **tryexecvec = g_strsplit (tryexec, " ", -1); - char *full = NULL; - - /* Do not pass any arguments to g_find_program_in_path */ - if (tryexecvec != NULL) - full = g_find_program_in_path (tryexecvec[0]); - - if (full == NULL) { - session = g_new0 (GdmSession, 1); - session->name = g_strdup (dent->d_name); - session->clearname = NULL; - g_hash_table_insert (*sessnames, g_strdup (dent->d_name), - session); - g_free (tryexec); - g_key_file_free (cfg); - dent = readdir (sessdir); - continue; - } - g_strfreev (tryexecvec); - g_free (full); - } - g_free (tryexec); - - exec = g_key_file_get_string (cfg, "Desktop Entry", "Exec", NULL); - name = g_key_file_get_locale_string (cfg, "Desktop Entry", "Name", NULL, NULL); - comment = g_key_file_get_locale_string (cfg, "Desktop Entry", "Comment", NULL, NULL); - g_key_file_free (cfg); - - if G_UNLIKELY (ve_string_empty (exec) || ve_string_empty (name)) { - session = g_new0 (GdmSession, 1); - session->name = g_strdup (dent->d_name); - session->clearname = NULL; - g_hash_table_insert (*sessnames, g_strdup (dent->d_name), session); - g_free (exec); - g_free (name); - g_free (comment); - dent = readdir (sessdir); - continue; - } - - /* if we found the default session */ - if (default_session != NULL) { - char *def; - - def = NULL; - gdm_settings_client_get_string (GDM_KEY_DEFAULT_SESSION, &def); - if ( ! ve_string_empty (def) && strcmp (dent->d_name, def) == 0) { - g_free (*default_session); - *default_session = g_strdup (dent->d_name); - searching_for_default = FALSE; - } - g_free (def); - - /* if there is a session called Default */ - if (searching_for_default && - g_ascii_strcasecmp (dent->d_name, "default.desktop") == 0) { - g_free (*default_session); - *default_session = g_strdup (dent->d_name); - } - - if (searching_for_default && - g_ascii_strcasecmp (dent->d_name, "gnome.desktop") == 0) { - /* Just in case there is no default session and - * no default link, make gnome the default */ - if (*default_session == NULL) - *default_session = g_strdup (dent->d_name); - - } - } - - session = g_new0 (GdmSession, 1); - session->name = g_strdup (name); - session->clearname = NULL; - session->comment = g_strdup (comment); - g_hash_table_insert (*sessnames, g_strdup (dent->d_name), session); - g_free (exec); - g_free (comment); - dent = readdir (sessdir); - } - - if G_LIKELY (sessdir != NULL) - closedir (sessdir); - } - - g_strfreev (vec); - - /* Check that session dir is readable */ - if G_UNLIKELY ( ! some_dir_exists) { - g_warning ("%s: Session directory <%s> not found!", - "gdm_session_list_init", - desktop_dir); - session_dir_whacked_out = TRUE; - } - - if G_UNLIKELY (g_hash_table_size (*sessnames) == 0) { - g_warning ("Error, no sessions found in the session directory <%s>.", - desktop_dir); - - session_dir_whacked_out = TRUE; - if (default_session != NULL) - *default_session = g_strdup (GDM_SESSION_FAILSAFE_GNOME); - } - - g_free (desktop_dir); - - /* Convert to list (which is unsorted) */ - g_hash_table_foreach (*sessnames, - (GHFunc) gdm_session_list_from_hash_table_func, sessions); - - /* Prioritize and sort the list */ - *sessions = g_list_sort (*sessions, (GCompareFunc) gdm_session_sort_func); - - if (default_session != NULL) - if G_UNLIKELY (*default_session == NULL) { - *default_session = g_strdup (GDM_SESSION_FAILSAFE_GNOME); - g_warning ("No default session link found. Using Failsafe GNOME."); - } - - if (current_session != NULL && - default_session != NULL) { - if (*current_session == NULL) - *current_session = *default_session; - } -} - -static gboolean -gdm_login_list_lookup (GList *l, - const gchar *data) -{ - GList *list = l; - - if (list == NULL || data == NULL) - return FALSE; - - /* FIXME: Hack, will support these builtin types later */ - if (strcmp (data, GDM_SESSION_DEFAULT ".desktop") == 0 || - strcmp (data, GDM_SESSION_CUSTOM ".desktop") == 0 || - strcmp (data, GDM_SESSION_FAILSAFE ".desktop") == 0) { - return TRUE; - } - - while (list) { - - if (strcmp (list->data, data) == 0) - return TRUE; - - list = list->next; - } - - return FALSE; -} - -char * -gdm_session_lookup (const char *saved_session, - gint *lookup_status) -{ - gchar *session = NULL; - - /* Assume that the lookup will go well */ - *lookup_status = SESSION_LOOKUP_SUCCESS; - - /* Don't save session unless told otherwise */ - save_session = GTK_RESPONSE_NO; - - /* Previously saved session not found in ~/.dmrc */ - if ( ! (saved_session != NULL && - strcmp ("(null)", saved_session) != 0 && - saved_session[0] != '\0')) { - /* If "Last" is chosen run default, - * else run user's current selection */ - if (current_session == NULL || strcmp (current_session, LAST_SESSION) == 0) - session = g_strdup (default_session); - else - session = g_strdup (current_session); - - save_session = GTK_RESPONSE_YES; - return session; - } - - /* If "Last" session is selected */ - if (current_session == NULL || strcmp (current_session, LAST_SESSION) == 0) { - session = g_strdup (saved_session); - - /* Check if user's saved session exists on this box */ - if (!gdm_login_list_lookup (sessions, session)) { - g_free (session); - session = g_strdup (default_session); - *lookup_status = SESSION_LOOKUP_PREFERRED_MISSING; - } - } else { - /* One of the other available session types is selected */ - session = g_strdup (current_session); - - /* User's saved session is not the chosen one */ - if (strcmp (session, GDM_SESSION_FAILSAFE_GNOME) == 0 || - strcmp (session, GDM_SESSION_FAILSAFE_XTERM) == 0 || - g_ascii_strcasecmp (session, GDM_SESSION_FAILSAFE ".desktop") == 0 || - g_ascii_strcasecmp (session, GDM_SESSION_FAILSAFE) == 0) { - /* - * Never save failsafe sessions as the default session. - * These are intended to be used for debugging or temporary - * purposes. - */ - save_session = GTK_RESPONSE_NO; - } else if (strcmp (saved_session, session) != 0) { - gboolean show_last; - - show_last = FALSE; - gdm_settings_client_get_boolean (GDM_KEY_SHOW_LAST_SESSION, &show_last); - - if (show_last) { - *lookup_status = SESSION_LOOKUP_DEFAULT_MISMATCH; - } else if (strcmp (session, default_session) != 0 && - strcmp (session, saved_session) != 0 && - strcmp (session, LAST_SESSION) != 0) { - /* - * If (! GDM_KEY_SHOW_LAST_SESSION) then our saved session is - * irrelevant, we are in "switchdesk mode" and the relevant - * thing is the saved session in .Xclients - */ - if (g_access ("/usr/bin/switchdesk", F_OK) == 0) { - *lookup_status = SESSION_LOOKUP_USE_SWITCHDESK; - } - save_session = GTK_RESPONSE_NO; - } - } - } - - return session; -} - -gint -gdm_get_save_session (void) -{ - return save_session; -} - -void -gdm_set_save_session (const gint session) -{ - save_session = session; -} - -const char* -gdm_get_default_session (void) -{ - return default_session; -} diff --git a/libgreeter/gdmsession.h b/libgreeter/gdmsession.h deleted file mode 100644 index a3998f9c..00000000 --- a/libgreeter/gdmsession.h +++ /dev/null @@ -1,72 +0,0 @@ -/* GDM - The Gnome Display Manager - * Copyright (C) 1999, 2000 Martin K. Petersen <mkp@mkp.net> - * - * This file Copyright (c) 2003 George Lebl - * - Common routines for the greeters. - * - * 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 GDM_SESSION_H -#define GDM_SESSION_H - -#include <glib.h> - -#define LAST_SESSION "Last" -#define SESSION_NAME "SessionName" - -typedef struct { - char *name; - char *clearname; - char *comment; -} GdmSession; - -enum { - SESSION_LOOKUP_SUCCESS, - SESSION_LOOKUP_PREFERRED_MISSING, - SESSION_LOOKUP_DEFAULT_MISMATCH, - SESSION_LOOKUP_USE_SWITCHDESK -}; - -#define GDM_SESSION_FAILSAFE_GNOME "GDM_Failsafe.GNOME" -#define GDM_SESSION_FAILSAFE_XTERM "GDM_Failsafe.XTERM" - -/* FIXME: will support these builtin types later */ -#define GDM_SESSION_DEFAULT "default" -#define GDM_SESSION_CUSTOM "custom" -#define GDM_SESSION_FAILSAFE "failsafe" - - -void gdm_session_list_init (void); -void _gdm_session_list_init (GHashTable **sessnames, - GList **sessions, - gchar **default_session, - const gchar **current_session); -gint gdm_session_sort_func (const char *a, const char *b); -const char * gdm_session_name (const char *name); -void gdm_session_list_from_hash_table_func (const char *key, - const char *value, - GList **sessions); -gint gdm_session_sort_func (const char *a, - const char *b); -char * gdm_session_lookup (const char *saved_session, gint *lookup_status); - -gint gdm_get_save_session (void); - -void gdm_set_save_session (const gint session); - -const char * gdm_get_default_session (void); - -#endif /* GDM_SESSION_H */ diff --git a/libgreeter/gdmwm.c b/libgreeter/gdmwm.c deleted file mode 100644 index 44ab5100..00000000 --- a/libgreeter/gdmwm.c +++ /dev/null @@ -1,1755 +0,0 @@ -/* GDM - The GNOME Display Manager - * Copyright (C) 1998, 1999, 2000 Martin K. Petersen <mkp@mkp.net> - * - * This file Copyright (c) 2001 George Lebl - * - * 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 "config.h" - -#include <stdlib.h> -#include <string.h> -#include <unistd.h> -#include <pwd.h> - -#include <X11/X.h> -#include <X11/Xlib.h> -#include <X11/Xatom.h> -#ifdef HAVE_XFREE_XINERAMA -#include <X11/extensions/Xinerama.h> -#elif HAVE_SOLARIS_XINERAMA -#include <X11/extensions/xinerama.h> -#endif - -#include "gdmwm.h" - -typedef struct _GdmWindow GdmWindow; -struct _GdmWindow { - int x, y; - Window win; - Window deco; - Window shadow; - gboolean ignore_size_hints; /* for gdm windows */ - gboolean center; /* do centering */ - gboolean recenter; /* do re-centering */ - gboolean takefocus; /* permit take focus */ - - /* hack, when we reparent, we will get an unmap and then - * an map, and we want to ignore those */ - int ignore_next_map; - int ignore_next_unmap; -}; - -static GList *windows = NULL; -static gboolean focus_new_windows = FALSE; -static int no_focus_login = 0; -static Display *wm_disp = NULL; -static Window wm_root = None; -static Window wm_login_window = None; -static Window wm_focus_window = None; - -static Atom XA_WM_PROTOCOLS = 0; -static Atom XA_WM_STATE = 0; -static Atom XA_WM_TAKE_FOCUS = 0; -static Atom XA_COMPOUND_TEXT = 0; -static Atom XA_NET_WM_STRUT = 0; - -static int trap_depth = 0; - -GdkRectangle *gdm_wm_allscreens = NULL; -int gdm_wm_screens = 0; -GdkRectangle gdm_wm_screen = {0,0,0,0}; - -static Window strut_owners[4] = {None, None, None, None}; -static guint save_struts[4] = {0, 0, 0, 0}; - -void -gdm_wm_screen_init (int cur_screen_num) -{ - if (g_getenv ("FAKE_XINERAMA_GDM") != NULL) { - /* for testing Xinerama support on non-xinerama setups */ - gdm_wm_screen.x = 100; - gdm_wm_screen.y = 100; - gdm_wm_screen.width = gdk_screen_width () / 2 - 100; - gdm_wm_screen.height = gdk_screen_height () / 2 - 100; - - gdm_wm_allscreens = g_new0 (GdkRectangle, 2); - gdm_wm_allscreens[0] = gdm_wm_screen; - gdm_wm_allscreens[1].x = gdk_screen_width () / 2; - gdm_wm_allscreens[1].y = gdk_screen_height () / 2; - gdm_wm_allscreens[1].width = gdk_screen_width () / 2; - gdm_wm_allscreens[1].height = gdk_screen_height () / 2; - gdm_wm_screens = 2; - return; - } - - { -#ifdef HAVE_XFREE_XINERAMA - gboolean have_xinerama = FALSE; - - gdk_flush (); - gdk_error_trap_push (); - have_xinerama = XineramaIsActive (GDK_DISPLAY ()); - gdk_flush (); - if (gdk_error_trap_pop () != 0) - have_xinerama = FALSE; - - if (have_xinerama) { - int screen_num, i; - XineramaScreenInfo *xscreens = - XineramaQueryScreens (GDK_DISPLAY (), - &screen_num); - - - if (screen_num <= 0) { - /* should NEVER EVER happen */ - g_warning ("Xinerama active, but <= 0 screens?"); - gdm_wm_screen.x = 0; - gdm_wm_screen.y = 0; - gdm_wm_screen.width = gdk_screen_width (); - gdm_wm_screen.height = gdk_screen_height (); - - gdm_wm_allscreens = g_new0 (GdkRectangle, 1); - gdm_wm_allscreens[0] = gdm_wm_screen; - gdm_wm_screens = 1; - return; - } - - if (screen_num <= cur_screen_num) - cur_screen_num = 0; - - gdm_wm_allscreens = g_new0 (GdkRectangle, screen_num); - gdm_wm_screens = screen_num; - - for (i = 0; i < screen_num; i++) { - gdm_wm_allscreens[i].x = xscreens[i].x_org; - gdm_wm_allscreens[i].y = xscreens[i].y_org; - gdm_wm_allscreens[i].width = xscreens[i].width; - gdm_wm_allscreens[i].height = xscreens[i].height; - - if (cur_screen_num == i) - gdm_wm_screen = gdm_wm_allscreens[i]; - } - - XFree (xscreens); - } else -#elif HAVE_SOLARIS_XINERAMA - gboolean have_xinerama = FALSE; - /* This code from GDK, Copyright (C) 2002 Sun Microsystems */ - int opcode; - int firstevent; - int firsterror; - int n_monitors = 0; - - gdk_flush (); - gdk_error_trap_push (); - have_xinerama = XQueryExtension (GDK_DISPLAY (), - "XINERAMA", - &opcode, - &firstevent, - &firsterror); - gdk_flush (); - if (gdk_error_trap_pop () != 0) - have_xinerama = FALSE; - - if (have_xinerama) { - int i; - int result; - XRectangle monitors[MAXFRAMEBUFFERS]; - unsigned char hints[16]; - - result = XineramaGetInfo (GDK_DISPLAY (), 0, monitors, hints, &n_monitors); - /* Yes I know it should be Success but the current implementation - * returns the num of monitor - */ - - if (result <= 0) { - /* should NEVER EVER happen */ - g_warning ("Xinerama active, but <= 0 screens?"); - gdm_wm_screen.x = 0; - gdm_wm_screen.y = 0; - gdm_wm_screen.width = gdk_screen_width (); - gdm_wm_screen.height = gdk_screen_height (); - - gdm_wm_allscreens = g_new0 (GdkRectangle, 1); - gdm_wm_allscreens[0] = gdm_wm_screen; - gdm_wm_screens = 1; - return; - } - - if (n_monitors <= cur_screen_num) - cur_screen_num = 0; - - gdm_wm_allscreens = g_new0 (GdkRectangle, n_monitors); - gdm_wm_screens = n_monitors; - - for (i = 0; i < n_monitors; i++) { - gdm_wm_allscreens[i].x = monitors[i].x; - gdm_wm_allscreens[i].y = monitors[i].y; - gdm_wm_allscreens[i].width = monitors[i].width; - gdm_wm_allscreens[i].height = monitors[i].height; - - if (cur_screen_num == i) - gdm_wm_screen = gdm_wm_allscreens[i]; - } - - } else -#endif - { - gdm_wm_screen.x = 0; - gdm_wm_screen.y = 0; - gdm_wm_screen.width = gdk_screen_width (); - gdm_wm_screen.height = gdk_screen_height (); - - gdm_wm_allscreens = g_new0 (GdkRectangle, 1); - gdm_wm_allscreens[0] = gdm_wm_screen; - gdm_wm_screens = 1; - } - } -} - -void -gdm_wm_set_screen (int cur_screen_num) -{ - if (cur_screen_num >= gdm_wm_screens || cur_screen_num < 0) - cur_screen_num = 0; - - gdm_wm_screen = gdm_wm_allscreens[cur_screen_num]; -} - -/* Not really a WM function, center a gtk window by setting uposition */ -void -gdm_wm_center_window (GtkWindow *cw) -{ - gint x, y; - gint w, h; - - gtk_window_get_size (cw, &w, &h); - - x = gdm_wm_screen.x + (gdm_wm_screen.width - w)/2; - y = gdm_wm_screen.y + (gdm_wm_screen.height - h)/2; - - if (x < gdm_wm_screen.x) - x = gdm_wm_screen.x; - if (y < gdm_wm_screen.y) - y = gdm_wm_screen.y; - - gtk_window_move (GTK_WINDOW (cw), x, y); -} - -void -gdm_wm_center_cursor (void) -{ - XWarpPointer (wm_disp, None, wm_root, 0, 0, 0, 0, - gdm_wm_screen.x + gdm_wm_screen.width / 2, - gdm_wm_screen.y + gdm_wm_screen.height / 2); -} - -static void -trap_push (void) -{ - trap_depth++; - gdk_error_trap_push (); -} - -static int -trap_pop (void) -{ - trap_depth --; - if (trap_depth <= 0) - XSync (wm_disp, False); - return gdk_error_trap_pop (); -} - -/* stolen from gwmh */ -static gpointer -get_typed_property_data (Display *xdisplay, - Window xwindow, - Atom property, - Atom requested_type, - gint *size_p, - guint expected_format) -{ - static const guint prop_buffer_lengh = 1024 * 1024; - unsigned char *prop_data = NULL; - Atom type_returned = 0; - unsigned long nitems_return = 0, bytes_after_return = 0; - int format_returned = 0; - gpointer data = NULL; - gboolean abort = FALSE; - - g_return_val_if_fail (size_p != NULL, NULL); - *size_p = 0; - - gdk_error_trap_push (); - - abort = XGetWindowProperty (xdisplay, - xwindow, - property, - 0, prop_buffer_lengh, - False, - requested_type, - &type_returned, &format_returned, - &nitems_return, - &bytes_after_return, - &prop_data) != Success; - if (gdk_error_trap_pop () || - type_returned == None) - abort++; - if (!abort && - requested_type != AnyPropertyType && - requested_type != type_returned) - { - /* aparently this can happen for some properties of broken apps, be silent */ - abort++; - } - if (!abort && bytes_after_return) - { - g_warning (G_GNUC_PRETTY_FUNCTION "(): Eeek, property has more than %u bytes, stored on harddisk?", - prop_buffer_lengh); - abort++; - } - if (!abort && expected_format && expected_format != format_returned) - { - g_warning (G_GNUC_PRETTY_FUNCTION "(): Expected format (%u) unmatched (%d)", - expected_format, format_returned); - abort++; - } - if (!abort && prop_data && nitems_return && format_returned) - { - switch (format_returned) - { - case 32: - *size_p = nitems_return * 4; - if (sizeof (gulong) == 8) - { - guint32 i, *mem = g_malloc0 (*size_p + 1); - gulong *prop_longs = (gulong*) prop_data; - - for (i = 0; i < *size_p / 4; i++) - mem[i] = prop_longs[i]; - data = mem; - } - break; - case 16: - *size_p = nitems_return * 2; - break; - case 8: - *size_p = nitems_return; - break; - default: - g_warning ("Unknown property data format with %d bits (extraterrestrial?)", - format_returned); - break; - } - if (!data && *size_p) - { - guint8 *mem = NULL; - - if (format_returned == 8 && type_returned == XA_COMPOUND_TEXT) - { - gchar **tlist = NULL; - gint count = gdk_text_property_to_text_list - (gdk_x11_xatom_to_atom (type_returned), 8, prop_data, - nitems_return, &tlist); - - if (count && tlist && tlist[0]) - { - mem = (guint8 *)g_strdup (tlist[0]); - *size_p = strlen ((char *)mem); - } - if (tlist) - gdk_free_text_list (tlist); - } - if (!mem) - { - mem = g_malloc (*size_p + 1); - memcpy (mem, prop_data, *size_p); - mem[*size_p] = 0; - } - data = mem; - } - } - - if (prop_data) - XFree (prop_data); - - return data; -} - -/* - * Update the gdm_wm_screen 'effective' screen area when a window reserves struts. - * This only works if struts don't "collide", i.e. there is a max of one strut setter - * per edge. Of course this should be the case at gdm time... - */ -static void -gdm_wm_update_struts (Display *xdisplay, Window xwindow) -{ - gint size = 0; - guint32 *struts = get_typed_property_data (xdisplay, xwindow, XA_NET_WM_STRUT, - XA_CARDINAL, &size, 32); - if (size == 16) - { - gint i; - for (i = 0; i < 4; ++i) - { - /* strut owners are the only windows whose 'zero' struts are reflected */ - if (struts[i] != 0 || (strut_owners[i] == xwindow)) - { - /* if any window re-specifies a strut, it becomes the new owner */ - strut_owners[i] = xwindow; - save_struts[i] = struts[i]; - } - } - } - g_free (struts); -} - -/* stolen from gwmh */ -static gboolean -wm_protocol_check_support (Window xwin, - Atom check_atom) -{ - Atom *pdata = NULL; - guint32 *gdata = NULL; - int n_pids = 0; - gboolean is_supported = FALSE; - guint i, n_gids = 0; - - trap_push (); - - if (!XGetWMProtocols (wm_disp, - xwin, - &pdata, - &n_pids)) - { - gint size = 0; - - gdata = get_typed_property_data (wm_disp, - xwin, - XA_WM_PROTOCOLS, - XA_WM_PROTOCOLS, - &size, 32); - n_gids = size / 4; - } - - trap_pop (); - - for (i = 0; i < n_pids; i++) - if (pdata[i] == check_atom) - { - is_supported = TRUE; - break; - } - if (pdata) - XFree (pdata); - if (!is_supported) - for (i = 0; i < n_gids; i++) - if (gdata[i] == check_atom) - { - is_supported = TRUE; - break; - } - g_free (gdata); - - return is_supported; -} - -static GList * -find_window_list (Window w, gboolean deco_ok) -{ - GList *li; - - for (li = windows; li != NULL; li = li->next) { - GdmWindow *gw = li->data; - - if (gw->win == w) - return li; - if (deco_ok && - (gw->deco == w || - gw->shadow == w)) - return li; - } - - return NULL; -} - -static GdmWindow * -find_window (Window w, gboolean deco_ok) -{ - GList *li = find_window_list (w, deco_ok); - if (li == NULL) - return NULL; - else - return li->data; -} - -void -gdm_wm_focus_window (Window window) -{ - XWindowAttributes attribs = {0}; - GdmWindow *win; - - if (no_focus_login > 0 && - window == wm_login_window) - return; - - win = find_window (window, TRUE); - if (win != NULL && - ! win->takefocus) - return; - - trap_push (); - - XGetWindowAttributes (wm_disp, window, &attribs); - if (attribs.map_state == IsUnmapped) { - trap_pop (); - return; - } - - if (wm_protocol_check_support (window, XA_WM_TAKE_FOCUS)) { - XEvent xevent = { 0, }; - - xevent.type = ClientMessage; - xevent.xclient.window = window; - xevent.xclient.message_type = XA_WM_PROTOCOLS; - xevent.xclient.format = 32; - xevent.xclient.data.l[0] = XA_WM_TAKE_FOCUS; - xevent.xclient.data.l[1] = CurrentTime; - - XSendEvent (wm_disp, window, False, 0, &xevent); - XSync (wm_disp, False); - } - - XSetInputFocus (wm_disp, - window, - RevertToPointerRoot, - CurrentTime); - trap_pop (); - - wm_focus_window = window; -} - -static void -constrain_window (GdmWindow *gw) -{ -/* constrain window to lie within screen geometry, with struts reserved */ - int x, y, screen_x = 0, screen_y = 0; - Window root; - unsigned int width, height, border, depth; - unsigned int screen_width = gdk_screen_width (), screen_height = gdk_screen_height (); - - /* exclude any strut areas not owned by this window */ - if (strut_owners[0] != gw->win) - { - screen_x = save_struts[0]; - screen_width -= save_struts[0]; - } - if (strut_owners[2] != gw->win) - { - screen_y = save_struts[2]; - screen_height -= save_struts[2]; - } - if (strut_owners[1] != gw->win) - screen_width -= save_struts[1]; - if (strut_owners[3] != gw->win) - screen_height -= save_struts[3]; - - if (gw->deco == None) - return; - - trap_push (); - - XGetGeometry (wm_disp, gw->deco, - &root, &x, &y, &width, &height, &border, &depth); - - if (width > screen_width) - width = screen_width; - if (height > screen_height) - height = screen_height; - - if (x < screen_x) - x = screen_x; - if (y < screen_y) - y = screen_y; - if ((x - screen_x + width) > screen_width) - x = screen_width - width; - if ((y - screen_y + height) > screen_height) - y = screen_height - height; - - XMoveResizeWindow (wm_disp, gw->deco, x, y, width, height); - - trap_pop (); -} - -static void -constrain_all_windows (void) -{ - GList *winlist = windows; - - while (winlist) - { - GdmWindow *gw = winlist->data; - constrain_window (gw); - winlist = winlist->next; - } -} - -static void -center_x_window (GdmWindow *gw, Window w, Window hintwin) -{ - XSizeHints hints; - Status status; - long ret; - int x, y; - Window root; - unsigned int width, height, border, depth; - gboolean can_resize, can_reposition; - - trap_push (); - - status = XGetWMNormalHints (wm_disp, - hintwin, - &hints, - &ret); - - if ( ! status) { - trap_pop (); - return; - } - - /* allow resizing when PSize is given, just don't allow centering when - * PPosition is goven */ - can_resize = ! (hints.flags & USSize); - can_reposition = ! (hints.flags & USPosition || - hints.flags & PPosition); - - if (can_reposition && ! gw->center) - can_reposition = FALSE; - - if (gw->ignore_size_hints) { - can_resize = TRUE; - can_reposition = TRUE; - } - - if ( ! can_resize && - ! can_reposition) { - trap_pop (); - return; - } - - XGetGeometry (wm_disp, w, - &root, &x, &y, &width, &height, &border, &depth); - - /* we replace the x,y and width,height with some new values */ - - if (can_resize) { - if (width > gdm_wm_screen.width) - width = gdm_wm_screen.width; - if (height > gdm_wm_screen.height) - height = gdm_wm_screen.height; - } - - if (can_reposition) { - /* we wipe the X with some new values */ - x = gdm_wm_screen.x + (gdm_wm_screen.width - width)/2; - y = gdm_wm_screen.y + (gdm_wm_screen.height - height)/2; - - if (x < gdm_wm_screen.x) - x = gdm_wm_screen.x; - if (y < gdm_wm_screen.y) - y = gdm_wm_screen.y; - } - - XMoveResizeWindow (wm_disp, w, x, y, width, height); - - if (gw->center && ! gw->recenter) { - gw->center = FALSE; - } - - trap_pop (); -} - -#ifndef MWMUTIL_H_INCLUDED - -typedef struct { - unsigned long flags; - unsigned long functions; - unsigned long decorations; - long input_mode; - unsigned long status; -} MotifWmHints, MwmHints; - -#define MWM_HINTS_DECORATIONS (1L << 1) - -#define MWM_DECOR_BORDER (1L << 1) - -#endif /* MWMUTIL_H_INCLUDED */ - -static gboolean -has_deco (Window win) -{ - static Atom hints_atom = None; - unsigned char *foo; - MotifWmHints *hints; - Atom type; - gint format; - gulong nitems; - gulong bytes_after; - gboolean border = TRUE; - - trap_push (); - - if (hints_atom == None) - hints_atom = XInternAtom (wm_disp, "_MOTIF_WM_HINTS", False); - - hints = NULL; - - XGetWindowProperty (wm_disp, win, - hints_atom, 0, - sizeof (MotifWmHints) / sizeof (long), - False, AnyPropertyType, &type, &format, &nitems, - &bytes_after, &foo); - hints = (MotifWmHints *)foo; - - if (type != None && - hints != NULL && - hints->flags & MWM_HINTS_DECORATIONS && - ! (hints->decorations & MWM_DECOR_BORDER)) { - border = FALSE; - } - - if (hints != NULL) - XFree (hints); - - trap_pop (); - - return border; -} - - -static void -add_deco (GdmWindow *w, gboolean is_mapped) -{ - int x, y; - Window root; - unsigned int width, height, border, depth; - XWindowAttributes attribs = { 0, }; - int black; - - trap_push (); - - XGetWindowAttributes (wm_disp, w->win, &attribs); - XSelectInput (wm_disp, w->win, - attribs.your_event_mask | - PropertyChangeMask); - - if ( ! has_deco (w->win)) { - trap_pop (); - return; - } - - XGetGeometry (wm_disp, w->win, - &root, &x, &y, &width, &height, &border, &depth); - - black = BlackPixel (wm_disp, DefaultScreen (wm_disp)); - - /* all but the login window has shadows */ - if (w->win != wm_login_window) { - w->shadow = XCreateSimpleWindow (wm_disp, - wm_root, - x + 4, y + 4, - width + 2 + 2 * border, - height + 2 + 2 * border, - 0, - black, black); - - XMapWindow (wm_disp, w->shadow); - } - - w->deco = XCreateSimpleWindow (wm_disp, - wm_root, - x - 1, y - 1, - width + 2 + 2 * border, - height + 2 + 2 * border, - 0, - black, black); - - XGetWindowAttributes (wm_disp, w->deco, &attribs); - XSelectInput (wm_disp, w->deco, - attribs.your_event_mask | - EnterWindowMask | - PropertyChangeMask | - SubstructureNotifyMask | - SubstructureRedirectMask); - - XMapWindow (wm_disp, w->deco); - - XSync (wm_disp, False); - trap_pop (); - - trap_push (); - XReparentWindow (wm_disp, w->win, w->deco, 1, 1); - XSync (wm_disp, False); - if (trap_pop () == 0) { - if (is_mapped) { - /* Ignore the next unmap/map, but only - * if reparent window really succeeded */ - w->ignore_next_map++; - w->ignore_next_unmap++; - } - } -} - -static gboolean -is_wm_class (XClassHint *hint, const char *string, int len) -{ - if (len > 0) { - return ((hint->res_name != NULL && - strncmp (hint->res_name, string, len) == 0) || - (hint->res_class != NULL && - strncmp (hint->res_class, string, len) == 0)); - } else { - return ((hint->res_name != NULL && - strcmp (hint->res_name, string) == 0) || - (hint->res_class != NULL && - strcmp (hint->res_class, string) == 0)); - } -} - -static GdmWindow * -add_window (Window w, gboolean center, gboolean is_mapped) -{ - GdmWindow *gw; - - gw = find_window (w, FALSE); - if (gw == NULL) { - XClassHint hint = { NULL, NULL }; - XWMHints *wmhints; - int x, y; - Window root; - unsigned int width, height, border, depth; - - gw = g_new0 (GdmWindow, 1); - gw->win = w; - windows = g_list_prepend (windows, gw); - - trap_push (); - - /* add "centering" */ - gw->ignore_size_hints = FALSE; - gw->center = center; - gw->recenter = FALSE; - gw->takefocus = TRUE; - - gw->ignore_next_map = 0; - gw->ignore_next_unmap = 0; - - wmhints = XGetWMHints (wm_disp, w); - if (wmhints != NULL) { - /* NoInput windows */ - if ((wmhints->flags & InputHint) && - ! wmhints->input) { - gw->takefocus = FALSE; - } - XFree (wmhints); - } - - /* hack, set USpos/size on login window */ - if (w == wm_login_window) { - long ret; - XSizeHints hints; - XGetWMNormalHints (wm_disp, w, &hints, &ret); - hints.flags |= USPosition | USSize; - XSetWMNormalHints (wm_disp, w, &hints); - gw->center = FALSE; - gw->recenter = FALSE; - } else if (XGetClassHint (wm_disp, w, &hint)) { - if (is_wm_class (&hint, "gdm", 3)) { - gw->ignore_size_hints = TRUE; - gw->center = TRUE; - gw->recenter = TRUE; - } else if (is_wm_class (&hint, "gkrellm", 0)) { - /* hack, gkrell is stupid and doesn't set - * right hints, such as USPosition and other - * such stuff */ - gw->center = FALSE; - gw->recenter = FALSE; - } else if (is_wm_class (&hint, "xscribble", 0)) { - /* hack, xscribble mustn't take focus */ - gw->takefocus = FALSE; - } - if (hint.res_name != NULL) - XFree (hint.res_name); - if (hint.res_class != NULL) - XFree (hint.res_class); - } - - XGetGeometry (wm_disp, w, - &root, &x, &y, &width, &height, &border, &depth); - - gw->x = x; - gw->y = x; - - center_x_window (gw, w, w); - add_deco (gw, is_mapped); - - XAddToSaveSet (wm_disp, w); - - trap_pop (); - } - return gw; -} - -static void -remove_window (Window w) -{ - GList *li = find_window_list (w, FALSE); - - if (w == wm_focus_window) - wm_focus_window = None; - - if (li != NULL) { - GdmWindow *gw = li->data; - - li->data = NULL; - - trap_push (); - - XRemoveFromSaveSet (wm_disp, w); - - gw->win = None; - - if (gw->deco != None) { - XDestroyWindow (wm_disp, gw->deco); - gw->deco = None; - } - if (gw->shadow != None) { - XDestroyWindow (wm_disp, gw->shadow); - gw->shadow = None; - } - trap_pop (); - - windows = g_list_remove_link (windows, li); - g_list_free_1 (li); - - g_free (gw); - } -} - -static void -revert_focus_to_login (void) -{ - if (wm_login_window != None) { - gdm_wm_focus_window (wm_login_window); - } -} - -static void -add_all_current_windows (void) -{ - Window *children = NULL; - Window xparent, xroot; - guint size = 0; - - gdk_flush (); - XSync (wm_disp, False); - trap_push (); - - XGrabServer (wm_disp); - - if (XQueryTree (wm_disp, - wm_root, - &xroot, - &xparent, - &children, - &size)) { - int i; - - for (i = 0; i < size; i++) { - XWindowAttributes attribs = {0}; - - XGetWindowAttributes (wm_disp, - children[i], - &attribs); - - if ( ! attribs.override_redirect && - attribs.map_state != IsUnmapped) { - add_window (children[i], - FALSE /*center*/, - TRUE /* is_mapped */); - } - } - - if (children != NULL) - XFree (children); - } - - XUngrabServer (wm_disp); - - trap_pop (); -} - -static void -reparent_to_root (GdmWindow *gw) -{ - /* only if reparented */ - if (gw->deco != None) { - trap_push (); - - XReparentWindow (wm_disp, gw->win, wm_root, gw->x, gw->y); - XSync (wm_disp, False); - - trap_pop (); - } -} - -static void -shadow_follow (GdmWindow *gw) -{ - int x, y; - Window root; - unsigned int width, height, border, depth; - - if (gw->shadow == None) - return; - - trap_push (); - - XGetGeometry (wm_disp, gw->deco, - &root, &x, &y, &width, &height, &border, &depth); - - x += 5; - y += 5; - - XMoveResizeWindow (wm_disp, gw->shadow, x, y, width, height); - - trap_pop (); -} - -static void -event_process (XEvent *ev) -{ - GdmWindow *gw; - Window w; - XWindowChanges wchanges; - - trap_push (); - - switch (ev->type) { - case MapRequest: - w = ev->xmaprequest.window; - gw = find_window (w, FALSE); - if (gw == NULL) { - if (ev->xmaprequest.parent == wm_root) { - XGrabServer (wm_disp); - gw = add_window (w, - TRUE /* center */, - FALSE /* is_mapped */); - XUngrabServer (wm_disp); - } - } - XMapWindow (wm_disp, w); - break; - case ConfigureRequest: - XGrabServer (wm_disp); - w = ev->xconfigurerequest.window; - gw = find_window (w, FALSE); - wchanges.border_width = ev->xconfigurerequest.border_width; - wchanges.sibling = ev->xconfigurerequest.above; - wchanges.stack_mode = ev->xconfigurerequest.detail; - if (gw == NULL || - gw->deco == None) { - wchanges.x = ev->xconfigurerequest.x; - wchanges.y = ev->xconfigurerequest.y; - } else { - wchanges.x = 1; - wchanges.y = 1; - } - wchanges.width = ev->xconfigurerequest.width; - wchanges.height = ev->xconfigurerequest.height; - XConfigureWindow (wm_disp, - w, - ev->xconfigurerequest.value_mask, - &wchanges); - if (gw != NULL) { - gw->x = ev->xconfigurerequest.x; - gw->y = ev->xconfigurerequest.y; - if (gw->deco != None) { - wchanges.x = ev->xconfigurerequest.x - 1; - wchanges.y = ev->xconfigurerequest.y - 1; - wchanges.width = ev->xconfigurerequest.width + 2 - + 2*ev->xconfigurerequest.border_width;; - wchanges.height = ev->xconfigurerequest.height + 2 - + 2*ev->xconfigurerequest.border_width;; - wchanges.border_width = 0; - XConfigureWindow (wm_disp, - gw->deco, - ev->xconfigurerequest.value_mask, - &wchanges); - center_x_window (gw, gw->deco, gw->win); - } else { - center_x_window (gw, gw->win, gw->win); - } - shadow_follow (gw); - } - XUngrabServer (wm_disp); - break; - case CirculateRequest: - w = ev->xcirculaterequest.window; - gw = find_window (w, FALSE); - if (gw == NULL) { - if (ev->xcirculaterequest.place == PlaceOnTop) - XRaiseWindow (wm_disp, w); - else - XLowerWindow (wm_disp, w); - } else { - if (ev->xcirculaterequest.place == PlaceOnTop) { - if (gw->shadow != None) - XRaiseWindow (wm_disp, gw->shadow); - if (gw->deco != None) - XRaiseWindow (wm_disp, gw->deco); - else - XRaiseWindow (wm_disp, gw->win); - } else { - if (gw->deco != None) - XLowerWindow (wm_disp, gw->deco); - else - XLowerWindow (wm_disp, gw->win); - if (gw->shadow != None) - XLowerWindow (wm_disp, gw->shadow); - } - } - break; - case MapNotify: - w = ev->xmap.window; - gw = find_window (w, FALSE); - if (gw != NULL) { - if (gw->ignore_next_map > 0) { - gw->ignore_next_map --; - break; - } - if ( ! ev->xmap.override_redirect && - focus_new_windows) { - gdm_wm_focus_window (w); - } - } - break; - case UnmapNotify: - w = ev->xunmap.window; - gw = find_window (w, FALSE); - if (gw != NULL) { - if (gw->ignore_next_unmap > 0) { - gw->ignore_next_unmap --; - break; - } - XGrabServer (wm_disp); - if (gw->deco != None) - XUnmapWindow (wm_disp, gw->deco); - if (gw->shadow != None) - XUnmapWindow (wm_disp, gw->shadow); - reparent_to_root (gw); - remove_window (w); - XDeleteProperty (wm_disp, w, XA_WM_STATE); - if (w != wm_login_window) - revert_focus_to_login (); - XUngrabServer (wm_disp); - } - break; - case DestroyNotify: - w = ev->xdestroywindow.window; - gw = find_window (w, FALSE); - if (gw != NULL) { - XGrabServer (wm_disp); - remove_window (w); - if (w != wm_login_window) - revert_focus_to_login (); - XUngrabServer (wm_disp); - } - break; - case EnterNotify: - w = ev->xcrossing.window; - gw = find_window (w, TRUE); - if (gw != NULL) - gdm_wm_focus_window (gw->win); - break; - case PropertyNotify: - if (ev->xproperty.atom == XA_NET_WM_STRUT) - { - gdm_wm_update_struts (ev->xproperty.display, - ev->xproperty.window); - constrain_all_windows (); - } - break; - default: - break; - } - - trap_pop (); -} - -/* following partly stolen from gdk */ -static GPollFD event_poll_fd; - -static gboolean -event_prepare (GSource *source, - gint *timeout) -{ - *timeout = -1; - return XPending (wm_disp) > 0; -} - -static gboolean -event_check (GSource *source) -{ - if (event_poll_fd.revents & G_IO_IN) { - return XPending (wm_disp) > 0; - } else { - return FALSE; - } -} - -static void -process_events (void) -{ - while (XPending (wm_disp) > 0) { - XEvent ev; - XNextEvent (wm_disp, &ev); - event_process (&ev); - } -} - -static gboolean -event_dispatch (GSource *source, - GSourceFunc callback, - gpointer user_data) -{ - process_events (); - - return TRUE; -} - -static GSourceFuncs event_funcs = { - event_prepare, - event_check, - event_dispatch -}; - -void -gdm_wm_init (Window login_window) -{ - XWindowAttributes attribs = { 0, }; - GSource *source; - - wm_login_window = login_window; - - if (wm_disp != NULL) { - return; - } - - wm_disp = XOpenDisplay (gdk_get_display ()); - if (wm_disp == NULL) { - /* EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEK! */ - wm_disp = GDK_DISPLAY (); - return; - } - - trap_push (); - - XA_WM_PROTOCOLS = XInternAtom (wm_disp, "WM_PROTOCOLS", False); - XA_WM_STATE = XInternAtom (wm_disp, "WM_STATE", False); - XA_WM_TAKE_FOCUS = XInternAtom (wm_disp, "WM_TAKE_FOCUS", False); - - XA_COMPOUND_TEXT = XInternAtom (wm_disp, "COMPOUND_TEXT", False); - XA_NET_WM_STRUT = XInternAtom (wm_disp, "_NET_WM_STRUT", False); - - wm_root = DefaultRootWindow (wm_disp); - - /* set event mask for events on root window */ - XGetWindowAttributes (wm_disp, wm_root, &attribs); - XSelectInput (wm_disp, wm_root, - attribs.your_event_mask | - SubstructureNotifyMask | - SubstructureRedirectMask); - - if (trap_pop () != 0) - return; - - trap_push (); - - add_all_current_windows (); - - source = g_source_new (&event_funcs, sizeof (GSource)); - - event_poll_fd.fd = ConnectionNumber (wm_disp); - event_poll_fd.events = G_IO_IN; - - g_source_add_poll (source, &event_poll_fd); - g_source_set_priority (source, GDK_PRIORITY_EVENTS); - g_source_set_can_recurse (source, FALSE); - g_source_attach (source, NULL); - - trap_pop (); -} - -void -gdm_wm_focus_new_windows (gboolean focus) -{ - focus_new_windows = focus; -} - -void -gdm_wm_no_login_focus_push (void) -{ - /* it makes not sense for this to be false then */ - focus_new_windows = TRUE; - no_focus_login++; -} - -void -gdm_wm_no_login_focus_pop (void) -{ - no_focus_login --; - - if (no_focus_login == 0 && - wm_focus_window == None && - wm_login_window != None) - gdm_wm_focus_window (wm_login_window); -} - -void -gdm_wm_get_window_pos (Window window, int *xp, int *yp) -{ - int x, y; - Window root; - unsigned int width, height, border, depth; - GdmWindow *gw; - - trap_push (); - - gw = find_window (window, TRUE); - - if (gw == NULL) { - XGetGeometry (wm_disp, window, - &root, &x, &y, &width, &height, &border, &depth); - - *xp = x; - *yp = y; - - trap_pop (); - - return; - } - - if (gw->deco != None) { - XGetGeometry (wm_disp, gw->deco, - &root, &x, &y, &width, &height, &border, &depth); - *xp = x + 1; - *yp = y + 1; - } else { - XGetGeometry (wm_disp, gw->win, - &root, &x, &y, &width, &height, &border, &depth); - *xp = x; - *yp = y; - } - - trap_pop (); -} - -void -gdm_wm_move_window_now (Window window, int x, int y) -{ - GdmWindow *gw; - - trap_push (); - - gw = find_window (window, TRUE); - - if (gw == NULL) { - XMoveWindow (wm_disp, window, x, y); - - XSync (wm_disp, False); - trap_pop (); - return; - } - - if (gw->deco != None) - XMoveWindow (wm_disp, gw->deco, x - 1, y - 1); - else - XMoveWindow (wm_disp, gw->win, x, y); - if (gw->shadow != None) - XMoveWindow (wm_disp, gw->deco, x + 4, y + 4); - - XSync (wm_disp, False); - trap_pop (); -} - -void -gdm_wm_save_wm_order (void) -{ - Window *children = NULL; - Window xparent, xroot; - guint size = 0; - int dlen = 0; - unsigned long *data; - - gdk_flush (); - XSync (wm_disp, False); - trap_push (); - - XGrabServer (wm_disp); - - if (XQueryTree (wm_disp, - wm_root, - &xroot, - &xparent, - &children, - &size)) { - int i; - Atom atom; - data = g_new0 (unsigned long, size); - - for (i = 0; i < size; i++) { - GdmWindow *gw = find_window (children[i], TRUE); - - /* Ignore unknowns and shadows */ - if (gw == NULL || - gw->shadow == children[i]) - continue; - - if (gw->win == wm_login_window) { - /* Empty spot in the list signifies the - * login window */ - data [dlen++] = None; - } else { - data [dlen++] = gw->win; - } - } - - atom = XInternAtom (wm_disp, "GDMWM_WINDOW_ORDER", False); - - XChangeProperty (wm_disp, wm_root, - atom, - XA_CARDINAL, - 32, - PropModeReplace, - (unsigned char *)data, - dlen); - - if (children != NULL) - XFree (children); - g_free (data); - } - - XUngrabServer (wm_disp); - - trap_pop (); -} - -static gboolean -focus_win (gpointer data) -{ - Window focus = (Window)data; - focus_new_windows = TRUE; - gdm_wm_focus_window (focus); - return FALSE; -} - -void -gdm_wm_restore_wm_order (void) -{ - guint32 *data; - Window focus = None; - int size; - int i; - Atom atom; - - gdk_flush (); - XSync (wm_disp, False); - - process_events (); - - gdk_flush (); - XSync (wm_disp, False); - trap_push (); - - XGrabServer (wm_disp); - - atom = XInternAtom (wm_disp, "GDMWM_WINDOW_ORDER", False); - - data = get_typed_property_data (wm_disp, wm_root, - atom, XA_CARDINAL, - &size, 32); - - if (data != NULL) { - for (i = 0; i < size/4; i++) { - GdmWindow *gw; - if (data[i] == None) - gw = find_window (wm_login_window, TRUE); - else - gw = find_window (data[i], TRUE); - - if (gw != NULL) { - focus = gw->win; - if (gw->shadow != None) - XRaiseWindow (wm_disp, gw->shadow); - if (gw->deco != None) - XRaiseWindow (wm_disp, gw->deco); - else - XRaiseWindow (wm_disp, gw->win); - } - } - - g_free (data); - } - - XUngrabServer (wm_disp); - - trap_pop (); - - process_events (); - - if (focus != None) { - /* let us hit the main loop first */ - g_idle_add (focus_win, (gpointer)focus); - } -} - -static void -setup_cursor (GdkCursorType type) -{ - GdkCursor *cursor = gdk_cursor_new (type); - gdk_window_set_cursor (gdk_get_default_root_window (), cursor); - gdk_cursor_unref (cursor); -} - -void -gdm_wm_show_info_msg_dialog (const gchar *msg_file, - const gchar *msg_font) -{ - GtkWidget *dialog, *label; - gchar *InfoMsg; - gsize InfoMsgLength; - - if ((msg_file == NULL || msg_file[0] == '\0') || - ! g_file_test (msg_file, G_FILE_TEST_EXISTS) || - ! g_file_get_contents (msg_file, &InfoMsg, &InfoMsgLength, NULL)) - return; - - if (InfoMsgLength <= 0) { - g_free (InfoMsg); - return; - } - - gdm_wm_focus_new_windows (TRUE); - dialog = gtk_dialog_new_with_buttons (NULL /* Message */, - NULL /* parent */, GTK_DIALOG_MODAL | - GTK_DIALOG_DESTROY_WITH_PARENT, - GTK_STOCK_OK, GTK_RESPONSE_OK, - NULL); - label = gtk_label_new (InfoMsg); - - if (msg_font && strlen (msg_font) > 0) { - PangoFontDescription *GdmInfoMsgFontDesc = pango_font_description_from_string (msg_font); - if (GdmInfoMsgFontDesc) { - gtk_widget_modify_font (label, GdmInfoMsgFontDesc); - pango_font_description_free (GdmInfoMsgFontDesc); - } - } - - gtk_container_add (GTK_CONTAINER (GTK_DIALOG (dialog)->vbox), label); - gtk_widget_show_all (dialog); - gdm_wm_center_window (GTK_WINDOW (dialog)); - - setup_cursor (GDK_LEFT_PTR); - - gdm_wm_no_login_focus_push (); - gtk_dialog_run (GTK_DIALOG (dialog)); - gtk_widget_destroy (dialog); - gdm_wm_no_login_focus_pop (); - - g_free (InfoMsg); -} - -static GtkWidget * -hig_dialog_new (GtkWindow *parent, - GtkDialogFlags flags, - GtkMessageType type, - GtkButtonsType buttons, - const gchar *primary_message, - const gchar *secondary_message) -{ - GtkWidget *dialog; - - dialog = gtk_message_dialog_new (GTK_WINDOW (parent), - GTK_DIALOG_DESTROY_WITH_PARENT, - type, - buttons, - "%s", primary_message); - - gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), - "%s", secondary_message); - - gtk_window_set_title (GTK_WINDOW (dialog), ""); - gtk_container_set_border_width (GTK_CONTAINER (dialog), 5); - gtk_box_set_spacing (GTK_BOX (GTK_DIALOG (dialog)->vbox), 14); - - return dialog; -} - -void -gdm_wm_message_dialog (const gchar *primary_message, - const gchar *secondary_message) -{ - GtkWidget *req = NULL; - - /* we should be now fine for focusing new windows */ - gdm_wm_focus_new_windows (TRUE); - - req = hig_dialog_new (NULL /* parent */, - GTK_DIALOG_MODAL /* flags */, - GTK_MESSAGE_INFO, - GTK_BUTTONS_OK, - primary_message, - secondary_message); - - gdm_wm_center_window (GTK_WINDOW (req)); - - gdm_wm_no_login_focus_push (); - gtk_dialog_run (GTK_DIALOG (req)); - gtk_widget_destroy (req); - gdm_wm_no_login_focus_pop (); -} - -gint -gdm_wm_query_dialog (const gchar *primary_message, - const gchar *secondary_message, - const char *posbutton, - const char *negbutton, - gboolean has_cancel) -{ - int ret; - GtkWidget *req; - GtkWidget *button; - - /* we should be now fine for focusing new windows */ - gdm_wm_focus_new_windows (TRUE); - - req = hig_dialog_new (NULL /* parent */, - GTK_DIALOG_MODAL /* flags */, - GTK_MESSAGE_QUESTION, - GTK_BUTTONS_NONE, - primary_message, - secondary_message); - - if (negbutton != NULL) { - button = gtk_button_new_from_stock (negbutton); - gtk_dialog_add_action_widget (GTK_DIALOG (req), button, GTK_RESPONSE_NO); - GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); - gtk_widget_show (button); - } - - if (has_cancel == TRUE) { - button = gtk_button_new_from_stock (GTK_STOCK_CANCEL); - gtk_dialog_add_action_widget (GTK_DIALOG (req), button, GTK_RESPONSE_CANCEL); - GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); - gtk_widget_show (button); - } - - if (posbutton != NULL) { - button = gtk_button_new_from_stock (posbutton); - gtk_dialog_add_action_widget (GTK_DIALOG (req), button, GTK_RESPONSE_YES); - GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); - gtk_widget_show (button); - } - - if (posbutton != NULL) - gtk_dialog_set_default_response (GTK_DIALOG (req), GTK_RESPONSE_YES); - else if (negbutton != NULL) - gtk_dialog_set_default_response (GTK_DIALOG (req), GTK_RESPONSE_NO); - else if (has_cancel) - gtk_dialog_set_default_response (GTK_DIALOG (req), GTK_RESPONSE_CANCEL); - - gdm_wm_center_window (GTK_WINDOW (req)); - - gdm_wm_no_login_focus_push (); - ret = gtk_dialog_run (GTK_DIALOG (req)); - gdm_wm_no_login_focus_pop (); - gtk_widget_destroy (req); - - return ret; -} - -gint -gdm_wm_warn_dialog (const gchar *primary_message, - const gchar *secondary_message, - const char *posbutton, - const char *negbutton, - gboolean has_cancel) -{ - int ret; - GtkWidget *req; - GtkWidget *button; - - /* we should be now fine for focusing new windows */ - gdm_wm_focus_new_windows (TRUE); - - req = hig_dialog_new (NULL /* parent */, - GTK_DIALOG_MODAL /* flags */, - GTK_MESSAGE_WARNING, - GTK_BUTTONS_NONE, - primary_message, - secondary_message); - - if (negbutton != NULL) { - button = gtk_button_new_from_stock (negbutton); - gtk_dialog_add_action_widget (GTK_DIALOG (req), button, GTK_RESPONSE_NO); - GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); - gtk_widget_show (button); - } - - if (has_cancel == TRUE) { - button = gtk_button_new_from_stock (GTK_STOCK_CANCEL); - gtk_dialog_add_action_widget (GTK_DIALOG (req), button, GTK_RESPONSE_CANCEL); - GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); - gtk_widget_show (button); - } - - if (posbutton != NULL) { - button = gtk_button_new_from_stock (posbutton); - gtk_dialog_add_action_widget (GTK_DIALOG (req), button, GTK_RESPONSE_YES); - GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT); - gtk_widget_show (button); - } - - if (posbutton != NULL) - gtk_dialog_set_default_response (GTK_DIALOG (req), GTK_RESPONSE_YES); - else if (negbutton != NULL) - gtk_dialog_set_default_response (GTK_DIALOG (req), GTK_RESPONSE_NO); - else if (has_cancel) - gtk_dialog_set_default_response (GTK_DIALOG (req), GTK_RESPONSE_CANCEL); - - gdm_wm_center_window (GTK_WINDOW (req)); - - gdm_wm_no_login_focus_push (); - ret = gtk_dialog_run (GTK_DIALOG (req)); - gdm_wm_no_login_focus_pop (); - gtk_widget_destroy (req); - - return ret; -} - -/* EOF */ diff --git a/libgreeter/gdmwm.h b/libgreeter/gdmwm.h deleted file mode 100644 index 6a3e7a08..00000000 --- a/libgreeter/gdmwm.h +++ /dev/null @@ -1,101 +0,0 @@ -/* GDM - The Gnome Display Manager - * Copyright (C) 1999, 2000 Martin K. Petersen <mkp@mkp.net> - * - * This file Copyright (c) 2001 George Lebl - * - * 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 GDM_WM_H -#define GDM_WM_H - -#include <X11/X.h> -#include <X11/Xlib.h> -#include <gdk/gdkx.h> -#include <gtk/gtk.h> - -/* - * Login window will be given focus every time a window - * is killed - */ -void gdm_wm_init (Window login_window); - -/* - * By default new windows aren't given focus, you have to - * call this function with a TRUE - */ -void gdm_wm_focus_new_windows (gboolean focus); - -void gdm_wm_focus_window (Window window); - -/* Movement for the impatient */ -void gdm_wm_move_window_now (Window window, - int x, - int y); -void gdm_wm_get_window_pos (Window window, - int *xp, - int *yp); - -/* Refuse to focus the login window, poor mans modal dialogs */ -void gdm_wm_no_login_focus_push (void); -void gdm_wm_no_login_focus_pop (void); - -/* - * Xinerama support stuff - */ -void gdm_wm_screen_init (int cur_screen_num); -void gdm_wm_set_screen (int cur_screen_num); - -/* - * Not really a WM function, center a gtk window on current screen - * by setting uposition - */ -void gdm_wm_center_window (GtkWindow *cw); - -/* Center mouse pointer - */ -void gdm_wm_center_cursor (void); - -/* - * Save and restore stacking order, useful for restarting - * the greeter - */ -void gdm_wm_save_wm_order (void); -void gdm_wm_restore_wm_order (void); - -/* Dialogs */ -gint gdm_wm_query_dialog (const gchar *primary_message, - const gchar *secondary_message, - const char *posbutton, - const char *negbutton, - gboolean has_cancel); -gint gdm_wm_warn_dialog (const gchar *primary_message, - const gchar *secondary_message, - const char *posbutton, - const char *negbutton, - gboolean has_cancel); -void gdm_wm_show_info_msg_dialog (const gchar *msg_file, - const gchar *msg_font); -void gdm_wm_message_dialog (const gchar *primary_message, - const gchar *secondary_message); - -/* Access to the screen structures */ -extern GdkRectangle *gdm_wm_allscreens; -extern int gdm_wm_screens; -extern GdkRectangle gdm_wm_screen; - -#endif /* GDM_WM_H */ - -/* EOF */ diff --git a/po/ChangeLog b/po/ChangeLog index a0133714..0b9cd8fc 100644 --- a/po/ChangeLog +++ b/po/ChangeLog @@ -4,6 +4,12 @@ * POTFILES.in: +2007-10-04 William Jon McCann <mccann@jhu.edu> + + reviewed by: <delete if not using a buddy> + + * POTFILES.in: + 2007-10-03 William Jon McCann <mccann@jhu.edu> * POTFILES.in: Add new files. diff --git a/po/POTFILES.in b/po/POTFILES.in index ba4dc33b..308d2a88 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -13,13 +13,11 @@ common/gdm-signal-handler.c common/test-log.c common/test-settings-client.c common/test-settings-server.c -common/ve-signal.c config/default.desktop.in config/ssh.desktop.in.in daemon/auth.c daemon/choose.c daemon/factory-slave-main.c -daemon/filecheck.c daemon/fstype.c daemon/gdm-display.c daemon/gdm-display-store.c @@ -60,6 +58,3 @@ libgreeter/gdmlanguages.c libgreeter/gdmsession.c libgreeter/gdmwm.c utils/gdm-dmx-reconnect-proxy.c -utils/gdmopen.c -utils/gdmprefetch.c -utils/gdmtranslate.c diff --git a/utils/Makefile.am b/utils/Makefile.am index 4fd77894..19dc4201 100644 --- a/utils/Makefile.am +++ b/utils/Makefile.am @@ -1,16 +1,11 @@ NULL = -DEFS = @DEFS@ -DGDM_CONFIG_FILE=\"$(gdmconfdir)/gdm.conf\" \ - -DGDM_FACTORY_CONFIG_FILE=\"$(gdmconfdir)/factory-gdm.conf\" \ - -DGDM_GLADE_DIR=\"@datadir@/gdm\" - INCLUDES = \ -I. \ -I.. \ - -I$(top_srcdir)/daemon \ - -I$(top_srcdir)/vicious-extensions \ -DGNOMELOCALEDIR=\""$(datadir)/locale"\" \ - $(UTILS_CFLAGS) + $(UTILS_CFLAGS) \ + $(NULL) edit = sed \ -e 's|@sbindir[@]|$(sbindir)|g' \ @@ -24,9 +19,6 @@ gdm-restart: gdm-restart.in Makefile $(edit) $< >$@ gdm-safe-restart: gdm-safe-restart.in Makefile $(edit) $< >$@ -gdmsetup: gdmsetup-security.in - $(edit) <$(srcdir)/gdmsetup-security.in >gdmsetup - sbin_SCRIPTS = \ gdm-stop \ @@ -35,44 +27,15 @@ sbin_SCRIPTS = \ $(NULL) EXTRA_DIST = \ - gdm-ssh-session \ gdm-stop.in \ gdm-restart.in \ gdm-safe-restart.in \ - gdmsetup-pam \ - gdmsetup-security.in \ $(NULL) -libexec_SCRIPTS = \ - @GDMSSHSESSION@ - -libexec_PROGRAMS = \ - @GDMOPEN@ \ - @GDMPREFETCH@ \ - gdmtranslate - if DMX_SUPPORT bin_PROGRAMS = gdm-dmx-reconnect-proxy endif -EXTRA_SCRIPTS = gdm-ssh-session -EXTRA_PROGRAMS = gdmopen gdmprefetch - -gdmtranslate_SOURCES = \ - gdmtranslate.c - -gdmopen_SOURCES = \ - gdmopen.c - -gdmprefetch_SOURCES = \ - gdmprefetch.c - -gdmopen_LDADD = \ - $(INTLLIBS) - -gdmtranslate_LDADD = \ - $(INTLLIBS) - if DMX_SUPPORT gdm_dmx_reconnect_proxy_SOURCES = \ gdm-dmx-reconnect-proxy.c @@ -85,23 +48,10 @@ gdm_dmx_reconnect_proxy_LDADD = \ $(DMX_LIBS) endif -if CONSOLE_HELPER -cappsdir = $(PAM_PREFIX)/security/console.apps -capps_DATA = gdmsetup - -install-data-local: - $(mkinstalldirs) $(DESTDIR)$(PAM_PREFIX)/pam.d - $(INSTALL_DATA) $(srcdir)/gdmsetup-pam $(DESTDIR)$(PAM_PREFIX)/pam.d/gdmsetup -else -install-data-local: -endif - CLEANFILES = \ - gdmsetup-security \ $(NULL) DISTCLEANFILES = \ - gdmsetup \ gdm-stop \ gdm-restart \ gdm-safe-restart \ diff --git a/utils/gdm-ssh-session b/utils/gdm-ssh-session deleted file mode 100644 index b70af907..00000000 --- a/utils/gdm-ssh-session +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -ZENITY=`which zenity` -TARGETHOST=`$ZENITY --title "Host to connect to" --entry --text "Enter the name of the host you want to log in to"` -# @@@ should probably get a user name too; -# for now can bet set using the $USERNAME@ convention -# @@@ should it do an ssh-add so the user doesn't have to enter its passphrase again? -ssh -A -X -T -n "$TARGETHOST" /etc/X11/Xsession diff --git a/utils/gdmmktemp.c b/utils/gdmmktemp.c deleted file mode 100644 index dba23650..00000000 --- a/utils/gdmmktemp.c +++ /dev/null @@ -1,36 +0,0 @@ -/* - * gdmmkstemp.c by the Queen of England - * A utility to do mkstemp from a script. - * - * Copyright (c) 2001 by Queen of England - * - * 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. - */ - -#include "config.h" -#include <stdio.h> -#include <stdlib.h> -#include <sys/types.h> -#include <sys/stat.h> -#include <unistd.h> - - -int -main (int argc, char *argv[]) -{ - char template[] = "/tmp/gdm-XXXXXX"; - int i; - - i = mkstemp (template); - if (i < 0) - return 1; - - fchmod (i, 0600); - - printf ("%s\n", template); - close (i); - return 0; -} diff --git a/utils/gdmopen.c b/utils/gdmopen.c deleted file mode 100644 index b49f51af..00000000 --- a/utils/gdmopen.c +++ /dev/null @@ -1,254 +0,0 @@ -/* - * gdmopen.c by the Queen of England, based upon original open. - * Simplified for the purposes of gdm. All useless (to me) - * functionality stripped. Also returns what the command returns. - * Return of 66 means error with open. - * - * Original header: - * - * open.c open a vt to run a new command (or shell). - * - * Copyright (c) 1994 by Jon Tombs <jon@gtex02.us.es> - * - * 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. - */ - -#include "config.h" -#include <stdio.h> -#include <signal.h> -#include <unistd.h> -#include <errno.h> -#include <stdlib.h> -#include <string.h> -#include <fcntl.h> -#include <dirent.h> -#include <pwd.h> -#include <sys/ioctl.h> -#include <sys/stat.h> -#include <sys/vt.h> -#include <sys/types.h> -#include <sys/wait.h> - -#define IGNORE_EINTR(expr) \ - do { \ - errno = 0; \ - expr; \ - } while (errno == EINTR); - -#ifndef FALSE -#define FALSE 0 -#define TRUE !FALSE -#endif - - -/* - * Where your VTs are hidden - */ -#ifdef __linux__ -#define VTNAME "/dev/tty%d" -#endif - -#ifdef ESIX_5_3_2_D -#define VTBASE "/dev/vt%02d" -#endif - -const char *GDMOPENversion = "gdmopen " VERSION " simplified (was: open: 1.4 (c) Jon Tombs 1994)"; - -#ifndef VTNAME -#error vt device name must be defined in open.c -#endif - -static pid_t child_pid = -1; -struct vt_stat vt; -static int vtno; -static int fd = 0; -static int do_switchback = FALSE; - -static void -sighandler (int sig) -{ - if (child_pid > 1) { - if (kill (child_pid, sig) == 0) - waitpid (child_pid, NULL, 0); - } - - if (do_switchback) { - /* Switch back... */ - (void) ioctl(fd, VT_ACTIVATE, vt.v_active); - /* wait to be really sure we have switched */ - (void) ioctl(fd, VT_WAITACTIVE, vt.v_active); - } - - /* Kill myself with this signal */ - signal (sig, SIG_DFL); - raise (sig); -} - -int -main (int argc, char *argv[]) -{ - char vtname[256]; - int status; - int cmd_start = 1; - char *command = NULL; - - if (getuid () != geteuid () || - getuid () != 0) { - fprintf (stderr, "gdmopen: Only root wants to run me\n"); - return 66; - } - - signal (SIGTERM, sighandler); - signal (SIGINT, sighandler); - signal (SIGHUP, sighandler); - - if (argc <= 1) { - fprintf (stderr, "gdmopen: must supply a command!\n"); - return 66; - } - - command = argv[1]; - - if (strcmp (argv[1], "-l") == 0) { - char *p; - if (argc <= 2) { - fprintf (stderr, "gdmopen: must supply a command!\n"); - return 66; - } - /* prepend '-' and start the command at - * argument 2 */ - cmd_start = 2; - command = argv[2]; - argv[2] = malloc (strlen (command) + 2); - if (argv[2] == NULL) { - fprintf (stderr, "gdmopen: cannot allocate memory!\n"); - return 66; - } - p = strrchr (command, '/'); - if (p != NULL) { - /* make it "-basename" */ - strcpy (argv[2]+1, p+1); - } else { - strcpy (argv[2]+1, command); - } - *(argv[2]) = '-'; - } - - fd = open ("/dev/console", O_WRONLY, 0); - if (fd < 0) { - perror ("gdmopen: Failed to open /dev/console"); - return 66; - } - - errno = 0; - if ((ioctl(fd, VT_OPENQRY, &vtno) < 0) || (vtno == -1)) { - perror ("gdmopen: Cannot find a free VT"); - IGNORE_EINTR (close (fd)); - return 66; - } - - if (ioctl(fd, VT_GETSTATE, &vt) < 0) { - perror ("gdmopen: can't get VTstate"); - IGNORE_EINTR (close(fd)); - return 66; - } - - snprintf (vtname, sizeof (vtname), VTNAME, vtno); - - chown (vtname, 0, -1); - - child_pid = fork(); - if (child_pid == 0) { - char VT_NUMBER[256]; - - if (getenv ("UNSAFE_TO_TRANSLATE") != NULL && - strcmp (getenv ("UNSAFE_TO_TRANSLATE"), "yes") == 0) { - putenv ("LANG=C"); - - /* portable way to truly unset with putenv? */ - putenv ("LC_ALL="); - putenv ("LC_MESSAGES="); - putenv ("LC_ALL"); - putenv ("LC_MESSAGES"); - } - -#ifdef __linux__ - putenv ("TERM=linux"); -#endif - - snprintf (VT_NUMBER, sizeof (VT_NUMBER), "VT_NUMBER=%d", vtno); - putenv (VT_NUMBER); - - signal (SIGTERM, SIG_DFL); - signal (SIGINT, SIG_DFL); - signal (SIGHUP, SIG_DFL); - - /* leave current vt */ - if ( -#ifdef ESIX_5_3_2_D - setpgrp() < 0 -#else - setsid() < 0 -#endif - ) { - fprintf(stderr, "open: Unable to set new session (%s)\n", - strerror(errno)); - } - IGNORE_EINTR (close (0)); - IGNORE_EINTR (close (1)); - IGNORE_EINTR (close (2)); - IGNORE_EINTR (close (fd)); - - /* and grab new one */ - fd = open (vtname, O_RDWR); - if (fd < 0) { /* Shouldn't happen */ - _exit (66); /* silently die */ - } - dup(fd); - dup(fd); - - /* - * Can't tell anyone if any of these fail, so throw away - * the return values - */ - (void) ioctl(fd, VT_ACTIVATE, vtno); - /* wait to be really sure we have switched */ - (void) ioctl(fd, VT_WAITACTIVE, vtno); - -#ifdef __linux__ - /* Turn on fonts */ - IGNORE_EINTR (write (0, "\033(K", 3)); -#endif /* __linux__ */ - - execvp (command, &argv[cmd_start]); - - _exit (66); /* failed */ - } - - if (child_pid < 0) { - perror ("gdmopen: fork() error"); - return 66; - } - - do_switchback = TRUE; - - IGNORE_EINTR (waitpid (child_pid, &status, 0)); - child_pid = -1; - - do_switchback = FALSE; - - /* Switch back... */ - (void) ioctl(fd, VT_ACTIVATE, vt.v_active); - /* wait to be really sure we have switched */ - (void) ioctl(fd, VT_WAITACTIVE, vt.v_active); - - IGNORE_EINTR (close (fd)); - - if (WIFEXITED (status)) - return WEXITSTATUS (status); - else - return 66; -} diff --git a/utils/gdmprefetch.c b/utils/gdmprefetch.c deleted file mode 100644 index 3e385b7f..00000000 --- a/utils/gdmprefetch.c +++ /dev/null @@ -1,144 +0,0 @@ -/* GDM - The GNOME Display Manager - * Copyright (C) 2005 Sun Microsystems, Inc. - * - * 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 - */ -/* - * program to either force pages into memory or force them - * out (-o option) - */ -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <sys/types.h> -#include <sys/mman.h> -#include <fcntl.h> -#include <sys/stat.h> -#include <unistd.h> -#include <errno.h> -#include <strings.h> - -int out = 0; - -static int -doout(char *s) -{ - int fd; - void *map; - struct stat buf; - - if (((fd = open (s, O_RDONLY)) < 0) || - (fstat (fd, &buf) < 0) || - ((map = mmap (NULL, buf.st_size, PROT_READ, MAP_PRIVATE, fd, 0)) == - MAP_FAILED)) { - (void)close(fd); - return (-1); - } - - (void)close (fd); - (void)msync (map, buf.st_size, MS_INVALIDATE); - (void)munmap (map, buf.st_size); - return (0); -} - -#define SIZE 1024*128 - -static int -doin (char *s) -{ - int fd; - char buffer[SIZE]; - - if ((fd = open(s, O_RDONLY)) < 0) { - fprintf (stderr, "fopen: %s %s\n", strerror (errno), s); - return (-1); - } - - while (read (fd, buffer, SIZE) != 0) - ; - - (void)close (fd); - - return (0); -} - -int -main (int argc, char *argv[]) -{ - FILE *fp = 0; - int c, errflg = 0; - extern int optind, optopt; - extern char *optarg; - - while ((c = getopt (argc, argv, "o:")) != -1) { - switch (c) { - - case 'o': - out = 1; - break; - default: - errflg++; - break; - - } - } - - if (errflg) { - fprintf (stderr, "usage: %s [-o] filename [filename]\n", - argv[0]); - exit (1); - } - - - for (; optind < argc; optind++) { - if ((argv[optind][0] == '@') && ((fp = fopen (argv[optind], "r")) == 0)) { - char path[1024]; - - if ((fp = fopen (&(argv[optind][1]), "r")) == 0) { - fprintf (stderr, "fopen: %s %s\n", strerror (errno), &argv[optind][1]); - continue; - } - while (fgets (path, sizeof (path), fp) != 0) { - path[strlen(path) -1] = '\0'; - - if (path[0] == '#') { - continue; - } - - if (!out) { - doin (path); - } else { - doout (path); - } - } - fclose (fp); - fp = 0; - - } else { - if (fp != 0) { - fclose (fp); - fp = 0; - } - - if (!out) { - doin (argv[optind]); - } else { - doout (argv[optind]); - } - } - } - exit (0); -} - diff --git a/utils/gdmsetup-pam b/utils/gdmsetup-pam deleted file mode 100644 index ecb84946..00000000 --- a/utils/gdmsetup-pam +++ /dev/null @@ -1,6 +0,0 @@ -#%PAM-1.0 -auth sufficient pam_rootok.so -auth required pam_stack.so service=system-auth -session required pam_permit.so -session optional pam_xauth.so -account required pam_permit.so diff --git a/utils/gdmsetup-security.in b/utils/gdmsetup-security.in deleted file mode 100644 index 4db426ac..00000000 --- a/utils/gdmsetup-security.in +++ /dev/null @@ -1,5 +0,0 @@ -USER=root -PROGRAM=@sbindir@/gdmsetup -SESSION=true -FALLBACK=false - diff --git a/utils/gdmtranslate.c b/utils/gdmtranslate.c deleted file mode 100644 index 03814919..00000000 --- a/utils/gdmtranslate.c +++ /dev/null @@ -1,51 +0,0 @@ -#include "config.h" -#include <stdio.h> -#include <locale.h> -#include <string.h> -#include <stdlib.h> - -#define gboolean char -#define FALSE 0 -#define TRUE 1 - -#ifdef ENABLE_NLS -#include <libintl.h> -#define _(String) gettext(String) -#else /* !ENABLE_NLS */ -#define _(String) (String) -#endif - -int -main (int argc, char *argv[]) -{ - char *string; - gboolean is_utf8 = FALSE; - - if (argc == 3 && - strcmp (argv[1], "--utf8") == 0) { - string = argv[2]; - is_utf8 = TRUE; - } else if (argc == 2) { - string = argv[1]; - is_utf8 = FALSE; - } else { - fprintf (stderr, "usage: gdmtranslate [--utf8] <string to translate>\n"); - return 0; - } - - if (getenv ("UNSAFE_TO_TRANSLATE") != NULL && - strcmp (getenv ("UNSAFE_TO_TRANSLATE"), "yes") == 0) { - printf ("%s\n", string); - return 0; - } - - setlocale (LC_ALL, ""); - bindtextdomain (GETTEXT_PACKAGE, GNOMELOCALEDIR); - if (is_utf8) - bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); - textdomain (GETTEXT_PACKAGE); - - printf ("%s\n", _(string)); - - return 0; -} |