Revision: 6448
http://ipcop.svn.sourceforge.net/ipcop/?rev=6448&view=rev
Author: owes
Date: 2012-03-02 18:23:33 +0000 (Fri, 02 Mar 2012)
Log Message:
-----------
GUI cannot touch/create files in /var/log without suid helper.
Create directory /var/log/updates with nobody.nobody rights and move the files
there. Also add functions for easier access.
Modified Paths:
--------------
ipcop/trunk/config/rootfiles/common/ipcop
ipcop/trunk/html/cgi-bin/urlfilter.cgi
ipcop/trunk/lfs/ipcop
ipcop/trunk/src/libs/general-functions.pl
ipcop/trunk/src/scripts/blacklistupdate.pl
ipcop/trunk/updates/2.1.0/setup
Modified: ipcop/trunk/config/rootfiles/common/ipcop
===================================================================
--- ipcop/trunk/config/rootfiles/common/ipcop 2012-03-02 15:26:21 UTC (rev
6447)
+++ ipcop/trunk/config/rootfiles/common/ipcop 2012-03-02 18:23:33 UTC (rev
6448)
@@ -12,3 +12,4 @@
var/lib/squidguard/db/custom/blocked/urls
var/log/dyndns
var/log/fw_timeframe_log
+var/log/updates
Modified: ipcop/trunk/html/cgi-bin/urlfilter.cgi
===================================================================
--- ipcop/trunk/html/cgi-bin/urlfilter.cgi 2012-03-02 15:26:21 UTC (rev
6447)
+++ ipcop/trunk/html/cgi-bin/urlfilter.cgi 2012-03-02 18:23:33 UTC (rev
6448)
@@ -70,7 +70,6 @@
my $sourceurlfile = "/var/ipcop/proxy/blacklistupdate/blacklistupdate.urls";
my $updconffile = "/var/ipcop/proxy/blacklistupdate/blacklistupdate.conf";
-my $updflagfile = "/var/log/updateblacklist.last";
my $errormessage = '';
my $updatemessage = '';
@@ -1535,8 +1534,8 @@
<td colspan='2' class='base'><b>$Lang::tr{'urlfilter automatic blacklist
update'}</b>
END
;
- if (-e "$updflagfile") {
- $blacklistage = int(-M "$updflagfile");
+ $blacklistage = &General::ageupdate('blacklist.last');
+ if ($blacklistage != -1) {
print
" <b>[</b> <small><i>$Lang::tr{'urlfilter blacklist age 1'}
<b>$blacklistage</b> $Lang::tr{'urlfilter blacklist age 2'}</i></small>
<b>]</b>";
}
Modified: ipcop/trunk/lfs/ipcop
===================================================================
--- ipcop/trunk/lfs/ipcop 2012-03-02 15:26:21 UTC (rev 6447)
+++ ipcop/trunk/lfs/ipcop 2012-03-02 18:23:33 UTC (rev 6448)
@@ -88,7 +88,11 @@
# Touch empty timeframe log for firewall rules
touch /var/log/fw_timeframe_log;
- # Make dyndns log dir (the dir needs nobody owner for [Instand update]
from WebGUI)
+ # Make updates flagfile dir (the dir needs nobody owner for [Instant
Updates] from WebGUI)
+ mkdir -p /var/log/updates
+ chown nobody.nobody /var/log/updates
+
+ # Make dyndns log dir (the dir needs nobody owner for [Instant Update]
from WebGUI)
mkdir -p /var/log/dyndns
chown nobody.nobody /var/log/dyndns
Modified: ipcop/trunk/src/libs/general-functions.pl
===================================================================
--- ipcop/trunk/src/libs/general-functions.pl 2012-03-02 15:26:21 UTC (rev
6447)
+++ ipcop/trunk/src/libs/general-functions.pl 2012-03-02 18:23:33 UTC (rev
6448)
@@ -190,6 +190,33 @@
return "${days}d ${hours}h ${mins}m ${secs}s";
}
+#
+# Return age of update flagfile in days.
+# -1 in case no flagfile.
+#
+sub ageupdate
+{
+ my $filename = $_[0];
+ my $age = &General::age("/var/log/updates/${filename}");
+
+ if ($age =~ m/(\d{1,3})d/) {
+ return $1;
+ }
+ return -1;
+}
+
+#
+# Touch a flagfile in /var/log/updates.
+# Flagfile should be something like updates.last, blacklist.check, etc.
+#
+sub touchupdate
+{
+ my $filename = $_[0];
+
+ system("/usr/bin/touch /var/log/updates/${filename}");
+ system("/bin/chown nobody.nobody /var/log/updates/${filename}");
+}
+
sub validip
{
my $ip = $_[0];
@@ -1220,7 +1247,7 @@
}
}
- system('/usr/bin/touch', '/var/log/updates.check');
+ &General::touchupdate('update.check');
if (${General::version} eq $available->{"latest"}) {
# We are uptodate, nothing left to do
return 0;
@@ -1281,14 +1308,11 @@
return "$Lang::tr{'there are updates'}";
}
- my $age;
- if (-e '/var/log/updates.check') {
- $age = &General::age('/var/log/updates.check');
- }
- else {
+ my $age = &General::ageupdate('update.check');
+ if ($age == -1) {
$age = &General::age('/var/ipcop/patches/available.xml');
}
- if ($age =~ m/(\d{1,3})d/) {
+ if ($age =~ m/(\d{1,3})d*/) {
if ($1 >= 7) {
return "$Lang::tr{'updates is old1'} $1 $Lang::tr{'updates is
old2'}";
}
Modified: ipcop/trunk/src/scripts/blacklistupdate.pl
===================================================================
--- ipcop/trunk/src/scripts/blacklistupdate.pl 2012-03-02 15:26:21 UTC (rev
6447)
+++ ipcop/trunk/src/scripts/blacklistupdate.pl 2012-03-02 18:23:33 UTC (rev
6448)
@@ -38,7 +38,6 @@
my $sourceurlfile = "/var/ipcop/proxy/blacklistupdate/blacklistupdate.urls";
my $updconffile = "/var/ipcop/proxy/blacklistupdate/blacklistupdate.conf";
-my $updflagfile = "/var/log/updateblacklist.last";
my %updatesettings;
$updatesettings{'ENABLE_AUTOUPDATE'} = 'off';
@@ -233,8 +232,7 @@
&setpermissions ($dbdir);
- system("touch $updflagfile");
- system("chown nobody.nobody $updflagfile");
+ &General::touchupdate('blacklist.last');
system("/usr/local/bin/restartsquid");
Modified: ipcop/trunk/updates/2.1.0/setup
===================================================================
--- ipcop/trunk/updates/2.1.0/setup 2012-03-02 15:26:21 UTC (rev 6447)
+++ ipcop/trunk/updates/2.1.0/setup 2012-03-02 18:23:33 UTC (rev 6448)
@@ -70,6 +70,10 @@
chown -R nobody:nobody /var/lib/squidguard/db
+if [ ! -e /var/log/updates ]; then
+ mkdir -p /var/log/updates
+fi
+chown -R nobody:nobody /var/log/updates
#####
#
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
Ipcop-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ipcop-svn