Bug 182466

Summary: headers: make <resolv.h> self-contained
Product: Base System Reporter: Jan Beich <jbeich>
Component: kernAssignee: Yoshihiro Takahashi <nyan>
Status: Closed FIXED    
Severity: Affects Some People CC: herbert, madpilot, madpilot, nyan, orion
Priority: --- Keywords: easy, needs-qa, standards
Version: CURRENTFlags: nyan: mfc-stable14+
nyan: mfc-stable13+
Hardware: Any   
OS: Any   
See Also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=85741
Attachments:
Description Flags
res.diff none

Description Jan Beich freebsd_committer freebsd_triage 2013-09-28 20:30:00 UTC
Our resolv.h already includes a bunch of headers listed in resolver(3)
man page. Make the list complete by adding netinet/in.h for sockaddr_in.

This should reduce patching required when porting code written with
Linux or NetBSD in mind.

reinstating kern/85741

How-To-Repeat: $ cat a.c
#include <resolv.h>
int main() { return 0; }

$ cc a.c
In file included from a.c:1:
/usr/include/resolv.h:157:14: error: array has incomplete element type
      'struct sockaddr_in'
                nsaddr_list[MAXNS];     /*%< address of name server */
                           ^
/usr/include/resolv.h:156:9: note: forward declaration of 'struct sockaddr_in'
        struct sockaddr_in
               ^
/usr/include/resolv.h:171:18: error: field has incomplete type 'struct in_addr'
                struct in_addr  addr;
                                ^
/usr/include/resolv.h:171:10: note: forward declaration of 'struct in_addr'
                struct in_addr  addr;
                       ^
/usr/include/resolv.h:195:21: error: field has incomplete type 'struct sockaddr_in'
        struct sockaddr_in      sin;
                                ^
/usr/include/resolv.h:156:9: note: forward declaration of 'struct sockaddr_in'
        struct sockaddr_in
               ^
3 errors generated.
Comment 1 Herbert J. Skuhra 2017-12-13 12:06:08 UTC
Hi,

I am trying to build Asterisk 15.1.3 on 12.0-CURRENT (r326622) and the configure script fails with this error while checking for resolv.h.

Applying Jan's patch resolves the issue. Why hasn't this been committed yet?

Thanks.

-- 
Herbert
Comment 2 Herbert J. Skuhra 2018-01-12 09:58:21 UTC
NetBSD did exactly this in

revision 1.40
date: 2012-11-07 16:45:24 +0100;  author: christos;  state: Exp;  lines: +2 -1;
add <netinet/in.h> because it is needed for sockaddr_in.
Comment 3 Kubilay Kocak freebsd_committer freebsd_triage 2018-07-04 08:01:47 UTC
Reset status (cant be in progress without 'real' assignee).

CC askterisk maintainer
Comment 4 Guido Falsi freebsd_committer freebsd_triage 2018-07-04 09:54:51 UTC
I have no objection.

I have not seen the reported failure in the asterisk ports, but I have never tested the specific version reported here. Present versions of the asterisk ports (13 and 15) work fine and I don't see this impacting them.
Comment 5 Graham Perrin freebsd_committer freebsd_triage 2022-10-17 12:39:37 UTC
Keyword: 

    patch
or  patch-ready

– in lieu of summary line prefix: 

    [patch]

* bulk change for the keyword
* summary lines may be edited manually (not in bulk). 

Keyword descriptions and search interface: 

    <https://bugs.freebsd.org/bugzilla/describekeywords.cgi>
Comment 6 Orion Poplawski 2023-03-24 04:26:05 UTC
I'm running into this error trying to build sssd 2.8.2.
Comment 7 commit-hook freebsd_committer freebsd_triage 2024-01-08 11:54:14 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=58cf91d3b72a01777bacf72d66a648a744ae3143

commit 58cf91d3b72a01777bacf72d66a648a744ae3143
Author:     Jan Beich <jbeich@FreeBSD.org>
AuthorDate: 2024-01-08 11:52:08 +0000
Commit:     Yoshihiro Takahashi <nyan@FreeBSD.org>
CommitDate: 2024-01-08 11:52:08 +0000

    resolv: Add a required include to resolv.h

    Add a required include to resolv.h for sockaddr_in.  This should reduce
    patching required when porting code written with Linux or NetBSD in mind.

    PR:             182466
    MFC after:      1 week

 include/resolv.h        | 1 +
 lib/libc/net/resolver.3 | 5 +----
 2 files changed, 2 insertions(+), 4 deletions(-)
Comment 8 commit-hook freebsd_committer freebsd_triage 2024-01-15 10:34:51 UTC
A commit in branch stable/14 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=5a70219b209f4ba8e8244d3886d364da4c00e4df

commit 5a70219b209f4ba8e8244d3886d364da4c00e4df
Author:     Jan Beich <jbeich@FreeBSD.org>
AuthorDate: 2024-01-08 11:52:08 +0000
Commit:     Yoshihiro Takahashi <nyan@FreeBSD.org>
CommitDate: 2024-01-15 10:33:59 +0000

    resolv: Add a required include to resolv.h

    Add a required include to resolv.h for sockaddr_in.  This should reduce
    patching required when porting code written with Linux or NetBSD in mind.

    PR:             182466
    MFC after:      1 week

    (cherry picked from commit 58cf91d3b72a01777bacf72d66a648a744ae3143)

 include/resolv.h        | 1 +
 lib/libc/net/resolver.3 | 5 +----
 2 files changed, 2 insertions(+), 4 deletions(-)
Comment 9 commit-hook freebsd_committer freebsd_triage 2024-01-15 10:36:56 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=4487c6281b6a9347731a06aafada7be57aa2fe19

commit 4487c6281b6a9347731a06aafada7be57aa2fe19
Author:     Jan Beich <jbeich@FreeBSD.org>
AuthorDate: 2024-01-08 11:52:08 +0000
Commit:     Yoshihiro Takahashi <nyan@FreeBSD.org>
CommitDate: 2024-01-15 10:35:35 +0000

    resolv: Add a required include to resolv.h

    Add a required include to resolv.h for sockaddr_in.  This should reduce
    patching required when porting code written with Linux or NetBSD in mind.

    PR:             182466
    MFC after:      1 week

    (cherry picked from commit 58cf91d3b72a01777bacf72d66a648a744ae3143)

 include/resolv.h        | 1 +
 lib/libc/net/resolver.3 | 5 +----
 2 files changed, 2 insertions(+), 4 deletions(-)