mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-04-22 04:40:47 +02:00
gentoo: simplify OpenRC detection
This commit is contained in:
parent
bd933b27a1
commit
c957d68855
1 changed files with 5 additions and 20 deletions
|
|
@ -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...");
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue