core: use fprintf before logging is set up
This commit is contained in:
50
src/main.c
50
src/main.c
@@ -237,18 +237,18 @@ write_pidfile (const char *pidfile)
|
|||||||
gboolean success = FALSE;
|
gboolean success = FALSE;
|
||||||
|
|
||||||
if ((fd = open (pidfile, O_CREAT|O_WRONLY|O_TRUNC, 00644)) < 0) {
|
if ((fd = open (pidfile, O_CREAT|O_WRONLY|O_TRUNC, 00644)) < 0) {
|
||||||
nm_warning ("Opening %s failed: %s", pidfile, strerror (errno));
|
fprintf (stderr, "Opening %s failed: %s", pidfile, strerror (errno));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf (pid, sizeof (pid), "%d", getpid ());
|
snprintf (pid, sizeof (pid), "%d", getpid ());
|
||||||
if (write (fd, pid, strlen (pid)) < 0)
|
if (write (fd, pid, strlen (pid)) < 0)
|
||||||
nm_warning ("Writing to %s failed: %s", pidfile, strerror (errno));
|
fprintf (stderr, "Writing to %s failed: %s", pidfile, strerror (errno));
|
||||||
else
|
else
|
||||||
success = TRUE;
|
success = TRUE;
|
||||||
|
|
||||||
if (close (fd))
|
if (close (fd))
|
||||||
nm_warning ("Closing %s failed: %s", pidfile, strerror (errno));
|
fprintf (stderr, "Closing %s failed: %s", pidfile, strerror (errno));
|
||||||
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
@@ -291,7 +291,7 @@ check_pidfile (const char *pidfile)
|
|||||||
if (strcmp (process_name, "NetworkManager") == 0) {
|
if (strcmp (process_name, "NetworkManager") == 0) {
|
||||||
/* Check that the process exists */
|
/* Check that the process exists */
|
||||||
if (kill (pid, 0) == 0) {
|
if (kill (pid, 0) == 0) {
|
||||||
g_warning ("NetworkManager is already running (pid %ld)", pid);
|
fprintf (stderr, "NetworkManager is already running (pid %ld)", pid);
|
||||||
nm_running = TRUE;
|
nm_running = TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -469,12 +469,12 @@ main (int argc, char *argv[])
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (getuid () != 0) {
|
if (getuid () != 0) {
|
||||||
g_printerr ("You must be root to run NetworkManager!\n");
|
fprintf (stderr, "You must be root to run NetworkManager!\n");
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!g_module_supported ()) {
|
if (!g_module_supported ()) {
|
||||||
g_printerr ("GModules are not supported on your platform!");
|
fprintf (stderr, "GModules are not supported on your platform!");
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -518,10 +518,10 @@ main (int argc, char *argv[])
|
|||||||
/* Parse the config file */
|
/* Parse the config file */
|
||||||
if (config) {
|
if (config) {
|
||||||
if (!parse_config_file (config, &conf_plugins, &dhcp, &error)) {
|
if (!parse_config_file (config, &conf_plugins, &dhcp, &error)) {
|
||||||
g_warning ("Config file %s invalid: (%d) %s.",
|
fprintf (stderr, "Config file %s invalid: (%d) %s.",
|
||||||
config,
|
config,
|
||||||
error ? error->code : -1,
|
error ? error->code : -1,
|
||||||
(error && error->message) ? error->message : "unknown");
|
(error && error->message) ? error->message : "unknown");
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -532,10 +532,10 @@ main (int argc, char *argv[])
|
|||||||
config = g_strdup (NM_DEFAULT_SYSTEM_CONF_FILE);
|
config = g_strdup (NM_DEFAULT_SYSTEM_CONF_FILE);
|
||||||
parsed = parse_config_file (config, &conf_plugins, &dhcp, &error);
|
parsed = parse_config_file (config, &conf_plugins, &dhcp, &error);
|
||||||
if (!parsed) {
|
if (!parsed) {
|
||||||
g_warning ("Default config file %s invalid: (%d) %s.",
|
fprintf (stderr, "Default config file %s invalid: (%d) %s.",
|
||||||
config,
|
config,
|
||||||
error ? error->code : -1,
|
error ? error->code : -1,
|
||||||
(error && error->message) ? error->message : "unknown");
|
(error && error->message) ? error->message : "unknown");
|
||||||
g_free (config);
|
g_free (config);
|
||||||
config = NULL;
|
config = NULL;
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
@@ -547,10 +547,10 @@ main (int argc, char *argv[])
|
|||||||
if (!parsed) {
|
if (!parsed) {
|
||||||
config = g_strdup (NM_OLD_SYSTEM_CONF_FILE);
|
config = g_strdup (NM_OLD_SYSTEM_CONF_FILE);
|
||||||
if (!parse_config_file (config, &conf_plugins, &dhcp, &error)) {
|
if (!parse_config_file (config, &conf_plugins, &dhcp, &error)) {
|
||||||
g_warning ("Default config file %s invalid: (%d) %s.",
|
fprintf (stderr, "Default config file %s invalid: (%d) %s.",
|
||||||
config,
|
config,
|
||||||
error ? error->code : -1,
|
error ? error->code : -1,
|
||||||
(error && error->message) ? error->message : "unknown");
|
(error && error->message) ? error->message : "unknown");
|
||||||
g_free (config);
|
g_free (config);
|
||||||
config = NULL;
|
config = NULL;
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
@@ -565,10 +565,10 @@ main (int argc, char *argv[])
|
|||||||
|
|
||||||
/* Parse the state file */
|
/* Parse the state file */
|
||||||
if (!parse_state_file (state_file, &net_enabled, &wifi_enabled, &wwan_enabled, &error)) {
|
if (!parse_state_file (state_file, &net_enabled, &wifi_enabled, &wwan_enabled, &error)) {
|
||||||
g_warning ("State file %s parsing failed: (%d) %s.",
|
fprintf (stderr, "State file %s parsing failed: (%d) %s.",
|
||||||
state_file,
|
state_file,
|
||||||
error ? error->code : -1,
|
error ? error->code : -1,
|
||||||
(error && error->message) ? error->message : "unknown");
|
(error && error->message) ? error->message : "unknown");
|
||||||
/* Not a hard failure */
|
/* Not a hard failure */
|
||||||
}
|
}
|
||||||
g_clear_error (&error);
|
g_clear_error (&error);
|
||||||
@@ -582,9 +582,9 @@ main (int argc, char *argv[])
|
|||||||
int saved_errno;
|
int saved_errno;
|
||||||
|
|
||||||
saved_errno = errno;
|
saved_errno = errno;
|
||||||
nm_error ("Could not daemonize: %s [error %u]",
|
fprintf (stderr, "Could not daemonize: %s [error %u]",
|
||||||
g_strerror (saved_errno),
|
g_strerror (saved_errno),
|
||||||
saved_errno);
|
saved_errno);
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
if (write_pidfile (pidfile))
|
if (write_pidfile (pidfile))
|
||||||
|
Reference in New Issue
Block a user