tags -1 patch
user debian-rele...@lists.debian.org
usertags -1 + bsp-2018-12-ch-bern
thanks

So here we go ...

The files resulting from the conversion to cmake are not as terse as I
hoped they would be. Still, at least for me, this is an improvement
over to several handcrafted rules, especially for any future changes in
the Debian build system.

This goes far beyond a usual NMU, so several more remarks:


## For upstream

The primary goal was to provide a distribution-agnostic replacement
for the specific and fairly limited build system, using cmake. Not
all features have been re-implemented, though.


## For Debian

* Any Patches not in 3.0 (quilt) format were converted accordingly.
  For most packages, this could take a refinement, read: Split the
  single patch into several smaller ones, reflecting the reason for
  each patch.

* Any debhelper compat level below 10 was raised accordingly.

* The debian/rules file was converted to dh style, moving all the
  install logic to other places. Obsolete debian/*dir were removed.

* All modifications to the no-longer used build system files
  (configure, Makefile, */Makefile) were reverted, and hopefully
  re-created by other means. There were several additional
  modifications, install paths and names to most. Some of them were
  re-implemented by modifying CMakeLists.txt - there is a second patch
  then.

* Probably all packagings need some review and further improvement.
  Good starting points are the messages emitted by lintian and gcc.

* Since there are no test suites, there is quite a risk some
  regressions were introduced without noticing. To detect at least the
  worst mistakes, the contents of each created package was compared
  using debdiff, and the flags in the build logs.

* Personally I'd merge the *-ssl src:packages into the related
  plain-text package as they share the same source tarball.


## Outlook

The patches will be release in in three batches:

### Packages maintained by Alberto Gonzalez Iniesta <a...@inittab.org>

* netkit-bootparamd
* netkit-ntalk
* netkit-rsh
* netkit-rusers
* netkit-rwall
* netkit-rwho
* netkit-tftp

Alberto, you'll do me a favour if you could refrain from uploading
for a few days - I'll do some more checks and expect one or two more
things will come up that require an adjustment.

Also, some formatting was done in my personal style. Feel free to apply
your $QUILT_REFRESH_ARGS on top of this.

### Packages by other maintainers

* biff
* bsd-finger

These will be fixed by an NMU

### Packages with an SSL variant

They will have an extra round of review first

* netkit-ftp
* netkit-ftp-ssl
* netkit-telnet
* netkit-telnet-ssl
* linux-ftpd
* linux-ftpd-ssl


## For future reference: Translation of some MCONFIG.in keywords

Not all features have been re-implemented - some like BINDIR and
permissions are hardcoded now.

The following lists those keywords that required some action. Some
statement in to top-level CMakeLists.txt, usually to detect some
libraries. And possible additions to particultar binaries to be built
("targets").

### BSDSIGNAL

Always true

### FN(crypt)

    find_library(USE_CRYPT crypt REQUIRED)

    target_link_libraries(
        ...
        crypt
    )

### FN(forkpty)

    target_link_libraries(
        ...
        util
    )

### FN(logwtmp)

    target_link_libraries(
        ...
        util
    )

### FN(snprintf)

Always true


### GLIBC

Always true

    set(USE_GLIBC 1)

### LDFLAGS

No-op

### LIBCURSES

    find_library(NCURSES lncurses REQUIRED)

    target_link_libraries(
        ...
        ncurses
    )

Note: Fallback to traditional curses is not supported

### LIBS

No-op

### LIBTERMCAP

    find_library(USE_CRYPT lncurses REQUIRED)

    target_link_libraries(
        ...
        ncurses
    )

Note: Fallback to traditional curses is not supported

### PAM

    find_library(USE_PAM pam)

Disabling PAM is not supported

### READLINE

    find_library(USE_READLINE readline)

    target_link_libraries(
        ...
        readline
    )

### SHADOW

No-op as PAM is enabled

Disabling shadow is not supported

### TYPE(socklen_t)

No-op

### YACC

Use yacc. Currently hardcoded, might be refined to use some cmake
logic.


Cheers,

    Christoph
diff -Nru netkit-ntalk-0.17/debian/compat netkit-ntalk-0.17/debian/compat
--- netkit-ntalk-0.17/debian/compat     2018-12-05 19:20:49.000000000 +0100
+++ netkit-ntalk-0.17/debian/compat     2012-06-14 12:54:26.000000000 +0200
@@ -1 +1 @@
-5
+10
diff -Nru netkit-ntalk-0.17/debian/control netkit-ntalk-0.17/debian/control
--- netkit-ntalk-0.17/debian/control    2018-12-05 19:20:49.000000000 +0100
+++ netkit-ntalk-0.17/debian/control    2012-06-14 12:54:26.000000000 +0200
@@ -3,7 +3,7 @@
 Priority: optional
 Maintainer: Alberto Gonzalez Iniesta <a...@inittab.org>
 Standards-Version: 3.9.3
-Build-Depends: debhelper (>> 7), libncurses-dev, libwrap0-dev
+Build-Depends: debhelper (>> 10~), libncurses-dev, libwrap0-dev, cmake
 
 Package: talk
 Architecture: any
