Bug 42336 - [patch] ISO-fication of /usr/src/contrib/tcp_wrappers
Summary: [patch] ISO-fication of /usr/src/contrib/tcp_wrappers
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 4.6-STABLE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-09-02 21:10 UTC by yuri
Modified: 2017-01-09 20:14 UTC (History)
2 users (show)

See Also:
pfg: mfc-stable10+
pfg: mfc-stable9+
bugmeister: mfc-stable8?


Attachments
file.diff (324 bytes, patch)
2002-09-02 21:10 UTC, yuri
no flags Details | Diff
file.diff (275 bytes, patch)
2002-09-02 21:10 UTC, yuri
no flags Details | Diff
file.diff (1.13 KB, patch)
2002-09-02 21:10 UTC, yuri
no flags Details | Diff
Updated patch (7.37 KB, patch)
2014-10-11 15:31 UTC, Pedro F. Giffuni
no flags Details | Diff
Updated patch (8.38 KB, patch)
2014-10-11 17:14 UTC, Pedro F. Giffuni
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description yuri 2002-09-02 21:10:01 UTC
Conversion of /usr/include/tcpd.h file to modern-style
function declarations. Also removed __STDC__ idfefs
since it's always defined.

MySQL-server was using those functions w/out parameters.
And it worked correctly just by accident on i386 and
crased on Alpha. I asked MySQL folks to fix the usage
but now MySQL breaks with new gcc-3.2 and with old tcpd.h.

So this also fixes PR:
http://www.FreeBSD.org/cgi/query-pr.cgi?pr=ports/42327

Fix: -extern char *inet_cfg();               /* read inetd.conf file */
-extern void inet_set();                        /* remember internet service */
-extern int inet_get();                 /* look up internet service */
+extern char *inet_cfg(char *conf);      /* read inetd.conf file */
+extern void inet_set(char *name, int type);/* remember internet service */
+extern int inet_get(char *name);       /* look up internet service */

 #define WR_UNKNOWN     (-1)            /* service unknown */
 #define WR_NOT         1               /* may not be wrapped */
-extern char *percent_m();
+extern char *percent_m(char *obuf, char *ibuf);
#ifdef INET6
-extern struct addrinfo *find_inet_addr();
+extern struct addrinfo *find_inet_addr(char *name);
 #else
-extern struct hostent *find_inet_addr();
+extern struct hostent *find_inet_addr(char *name);
 #endif
-extern int check_dns();
-extern int check_path();
+extern int check_dns(char *host);
+extern int check_path(char *path, struct stat *st);


@@ -67,20 +67,28 @@
 /* Global functions. */

 #if defined(TLI) || defined(PTX) || defined(TLI_SEQUENT)
-extern void fromhost();                        /* get/validate client host info */
+extern void fromhost(struct request_info *);/* get/validate client host info */
 #else
 #define fromhost sock_host             /* no TLI support needed */
 #endif

-extern int hosts_access();             /* access control */
-extern void shell_cmd();               /* execute shell command */
-extern char *percent_x();              /* do %<char> expansion */
-extern void rfc931();                  /* client name from RFC 931 daemon */
-extern void clean_exit();              /* clean up and exit */
-extern void refuse();                  /* clean up and exit */
-extern char *xgets();                  /* fgets() on steroids */
-extern char *split_at();               /* strchr() and split */
-extern unsigned long dot_quad_addr();  /* restricted inet_addr() */
+int hosts_access(struct request_info *request);  /* access control */
+void shell_cmd(char *command);          /* execute shell command */
+char *percent_x(char *result, int result_len, char *string,
+  struct request_info *request);        /* do %<char> expansion */
+void rfc931(                            /* client name from RFC 931 daemon */
+#ifdef INET6
+        struct sockaddr *rmt_sin, struct sockaddr *our_sin, char *dest
+#else
+        struct sockaddr_in *rmt_sin, struct sockaddr_in *our_sin, char *dest
+#endif
+);
+
+void clean_exit(struct request_info *request);   /* clean up and exit */
+void refuse(struct request_info *request);       /* clean up and exit */
+char *xgets(char *ptr, int len, FILE *fp);       /* fgets() on steroids */
+char *split_at(char *string, int delimiter);     /* strchr() and split */
+unsigned long dot_quad_addr(char *str);          /* restricted inet_addr() */

 /* Global variables. */

