Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 194650 - net-analyzer/darkstat-{3.0619, 3.0.707} version bump
Summary: net-analyzer/darkstat-{3.0619, 3.0.707} version bump
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: New packages (show other bugs)
Hardware: All Linux
: High enhancement
Assignee: Peter Volkov (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-10-03 20:41 UTC by Tiger
Modified: 2007-11-03 17:34 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
a new init script (darkstat.init,1.55 KB, text/plain)
2007-11-01 19:14 UTC, Jukka Ruohonen
Details
a new conf.d script (darkstat.confd,929 bytes, text/plain)
2007-11-01 19:14 UTC, Jukka Ruohonen
Details
patch file for confd (confd.patch,1.36 KB, patch)
2007-11-01 20:01 UTC, Jukka Ruohonen
Details | Diff
patch file for initd (initd.patch,1.26 KB, patch)
2007-11-01 20:02 UTC, Jukka Ruohonen
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Tiger 2007-10-03 20:41:16 UTC
I have tested thoses new versions and they work fine (just copy the last ebuild with new version number), but without the runscript.
The runscript seems to have troubles with creation of pidfile, don't know how to fix it after testing some solutions.
Maybe because darkstat is running two instances, and the pid in /var/run/darkstat.pid is wrong. 

Reproducible: Always

Steps to Reproduce:
Comment 1 Peter Volkov (RETIRED) gentoo-dev 2007-10-04 09:11:59 UTC
Tiger, thank you for report. While I'm working on this could you explain is there any specific interest in version 3.0619?
Comment 2 Tiger 2007-10-04 15:28:02 UTC
There's no specifics interest for this, I just include this version to inform you about new versions availables.
I'm working on the initscript (I found the same problem with the net-irc/inspircd initscript), but I don't find any specific documentation about initscript and policy for thoses scripts.
Comment 3 Peter Volkov (RETIRED) gentoo-dev 2007-10-04 20:51:29 UTC
For documentation see handbook:
http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=2&chap=4#doc_chap4

The solution for pid problem is to use --pidfile darkstat option instead of start-stop-daemon option. If you are interested in my progress take a look at my overlay:
http://overlays.gentoo.org/dev/pva/browser/net-analyzer/darkstat

The problem is that I'm still thinking how to pass FILTER to darkstat. Current implementation does not work. Other things should work.
Comment 4 Tiger 2007-10-04 22:43:31 UTC
I found the problem, add that in initscript :

[ -n "${FILTER}" ] && DARK_OPTS="${DARK_OPTS} -f '${FILTER}'"

darkstat only accept filters with ''.
Comment 5 Peter Volkov (RETIRED) gentoo-dev 2007-10-05 06:18:48 UTC
Sorry to ask, but have you tested it? What is your baselayout version? That was the first solution I thought about and it does not work here: 

camobap ~ # /etc/init.d/darkstat start
 * Starting darkstat on ath0 ...

start-stop-daemon --start --exec /usr/sbin/darkstat -- --chroot / --pidfile /var/run/darkstat.pid --no-promisc --no-dns --user darkstat -i ath0 -p 668 -b 0.0.0.0 --daylog /var/lib/darkstat/darkstat.log -f 'host 87.250.251.8'
darkstat 3.0.707 (built with libpcap 2.4)

error: illegal argument: "87.250.251.8'"

usage: darkstat -i interface
[snip]

See I've inserted echo of the actual command to run. If I run the same command from line it works. I have to find the cause of this behavior before bump.
Comment 6 Peter Volkov (RETIRED) gentoo-dev 2007-10-05 07:22:35 UTC
Well. I've updated init script and now it works. But that's workaround which I'd like to fix...
Comment 7 Tiger 2007-10-05 09:35:57 UTC
I have tested only from command line, but it's very strange to not work in initscript, I'm working on and it should be fixed.

I have two questions about your ebuild :

1) why you compile darkstat with a virtual directory for chroot ? (I think we can create a /var/lib/darkstat/chroot empty folder for it if needed)

2) Is / chroot directory secure ? I seen you fix the default chroot to root filesystem ([ -z "${CHROOT}" ] && CHROOT="/"). Is there a special reaso for it ? (darkstat manual say  "For security reasons, this directory should be empty, ..")
Comment 8 Tiger 2007-10-05 13:22:22 UTC
Yawn! I found how to pass filter args in the initscript !

@@ -36,7 +36,6 @@
 	[ -n "${PORT}" ] && DARK_OPTS="${DARK_OPTS} -p ${PORT}"
 	[ -n "${ADDRESS}" ] && DARK_OPTS="${DARK_OPTS} -b ${ADDRESS}"
 	[ -n "${DAYLOGFILE}" ] && DARK_OPTS="${DARK_OPTS} --daylog ${DAYLOGFILE}"
-	[ -n "${FILTER}" ] && DARK_OPTS="${DARK_OPTS} -f ${FILTER}"
 
 	# Defaults:
 	[ -z "${CHROOT}" ] && CHROOT="/"
