]> granicus.if.org Git - sudo/commitdiff
uses sysconf() if available
authorTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 6 Jun 1994 00:04:55 +0000 (00:04 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 6 Jun 1994 00:04:55 +0000 (00:04 +0000)
tgetpass.c

index e21bc70608be85ec487fa6b4d42663a440b76310..09b31ef5f5a26447eafadd322648eda9e839c701 100644 (file)
@@ -1,11 +1,38 @@
+/*
+ *  CU sudo version 1.3.1
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 1, or (at your option)
+ *  any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *  Please send bugs, changes, problems to sudo-bugs.cs.colorado.edu
+ *
+ *******************************************************************
+ *
+ *  This module contains tgetpass(), getpass(3) with a timeout.
+ *
+ *  Todd C. Miller  Sun Jun  5 17:22:31 MDT 1994
+ */
+
 #include "config.h"
 #include "pathnames.h"
 
 #include <stdio.h>
-#include <string.h>
-#include <strings.h>
-#include <sys/time.h>
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif /* HAVE_UNISTD_H */
 #include <sys/types.h>
+#include <sys/time.h>
 #include <signal.h>
 #include <fcntl.h>
 #ifdef HAVE_TERMIOS_H
 #endif /* _PASSWD_LEN */
 
 
+/******************************************************************
+ *
+ *  tgetpass()
+ *
+ *  this function prints a prompt and gets a password from /dev/tty
+ *  or stdin.  Echo is turned off (if possible) during password entry
+ *  and input will time out based on the value of timeout.
+ */
+
 char * tgetpass(prompt, timeout)
     const char *prompt;
     int timeout;
@@ -101,7 +137,11 @@ char * tgetpass(prompt, timeout)
        FD_SET(input, &readfds);
        tv.tv_sec = timeout;
        tv.tv_usec = 0;
+#ifdef HAVE_SYSCONF
+       if (select(sysconf(_SC_OPEN_MAX), &readfds, NULL, NULL, &tv) <= 0) {
+#else
        if (select(getdtablesize(), &readfds, NULL, NULL, &tv) <= 0) {
+#endif /* HAVE_SYSCONF */
            i = 0;
            break;
        }