@@ -97,13 +105,10 @@
   * attributes. Each attribute has its own key.
   */

-#ifdef __STDC__
+/* initialize request */
 extern struct request_info *request_init(struct request_info *,...);
+/* update request structure */
 extern struct request_info *request_set(struct request_info *,...);
-#else
-extern struct request_info *request_init();    /* initialize request */
-extern struct request_info *request_set();     /* update request structure */
-#endif

 #define RQ_FILE                1               /* file descriptor */
 #define RQ_DAEMON      2               /* server process (argv[0]) */
@@ -123,27 +128,27 @@
   * host_info structures serve as caches for the lookup results.
   */

-extern char *eval_user();              /* client user */
-extern char *eval_hostname();          /* printable hostname */
-extern char *eval_hostaddr();          /* printable host address */
-extern char *eval_hostinfo();          /* host name or address */
-extern char *eval_client();            /* whatever is available */
-extern char *eval_server();            /* whatever is available */
+extern char *eval_user(struct request_info *); /* client user */
+extern char *eval_hostname(struct host_info *host);    /* printable hostname */
+extern char *eval_hostaddr(struct host_info *);/* printable host address */
+extern char *eval_hostinfo(struct host_info *);        /* host name or address */
+extern char *eval_client(struct request_info *);/* whatever is available */
+extern char *eval_server(struct request_info *);/* whatever is available */
 #define eval_daemon(r) ((r)->daemon)   /* daemon process name */
 #define eval_pid(r)    ((r)->pid)      /* process id */

 /* Socket-specific methods, including DNS hostname lookups. */

-extern void sock_host();               /* look up endpoint addresses */
-extern void sock_hostname();           /* translate address to hostname */
-extern void sock_hostaddr();           /* address to printable address */
+extern void sock_host(struct request_info *);/* look up endpoint addresses */
+extern void sock_hostname(struct host_info *);/*translate address to hostname*/
+extern void sock_hostaddr(struct host_info *);/* address to printable address */
 #define sock_methods(r) \
        { (r)->hostname = sock_hostname; (r)->hostaddr = sock_hostaddr; }

 /* The System V Transport-Level Interface (TLI) interface. */

 #if defined(TLI) || defined(PTX) || defined(TLI_SEQUENT)
-extern void tli_host();                        /* look up endpoint addresses etc. */
+extern void tli_host(struct request_info *);/*look up endpoint addresses etc.*/
 #endif

  /*
@@ -152,13 +157,8 @@
   * everyone would have to include <setjmp.h>.
   */

-#ifdef __STDC__
 extern void tcpd_warn(char *, ...);    /* report problem and proceed */
 extern void tcpd_jump(char *, ...);    /* report problem and jump */
-#else
-extern void tcpd_warn();
-extern void tcpd_jump();
-#endif

 struct tcpd_context {
     char   *file;                      /* current file */
@@ -184,42 +184,44 @@
   * behavior.
   */

-extern void process_options();         /* execute options */
+/* execute options */
+extern void process_options(char   *options, struct request_info *request);
 extern int dry_run;                    /* verification flag */

 /* Bug workarounds. */

 #ifdef INET_ADDR_BUG                   /* inet_addr() returns struct */
 #define inet_addr fix_inet_addr
-extern long fix_inet_addr();
+extern long fix_inet_addr(char *string);
 #endif

 #ifdef BROKEN_FGETS                    /* partial reads from sockets */
 #define fgets fix_fgets
-extern char *fix_fgets();
+extern char *fix_fgets(char *buf, int len, FILE *fp);
 #endif

 #ifdef RECVFROM_BUG                    /* no address family info */
 #define recvfrom fix_recvfrom
-extern int fix_recvfrom();
+extern int fix_recvfrom(int sock, char *buf, int buflen, int flags,
+                        struct sockaddr *from, int *fromlen);
 #endif

 #ifdef GETPEERNAME_BUG                 /* claims success with UDP */
 #define getpeername fix_getpeername
-extern int fix_getpeername();
+extern int fix_getpeername(int sock, struct sockaddr *sa, int len);
 #endif

 #ifdef SOLARIS_24_GETHOSTBYNAME_BUG    /* lists addresses as aliases */
 #define gethostbyname fix_gethostbyname
-extern struct hostent *fix_gethostbyname();
+extern struct hostent *fix_gethostbyname(char *name);
 #endif

 #ifdef USE_STRSEP                      /* libc calls strtok() */
 #define strtok fix_strtok
-extern char *fix_strtok();
+extern char *fix_strtok(char *buf, char *sep);
 #endif

 #ifdef LIBC_CALLS_STRTOK               /* libc calls strtok() */
 #define strtok my_strtok
-extern char *my_strtok();
+extern char *my_strtok(char *buf, char *sep);
 #endif--NORwxjcR9q7PRxZtGyjL7O62DZZ8UP0XgrjT6h3pKNTa1lVG
Content-Type: text/plain; name="file.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="file.diff"

diff -u /usr/src/contrib/tcp_wrappers/inetcf.h /home/yuri/usr/src/contrib/tcp_wrappers/inetcf.h
--- /usr/src/contrib/tcp_wrappers/inetcf.h      Sun Mar 14 12:13:19 1999
+++ /home/yuri/usr/src/contrib/tcp_wrappers/inetcf.h    Fri Aug 23 22:22:45 2002
@@ -4,9 +4,9 @@
   * Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
   */
How-To-Repeat: N/A
Comment 1 yuri 2002-09-03 01:50:29 UTC
BTW: The updated copyright by the author allows to
modify the code ;)
ftp://ftp.porcupine.org/pub/security/tcp_wrappers_license
Comment 2 Ying-Chieh Liao freebsd_committer 2002-09-22 19:12:27 UTC
State Changed
From-To: open->closed

