gentoo: simplify OpenRC detection
This commit is contained in:

committed by
Dan Williams

parent
bd933b27a1
commit
c957d68855
@@ -54,31 +54,16 @@ static void openrc_start_lo_if_necessary()
|
|||||||
*/
|
*/
|
||||||
void nm_system_enable_loopback (void)
|
void nm_system_enable_loopback (void)
|
||||||
{
|
{
|
||||||
GFile *file;
|
gchar *comm;
|
||||||
GFileInputStream *in;
|
|
||||||
gchar buffer[BUFFER_SIZE];
|
|
||||||
gchar *comm, *readed, *tmp;
|
|
||||||
gssize r;
|
|
||||||
|
|
||||||
file = g_file_new_for_path ("/proc/1/comm");
|
/* If anything goes wrong trying to open /proc/1/comm, we will assume
|
||||||
in = g_file_read (file, NULL, NULL);
|
OpenRC. */
|
||||||
|
if (!g_file_get_contents ("/proc/1/comm", &comm, NULL, NULL)) {
|
||||||
/* If anything goes wrong trying to open /proc/1/comm,
|
nm_log_info (LOGD_CORE, "NetworkManager is running with OpenRC...");
|
||||||
we will assume OpenRC. */
|
|
||||||
if (!in) {
|
|
||||||
openrc_start_lo_if_necessary ();
|
openrc_start_lo_if_necessary ();
|
||||||
return;
|
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")) {
|
if (g_strstr_len (comm, -1, "systemd")) {
|
||||||
/* We use the generic loopback enabler if using systemd. */
|
/* We use the generic loopback enabler if using systemd. */
|
||||||
nm_log_info (LOGD_CORE, "NetworkManager is running with systemd...");
|
nm_log_info (LOGD_CORE, "NetworkManager is running with systemd...");
|
||||||
|
Reference in New Issue
Block a user