Commit 69420ae2 authored by Robert Ancell's avatar Robert Ancell Committed by Ray Strode

Use standard exit codes.

Use EXIT_ defines for readibility.
There were some exit codes > 1, but they don't seem to be checked by any of the
parent process code. This does mean that the logs might have changed, but
modern logging techniques have probably made this obsolete.

https://bugzilla.gnome.org/show_bug.cgi?id=788307
parent e6f5fa6d
......@@ -229,7 +229,7 @@ main (int argc, char *argv[])
session = gdm_chooser_session_new ();
if (session == NULL) {
g_critical ("Unable to create chooser session");
exit (1);
exit (EXIT_FAILURE);
}
error = NULL;
......@@ -237,7 +237,7 @@ main (int argc, char *argv[])
if (! res) {
g_warning ("Unable to start chooser session: %s", error->message);
g_error_free (error);
exit (1);
exit (EXIT_FAILURE);
}
gtk_main ();
......
......@@ -1103,7 +1103,7 @@ register_display (GdmDisplay *self)
if (self->priv->connection == NULL) {
g_critical ("error getting system bus: %s", error->message);
g_error_free (error);
exit (1);
exit (EXIT_FAILURE);
}
self->priv->object_skeleton = g_dbus_object_skeleton_new (self->priv->id);
......
......@@ -678,7 +678,7 @@ register_factory (GdmLocalDisplayFactory *factory)
if (factory->priv->connection == NULL) {
g_critical ("error getting system bus: %s", error->message);
g_error_free (error);
exit (1);
exit (EXIT_FAILURE);
}
factory->priv->skeleton = GDM_DBUS_LOCAL_DISPLAY_FACTORY (gdm_dbus_local_display_factory_skeleton_new ());
......@@ -694,7 +694,7 @@ register_factory (GdmLocalDisplayFactory *factory)
&error)) {
g_critical ("error exporting LocalDisplayFactory object: %s", error->message);
g_error_free (error);
exit (1);
exit (EXIT_FAILURE);
}
return TRUE;
......
......@@ -2530,7 +2530,7 @@ register_manager (GdmManager *manager)
if (manager->priv->connection == NULL) {
g_critical ("error getting system bus: %s", error->message);
g_error_free (error);
exit (1);
exit (EXIT_FAILURE);
}
object_server = g_dbus_object_manager_server_new (GDM_MANAGER_DISPLAYS_PATH);
......@@ -2545,7 +2545,7 @@ register_manager (GdmManager *manager)
GDM_MANAGER_PATH,
error->message);
g_error_free (error);
exit (1);
exit (EXIT_FAILURE);
}
return TRUE;
......
......@@ -65,14 +65,6 @@ extern char **environ;
#define GDM_SERVER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GDM_TYPE_SERVER, GdmServerPrivate))
/* These are the servstat values, also used as server
* process exit codes */
#define SERVER_TIMEOUT 2 /* Server didn't start */
#define SERVER_DEAD 250 /* Server stopped */
#define SERVER_PENDING 251 /* Server started but not ready for connections yet */
#define SERVER_RUNNING 252 /* Server running and ready for connections */
#define SERVER_ABORT 253 /* Server failed badly. Suspending display. */
#define MAX_LOGS 5
struct GdmServerPrivate
......@@ -390,7 +382,7 @@ change_user (GdmServer *server)
if (pwent == NULL) {
g_warning (_("Server was to be spawned by user %s but that user doesn’t exist"),
server->priv->user_name);
_exit (1);
_exit (EXIT_FAILURE);
}
g_debug ("GdmServer: Changing (uid:gid) for child process to (%d:%d)",
......@@ -401,19 +393,19 @@ change_user (GdmServer *server)
if (setgid (pwent->pw_gid) < 0) {
g_warning (_("Couldn’t set groupid to %d"),
pwent->pw_gid);
_exit (1);
_exit (EXIT_FAILURE);
}
if (initgroups (pwent->pw_name, pwent->pw_gid) < 0) {
g_warning (_("initgroups () failed for %s"),
pwent->pw_name);
_exit (1);
_exit (EXIT_FAILURE);
}
if (setuid (pwent->pw_uid) < 0) {
g_warning (_("Couldn’t set userid to %d"),
(int)pwent->pw_uid);
_exit (1);
_exit (EXIT_FAILURE);
}
} else {
gid_t groups[1] = { 0 };
......@@ -512,19 +504,19 @@ server_child_setup (GdmServer *server)
if (sigaction (SIGUSR1, &ign_signal, NULL) < 0) {
g_warning (_("%s: Error setting %s to %s"),
"gdm_server_spawn", "USR1", "SIG_IGN");
_exit (SERVER_ABORT);
_exit (EXIT_FAILURE);
}
if (sigaction (SIGTTIN, &ign_signal, NULL) < 0) {
g_warning (_("%s: Error setting %s to %s"),
"gdm_server_spawn", "TTIN", "SIG_IGN");
_exit (SERVER_ABORT);
_exit (EXIT_FAILURE);
}
if (sigaction (SIGTTOU, &ign_signal, NULL) < 0) {
g_warning (_("%s: Error setting %s to %s"),
"gdm_server_spawn", "TTOU", "SIG_IGN");
_exit (SERVER_ABORT);
_exit (EXIT_FAILURE);
}
/* And HUP and TERM are at SIG_DFL from gdm_unset_signals,
......
......@@ -1920,7 +1920,7 @@ gdm_session_worker_start_session (GdmSessionWorker *worker,
if (setsid () < 0) {
g_debug ("GdmSessionWorker: could not set pid '%u' as leader of new session and process group: %s",
(guint) getpid (), g_strerror (errno));
_exit (2);
_exit (EXIT_FAILURE);
}
/* Take control of the tty
......@@ -1935,12 +1935,12 @@ gdm_session_worker_start_session (GdmSessionWorker *worker,
if (setusercontext (NULL, passwd_entry, passwd_entry->pw_uid, LOGIN_SETALL) < 0) {
g_debug ("GdmSessionWorker: setusercontext() failed for user %s: %s",
passwd_entry->pw_name, g_strerror (errno));
_exit (1);
_exit (EXIT_FAILURE);
}
#else
if (setuid (worker->priv->uid) < 0) {
g_debug ("GdmSessionWorker: could not reset uid: %s", g_strerror (errno));
_exit (1);
_exit (EXIT_FAILURE);
}
#endif
......@@ -2040,7 +2040,7 @@ gdm_session_worker_start_session (GdmSessionWorker *worker,
worker->priv->arguments[0],
g_strerror (errno));
_exit (127);
_exit (EXIT_FAILURE);
}
if (worker->priv->session_tty_fd > 0) {
......@@ -3150,7 +3150,7 @@ gdm_session_worker_constructor (GType type,
g_warning ("error opening connection: %s", error->message);
g_clear_error (&error);
exit (1);
exit (EXIT_FAILURE);
}
worker->priv->manager = GDM_DBUS_WORKER_MANAGER (gdm_dbus_worker_manager_proxy_new_sync (worker->priv->connection,
......@@ -3163,7 +3163,7 @@ gdm_session_worker_constructor (GType type,
g_warning ("error creating session proxy: %s", error->message);
g_clear_error (&error);
exit (1);
exit (EXIT_FAILURE);
}
if (!g_dbus_interface_skeleton_export (G_DBUS_INTERFACE_SKELETON (worker),
......@@ -3171,7 +3171,7 @@ gdm_session_worker_constructor (GType type,
GDM_WORKER_DBUS_PATH,
&error)) {
g_warning ("Error while exporting object: %s", error->message);
exit (1);
exit (EXIT_FAILURE);
}
g_dbus_proxy_set_default_timeout (G_DBUS_PROXY (worker->priv->manager), G_MAXINT);
......
......@@ -2434,7 +2434,7 @@ get_session_command (GdmSession *self)
res = get_session_command_for_name (self, session_name, &command);
if (! res) {
g_critical ("Cannot find a command for specified session: %s", session_name);
exit (1);
exit (EXIT_FAILURE);
}
return command;
......
......@@ -337,19 +337,19 @@ main (int argc,
if (! res) {
g_printerr ("Failed to parse options: %s\n", error->message);
g_error_free (error);
return 1;
return EXIT_FAILURE;
}
if (print_version) {
g_print ("GDM %s\n", VERSION);
return 1;
return EXIT_SUCCESS;
}
/* XDM compliant error message */
if (getuid () != 0) {
/* make sure the pid file doesn't get wiped */
g_printerr ("%s\n", _("Only the root user can run GDM"));
return -1;
return EXIT_FAILURE;
}
if (fatal_warnings) {
......@@ -365,7 +365,7 @@ main (int argc,
settings = gdm_settings_new ();
if (! gdm_settings_direct_init (settings, DATADIR "/gdm/gdm.schemas", "/")) {
g_warning ("Unable to initialize settings");
return 1;
return EXIT_FAILURE;
}
gdm_log_set_debug (is_debug_set ());
......@@ -405,7 +405,7 @@ main (int argc,
g_main_loop_unref (main_loop);
return 0;
return EXIT_SUCCESS;
}
static void
......@@ -419,7 +419,7 @@ on_name_acquired (GDBusConnection *bus,
manager = gdm_manager_new ();
if (manager == NULL) {
g_warning ("Could not construct manager object");
exit (1);
exit (EXIT_FAILURE);
}
g_debug ("Successfully connected to D-Bus");
......
......@@ -67,7 +67,7 @@ is_debug_set (void)
static void
on_sigterm_cb (int signal_number)
{
_exit (0);
_exit (EXIT_SUCCESS);
}
int
......@@ -102,12 +102,12 @@ main (int argc,
settings = gdm_settings_new ();
if (settings == NULL) {
g_warning ("Unable to initialize settings");
exit (1);
exit (EXIT_FAILURE);
}
if (! gdm_settings_direct_init (settings, DATADIR "/gdm/gdm.schemas", "/")) {
g_warning ("Unable to initialize settings");
exit (1);
exit (EXIT_FAILURE);
}
gdm_log_set_debug (is_debug_set ());
......@@ -115,7 +115,7 @@ main (int argc,
address = g_getenv ("GDM_SESSION_DBUS_ADDRESS");
if (address == NULL) {
g_warning ("GDM_SESSION_DBUS_ADDRESS not set");
exit (1);
exit (EXIT_FAILURE);
}
is_for_reauth = g_getenv ("GDM_SESSION_FOR_REAUTH") != NULL;
......
......@@ -125,7 +125,7 @@ on_secret_info_query (GdmDBusUserVerifier *user_verifier,
if (tcsetattr (fileno (stdin), TCSAFLUSH, &ts1) != 0) {
fprintf (stderr, "Could not set terminal attributes\n");
exit (1);
exit (EXIT_FAILURE);
}
answer[0] = '\0';
......@@ -164,7 +164,7 @@ main (int argc,
system_bus = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
if (system_bus == NULL) {
g_critical ("Failed connecting to the system bus (this is pretty bad): %s", error->message);
exit (1);
exit (EXIT_FAILURE);
}
manager = GDM_DBUS_MANAGER (gdm_dbus_manager_proxy_new_for_bus_sync (G_BUS_TYPE_SYSTEM,
......@@ -175,7 +175,7 @@ main (int argc,
&error));
if (manager == NULL) {
g_critical ("Failed creating display proxy: %s", error->message);
exit (1);
exit (EXIT_FAILURE);
}
address = NULL;
......@@ -186,7 +186,7 @@ main (int argc,
&error);
if (address == NULL) {
g_critical ("Failed opening reauthentication channel: %s", error->message);
exit (1);
exit (EXIT_FAILURE);
}
connection = g_dbus_connection_new_for_address_sync (address,
......@@ -196,7 +196,7 @@ main (int argc,
&error);
if (connection == NULL) {
g_critical ("Failed connecting to the manager: %s", error->message);
exit (1);
exit (EXIT_FAILURE);
}
user_verifier = GDM_DBUS_USER_VERIFIER (gdm_dbus_user_verifier_proxy_new_sync (connection,
......@@ -207,7 +207,7 @@ main (int argc,
&error));
if (user_verifier == NULL) {
g_critical ("Failed creating user verifier proxy: %s", error->message);
exit (1);
exit (EXIT_FAILURE);
}
g_signal_connect (user_verifier,
......@@ -246,7 +246,7 @@ main (int argc,
&error);
if (!ok) {
g_critical ("Failed to start PAM session: %s", error->message);
exit (1);
exit (EXIT_FAILURE);
}
......
......@@ -54,7 +54,7 @@ main (int argc, char **argv)
if (error != NULL) {
g_warning ("%s", error->message);
g_error_free (error);
exit (1);
exit (EXIT_FAILURE);
}
r = srunner_create (suite_common_address ());
......
......@@ -239,7 +239,7 @@ prepare_screenshot (void)
char *filename;
if (!screenshot_grab_lock ()) {
exit (0);
exit (EXIT_SUCCESS);
}
win = GDK_ROOT_WINDOW ();
......@@ -250,7 +250,7 @@ prepare_screenshot (void)
if (screenshot == NULL) {
/* FIXME: dialog? */
exit (1);
exit (EXIT_FAILURE);
}
play_sound_effect (win);
......@@ -287,7 +287,7 @@ main (int argc, char *argv[])
if (! res) {
g_warning ("%s", error->message);
g_error_free (error);
exit (1);
exit (EXIT_FAILURE);
}
prepare_screenshot ();
......
......@@ -143,7 +143,7 @@ main (int argc, char *argv[])
if (show_version) {
g_print ("%s %s\n", argv [0], VERSION);
exit (1);
exit (EXIT_FAILURE);
}
/* don't support commands other than VERSION */
......
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