mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 09:58:07 +02:00
core: add --version and allow it and --help to be run without root
This commit is contained in:
parent
08fda12858
commit
3620353050
2 changed files with 20 additions and 8 deletions
|
|
@ -8,7 +8,7 @@
|
|||
.SH NAME
|
||||
NetworkManager \- network management daemon
|
||||
.SH SYNOPSIS
|
||||
.B NetworkManager [\-\-no\-daemon] [\-\-pid\-file=<filename>] [\-\-state\-file=<filename>] [\-\-config=<filename>] [\-\-plugins=<plugin1>,plugin2>,...] [\-\-log\-level=<level>] [\-\-log\-domains=<domain1>,<domain2>,...]
|
||||
.B NetworkManager [\-\-version] [\-\-no\-daemon] [\-\-pid\-file=<filename>] [\-\-state\-file=<filename>] [\-\-config=<filename>] [\-\-plugins=<plugin1>,plugin2>,...] [\-\-log\-level=<level>] [\-\-log\-domains=<domain1>,<domain2>,...]
|
||||
.SH DESCRIPTION
|
||||
The \fINetworkManager\fP daemon attempts to make networking configuration and
|
||||
operation as painless and automatic as possible by managing the primary network
|
||||
|
|
@ -61,6 +61,9 @@ The DHCPv6 lease has changed (renewed, rebound, etc).
|
|||
.SH OPTIONS
|
||||
The following options are supported:
|
||||
.TP
|
||||
.I "\-\-version"
|
||||
Print the NetworkManager software version and exit.
|
||||
.TP
|
||||
.I "\-\-no\-daemon"
|
||||
Do not daemonize. This is useful for debugging, and directs log output to the
|
||||
controlling terminal in addition to syslog.
|
||||
|
|
|
|||
23
src/main.c
23
src/main.c
|
|
@ -474,7 +474,7 @@ main (int argc, char *argv[])
|
|||
char *log_level = NULL, *log_domains = NULL;
|
||||
char **dns = NULL;
|
||||
gboolean wifi_enabled = TRUE, net_enabled = TRUE, wwan_enabled = TRUE, wimax_enabled = TRUE;
|
||||
gboolean success;
|
||||
gboolean success, show_version = FALSE;
|
||||
NMPolicy *policy = NULL;
|
||||
NMVPNManager *vpn_manager = NULL;
|
||||
NMDnsManager *dns_mgr = NULL;
|
||||
|
|
@ -487,6 +487,7 @@ main (int argc, char *argv[])
|
|||
char *cfg_log_level = NULL, *cfg_log_domains = NULL;
|
||||
|
||||
GOptionEntry options[] = {
|
||||
{ "version", 0, 0, G_OPTION_ARG_NONE, &show_version, "Print NetworkManager version and exit", NULL },
|
||||
{ "no-daemon", 0, 0, G_OPTION_ARG_NONE, &become_daemon, "Don't become a daemon", NULL },
|
||||
{ "g-fatal-warnings", 0, 0, G_OPTION_ARG_NONE, &g_fatal_warnings, "Make all warnings fatal", NULL },
|
||||
{ "pid-file", 0, 0, G_OPTION_ARG_FILENAME, &pidfile, "Specify the location of a PID file", "filename" },
|
||||
|
|
@ -495,16 +496,14 @@ main (int argc, char *argv[])
|
|||
{ "plugins", 0, 0, G_OPTION_ARG_STRING, &plugins, "List of plugins separated by ','", "plugin1,plugin2" },
|
||||
{ "log-level", 0, 0, G_OPTION_ARG_STRING, &log_level, "Log level: one of [ERR, WARN, INFO, DEBUG]", "INFO" },
|
||||
{ "log-domains", 0, 0, G_OPTION_ARG_STRING, &log_domains,
|
||||
"Log domains separated by ',': any combination of [NONE,HW,RFKILL,ETHER,WIFI,BT,MB,DHCP4,DHCP6,PPP,WIFI_SCAN,IP4,IP6,AUTOIP4,DNS,VPN,SHARING,SUPPLICANT,USER_SET,SYS_SET,SUSPEND,CORE,DEVICE,OLPC]",
|
||||
"Log domains separated by ',': any combination of\n"
|
||||
" [NONE,HW,RFKILL,ETHER,WIFI,BT,MB,DHCP4,DHCP6,PPP,\n"
|
||||
" WIFI_SCAN,IP4,IP6,AUTOIP4,DNS,VPN,SHARING,SUPPLICANT,\n"
|
||||
" AGENTS,SETTINGS,SUSPEND,CORE,DEVICE,OLPC,WIMAX]",
|
||||
"HW,RFKILL,WIFI" },
|
||||
{NULL}
|
||||
};
|
||||
|
||||
if (getuid () != 0) {
|
||||
fprintf (stderr, "You must be root to run NetworkManager!\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
if (!g_module_supported ()) {
|
||||
fprintf (stderr, "GModules are not supported on your platform!\n");
|
||||
exit (1);
|
||||
|
|
@ -532,6 +531,16 @@ main (int argc, char *argv[])
|
|||
exit (1);
|
||||
}
|
||||
|
||||
if (show_version) {
|
||||
fprintf (stdout, NM_DIST_VERSION "\n");
|
||||
exit (0);
|
||||
}
|
||||
|
||||
if (getuid () != 0) {
|
||||
fprintf (stderr, "You must be root to run NetworkManager!\n");
|
||||
exit (1);
|
||||
}
|
||||
|
||||
/* Make GIO ignore the remote VFS service; otherwise it tries to use the
|
||||
* session bus to contact the remote service, and NM shouldn't ever be
|
||||
* talking on the session bus. See rh #588745
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue