Removed w32_poll, fixes in signal implementation

This commit is contained in:
manojampalam 2016-03-21 20:17:15 -07:00
parent 6af7c19743
commit ae3705d53b
9 changed files with 126 additions and 173 deletions

View File

@ -6,11 +6,13 @@
/* Define if building universal (internal helper macro) */
/* #undef AC_APPLE_UNIVERSAL_BUILD */
/* Define if you have a getaddrinfo that fails for the all-zeros IPv6 address
/* Define if you have a getaddrinfo that fails
for the all-zeros IPv6 address
*/
/* #undef AIX_GETNAMEINFO_HACK */
/* Define if your AIX loginfailed() function takes 4 arguments (AIX >= 5.2)
/* Define if your AIX loginfailed() function
takes 4 arguments (AIX >= 5.2)
*/
/* #undef AIX_LOGINFAILED_4ARG */
@ -32,7 +34,8 @@
/* FreeBSD glob does not do what we need */
/* #undef BROKEN_GLOB */
/* Define if you system's inet_ntoa is busted (e.g. Irix gcc issue) */
/* Define if you system's inet_ntoa is busted
(e.g. Irix gcc issue) */
/* #undef BROKEN_INET_NTOA */
/* ia_uinfo routines not supported by OS yet */
@ -41,7 +44,8 @@
/* Ultrix mmap can't map files */
/* #undef BROKEN_MMAP */
/* Define if your struct dirent expects you to allocate extra space for
/* Define if your struct dirent expects you to
allocate extra space for
d_name */
/* #undef BROKEN_ONE_BYTE_DIRENT_D_NAME */
@ -96,19 +100,23 @@
/* Define if you want to specify the path to your wtmp file */
/* #undef CONF_WTMP_FILE */
/* Define if your platform needs to skip post auth file descriptor passing */
/* Define if your platform needs to skip post auth
file descriptor passing */
#define DISABLE_FD_PASSING 1
/* Define if you don't want to use lastlog */
/* #undef DISABLE_LASTLOG */
/* Define if you don't want to use your system's login() call */
/* Define if you don't want to use your
system's login() call */
/* #undef DISABLE_LOGIN */
/* Define if you don't want to use pututline() etc. to write [uw]tmp */
/* Define if you don't want to use pututline()
etc. to write [uw]tmp */
/* #undef DISABLE_PUTUTLINE */
/* Define if you don't want to use pututxline() etc. to write [uw]tmpx */
/* Define if you don't want to use pututxline()
etc. to write [uw]tmpx */
/* #undef DISABLE_PUTUTXLINE */
/* Define if you want to disable shadow passwords */
@ -144,22 +152,27 @@
/* Conflicting defs for getspnam */
/* #undef GETSPNAM_CONFLICTING_DEFS */
/* Define if your system glob() function has the GLOB_ALTDIRFUNC extension */
/* Define if your system glob() function has
the GLOB_ALTDIRFUNC extension */
/* #undef GLOB_HAS_ALTDIRFUNC */
/* Define if your system glob() function has gl_matchc options in glob_t */
/* Define if your system glob() function has
gl_matchc options in glob_t */
#define GLOB_HAS_GL_MATCHC 1
/* Define if your system glob() function has gl_statv options in glob_t */
/* Define if your system glob() function has
gl_statv options in glob_t */
#define GLOB_HAS_GL_STATV 1
/* Define this if you want GSSAPI support in the version 2 protocol */
/* Define this if you want GSSAPI
support in the version 2 protocol */
#define GSSAPI 1
/* Define if you want to use shadow password expire field */
/* #undef HAS_SHADOW_EXPIRE */
/* Define if your system uses access rights style file descriptor passing */
/* Define if your system uses access rights style
file descriptor passing */
/* #undef HAVE_ACCRIGHTS_IN_MSGHDR */
/* Define if you have ut_addr in utmp.h */
@ -234,7 +247,8 @@
/* Define if gai_strerror() returns const char * */
/* #undef HAVE_CONST_GAI_STRERROR_PROTO */
/* Define if your system uses ancillary data style file descriptor passing */
/* Define if your system uses ancillary data style
file descriptor passing */
/* #undef HAVE_CONTROL_IN_MSGHDR */
/* Define to 1 if you have the <crypto/sha2.h> header file. */
@ -675,7 +689,8 @@
/* Define to 1 if you have the `ogetaddrinfo' function. */
/* #undef HAVE_OGETADDRINFO */
/* Define if you have an old version of PAM which takes only one argument to
/* Define if you have an old version of PAM
which takes only one argument to
pam_strerror */
/* #undef HAVE_OLD_PAM */
@ -685,11 +700,13 @@
/* Define to 1 if you have the `openpty' function. */
/* #undef HAVE_OPENPTY */
/* Define if your ssl headers are included with #include <openssl/header.h>
/* Define if your ssl headers are included
with #include <openssl/header.h>
*/
#define HAVE_OPENSSL 1
/* Define if you have Digital Unix Security Integration Architecture */
/* Define if you have Digital Unix Security
Integration Architecture */
/* #undef HAVE_OSF_SIA */
/* Define to 1 if you have the `pam_getenvlist' function. */
@ -711,10 +728,10 @@
#define HAVE_PID_T 1
/* Define to 1 if you have the `poll' function. */
#define HAVE_POLL 1
/* #undef HAVE_POLL */
/* Define to 1 if you have the <poll.h> header file. */
/* #undef HAVE_POLL_H */
#define HAVE_POLL_H 1
/* Define to 1 if you have the `prctl' function. */
/* #undef HAVE_PRCTL */
@ -782,7 +799,8 @@
/* define if you have sa_family_t data type */
/* #undef HAVE_SA_FAMILY_T */
/* Define if you have SecureWare-based protected password database */
/* Define if you have SecureWare-based
protected password database */
/* #undef HAVE_SECUREWARE */
/* Define to 1 if you have the <security/pam_appl.h> header file. */
@ -1017,7 +1035,7 @@
/* #undef HAVE_SYS_NERR */
/* Define to 1 if you have the <sys/poll.h> header file. */
#define HAVE_SYS_POLL_H 1
/* #undef HAVE_SYS_POLL_H */
/* Define to 1 if you have the <sys/prctl.h> header file. */
/* #undef HAVE_SYS_PRCTL_H */
@ -1029,7 +1047,7 @@
/* #undef HAVE_SYS_PTMS_H */
/* Define to 1 if you have the <sys/select.h> header file. */
/* #undef HAVE_SYS_SELECT_H */
#define HAVE_SYS_SELECT_H 1
/* Define to 1 if you have the <sys/statvfs.h> header file. */
/* #undef HAVE_SYS_STATVFS_H */
@ -1220,13 +1238,16 @@
/* Define if compiler implements __func__ */
#define HAVE___func__ 1
/* Define this if you are using the Heimdal version of Kerberos V5 */
/* Define this if you are using the Heimdal
version of Kerberos V5 */
/* #undef HEIMDAL */
/* Define if you need to use IP address instead of hostname in $DISPLAY */
/* Define if you need to use IP address
instead of hostname in $DISPLAY */
/* #undef IPADDR_IN_DISPLAY */
/* Detect IPv4 in IPv6 mapped addresses and treat as IPv4 */
/* Detect IPv4 in IPv6 mapped addresses
and treat as IPv4 */
/* #undef IPV4_IN_IPV6 */
/* Define if your system choked on IP TOS setting */
@ -1238,10 +1259,12 @@
/* Define if pututxline updates lastlog too */
/* #undef LASTLOG_WRITE_PUTUTXLINE */
/* Define if you want TCP Wrappers support */
/* Define if you want
TCP Wrappers support */
/* #undef LIBWRAP */
/* Define to whatever link() returns for "not supported" if it doesn't return
/* Define to whatever link() returns for "not supported"
if it doesn't return
EOPNOTSUPP. */
/* #undef LINK_OPNOTSUPP_ERRNO */
@ -1263,7 +1286,8 @@
/* String used in /etc/passwd to denote locked account */
/* #undef LOCKED_PASSWD_SUBSTR */
/* Some versions of /bin/login need the TERM supplied on the commandline */
/* Some versions of /bin/login need the TERM supplied
on the commandline */
/* #undef LOGIN_NEEDS_TERM */
/* Some systems need a utmpx entry for /bin/login to work */
@ -1272,7 +1296,8 @@
/* Define if your login program cannot handle end of options ("--") */
/* #undef LOGIN_NO_ENDOPT */
/* If your header files don't define LOGIN_PROGRAM, then use this (detected)
/* If your header files don't define LOGIN_PROGRAM,
then use this (detected)
from environment and PATH */
#define LOGIN_PROGRAM_FALLBACK "/usr/bin/login"
@ -1291,7 +1316,8 @@
/* Need setpgrp to acquire controlling tty */
/* #undef NEED_SETPGRP */
/* Define if the concept of ports only accessible to superusers isn't known
/* Define if the concept of ports only accessible to
superusers isn't known
*/
#define NO_IPPORT_RESERVED_CONCEPT 1
@ -1331,8 +1357,10 @@
/* Define to the version of this package. */
#define PACKAGE_VERSION "Portable"
/* Define if you are using Solaris-derived PAM which passes pam_messages to
the conversation function with an extra level of indirection */
/* Define if you are using Solaris-derived PAM which
passes pam_messages to
the conversation function
with an extra level of indirection */
/* #undef PAM_SUN_CODEBASE */
/* Work around problematic Linux PAM modules handling of PAM_TTY */
@ -1383,20 +1411,24 @@
/* Define if you want S/Key support */
/* #undef SKEY */
/* Define if your skeychallenge() function takes 4 arguments (NetBSD) */
/* Define if your skeychallenge()
function takes 4 arguments (NetBSD) */
/* #undef SKEYCHALLENGE_4ARG */
/* Define as const if snprintf() can declare const char *fmt */
#define SNPRINTF_CONST const
/* Define to a Set Process Title type if your system is supported by
/* Define to a Set Process Title type if your system is
supported by
bsd-setproctitle.c */
/* #undef SPT_TYPE */
/* Define if sshd somehow reacquires a controlling TTY after setsid() */
/* Define if sshd somehow reacquires a controlling TTY
after setsid() */
/* #undef SSHD_ACQUIRES_CTTY */
/* Define if pam_chauthtok wants real uid set to the unpriv'ed user */
/* Define if pam_chauthtok wants real uid set
to the unpriv'ed user */
/* #undef SSHPAM_CHAUTHTOK_NEEDS_RUID */
/* Use audit debugging module */
@ -1429,7 +1461,8 @@
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define if you want a different $PATH for the superuser */
/* Define if you want a different $PATH
for the superuser */
/* #undef SUPERUSER_PATH */
/* syslog_r function is safe to use in in a signal handler */
@ -1474,13 +1507,15 @@
/* Define if you have Solaris projects */
/* #undef USE_SOLARIS_PROJECTS */
/* Define if you shouldn't strip 'tty' from your ttyname in [uw]tmp */
/* Define if you shouldn't strip 'tty' from your
ttyname in [uw]tmp */
/* #undef WITH_ABBREV_NO_TTY */
/* Define if you want to enable AIX4's authenticate function */
/* #undef WITH_AIXAUTHENTICATE */
/* Define if you have/want arrays (cluster-wide session managment, not C
/* Define if you have/want arrays
(cluster-wide session managment, not C
arrays) */
/* #undef WITH_IRIX_ARRAY */
@ -1580,7 +1615,6 @@
#define HAVE_MKDTEMP 1
#define HAVE_NANOSLEEP 1
#undef HAVE_PATHS_H
#undef HAVE_POLL_H
#undef HAVE_PROC_PID
#undef HAVE_PTY_H
#define HAVE_NANOSLEEP 1
@ -1650,7 +1684,7 @@
typedef unsigned long pid_t;
#ifndef ssize_t
#ifdef _WIN64
#ifdef _WIN64
typedef __int64 ssize_t;
#else
typedef long ssize_t;
@ -1663,8 +1697,8 @@ typedef long ssize_t;
#define HAVE_STRTOULL 1
#undef HAVE_USLEEP
#if defined ( WIN32 )
#define __func__ __FUNCTION__
#if defined ( WIN32 )
#define __func__ __FUNCTION__
#endif
#define PATH_MAX MAX_PATH
@ -1684,30 +1718,16 @@ typedef long ssize_t;
#define WIN32_ZLIB_NO 1
#ifdef WIN32
typedef unsigned short _mode_t;
typedef _mode_t mode_t;
#endif
#include <signal.h>
#include <io.h>
#include <signal.h>
#include <io.h>
struct iovec
{
void *iov_base;
size_t iov_len;
};
#define __attribute__(A)
// define building with MS Visual Studio Compiler and runtime and not with MingW/gcc compiler
#define WIN32_VS 1
#define __STDC__ 1
#define WIN32_VS 1
/* disable inclusion of compatability defitnitions in CRT headers */
#define __STDC__ 1
// Use Pragma Systems Remote Console modules for shell sessions so that cmd/powershell fully
// works remotely over SSH like they operate in a local machine
//#define WIN32_PRAGMA_REMCON

