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 b6f22341d..0290869b9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
120000924
2 - (djm) Merged cleanup patch from Mark Miller <markm@swoon.net>
3 - (djm) A bit more cleanup - created cygwin_util.h
4
120000923 520000923
2 - (djm) Fix address logging in utmp from Kevin Steves 6 - (djm) Fix address logging in utmp from Kevin Steves
3 <stevesk@sweden.hp.com> 7 <stevesk@sweden.hp.com>
diff --git a/bsd-arc4random.c b/bsd-arc4random.c
index fb378d848..ea0abf3f4 100644
--- a/bsd-arc4random.c
+++ b/bsd-arc4random.c
@@ -23,11 +23,12 @@
23 */ 23 */
24 24
25#include "includes.h" 25#include "includes.h"
26#include <openssl/rand.h>
27#include <openssl/rc4.h>
28 26
29#ifndef HAVE_ARC4RANDOM 27#ifndef HAVE_ARC4RANDOM
30 28
29#include <openssl/rand.h>
30#include <openssl/rc4.h>
31
31/* Size of key to use */ 32/* Size of key to use */
32#define SEED_SIZE 20 33#define SEED_SIZE 20
33 34
diff --git a/configure.in b/configure.in
index 305d9a493..398ab8c1b 100644
--- a/configure.in
+++ b/configure.in
@@ -230,7 +230,7 @@ if test -z "$no_libnsl" ; then
230fi 230fi
231 231
232# Checks for header files. 232# Checks for header files.
233AC_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) 233AC_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)
234 234
235dnl Checks for library functions. 235dnl Checks for library functions.
236AC_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) 236AC_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 88748c4fb..b540ebe1a 100644
--- a/cygwin_util.c
+++ b/cygwin_util.c
@@ -16,6 +16,7 @@
16#include "config.h" 16#include "config.h"
17 17
18#ifdef HAVE_CYGWIN 18#ifdef HAVE_CYGWIN
19
19#include <fcntl.h> 20#include <fcntl.h>
20#include <io.h> 21#include <io.h>
21#include <stdlib.h> 22#include <stdlib.h>
@@ -25,35 +26,37 @@
25 26
26int binary_open(const char *filename, int flags, mode_t mode) 27int binary_open(const char *filename, int flags, mode_t mode)
27{ 28{
28 return open(filename, flags | O_BINARY, mode); 29 return open(filename, flags | O_BINARY, mode);
29} 30}
30 31
31int binary_pipe(int fd[2]) 32int binary_pipe(int fd[2])
32{ 33{
33 int ret = pipe(fd); 34 int ret = pipe(fd);
34 if (!ret) { 35
35 setmode (fd[0], O_BINARY); 36 if (!ret) {
36 setmode (fd[1], O_BINARY); 37 setmode (fd[0], O_BINARY);
37 } 38 setmode (fd[1], O_BINARY);
38 return ret; 39 }
40 return ret;
39} 41}
40 42
41int check_nt_auth (int pwd_authenticated, uid_t uid) 43int check_nt_auth(int pwd_authenticated, uid_t uid)
42{ 44{
43 /* 45 /*
44 * The only authentication which is able to change the user 46 * The only authentication which is able to change the user
45 * context on NT systems is the password authentication. So 47 * context on NT systems is the password authentication. So
46 * we deny all requsts for changing the user context if another 48 * we deny all requsts for changing the user context if another
47 * authentication method is used. 49 * authentication method is used.
48 * This may change in future when a special openssh 50 * This may change in future when a special openssh
49 * subauthentication package is available. 51 * subauthentication package is available.
50 */ 52 */
51 if (is_winnt && !pwd_authenticated && geteuid() != uid) 53 if (is_winnt && !pwd_authenticated && geteuid() != uid)
52 return 0; 54 return 0;
55
53 return 1; 56 return 1;
54} 57}
55 58
56int check_ntsec (const char *filename) 59int check_ntsec(const char *filename)
57{ 60{
58 char *cygwin; 61 char *cygwin;
59 int allow_ntea = 0; 62 int allow_ntea = 0;
@@ -98,4 +101,5 @@ int check_ntsec (const char *filename)
98 101
99 return 0; 102 return 0;
100} 103}
101#endif 104
105#endif /* HAVE_CYGWIN */
diff --git a/cygwin_util.h b/cygwin_util.h
new file mode 100644
index 000000000..efd28bfc9
--- /dev/null
+++ b/cygwin_util.h
@@ -0,0 +1,28 @@
1/*
2 *
3 * cygwin_util.c
4 *
5 * Author: Corinna Vinschen <vinschen@cygnus.com>
6 *
7 * Copyright (c) 2000 Corinna Vinschen <vinschen@cygnus.com>, Duisburg, Germany
8 * All rights reserved
9 *
10 * Created: Sat Sep 02 12:17:00 2000 cv
11 *
12 * This file contains functions for forcing opened file descriptors to
13 * binary mode on Windows systems.
14 */
15
16#include "config.h"
17
18#ifdef HAVE_CYGWIN
19
20int binary_open(const char *filename, int flags, mode_t mode);
21int binary_pipe(int fd[2]);
22int check_nt_auth(int pwd_authenticated, uid_t uid);
23int check_ntsec(const char *filename);
24
25#define open binary_open
26#define pipe binary_pipe
27
28#endif /* HAVE_CYGWIN */
diff --git a/defines.h b/defines.h
index b34045963..837ed0207 100644
--- a/defines.h
+++ b/defines.h
@@ -250,6 +250,8 @@ typedef int mode_t;
250#ifndef _PATH_RSH 250#ifndef _PATH_RSH
251# ifdef RSH_PATH 251# ifdef RSH_PATH
252# define _PATH_RSH RSH_PATH 252# define _PATH_RSH RSH_PATH
253# else /* RSH_PATH */
254# define _PATH_RSH "/usr/bin/rsh"
253# endif /* RSH_PATH */ 255# endif /* RSH_PATH */
254#endif /* _PATH_RSH */ 256#endif /* _PATH_RSH */
255 257
@@ -257,6 +259,11 @@ typedef int mode_t;
257# define _PATH_NOLOGIN "/etc/nologin" 259# define _PATH_NOLOGIN "/etc/nologin"
258#endif 260#endif
259 261
262/* Define this to be the path of the xauth program. */
263#ifndef XAUTH_PATH
264#define XAUTH_PATH "/usr/X11R6/bin/xauth"
265#endif /* XAUTH_PATH */
266
260/* Macros */ 267/* Macros */
261 268
262#if defined(HAVE_LOGIN_GETCAPBOOL) && defined(HAVE_LOGIN_CAP_H) 269#if defined(HAVE_LOGIN_GETCAPBOOL) && defined(HAVE_LOGIN_CAP_H)
@@ -332,6 +339,15 @@ typedef int mode_t;
332# define getpgrp() getpgrp(0) 339# define getpgrp() getpgrp(0)
333#endif 340#endif
334 341
342/*
343 * Define this to use pipes instead of socketpairs for communicating with the
344 * client program. Socketpairs do not seem to work on all systems.
345 *
346 * configure.in sets this for a few OS's which are known to have problems
347 * but you may need to set it yourself
348 */
349/* #define USE_PIPES 1 */
350
335/** 351/**
336 ** login recorder definitions 352 ** login recorder definitions
337 **/ 353 **/
diff --git a/includes.h b/includes.h
index da08722ec..b7b013745 100644
--- a/includes.h
+++ b/includes.h
@@ -46,10 +46,10 @@ static /**/const char *const rcsid[] = { (char *)rcsid, "\100(#)" msg }
46#include <grp.h> 46#include <grp.h>
47#include <time.h> 47#include <time.h>
48#include <dirent.h> 48#include <dirent.h>
49#ifdef HAVE_CYGWIN 49
50#ifdef HAVE_GETOPT_H
50#include <getopt.h> 51#include <getopt.h>
51#endif 52#endif
52
53#ifdef HAVE_BSTRING_H 53#ifdef HAVE_BSTRING_H
54# include <bstring.h> 54# include <bstring.h>
55#endif 55#endif
@@ -90,34 +90,8 @@ static /**/const char *const rcsid[] = { (char *)rcsid, "\100(#)" msg }
90#endif 90#endif
91 91
92#include "version.h" 92#include "version.h"
93
94/* OpenBSD function replacements */
95#include "openbsd-compat.h" 93#include "openbsd-compat.h"
96 94#include "cygwin_util.h"
97/* Entropy collection */
98#include "entropy.h" 95#include "entropy.h"
99 96
100/* Define this to be the path of the xauth program. */ 97#endif /* INCLUDES_H */
101#ifndef XAUTH_PATH
102#define XAUTH_PATH "/usr/X11R6/bin/xauth"
103#endif /* XAUTH_PATH */
104
105/* Define this to be the path of the rsh program. */
106#ifndef _PATH_RSH
107#define _PATH_RSH "/usr/bin/rsh"
108#endif /* _PATH_RSH */
109
110/*
111 * Define this to use pipes instead of socketpairs for communicating with the
112 * client program. Socketpairs do not seem to work on all systems.
113 */
114/* #define USE_PIPES 1 */
115
116#ifdef HAVE_CYGWIN
117#define open binary_open
118#define pipe binary_pipe
119extern int binary_open();
120extern int binary_pipe();
121#endif
122
123#endif /* INCLUDES_H */
diff --git a/next-posix.h b/next-posix.h
index 077b132e4..fc06e41bc 100644
--- a/next-posix.h
+++ b/next-posix.h
@@ -10,7 +10,7 @@
10#include <sys/dir.h> 10#include <sys/dir.h>
11 11
12/* readdir() returns struct direct (BSD) not struct dirent (POSIX) */ 12/* readdir() returns struct direct (BSD) not struct dirent (POSIX) */
13#define dirent direct 13#define dirent direct
14 14
15/* POSIX utime() struct */ 15/* POSIX utime() struct */
16struct utimbuf { 16struct utimbuf {
@@ -19,7 +19,7 @@ struct utimbuf {
19}; 19};
20 20
21/* FILE */ 21/* FILE */
22#define O_NONBLOCK 00004 /* non-blocking open */ 22#define O_NONBLOCK 00004 /* non-blocking open */
23 23
24/* WAITPID */ 24/* WAITPID */
25#undef WIFEXITED 25#undef WIFEXITED
@@ -29,8 +29,8 @@ struct utimbuf {
29#define WIFEXITED(w) (!((w) & 0377)) 29#define WIFEXITED(w) (!((w) & 0377))
30#define WIFSTOPPED(w) ((w) & 0100) 30#define WIFSTOPPED(w) ((w) & 0100)
31#define WIFSIGNALED(w) (!WIFEXITED(w) && !WIFSTOPPED(w)) 31#define WIFSIGNALED(w) (!WIFEXITED(w) && !WIFSTOPPED(w))
32#define WEXITSTATUS(w) (int)(WIFEXITED(w) ? ((w >> 8) & 0377) : -1) 32#define WEXITSTATUS(w) (int)(WIFEXITED(w) ? (((w) >> 8) & 0377) : -1)
33#define WTERMSIG(w) (int)(WIFSIGNALED(w) ? (w & 0177) : -1) 33#define WTERMSIG(w) (int)(WIFSIGNALED(w) ? ((w) & 0177) : -1)
34#define WCOREFLAG 0x80 34#define WCOREFLAG 0x80
35#define WCOREDUMP(w) ((w) & WCOREFLAG) 35#define WCOREDUMP(w) ((w) & WCOREFLAG)
36 36
@@ -42,17 +42,17 @@ pid_t posix_wait(int *status); /* new wait() */
42#define wait posix_wait 42#define wait posix_wait
43 43
44/* MISC functions */ 44/* MISC functions */
45int waitpid(int pid,int *stat_loc,int options); 45int waitpid(int pid, int *stat_loc, int options);
46pid_t setsid(void); 46pid_t setsid(void);
47 47
48/* TC */ 48/* TERMCAP */
49int tcgetattr(int fd,struct termios *t); 49int tcgetattr(int fd, struct termios *t);
50int tcsetattr(int fd,int opt,const struct termios *t); 50int tcsetattr(int fd, int opt, const struct termios *t);
51int tcsetpgrp(int fd, pid_t pgrp); 51int tcsetpgrp(int fd, pid_t pgrp);
52speed_t cfgetospeed(const struct termios *t); 52speed_t cfgetospeed(const struct termios *t);
53speed_t cfgetispeed(const struct termios *t); 53speed_t cfgetispeed(const struct termios *t);
54int cfsetospeed(struct termios *t,int speed); 54int cfsetospeed(struct termios *t, int speed);
55
56 55
57#endif /* HAVE_NEXT */ 56#endif /* HAVE_NEXT */
57
58#endif /* _NEXT_POSIX_H */ 58#endif /* _NEXT_POSIX_H */