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_100-7-g52e


From: Mats Erik Andersson
Subject: [SCM] GNU Inetutils branch, master, updated. inetutils-1_9_1_100-7-g52e6331
Date: Sun, 06 Oct 2013 13:26:07 +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  52e6331fe7cc311fa53776cd94988f3cecad0728 (commit)
      from  13a585a09a9aedd20bcf1cbee3eeada1a10d0624 (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=52e6331fe7cc311fa53776cd94988f3cecad0728


commit 52e6331fe7cc311fa53776cd94988f3cecad0728
Author: Mats Erik Andersson <address@hidden>
Date:   Sun Oct 6 13:35:00 2013 +0200

    rexec, rexecd: Small changes.
    
    Turn echo off while reading password by rexec.

diff --git a/ChangeLog b/ChangeLog
index 0a4556c..13a82ae 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2013-10-06  Mats Erik Andersson  <address@hidden>
+
+       rexec: No echoing of passwords.
+
+       * src/rexec.c: Include <termios.h>.
+       (main) <password is '-'>: Call isatty().  If this
+       is a terminal, print `Password:' and disable echo
+       while reading password string.
+       (do_rexec) <FD_ISSET(STDIN_FD)>: Write input from
+       client to the outgoing socket SOCK.  This restores
+       the ability to transfer contents to the server.
+
+
+       rexecd: Better adaption to BSD.
+
+       * configure.ac: Check for function setlogin.
+       * src/rexecd.c (doit) [HAVE_SETLOGIN]: Before
+       setting underpriviledged user, call setlogin().
+       (doit) <with error port && child process>:
+       Close PV[1], which is duplicate of stderr.
+       [HAVE_SETLOGIN]: Call setsid(), not setpgid().
+
 2013-10-03  Mats Erik Andersson  <address@hidden>
 
        * configure.ac (HAVE_SYSLOG_INTERNAL): Remove
diff --git a/configure.ac b/configure.ac
index fc1194d..229f814 100644
--- a/configure.ac
+++ b/configure.ac
@@ -732,7 +732,7 @@ AC_CHECK_FUNCS(cfsetspeed cgetent dirfd fchdir flock \
                getcwd getmsg getpwuid_r getspnam getutxent getutxuser \
                initgroups initsetproctitle killpg \
                ptsname pututline pututxline \
-               setegid seteuid setpgid \
+               setegid seteuid setpgid setlogin \
                setsid setregid setreuid setresgid setresuid setutent_r \
                sigaction sigvec strchr setproctitle tcgetattr tzset utimes \
                utime uname \
diff --git a/src/rexec.c b/src/rexec.c
index 05e358a..bb222ee 100644
--- a/src/rexec.c
+++ b/src/rexec.c
@@ -38,6 +38,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <termios.h>
 
 #include <sys/select.h>
 
@@ -188,7 +189,30 @@ main (int argc, char **argv)
       password[0] = '\0';
 
       alarm (15);
-      fgets (password, sizeof (password), stdin);
+
+      if (isatty (STDIN_FILENO))
+       {
+         int changed = 0;
+         struct termios tt, newtt;
+
+         if (tcgetattr (STDIN_FILENO, &tt) >= 0)
+           {
+             memcpy (&newtt, &tt, sizeof (newtt));
+             newtt.c_lflag &= ~ECHO;
+             newtt.c_lflag |= ECHONL;
+             if (tcsetattr (STDIN_FILENO, TCSANOW, &newtt))
+               error (0, errno, "failed to turn off echo");
+             changed = 1;
+           }
+
+         printf ("Password: ");
+         fgets (password, sizeof (password), stdin);
+
+         if (changed && (tcsetattr (STDIN_FILENO, TCSANOW, &tt) < 0))
+           error (0, errno, "failed to restore terminal");
+       }
+      else
+       fgets (password, sizeof (password), stdin);
       alarm (0);
 
       n = strlen (password);
@@ -391,7 +415,7 @@ do_rexec (struct arguments *arguments)
               continue;
             }
 
-          if (write (STDOUT_FILENO, buffer, err) < 0)
+          if (write (sock, buffer, err) < 0)
             error (EXIT_FAILURE, errno, "error writing");
         }
 
diff --git a/src/rexecd.c b/src/rexecd.c
index 360684b..4678380 100644
--- a/src/rexecd.c
+++ b/src/rexecd.c
@@ -439,6 +439,11 @@ doit (int f, struct sockaddr *fromp, socklen_t fromlen)
     }
 #endif /* WITH_PAM */
 
+#ifdef HAVE_SETLOGIN
+  if (setlogin (pwd->pw_name) < 0)
+    syslog (LOG_ERR, "setlogin() failed: %m");
+#endif
+
   /* Step down from superuser personality.
    *
    * The changing of group membership will seldomly
@@ -549,13 +554,20 @@ doit (int f, struct sockaddr *fromp, socklen_t fromlen)
            }
          while (FD_ISSET (pv[0], &readfrom) || FD_ISSET (s, &readfrom));
          exit (EXIT_SUCCESS);
-       }
-#ifdef HAVE_SETPGID
+       } /* Parent process.  */
+
+#ifdef HAVE_SETLOGIN
+      /* Not sufficient to call setpgid() on BSD systems.  */
+      if (setsid () < 0)
+       syslog (LOG_ERR, "setsid() failed: %m");
+#elif defined HAVE_SETPGID /* !HAVE_SETLOGIN */
       setpgid (0, getpid ());
 #endif
+
       close (s);
       close (pv[0]);
       dup2 (pv[1], STDERR_FILENO);
+      close (pv[1]);
     }
 
   if (f > 2)

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

Summary of changes:
 ChangeLog    |   22 ++++++++++++++++++++++
 configure.ac |    2 +-
 src/rexec.c  |   28 ++++++++++++++++++++++++++--
 src/rexecd.c |   16 ++++++++++++++--
 4 files changed, 63 insertions(+), 5 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 



reply via email to

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