Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 541728 - sys-process/lsof-4.87 compile error: redefinition of ‘struct tcphdr’ on hardened musl
Summary: sys-process/lsof-4.87 compile error: redefinition of ‘struct tcphdr’ on harde...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Hardened (show other bugs)
Hardware: AMD64 Linux
: Normal normal (vote)
Assignee: Gentoo musl team
URL:
Whiteboard:
Keywords:
Depends on: 596186
Blocks: musl-porting
  Show dependency tree
 
Reported: 2015-02-28 22:04 UTC by Cato Auestad
Modified: 2016-12-07 17:05 UTC (History)
2 users (show)

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


Attachments
lsof-4.87 remove glibc check (lsof-4.87-remove-glibc-check.patch,514 bytes, patch)
2015-02-28 22:04 UTC, Cato Auestad
Details | Diff
lsof-4.87 build log (lsof-build-log.log,9.11 KB, text/plain)
2015-02-28 22:05 UTC, Cato Auestad
Details
lsof-4.87 ebuild patch (lsof-ebuild.patch,450 bytes, patch)
2015-02-28 22:05 UTC, Cato Auestad
Details | Diff
emerge --info (lsof-emerge.log,4.05 KB, text/plain)
2015-02-28 22:06 UTC, Cato Auestad
Details
diff showing author modifications to Configure/dlsof.h (lsof-4.89B-needs_netinet_tcp_h.diff,1.75 KB, text/plain)
2015-03-01 20:50 UTC, Cato Auestad
Details
Sample of lsof 4.89B ebuild script (lsof-4.89-r99.ebuild,2.96 KB, text/plain)
2015-03-01 20:51 UTC, Cato Auestad
Details
diff showing modifications between 4.87 ebuild and 4.89 ebuild (lsof-4.89B-ebuild.diff,1.00 KB, text/plain)
2015-03-01 20:52 UTC, Cato Auestad
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Cato Auestad 2015-02-28 22:04:18 UTC
Created attachment 397712 [details, diff]
lsof-4.87 remove glibc check

Assign this to blueness@gentoo.org who maintains the musl branch

sys-process/lsof-4.87 does not compile on musl because a patch to lsof.h adds "#include <netinet/tcp.h>". Later in lsof.h file there is an include on dlsof.h, which itself has an include macro check on either netinet/tcp.h OR linux/tcp.h depending on whether glibc is found. Since glibc obviously is not found on musl, gcc tries to include linux/tcp.h then causing an "redefinition of struct" error in dfile.c. Trying to add the same include macro check on lsof.h fails because dsock.h, which includes lsof.h, uses enums not available in linux/tcp.h, but which are available in both glibc, musl and uclibc. 

Since there is no way the source code can compile with just linux/tcp.h, because of the missing enum, I have attached a patch which removes the check on glibc and always include netinet/tcp.h.
Comment 1 Cato Auestad 2015-02-28 22:05:05 UTC
Created attachment 397714 [details]
lsof-4.87 build log
Comment 2 Cato Auestad 2015-02-28 22:05:41 UTC
Created attachment 397716 [details, diff]
lsof-4.87 ebuild patch
Comment 3 Cato Auestad 2015-02-28 22:06:56 UTC
Created attachment 397718 [details]
emerge --info
Comment 4 Anthony Basile gentoo-dev 2015-02-28 23:22:30 UTC
(In reply to Cato Auestad from comment #3)
> Created attachment 397718 [details]
> emerge --info

Okay I've add this to the overlay.  We should try to get this in upstream.  Can you see if you can figure out how?
Comment 5 Cato Auestad 2015-03-01 00:08:26 UTC
Seems like lsof is maintained by a single individual, I'll get in touch and try to work something out.
Comment 6 Cato Auestad 2015-03-01 12:43:26 UTC
Note that this bug exists on version 4.88 as well.
Comment 7 Cato Auestad 2015-03-01 20:50:00 UTC
After discussions with the author he suggested that a better fix for this would be to add a test to Configure and a pre-processor test to dlsof.h which includes netinet/tcp.h if the Configure-test can't find the enum containing TCP_ESTABLISHED (and the like). 

He have updated the tarball on the source server and changed version to 4.89B. You can find the tarball here: ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/NEW/lsof_4.89B.linux.tar.bz2

I have created an ebuild for 4.89B (just a modified copy of 4.87) and done a successfull install on hardened/musl. Since this package is not musl specific I guess this bug should probably be reassigned to the maintainer of lsof so he can update this package "globally"?

For convenience I have added the following attachments to this bug:
* A copy of the modified ebuild I created
* A diff highlighting the changes I made to the 4.87 ebuild
* A diff highlighting the changes the author made to Configure and dlsof.h

Please advice of next steps to resolve this bug
Comment 8 Cato Auestad 2015-03-01 20:50:48 UTC
Created attachment 397818 [details]
diff showing author modifications to Configure/dlsof.h
Comment 9 Cato Auestad 2015-03-01 20:51:40 UTC
Created attachment 397820 [details]
Sample of lsof 4.89B ebuild script
Comment 10 Cato Auestad 2015-03-01 20:52:20 UTC
Created attachment 397822 [details]
diff showing modifications between 4.87 ebuild and 4.89 ebuild
Comment 11 Anthony Basile gentoo-dev 2015-03-02 11:38:40 UTC
(In reply to Cato Auestad from comment #8)
> Created attachment 397818 [details]
> diff showing author modifications to Configure/dlsof.h

Is there a url to this patch?  ie where's the repo showing the commit.
Comment 12 Cato Auestad 2015-03-02 18:08:05 UTC
(In reply to Anthony Basile from comment #11)
> (In reply to Cato Auestad from comment #8)
> > Created attachment 397818 [details]
> > diff showing author modifications to Configure/dlsof.h
> 
> Is there a url to this patch?  ie where's the repo showing the commit.

I checked with the author after your last comment and there is no URL to a repository for lsof. The source code for lsof is in a non-public repository. 

You can see the change by downloading 4.89B and do a diff on the previous version. As a temporary solution I could make a patch to 4.87 which implements the authors changes (related to the issue with netinet/tcp.h) in 4.89B on the musl overlay. But I imagine since this really is a new version we should rather stay up to date with upstream than patch older versions ourselves.
Comment 13 Anthony Basile gentoo-dev 2015-03-02 23:23:07 UTC
(In reply to Cato Auestad from comment #12)
> (In reply to Anthony Basile from comment #11)
> > (In reply to Cato Auestad from comment #8)
> > > Created attachment 397818 [details]
> > > diff showing author modifications to Configure/dlsof.h
> > 
> > Is there a url to this patch?  ie where's the repo showing the commit.
> 
> I checked with the author after your last comment and there is no URL to a
> repository for lsof. The source code for lsof is in a non-public repository. 
> 
> You can see the change by downloading 4.89B and do a diff on the previous
> version. As a temporary solution I could make a patch to 4.87 which
> implements the authors changes (related to the issue with netinet/tcp.h) in
> 4.89B on the musl overlay. But I imagine since this really is a new version
> we should rather stay up to date with upstream than patch older versions
> ourselves.

The reason I ask is that this is not my package, its maintained by base-system.  However, I would backport the fix if it were already upstream.
Comment 14 Cato Auestad 2015-03-03 13:03:19 UTC
(In reply to Anthony Basile from comment #13)
> (In reply to Cato Auestad from comment #12)
> > (In reply to Anthony Basile from comment #11)
> > > (In reply to Cato Auestad from comment #8)
> > > > Created attachment 397818 [details]
> > > > diff showing author modifications to Configure/dlsof.h
> > > 
> > > Is there a url to this patch?  ie where's the repo showing the commit.
> > 
> > I checked with the author after your last comment and there is no URL to a
> > repository for lsof. The source code for lsof is in a non-public repository. 
> > 
> > You can see the change by downloading 4.89B and do a diff on the previous
> > version. As a temporary solution I could make a patch to 4.87 which
> > implements the authors changes (related to the issue with netinet/tcp.h) in
> > 4.89B on the musl overlay. But I imagine since this really is a new version
> > we should rather stay up to date with upstream than patch older versions
> > ourselves.
> 
> The reason I ask is that this is not my package, its maintained by
> base-system.  However, I would backport the fix if it were already upstream.

As I mentioned on IRC, I guess you would either have to do a diff and patch on the 4.87 and 4.89B's Configure and dlsof.h to get it working on musl, or wait till 4.89 is out of beta and implemented by base-system. If there is anything else I can contribute with for resolution of this bug, let me know.
Comment 15 SpanKY gentoo-dev 2015-04-03 06:12:36 UTC
(In reply to Cato Auestad from comment #14)

lets just wait for the 4.89 final release
Comment 16 SpanKY gentoo-dev 2016-12-07 17:05:41 UTC
4.89 is stable, so there's nothing left here