View File

@ -152,13 +152,13 @@
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\defs.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\fcntl.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\signal.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\sys\poll.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\sys\select.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\sys\socket.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\sys\stat.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\sys\time.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\unistd.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\w32posix.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\poll.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">

View File

@ -9,9 +9,6 @@
</ItemGroup>
<ItemGroup>
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\w32fd.h" />
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\sys\poll.h">
<Filter>inc\sys</Filter>
</ClInclude>
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\sys\select.h">
<Filter>inc\sys</Filter>
</ClInclude>
@ -39,6 +36,9 @@
<ClInclude Include="$(OpenSSH-Src-Path)\contrib\win32\win32compat\inc\w32posix.h">
<Filter>inc</Filter>
</ClInclude>
<ClInclude Include="..\win32compat\inc\poll.h">
<Filter>inc</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="inc">

View File

@ -0,0 +1,7 @@
#pragma once
#include "w32posix.h"
/* created to #def out decarations in open-bsd.h (that are defined in winsock2.h) */
int poll(struct pollfd *, nfds_t, int);

View File

@ -1,3 +0,0 @@
#include "..\w32posix.h"
#define poll(a,b,c) w32_poll((a), (b), (c))

View File

@ -57,7 +57,6 @@ int w32_mkdir(const char *pathname, unsigned short mode);
int w32_close(int fd);
int w32_select(int fds, w32_fd_set* readfds, w32_fd_set* writefds, w32_fd_set* exceptfds,
const struct timeval *timeout);
int w32_poll(struct pollfd *fds, unsigned int nfds, int timeout);
int w32_fcntl(int fd, int cmd, ... /* arg */);
int w32_dup(int oldfd);
int w32_dup2(int oldfd, int newfd);
@ -117,4 +116,27 @@ int sw_add_child(HANDLE child);
#define allocate_sfd(a, b) w32_allocate_fd_for_handle((a, b))
//#define WSHELPwopen(a, b) w32_open((a, b))
/* TODO - These defs need to revisited and positioned appropriately */
#define environ _environ
typedef unsigned int nfds_t;
struct w32_pollfd {
int fd;
SHORT events;
SHORT revents;
};
#define pollfd w32_pollfd
struct iovec
{
void *iov_base;
size_t iov_len;
};
typedef unsigned short _mode_t;
typedef _mode_t mode_t;

