diff options
author | Robert Ancell <robert.ancell@canonical.com> | 2017-09-28 15:33:50 -0400 |
---|---|---|
committer | Ray Strode <rstrode@redhat.com> | 2017-10-03 16:18:28 -0400 |
commit | 69420ae2c587c75cfb915330d4f60f866281345b (patch) | |
tree | c3db9bef9e74a801c0f42e31d0a1b8ab6b78800c /daemon | |
parent | e6f5fa6d95e2661477471c6ff1a6a0c379421785 (diff) | |
download | gdm-69420ae2c587c75cfb915330d4f60f866281345b.tar.gz |
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
Diffstat (limited to 'daemon')
-rw-r--r-- | daemon/gdm-display.c | 2 | ||||
-rw-r--r-- | daemon/gdm-local-display-factory.c | 4 | ||||
-rw-r--r-- | daemon/gdm-manager.c | 4 | ||||
-rw-r--r-- | daemon/gdm-server.c | 22 | ||||
-rw-r--r-- | daemon/gdm-session-worker.c | 14 | ||||
-rw-r--r-- | daemon/gdm-session.c | 2 | ||||
-rw-r--r-- | daemon/main.c | 12 | ||||
-rw-r--r-- | daemon/session-worker-main.c | 8 | ||||
-rw-r--r-- | daemon/test-session-client.c | 14 |
9 files changed, 37 insertions, 45 deletions
diff --git a/daemon/gdm-display.c b/daemon/gdm-display.c index 2d7eacf5..1f1ecb6d 100644 --- a/daemon/gdm-display.c +++ b/daemon/gdm-display.c @@ -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); diff --git a/daemon/gdm-local-display-factory.c b/daemon/gdm-local-display-factory.c index 95bdc59d..b29f5ac5 100644 --- a/daemon/gdm-local-display-factory.c +++ b/daemon/gdm-local-display-factory.c @@ -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; diff --git a/daemon/gdm-manager.c b/daemon/gdm-manager.c index e9f8465f..256b6447 100644 --- a/daemon/gdm-manager.c +++ b/daemon/gdm-manager.c @@ -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; diff --git a/daemon/gdm-server.c b/daemon/gdm-server.c index 79cddc6e..83fba99c 100644 --- a/daemon/gdm-server.c +++ b/daemon/gdm-server.c @@ -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, diff --git a/daemon/gdm-session-worker.c b/daemon/gdm-session-worker.c index 543006ba..9ef4c5b0 100644 --- a/daemon/gdm-session-worker.c +++ b/daemon/gdm-session-worker.c @@ -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); diff --git a/daemon/gdm-session.c b/daemon/gdm-session.c index 1f1f6eea..af9f6fb3 100644 --- a/daemon/gdm-session.c +++ b/daemon/gdm-session.c @@ -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; diff --git a/daemon/main.c b/daemon/main.c index cf8600da..4a5c5496 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -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"); diff --git a/daemon/session-worker-main.c b/daemon/session-worker-main.c index 051d7f97..4a3a8ebb 100644 --- a/daemon/session-worker-main.c +++ b/daemon/session-worker-main.c @@ -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; diff --git a/daemon/test-session-client.c b/daemon/test-session-client.c index a38cbfda..ae4f59d3 100644 --- a/daemon/test-session-client.c +++ b/daemon/test-session-client.c @@ -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); } |