main: (order) move root user check after help/version option
With this change, `NetworkManager --help` and `NetworkManager --version` work for non-root user.
This commit is contained in:
@@ -36,6 +36,7 @@
|
||||
|
||||
#include "gsystem-local-alloc.h"
|
||||
#include "main-utils.h"
|
||||
#include "NetworkManagerUtils.h"
|
||||
#include "nm-logging.h"
|
||||
|
||||
static gboolean
|
||||
@@ -172,6 +173,15 @@ nm_main_utils_ensure_not_running_pidfile (const char *pidfile)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nm_main_utils_ensure_root ()
|
||||
{
|
||||
if (getuid () != 0) {
|
||||
fprintf (stderr, _("You must be root to run %s!\n"), str_if_set (g_get_prgname (), ""));
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
nm_main_utils_early_setup (const char *progname,
|
||||
int *argc,
|
||||
@@ -205,11 +215,6 @@ nm_main_utils_early_setup (const char *progname,
|
||||
setlocale (LC_ALL, "");
|
||||
textdomain (GETTEXT_PACKAGE);
|
||||
|
||||
if (getuid () != 0) {
|
||||
fprintf (stderr, _("You must be root to run %s!\n"), progname);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
for (i = 0; options[i].long_name; i++) {
|
||||
if (!strcmp (options[i].long_name, "log-level")) {
|
||||
opt_fmt_log_level = options[i].description;
|
||||
|
Reference in New Issue
Block a user