Type=dbus
BusName=org.freedesktop.NetworkManager
ExecStart=@sbindir@/NetworkManager --no-daemon
-# Suppress stderr to eliminate duplicated messages in syslog. NM calls openlog()
-# with LOG_PERROR when run in foreground. But systemd redirects stderr to
-# syslog by default, which results in logging each message twice.
-StandardError=null
# NM doesn't want systemd to kill its children for it
KillMode=process
</varlistentry>
<varlistentry>
<term><option>--no-daemon</option></term>
- <listitem><para>Do not daemonize. This is useful for
- debugging, and directs log output to the controlling terminal
- in addition to syslog.
+ <listitem><para>Do not daemonize.
+ </para></listitem>
+ </varlistentry>
+ <varlistentry>
+ <term><option>--debug</option></term>
+ <listitem><para>Do not daemonize, and direct log output to the
+ controlling terminal in addition to syslog.
</para></listitem>
</varlistentry>
<varlistentry>
}
void
-nm_logging_start (gboolean become_daemon)
+nm_logging_start (gboolean debug)
{
- if (become_daemon)
- openlog (G_LOG_DOMAIN, LOG_PID, LOG_DAEMON);
- else
+ if (debug)
openlog (G_LOG_DOMAIN, LOG_CONS | LOG_PERROR | LOG_PID, LOG_USER);
+ else
+ openlog (G_LOG_DOMAIN, LOG_PID, LOG_DAEMON);
g_log_set_handler (G_LOG_DOMAIN,
G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION,
{
GOptionContext *opt_ctx = NULL;
gboolean become_daemon = FALSE;
+ gboolean debug = FALSE;
gboolean g_fatal_warnings = FALSE;
gs_free char *pidfile = NULL;
gs_free char *state_file = NULL;
GOptionEntry options[] = {
{ "version", 0, 0, G_OPTION_ARG_NONE, &show_version, N_("Print NetworkManager version and exit"), NULL },
{ "no-daemon", 0, G_OPTION_FLAG_REVERSE, G_OPTION_ARG_NONE, &become_daemon, N_("Don't become a daemon"), NULL },
+ { "debug", 0, 0, G_OPTION_ARG_NONE, &debug, N_("Don't become a daemon, and log to stderr"), NULL },
{ "g-fatal-warnings", 0, 0, G_OPTION_ARG_NONE, &g_fatal_warnings, N_("Make all warnings fatal"), NULL },
{ "pid-file", 0, 0, G_OPTION_ARG_FILENAME, &pidfile, N_("Specify the location of a PID file"), N_("filename") },
{ "state-file", 0, 0, G_OPTION_ARG_FILENAME, &state_file, N_("State file location"), N_("/path/to/state.file") },
}
g_clear_error (&error);
- if (become_daemon) {
+ if (become_daemon && !debug) {
if (daemon (0, 0) < 0) {
int saved_errno;
*/
dbus_glib_global_set_disable_legacy_property_access ();
- nm_logging_start (become_daemon);
+ nm_logging_start (debug);
nm_log_info (LOGD_CORE, "NetworkManager (version " NM_DIST_VERSION ") is starting...");
success = FALSE;