View File

@ -182,6 +182,7 @@ sw_init_timer() {
errno = ENOMEM;
return -1;
}
return 0;
}
sighandler_t
@ -313,10 +314,13 @@ wait_for_any_event(HANDLE* events, int num_events, DWORD milli_seconds)
if ((ret >= WAIT_OBJECT_0) && (ret <= WAIT_OBJECT_0 + num_all_events - 1)) {
//woken up by event signalled
/* is this due to a child process going down*/
if (children.num_children && ((ret - WAIT_OBJECT_0) < children.num_children))
sigaddset(&pending_signals, W32_SIGCHLD);
if (children.num_children && ((ret - WAIT_OBJECT_0) < children.num_children)) {
//sigaddset(&pending_signals, W32_SIGCHLD);
/* TODO - enable this once all direct closes are removed in core code*/
//sw_remove_child(ret - WAIT_OBJECT_0);
errno = EINTR;
return -1;
}
}
else if (ret == WAIT_IO_COMPLETION) {
/* APC processed due to IO or signal*/
@ -349,10 +353,10 @@ wait_for_any_event(HANDLE* events, int num_events, DWORD milli_seconds)
}
if (pending_signals) {
/*if (pending_signals) {
return sw_process_pending_signals();
}
return;
}*/
return 0;
}