dup with pr/43227
Comment 3 Ying-Chieh Liao freebsd_committer 2002-09-22 19:51:14 UTC
State Changed
From-To: closed->open

oops... my fat fingers
Comment 4 Pedro F. Giffuni freebsd_committer 2014-10-11 15:31:09 UTC
Created attachment 148193 [details]
Updated patch

The first two patches were bogus (no apparent change),  and I don't find it much use in dropping the __STDC__ . I did take the chance to cleanup somewhat the spacing issues. This is pending testing.
Comment 5 Pedro F. Giffuni freebsd_committer 2014-10-11 17:14:02 UTC
Created attachment 148196 [details]
Updated patch
Comment 6 commit-hook freebsd_committer 2014-10-11 18:34:39 UTC
A commit references this bug:

Author: pfg
Date: Sat Oct 11 18:34:11 UTC 2014
New revision: 272949
URL: https://svnweb.freebsd.org/changeset/base/272949

Log:
  tcpd: complete function prototypes.

  This clears up at least a build issues on mysql-server
  ports. While here also replace some spaces with tabs
  in our headers.

  PR:		42336
  MFC after:	2 weeks

Changes:
  head/contrib/tcp_wrappers/inetcf.h
  head/contrib/tcp_wrappers/mystdarg.h
  head/contrib/tcp_wrappers/tcpd.h
  head/contrib/tcp_wrappers/tli-sequent.h
