summaryrefslogtreecommitdiffstats
path: root/networkmanager/NuTyX.patch
blob: a50b51e2b364bc51d9709d363379ff81713a4581 (plain)
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
--- b/config.h.in	2011-05-07 13:34:44.000000000 +1000
+++ a/config.h.in	2011-05-07 13:34:44.000000000 +1000
@@ -180,6 +180,9 @@
 /* Define if you have Gentoo */
 #undef TARGET_GENTOO
 
+/* Define if you have NuTyX */
+#undef TARGET_NUTYX
+
 /* Define if you have linexa */
 #undef TARGET_LINEXA
 
--- b/configure.ac	2011-05-07 13:34:44.000000000 +1000
+++ a/configure.ac	2011-05-07 13:34:44.000000000 +1000
@@ -107,7 +107,7 @@
 dnl
 AC_C_BIGENDIAN
 
-AC_ARG_WITH(distro, AS_HELP_STRING([--with-distro=DISTRO], [Specify the Linux distribution to target: One of redhat, suse, gentoo, debian, arch, slackware, paldo, mandriva, pardus, linexa or exherbo]))
+AC_ARG_WITH(distro, AS_HELP_STRING([--with-distro=DISTRO], [Specify the Linux distribution to target: One of redhat, suse, gentoo, debian, arch, slackware, paldo, mandriva, pardus, linexa, exherbo or nutyx]))
 if test "z$with_distro" = "z"; then
 	AC_CHECK_FILE(/etc/redhat-release,with_distro="redhat")
 	AC_CHECK_FILE(/etc/SuSE-release,with_distro="suse")
@@ -121,6 +121,7 @@
 	AC_CHECK_FILE(/etc/pardus-release,with_distro="pardus")
 	AC_CHECK_FILE(/etc/linexa-release,with_distro="linexa")
 	AC_CHECK_FILE(/etc/exherbo-release,with_distro="exherbo")
+	AC_CHECK_FILE(/etc/nutyx-version,with_distro="nutyx")
 	if test "z$with_distro" = "z"; then
 		with_distro=`lsb_release -is`
 	fi
@@ -132,7 +133,7 @@
 	exit 1
 else
 	case $with_distro in
-		redhat|suse|gentoo|debian|slackware|arch|paldo|frugalware|mandriva|pardus|linexa|exherbo|generic) ;;
+		redhat|suse|gentoo|debian|slackware|arch|paldo|frugalware|mandriva|pardus|linexa|exherbo|generic|nutyx) ;;
 		*)
 			echo "Your distribution (${with_distro}) is not yet supported!  (patches welcome)"
 			exit 1
@@ -205,6 +206,11 @@
   AC_DEFINE(TARGET_EXHERBO, 1, [Define if you have Exherbo])
 fi
 
+AM_CONDITIONAL(TARGET_NUTYX, test x"$with_distro" = xnutyx)
+if test x"$with_distro" = xnutyx; then
+  AC_DEFINE(TARGET_NUTYX, 1, [Define if you have NuTyX])
+fi
+
 dnl
 dnl Distribution version string
 dnl
--- b/src/backends/Makefile.am	2011-05-07 13:34:44.000000000 +1000
+++ a/src/backends/Makefile.am	2011-05-07 13:34:44.000000000 +1000
@@ -64,6 +64,10 @@
 libnmbackend_la_SOURCES += NetworkManagerExherbo.c
 endif
 
+if TARGET_NUTYX
+libnmbackend_la_SOURCES += NetworkManagerNuTyX.c
+endif
+
 libnmbackend_la_LIBADD += \
 	$(top_builddir)/src/logging/libnm-logging.la \
 	$(LIBNL_LIBS) \
--- b/src/backends/NetworkManagerNuTyX.c	1970-01-01 10:00:00.000000000 +1000
+++ a/src/backends/NetworkManagerNuTyX.c	2011-05-07 13:34:44.000000000 +1000
@@ -0,0 +1,107 @@
+/* NetworkManager -- Network link manager
+ *
+ * Jürg Billeter <juerg@paldo.org>
+ *
+ * Adapted for NuTyX by piernov <piernov@piernov.org>
+ * Heavily based on NetworkManagerRedhat.c by Dan Williams <dcbw@redhat.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * (C) Copyright 2004 Red Hat, Inc.
+ * (C) Copyright 2006 Jürg Billeter
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+//#include <stdio.h>
+//#include <string.h>
+//#include <stdlib.h>
+
+#include "NetworkManagerGeneric.h"
+//#include "nm-system.h"
+#include "NetworkManagerUtils.h"
+#include "nm-logging.h"
+
+/*
+ * nm_backend_enable_loopback
+ *
+ * Bring up the loopback interface
+ *
+ */
+void nm_backend_enable_loopback (void)
+{
+       nm_spawn_process ("/etc/rc.d/init.d/localnet restart");
+}
+
+/*
+ * nm_backend_update_dns
+ *
+ * Invalidate the nscd host cache, if it exists, since
+ * we changed resolv.conf.
+ *
+ */
+void nm_backend_update_dns (void)
+{
+        if (g_file_test("/var/run/nscd/nscd.pid", G_FILE_TEST_EXISTS))
+               nm_log_info (LOGD_DNS, "Clearing nscd hosts cache.");
+               nm_spawn_process ("/usr/sbin/nscd -i hosts");
+}
+
+/*
+ * nm_backend_ipv6_use_tempaddr
+ *
+ * Get net.ipv6.conf.default.use_tempaddr value from /etc/sysctl.conf or
+ * /lib/sysctl.d/sysctl.conf
+ *
+ */
+int nm_backend_ipv6_use_tempaddr (void)
+{
+	char *contents = NULL;
+	gsize len = 0;
+	const char *group_name = "[forged_group]\n";
+	char *sysctl_data = NULL;
+	GKeyFile *keyfile;
+	GError *error = NULL;
+	int tmp, ret = -1;
+
+	/* Read file contents to a string. */
+	if (!g_file_get_contents ("/etc/sysctl.conf", &contents, &len, NULL))
+		if (!g_file_get_contents ("/lib/sysctl.d/sysctl.conf", &contents, &len, NULL))
+			return -1;
+
+	/* Prepend a group so that we can use GKeyFile parser. */
+	sysctl_data = g_strdup_printf ("%s%s", group_name, contents);
+
+	keyfile = g_key_file_new ();
+	if (keyfile == NULL)
+		goto done;
+
+	if (!g_key_file_load_from_data (keyfile, sysctl_data, len + strlen (group_name), G_KEY_FILE_NONE, NULL))
+		goto done;
+
+	tmp = g_key_file_get_integer (keyfile, "forged_group", "net.ipv6.conf.default.use_tempaddr", &error);
+	if (error == NULL)
+		ret = tmp;
+
+done:
+	g_free (contents);
+	g_free (sysctl_data);
+	g_clear_error (&error);
+	g_key_file_free (keyfile);
+
+	return ret;
+}