commit-inetutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU Inetutils branch, master, updated. inetutils-1_9_1-181-g066ab


From: Mats Erik Andersson
Subject: [SCM] GNU Inetutils branch, master, updated. inetutils-1_9_1-181-g066ab95
Date: Wed, 03 Oct 2012 20:21:58 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Inetutils ".

The branch, master has been updated
       via  066ab951480bcdf9599da7e8a1f2822b116fa5ef (commit)
       via  6cc00eea329b672efee344f71844d70796d90510 (commit)
       via  99971d407ceff56f8f6be622d8295f20f7104e41 (commit)
      from  303e2467054ace8a8951d42ae28e714a67059295 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=066ab951480bcdf9599da7e8a1f2822b116fa5ef


commit 066ab951480bcdf9599da7e8a1f2822b116fa5ef
Author: Mats Erik Andersson <address@hidden>
Date:   Tue Oct 2 16:31:21 2012 +0200

    Overflow protection.

diff --git a/ChangeLog b/ChangeLog
index 801b192..a6cc7af 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,18 @@
 2012-10-02  Mats Erik Andersson  <address@hidden>
 
+       * libinetutils/logwtmp.c [HAVE_STRUCT_UTMPX_UT_SYSLEN]:
+       Take care of overlong host name when storing length
+       in `ut.ut_syslen'.
+       * libinetutils/logwtmpko.c, libinetutils/utmp_init.c:
+       Likewise.
+
+       * ftpd/popen.c, libinetutils/daemon.c,
+       libinetutils/ttymsg.c, src/inetd.c, src/rshd.c,
+       src/syslogd.c, telnet/commands.c: Call _exit()
+       with EXIT_SUCCESS or EXIT_FAILURE, not 0 or 1.
+
+2012-10-02  Mats Erik Andersson  <address@hidden>
+
        uucpd: Upgrade, including IPv6.
 
        * src/uucpd.c: Include <unused-parameter.h>.
diff --git a/ftpd/popen.c b/ftpd/popen.c
index 8aa8a11..8cc6857 100644
--- a/ftpd/popen.c
+++ b/ftpd/popen.c
@@ -183,7 +183,7 @@ ftpd_popen (char *program, const char *type)
 #endif
 
       execv (gargv[0], gargv);
-      _exit (1);
+      _exit (EXIT_FAILURE);
     }
   /* parent; assume fdopen can't fail...  */
   if (*type == 'r')
diff --git a/libinetutils/daemon.c b/libinetutils/daemon.c
index 5606b10..1265c68 100644
--- a/libinetutils/daemon.c
+++ b/libinetutils/daemon.c
@@ -142,7 +142,7 @@ waitdaemon (int nochdir, int noclose, int maxwait)
          alarm (maxwait);
          pause ();
        }
-      _exit (0);
+      _exit (EXIT_SUCCESS);
     }
 
   if (setsid () == -1)
@@ -163,7 +163,7 @@ waitdaemon (int nochdir, int noclose, int maxwait)
       return -1;
 
     default:
-      _exit (0);
+      _exit (EXIT_SUCCESS);
     }
 
   if (!nochdir)
diff --git a/libinetutils/logwtmp.c b/libinetutils/logwtmp.c
index e8a0965..d859efe 100644
--- a/libinetutils/logwtmp.c
+++ b/libinetutils/logwtmp.c
@@ -136,7 +136,13 @@ logwtmp (char *line, char *name, char *host)
 #if defined HAVE_STRUCT_UTMP_UT_HOST || defined HAVE_STRUCT_UTMPX_UT_HOST
   strncpy (ut.ut_host, host, sizeof ut.ut_host);
 # ifdef HAVE_STRUCT_UTMPX_UT_SYSLEN    /* Only utmpx.  */
-  ut.ut_syslen = strlen (host) + 1;    /* Including NUL.  */
+  if (strlen (host) < sizeof (ut.ut_host))
+    ut.ut_syslen = strlen (host) + 1;  /* Including NUL.  */
+  else
+    {
+      ut.ut_host[sizeof (ut.ut_host) - 1] = '\0';
+      ut.ut_syslen = sizeof (ut.ut_host);
+    }
 # endif /* UT_SYSLEN */
 #endif /* UT_HOST */
 
diff --git a/libinetutils/logwtmpko.c b/libinetutils/logwtmpko.c
index ec4135a..a40ad07 100644
--- a/libinetutils/logwtmpko.c
+++ b/libinetutils/logwtmpko.c
@@ -54,7 +54,13 @@ logwtmp (char *line, char *name, char *host)
 #ifdef HAVE_STRUCT_UTMPX_UT_HOST
   strncpy (ut.ut_host, host, sizeof ut.ut_host);
 # ifdef HAVE_STRUCT_UTMPX_UT_SYSLEN
-  ut.ut_syslen = strlen (host) + 1;    /* Including NUL.  */
+  if (strlen (host) < sizeof (ut.ut_host))
+    ut.ut_syslen = strlen (host) + 1;
+  else
+    {
+      ut.ut_host[sizeof (ut.ut_host) - 1] = '\0';
+      ut.ut_syslen = sizeof (ut.ut_host);
+    }
 # endif /* UT_SYSLEN */
 #endif
 #ifdef HAVE_STRUCT_UTMPX_UT_PID
diff --git a/libinetutils/ttymsg.c b/libinetutils/ttymsg.c
index b25d07a..8d4e0b2 100644
--- a/libinetutils/ttymsg.c
+++ b/libinetutils/ttymsg.c
@@ -152,7 +152,7 @@ ttymsg (struct iovec *iov, int iovcnt, char *line, int 
tmout)
          if (forked)
            {
              close (fd);
-             _exit (1);
+             _exit (EXIT_FAILURE);
            }
          cpid = fork2 ();
          if (cpid < 0)
@@ -194,7 +194,7 @@ ttymsg (struct iovec *iov, int iovcnt, char *line, int 
tmout)
        break;
       close (fd);
       if (forked)
-       _exit (1);
+       _exit (EXIT_FAILURE);
       snprintf (errbuf, sizeof (errbuf), "%s: %s", device, strerror (errno));
       free (device);
       return (errbuf);
@@ -203,7 +203,7 @@ ttymsg (struct iovec *iov, int iovcnt, char *line, int 
tmout)
   free (device);
   close (fd);
   if (forked)
-    _exit (0);
+    _exit (EXIT_SUCCESS);
   return (NULL);
 }
 
@@ -232,7 +232,7 @@ fork2 (void)
        case -1:
          _exit (errno);        /* Assumes all errnos are <256 */
        default:                /* Parent.  */
-         _exit (0);
+         _exit (EXIT_SUCCESS);
        }
     }
 
diff --git a/libinetutils/utmp_init.c b/libinetutils/utmp_init.c
index b598a9f..6cbfd10 100644
--- a/libinetutils/utmp_init.c
+++ b/libinetutils/utmp_init.c
@@ -91,7 +91,13 @@ utmp_init (char *line, char *user, char *id, char *host)
 #if defined HAVE_STRUCT_UTMP_UT_HOST || defined HAVE_STRUCT_UTMPX_UT_HOST
   strncpy (utx.ut_host, host, sizeof (utx.ut_host));
 # ifdef HAVE_STRUCT_UTMPX_UT_SYSLEN    /* Only utmpx.  */
-  utx.ut_syslen = strlen (host) + 1;
+  if (strlen (host) < sizeof (utx.ut_host))
+    utx.ut_syslen = strlen (host) + 1;
+  else
+    {
+      utx.ut_host[sizeof (utx.ut_host) - 1] = '\0';
+      utx.ut_syslen = sizeof (utx.ut_host);
+    }
 # endif
 #endif /* UT_HOST */
 #if defined HAVE_STRUCT_UTMP_UT_LINE || defined HAVE_STRUCT_UTMPX_UT_LINE
diff --git a/src/inetd.c b/src/inetd.c
index 51b812b..5c720de 100644
--- a/src/inetd.c
+++ b/src/inetd.c
@@ -438,7 +438,7 @@ run_service (int ctrl, struct servtab *sep)
                  sep->se_service, sep->se_proto, sep->se_user);
          if (sep->se_socktype != SOCK_STREAM)
            recv (0, buf, sizeof buf, 0);
-         _exit (1);
+         _exit (EXIT_FAILURE);
        }
       if (sep->se_group && *sep->se_group)
        {
@@ -449,7 +449,7 @@ run_service (int ctrl, struct servtab *sep)
                      sep->se_service, sep->se_proto, sep->se_group);
              if (sep->se_socktype != SOCK_STREAM)
                recv (0, buf, sizeof buf, 0);
-             _exit (1);
+             _exit (EXIT_FAILURE);
            }
        }
       if (pwd->pw_uid)
@@ -460,14 +460,14 @@ run_service (int ctrl, struct servtab *sep)
                {
                  syslog (LOG_ERR, "%s: can't set gid %d: %m",
                          sep->se_service, grp->gr_gid);
-                 _exit (1);
+                 _exit (EXIT_FAILURE);
                }
            }
          else if (setgid (pwd->pw_gid) < 0)
            {
              syslog (LOG_ERR, "%s: can't set gid %d: %m",
                      sep->se_service, pwd->pw_gid);
-             _exit (1);
+             _exit (EXIT_FAILURE);
            }
 #ifdef HAVE_INITGROUPS
          initgroups (pwd->pw_name,
@@ -477,14 +477,14 @@ run_service (int ctrl, struct servtab *sep)
            {
              syslog (LOG_ERR, "%s: can't set uid %d: %m",
                      sep->se_service, pwd->pw_uid);
-             _exit (1);
+             _exit (EXIT_FAILURE);
            }
        }
       execv (sep->se_server, sep->se_argv);
       if (sep->se_socktype != SOCK_STREAM)
        recv (0, buf, sizeof buf, 0);
       syslog (LOG_ERR, "cannot execute %s: %m", sep->se_server);
-      _exit (1);
+      _exit (EXIT_FAILURE);
     }
 }
 
@@ -1768,7 +1768,7 @@ tcpmux (int s, struct servtab *sep)
   if (len < 0)
     {
       strwrite (s, "-Error reading service name\r\n");
-      _exit (1);
+      _exit (EXIT_FAILURE);
     }
   service[len] = '\0';
 
@@ -1788,7 +1788,7 @@ tcpmux (int s, struct servtab *sep)
          write (s, sep->se_service, strlen (sep->se_service));
          strwrite (s, "\r\n");
        }
-      _exit (1);
+      _exit (EXIT_FAILURE);
     }
 
   /* Try matching a service in inetd.conf with the request */
diff --git a/src/rshd.c b/src/rshd.c
index 27d4017..35d8588 100644
--- a/src/rshd.c
+++ b/src/rshd.c
@@ -362,7 +362,7 @@ main (int argc, char *argv[])
   if (getpeername (sockfd, (struct sockaddr *) &from, &fromlen) < 0)
     {
       syslog (LOG_ERR, "getpeername: %m");
-      _exit (1);
+      _exit (EXIT_FAILURE);
     }
 
   /* Set the socket options: SO_KEEPALIVE and SO_LINGER */
diff --git a/src/syslogd.c b/src/syslogd.c
index 37dfd8a..f184459 100644
--- a/src/syslogd.c
+++ b/src/syslogd.c
@@ -1676,7 +1676,7 @@ logerror (const char *type)
 void
 doexit (int signo _GL_UNUSED_PARAMETER)
 {
-  _exit (0);
+  _exit (EXIT_SUCCESS);
 }
 
 void
diff --git a/telnet/commands.c b/telnet/commands.c
index e6b73d5..0375e72 100644
--- a/telnet/commands.c
+++ b/telnet/commands.c
@@ -1590,7 +1590,7 @@ shell (int argc, char *argv[] _GL_UNUSED_PARAMETER)
        else
          execl (shellp, shellname, NULL);
        perror ("Execl");
-       _exit (1);
+       _exit (EXIT_FAILURE);
       }
     default:
       wait ((int *) 0);                /* Wait for the shell to complete */

http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=6cc00eea329b672efee344f71844d70796d90510


commit 6cc00eea329b672efee344f71844d70796d90510
Author: Mats Erik Andersson <address@hidden>
Date:   Tue Oct 2 14:39:34 2012 +0200

    uucpd: Upgrade, including IPv6.

diff --git a/ChangeLog b/ChangeLog
index 8ba9f02..801b192 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,30 @@
+2012-10-02  Mats Erik Andersson  <address@hidden>
+
+       uucpd: Upgrade, including IPv6.
+
+       * src/uucpd.c: Include <unused-parameter.h>.
+       (hisctladdr, hisaddrlen): Remove variables.
+       (uucico_location, Logname): New variables.
+       (nenv): Add `Logname'.
+       (argp_options): New variable.
+       (parse_opt): New function.
+       (argp): Add `argp_options' and `parse_opt'.
+       (main): New variables HISCTLADDR, HISADDRLEN.
+       (readline): Read from STDIN_FILENO.
+       (doit): New signature `(struct sockaddr *, socklen_t)'.
+       Remove truncation of USER.  Ask password for non-existent
+       user, then fail.  Check user shell after password check,
+       and compare to `uucico_location'.  Set LOGNAME in `nenv'
+       for portability.  Call execl() with `uucico_location'.
+       [HAVE_INITGROUPS]: Guard call to initgroups().
+       (dologin): New signature
+       `(struct passwd *, struct sockaddr *, socklen_t)'
+       [HAVE_DECL_GETNAMEINFO]: Use getnameinfo() as resolver.
+       [!HAVE_DECL_GETNAMEINFO]: Extend code with gethostbyaddr()
+       to accept IPv6.  Replace inet_ntoa() by inet_ntop().
+       (dologin) [HAVE_STRUCT_UTMPX_UT_SYSLEN]: Correctly set
+       the used length of `ut.ut_host'.
+
 2012-10-01  Mats Erik Andersson  <address@hidden>
 
        uucpd: Restore inetd code.
diff --git a/src/uucpd.c b/src/uucpd.c
index bee2803..4ff6295 100644
--- a/src/uucpd.c
+++ b/src/uucpd.c
@@ -87,28 +87,53 @@
 
 #include <argp.h>
 #include <progname.h>
+#include <unused-parameter.h>
 #include <libinetutils.h>
 
-void dologin (struct passwd *pw, struct sockaddr_in *sin);
+void dologin (struct passwd *pw, struct sockaddr *sap, socklen_t salen);
 void dologout (void);
-void doit (struct sockaddr_in *sinp);
-
-struct sockaddr_in hisctladdr;
-socklen_t hisaddrlen = sizeof (hisctladdr);
+void doit (struct sockaddr *sap, socklen_t salen);
 
+char *uucico_location = PATH_UUCICO;
 int mypid;
 
 char Username[64];
+char Logname[64];
 char *nenv[] = {
   Username,
+  Logname,
   NULL,
 };
 
 extern char **environ;
 
+static struct argp_option argp_options[] = {
+#define GRP 10
+  { "uucico", 'u', "LOCATION", 0,
+    "location of uucico executable, "
+    "replacing default at " PATH_UUCICO, GRP },
+#undef GRP
+  { NULL, 0, NULL, 0, NULL, 0 }
+};
+
+static error_t
+parse_opt (int key, char *arg,
+          struct argp_state *state _GL_UNUSED_PARAMETER)
+{
+  switch (key)
+    {
+    case 'u':
+      uucico_location = arg;
+      break;
+    default:
+      return ARGP_ERR_UNKNOWN;
+    }
+  return 0;
+}
+
 static struct argp argp =
   {
-    NULL, NULL, NULL,
+    argp_options, parse_opt, NULL,
     "TCP/IP server for uucico.",
     NULL, NULL, NULL
   };
@@ -116,6 +141,9 @@ static struct argp argp =
 int
 main (int argc, char **argv)
 {
+  struct sockaddr_storage hisctladdr;
+  socklen_t hisaddrlen = sizeof (hisctladdr);
+
   set_program_name (argv[0]);
   iu_argp_init ("uucpd", default_program_authors);
   argp_parse (&argp, argc, argv, 0, NULL, NULL);
@@ -128,7 +156,8 @@ main (int argc, char **argv)
   dup2 (STDIN_FILENO, STDERR_FILENO);
 
   hisaddrlen = sizeof (hisctladdr);
-  if (getpeername (STDIN_FILENO, &hisctladdr, &hisaddrlen) < 0)
+  if (getpeername (STDIN_FILENO, (struct sockaddr *) &hisctladdr,
+                  &hisaddrlen) < 0)
     {
       fprintf (stderr, "%s: ", argv[0]);
       perror ("getpeername");
@@ -136,7 +165,7 @@ main (int argc, char **argv)
     }
 
   if (fork () == 0)
-    doit (&hisctladdr);
+    doit ((struct sockaddr *) &hisctladdr, hisaddrlen);
 
   dologout ();
   exit (EXIT_FAILURE);
@@ -149,7 +178,7 @@ readline (register char *p, register int n)
 
   while (n-- > 0)
     {
-      if (read (0, &c, 1) <= 0)
+      if (read (STDIN_FILENO, &c, 1) <= 0)
        return (-1);
       c &= 0177;
       if (c == '\n' || c == '\r')
@@ -163,7 +192,7 @@ readline (register char *p, register int n)
 }
 
 void
-doit (struct sockaddr_in *sinp)
+doit (struct sockaddr *sap, socklen_t salen)
 {
   struct passwd *pw;
   char user[64], passwd[64];
@@ -177,17 +206,21 @@ doit (struct sockaddr_in *sinp)
       fprintf (stderr, "user read\n");
       return;
     }
-  /* truncate username to 8 characters */
-  user[8] = '\0';
+  user[sizeof (user) - 1] = '\0';
+
   pw = getpwnam (user);
   if (pw == NULL)
     {
-      fprintf (stderr, "user unknown\n");
-      return;
-    }
-  /* XXX: Compare only shell base name to "uucico"?  */
-  if (strcmp (pw->pw_shell, PATH_UUCICO))
-    {
+      /* Simulate continuation, in order not
+       * to disclose user name information.
+       */
+      printf ("Password: ");
+      fflush (stdout);
+      if (readline (passwd, sizeof (passwd)) < 0)
+       {
+         fprintf (stderr, "passwd read\n");
+         return;
+       }
       fprintf (stderr, "Login incorrect.");
       return;
     }
@@ -207,14 +240,27 @@ doit (struct sockaddr_in *sinp)
          return;
        }
     }
+
+  /* XXX: Compare only shell base name to "uucico"?
+   * Calling execl(uucico_location) would still use
+   * the only acceptable binary.  */
+  if (strcmp (pw->pw_shell, uucico_location))
+    {
+      fprintf (stderr, "Login incorrect.");
+      return;
+    }
+
   alarm (0);
   sprintf (Username, "USER=%s", user);
-  dologin (pw, sinp);
+  sprintf (Logname, "LOGNAME=%s", user);
+  dologin (pw, sap, salen);
   setgid (pw->pw_gid);
+#ifdef HAVE_INITGROUPS
   initgroups (pw->pw_name, pw->pw_gid);
+#endif
   chdir (pw->pw_dir);
   setuid (pw->pw_uid);
-  execl (pw->pw_shell, "uucico", NULL);
+  execl (uucico_location, "uucico", NULL);
   perror ("uucico server: execl");
 }
 
@@ -266,15 +312,42 @@ dologout (void)
  * Record login in wtmp file.
  */
 void
-dologin (struct passwd *pw, struct sockaddr_in *sin)
+dologin (struct passwd *pw, struct sockaddr *sap, socklen_t salen)
 {
   char line[32];
-  char remotehost[32];
 #if defined PATH_LASTLOG && defined HAVE_STRUCT_LASTLOG
   int f;
 #endif
-  struct hostent *hp = gethostbyaddr ((char *) &sin->sin_addr,
-                                     sizeof (struct in_addr), AF_INET);
+#if HAVE_DECL_GETNAMEINFO
+  char remotehost[NI_MAXHOST];
+
+  if (getnameinfo (sap, salen, remotehost, sizeof (remotehost),
+                  NULL, 0, 0))
+    (void) getnameinfo (sap, salen, remotehost, sizeof (remotehost),
+                       NULL, 0, NI_NUMERICHOST);
+#else
+  char remotehost[64];
+  struct hostent *hp;
+  void *addr;
+  socklen_t addrlen;
+
+  switch (sap->sa_family)
+    {
+#ifdef IPV6
+    case AF_INET6:
+      addr = (void *) &(((struct sockaddr_in6 *) sap)->sin6_addr);
+      addrlen = sizeof (struct in6_addr);
+      break;
+#endif
+    case AF_INET:
+    default:
+      addr = (void *) &(((struct sockaddr_in *) sap)->sin_addr);
+      addrlen = sizeof (struct in_addr);
+      break;
+    }
+
+  (void) salen;                /* Silence warning.  */
+  hp = gethostbyaddr (addr, addrlen, sap->sa_family);
 
   if (hp)
     {
@@ -282,7 +355,12 @@ dologin (struct passwd *pw, struct sockaddr_in *sin)
       endhostent ();
     }
   else
-    strncpy (remotehost, inet_ntoa (sin->sin_addr), sizeof (remotehost));
+    {
+      remotehost[0] = '\0';
+      (void) inet_ntop (sap->sa_family, addr,
+                       remotehost, sizeof (remotehost));
+    }
+#endif
 
   sprintf (line, "uucp%.4d", (int) getpid ());
 
@@ -302,7 +380,13 @@ dologin (struct passwd *pw, struct sockaddr_in *sin)
     strncpy (ut.ut_user, pw->pw_name, sizeof (ut.ut_user));
     strncpy (ut.ut_host, remotehost, sizeof (ut.ut_host));
 # ifdef HAVE_STRUCT_UTMPX_UT_SYSLEN
-       ut.ut_syslen = strlen (remotehost) + 1;
+    if (strlen (remotehost) < sizeof (ut.ut_host))
+      ut.ut_syslen = strlen (remotehost) + 1;
+    else
+      {
+       ut.ut_host[sizeof (ut.ut_host) - 1] = '\0';
+       ut.ut_syslen = sizeof (ut.ut_host);
+      }
 # endif
     gettimeofday (&now, NULL);
     ut.ut_tv.tv_sec = now.tv_sec;

http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=99971d407ceff56f8f6be622d8295f20f7104e41


commit 99971d407ceff56f8f6be622d8295f20f7104e41
Author: Mats Erik Andersson <address@hidden>
Date:   Mon Oct 1 13:58:26 2012 +0200

    uucpd: Restore inetd code.

diff --git a/ChangeLog b/ChangeLog
index 21836c8..8ba9f02 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2012-10-01  Mats Erik Andersson  <address@hidden>
+
+       uucpd: Restore inetd code.
+
+       Code necessary for inetd mode was accidentally
+       removed on 2009-10-26.  Replace daemon mode code.
+       * src/uucpd.c: Include <grp.h>.
+       (hisaddrlen): Type is socklen_t.
+       (myctladdr): Removed.
+       (main): Remove variables S and SP.  Remove broken,
+       partial code for daemon mode operation.  New calls
+       to dup2(), getpeername(), doit(), and dologout().
+       (doit): New calls to initgroups() and execl().
+
 2012-09-28  Mats Erik Andersson  <address@hidden>
 
        rlogind: Daemon mode update.
diff --git a/src/uucpd.c b/src/uucpd.c
index 70b38cd..bee2803 100644
--- a/src/uucpd.c
+++ b/src/uucpd.c
@@ -51,7 +51,7 @@
    Adams. */
 
 /*
- * 4.2BSD TCP/IP server for uucico
+ * TCP/IP server for uucico.
  * uucico's TCP channel causes this server to be run at the remote end.
  */
 
@@ -68,6 +68,7 @@
 #include <sys/time.h>
 #include <time.h>
 #include <pwd.h>
+#include <grp.h>
 #include <unistd.h>
 #include <errno.h>
 #include <stdio.h>
@@ -89,10 +90,12 @@
 #include <libinetutils.h>
 
 void dologin (struct passwd *pw, struct sockaddr_in *sin);
+void dologout (void);
+void doit (struct sockaddr_in *sinp);
 
 struct sockaddr_in hisctladdr;
-int hisaddrlen = sizeof hisctladdr;
-struct sockaddr_in myctladdr;
+socklen_t hisaddrlen = sizeof (hisctladdr);
+
 int mypid;
 
 char Username[64];
@@ -100,44 +103,43 @@ char *nenv[] = {
   Username,
   NULL,
 };
+
 extern char **environ;
 
 static struct argp argp =
   {
     NULL, NULL, NULL,
-    "TCP/IP server for uucico",
+    "TCP/IP server for uucico.",
     NULL, NULL, NULL
   };
 
 int
 main (int argc, char **argv)
 {
-  register int s;
-  struct servent *sp;
-  void dologout (void);
-
   set_program_name (argv[0]);
   iu_argp_init ("uucpd", default_program_authors);
   argp_parse (&argp, argc, argv, 0, NULL, NULL);
 
+  /* Minimal environment, containing only USER.  */
   environ = nenv;
-  sp = getservbyname ("uucp", "tcp");
-  if (sp == NULL)
-    {
-      perror ("uucpd: getservbyname");
-      exit (EXIT_FAILURE);
-    }
-  if (fork ())
-    exit (EXIT_SUCCESS);
-  if ((s = open (PATH_TTY, O_RDWR)) >= 0)
+
+  /* Circumvent all descriptor trickery.  */
+  dup2 (STDIN_FILENO, STDOUT_FILENO);
+  dup2 (STDIN_FILENO, STDERR_FILENO);
+
+  hisaddrlen = sizeof (hisctladdr);
+  if (getpeername (STDIN_FILENO, &hisctladdr, &hisaddrlen) < 0)
     {
-      ioctl (s, TIOCNOTTY, (char *) 0);
-      close (s);
+      fprintf (stderr, "%s: ", argv[0]);
+      perror ("getpeername");
+      _exit (EXIT_FAILURE);
     }
 
-  memset (&myctladdr, 0, sizeof (myctladdr));
-  myctladdr.sin_family = AF_INET;
-  myctladdr.sin_port = sp->s_port;
+  if (fork () == 0)
+    doit (&hisctladdr);
+
+  dologout ();
+  exit (EXIT_FAILURE);
 }
 
 static int
@@ -163,14 +165,14 @@ readline (register char *p, register int n)
 void
 doit (struct sockaddr_in *sinp)
 {
-  struct passwd *pw, *getpwnam (const char *);
+  struct passwd *pw;
   char user[64], passwd[64];
   char *xpasswd;
 
   alarm (60);
   printf ("login: ");
   fflush (stdout);
-  if (readline (user, sizeof user) < 0)
+  if (readline (user, sizeof (user)) < 0)
     {
       fprintf (stderr, "user read\n");
       return;
@@ -183,6 +185,7 @@ doit (struct sockaddr_in *sinp)
       fprintf (stderr, "user unknown\n");
       return;
     }
+  /* XXX: Compare only shell base name to "uucico"?  */
   if (strcmp (pw->pw_shell, PATH_UUCICO))
     {
       fprintf (stderr, "Login incorrect.");
@@ -192,7 +195,7 @@ doit (struct sockaddr_in *sinp)
     {
       printf ("Password: ");
       fflush (stdout);
-      if (readline (passwd, sizeof passwd) < 0)
+      if (readline (passwd, sizeof (passwd)) < 0)
        {
          fprintf (stderr, "passwd read\n");
          return;
@@ -208,8 +211,10 @@ doit (struct sockaddr_in *sinp)
   sprintf (Username, "USER=%s", user);
   dologin (pw, sinp);
   setgid (pw->pw_gid);
+  initgroups (pw->pw_name, pw->pw_gid);
   chdir (pw->pw_dir);
   setuid (pw->pw_uid);
+  execl (pw->pw_shell, "uucico", NULL);
   perror ("uucico server: execl");
 }
 
@@ -320,7 +325,7 @@ dologin (struct passwd *pw, struct sockaddr_in *sin)
       strcpy (line, remotehost);
       SCPYN (ll.ll_line, line);
       SCPYN (ll.ll_host, remotehost);
-      write (f, (char *) &ll, sizeof ll);
+      write (f, (char *) &ll, sizeof (ll));
       close (f);
     }
 #endif

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog                |   54 ++++++++++++++
 ftpd/popen.c             |    2 +-
 libinetutils/daemon.c    |    4 +-
 libinetutils/logwtmp.c   |    8 ++-
 libinetutils/logwtmpko.c |    8 ++-
 libinetutils/ttymsg.c    |    8 +-
 libinetutils/utmp_init.c |    8 ++-
 src/inetd.c              |   16 ++--
 src/rshd.c               |    2 +-
 src/syslogd.c            |    2 +-
 src/uucpd.c              |  177 ++++++++++++++++++++++++++++++++++-----------
 telnet/commands.c        |    2 +-
 12 files changed, 226 insertions(+), 65 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]