View File

@ -696,87 +696,6 @@ w32_select(int fds, w32_fd_set* readfds, w32_fd_set* writefds, w32_fd_set* excep
}
/* TODO - consolidate these defs from defines.h*/
# define NFDBITS (8 * sizeof(unsigned long))
typedef unsigned long int fd_mask;
# define howmany(x,y) (((x)+((y)-1))/(y))
int
w32_poll(struct pollfd *fds, unsigned int nfds, int timeout) {
unsigned int i;
int saved_errno, ret, fd, maxfd = 0;
w32_fd_set *readfds = NULL, *writefds = NULL, *exceptfds = NULL;
size_t nmemb;
struct timeval tv, *tvp = NULL;
for (i = 0; i < nfds; i++) {
fd = fds[i].fd;
if (fd >= MAX_FDS) {
errno = EINVAL;
return -1;
}
maxfd = max(maxfd, fd);
}
nmemb = howmany(maxfd + 1, NFDBITS);
if ((readfds = calloc(nmemb, sizeof(fd_mask))) == NULL ||
(writefds = calloc(nmemb, sizeof(fd_mask))) == NULL ||
(exceptfds = calloc(nmemb, sizeof(fd_mask))) == NULL) {
saved_errno = ENOMEM;
ret = -1;
goto out;
}
/* populate event bit vectors for the events we're interested in */
for (i = 0; i < nfds; i++) {
fd = fds[i].fd;
if (fd == -1)
continue;
if (fds[i].events & POLLIN) {
FD_SET(fd, readfds);
FD_SET(fd, exceptfds);
}
if (fds[i].events & POLLOUT) {
FD_SET(fd, writefds);
FD_SET(fd, exceptfds);
}
}
/* poll timeout is msec, select is timeval (sec + usec) */
if (timeout >= 0) {
tv.tv_sec = timeout / 1000;
tv.tv_usec = (timeout % 1000) * 1000;
tvp = &tv;
}
ret = select(maxfd + 1, readfds, writefds, exceptfds, tvp);
saved_errno = errno;
/* scan through select results and set poll() flags */
for (i = 0; i < nfds; i++) {
fd = fds[i].fd;
fds[i].revents = 0;
if (fd == -1)
continue;
if (FD_ISSET(fd, readfds)) {
fds[i].revents |= POLLIN;
}
if (FD_ISSET(fd, writefds)) {
fds[i].revents |= POLLOUT;
}
if (FD_ISSET(fd, exceptfds)) {
fds[i].revents |= POLLERR;
}
}
out:
free(readfds);
free(writefds);
free(exceptfds);
if (ret == -1)
errno = saved_errno;
return ret;
}
int
w32_dup(int oldfd) {
int min_index;

View File

@ -22,12 +22,6 @@
#define _GNU_SOURCE /* activate extra prototypes for glibc */
#endif
#ifdef WIN32
#undef __USE_W32_SOCKETS
//#include <winsock2.h>
#include <sys/compat-types.h>
#endif
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h> /* For CMSG_* */
@ -127,13 +121,9 @@
#if defined(HAVE_SECURITY_PAM_APPL_H)
# include <security/pam_appl.h>
#elif defined (HAVE_PAM_PAM_APPL_H)
#ifdef WIN32_FIXME
# include <security/pam_appl.h>
#else
# include <pam/pam_appl.h>
#endif
#endif
#endif
#ifdef HAVE_READPASSPHRASE_H
# include <readpassphrase.h>
#endif
@ -189,10 +179,4 @@
#include "entropy.h"
//#ifdef WIN32_FIXME
// #define signal(X, Y)
// #define alarm(X)
// #define mysignal(X, Y)
//#endif
#endif /* INCLUDES_H */