Comment 7 Oleg Sidorkin 2015-01-16 14:18:52 UTC
Is this patch going to be actually MFC'ed?
Comment 8 Pedro F. Giffuni freebsd_committer 2015-01-16 14:57:40 UTC
(In reply to osidorkin from comment #7)
I was planning to MFC it only to 10-stable.

Is there a use case for it?
Comment 9 Oleg Sidorkin 2015-01-16 15:18:27 UTC
(In reply to Pedro F. Giffuni from comment #8)

I'm experimenting with mysql-5.7 development release and it uses tcpwrappers inside c++ code.
However I don't know any issues with existing ports.
Comment 10 Pedro F. Giffuni freebsd_committer 2015-01-16 15:33:53 UTC
(In reply to osidorkin from comment #9)
The port has local patches to work around the issues.

I will MFC the patch soon to 10-stable and 9-stable.
Comment 11 commit-hook freebsd_committer 2015-01-17 01:21:02 UTC
A commit references this bug:

Author: pfg
Date: Sat Jan 17 01:20:29 UTC 2015
New revision: 277281
URL: https://svnweb.freebsd.org/changeset/base/277281

Log:
  MFC	r272947, r272950:

  tcpd: complete function prototypes.
  tcpd.h: add prototype for hosts_ctl

  This clears up at least a build issues on mysql-server
  ports. While here also replace some spaces with tabs
  in our headers.

  PR:	32808
  PR:	42336

Changes:
_U  stable/10/
  stable/10/contrib/tcp_wrappers/inetcf.h
  stable/10/contrib/tcp_wrappers/mystdarg.h
  stable/10/contrib/tcp_wrappers/tcpd.h
  stable/10/contrib/tcp_wrappers/tli-sequent.h
Comment 12 commit-hook freebsd_committer 2015-01-17 01:22:05 UTC
A commit references this bug:

Author: pfg
Date: Sat Jan 17 01:21:32 UTC 2015
New revision: 277282
URL: https://svnweb.freebsd.org/changeset/base/277282

Log:
  MFC	r272947, r272950:

  tcpd: complete function prototypes.
  tcpd.h: add prototype for hosts_ctl

  This clears up at least a build issues on mysql-server
  ports. While here also replace some spaces with tabs
  in our headers.

  PR:	32808
  PR:	42336

Changes:
  stable/9/contrib/tcp_wrappers/inetcf.h
  stable/9/contrib/tcp_wrappers/mystdarg.h
  stable/9/contrib/tcp_wrappers/tcpd.h
  stable/9/contrib/tcp_wrappers/tli-sequent.h
Comment 13 commit-hook freebsd_committer 2017-01-09 20:14:56 UTC
A commit references this bug:

Author: dim
Date: Mon Jan  9 20:14:21 UTC 2017
New revision: 311816
URL: https://svnweb.freebsd.org/changeset/base/311816

Log:
  MFC r257398 (by sbruno):

  Quiesce warnings by updating headerfile includes

  r257404 | sbruno | 2013-10-30 23:41:18 +0100 (Wed, 30 Oct 2013) | 9 lines

  Quiesce two warnings:

  1.  define the CODE * as const
  2.  restructure function to eliminate warning about exiting with no return.
      severity_map() never returns when it can't find an appropriate sysylog
      facility, and it longjmp()'s away into error code handling.  Keep this
      behavior by stashing the facility value found during our search and
      checking for -1 if found.

  MFC r257405 (by sbruno):

  Quiesce warning, which could be a bug IMO, by correctly defining the host_info
  structure name

  MFC r257406 (by sbruno):

  Queisce warning about undeclared function usage.

  yp_get_default_domain is defined in workaround.c but is not declared
  in any header file.  Tie the declaration to the same #define conditional
  used when the function is called, NETGROUP

  MFC r272949 (by pfg):

  tcpd: complete function prototypes.

  This clears up at least a build issues on mysql-server
  ports. While here also replace some spaces with tabs
  in our headers.

  PR:		42336

  MFC r272950 (by pfg):

  tcpd.h: add prototype for hosts_ctl

  According the hosts_access(3) man page the hosts_ctl() prototype
  should be in tcpd.h. For now, follow other declarations and don't
  add the arguments in the prototype.

  Reference:
  https://www.illumos.org/issues/4385

  PR:		32808

  MFC r311459:

  Put proper prototypes in tcpd.h

  Clang 4.0.0 complains about tcpd.h's not-really-prototypes, e.g.:

      /usr/include/tcpd.h:75:24: error: this function declaration is not a prototype [-Werror,-Wstrict-prototypes]
      extern int hosts_access();              /* access control */
                             ^

  To fix this, turn these declarations into real prototypes.  While here,
  garbage collect the incompatible rfc931() function from scaffold.c, as
  it is never used.

  Reviewed by:	emaste
  Differential Revision:	https://reviews.freebsd.org/D9052

  MFC r311461:

  Also remove unnecessary extern keywords from tcpd.h.

  Noticed by:	kib

  MFC r311556:

  After r311459, some ports can break, because a few of the newly added
  prototypes in <tcpd.h> use FILE.  Pull in a minimal forward declaration
  of FILE from <stdio.h> to minimize impact.  Sorry for the breakage.

  Reported by:	Shawn Webb <shawn.webb@hardenedbsd.org>

Changes:
_U  stable/9/
_U  stable/9/contrib/
  stable/9/contrib/tcp_wrappers/clean_exit.c
  stable/9/contrib/tcp_wrappers/hosts_access.c
  stable/9/contrib/tcp_wrappers/options.c
  stable/9/contrib/tcp_wrappers/percent_x.c
  stable/9/contrib/tcp_wrappers/rfc931.c
  stable/9/contrib/tcp_wrappers/scaffold.c
  stable/9/contrib/tcp_wrappers/shell_cmd.c
  stable/9/contrib/tcp_wrappers/tcpd.h
  stable/9/contrib/tcp_wrappers/update.c