Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Jun 2008 15:42:18 GMT
From:      Dennis Herrmann <adox@mcx2.org>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/124789: Cronline fix in vnstat 
Message-ID:  <200806201542.m5KFgIt3004382@www.freebsd.org>
Resent-Message-ID: <200806201550.m5KFo2Ec081087@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         124789
>Category:       ports
>Synopsis:       Cronline fix in vnstat
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jun 20 15:50:01 UTC 2008
>Closed-Date:
>Last-Modified:
>Originator:     Dennis Herrmann
>Release:        FreeBSD 7.0-RELEASE
>Organization:
>Environment:
FreeBSD contempt 7.0-RELEASE FreeBSD 7.0-RELEASE #4: Mon Mar 24 11:53:38 CET 2008     root@contempt:/usr/obj/usr/src/sys/MCX  i386

>Description:
Dan Pelleg found a bug in the cron line alias vnstat-cron ,he writed me an email and send me a patch file i checked it and fix few things. Accessorily i add two more Mirrors.

The crontab entry is run as "root". So the test may fail, because the
number of files is greater than one.

Here an example by Dan:

mail2# whoami
root
mail2# ls -l /variable/db/vnstat/
total 20
-rw-r--r--  1 root  wheel  2272 Apr 24 17:50 .sk0
-rw-r--r--  1 root  wheel  2272 Jun 15 11:25 .tun0
-rw-r--r--  1 root  wheel  2272 Apr 24 17:50 .xl0
-rw-r--r--  1 root  wheel  2272 Apr 24 17:50 .xl1
-rw-r--r--  1 root  wheel  2272 Jun 15 11:30 tun0
mail2# su ftp1 -c "ls -l /variable/db/vnstat"
total 4
-rw-r--r--  1 root  wheel  2272 Jun 15 11:30 tun0

Therefore you need to inhibit the listing of the dot-files. This is done
with the "-I" switch.

Dan Pelleg writed Teemu Toivola,the developer of vnstat, a mail .Teemu ratify the bug

"I did some testing with both FreeBSD and Linux. You are correct that
the cron line in its current form doesn't seem behave in all situations
as the user might expect. In the normal "after install" situation when
that directory doesn't contain any files, that cron entry will work
correctly since "ls dbdir" will return 0. It also works correctly when
there's at least one database to work with.

However, now (after I added the database backup feature) the problem
seems to be that since database backups are named according to the
interface name starting with a dot, it might not be clear enough for
the user that both the database file AND the backup file needs to be
removed if the aim is to disable monitoring of the last monitored
interface. Leaving those backups will make the cron line fail in its
current form if the directory looks something like this:

mail2# ls -l /variable/db/vnstat/
total 20
-rw-r--r--  1 root  wheel  2272 Apr 24 17:50 .sk0
-rw-r--r--  1 root  wheel  2272 Jun 15 11:25 .tun0
-rw-r--r--  1 root  wheel  2272 Apr 24 17:50 .xl0
-rw-r--r--  1 root  wheel  2272 Apr 24 17:50 .xl1

So yes, that cron line should now also include that -I and the
documentation for disabling the monitoring of interfaces updated.
However, it seems that the need of -I is only *BSD specific since I
can't reproduce that behaviour on Linux and the -I option has a
difference function (in Linux):

 -I, --ignore=PATTERN       do not list implied entries matching shell PATTERN

Without a pattern, ls either gives an error or the file listing of the
current directory depending of which shell is used." by Teemu Toivola
>How-To-Repeat:

>Fix:


Patch attached with submission follows:

--- Makefile.org        2008-02-24 12:03:55.000000000 +0100
+++ Makefile	2008-06-20 17:06:54.000000000 +0200
@@ -10,7 +10,9 @@
 PORTREVISION=	2
 CATEGORIES=	net
 MASTER_SITES=	http://humdi.net/vnstat/ \
-		http://mcx2.org/files/
+		http://mirror.mcx2.org/ \
+                http://ftp.uwsg.indiana.edu/FreeBSD/distfiles/ \
+                ftp://ftp.jpix.ad.jp/pub/FreeBSD/ports/distfiles/
 DISTNAME=	${PORTNAME}-${PORTVERSION}_bsd
 
 MAINTAINER=	adox@mcx2.org
@@ -25,7 +27,7 @@
 post-extract:
 	@cd ${WRKSRC} && ${CP} cron/vnstat vnstat-cron
 	@${REINPLACE_CMD} -e 's|/usr/bin|/usr/local/bin|g' \
-		-e 's|/var/lib|/var/db|g' ${WRKSRC}/vnstat-cron
+		-e 's|ls /var/lib|ls -l /var/db|g' ${WRKSRC}/vnstat-cron
 
 post-install:
 .if !defined(NOPORTDOCS)


>Release-Note:
>Audit-Trail:
>Unformatted:



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200806201542.m5KFgIt3004382>