Commit 14333ef1 authored by William Jon McCann's avatar William Jon McCann Committed by William Jon McCann

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
parent dae89542
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:
......
......@@ -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 = \
......
This diff is collapsed.
......@@ -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);
......
/* -*- 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);
}
/* -*- 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 */
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' \
......
This diff is collapsed.
......@@ -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 = \
......
/* -*- 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"
......
/* -*- 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;
}
/* 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 */
......@@ -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");
......
......@@ -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);