gentoo: simplify OpenRC detection

This commit is contained in:
Robert Piasek
2011-02-23 12:24:50 -06:00
committed by Dan Williams
parent bd933b27a1
commit c957d68855

View File

@@ -54,31 +54,16 @@ static void openrc_start_lo_if_necessary()
*/
void nm_system_enable_loopback (void)
{
GFile *file;
GFileInputStream *in;
gchar buffer[BUFFER_SIZE];
gchar *comm, *readed, *tmp;
gssize r;
gchar *comm;
file = g_file_new_for_path ("/proc/1/comm");
in = g_file_read (file, NULL, NULL);
/* If anything goes wrong trying to open /proc/1/comm,
we will assume OpenRC. */
if (!in) {
/* If anything goes wrong trying to open /proc/1/comm, we will assume
OpenRC. */
if (!g_file_get_contents ("/proc/1/comm", &comm, NULL, NULL)) {
nm_log_info (LOGD_CORE, "NetworkManager is running with OpenRC...");
openrc_start_lo_if_necessary ();
return;
}
comm = g_strdup("");
while ((r = g_input_stream_read (G_INPUT_STREAM(in), buffer, BUFFER_SIZE, NULL, NULL)) > 0) {
readed = g_strndup (buffer, r);
tmp = g_strconcat (comm, readed, NULL);
g_free (comm);
g_free (readed);
comm = tmp;
}
if (g_strstr_len (comm, -1, "systemd")) {
/* We use the generic loopback enabler if using systemd. */
nm_log_info (LOGD_CORE, "NetworkManager is running with systemd...");