- (djm) Merged cleanup patch from Mark Miller <markm@swoon.net>

- (djm) A bit more cleanup - created cygwin_util.h
This commit is contained in:
Damien Miller 2000-09-24 11:10:13 +11:00
parent 62cee00753
commit 72c9a7e958
8 changed files with 87 additions and 60 deletions

View File

@ -1,3 +1,7 @@
20000924
- (djm) Merged cleanup patch from Mark Miller <markm@swoon.net>
- (djm) A bit more cleanup - created cygwin_util.h
20000923
- (djm) Fix address logging in utmp from Kevin Steves
<stevesk@sweden.hp.com>

View File

@ -23,11 +23,12 @@
*/
#include "includes.h"
#include <openssl/rand.h>
#include <openssl/rc4.h>
#ifndef HAVE_ARC4RANDOM
#include <openssl/rand.h>
#include <openssl/rc4.h>
/* Size of key to use */
#define SEED_SIZE 20

View File

@ -230,7 +230,7 @@ if test -z "$no_libnsl" ; then
fi
# Checks for header files.
AC_CHECK_HEADERS(bstring.h endian.h floatingpoint.h lastlog.h limits.h login.h login_cap.h maillock.h netdb.h netgroup.h netinet/in_systm.h paths.h poll.h pty.h shadow.h security/pam_appl.h sys/bitypes.h sys/bsdtty.h sys/cdefs.h sys/poll.h sys/select.h sys/stat.h sys/stropts.h sys/sysmacros.h sys/time.h sys/ttcompat.h stddef.h time.h ttyent.h usersec.h util.h utmp.h utmpx.h)
AC_CHECK_HEADERS(bstring.h endian.h floatingpoint.h getopt.h lastlog.h limits.h login.h login_cap.h maillock.h netdb.h netgroup.h netinet/in_systm.h paths.h poll.h pty.h shadow.h security/pam_appl.h sys/bitypes.h sys/bsdtty.h sys/cdefs.h sys/poll.h sys/select.h sys/stat.h sys/stropts.h sys/sysmacros.h sys/time.h sys/ttcompat.h stddef.h time.h ttyent.h usersec.h util.h utmp.h utmpx.h)
dnl Checks for library functions.
AC_CHECK_FUNCS(arc4random atexit b64_ntop bcopy bindresvport_af clock freeaddrinfo futimes gai_strerror getaddrinfo getnameinfo getrusage getttyent inet_aton inet_ntoa innetgr login_getcapbool md5_crypt memmove mkdtemp on_exit openpty rresvport_af setenv seteuid setlogin setproctitle setreuid sigaction sigvec snprintf strerror strlcat strlcpy strsep vsnprintf vhangup _getpty __b64_ntop)

View File

@ -16,6 +16,7 @@
#include "config.h"
#ifdef HAVE_CYGWIN
#include <fcntl.h>
#include <io.h>
#include <stdlib.h>
@ -25,35 +26,37 @@
int binary_open(const char *filename, int flags, mode_t mode)
{
return open(filename, flags | O_BINARY, mode);
return open(filename, flags | O_BINARY, mode);
}
int binary_pipe(int fd[2])
{
int ret = pipe(fd);
if (!ret) {
setmode (fd[0], O_BINARY);
setmode (fd[1], O_BINARY);
}
return ret;
int ret = pipe(fd);
if (!ret) {
setmode (fd[0], O_BINARY);
setmode (fd[1], O_BINARY);
}
return ret;
}
int check_nt_auth (int pwd_authenticated, uid_t uid)
int check_nt_auth(int pwd_authenticated, uid_t uid)
{
/*
* The only authentication which is able to change the user
* context on NT systems is the password authentication. So
* we deny all requsts for changing the user context if another
* authentication method is used.
* This may change in future when a special openssh
* subauthentication package is available.
*/
* The only authentication which is able to change the user
* context on NT systems is the password authentication. So
* we deny all requsts for changing the user context if another
* authentication method is used.
* This may change in future when a special openssh
* subauthentication package is available.
*/
if (is_winnt && !pwd_authenticated && geteuid() != uid)
return 0;
return 1;
}
int check_ntsec (const char *filename)
int check_ntsec(const char *filename)
{
char *cygwin;
int allow_ntea = 0;
@ -98,4 +101,5 @@ int check_ntsec (const char *filename)
return 0;
}
#endif
#endif /* HAVE_CYGWIN */

28
cygwin_util.h Normal file
View File

@ -0,0 +1,28 @@
/*
*
* cygwin_util.c
*
* Author: Corinna Vinschen <vinschen@cygnus.com>
*
* Copyright (c) 2000 Corinna Vinschen <vinschen@cygnus.com>, Duisburg, Germany
* All rights reserved
*
* Created: Sat Sep 02 12:17:00 2000 cv
*
* This file contains functions for forcing opened file descriptors to
* binary mode on Windows systems.
*/
#include "config.h"
#ifdef HAVE_CYGWIN
int binary_open(const char *filename, int flags, mode_t mode);
int binary_pipe(int fd[2]);
int check_nt_auth(int pwd_authenticated, uid_t uid);
int check_ntsec(const char *filename);
#define open binary_open
#define pipe binary_pipe
#endif /* HAVE_CYGWIN */

View File

@ -250,6 +250,8 @@ typedef int mode_t;
#ifndef _PATH_RSH
# ifdef RSH_PATH
# define _PATH_RSH RSH_PATH
# else /* RSH_PATH */
# define _PATH_RSH "/usr/bin/rsh"
# endif /* RSH_PATH */
#endif /* _PATH_RSH */
@ -257,6 +259,11 @@ typedef int mode_t;
# define _PATH_NOLOGIN "/etc/nologin"
#endif
/* Define this to be the path of the xauth program. */
#ifndef XAUTH_PATH
#define XAUTH_PATH "/usr/X11R6/bin/xauth"
#endif /* XAUTH_PATH */
/* Macros */
#if defined(HAVE_LOGIN_GETCAPBOOL) && defined(HAVE_LOGIN_CAP_H)
@ -332,6 +339,15 @@ typedef int mode_t;
# define getpgrp() getpgrp(0)
#endif
/*
* Define this to use pipes instead of socketpairs for communicating with the
* client program. Socketpairs do not seem to work on all systems.
*
* configure.in sets this for a few OS's which are known to have problems
* but you may need to set it yourself
*/
/* #define USE_PIPES 1 */
/**
** login recorder definitions
**/

View File

@ -46,10 +46,10 @@ static /**/const char *const rcsid[] = { (char *)rcsid, "\100(#)" msg }
#include <grp.h>
#include <time.h>
#include <dirent.h>
#ifdef HAVE_CYGWIN
#ifdef HAVE_GETOPT_H
#include <getopt.h>
#endif
#ifdef HAVE_BSTRING_H
# include <bstring.h>
#endif
@ -90,34 +90,8 @@ static /**/const char *const rcsid[] = { (char *)rcsid, "\100(#)" msg }
#endif
#include "version.h"
/* OpenBSD function replacements */
#include "openbsd-compat.h"
/* Entropy collection */
#include "cygwin_util.h"
#include "entropy.h"
/* Define this to be the path of the xauth program. */
#ifndef XAUTH_PATH
#define XAUTH_PATH "/usr/X11R6/bin/xauth"
#endif /* XAUTH_PATH */
/* Define this to be the path of the rsh program. */
#ifndef _PATH_RSH
#define _PATH_RSH "/usr/bin/rsh"
#endif /* _PATH_RSH */
/*
* Define this to use pipes instead of socketpairs for communicating with the
* client program. Socketpairs do not seem to work on all systems.
*/
/* #define USE_PIPES 1 */
#ifdef HAVE_CYGWIN
#define open binary_open
#define pipe binary_pipe
extern int binary_open();
extern int binary_pipe();
#endif
#endif /* INCLUDES_H */
#endif /* INCLUDES_H */

View File

@ -10,7 +10,7 @@
#include <sys/dir.h>
/* readdir() returns struct direct (BSD) not struct dirent (POSIX) */
#define dirent direct
#define dirent direct
/* POSIX utime() struct */
struct utimbuf {
@ -19,7 +19,7 @@ struct utimbuf {
};
/* FILE */
#define O_NONBLOCK 00004 /* non-blocking open */
#define O_NONBLOCK 00004 /* non-blocking open */
/* WAITPID */
#undef WIFEXITED
@ -29,8 +29,8 @@ struct utimbuf {
#define WIFEXITED(w) (!((w) & 0377))
#define WIFSTOPPED(w) ((w) & 0100)
#define WIFSIGNALED(w) (!WIFEXITED(w) && !WIFSTOPPED(w))
#define WEXITSTATUS(w) (int)(WIFEXITED(w) ? ((w >> 8) & 0377) : -1)
#define WTERMSIG(w) (int)(WIFSIGNALED(w) ? (w & 0177) : -1)
#define WEXITSTATUS(w) (int)(WIFEXITED(w) ? (((w) >> 8) & 0377) : -1)
#define WTERMSIG(w) (int)(WIFSIGNALED(w) ? ((w) & 0177) : -1)
#define WCOREFLAG 0x80
#define WCOREDUMP(w) ((w) & WCOREFLAG)
@ -42,17 +42,17 @@ pid_t posix_wait(int *status); /* new wait() */
#define wait posix_wait
/* MISC functions */
int waitpid(int pid,int *stat_loc,int options);
int waitpid(int pid, int *stat_loc, int options);
pid_t setsid(void);
/* TC */
int tcgetattr(int fd,struct termios *t);
int tcsetattr(int fd,int opt,const struct termios *t);
/* TERMCAP */
int tcgetattr(int fd, struct termios *t);
int tcsetattr(int fd, int opt, const struct termios *t);
int tcsetpgrp(int fd, pid_t pgrp);
speed_t cfgetospeed(const struct termios *t);
speed_t cfgetispeed(const struct termios *t);
int cfsetospeed(struct termios *t,int speed);
int cfsetospeed(struct termios *t, int speed);
#endif /* HAVE_NEXT */
#endif /* _NEXT_POSIX_H */