Package: firestarter / 1.0.3-11

09_fix_ip_up.patch Patch series | download
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
From: Yann Verley <yann.verley@free.fr>
Subject: Restart firestarter after pppd establishes the link

---
 src/scriptwriter.c |   34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)

--- a/src/scriptwriter.c
+++ b/src/scriptwriter.c
@@ -29,7 +29,7 @@
 #include "policyview.h"
 
 #define PPP_HOOK_FILE "/etc/ppp/ip-up.local"
-const gchar* FIRESTARTER_HOOK = "sh "FIRESTARTER_CONTROL_SCRIPT" start\n";
+const gchar* FIRESTARTER_HOOK = "sh /etc/init.d/firestarter start\n";
 
 static const gchar *
 test_bool (const gchar *conf_key)
@@ -598,23 +598,45 @@
 void
 scriptwriter_write_ppp_hook (void)
 {
-	if (!file_exists ("/etc/ppp")) {
+	FILE *f;
+	gchar *path = "/etc/ppp/ip-up.d/1firestarter";
+
+	if (file_exists (path)) {
+		return;
+	}
+
+	if (!file_exists ("/etc/ppp/ip-up.d")) {
 		printf ("No ppp detected on system. Not adding starting hook\n");
 		return;
 	}
 
-	add_hook (PPP_HOOK_FILE);
-	chmod (PPP_HOOK_FILE, 0755);
+	printf ("Adding Firestarter PPP hook to %s\n", path);
+
+	f = fopen (path, "w");
+
+	if (f == NULL) {
+		perror ("Could not write firestarter PPP hook");
+		return;
+	}
+
+	fprintf (f, "#!/bin/sh\n%s", FIRESTARTER_HOOK);
+	fclose (f);
+
+	chmod (path, 00755);
 }
 
 void
 scriptwriter_remove_ppp_hook (void)
 {
-	if (!file_exists ("/etc/ppp/ip-up.local")) {
+	gchar *path = "/etc/ppp/ip-up.d/1firestarter";
+
+	if (!file_exists (path)) {
 		return;
 	}
 
-	remove_hook (PPP_HOOK_FILE);
+	if (unlink (path) == -1) {
+		perror ("Could not remove firestarter PPP hook");
+	}
 }
 
 void