main: Move static assertions after setlocale(), but before option processing

These assertions (such as getuid() == 0) don't need to access the
config files or commandline arguments, but *do* output localized error
messages, so they should be after setlocale().
This commit is contained in:
Colin Walters 2013-06-14 13:31:11 -04:00
parent d3fd1b7464
commit 8043d77237

View file

@ -346,11 +346,6 @@ main (int argc, char *argv[])
*/
umask (022);
if (!g_module_supported ()) {
fprintf (stderr, _("GModules are not supported on your platform!\n"));
exit (1);
}
/* Set locale to be able to use environment variables */
setlocale (LC_ALL, "");
@ -358,6 +353,16 @@ main (int argc, char *argv[])
bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
textdomain (GETTEXT_PACKAGE);
if (!g_module_supported ()) {
fprintf (stderr, _("GModules are not supported on your platform!\n"));
exit (1);
}
if (getuid () != 0) {
fprintf (stderr, _("You must be root to run NetworkManager!\n"));
exit (1);
}
/* Parse options */
opt_ctx = g_option_context_new (NULL);
g_option_context_set_translation_domain (opt_ctx, GETTEXT_PACKAGE);
@ -382,11 +387,6 @@ main (int argc, char *argv[])
exit (0);
}
if (getuid () != 0) {
fprintf (stderr, _("You must be root to run NetworkManager!\n"));
exit (1);
}
/* When running from the build directory, determine our build directory
* base and set helper paths in the build tree */
if (run_from_build_dir) {