@@ -50,9 +49,10 @@
 	# If ${PIDFILE} exist darkstat fails to start
 	[ -f ${PIDFILE} ] && rm ${PIDFILE}
 	ebegin "Starting darkstat on ${INTERFACE}"
-	start-stop-daemon --start --exec /usr/sbin/darkstat -- \
+	start-stop-daemon --start --quiet --exec /usr/sbin/darkstat -- \
 			--chroot ${CHROOT} --pidfile ${PIDFILE} \
-			${DARK_OPTS} ${DARKSTAT_OPTS}
+			${DARKSTAT_OPTS} ${DARK_OPTS} -f "$FILTER" \
+			&> /dev/null
 	eend $?
 }

It was a long way, I didn't understand why it's the only way to pass filter arguments in the initscript.
Comment 9 Tiger 2007-10-05 14:02:07 UTC
When we merge darkstat again we have an access violation because /var/lib/darkstat is not owned by darkstat user.

This patch fix that :

 @@ -30,7 +30,6 @@
 	newconfd "${FILESDIR}"/darkstat-confd.new darkstat
 
 	keepdir /var/lib/darkstat
-	chown darkstat /var/lib/darkstat
 }
 
 pkg_preinst() {
@@ -38,6 +37,8 @@
 }
 
 pkg_postinst() {
+	chown darkstat:darkstat "${ROOT}"/var/lib/darkstat
+
 	elog "WARNING: the darkstat init script has changed"
 	elog "To start different darkstat instances which will listen on a different"
 	elog "interfaces create in /etc/init.d directory the 'darkstat.if' symlink to"
Comment 10 Markus Ullmann (RETIRED) gentoo-dev 2007-11-01 13:58:42 UTC
meh, somehow this was hidden in my named search, had a user on irc with a request to bump it, so did it, I guess this will be an -r1 then. Sorry
Comment 11 Jukka Ruohonen 2007-11-01 19:13:42 UTC
I requested the bump in the comment #10 and I too was indeed a little hasty in not noticing the mentioned problems.

Few comments on the basis of 3.0.707.

1. The program chroots automatically to /var/empty. This is determined in the Makefile and it can be changed there with --with-chroot-dir /var/foo.

2. The above applies also to the UID/GID that the program choosen to drop privileges to. Whilst this can changed again at compile time by using the --with-privdrop-user, there is probably no need to patch the Makefile due (a) the program chooses the user 'nobody' that is in the default Gentoo install and used by many other networking programs (c.f. e.g. net-analyzer/ngrep) and (b) because this can be specified with a command line argument at runtime.

3. Due to the above two reasons, there are no access violations whatsoever.

4. Talked to Markus in IRC and it was decided that probably a reasonably enough way to handle the chroot/user-dilemma is to provide options for these in the conf.d-file with a warning that if an user wants to change these, permissions must be changed accordingly. Alternatively a new 'darkstat'-user can be created.

5. The mandatory chroot-option caused the pidfile-problems; I followed the ideas laid down in the comment #8.

6. Ditto for the filtering options.

7. New conf.d and init scripts are provided as attachments.
Comment 12 Jukka Ruohonen 2007-11-01 19:14:15 UTC
Created attachment 134939 [details]
a new init script
Comment 13 Jukka Ruohonen 2007-11-01 19:14:41 UTC
Created attachment 134941 [details]
a new conf.d script
Comment 14 Jukka Ruohonen 2007-11-01 20:01:26 UTC
Created attachment 134947 [details, diff]
patch file for confd
Comment 15 Jukka Ruohonen 2007-11-01 20:02:09 UTC
Created attachment 134949 [details, diff]
patch file for initd
Comment 16 Peter Volkov (RETIRED) gentoo-dev 2007-11-03 16:14:30 UTC
Tiger, actually default chroot "/" is not safe, but I just wanted to mimic behavior of named and dhcp which by default do not use chroot but create them on user request. But I see the difference: both that packages are client and server. So if you need only client you do not need chroot. So I've changed ebuild and now it'll create /var/lib/darkstat directory for chroot, while it's still possible to overide default value both at runtime and build time (for latter, see ebuild)

Fix for FILTER is good and taken.

chown is a bug in portage and I've added workaround.

Jukka, /var/empty is not the best solution. It's used by sshd (man sshd). Also personally I do not like user "nobody" to own all daemons. It's simple to create different users for different daemons and that's adds some security with no harm at all. And note, gentoo do not use bashisms in init.d scripts, thus [[ ]] should be [ ] with all consequences.

That's said, all problems seems to be solved so I'm going to test it a bit and bump in an hour.
Comment 17 Peter Volkov (RETIRED) gentoo-dev 2007-11-03 17:34:13 UTC
Thank you all, guys. darkstat-3.0.707-r1 is in the tree. I hope I did not missed anything. Enjoy :)