diff -Nru netkit-ntalk-0.17/debian/dirs netkit-ntalk-0.17/debian/dirs
--- netkit-ntalk-0.17/debian/dirs       2018-12-05 19:20:49.000000000 +0100
+++ netkit-ntalk-0.17/debian/dirs       1970-01-01 01:00:00.000000000 +0100
@@ -1,2 +0,0 @@
-usr/bin
-usr/share/man/man1
diff -Nru netkit-ntalk-0.17/debian/not-installed 
netkit-ntalk-0.17/debian/not-installed
--- netkit-ntalk-0.17/debian/not-installed      1970-01-01 01:00:00.000000000 
+0100
+++ netkit-ntalk-0.17/debian/not-installed      2012-06-14 12:54:26.000000000 
+0200
@@ -0,0 +1,5 @@
+
+usr/sbin/in.talkd
+usr/share/man/man8/in.talkd.8
+usr/share/man/man8/ntalkd.8
+usr/share/man/man8/talkd.8
diff -Nru netkit-ntalk-0.17/debian/patches/old-debian-patches.patch 
netkit-ntalk-0.17/debian/patches/old-debian-patches.patch
--- netkit-ntalk-0.17/debian/patches/old-debian-patches.patch   1970-01-01 
01:00:00.000000000 +0100
+++ netkit-ntalk-0.17/debian/patches/old-debian-patches.patch   2012-06-14 
12:54:26.000000000 +0200
@@ -0,0 +1,503 @@
+Description: Old patches found when converting to quilt patch queue
+Author: Christoph Biedl <debian.a...@manchmal.in-ulm.de>
+Last-Update: 2018-11-25
+
+--- /dev/null
++++ b/talk/convert.c
+@@ -0,0 +1,46 @@
++/*
++ * This routines handle conversions needed to make standard talk/talkd
++ * compatible with Sun's. SunOS/Solaris use a different protocol than
++ * anyone else.
++ *
++ * What we do here is take SunOS' messages and convert them to standard
++ * ones, so that our talk/talkd can manage them without many changes.
++ *
++ * Juan-Mariano de Goyeneche. jmse...@dit.upm.es
++ * Mon Aug 10 1998
++ */
++
++#ifdef SUN_HACK
++#include <string.h>
++#include "talk.h"
++
++char personality;
++
++void msg2msg_S(const CTL_MSG* msg, CTL_MSG_S* msg_S)
++{
++      msg_S->type = msg->type;
++      strncpy (msg_S->l_name, msg->l_name, NAME_SIZE_S);
++      msg_S->l_name[NAME_SIZE_S - 1] = '\0';
++      strncpy (msg_S->r_name, msg->r_name, NAME_SIZE_S);
++      msg_S->r_name[NAME_SIZE_S - 1] = '\0';
++      msg_S->pad = 0;
++      msg_S->id_num = msg->id_num;
++      msg_S->pid = msg->pid;
++      strncpy (msg_S->r_tty, msg->r_tty, TTY_SIZE);
++      msg_S->r_tty[TTY_SIZE - 1] = '\0';
++      memcpy(&(msg_S->addr), &(msg->addr), sizeof(msg_S->addr));
++/*    if (*(&(msg_S->addr.sa_family)+1) == (short)0)
++              msg_S->addr.sa_family = 0;*/
++      memcpy(&(msg_S->ctl_addr), &(msg->ctl_addr), sizeof(msg_S->ctl_addr));
++}
++
++void resp_S2resp(const CTL_RESPONSE_S* resp_S, CTL_RESPONSE* resp)
++{
++      resp->vers = TALK_VERSION;
++      resp->type = resp_S->type;
++      resp->answer = resp_S->answer;
++      resp->pad = 0;
++      resp->id_num = resp_S->id_num;
++      memcpy(&(resp->addr), &(resp_S->addr), sizeof(resp->addr));
++}
++#endif
+--- a/talk/ctl_transact.c
++++ b/talk/ctl_transact.c
+@@ -45,6 +45,7 @@
+ /* #include <netinet/ip.h> looks like this is not needed (no functions used) 
*/
+ #include <string.h>
+ #include <errno.h>
++#include <netdb.h>
+ #include "talk.h"
+ 
+ #define CTL_WAIT 2    /* time to wait for a response, in seconds */
+@@ -69,15 +70,16 @@
+       if (to_local_talkd < 0 || to_remote_talkd < 0) {
+               p_error("Bad socket");
+       }
+-
+-#ifdef SO_BSDCOMPAT
++/* agi: SO_BSDCOMPAT is defined, but obsolete in current kernels
++#ifdef SO_BSDCOMPAT */
+       /* 
+        * Linux does some async error return stuff that
+        * really disagrees with us. So we disable it.
+        */
+-      setsockopt(to_local_talkd, SOL_SOCKET, SO_BSDCOMPAT, &on, sizeof(on));
++/*    setsockopt(to_local_talkd, SOL_SOCKET, SO_BSDCOMPAT, &on, sizeof(on));
+       setsockopt(to_remote_talkd, SOL_SOCKET, SO_BSDCOMPAT, &on, sizeof(on));
+ #endif
++*/
+ 
+       /*
+        * Explicitly talk to the local daemon over loopback.
+@@ -120,20 +122,45 @@
+               p_error("getsockname");
+       }
+       local_addr_for_remote = rem.sin_addr.s_addr;
++
++#ifdef SUN_HACK
++      personality = P_NORMAL;
++#endif
+ }
+ 
+ static void
+ send_packet(CTL_MSG *msg, int sock)
+ {
+       int cc;
++#ifdef SUN_HACK
++      CTL_MSG_S msg_S;
++      const void *packet;
++      size_t len;
++
++      if (personality == P_SUNOS) {
++              msg2msg_S(msg, &msg_S);
++              packet = &msg_S;
++              len = sizeof(msg_S);
++      } else {
++              packet = msg;
++              len = sizeof(*msg);
++      }
++
++      cc = send(sock, packet, len, 0);
++#else
+       cc = send(sock, msg, sizeof(*msg), 0);
++#endif
+       if (cc<0 && errno == EINTR) {
+               return;
+       }
+       else if (cc<0) {
+           p_error("Error on write to talk daemon");
+       }
++#ifdef SUN_HACK
++      else if (((size_t) cc) != len) {
++#else
+       else if (cc != sizeof(*msg)) {
++#endif
+           p_error("Short write to talk daemon");
+       }
+ }
+@@ -170,6 +197,36 @@
+       send_packet(&tmp, sock);
+ }
+ 
++#ifdef SUN_HACK
++static void
++reconnect(void)
++{
++      struct sockaddr_in loc, rem;
++
++      daemon_port = getservbyname("talk", "udp")->s_port;
++
++      memset(&loc, 0, sizeof(loc));
++      loc.sin_family = AF_INET;
++      loc.sin_port = daemon_port;
++      loc.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
++
++      if (connect(to_local_talkd, (struct sockaddr *)&loc, sizeof(loc))<0) {
++              p_error("Couldn't connect local control socket");
++      }
++
++      memset(&rem, 0, sizeof(rem));
++      rem.sin_family = AF_INET;
++      rem.sin_port = daemon_port;
++      rem.sin_addr = his_machine_addr;
++
++      if (connect(to_remote_talkd, (struct sockaddr *)&rem, sizeof(rem))<0) {
++              p_error("Couldn't connect remote control socket");
++      }
++
++      personality = P_SUNOS;
++}
++#endif
++
+ /*
+  * SOCKDGRAM is unreliable, so we must repeat messages if we have
+  * not received an acknowledgement within a reasonable amount
+@@ -192,6 +249,9 @@
+       do {
+               /* resend message until a response is obtained */
+               do {
++#ifdef SUN_HACK
++again:
++#endif
+                       send_packet(mesg, sock);
+                       read_mask = ctl_mask;
+                       wait.tv_sec = CTL_WAIT;
+@@ -209,12 +269,35 @@
+                * request/acknowledgements being sent)
+                */
+               do {
+-                      cc = recv(sock, (char *)rp, sizeof (*rp), 0);
++#ifdef SUN_HACK
++                      CTL_RESPONSE_S rp_S;
++
++                        if (personality==P_NORMAL)
++#endif
++                              cc = recv(sock, (char *)rp,
++                                        sizeof (*rp), 0);
++#ifdef SUN_HACK
++                        else
++                              cc = recv(sock, (char *)&rp_S,
++                                        sizeof (rp_S), 0);
++#endif
+                       if (cc < 0) {
+                               if (errno == EINTR)
+                                       continue;
++#ifdef SUN_HACK
++                              if (errno == ECONNREFUSED &&
++                                  personality == P_NORMAL &&
++                                  sock == to_remote_talkd) {
++                                      reconnect();
++                                      goto again;
++                              }
++#endif
+                               p_error("Error on read from talk daemon");
+                       }
++#ifdef SUN_HACK
++                      if (personality==P_SUNOS)
++                              resp_S2resp(&rp_S, rp);
++#endif
+                       read_mask = ctl_mask;
+                       /* an immediate poll */
+                       timerclear(&wait);
+--- a/talk/talk.1
++++ b/talk/talk.1
+@@ -139,7 +139,10 @@
+ .Bx 4.2
+ uses a different and even more braindead protocol that is completely
+ incompatible. Some vendor Unixes (particularly those from Sun) have
+-been found to use this old protocol.
++been found to use this old protocol. There's a patch from Juan-Mariano de
++Goyeneche (jmse...@dit.upm.es) which makes talk/talkd, if compiled with
++-DSUN_HACK, compatible with SunOS/Solaris' ones. It converts messages from
++one protocol to the other.
+ .Pp
+ Old versions of
+ .Nm talk
+--- a/talk/talk.h
++++ b/talk/talk.h
+@@ -40,12 +40,56 @@
+ 
+ #include "prot_talkd.h"
+ 
++#ifdef SUN_HACK
++/*
++ * Personalities: NORMAL --> Normal behaviour; (almost) everybody.
++ *              SUNOS  --> The rest: SunOS/Solaris.
++ */
++#define P_NORMAL 1
++#define P_SUNOS  2
++
++/*
++ * Client(SunOS)->server request message format.
++ */
++
++typedef struct {
++        u_char  type;           /* request type */
++#define NAME_SIZE_S       9
++        char    l_name[NAME_SIZE_S];/* caller's name */
++        char    r_name[NAME_SIZE_S];/* callee's name */
++        u_char  pad;
++        u_int32_t id_num;       /* message id */
++        int32_t pid;            /* caller's process id */
++        char    r_tty[TTY_SIZE];/* callee's tty name */
++        struct  osockaddr addr;         /* old (4.3) style */
++        struct  osockaddr ctl_addr;     /* old (4.3) style */
++} CTL_MSG_S;
++
++/*
++ * Server(SunOS)->client response message format.
++ */
++typedef struct {
++        u_char  type;           /* type of request message, see below */
++        u_char  answer;         /* response to request message, see below */
++        u_short  pad;
++        u_long id_num;       /* message id */
++        struct  osockaddr addr; /* address for establishing conversation */
++} CTL_RESPONSE_S;
++#endif
++
++
++
+ extern int sockt;
+ extern int invitation_waiting;
+ 
+ extern const char *current_state;
+ extern int current_line;
+ 
++#ifdef SUN_HACK
++extern char personality;
++#endif
++
++
+ void p_error(const char *string);
+ void quit(int);
+ void message(const char *mesg);
+@@ -63,6 +107,10 @@
+ void talk(void);
+ void send_delete(void);
+ void display(int hiswin, unsigned char *, int);
++#ifdef SUN_HACK
++void msg2msg_S(const CTL_MSG *, CTL_MSG_S *);
++void resp_S2resp(const CTL_RESPONSE_S *, CTL_RESPONSE *);
++#endif
+ 
+ void set_my_edit_chars(int ctrlh, int ctrlu, int ctrlw);
+ void set_his_edit_chars(int ctrlh, int ctrlu, int ctrlw);
+--- a/talkd/announce.c
++++ b/talkd/announce.c
+@@ -49,6 +49,7 @@
+ #include <fcntl.h>
+ #include <string.h>
+ #include <paths.h>
++#include <time.h>
+ #include "prot_talkd.h"
+ #include "proto.h"
+ 
+--- a/talkd/table.c
++++ b/talkd/table.c
+@@ -46,13 +46,13 @@
+  * Consider this a mis-guided attempt at modularity
+  */
+ #include <sys/param.h>
+-#include <sys/time.h>
+ #include <sys/socket.h>
+ #include <syslog.h>
+ #include <unistd.h>
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
++#include <time.h>
+ #include <netinet/in.h>
+ 
+ #include "prot_talkd.h"
+--- a/talkd/talkd.8
++++ b/talkd/talkd.8
+@@ -39,8 +39,8 @@
+ .Nm talkd
+ .Nd remote user communication server
+ .Sh SYNOPSIS
+-.Nm talkd
+-.Op Fl dp
++.Nm /usr/sbin/in.talkd
++.Op Fl dpq
+ .Sh DESCRIPTION
+ .Nm Talkd
+ is the server that notifies a user that someone else wants to
+@@ -76,6 +76,9 @@
+ Packet logging mode; writes copies of malformed packets to
+ .Pa /var/log/talkd.packets .
+ This is useful for debugging interoperability problems.
++.Pp
++.Op Fl q
++Don't log successful connects.
+ .Sh SEE ALSO
+ .Xr talk 1 ,
+ .Xr write 1
+--- a/talkd/talkd.c
++++ b/talkd/talkd.c
+@@ -63,11 +63,13 @@
+ #include <string.h>
+ #include <netdb.h>
+ #include <paths.h>
++#include <tcpd.h>
+ #include "prot_talkd.h"
+ #include "proto.h"
+ 
+ #define TIMEOUT 30
+ #define MAXIDLE 120
++#define MINUDPSRCPORT 1024
+ 
+ #if !defined(MAXHOSTNAMELEN)
+ #define       MAXHOSTNAMELEN  64
+@@ -75,6 +77,10 @@
+ char ourhostname[MAXHOSTNAMELEN];
+ 
+ static time_t lastmsgtime;
++#ifndef __USE_GNU
++static char *program_invocation_short_name;
++#endif
++static int quiet;
+ 
+ static void
+ timeout(int ignore)
+@@ -163,11 +169,16 @@
+       char theirhost[MAXHOSTNAMELEN];
+       const char *theirip;
+ 
+-      struct hostent *hp;
+       struct sockaddr_in sn;
+-      int cc, i, ok;
++      struct sockaddr_in server_sin;
++      int cc;
+       socklen_t addrlen;
++      int theirport;
++
++      struct request_info request;
+ 
++      signal(SIGALRM, timeout);
++      alarm(TIMEOUT);
+       addrlen = sizeof(sn);
+       cc = recvfrom(0, inbuf, sizeof(inbuf), 0,
+                     (struct sockaddr *)&sn, &addrlen);
+@@ -194,6 +205,12 @@
+               return;
+       }
+ 
++      theirport = ntohs(sn.sin_port);
++      if (theirport < MINUDPSRCPORT) {
++              syslog(LOG_WARNING, "%d: bad port", theirport);
++              return;
++      }
++
+       /* 
+        * If we get here we have an address we can reply to, although
+        * it may not be good for much. If possible, reply to it, because
+@@ -203,38 +220,32 @@
+       theirip = inet_ntoa(sn.sin_addr);
+       mp = (CTL_MSG *)inbuf;
+ 
+-      /*
+-       * Check they're not being weenies.
+-       * We should look into using libwrap here so hosts.deny works.
+-       * Wrapping talkd with tcpd isn't very useful.
+-       */
+-      hp = gethostbyaddr((char *)&sn.sin_addr, sizeof(struct in_addr), 
+-                         AF_INET);
+-      if (hp == NULL) {
+-              syslog(LOG_WARNING, "%s: bad dns", theirip);
+-              send_reject_packet(mp, &sn, MACHINE_UNKNOWN, 0);
++      addrlen = sizeof(server_sin);
++      if (getsockname(0, (struct sockaddr *)&server_sin, &addrlen)<0) {
++              syslog(LOG_WARNING, "getsockname: %s", strerror(errno));
+               return;
+       }
+-      strncpy(theirhost, hp->h_name, sizeof(theirhost));
+-      theirhost[sizeof(theirhost)-1] = 0;
+-
+-      hp = gethostbyname(theirhost);
+-      if (hp == NULL) {
+-              syslog(LOG_WARNING, "%s: bad dns", theirip);
++      request_init(&request,
++                   RQ_FILE, 0,
++                   RQ_DAEMON, program_invocation_short_name,
++                   RQ_CLIENT_SIN, &sn,
++                   RQ_SERVER_SIN, &server_sin,
++                   0);
++      sock_methods(&request);
++      if (!hosts_access(&request)) {
++              refuse(&request);
+               send_reject_packet(mp, &sn, MACHINE_UNKNOWN, 0);
+               return;
+       }
+-
+-      for (i=ok=0; hp->h_addr_list[i] && !ok; i++) {
+-              if (!memcmp(hp->h_addr_list[i], &sn.sin_addr, 
+-                          sizeof(sn.sin_addr))) ok = 1;
+-      }
+-      if (!ok) {
+-              syslog(LOG_WARNING, "%s: bad dns", theirip);
+-              send_reject_packet(mp, &sn, MACHINE_UNKNOWN, 0);
+-              return;
++      if (!quiet) {
++              syslog(LOG_INFO, "connect from %s", eval_client(&request));
+       }
+ 
++      signal(SIGALRM, timeout);
++      alarm(TIMEOUT);
++      strncpy(theirhost, eval_hostinfo(request.client), sizeof(theirhost));
++      theirhost[sizeof(theirhost)-1] = 0;
++
+       /*
+        * Try to straighten out bad packets.
+        */
+@@ -319,11 +330,16 @@
+       socklen_t sz = sizeof(sn);
+       int do_debug=0, do_badpackets=0, ch;
+ 
++#ifndef __USE_GNU
++      program_invocation_short_name = argv[0];
++      if (argv[0][0] == '/') {
++              program_invocation_short_name = strrchr(argv[0], '/') + 1;
++      }
++#endif
+       /* make sure we're a daemon */
+       if (getsockname(0, (struct sockaddr *)&sn, &sz)) {
+-              const char *msg = strerror(errno);
+-              write(2, msg, strlen(msg));
+-              exit(1);
++              printf ("must be run from inetd.\n");
++              exit (1);
+       }
+       openlog("talkd", LOG_PID, LOG_DAEMON);
+       if (gethostname(ourhostname, sizeof(ourhostname) - 1) < 0) {
+@@ -334,16 +350,15 @@
+               syslog(LOG_ERR, "chdir: %s: %s", _PATH_DEV, strerror(errno));
+               exit(1);
+       }
+-      while ((ch = getopt(argc, argv, "dp"))!=-1) {
++      while ((ch = getopt(argc, argv, "dpq"))!=-1) {
+               switch (ch) {
+                   case 'd': do_debug=1; break;
+                   case 'p': do_badpackets=1; break;
++                  case 'q': quiet=1; break;
+               }
+       }
+       set_debug(do_debug, do_badpackets);
+ 
+-      signal(SIGALRM, timeout);
+-      alarm(TIMEOUT);
+       for (;;) {
+               do_one_packet();
+       }
diff -Nru netkit-ntalk-0.17/debian/patches/series 
netkit-ntalk-0.17/debian/patches/series
--- netkit-ntalk-0.17/debian/patches/series     1970-01-01 01:00:00.000000000 
+0100
+++ netkit-ntalk-0.17/debian/patches/series     2012-06-14 12:54:26.000000000 
+0200
@@ -0,0 +1,3 @@
+old-debian-patches.patch
+use-cmake-as-buildsystem.patch
+use-cmake-as-buildsystem-debian-extras.patch
diff -Nru 
netkit-ntalk-0.17/debian/patches/use-cmake-as-buildsystem-debian-extras.patch 
netkit-ntalk-0.17/debian/patches/use-cmake-as-buildsystem-debian-extras.patch
--- 
netkit-ntalk-0.17/debian/patches/use-cmake-as-buildsystem-debian-extras.patch   
    1970-01-01 01:00:00.000000000 +0100
+++ 
netkit-ntalk-0.17/debian/patches/use-cmake-as-buildsystem-debian-extras.patch   
    2012-06-14 12:54:26.000000000 +0200
@@ -0,0 +1,35 @@
+Description: Debian-specific changes to the cmake build system
+Author: Christoph Biedl <debian.a...@manchmal.in-ulm.de>
+Forwarded: not-needed
+Last-Update: 2018-11-25
+
+--- a/talk/CMakeLists.txt
++++ b/talk/CMakeLists.txt
+@@ -2,7 +2,7 @@
+ include_directories(BEFORE "../include/")
+ 
+ add_executable(
+-    talk
++    netkit-ntalk
+     ctl.c
+     ctl_transact.c
+     display.c
+@@ -16,15 +16,16 @@
+     talk.c
+ )
+ target_link_libraries(
+-    talk
++    netkit-ntalk
+     ncurses
+ )
+ install(
+-    TARGETS talk
++    TARGETS netkit-ntalk
+     DESTINATION ${BIN_DIR}
+ )
+ 
+ install(
+     FILES talk.1
+     DESTINATION ${MAN_DIR}/man1/
++    RENAME netkit-ntalk.1
+ )
diff -Nru netkit-ntalk-0.17/debian/patches/use-cmake-as-buildsystem.patch 
netkit-ntalk-0.17/debian/patches/use-cmake-as-buildsystem.patch
--- netkit-ntalk-0.17/debian/patches/use-cmake-as-buildsystem.patch     
1970-01-01 01:00:00.000000000 +0100
+++ netkit-ntalk-0.17/debian/patches/use-cmake-as-buildsystem.patch     
2012-06-14 12:54:26.000000000 +0200
@@ -0,0 +1,107 @@
+Description: Use cmake as build system
+Author: Christoph Biedl <debian.a...@manchmal.in-ulm.de>
+Bug-Debian: https://bugs.debian.org/911154
+Last-Update: 2018-11-25
+
+--- /dev/null
++++ b/CMakeLists.txt
+@@ -0,0 +1,13 @@
++cmake_minimum_required(VERSION 3.7)
++project(netkit-ntalk)
++
++set(BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin")
++set(SBIN_DIR "${CMAKE_INSTALL_PREFIX}/sbin")
++set(MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man")
++
++set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_GNU_SOURCE")
++
++find_library(NCURSES lncurses REQUIRED)
++
++add_subdirectory(talk)
++add_subdirectory(talkd)
+--- /dev/null
++++ b/talk/CMakeLists.txt
+@@ -0,0 +1,30 @@
++
++include_directories(BEFORE "../include/")
++
++add_executable(
++    talk
++    ctl.c
++    ctl_transact.c
++    display.c
++    get_addrs.c
++    get_names.c
++    init_disp.c
++    invite.c
++    io.c
++    look_up.c
++    msgs.c
++    talk.c
++)
++target_link_libraries(
++    talk
++    ncurses
++)
++install(
++    TARGETS talk
++    DESTINATION ${BIN_DIR}
++)
++
++install(
++    FILES talk.1
++    DESTINATION ${MAN_DIR}/man1/
++)
+--- /dev/null
++++ b/talkd/CMakeLists.txt
+@@ -0,0 +1,50 @@
++
++include_directories(BEFORE "../include/")
++
++add_executable(
++    in.ntalkd
++    talkd.c
++    announce.c
++    process.c
++    table.c
++    print.c
++    repairs.c
++)
++target_link_libraries(
++    in.ntalkd
++    wrap
++)
++install(
++    TARGETS in.ntalkd
++    DESTINATION ${SBIN_DIR}
++)
++install(
++    CODE "execute_process( \
++        COMMAND ${CMAKE_COMMAND} -E create_symlink \
++        in.ntalkd \$ENV{DESTDIR}${SBIN_DIR}/in.talkd \
++    )"
++)
++
++install(
++    FILES talkd.8
++    DESTINATION ${MAN_DIR}/man8/
++    RENAME in.ntalkd.8
++)
++install(
++    CODE "execute_process( \
++        COMMAND ${CMAKE_COMMAND} -E create_symlink \
++        in.ntalkd.8 \$ENV{DESTDIR}${MAN_DIR}/man8/in.talkd.8 \
++    )"
++)
++install(
++    CODE "execute_process( \
++        COMMAND ${CMAKE_COMMAND} -E create_symlink \
++        in.ntalkd.8 \$ENV{DESTDIR}${MAN_DIR}/man8/ntalkd.8 \
++    )"
++)
++install(
++    CODE "execute_process( \
++        COMMAND ${CMAKE_COMMAND} -E create_symlink \
++        in.ntalkd.8 \$ENV{DESTDIR}${MAN_DIR}/man8/talkd.8 \
++    )"
++)
diff -Nru netkit-ntalk-0.17/debian/rules netkit-ntalk-0.17/debian/rules
--- netkit-ntalk-0.17/debian/rules      2018-12-05 19:20:49.000000000 +0100
+++ netkit-ntalk-0.17/debian/rules      2012-06-14 12:54:26.000000000 +0200
@@ -1,83 +1,7 @@
 #!/usr/bin/make -f
-# $Id: rules,v 1.7 2002/12/22 05:30:26 herbert Exp $
-# Sample debian/rules that uses debhelper. GNU copyright 1997 by Joey Hess.
 
-# Uncomment this to turn on verbose mode. 
-#export DH_VERBOSE=1
+%:
+       dh $@ --buildsystem=cmake
 
-build: build-arch build-indep
-build-arch: build-stamp
-build-indep: build-stamp
-build-stamp:
-       dh_testdir
-
-       if [ ! -f MCONFIG ]; then \
-               ./configure; \
-               echo "CFLAGS += -g -D_GNU_SOURCE" >> MCONFIG; \
-               echo "CFLAGS += $(shell dpkg-buildflags --get CPPFLAGS)" >> 
MCONFIG; \
-               echo "CFLAGS += $(shell dpkg-buildflags --get CFLAGS)" >> 
MCONFIG; \
-               echo "LDFLAGS += $(shell dpkg-buildflags --get LDFLAGS)" >> 
MCONFIG; \
-       fi
-       $(MAKE)
-
-       touch build-stamp
-
-clean:
-       dh_testdir
-       dh_testroot
-       rm -f build-stamp install-stamp
-
-       [ ! -f MCONFIG ] || $(MAKE) distclean
-
-       dh_clean
-
-install: install-stamp
-install-stamp: build-stamp
-       dh_testdir
-       dh_testroot
-       dh_prep
-       dh_installdirs
-
-       $(MAKE) -C talk install INSTALLROOT=`pwd`/debian/talk \
-               MANDIR=/usr/share/man
-       mv debian/talk/usr/bin/talk debian/talk/usr/bin/netkit-ntalk
-       mv debian/talk/usr/share/man/man1/talk.1 \
-          debian/talk/usr/share/man/man1/netkit-ntalk.1
-       $(MAKE) -C talkd install INSTALLROOT=`pwd`/debian/talkd \
-               MANDIR=/usr/share/man
-
-       touch install-stamp
-
-# Build architecture-independent files here.
-binary-indep: build install
-# We have nothing to do by default.
-
-# Build architecture-dependent files here.
-binary-arch: build install
-#      dh_testversion
-       dh_testdir
-       dh_testroot
-#      dh_movefiles
-       dh_installdocs
-       dh_installexamples
-       dh_installmenu
-       dh_installlogcheck
-       dh_installcron
-#      dh_installmanpages
-#      dh_undocumented
-       dh_installchangelogs ChangeLog
-       dh_strip
-       dh_compress
-       dh_fixperms
-       dh_installdeb
-       dh_shlibdeps
-       dh_gencontrol
-#      dh_makeshlibs
-       dh_md5sums
-       dh_builddeb
-
-source diff:                                                                  
-       @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary
+override_dh_missing:
+       dh_missing --fail-missing
diff -Nru netkit-ntalk-0.17/debian/source/format 
netkit-ntalk-0.17/debian/source/format
--- netkit-ntalk-0.17/debian/source/format      2018-12-05 19:20:49.000000000 
+0100
+++ netkit-ntalk-0.17/debian/source/format      2012-06-14 12:54:26.000000000 
+0200
@@ -1 +1 @@
-1.0
+3.0 (quilt)
diff -Nru netkit-ntalk-0.17/debian/talkd.dirs 
netkit-ntalk-0.17/debian/talkd.dirs
--- netkit-ntalk-0.17/debian/talkd.dirs 2018-12-05 19:20:49.000000000 +0100
+++ netkit-ntalk-0.17/debian/talkd.dirs 1970-01-01 01:00:00.000000000 +0100
@@ -1,3 +0,0 @@
-usr/sbin
-usr/share/man/man8
-etc/logcheck/ignore.d.server
diff -Nru netkit-ntalk-0.17/debian/talkd.install 
netkit-ntalk-0.17/debian/talkd.install
--- netkit-ntalk-0.17/debian/talkd.install      1970-01-01 01:00:00.000000000 
+0100
+++ netkit-ntalk-0.17/debian/talkd.install      2012-06-14 12:54:26.000000000 
+0200
@@ -0,0 +1,2 @@
+
+usr/sbin/in.ntalkd
diff -Nru netkit-ntalk-0.17/debian/talkd.links 
netkit-ntalk-0.17/debian/talkd.links
--- netkit-ntalk-0.17/debian/talkd.links        1970-01-01 01:00:00.000000000 
+0100
+++ netkit-ntalk-0.17/debian/talkd.links        2012-06-14 12:54:26.000000000 
+0200
@@ -0,0 +1,5 @@
+
+usr/sbin/in.ntalkd                  usr/sbin/in.talkd
+usr/share/man/man8/in.ntalkd.8.gz   usr/share/man/man8/in.talkd.8.gz
+usr/share/man/man8/in.ntalkd.8.gz   usr/share/man/man8/ntalkd.8.gz
+usr/share/man/man8/in.talkd.8.gz    usr/share/man/man8/talkd.8.gz
diff -Nru netkit-ntalk-0.17/debian/talkd.manpages 
netkit-ntalk-0.17/debian/talkd.manpages
--- netkit-ntalk-0.17/debian/talkd.manpages     1970-01-01 01:00:00.000000000 
+0100
+++ netkit-ntalk-0.17/debian/talkd.manpages     2012-06-14 12:54:26.000000000 
+0200
@@ -0,0 +1,2 @@
+
+debian/tmp/usr/share/man/man8/in.ntalkd.8
diff -Nru netkit-ntalk-0.17/debian/talk.install 
netkit-ntalk-0.17/debian/talk.install
--- netkit-ntalk-0.17/debian/talk.install       1970-01-01 01:00:00.000000000 
+0100
+++ netkit-ntalk-0.17/debian/talk.install       2012-06-14 12:54:26.000000000 
+0200
@@ -0,0 +1,2 @@
+
+usr/bin/netkit-ntalk
diff -Nru netkit-ntalk-0.17/debian/talk.manpages 
netkit-ntalk-0.17/debian/talk.manpages
--- netkit-ntalk-0.17/debian/talk.manpages      1970-01-01 01:00:00.000000000 
+0100
+++ netkit-ntalk-0.17/debian/talk.manpages      2012-06-14 12:54:26.000000000 
+0200
@@ -0,0 +1,2 @@
+
+debian/tmp/usr/share/man/man1/netkit-ntalk.1
diff -Nru netkit-ntalk-0.17/talk/convert.c netkit-ntalk-0.17/talk/convert.c
--- netkit-ntalk-0.17/talk/convert.c    2018-12-05 19:20:49.000000000 +0100
+++ netkit-ntalk-0.17/talk/convert.c    1970-01-01 01:00:00.000000000 +0100
@@ -1,46 +0,0 @@
-/*
- * This routines handle conversions needed to make standard talk/talkd
- * compatible with Sun's. SunOS/Solaris use a different protocol than
- * anyone else.
- *
- * What we do here is take SunOS' messages and convert them to standard
- * ones, so that our talk/talkd can manage them without many changes.
- *
- * Juan-Mariano de Goyeneche. jmse...@dit.upm.es
- * Mon Aug 10 1998
- */
-
-#ifdef SUN_HACK
-#include <string.h>
-#include "talk.h"
-
-char personality;
-
-void msg2msg_S(const CTL_MSG* msg, CTL_MSG_S* msg_S)
-{
-       msg_S->type = msg->type;
-       strncpy (msg_S->l_name, msg->l_name, NAME_SIZE_S);
-       msg_S->l_name[NAME_SIZE_S - 1] = '\0';
-       strncpy (msg_S->r_name, msg->r_name, NAME_SIZE_S);
-       msg_S->r_name[NAME_SIZE_S - 1] = '\0';
-       msg_S->pad = 0;
-       msg_S->id_num = msg->id_num;
-       msg_S->pid = msg->pid;
-       strncpy (msg_S->r_tty, msg->r_tty, TTY_SIZE);
-       msg_S->r_tty[TTY_SIZE - 1] = '\0';
-       memcpy(&(msg_S->addr), &(msg->addr), sizeof(msg_S->addr));
-/*     if (*(&(msg_S->addr.sa_family)+1) == (short)0)
-               msg_S->addr.sa_family = 0;*/
-       memcpy(&(msg_S->ctl_addr), &(msg->ctl_addr), sizeof(msg_S->ctl_addr));
-}
-
-void resp_S2resp(const CTL_RESPONSE_S* resp_S, CTL_RESPONSE* resp)
-{
-       resp->vers = TALK_VERSION;
-       resp->type = resp_S->type;
-       resp->answer = resp_S->answer;
-       resp->pad = 0;
-       resp->id_num = resp_S->id_num;
-       memcpy(&(resp->addr), &(resp_S->addr), sizeof(resp->addr));
-}
-#endif
diff -Nru netkit-ntalk-0.17/talk/ctl_transact.c 
netkit-ntalk-0.17/talk/ctl_transact.c
--- netkit-ntalk-0.17/talk/ctl_transact.c       2018-12-05 19:20:49.000000000 
+0100
+++ netkit-ntalk-0.17/talk/ctl_transact.c       1999-09-29 00:04:14.000000000 
+0200
@@ -45,7 +45,6 @@
 /* #include <netinet/ip.h> looks like this is not needed (no functions used) */
 #include <string.h>
 #include <errno.h>
-#include <netdb.h>
 #include "talk.h"
 
 #define CTL_WAIT 2     /* time to wait for a response, in seconds */
@@ -70,16 +69,15 @@
        if (to_local_talkd < 0 || to_remote_talkd < 0) {
                p_error("Bad socket");
        }
-/* agi: SO_BSDCOMPAT is defined, but obsolete in current kernels
-#ifdef SO_BSDCOMPAT */
+
+#ifdef SO_BSDCOMPAT
        /* 
         * Linux does some async error return stuff that
         * really disagrees with us. So we disable it.
         */
-/*     setsockopt(to_local_talkd, SOL_SOCKET, SO_BSDCOMPAT, &on, sizeof(on));
+       setsockopt(to_local_talkd, SOL_SOCKET, SO_BSDCOMPAT, &on, sizeof(on));
        setsockopt(to_remote_talkd, SOL_SOCKET, SO_BSDCOMPAT, &on, sizeof(on));
 #endif
-*/
 
        /*
         * Explicitly talk to the local daemon over loopback.
@@ -122,45 +120,20 @@
                p_error("getsockname");
        }
        local_addr_for_remote = rem.sin_addr.s_addr;
-
-#ifdef SUN_HACK
-       personality = P_NORMAL;
-#endif
 }
 
 static void
 send_packet(CTL_MSG *msg, int sock)
 {
        int cc;
-#ifdef SUN_HACK
-       CTL_MSG_S msg_S;
-       const void *packet;
-       size_t len;
-
-       if (personality == P_SUNOS) {
-               msg2msg_S(msg, &msg_S);
-               packet = &msg_S;
-               len = sizeof(msg_S);
-       } else {
-               packet = msg;
-               len = sizeof(*msg);
-       }
-
-       cc = send(sock, packet, len, 0);
-#else
        cc = send(sock, msg, sizeof(*msg), 0);
-#endif
        if (cc<0 && errno == EINTR) {
                return;
        }
        else if (cc<0) {
            p_error("Error on write to talk daemon");
        }
-#ifdef SUN_HACK
-       else if (((size_t) cc) != len) {
-#else
        else if (cc != sizeof(*msg)) {
-#endif
            p_error("Short write to talk daemon");
        }
 }
@@ -197,36 +170,6 @@
        send_packet(&tmp, sock);
 }
 
-#ifdef SUN_HACK
-static void
-reconnect(void)
-{
-       struct sockaddr_in loc, rem;
-
-       daemon_port = getservbyname("talk", "udp")->s_port;
-
-       memset(&loc, 0, sizeof(loc));
-       loc.sin_family = AF_INET;
-       loc.sin_port = daemon_port;
-       loc.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
-
-       if (connect(to_local_talkd, (struct sockaddr *)&loc, sizeof(loc))<0) {
-               p_error("Couldn't connect local control socket");
-       }
-
-       memset(&rem, 0, sizeof(rem));
-       rem.sin_family = AF_INET;
-       rem.sin_port = daemon_port;
-       rem.sin_addr = his_machine_addr;
-
-       if (connect(to_remote_talkd, (struct sockaddr *)&rem, sizeof(rem))<0) {
-               p_error("Couldn't connect remote control socket");
-       }
-
-       personality = P_SUNOS;
-}
-#endif
-
 /*
  * SOCKDGRAM is unreliable, so we must repeat messages if we have
  * not received an acknowledgement within a reasonable amount
@@ -249,9 +192,6 @@
        do {
                /* resend message until a response is obtained */
                do {
-#ifdef SUN_HACK
-again:
-#endif
                        send_packet(mesg, sock);
                        read_mask = ctl_mask;
                        wait.tv_sec = CTL_WAIT;
@@ -269,35 +209,12 @@
                 * request/acknowledgements being sent)
                 */
                do {
-#ifdef SUN_HACK
-                       CTL_RESPONSE_S rp_S;
-
-                        if (personality==P_NORMAL)
-#endif
-                               cc = recv(sock, (char *)rp,
-                                         sizeof (*rp), 0);
-#ifdef SUN_HACK
-                        else
-                               cc = recv(sock, (char *)&rp_S,
-                                         sizeof (rp_S), 0);
-#endif
+                       cc = recv(sock, (char *)rp, sizeof (*rp), 0);
                        if (cc < 0) {
                                if (errno == EINTR)
-                                       continue;                               
-#ifdef SUN_HACK
-                               if (errno == ECONNREFUSED &&
-                                   personality == P_NORMAL &&
-                                   sock == to_remote_talkd) {
-                                       reconnect();
-                                       goto again;
-                               }
-#endif
+                                       continue;
                                p_error("Error on read from talk daemon");
                        }
-#ifdef SUN_HACK
-                       if (personality==P_SUNOS) 
-                               resp_S2resp(&rp_S, rp);
-#endif
                        read_mask = ctl_mask;
                        /* an immediate poll */
                        timerclear(&wait);
diff -Nru netkit-ntalk-0.17/talk/Makefile netkit-ntalk-0.17/talk/Makefile
--- netkit-ntalk-0.17/talk/Makefile     2018-12-05 19:20:49.000000000 +0100
+++ netkit-ntalk-0.17/talk/Makefile     1999-08-01 05:20:44.000000000 +0200
@@ -6,9 +6,8 @@
 CFLAGS += -I../include
 
 OBJS = ctl.o ctl_transact.o display.o get_addrs.o get_names.o \
-       init_disp.o invite.o io.o look_up.o msgs.o talk.o convert.o
+       init_disp.o invite.o io.o look_up.o msgs.o talk.o
 
-CFLAGS += -DSUN_HACK # -DBAD_LINUX_HACK
 LIBS += $(LIBCURSES)
 
 talk: $(OBJS)
diff -Nru netkit-ntalk-0.17/talk/talk.1 netkit-ntalk-0.17/talk/talk.1
--- netkit-ntalk-0.17/talk/talk.1       2018-12-05 19:20:49.000000000 +0100
+++ netkit-ntalk-0.17/talk/talk.1       2000-07-31 01:57:02.000000000 +0200
@@ -139,10 +139,7 @@
 .Bx 4.2
 uses a different and even more braindead protocol that is completely
 incompatible. Some vendor Unixes (particularly those from Sun) have
-been found to use this old protocol. There's a patch from Juan-Mariano de
-Goyeneche (jmse...@dit.upm.es) which makes talk/talkd, if compiled with 
--DSUN_HACK, compatible with SunOS/Solaris' ones. It converts messages from
-one protocol to the other.
+been found to use this old protocol.
 .Pp
 Old versions of
 .Nm talk
diff -Nru netkit-ntalk-0.17/talk/talk.h netkit-ntalk-0.17/talk/talk.h
--- netkit-ntalk-0.17/talk/talk.h       2018-12-05 19:20:49.000000000 +0100
+++ netkit-ntalk-0.17/talk/talk.h       1999-11-25 08:46:44.000000000 +0100
@@ -40,56 +40,12 @@
 
 #include "prot_talkd.h"
 
-#ifdef SUN_HACK
-/*
- * Personalities: NORMAL --> Normal behaviour; (almost) everybody.
- *               SUNOS  --> The rest: SunOS/Solaris.
- */
-#define P_NORMAL 1
-#define P_SUNOS  2
-
-/*
- * Client(SunOS)->server request message format.
- */
-
-typedef struct {
-        u_char  type;           /* request type */
-#define NAME_SIZE_S       9
-        char    l_name[NAME_SIZE_S];/* caller's name */
-        char    r_name[NAME_SIZE_S];/* callee's name */
-        u_char  pad;
-        u_int32_t id_num;       /* message id */
-        int32_t pid;            /* caller's process id */
-        char    r_tty[TTY_SIZE];/* callee's tty name */
-        struct  osockaddr addr;         /* old (4.3) style */
-        struct  osockaddr ctl_addr;     /* old (4.3) style */
-} CTL_MSG_S;
-
-/*
- * Server(SunOS)->client response message format.
- */
-typedef struct {
-        u_char  type;           /* type of request message, see below */
-        u_char  answer;         /* response to request message, see below */
-        u_short  pad;
-        u_long id_num;       /* message id */
-        struct  osockaddr addr; /* address for establishing conversation */
-} CTL_RESPONSE_S;
-#endif
-
-
-
 extern int sockt;
 extern int invitation_waiting;
 
 extern const char *current_state;
 extern int current_line;
 
-#ifdef SUN_HACK
-extern char personality;
-#endif
-
-
 void p_error(const char *string);
 void quit(int);
 void message(const char *mesg);
@@ -107,10 +63,6 @@
 void talk(void);
 void send_delete(void);
 void display(int hiswin, unsigned char *, int);
-#ifdef SUN_HACK
-void msg2msg_S(const CTL_MSG *, CTL_MSG_S *);
-void resp_S2resp(const CTL_RESPONSE_S *, CTL_RESPONSE *);
-#endif
 
 void set_my_edit_chars(int ctrlh, int ctrlu, int ctrlw);
 void set_his_edit_chars(int ctrlh, int ctrlu, int ctrlw);
diff -Nru netkit-ntalk-0.17/talkd/announce.c netkit-ntalk-0.17/talkd/announce.c
--- netkit-ntalk-0.17/talkd/announce.c  2018-12-05 19:20:49.000000000 +0100
+++ netkit-ntalk-0.17/talkd/announce.c  2000-07-22 17:27:39.000000000 +0200
@@ -49,7 +49,6 @@
 #include <fcntl.h>
 #include <string.h>
 #include <paths.h>
-#include <time.h>
 #include "prot_talkd.h"
 #include "proto.h"
 
diff -Nru netkit-ntalk-0.17/talkd/Makefile netkit-ntalk-0.17/talkd/Makefile
--- netkit-ntalk-0.17/talkd/Makefile    2018-12-05 19:20:49.000000000 +0100
+++ netkit-ntalk-0.17/talkd/Makefile    1999-08-01 05:20:44.000000000 +0200
@@ -4,7 +4,6 @@
 include ../MRULES
 
 CFLAGS += -I../include
-LIBS += -lwrap
 
 OBJS = talkd.o announce.o process.o table.o print.o repairs.o
 
diff -Nru netkit-ntalk-0.17/talkd/table.c netkit-ntalk-0.17/talkd/table.c
--- netkit-ntalk-0.17/talkd/table.c     2018-12-05 19:20:49.000000000 +0100
+++ netkit-ntalk-0.17/talkd/table.c     1998-11-27 08:58:47.000000000 +0100
@@ -46,13 +46,13 @@
  * Consider this a mis-guided attempt at modularity
  */
 #include <sys/param.h>
+#include <sys/time.h>
 #include <sys/socket.h>
 #include <syslog.h>
 #include <unistd.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <time.h>
 #include <netinet/in.h>
 
 #include "prot_talkd.h"
diff -Nru netkit-ntalk-0.17/talkd/talkd.8 netkit-ntalk-0.17/talkd/talkd.8
--- netkit-ntalk-0.17/talkd/talkd.8     2018-12-05 19:20:49.000000000 +0100
+++ netkit-ntalk-0.17/talkd/talkd.8     2000-07-31 01:57:02.000000000 +0200
@@ -39,8 +39,8 @@
 .Nm talkd
 .Nd remote user communication server
 .Sh SYNOPSIS
-.Nm /usr/sbin/in.talkd
-.Op Fl dpq
+.Nm talkd
+.Op Fl dp
 .Sh DESCRIPTION
 .Nm Talkd
 is the server that notifies a user that someone else wants to
@@ -76,9 +76,6 @@
 Packet logging mode; writes copies of malformed packets to
 .Pa /var/log/talkd.packets .
 This is useful for debugging interoperability problems.
-.Pp
-.Op Fl q
-Don't log successful connects.
 .Sh SEE ALSO
 .Xr talk 1 ,
 .Xr write 1
diff -Nru netkit-ntalk-0.17/talkd/talkd.c netkit-ntalk-0.17/talkd/talkd.c
--- netkit-ntalk-0.17/talkd/talkd.c     2018-12-05 19:20:49.000000000 +0100
+++ netkit-ntalk-0.17/talkd/talkd.c     1999-09-29 00:04:15.000000000 +0200
@@ -63,13 +63,11 @@
 #include <string.h>
 #include <netdb.h>
 #include <paths.h>
-#include <tcpd.h>
 #include "prot_talkd.h"
 #include "proto.h"
 
 #define TIMEOUT 30
 #define MAXIDLE 120
-#define MINUDPSRCPORT 1024
 
 #if !defined(MAXHOSTNAMELEN)
 #define        MAXHOSTNAMELEN  64
@@ -77,10 +75,6 @@
 char ourhostname[MAXHOSTNAMELEN];
 
 static time_t lastmsgtime;
-#ifndef __USE_GNU
-static char *program_invocation_short_name;
-#endif
-static int quiet;
 
 static void
 timeout(int ignore)
@@ -169,16 +163,11 @@
        char theirhost[MAXHOSTNAMELEN];
        const char *theirip;
 
+       struct hostent *hp;
        struct sockaddr_in sn;
-       struct sockaddr_in server_sin;
-       int cc;
+       int cc, i, ok;
        socklen_t addrlen;
-       int theirport;
-
-       struct request_info request;
 
-       signal(SIGALRM, timeout);
-       alarm(TIMEOUT);
        addrlen = sizeof(sn);
        cc = recvfrom(0, inbuf, sizeof(inbuf), 0,
                      (struct sockaddr *)&sn, &addrlen);
@@ -205,12 +194,6 @@
                return;
        }
 
-       theirport = ntohs(sn.sin_port);
-       if (theirport < MINUDPSRCPORT) {
-               syslog(LOG_WARNING, "%d: bad port", theirport);
-               return;
-       }
-
        /* 
         * If we get here we have an address we can reply to, although
         * it may not be good for much. If possible, reply to it, because
@@ -220,31 +203,37 @@
        theirip = inet_ntoa(sn.sin_addr);
        mp = (CTL_MSG *)inbuf;
 
-       addrlen = sizeof(server_sin);
-       if (getsockname(0, (struct sockaddr *)&server_sin, &addrlen)<0) {
-               syslog(LOG_WARNING, "getsockname: %s", strerror(errno));
+       /*
+        * Check they're not being weenies.
+        * We should look into using libwrap here so hosts.deny works.
+        * Wrapping talkd with tcpd isn't very useful.
+        */
+       hp = gethostbyaddr((char *)&sn.sin_addr, sizeof(struct in_addr), 
+                          AF_INET);
+       if (hp == NULL) {
+               syslog(LOG_WARNING, "%s: bad dns", theirip);
+               send_reject_packet(mp, &sn, MACHINE_UNKNOWN, 0);
                return;
        }
-       request_init(&request,
-                    RQ_FILE, 0,
-                    RQ_DAEMON, program_invocation_short_name,
-                    RQ_CLIENT_SIN, &sn,
-                    RQ_SERVER_SIN, &server_sin,
-                    0);
-       sock_methods(&request);
-       if (!hosts_access(&request)) {
-               refuse(&request);
+       strncpy(theirhost, hp->h_name, sizeof(theirhost));
+       theirhost[sizeof(theirhost)-1] = 0;
+
+       hp = gethostbyname(theirhost);
+       if (hp == NULL) {
+               syslog(LOG_WARNING, "%s: bad dns", theirip);
                send_reject_packet(mp, &sn, MACHINE_UNKNOWN, 0);
                return;
        }
-       if (!quiet) {
-               syslog(LOG_INFO, "connect from %s", eval_client(&request));
-       }
 
-       signal(SIGALRM, timeout);
-       alarm(TIMEOUT);
-       strncpy(theirhost, eval_hostinfo(request.client), sizeof(theirhost));
-       theirhost[sizeof(theirhost)-1] = 0;
+       for (i=ok=0; hp->h_addr_list[i] && !ok; i++) {
+               if (!memcmp(hp->h_addr_list[i], &sn.sin_addr, 
+                           sizeof(sn.sin_addr))) ok = 1;
+       }
+       if (!ok) {
+               syslog(LOG_WARNING, "%s: bad dns", theirip);
+               send_reject_packet(mp, &sn, MACHINE_UNKNOWN, 0);
+               return;
+       }
 
        /*
         * Try to straighten out bad packets.
@@ -330,16 +319,11 @@
        socklen_t sz = sizeof(sn);
        int do_debug=0, do_badpackets=0, ch;
 
-#ifndef __USE_GNU
-       program_invocation_short_name = argv[0];
-       if (argv[0][0] == '/') {
-               program_invocation_short_name = strrchr(argv[0], '/') + 1;
-       }
-#endif
        /* make sure we're a daemon */
        if (getsockname(0, (struct sockaddr *)&sn, &sz)) {
-               printf ("must be run from inetd.\n");
-               exit (1);
+               const char *msg = strerror(errno);
+               write(2, msg, strlen(msg));
+               exit(1);
        }
        openlog("talkd", LOG_PID, LOG_DAEMON);
        if (gethostname(ourhostname, sizeof(ourhostname) - 1) < 0) {
@@ -350,15 +334,16 @@
                syslog(LOG_ERR, "chdir: %s: %s", _PATH_DEV, strerror(errno));
                exit(1);
        }
-       while ((ch = getopt(argc, argv, "dpq"))!=-1) {
+       while ((ch = getopt(argc, argv, "dp"))!=-1) {
                switch (ch) {
                    case 'd': do_debug=1; break;
                    case 'p': do_badpackets=1; break;
-                   case 'q': quiet=1; break;
                }
        }
        set_debug(do_debug, do_badpackets);
 
+       signal(SIGALRM, timeout);
+       alarm(TIMEOUT);
        for (;;) {
                do_one_packet();
        }

Attachment: signature.asc
Description: PGP signature

Reply via email to