Commit 441eb0bd authored by Brian Cameron's avatar Brian Cameron Committed by Brian Cameron

Return compiled in value if slave fails to get a value back from the

2006-02-07  Brian Cameron  <brian.cameron@sun.com>

        * gui/gdmconfig.c: Return compiled in value if slave fails
          to get a value back from the daemon.
        * gui/gdmcomm.c:, gui/gdmconfig.c:  Use gdm_common_error
          instead of gdm_common_info so message really go to log.
        * gui/gdmsession.c: Include needed gdmcommon.h.  Missed this
          in my previous putback earlier today.
parent 3cce7bd8
2006-02-07 Brian Cameron <brian.cameron@sun.com>
* gui/gdmconfig.c: Return compiled in value if slave fails
to get a value back from the daemon.
* gui/gdmcomm.c:, gui/gdmconfig.c: Use gdm_common_error
instead of gdm_common_info so message really go to log.
* gui/gdmsession.c: Include needed gdmcommon.h. Missed this
in my previous putback earlier today.
2006-02-07 Brian Cameron <brian.cameron@sun.com>
* gdm-restart.in, gdm-safe-restart.in, gdm-stop.in, gdm.spec.in:
......
......@@ -38,6 +38,7 @@
#include "vicious.h"
#include "gdm.h"
#include "gdmcommon.h"
#include "gdmcomm.h"
#include "gdmconfig.h"
......@@ -45,11 +46,12 @@ static gboolean debug = FALSE;
static int num_cmds = 0;
/*
* Note, we have to call gdm_common_info instead of gdm_common_debug,
* Note, we have to call gdm_common_error instead of gdm_common_debug,
* since gdm_common_debug accesses the GDM_KEY_DEBUG which can cause
* this function to be called again, causing an infinite loop. This
* is why clients must call the gdmcomm_set_debug function to turn
* on debug for these functions.
* on debug for these functions. We use gdm_common_error instead
* of gdm_common_info so the messages really go to the syslog.
*/
void
gdmcomm_set_debug (gboolean enable)
......@@ -69,7 +71,7 @@ do_command (int fd, const char *command, gboolean get_response)
#endif
if (debug) {
gdm_common_info ("Sending command: '%s'", command);
gdm_common_error ("Sending command: '%s'", command);
}
cstr = g_strdup_printf ("%s\n", command);
......@@ -87,7 +89,7 @@ do_command (int fd, const char *command, gboolean get_response)
if (ret < 0) {
if (debug)
gdm_common_info ("Command failed, no data returned");
gdm_common_error ("Command failed, no data returned");
return NULL;
}
......@@ -102,14 +104,14 @@ do_command (int fd, const char *command, gboolean get_response)
}
if (debug)
gdm_common_info (" Got response: '%s'", str->str);
gdm_common_error (" Got response: '%s'", str->str);
cstr = str->str;
g_string_free (str, FALSE);
if (strcmp (ve_sure_string (cstr), "ERROR 200 Too many messages") == 0) {
if (debug)
gdm_common_info ("Command failed, daemon busy.");
gdm_common_error ("Command failed, daemon busy.");
g_free (cstr);
return NULL;
}
......@@ -156,7 +158,7 @@ gdmcomm_call_gdm_real (const char *command,
*/
if (num_cmds == (GDM_SUP_MAX_MESSAGES)) {
if (debug)
gdm_common_info (" Closing and reopening connection.");
gdm_common_error (" Closing and reopening connection.");
do_command (comm_fd, GDM_SUP_CLOSE, FALSE);
VE_IGNORE_EINTR (close (comm_fd));
comm_fd = 0;
......@@ -165,12 +167,12 @@ gdmcomm_call_gdm_real (const char *command,
if (tries <= 0) {
if (debug)
gdm_common_info (" Command failed %d times, aborting.", try_start);
gdm_common_error (" Command failed %d times, aborting.", try_start);
return NULL;
}
if (debug && tries != try_start) {
gdm_common_info (" Trying failed command again. Retry %d of %d.",
gdm_common_error (" Trying failed command again. Retry %d of %d.",
(try_start - tries), try_start);
}
......@@ -182,7 +184,7 @@ gdmcomm_call_gdm_real (const char *command,
comm_fd = socket (AF_UNIX, SOCK_STREAM, 0);
if (comm_fd < 0) {
if (debug)
gdm_common_info (" Failed to open socket");
gdm_common_error (" Failed to open socket");
return gdmcomm_call_gdm_real (command, auth_cookie, min_version, tries - 1, try_start);
}
......@@ -190,7 +192,7 @@ gdmcomm_call_gdm_real (const char *command,
if (connect (comm_fd, (struct sockaddr *)&addr, sizeof (addr)) < 0) {
if (debug)
gdm_common_info (" Failed to connect to socket");
gdm_common_error (" Failed to connect to socket");
/*
* If there is a failure on connect, there are probably
......@@ -224,7 +226,7 @@ gdmcomm_call_gdm_real (const char *command,
ret = do_command (comm_fd, GDM_SUP_VERSION, TRUE);
if (ret == NULL) {
if (debug)
gdm_common_info (" Version check failed");
gdm_common_error (" Version check failed");
VE_IGNORE_EINTR (close (comm_fd));
comm_fd = 0;
return gdmcomm_call_gdm_real (command, auth_cookie,
......@@ -232,7 +234,7 @@ gdmcomm_call_gdm_real (const char *command,
}
if (strncmp (ret, "GDM ", strlen ("GDM ")) != 0) {
if (debug)
gdm_common_info (" Version check failed, bad name");
gdm_common_error (" Version check failed, bad name");
g_free (ret);
VE_IGNORE_EINTR (close (comm_fd));
......@@ -241,7 +243,7 @@ gdmcomm_call_gdm_real (const char *command,
}
if ( ! version_ok_p (&ret[4], min_version)) {
if (debug)
gdm_common_info (" Version check failed, bad version");
gdm_common_error (" Version check failed, bad version");
g_free (ret);
VE_IGNORE_EINTR (close (comm_fd));
comm_fd = 0;
......@@ -265,7 +267,7 @@ gdmcomm_call_gdm_real (const char *command,
/* not auth'ed */
if (strcmp (ve_sure_string (ret), "OK") != 0) {
if (debug)
gdm_common_info (" Error, auth check failed");
gdm_common_error (" Error, auth check failed");
VE_IGNORE_EINTR (close (comm_fd));
comm_fd = 0;
/* returns the error */
......
......@@ -27,6 +27,7 @@
#include "config.h"
#include "gdm.h"
#include "gdmcommon.h"
#include "gdmcomm.h"
#include "gdmconfig.h"
......@@ -147,7 +148,7 @@ gdm_config_get_xserver_details (gchar *xserver, gchar *key)
if (! result || ve_string_empty (result) ||
strncmp (result, "OK ", 3) != 0) {
gdm_common_info ("Could not access xserver configuration");
gdm_common_error ("Could not access xserver configuration");
if (result)
g_free (result);
......@@ -185,7 +186,7 @@ gdm_config_get_xservers (gboolean flexible)
if (! result || ve_string_empty (result) ||
strncmp (result, "OK ", 3) != 0) {
gdm_common_info ("Could not access xserver configuration");
gdm_common_error ("Could not access xserver configuration");
if (result)
g_free (result);
......@@ -287,7 +288,7 @@ gdm_config_get_xservers (gboolean flexible)
* access is faster.
*/
static gchar *
_gdm_config_get_string (gchar *key, gboolean reload, gboolean *changed, gboolean show_error)
_gdm_config_get_string (gchar *key, gboolean reload, gboolean *changed, gboolean doing_translated)
{
gchar **hashretval = NULL;
gchar *result = NULL;
......@@ -303,22 +304,39 @@ _gdm_config_get_string (gchar *key, gboolean reload, gboolean *changed, gboolean
result = gdm_config_get_result (key);
if (! result || ve_string_empty (result) ||
if ( ! result || ve_string_empty (result) ||
strncmp (result, "OK ", 3) != 0) {
/* No need to show error for failed translated strings */
if (show_error) {
gdm_common_info ("Could not access configuration key %s", key);
gchar *getdefault;
/*
* If looking for a translated string, and not found, just return
* NULL.
*/
if (doing_translated) {
if (result)
g_free (result);
return NULL;
}
if (result)
g_free (result);
return NULL;
gdm_common_error ("Could not access configuration key <%s>", key);
/* Return the compiled in value associated with the key, if available. */
getdefault = strchr (key, '=');
if (getdefault != NULL)
getdefault++;
temp = g_strdup (getdefault);
gdm_common_error ("Using compiled in value <%s> for <%s>", temp, key);
} else {
/* skip the "OK " */
temp = g_strdup (result + 3);
}
/* skip the "OK " */
temp = g_strdup (result + 3);
g_free (result);
if (result)
g_free (result);
if (hashretval == NULL) {
gchar **charval = g_new0 (gchar *, 1);
......@@ -347,9 +365,9 @@ gchar *
gdm_config_get_string (gchar *key)
{
if (gdm_never_cache == TRUE)
return _gdm_config_get_string (key, TRUE, NULL, TRUE);
return _gdm_config_get_string (key, TRUE, NULL, FALSE);
else
return _gdm_config_get_string (key, FALSE, NULL, TRUE);
return _gdm_config_get_string (key, FALSE, NULL, FALSE);
}
/**
......@@ -386,14 +404,14 @@ _gdm_config_get_translated_string (gchar *key, gboolean reload, gboolean *change
* Pass FALSE for last argument so it doesn't print errors for
* failing to find the key, since this is expected
*/
gchar *val = _gdm_config_get_string (full, reload, changed, FALSE);
gchar *val = _gdm_config_get_string (full, reload, changed, TRUE);
if (val != NULL)
return val;
}
/* Print error if it fails this time */
return _gdm_config_get_string (key, reload, changed, TRUE);
return _gdm_config_get_string (key, reload, changed, FALSE);
}
gchar *
......@@ -428,19 +446,30 @@ _gdm_config_get_int (gchar *key, gboolean reload, gboolean *changed)
result = gdm_config_get_result (key);
if (! result || ve_string_empty (result) ||
if ( ! result || ve_string_empty (result) ||
strncmp (result, "OK ", 3) != 0) {
gdm_common_info ("Could not access configuration key %s", key);
gchar *getdefault;
if (result)
g_free (result);
return 0;
gdm_common_error ("Could not access configuration key <%s>", key);
/* Return the compiled in value associated with the key, if available. */
getdefault = strchr (key, '=');
if (getdefault != NULL)
getdefault++;
temp = atoi (getdefault);
gdm_common_error ("Using compiled in value <%d> for <%s>", temp, key);
} else {
/* skip the "OK " */
temp = atoi (result + 3);
}
/* skip the "OK " */
temp = atoi (result + 3);
g_free (result);
if (result)
g_free (result);
if (hashretval == NULL) {
gint *intval = g_new0 (gint, 1);
......@@ -496,22 +525,42 @@ _gdm_config_get_bool (gchar *key, gboolean reload, gboolean *changed)
result = gdm_config_get_result (key);
if (! result || ve_string_empty (result) ||
if ( ! result || ve_string_empty (result) ||
strncmp (result, "OK ", 3) != 0) {
gdm_common_info ("Could not access configuration key %s", key);
gchar *getdefault;
if (result)
g_free (result);
return FALSE;
gdm_common_error ("Could not access configuration key <%s>", key);
/* Return the compiled in value associated with the key, if available. */
getdefault = strchr (key, '=');
if (getdefault != NULL)
getdefault++;
/* Same logic as used in ve_config_get_bool */
if (getdefault != NULL &&
(getdefault[0] == 'T' ||
getdefault[0] == 't' ||
getdefault[0] == 'Y' ||
getdefault[0] == 'y' ||
atoi (getdefault) != 0)) {
temp = TRUE;
gdm_common_error ("Using compiled in value <TRUE> for <%s>", key);
} else {
temp = FALSE;
gdm_common_error ("Using compiled in value <FALSE> for <%s>", key);
}
} else {
/* skip the "OK " */
if (strcmp (ve_sure_string (result + 3), "true") == 0)
temp = TRUE;
else
temp = FALSE;
}
/* skip the "OK " */
if (strcmp (ve_sure_string (result + 3), "true") == 0)
temp = TRUE;
else
temp = FALSE;
g_free (result);
if (result)
g_free (result);
if (hashretval == NULL) {
gboolean *boolval = g_new0 (gboolean, 1);
......@@ -557,7 +606,7 @@ gboolean
gdm_config_reload_string (gchar *key)
{
gboolean changed;
_gdm_config_get_string (key, TRUE, &changed, TRUE);
_gdm_config_get_string (key, TRUE, &changed, FALSE);
return changed;
}
......
......@@ -30,6 +30,7 @@
#include "gdm.h"
#include "gdmsession.h"
#include "gdmcommon.h"
#include "gdmconfig.h"
GHashTable *sessnames = NULL;
......
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