Commit 36203530 authored by Dan Williams's avatar Dan Williams

core: add --version and allow it and --help to be run without root

parent 08fda128
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
.SH NAME .SH NAME
NetworkManager \- network management daemon NetworkManager \- network management daemon
.SH SYNOPSIS .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 .SH DESCRIPTION
The \fINetworkManager\fP daemon attempts to make networking configuration and The \fINetworkManager\fP daemon attempts to make networking configuration and
operation as painless and automatic as possible by managing the primary network operation as painless and automatic as possible by managing the primary network
...@@ -61,6 +61,9 @@ The DHCPv6 lease has changed (renewed, rebound, etc). ...@@ -61,6 +61,9 @@ The DHCPv6 lease has changed (renewed, rebound, etc).
.SH OPTIONS .SH OPTIONS
The following options are supported: The following options are supported:
.TP .TP
.I "\-\-version"
Print the NetworkManager software version and exit.
.TP
.I "\-\-no\-daemon" .I "\-\-no\-daemon"
Do not daemonize. This is useful for debugging, and directs log output to the Do not daemonize. This is useful for debugging, and directs log output to the
controlling terminal in addition to syslog. controlling terminal in addition to syslog.
......
...@@ -474,7 +474,7 @@ main (int argc, char *argv[]) ...@@ -474,7 +474,7 @@ main (int argc, char *argv[])
char *log_level = NULL, *log_domains = NULL; char *log_level = NULL, *log_domains = NULL;
char **dns = NULL; char **dns = NULL;
gboolean wifi_enabled = TRUE, net_enabled = TRUE, wwan_enabled = TRUE, wimax_enabled = TRUE; gboolean wifi_enabled = TRUE, net_enabled = TRUE, wwan_enabled = TRUE, wimax_enabled = TRUE;
gboolean success; gboolean success, show_version = FALSE;
NMPolicy *policy = NULL; NMPolicy *policy = NULL;
NMVPNManager *vpn_manager = NULL; NMVPNManager *vpn_manager = NULL;
NMDnsManager *dns_mgr = NULL; NMDnsManager *dns_mgr = NULL;
...@@ -487,6 +487,7 @@ main (int argc, char *argv[]) ...@@ -487,6 +487,7 @@ main (int argc, char *argv[])
char *cfg_log_level = NULL, *cfg_log_domains = NULL; char *cfg_log_level = NULL, *cfg_log_domains = NULL;
GOptionEntry options[] = { 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 }, { "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 }, { "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" }, { "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[]) ...@@ -495,16 +496,14 @@ main (int argc, char *argv[])
{ "plugins", 0, 0, G_OPTION_ARG_STRING, &plugins, "List of plugins separated by ','", "plugin1,plugin2" }, { "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-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", 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" }, "HW,RFKILL,WIFI" },
{NULL} {NULL}
}; };
if (getuid () != 0) {
fprintf (stderr, "You must be root to run NetworkManager!\n");
exit (1);
}
if (!g_module_supported ()) { if (!g_module_supported ()) {
fprintf (stderr, "GModules are not supported on your platform!\n"); fprintf (stderr, "GModules are not supported on your platform!\n");
exit (1); exit (1);
...@@ -532,6 +531,16 @@ main (int argc, char *argv[]) ...@@ -532,6 +531,16 @@ main (int argc, char *argv[])
exit (1); 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 /* 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 * session bus to contact the remote service, and NM shouldn't ever be
* talking on the session bus. See rh #588745 * talking on the session bus. See rh #588745
......
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