qi: Make is_readable() function more flatter
[dragora.git] / patches / tcp_wrappers / expand_remote_port
blobe35fc7ecd937b0f5eda883c7906c93249cb35b9e
1 diff -ruN tcp_wrappers_7.6.orig/eval.c tcp_wrappers_7.6/eval.c
2 --- tcp_wrappers_7.6.orig/eval.c        1995-01-30 19:51:46.000000000 +0100
3 +++ tcp_wrappers_7.6/eval.c     2004-11-04 13:59:01.000000000 +0100
4 @@ -98,6 +98,28 @@
5      }
6  }
7  
8 +/* eval_port - return string with the port */
9 +char   *eval_port(saddr)
10 +#ifdef INET6
11 +struct sockaddr *saddr;
12 +#else
13 +struct sockaddr_in *saddr;
14 +#endif
16 +    static char port[16];
17 +    if (saddr != 0) {
18 +        sprintf(port, "%u",
19 +#ifdef INET6
20 +            ntohs(((struct sockaddr_in *)saddr)->sin_port));
21 +#else
22 +            ntohs(saddr->sin_port));
23 +#endif
24 +    } else {
25 +       strcpy(port, "0");
26 +    }
27 +    return (port);
30  /* eval_client - return string with as much about the client as we know */
32  char   *eval_client(request)
33 diff -ruN tcp_wrappers_7.6.orig/hosts_access.5 tcp_wrappers_7.6/hosts_access.5
34 --- tcp_wrappers_7.6.orig/hosts_access.5        2004-11-04 13:17:45.000000000 +0100
35 +++ tcp_wrappers_7.6/hosts_access.5     2004-11-04 13:55:32.000000000 +0100
36 @@ -175,6 +175,8 @@
37  unavailable.
38  .IP "%n (%N)"
39  The client (server) host name (or "unknown" or "paranoid").
40 +.IP "%r (%R)"
41 +The clients (servers) port number (or "0").
42  .IP %p
43  The daemon process id.
44  .IP %s
45 diff -ruN tcp_wrappers_7.6.orig/percent_x.c tcp_wrappers_7.6/percent_x.c
46 --- tcp_wrappers_7.6.orig/percent_x.c   1994-12-28 17:42:38.000000000 +0100
47 +++ tcp_wrappers_7.6/percent_x.c        2004-11-04 13:19:29.000000000 +0100
48 @@ -63,6 +63,8 @@
49                 ch == 'n' ? eval_hostname(request->client) :
50                 ch == 'N' ? eval_hostname(request->server) :
51                 ch == 'p' ? eval_pid(request) :
52 +               ch == 'r' ? eval_port(request->client->sin) :
53 +               ch == 'R' ? eval_port(request->server->sin) :
54                 ch == 's' ? eval_server(request) :
55                 ch == 'u' ? eval_user(request) :
56                 ch == '%' ? "%" : (tcpd_warn("unrecognized %%%c", ch), "");
57 diff -ruN tcp_wrappers_7.6.orig/tcpd.h tcp_wrappers_7.6/tcpd.h
58 --- tcp_wrappers_7.6.orig/tcpd.h        2004-11-04 13:17:45.000000000 +0100
59 +++ tcp_wrappers_7.6/tcpd.h     2004-11-04 13:19:13.000000000 +0100
60 @@ -145,6 +145,11 @@
61  extern char *eval_hostinfo(struct host_info *);        /* host name or address */
62  extern char *eval_client(struct request_info *);/* whatever is available */
63  extern char *eval_server(struct request_info *);/* whatever is available */
64 +#ifdef INET6
65 +extern char *eval_port(struct sockaddr *);
66 +#else
67 +extern char *eval_port(struct sockaddr_in *);
68 +#endif
69  #define eval_daemon(r) ((r)->daemon)   /* daemon process name */
70  #define eval_pid(r)    ((r)->pid)      /* process id */