Revision: 6535
http://ipcop.svn.sourceforge.net/ipcop/?rev=6535&view=rev
Author: owes
Date: 2012-04-09 12:56:26 +0000 (Mon, 09 Apr 2012)
Log Message:
-----------
Allow aliases when red is not static.
Fix setting netmask for aliases, strtok does not work for 'empty' fields.
Modified Paths:
--------------
ipcop/trunk/html/cgi-bin/aliases.cgi
ipcop/trunk/src/misc-progs/setaliases.c
ipcop/trunk/updates/2.1.0/ROOTFILES.i486-2.1.0
Modified: ipcop/trunk/html/cgi-bin/aliases.cgi
===================================================================
--- ipcop/trunk/html/cgi-bin/aliases.cgi 2012-04-09 09:34:24 UTC (rev
6534)
+++ ipcop/trunk/html/cgi-bin/aliases.cgi 2012-04-09 12:56:26 UTC (rev
6535)
@@ -16,7 +16,7 @@
# along with IPCop. If not, see <http://www.gnu.org/licenses/>.
#
# (c) Steve Bootes 2002/04/13 - Manage IP Aliases
-# Copyright (c) 2002-2011 The IPCop Team
+# Copyright (c) 2002-2012 The IPCop Team
#
# $Id$
@@ -255,11 +255,13 @@
$error = 'error';
}
-unless (($netsettings{'RED_COUNT'} >= 1) && ($netsettings{'RED_1_TYPE'} eq
'STATIC')) {
- &Header::openbox('100%', 'left', "$Lang::tr{'information messages'}:",
'warning');
- print "<font class='base'>$Lang::tr{'aliases not active'} </font>";
- &Header::closebox();
-}
+# Not fully verified if working properly. setaliases no longer checks on
RED==STATIC
+#
+#unless (($netsettings{'RED_COUNT'} >= 1) && ($netsettings{'RED_1_TYPE'} eq
'STATIC')) {
+# &Header::openbox('100%', 'left', "$Lang::tr{'information messages'}:",
'warning');
+# print "<font class='base'>$Lang::tr{'aliases not active'} </font>";
+# &Header::closebox();
+#}
#
# Second check box is for editing the list
Modified: ipcop/trunk/src/misc-progs/setaliases.c
===================================================================
--- ipcop/trunk/src/misc-progs/setaliases.c 2012-04-09 09:34:24 UTC (rev
6534)
+++ ipcop/trunk/src/misc-progs/setaliases.c 2012-04-09 12:56:26 UTC (rev
6535)
@@ -59,10 +59,10 @@
{
char s[STRING_SIZE];
char command[STRING_SIZE];
- char *aliasip;
- char *netmask;
- char *enabled;
- char *comment;
+ char aliasip[STRING_SIZE];
+ char netmask[STRING_SIZE];
+ char enabled[STRING_SIZE];
+ char comment[STRING_SIZE];
static struct option long_options[] =
{
@@ -110,12 +110,13 @@
verbose_printf(1, "No RED ethernet present. Exit.\n");
exit(0);
}
-
+#if 0
/* Now check the RED_TYPE - aliases currently only set when RED is STATIC.
*/
if (strcmp(ipcop_ethernet.red_type[1], "STATIC")) {
verbose_printf(1, "RED is not STATIC. Exit.\n");
exit(0);
}
+#endif
/* Now set up the new aliases from the config file */
if (!(file = fopen("/var/ipcop/ethernet/aliases", "r"))) {
@@ -125,16 +126,30 @@
int linecounter = 0;
while (fgets(s, STRING_SIZE, file) != NULL) {
+ char *running;
+ char *result;
+ int count = 0;
+
linecounter++;
if (s[strlen(s) - 1] == '\n')
s[strlen(s) - 1] = '\0';
- aliasip = strtok(s, ",");
- enabled = strtok(NULL, ",");
- comment = strtok(NULL, ",");
- netmask = strtok(NULL, ",");
+ running = strdupa(s);
+ result = strsep(&running, ",");
+ while (result) {
+ if (count == 0)
+ strcpy(aliasip, result);
+ if (count == 1)
+ strcpy(enabled, result);
+ if (count == 2)
+ strcpy(comment, result);
+ if (count == 3)
+ strcpy(netmask, result);
+ count++;
+ result = strsep(&running, ",");
+ }
- if ((aliasip == NULL) || (enabled == NULL)) {
+ if ((aliasip == NULL) || (enabled == NULL) || (count < 4)) {
fprintf(stderr, "Incomplete data line: in %s(%d)\n",
"/var/ipcop/ethernet/aliases", linecounter);
exit(1);
}
@@ -151,21 +166,28 @@
/* ip addr will set proper mask. /32 if alias outside RED ip
address range */
snprintf(command, STRING_SIZE - 1,
"/sbin/ip addr add %s dev %s label %s:alias",
- aliasip, ipcop_ethernet.device[RED][1],
ipcop_ethernet.device[RED][1]);
- verbose_printf(2, "Add alias %s/%s\n", aliasip,
ipcop_ethernet.netmask[RED][1]);
+ aliasip, ipcop_ethernet.red_device[1],
ipcop_ethernet.red_device[1]);
+ verbose_printf(1, "Add alias %s\n", aliasip);
}
else {
snprintf(command, STRING_SIZE - 1,
"/sbin/ip addr add %s/%s dev %s label %s:alias",
- aliasip, netmask, ipcop_ethernet.device[RED][1],
ipcop_ethernet.device[RED][1]);
- verbose_printf(2, "Add alias %s/%s\n", aliasip, netmask);
+ aliasip, netmask, ipcop_ethernet.red_device[1],
ipcop_ethernet.red_device[1]);
+ verbose_printf(1, "Add alias %s/%s\n", aliasip, netmask);
}
safe_system(command);
- memset(command, 0, STRING_SIZE);
- snprintf(command, STRING_SIZE - 1,
- "/usr/sbin/arping -q -c 1 -w 1 -i %s -S %s %s",
- ipcop_ethernet.device[RED][1], aliasip,
ipcop_ethernet.default_gateway);
- safe_system(command);
+ /*
+ TODO:
+ When not STATIC we do not have a default_gw in ethernet/settings
... So arping fails.
+ Do we need arping in such cases? Only useful for RED is STATIC?
+ */
+ if (!strcmp(ipcop_ethernet.red_type[1], "STATIC")) {
+ memset(command, 0, STRING_SIZE);
+ snprintf(command, STRING_SIZE - 1,
+ "/usr/sbin/arping -q -c 1 -w 1 -i %s -S %s %s",
+ ipcop_ethernet.device[RED][1], aliasip,
ipcop_ethernet.default_gateway);
+ safe_system(command);
+ }
}
return 0;
}
Modified: ipcop/trunk/updates/2.1.0/ROOTFILES.i486-2.1.0
===================================================================
--- ipcop/trunk/updates/2.1.0/ROOTFILES.i486-2.1.0 2012-04-09 09:34:24 UTC
(rev 6534)
+++ ipcop/trunk/updates/2.1.0/ROOTFILES.i486-2.1.0 2012-04-09 12:56:26 UTC
(rev 6535)
@@ -1,6 +1,7 @@
## please place IPCop files first, then packages sorted by alphabetical order
/etc/rc.d/rc.sysinit
/etc/rc.d/rc.updatered
+/home/httpd/cgi-bin/aliases.cgi
/home/httpd/cgi-bin/ddns.cgi
/home/httpd/cgi-bin/dhcp.cgi
/home/httpd/cgi-bin/hosts.cgi
@@ -28,6 +29,7 @@
/usr/local/bin/puzzleFwRules.pl
/usr/local/bin/restartsquid
/usr/local/bin/scheduler.pl
+/usr/local/bin/setaliases
/usr/local/sbin/updatekernel.pl
/usr/share/locale/af_ZA/LC_MESSAGES/ipcop.mo
/usr/share/locale/bg_BG/LC_MESSAGES/ipcop.mo
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
For Developers, A Lot Can Happen In A Second.
Boundary is the first to Know...and Tell You.
Monitor Your Applications in Ultra-Fine Resolution. Try it FREE!
http://p.sf.net/sfu/Boundary-d2dvs2
_______________________________________________
Ipcop-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ipcop-svn