Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 213788 - net-analyzer/flow-tools broken with pgsql
Summary: net-analyzer/flow-tools broken with pgsql
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High major (vote)
Assignee: Gentoo Netmon project
URL: http://sources.gentoo.org/viewcvs.py/...
Whiteboard:
Keywords:
: 303395 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-03-18 07:51 UTC by Rusnan R. Shaimardanov
Modified: 2010-02-08 12:49 UTC (History)
1 user (show)

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


Attachments
Patch to fix (flow-tools-0.68-dburi.patch,1.03 KB, patch)
2008-03-18 12:57 UTC, Rusnan R. Shaimardanov
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Rusnan R. Shaimardanov 2008-03-18 07:51:55 UTC
There is a bug in flow-export program included in flow-tools package.
When trying to export flow data to postgres or mysql, user gets the error:

$ /usr/bin/flow-export -f 5 -m DOCTETS,SRCADDR,DSTADDR,INPUT,OUTPUT,SRCPORT,DSTPORT,PROT -u "user:pass:localhost:5432:flow:raw_traffic" < /var/lib/flows/2008/2008-03/2008-03-18/ft-v05.2008-03-18.061500+0500
flow-export: Missing field in dbaseURI, expecting user:pwd:host:port:name:table.
/usr/bin/flow-export: Exported 0 records
.

This is because it flow-export.c there is a typo(?) in validating dbUri:

if (!db_user || !db_pwd || !db_host || !db_tmp || !db_name || !db_table) {

And the right line is:

if (!db_user || !db_pwd || !db_host || !db_port || !db_name || !db_table) {

The same typo is in mysql section.

Reproducible: Always

Steps to Reproduce:
1.Install flow-tools
2.Try to export flow data to postgresql using flow-export

Actual Results:  
flow-export prints error

Expected Results:  
adding data to database
Comment 1 Rusnan R. Shaimardanov 2008-03-18 12:57:38 UTC
Created attachment 146478 [details, diff]
Patch to fix
Comment 2 Jeroen Roovers (RETIRED) gentoo-dev 2009-05-26 01:29:40 UTC
Patch applied in flow-tools-0.68-r6. Thanks for reporting. Patch sent upstream.
Comment 3 Jeroen Roovers (RETIRED) gentoo-dev 2010-02-03 23:18:01 UTC
*** Bug 303395 has been marked as a duplicate of this bug. ***
Comment 4 Jeroen Roovers (RETIRED) gentoo-dev 2010-02-03 23:20:20 UTC
Reopening because of comments in bug #303395.

@Mike Nerone: Please have your say right here where it belongs. Please provide some actual evidence too that this patch is wrong.
Comment 5 Jeroen Roovers (RETIRED) gentoo-dev 2010-02-03 23:33:55 UTC
Comment on attachment 146478 [details, diff]
Patch to fix

The original goes like this:

1)db_tmp is initially set to whatever follows a colon after a couple of iterations.
2) Then db_tmp is used in atoi to get at db_port, an interger based on a string.
3) Then instead of db_port, db_tmp is used _again_ when checking if all required fields are initialised. Twice.

After the patch it's like this:

1) db_tmp is initially set to whatever follows a colon after a couple of iterations.
2) Then db_tmp is used in atoi to get at db_port, an interger based on a string.
3) Then the calculated db_port is checked along with the other fields.

Oh and one more thing. The patch you see here never made it into the tree whole - in the tree it doesn't remove that first line. See [URL].
Comment 6 Jeroen Roovers (RETIRED) gentoo-dev 2010-02-03 23:34:31 UTC
Wow, still fixed!
Comment 7 Mike Nerone 2010-02-03 23:58:46 UTC
Ok, I had assumed that the patch as given was applied. My bad. I'm still at a loss as to why the code works fine for me without the patch, nor do I see why it's invalid to check the string just like all of the other values.

But incidentally, in previous instances where I had a comment on an old, closed bug (and not always under an erroneous assumption as happened here ;D ), when I commented on the old bug, a Gentoo dev jumped on me and said, "Don't comment on old, closed bug! Open a new one!"
Comment 8 Mike Nerone 2010-02-05 19:16:59 UTC
I see what happened now.

There was no bug in the mysql code at all (and the change there should still be reverted): db_tmp was a string and checking the string is fine. It was needed because the connect code needs the port as an int.

In the postgresql part of the code, though, there's no need for db_tmp because the connect code wants the port as a string anyway, so db_port gets it as a string. The sanity check line was cut-and-pasted from the mysql code, though, which erroneously checks for db_tmp.

Only the line in the postgresql code needed to be fixed. This is why rush.ru hit the error (with postgresql) and I didn't (with mysql).
Comment 9 Jeroen Roovers (RETIRED) gentoo-dev 2010-02-06 17:17:12 UTC
(In reply to comment #8)
> There was no bug in the mysql code at all (and the change there should still be
> reverted): db_tmp was a string and checking the string is fine. It was needed
> because the connect code needs the port as an int.
Comment 10 Jeroen Roovers (RETIRED) gentoo-dev 2010-02-08 12:47:12 UTC
OK, I have bumped the revision to -r7 and edited the patch so that users get the pgsql patching applied, and not the mysql patching.