summaryrefslogtreecommitdiff
path: root/daemon
diff options
context:
space:
mode:
authorGeorge Lebl <jirka@5z.com>2001-07-06 08:53:57 +0000
committerGeorge Lebl <jirka@src.gnome.org>2001-07-06 08:53:57 +0000
commitd4c650b16fc9c523fc0435db408643800fb67f4c (patch)
treeafcbfceadc92e5cff054ed7d7c27a007ad4016ab /daemon
parentbe6c1ba782cc9c3eb14dc1484c6fa90455bf14cf (diff)
downloadgdm-d4c650b16fc9c523fc0435db408643800fb67f4c.tar.gz
Correct checks for chooser greeter binaries, and fix Suspend feature
Fri Jul 06 01:55:27 2001 George Lebl <jirka@5z.com> * daemon/gdm.c: Correct checks for chooser greeter binaries, and fix Suspend feature * daemon/gdm.[ch], daemon/misc.[ch], gui/misc.[ch], daemon/server.c, daemon/slave.c, gui/gdmconfig.c, gui/gdmlogin.c: Use popt for splitting argv's, this makes things understand quotes which are apparently already used in places (eek). This underlines the need for the vicious-extentions-module, I just cut and paste too much code. Watch for this new cvs module soon. * daemon/slave.c: fix code for sessions with spaces in them
Diffstat (limited to 'daemon')
-rw-r--r--daemon/gdm.c45
-rw-r--r--daemon/gdm.h1
-rw-r--r--daemon/misc.c52
-rw-r--r--daemon/misc.h3
-rw-r--r--daemon/server.c3
-rw-r--r--daemon/slave.c55
6 files changed, 113 insertions, 46 deletions
diff --git a/daemon/gdm.c b/daemon/gdm.c
index 4a25368e..deab09c4 100644
--- a/daemon/gdm.c
+++ b/daemon/gdm.c
@@ -59,7 +59,6 @@ static void gdm_restart_now (void);
GSList *displays; /* List of displays managed */
gint sessions = 0; /* Number of remote sessions */
sigset_t sysmask; /* Inherited system signal mask */
-gchar *argdelim = " "; /* argv argument delimiter */
uid_t GdmUserId; /* Userid under which gdm should run */
gid_t GdmGroupId; /* Groupid under which gdm should run */
int fifofd = -1; /* fifo fd for the slave communication fifo */
@@ -157,7 +156,7 @@ gdm_config_parse (void)
struct passwd *pwent;
struct group *grent;
struct stat statbuf;
- gchar *gtemp, *stemp;
+ gchar *bin;
displays = NULL;
@@ -365,31 +364,26 @@ gdm_config_parse (void)
/* Check that the greeter can be executed */
- gtemp = g_strdup (GdmGreeter);
- stemp = strchr (gtemp, ' ');
+ bin = gdm_first_word (GdmGreeter);
- if (stemp) {
- *stemp = '\0';
-
- if (access (gtemp, X_OK))
+ if ( ! gdm_string_empty (bin) &&
+ access (bin, X_OK) != 0) {
gdm_error (_("%s: Greeter not found or can't be executed by the gdm user"), "gdm_config_parse");
}
- g_free (gtemp);
+ g_free (bin);
/* Check that chooser can be executed */
- gtemp = g_strdup (GdmChooser);
- stemp = strchr (gtemp, ' ');
-
- if (GdmIndirect && stemp) {
- *stemp = '\0';
+ bin = gdm_first_word (GdmChooser);
- if (access (gtemp, X_OK))
+ if (GdmIndirect &&
+ ! gdm_string_empty (bin) &&
+ access (bin, X_OK) != 0) {
gdm_error (_("%s: Chooser not found or it can't be executed by the gdm user"), "gdm_config_parse");
}
- g_free (gtemp);
+ g_free (bin);
/* Enter paranoia mode */
@@ -513,12 +507,10 @@ deal_with_x_crashes (GdmDisplay *d)
if ( ! d->failsafe_xserver &&
! gdm_string_empty (GdmFailsafeXServer)) {
- char *bin = g_strdup (GdmFailsafeXServer);
- char *p = strchr (bin, argdelim[0]);
- if (p != NULL)
- *p = '\0';
+ char *bin = gdm_first_word (GdmFailsafeXServer);
/* Yay we have a failsafe */
- if (access (bin, X_OK) == 0) {
+ if ( ! gdm_string_empty (bin) &&
+ access (bin, X_OK) == 0) {
gdm_info (_("deal_with_x_crashes: Trying failsafe X "
"server %s"), GdmFailsafeXServer);
g_free (bin);
@@ -540,8 +532,7 @@ deal_with_x_crashes (GdmDisplay *d)
char **configurators;
int i;
- configurators = g_strsplit (GdmXKeepsCrashingConfigurators,
- argdelim, MAX_ARGS);
+ configurators = gdm_split (GdmXKeepsCrashingConfigurators);
for (i = 0; configurators[i] != NULL; i++) {
if (access (configurators[i], X_OK) == 0)
break;
@@ -673,7 +664,7 @@ bin_executable (const char *command)
if (gdm_string_empty (command))
return FALSE;
- argv = g_strsplit (command, argdelim, MAX_ARGS);
+ argv = gdm_split (command);
if (argv != NULL &&
argv[0] != NULL &&
access (argv[0], X_OK) == 0) {
@@ -814,7 +805,7 @@ gdm_cleanup_children (void)
final_cleanup ();
- argv = g_strsplit (GdmReboot, argdelim, MAX_ARGS);
+ argv = gdm_split (GdmReboot);
execv (argv[0], argv);
gdm_error (_("gdm_child_action: Reboot failed: %s"), strerror (errno));
@@ -825,7 +816,7 @@ gdm_cleanup_children (void)
final_cleanup ();
- argv = g_strsplit (GdmHalt, argdelim, MAX_ARGS);
+ argv = gdm_split (GdmHalt);
execv (argv[0], argv);
gdm_error (_("gdm_child_action: Halt failed: %s"), strerror (errno));
@@ -836,7 +827,7 @@ gdm_cleanup_children (void)
final_cleanup ();
- argv = g_strsplit (GdmReboot, argdelim, MAX_ARGS);
+ argv = gdm_split (GdmSuspend);
execv (argv[0], argv);
gdm_error (_("gdm_child_action: Suspend failed: %s"), strerror (errno));
diff --git a/daemon/gdm.h b/daemon/gdm.h
index db630290..13ac508f 100644
--- a/daemon/gdm.h
+++ b/daemon/gdm.h
@@ -94,7 +94,6 @@
#define GDM_INTERRUPT_CONFIGURE 'C'
/* The dreaded miscellaneous category */
-#define MAX_ARGS 32
#define FIELD_SIZE 256
#define PIPE_SIZE 4096
diff --git a/daemon/misc.c b/daemon/misc.c
index 2dddcea6..4ed2a680 100644
--- a/daemon/misc.c
+++ b/daemon/misc.c
@@ -321,4 +321,56 @@ gdm_strcasecmp_no_locale (const char *s1, const char *s2)
return 0; /* equal */
}
+char **
+gdm_split (const char *s)
+{
+ int argc;
+ char **temp_argv;
+ char **ret;
+ int i;
+
+ if (s == NULL)
+ return NULL;
+
+ if (poptParseArgvString (s, &argc, &temp_argv) != 0) {
+ return g_strsplit (s, " ", -1);
+ }
+
+ ret = g_new (char *, argc+1);
+ for (i = 0; i < argc; i++) {
+ ret[i] = g_strdup (temp_argv[i]);
+ }
+ ret[i] = NULL;
+
+ free (temp_argv);
+
+ return ret;
+}
+
+char *
+gdm_first_word (const char *s)
+{
+ int argc;
+ char **temp_argv;
+ char *ret;
+
+ if (s == NULL)
+ return NULL;
+
+ if (poptParseArgvString (s, &argc, &temp_argv) != 0) {
+ char *p;
+ ret = g_strdup (s);
+ p = strchr (ret, ' ');
+ if (p != NULL)
+ *p = '\0';
+ return ret;
+ }
+
+ ret = g_strdup (temp_argv[0]);
+
+ free (temp_argv);
+
+ return ret;
+}
+
/* EOF */
diff --git a/daemon/misc.h b/daemon/misc.h
index cf267beb..7cc194c6 100644
--- a/daemon/misc.h
+++ b/daemon/misc.h
@@ -47,6 +47,9 @@ void gdm_clearenv_no_lang (void);
int gdm_strcasecmp_no_locale (const char *s1, const char *s2);
+char ** gdm_split (const char *s);
+char * gdm_first_word (const char *s);
+
#endif /* GDM_MISC_H */
/* EOF */
diff --git a/daemon/server.c b/daemon/server.c
index 1c8df8a9..d6b10547 100644
--- a/daemon/server.c
+++ b/daemon/server.c
@@ -50,7 +50,6 @@ static void gdm_server_alarm_handler (gint);
static void gdm_server_child_handler (gint);
/* Configuration options */
-extern gchar *argdelim;
extern gchar *GdmDisplayInit;
extern gchar *GdmServAuthDir;
extern gchar *GdmLogDir;
@@ -443,7 +442,7 @@ gdm_server_spawn (GdmDisplay *d)
sigaddset (&mask, SIGTERM);
sigprocmask (SIG_UNBLOCK, &mask, NULL);
- argv = g_strsplit (d->command, argdelim, MAX_ARGS);
+ argv = gdm_split (d->command);
for (len = 0; argv != NULL && argv[len] != NULL; len++)
;
diff --git a/daemon/slave.c b/daemon/slave.c
index 2ac6797c..d463e672 100644
--- a/daemon/slave.c
+++ b/daemon/slave.c
@@ -108,7 +108,6 @@ extern gint GdmPingInterval;
extern gint GdmRetryDelay;
extern gboolean GdmAllowRoot;
extern sigset_t sysmask;
-extern gchar *argdelim;
extern gchar *GdmGlobalFaceDir;
extern gboolean GdmBrowser;
@@ -595,7 +594,7 @@ run_config (GdmDisplay *display, struct passwd *pwent)
open("/dev/null", O_RDWR); /* open stderr - fd 2 */
/* exec the configurator */
- argv = g_strsplit (GdmConfigurator, " ", MAX_ARGS);
+ argv = gdm_split (GdmConfigurator);
if (argv != NULL &&
argv[0] != NULL &&
access (argv[0], X_OK) == 0)
@@ -609,10 +608,9 @@ run_config (GdmDisplay *display, struct passwd *pwent)
"I will attempt to start it from the\n"
"default location."));
- argv = g_strsplit
+ argv = gdm_split
(EXPANDED_GDMCONFIGDIR
- "/gdmconfig --disable-sound --disable-crash-dialog",
- " ", MAX_ARGS);
+ "/gdmconfig --disable-sound --disable-crash-dialog");
if (access (argv[0], X_OK) == 0)
execv (argv[0], argv);
@@ -1080,7 +1078,7 @@ gdm_slave_greeter (void)
"configure the X server."));
}
- argv = g_strsplit (GdmGreeter, argdelim, MAX_ARGS);
+ argv = gdm_split (GdmGreeter);
execv (argv[0], argv);
gdm_error (_("gdm_slave_greeter: Cannot start greeter trying default: %s"),
@@ -1089,9 +1087,8 @@ gdm_slave_greeter (void)
gdm_setenv ("GDM_WHACKED_GREETER_CONFIG", "true");
- argv = g_strsplit (EXPANDED_BINDIR
- "/gdmlogin --disable-sound --disable-crash-dialog",
- argdelim, MAX_ARGS);
+ argv = gdm_split (EXPANDED_BINDIR
+ "/gdmlogin --disable-sound --disable-crash-dialog");
execv (argv[0], argv);
gdm_error_box (d,
@@ -1323,7 +1320,7 @@ gdm_slave_chooser (void)
gdm_setenv ("PATH", GdmDefaultPath);
gdm_setenv ("RUNNING_UNDER_GDM", "true");
- argv = g_strsplit (GdmChooser, argdelim, MAX_ARGS);
+ argv = gdm_split (GdmChooser);
execv (argv[0], argv);
gdm_error_box (d,
@@ -1618,6 +1615,27 @@ unaliaslang (const char *origlang)
}
+static char *
+dequote (const char *in)
+{
+ GString *str;
+ char *out;
+ const char *p;
+
+ str = g_string_new (NULL);
+
+ for (p = in; *p != '\0'; p++) {
+ if (*p == '\'')
+ g_string_append (str, "'\\''");
+ else
+ g_string_append_c (str, *p);
+ }
+
+ out = str->str;
+ g_string_free (str, FALSE);
+ return out;
+}
+
static void
gdm_slave_session_start (void)
{
@@ -1985,10 +2003,15 @@ gdm_slave_session_start (void)
}
if (sesspath == NULL) {
- if (GdmSessDir != NULL)
- sesspath = g_strconcat (GdmSessDir, "/", session, NULL);
- else
- sesspath = g_strdup ("/Eeeeek! Eeeeek!");
+ if (GdmSessDir != NULL) {
+ sesspath = g_strconcat
+ ("'", GdmSessDir, "/",
+ dequote (session), "'", NULL);
+ sessexec = g_strconcat (GdmSessDir, "/",
+ session, NULL);
+ } else {
+ sesspath = g_strdup ("'/Eeeeek! Eeeeek!'");
+ }
}
gdm_debug (_("Running %s for %s on %s"),
@@ -2438,7 +2461,7 @@ gdm_slave_exec_script (GdmDisplay *d, const gchar *dir, const char *login,
gdm_setenv ("DISPLAY", d->name);
gdm_setenv ("PATH", GdmRootPath);
gdm_unsetenv ("MAIL");
- argv = g_strsplit (scr, argdelim, MAX_ARGS);
+ argv = gdm_split (scr);
execv (argv[0], argv);
syslog (LOG_ERR, _("gdm_slave_exec_script: Failed starting: %s"), scr);
_exit (EXIT_SUCCESS);
@@ -2583,7 +2606,7 @@ gdm_parse_enriched_login (const gchar *s, GdmDisplay *display)
gdm_setenv ("PATH", GdmRootPath);
gdm_unsetenv ("MAIL");
- argv = g_strsplit (str->str, argdelim, MAX_ARGS);
+ argv = gdm_split (str->str);
execv (argv[0], argv);
syslog (LOG_ERR, _("gdm_parse_enriched_login: Failed executing: %s"),
str->str);