mirror of
https://github.com/sudo-project/sudo.git
synced 2025-08-31 14:25:15 +00:00
uses sysconf() if available
This commit is contained in:
46
tgetpass.c
46
tgetpass.c
@@ -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
|
||||
@@ -24,6 +51,15 @@
|
||||
#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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user