Package: netplug Version: 1.2.9.2-1 Severity: normal Tags: patch Hello,
I'm sending patch for netplug which allow to specify custom script file via new param '-s'. It is usefull if you want to start another instance of netplug, or want to start netplug with custom script file (no with default which calling ifup/ifdown). Patch is attached, generated by hg diff against repository on: http://hg.serpentine.com/netplug -- Pali Rohár [email protected]
diff -r aaebd52fac19 lib.c
--- a/lib.c Sat Jun 26 09:36:45 2010 -0700
+++ b/lib.c Sat Mar 02 02:38:19 2013 +0100
@@ -29,6 +29,7 @@
#include "netplug.h"
+const char *script_file = NP_SCRIPT_DIR "/netplug";
void
do_log(int pri, const char *fmt, ...)
@@ -109,11 +110,11 @@
setpgrp(); /* become group leader */
do_log(LOG_INFO, "%s %s %s -> pid %d",
- NP_SCRIPT, ifname, action, getpid());
+ script_file, ifname, action, getpid());
- execl(NP_SCRIPT, NP_SCRIPT, ifname, action, NULL);
+ execl(script_file, script_file, ifname, action, NULL);
- do_log(LOG_ERR, NP_SCRIPT ": %m");
+ do_log(LOG_ERR, "%s: %m", script_file);
exit(1);
}
diff -r aaebd52fac19 main.c
--- a/main.c Sat Jun 26 09:36:45 2010 -0700
+++ b/main.c Sat Mar 02 02:38:19 2013 +0100
@@ -91,7 +91,7 @@
static void
usage(char *progname, int exitcode)
{
- fprintf(stderr, "Usage: %s [-DFP] [-c config-file] [-i interface] [-p pid-file]\n",
+ fprintf(stderr, "Usage: %s [-DFP] [-c config-file] [-s script-file] [-i interface] [-p pid-file]\n",
progname);
fprintf(stderr, "\t-D\t\t"
@@ -102,6 +102,8 @@
"do not autoprobe for interfaces (use with care)\n");
fprintf(stderr, "\t-c config_file\t"
"read interface patterns from this config file\n");
+ fprintf(stderr, "\t-s script_file\t"
+ "script file for probing interfaces, bringing them up or down\n");
fprintf(stderr, "\t-i interface\t"
"only handle interfaces matching this pattern\n");
fprintf(stderr, "\t-p pid_file\t"
@@ -219,7 +221,7 @@
int probe = 1;
int c;
- while ((c = getopt(argc, argv, "DFPc:hi:p:")) != EOF) {
+ while ((c = getopt(argc, argv, "DFPc:s:hi:p:")) != EOF) {
switch (c) {
case 'D':
debug = 1;
@@ -234,6 +236,9 @@
read_config(optarg);
cfg_read = 1;
break;
+ case 's':
+ script_file = optarg;
+ break;
case 'h':
fprintf(stderr, "netplugd version %s\n", NP_VERSION);
usage(argv[0], 0);
diff -r aaebd52fac19 man/man8/netplugd.8
--- a/man/man8/netplugd.8 Sat Jun 26 09:36:45 2010 -0700
+++ b/man/man8/netplugd.8 Sat Mar 02 02:38:19 2013 +0100
@@ -19,6 +19,7 @@
.Nm netplugd
.Op Fl FP
.Op Fl c Ar config_file
+.Op Fl s Ar script_file
.Op Fl i Ar interface_pattern
.Op Fl p Ar pid_file
.\"
@@ -117,6 +118,9 @@
.Pa /dev/null
as a config file.
.\"
+.It Fl s Ar script_file
+Specify an alternative script file path, override /etc/netplug.d/netplug
+.\"
.It Fl i Ar interface_pattern
Specify a pattern that will be used to match interface names that
.Nm
diff -r aaebd52fac19 netplug.h
--- a/netplug.h Sat Jun 26 09:36:45 2010 -0700
+++ b/netplug.h Sat Mar 02 02:38:19 2013 +0100
@@ -26,8 +26,6 @@
#include <linux/netlink.h>
#include <linux/rtnetlink.h>
-#define NP_SCRIPT NP_SCRIPT_DIR "/netplug"
-
/* configuration */
void read_config(char *filename);
@@ -37,6 +35,8 @@
void probe_interfaces(void);
void close_on_exec(int fd);
+extern const char *script_file;
+
extern int debug;
/* netlink interfacing */
signature.asc
Description: This is a digitally signed message part.

