Commit cc0647cd authored by William Jon McCann's avatar William Jon McCann Committed by William Jon McCann

Remove some more obsolete stuff. Make distcheck happy.

2007-10-04  William Jon McCann  <mccann@jhu.edu>

	* common/gdm-common-unknown-origin.c: (gdm_safe_fopen_w):
	* common/gdm-common-unknown-origin.h:
	* common/gdm-common.c:
	* configure.ac:
	* daemon/gdm-slave.c: (gdm_slave_connect_to_x11_display):
	* daemon/gdm-xdmcp-display-factory.c:
	(gdm_xdmcp_handle_indirect_query),
	(gdm_xdmcp_handle_managed_forward):
	* daemon/main.c: (main_restoreenv), (gdm_restart_now),
	(check_logdir), (check_servauthdir), (set_effective_user_group),
	(gdm_daemon_check_permissions), (gdm_daemon_change_user), (main):
	Remove some more obsolete stuff.  Make distcheck happy.


svn path=/branches/mccann-gobject/; revision=5342
parent ac350bf5
2007-10-04 William Jon McCann <mccann@jhu.edu>
* common/gdm-common-unknown-origin.c: (gdm_safe_fopen_w):
* common/gdm-common-unknown-origin.h:
* common/gdm-common.c:
* configure.ac:
* daemon/gdm-slave.c: (gdm_slave_connect_to_x11_display):
* daemon/gdm-xdmcp-display-factory.c:
(gdm_xdmcp_handle_indirect_query),
(gdm_xdmcp_handle_managed_forward):
* daemon/main.c: (main_restoreenv), (gdm_restart_now),
(check_logdir), (check_servauthdir), (set_effective_user_group),
(gdm_daemon_check_permissions), (gdm_daemon_change_user), (main):
Remove some more obsolete stuff. Make distcheck happy.
2007-10-04 William Jon McCann <mccann@jhu.edu>
* configure.ac:
......
......@@ -27,111 +27,13 @@
#include <locale.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <setjmp.h>
#include <dirent.h>
#ifdef HAVE_CRT_EXTERNS_H
#include <crt_externs.h>
#endif
#include <glib.h>
#include <glib/gi18n.h>
#include <glib/gstdio.h>
#include "gdm-common.h"
static int sigchld_blocked = 0;
static sigset_t sigchldblock_mask, sigchldblock_oldmask;
static int sigterm_blocked = 0;
static sigset_t sigtermblock_mask, sigtermblock_oldmask;
static int sigusr2_blocked = 0;
static sigset_t sigusr2block_mask, sigusr2block_oldmask;
void
gdm_sigchld_block_push (void)
{
sigchld_blocked++;
if (sigchld_blocked == 1) {
/* Set signal mask */
sigemptyset (&sigchldblock_mask);
sigaddset (&sigchldblock_mask, SIGCHLD);
sigprocmask (SIG_BLOCK, &sigchldblock_mask, &sigchldblock_oldmask);
}
}
void
gdm_sigchld_block_pop (void)
{
sigchld_blocked --;
if (sigchld_blocked == 0) {
/* Reset signal mask back */
sigprocmask (SIG_SETMASK, &sigchldblock_oldmask, NULL);
}
}
void
gdm_sigterm_block_push (void)
{
sigterm_blocked++;
if (sigterm_blocked == 1) {
/* Set signal mask */
sigemptyset (&sigtermblock_mask);
sigaddset (&sigtermblock_mask, SIGTERM);
sigaddset (&sigtermblock_mask, SIGINT);
sigaddset (&sigtermblock_mask, SIGHUP);
sigprocmask (SIG_BLOCK, &sigtermblock_mask, &sigtermblock_oldmask);
}
}
void
gdm_sigterm_block_pop (void)
{
sigterm_blocked --;
if (sigterm_blocked == 0) {
/* Reset signal mask back */
sigprocmask (SIG_SETMASK, &sigtermblock_oldmask, NULL);
}
}
void
gdm_sigusr2_block_push (void)
{
sigset_t oldmask;
if (sigusr2_blocked == 0) {
/* Set signal mask */
sigemptyset (&sigusr2block_mask);
sigaddset (&sigusr2block_mask, SIGUSR2);
sigprocmask (SIG_BLOCK, &sigusr2block_mask, &oldmask);
}
sigusr2_blocked++;
sigusr2block_oldmask = oldmask;
}
void
gdm_sigusr2_block_pop (void)
{
sigset_t oldmask;
oldmask = sigusr2block_oldmask;
sigusr2_blocked--;
if (sigusr2_blocked == 0) {
/* Reset signal mask back */
sigprocmask (SIG_SETMASK, &sigusr2block_oldmask, NULL);
}
}
/* Like fopen with "w" */
FILE *
gdm_safe_fopen_w (const char *file,
......@@ -162,30 +64,3 @@ gdm_safe_fopen_w (const char *file,
ret = fdopen (fd, "w");
return ret;
}
/**
* ve_clearenv:
*
* Description: Clears out the environment completely.
* In case there is no native implementation of clearenv,
* this could cause leaks depending on the implementation
* of environment.
*
**/
void
ve_clearenv (void)
{
#ifdef HAVE_CLEARENV
clearenv ();
#else
#ifdef HAVE__NSGETENVIRON
#define environ (*_NSGetEnviron())
#else
extern char **environ;
#endif
if (environ != NULL)
environ[0] = NULL;
#endif
}
......@@ -22,12 +22,9 @@
#ifndef _GDM_COMMON_UNKNOWN_H
#define _GDM_COMMON_UNKNOWN_H
#include <glib.h>
#include <glib/gstdio.h>
#include <time.h>
#include <stdio.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <glib.h>
G_BEGIN_DECLS
......@@ -37,51 +34,10 @@ G_BEGIN_DECLS
expr; \
} while G_UNLIKELY (errno == EINTR);
#define NEVER_FAILS_seteuid(uid) \
{ int r = 0; \
if (geteuid () != uid) \
r = seteuid (uid); \
if G_UNLIKELY (r != 0) \
g_error ("GDM file %s: line %d (%s): Cannot run seteuid to %d: %s", \
__FILE__, \
__LINE__, \
G_GNUC_PRETTY_FUNCTION, \
(int)uid, \
strerror (errno)); }
#define NEVER_FAILS_setegid(gid) \
{ int r = 0; \
if (getegid () != gid) \
r = setegid (gid); \
if G_UNLIKELY (r != 0) \
g_error ("GDM file %s: line %d (%s): Cannot run setegid to %d: %s", \
__FILE__, \
__LINE__, \
G_GNUC_PRETTY_FUNCTION, \
(int)gid, \
strerror (errno)); }
/* first goes to euid-root and then sets the egid and euid, to make sure
* this succeeds */
#define NEVER_FAILS_root_set_euid_egid(uid,gid) \
{ NEVER_FAILS_seteuid (0); \
NEVER_FAILS_setegid (gid); \
if (uid != 0) { NEVER_FAILS_seteuid (uid); } }
/* like fopen with "w" but unlinks and uses O_EXCL */
FILE * gdm_safe_fopen_w (const char *file,
mode_t perm);
/* This is for race free forks */
void gdm_sigchld_block_push (void);
void gdm_sigchld_block_pop (void);
void gdm_sigterm_block_push (void);
void gdm_sigterm_block_pop (void);
void gdm_sigusr2_block_push (void);
void gdm_sigusr2_block_pop (void);
void ve_clearenv (void);
G_END_DECLS
#endif /* _GDM_COMMON_UNKNOWN_H */
......@@ -25,171 +25,14 @@
#include <stdlib.h>
#include <locale.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <setjmp.h>
#include <dirent.h>
#ifdef HAVE_CRT_EXTERNS_H
#include <crt_externs.h>
#endif
#include <glib.h>
#include <glib/gi18n.h>
#include <glib/gstdio.h>
#include "gdm-common.h"
#include "gdm-md5.h"
static int sigchld_blocked = 0;
static sigset_t sigchldblock_mask, sigchldblock_oldmask;
static int sigterm_blocked = 0;
static sigset_t sigtermblock_mask, sigtermblock_oldmask;
static int sigusr2_blocked = 0;
static sigset_t sigusr2block_mask, sigusr2block_oldmask;
void
gdm_sigchld_block_push (void)
{
sigchld_blocked++;
if (sigchld_blocked == 1) {
/* Set signal mask */
sigemptyset (&sigchldblock_mask);
sigaddset (&sigchldblock_mask, SIGCHLD);
sigprocmask (SIG_BLOCK, &sigchldblock_mask, &sigchldblock_oldmask);
}
}
void
gdm_sigchld_block_pop (void)
{
sigchld_blocked --;
if (sigchld_blocked == 0) {
/* Reset signal mask back */
sigprocmask (SIG_SETMASK, &sigchldblock_oldmask, NULL);
}
}
void
gdm_sigterm_block_push (void)
{
sigterm_blocked++;
if (sigterm_blocked == 1) {
/* Set signal mask */
sigemptyset (&sigtermblock_mask);
sigaddset (&sigtermblock_mask, SIGTERM);
sigaddset (&sigtermblock_mask, SIGINT);
sigaddset (&sigtermblock_mask, SIGHUP);
sigprocmask (SIG_BLOCK, &sigtermblock_mask, &sigtermblock_oldmask);
}
}
void
gdm_sigterm_block_pop (void)
{
sigterm_blocked --;
if (sigterm_blocked == 0) {
/* Reset signal mask back */
sigprocmask (SIG_SETMASK, &sigtermblock_oldmask, NULL);
}
}
void
gdm_sigusr2_block_push (void)
{
sigset_t oldmask;
if (sigusr2_blocked == 0) {
/* Set signal mask */
sigemptyset (&sigusr2block_mask);
sigaddset (&sigusr2block_mask, SIGUSR2);
sigprocmask (SIG_BLOCK, &sigusr2block_mask, &oldmask);
}
sigusr2_blocked++;
sigusr2block_oldmask = oldmask;
}
void
gdm_sigusr2_block_pop (void)
{
sigset_t oldmask;
oldmask = sigusr2block_oldmask;
sigusr2_blocked--;
if (sigusr2_blocked == 0) {
/* Reset signal mask back */
sigprocmask (SIG_SETMASK, &sigusr2block_oldmask, NULL);
}
}
/* Like fopen with "w" */
FILE *
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;
flags = O_EXCL | O_CREAT | O_TRUNC | O_WRONLY;
#ifdef O_NOCTTY
flags |= O_NOCTTY;
#endif
#ifdef O_NOFOLLOW
flags |= O_NOFOLLOW;
#endif
fd = g_open (file, flags, perm);
} while (errno == EINTR);
if (fd < 0) {
return NULL;
}
ret = fdopen (fd, "w");
return ret;
}
/**
* ve_clearenv:
*
* Description: Clears out the environment completely.
* In case there is no native implementation of clearenv,
* this could cause leaks depending on the implementation
* of environment.
*
**/
void
ve_clearenv (void)
{
#ifdef HAVE_CLEARENV
clearenv ();
#else
#ifdef HAVE__NSGETENVIRON
#define environ (*_NSGetEnviron())
#else
extern char **environ;
#endif
if (environ != NULL)
environ[0] = NULL;
#endif
}
/* hex conversion adapted from D-Bus */
/**
* Appends a two-character hex digit to a string, where the hex digit
......
......@@ -1283,8 +1283,6 @@ po/Makefile.in
config/Init
config/PreSession
config/PostSession
config/gdmprefetchlist
config/ssh.desktop.in
])
dnl ---------------------------------------------------------------------------
......
......@@ -161,6 +161,8 @@ gboolean
gdm_slave_connect_to_x11_display (GdmSlave *slave)
{
gboolean ret;
sigset_t mask;
sigset_t omask;
ret = FALSE;
......@@ -181,9 +183,14 @@ gdm_slave_connect_to_x11_display (GdmSlave *slave)
XSetIOErrorHandler (gdm_slave_xioerror_handler);
#endif
gdm_sigchld_block_push ();
sigemptyset (&mask);
sigaddset (&mask, SIGCHLD);
sigprocmask (SIG_BLOCK, &mask, &omask);
slave->priv->server_display = XOpenDisplay (slave->priv->display_name);
gdm_sigchld_block_pop ();
sigprocmask (SIG_SETMASK, &omask, NULL);
if (slave->priv->server_display == NULL) {
g_warning ("Unable to connect to display %s", slave->priv->display_name);
......
......@@ -547,6 +547,7 @@ setup_multicast (GdmXdmcpDisplayFactory *factory)
#endif /* ENABLE_IPV6 */
}
static void
fd_set_close_on_exec (int fd)
{
int flags;
......@@ -921,8 +922,10 @@ set_address_for_request (GdmAddress *address,
}
#if 0
/* FIXME: Add chooser support */
static void
gdm_xdmcp_send_forward_query (GdmXdmcpDisplayFactory *factory,
gdm_xdmcp_send_forward_query (GdmXdmcpDisplayFactory *factory,
GdmIndirectDisplay *id,
GdmAddress *address,
GdmAddress *display_address,
......@@ -978,6 +981,7 @@ gdm_xdmcp_send_forward_query (GdmXdmcpDisplayFactory *factory,
g_free (port.data);
g_free (addr.data);
}
#endif
static void
handle_any_query (GdmXdmcpDisplayFactory *factory,
......@@ -1053,7 +1057,6 @@ gdm_xdmcp_handle_indirect_query (GdmXdmcpDisplayFactory *factory,
int expected_len;
int i;
int res;
GdmIndirectDisplay *id;
if (! gdm_xdmcp_host_allow (address)) {
/* ignore the request */
......@@ -1088,6 +1091,7 @@ gdm_xdmcp_handle_indirect_query (GdmXdmcpDisplayFactory *factory,
#if 0
GdmIndirectDisplay *id;
/* FIXME: Add chooser support */
id = gdm_choose_indirect_lookup (address);
......@@ -2373,7 +2377,6 @@ gdm_xdmcp_handle_managed_forward (GdmXdmcpDisplayFactory *factory,
int len)
{
ARRAY8 clnt_address;
GdmIndirectDisplay *id;
char *host;
GdmAddress *disp_address;
......@@ -2406,6 +2409,7 @@ gdm_xdmcp_handle_managed_forward (GdmXdmcpDisplayFactory *factory,
}
#if 0
GdmIndirectDisplay *id;
/* FIXME: Add chooser support */
id = gdm_choose_indirect_lookup_by_chosen (address, disp_address);
if (id != NULL) {
......
......@@ -280,7 +280,13 @@ main_restoreenv (void)
{
GList *li;
ve_clearenv ();
#ifdef HAVE_CLEARENV
clearenv ();
#else
if (environ != NULL) {
environ[0] = NULL;
}
#endif
/* FIXME: leaks */
......@@ -295,7 +301,12 @@ gdm_restart_now (void)
gdm_info (_("GDM restarting ..."));
gdm_final_cleanup ();
main_restoreenv ();
VE_IGNORE_EINTR (execvp (stored_argv[0], stored_argv));
do {
errno = 0;
execvp (stored_argv[0], stored_argv);
} while (errno == EINTR);
g_warning (_("Failed to restart self"));
_exit (1);
}
......@@ -323,7 +334,7 @@ check_logdir (void)
log_path = LOGDIR;
VE_IGNORE_EINTR (r = g_stat (log_path, &statbuf));
r = g_stat (log_path, &statbuf);
if (r < 0 || ! S_ISDIR (statbuf.st_mode)) {
gdm_fail (_("Logdir %s does not exist or isn't a directory."), log_path);
}
......@@ -336,35 +347,66 @@ check_servauthdir (const char *auth_path,
int r;
/* Enter paranoia mode */
VE_IGNORE_EINTR (r = g_stat (auth_path, statbuf));
if G_UNLIKELY (r < 0) {
r = g_stat (auth_path, statbuf);
if (r < 0) {
gdm_fail (_("Authdir %s does not exist. Aborting."), auth_path);
}
if G_UNLIKELY (! S_ISDIR (statbuf->st_mode)) {
if (! S_ISDIR (statbuf->st_mode)) {
gdm_fail (_("Authdir %s is not a directory. Aborting."), auth_path);
}
}
static void
set_effective_user_group (uid_t uid,
gid_t gid)
{
int res;
res = 0;
if (geteuid () != uid) {
res = seteuid (uid);
}
if (res != 0) {
g_error ("Cannot set uid to %d: %s",
(int)uid,
g_strerror (errno));
}
res = 0;
if (getegid () != gid) {
res = setegid (gid);
}
if (res != 0) {
g_error ("Cannot set gid to %d: %s",
(int)gid,
g_strerror (errno));
}
}
static void
gdm_daemon_check_permissions (uid_t uid,
gid_t gid)
{
struct stat statbuf;
const char *auth_path;
int res;
auth_path = LOGDIR;
/* Enter paranoia mode */
check_servauthdir (auth_path, &statbuf);
NEVER_FAILS_root_set_euid_egid (0, 0);
set_effective_user_group (0, 0);
/* Now set things up for us as */
chown (auth_path, 0, gid);
g_chmod (auth_path, (S_IRWXU|S_IRWXG|S_ISVTX));
NEVER_FAILS_root_set_euid_egid (uid, gid);
set_effective_user_group (uid, gid);
/* Again paranoid */
check_servauthdir (auth_path, &statbuf);
......@@ -436,7 +478,7 @@ gdm_daemon_change_user (uid_t *uidp,
}
/* gid remains `gdm' */
NEVER_FAILS_root_set_euid_egid (uid, gid);
set_effective_user_group (uid, gid);
if (uidp != NULL) {
*uidp = uid;
......@@ -633,7 +675,8 @@ main (int argc,
gdm_daemon_change_user (&gdm_uid, &gdm_gid);
gdm_daemon_check_permissions (gdm_uid, gdm_gid);
NEVER_FAILS_root_set_euid_egid (0, 0);
set_effective_user_group (0, 0);
check_logdir ();
/* XDM compliant error message */
......
2007-10-04 William Jon McCann <mccann@jhu.edu>
reviewed by: <delete if not using a buddy>
* POTFILES.in:
* POTFILES.skip:
2007-10-04 William Jon McCann <mccann@jhu.edu>
reviewed by: <delete if not using a buddy>
......
......@@ -13,8 +13,6 @@ common/gdm-signal-handler.c
common/test-log.c
common/test-settings-client.c
common/test-settings-server.c
config/default.desktop.in
config/ssh.desktop.in.in
daemon/auth.c
daemon/factory-slave-main.c
daemon/fstype.c
......@@ -53,4 +51,4 @@ gui/simple-greeter/gdm-user-chooser-widget.c
gui/simple-greeter/gdm-user.c
gui/simple-greeter/greeter-main.c
libgreeter/gdm-greeter.c
utils/gdm-dmx-reconnect-proxy.c
......@@ -6,8 +6,6 @@
# Without these files, "make distcheck" fails. Please do not
# remove these unless you fix "make distcheck" a different way.
#
config/gettextfoo.h
data/gdm.schemas.in
config/gnome.desktop.in
config/ssh.desktop.in
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment