summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2000-09-24 11:10:13 +1100
committerDamien Miller <djm@mindrot.org>2000-09-24 11:10:13 +1100
commit72c9a7e958689740cb3449df5732e0956d52ef5b (patch)
tree70f861946c4e7750bd04cdd57fd7952da1c889fe
parent62cee00753ef8ce31b322ce6a14318cb974e883d (diff)
- (djm) Merged cleanup patch from Mark Miller <markm@swoon.net>
- (djm) A bit more cleanup - created cygwin_util.h
-rw-r--r--ChangeLog4
-rw-r--r--bsd-arc4random.c5
-rw-r--r--configure.in2
-rw-r--r--cygwin_util.c38
-rw-r--r--cygwin_util.h28
-rw-r--r--defines.h16
-rw-r--r--includes.h34
-rw-r--r--next-posix.h20
8 files changed, 87 insertions, 60 deletions
diff --git a/ChangeLog b/ChangeLog
index b6f22341..0290869b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
diff --git a/bsd-arc4random.c b/bsd-arc4random.c
index fb378d84..ea0abf3f 100644
--- a/bsd-arc4random.c
+++ b/bsd-arc4random.c
@@ -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
diff --git a/configure.in b/configure.in
index 305d9a49..398ab8c1 100644
--- a/configure.in
+++ b/configure.in
@@ -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)
diff --git a/cygwin_util.c b/cygwin_util.c
index 88748c4f..b540ebe1 100644
--- a/cygwin_util.c
+++ b/cygwin_util.c
@@ -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 */
diff --git a/cygwin_util.h b/cygwin_util.h
new file mode 100644
index 00000000..efd28bfc
--- /dev/null
+++ b/cygwin_util.h
@@ -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 */
diff --git a/defines.h b/defines.h
index b3404596..837ed020 100644
--- a/defines.h
+++ b/defines.h
@@ -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
**/
diff --git a/includes.h b/includes.h
index da08722e..b7b01374 100644
--- a/includes.h
+++ b/includes.h
@@ -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 */
diff --git a/next-posix.h b/next-posix.h
index 077b132e..fc06e41b 100644
--- a/next-posix.h
+++ b/next-posix.h
@@ -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 */