forked from nm-l2tp/NetworkManager-l2tp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.c
85 lines (68 loc) · 1.66 KB
/
utils.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// SPDX-License-Identifier: GPL-2.0+
/*
* Dan Williams <dcbw@redhat.com>
*
* (C) Copyright 2010 Red Hat, Inc.
* (C) Copyright 2019 Douglas Kosovic <doug@uq.edu.au>
*/
#include "nm-default.h"
#include "utils.h"
#include "nm-utils/nm-shared-utils.h"
NML2tpIpsecDaemon
check_ipsec_daemon (const char *path)
{
const char *argv[] = { path, "--version", NULL };
g_autofree char *output = NULL;
if (path == NULL)
return NM_L2TP_IPSEC_DAEMON_UNKNOWN;
if (g_spawn_sync (NULL, (char **) argv, NULL, 0, NULL, NULL, &output, NULL, NULL, NULL)) {
if (!output)
return NM_L2TP_IPSEC_DAEMON_UNKNOWN;
if (strstr (output, " strongSwan "))
return NM_L2TP_IPSEC_DAEMON_STRONGSWAN;
if (strstr (output, " Libreswan "))
return NM_L2TP_IPSEC_DAEMON_LIBRESWAN;
if (strstr (output, " Openswan "))
return NM_L2TP_IPSEC_DAEMON_OPENSWAN;
}
return NM_L2TP_IPSEC_DAEMON_UNKNOWN;
}
const char *
nm_find_ipsec (void)
{
static const char *ipsec_binary_paths[] =
{
"/sbin/ipsec",
"/usr/sbin/ipsec",
"/usr/local/sbin/ipsec",
"/sbin/strongswan",
"/usr/sbin/strongswan",
"/usr/local/sbin/strongswan",
NULL
};
const char **ipsec_binary = ipsec_binary_paths;
while (*ipsec_binary != NULL) {
if (g_file_test (*ipsec_binary, G_FILE_TEST_EXISTS))
break;
ipsec_binary++;
}
return *ipsec_binary;
}
const char *
nm_find_l2tpd (void)
{
static const char *l2tp_binary_paths[] =
{
"/sbin/xl2tpd",
"/usr/sbin/xl2tpd",
"/usr/local/sbin/xl2tpd",
NULL
};
const char **l2tp_binary = l2tp_binary_paths;
while (*l2tp_binary != NULL) {
if (g_file_test (*l2tp_binary, G_FILE_TEST_EXISTS))
break;
l2tp_binary++;
}
return *l2tp_binary;
}