]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
- Renamed BSD helper function files to bsd-*
authorDamien Miller <djm@mindrot.org>
Fri, 19 Nov 1999 04:32:34 +0000 (15:32 +1100)
committerDamien Miller <djm@mindrot.org>
Fri, 19 Nov 1999 04:32:34 +0000 (15:32 +1100)
 - Added tests for login and daemon and OpenBSD replacements for when they
   are absent.

14 files changed:
ChangeLog
Makefile.in
README
acconfig.h
bsd-daemon.c [new file with mode: 0644]
bsd-daemon.h [new file with mode: 0644]
bsd-login.c [new file with mode: 0644]
bsd-login.h [new file with mode: 0644]
bsd-mktemp.c [moved from mktemp.c with 99% similarity]
bsd-mktemp.h [moved from mktemp.h with 68% similarity]
bsd-strlcpy.c [moved from strlcpy.c with 100% similarity]
bsd-strlcpy.h [moved from strlcpy.h with 56% similarity]
configure.in
includes.h

index 6b02ba1a8e6df1f546a9a463e51c897f0d95f3ad..b92f9bfafded09f19f1eb919916b4dfbc39f4521 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -14,6 +14,9 @@
  - Added autoconf option to enable AFS support (untested)
  - Added autoconf option to enable S/Key support (untested)
  - Added autoconf option to enable TCP wrappers support (compiles OK)
+ - Renamed BSD helper function files to bsd-*
+ - Added tests for login and daemon and OpenBSD replacements for when they
+   are absent.
 
 19991118
  - Merged OpenBSD CVS changes
index 4daa810ec146dc6dc0a954450ef6fecca7988a25..fec1d1301b00665698b88350ea78ac114a0e74fc 100644 (file)
@@ -27,18 +27,18 @@ OBJS=       authfd.o authfile.o auth-passwd.o auth-rhosts.o auth-rh-rsa.o \
                hostfile.o log-client.o login.o log-server.o match.o mpaux.o \
                packet.o pty.o readconf.o readpass.o rsa.o servconf.o serverloop.o \
                sshconnect.o tildexpand.o ttymodes.o uidswap.o xmalloc.o \
-               helper.o mktemp.o strlcpy.o rc4.o
+               helper.o bsd-mktemp.o bsd-strlcpy.o bsd-daemon.o bsd-login.o rc4.o
 
 all: $(OBJS) $(TARGETS)
 
-libssh.a: authfd.o authfile.o bufaux.o buffer.o canohost.o channels.o cipher.o compat.o compress.o crc32.o deattack.o hostfile.o match.o mpaux.o nchan.o packet.o readpass.o rsa.o tildexpand.o ttymodes.o uidswap.o xmalloc.o helper.o rc4.o mktemp.o strlcpy.o log.o fingerprint.o
+libssh.a: authfd.o authfile.o bufaux.o buffer.o canohost.o channels.o cipher.o compat.o compress.o crc32.o deattack.o hostfile.o match.o mpaux.o nchan.o packet.o readpass.o rsa.o tildexpand.o ttymodes.o uidswap.o xmalloc.o helper.o rc4.o bsd-mktemp.o bsd-strlcpy.o log.o fingerprint.o
        $(AR) rv $@ $^
        $(RANLIB) $@
 
 ssh: ssh.o sshconnect.o log-client.o readconf.o clientloop.o libssh.a
        $(CC) -o $@ $^ $(LFLAGS) $(LIBS) 
 
-sshd:  sshd.o auth-rhosts.o auth-passwd.o auth-rsa.o auth-rh-rsa.o pty.o log-server.o login.o servconf.o serverloop.o libssh.a
+sshd:  sshd.o auth-rhosts.o auth-passwd.o auth-rsa.o auth-rh-rsa.o pty.o log-server.o login.o servconf.o serverloop.o bsd-login.o bsd-daemon.o libssh.a
        $(CC) -o $@ $^ $(LFLAGS) $(LIBS) 
 
 scp:   scp.o libssh.a
diff --git a/README b/README
index c9427da27df4c51e21193483909fb06e4f0cad16..f6dbcdd523123d2a197c7b318fc9ee56eb3fd01c 100644 (file)
--- a/README
+++ b/README
@@ -10,9 +10,9 @@ Niels Provos, Theo de Raadt, and Dug Song. It has a homepage at
 http://www.openssh.com/
 
 This port consists of the re-introduction of autoconf support, PAM
-support (for Linux and Solaris), EGD[1] support, and replacements for
-OpenBSD library functions that are (regrettably) absent from most
-other unices. This patch has been best tested on Linux, though some 
+support (for Linux and Solaris), EGD[1] support, and replacements
+for OpenBSD library functions that are (regrettably) absent from
+other unices. This port has been best tested on Linux, though some
 Solaris support is beginning to filter in. This version actively
 tracks changes in the OpenBSD CVS repository.
 
@@ -22,8 +22,8 @@ all logins, not just when using password authentication.
 
 All new code is released under a XFree style license, which is very
 liberal. Please refer to the source files for details. The code in
-strlcpy.c and mktemp.c is from the OpenBSD project and has its own
-license (again, see source file for details).
+bsd-*.[ch] is from the OpenBSD project and has its own license (again,
+see the source files for details).
 
 OpenSSH depends on Zlib[2], OpenSSL[3] and optionally PAM[4]. To build
 the GNOME[5] pass-phrase requester (--with-gnome-askpass), you will
@@ -52,13 +52,14 @@ Credits -
 Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos, 
 Theo de Raadt, and Dug Song - Creators of OpenSSH
 'jonchen' - the original author of PAM support of SSH
+Chip Salzenberg <chip@valinux.com> - Assorted patches
 Dan Brosemer <odin@linuxfreak.com> - Autoconf and build fixes & Debian scripts
+Jim Knoble <jmknoble@pobox.com> - RPM spec file fixes
+Marc G. Fournier <marc.fournier@acadiau.ca> - Solaris patches
 Nalin Dahyabhai <nalin.dahyabhai@pobox.com> - PAM environment patch
-Phil Hands <phil@hands.com> - Debian scripts, assorted patches
 Niels Kristian Bech Jensen <nkbj@image.dk> - Assorted patches
-Marc G. Fournier <marc.fournier@acadiau.ca> - Solaris patches
+Phil Hands <phil@hands.com> - Debian scripts, assorted patches
 Thomas Neumann <tom@smart.ruhr.de> - Shadow passwords
-Jim Knoble <jmknoble@pobox.com> - RPM spec file fixes
 
 Miscellania - 
 
index 44c5c1a14fd7cb0161366c21aa4660628d3ebf55..2732c26cc37112657a837de7734ebbed065325b6 100644 (file)
 /* Define if you want TCP Wrappers support */
 #undef LIBWRAP
 
+/* Define if your libraries define login() */
+#undef HAVE_LOGIN
+
+/* Define if your libraries define daemon() */
+#undef HAVE_DAEMON
+
 @BOTTOM@
 
 /* ******************* Shouldn't need to edit below this line ************** */
diff --git a/bsd-daemon.c b/bsd-daemon.c
new file mode 100644 (file)
index 0000000..7b292c1
--- /dev/null
@@ -0,0 +1,78 @@
+/*-
+ * Copyright (c) 1990, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "config.h"
+
+#ifndef HAVE_DAEMON
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char rcsid[] = "$OpenBSD: daemon.c,v 1.2 1996/08/19 08:22:13 tholo Exp $";
+#endif /* LIBC_SCCS and not lint */
+
+#include <fcntl.h>
+#include <paths.h>
+#include <unistd.h>
+
+int
+daemon(nochdir, noclose)
+       int nochdir, noclose;
+{
+       int fd;
+
+       switch (fork()) {
+       case -1:
+               return (-1);
+       case 0:
+               break;
+       default:
+               _exit(0);
+       }
+
+       if (setsid() == -1)
+               return (-1);
+
+       if (!nochdir)
+               (void)chdir("/");
+
+       if (!noclose && (fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) {
+               (void)dup2(fd, STDIN_FILENO);
+               (void)dup2(fd, STDOUT_FILENO);
+               (void)dup2(fd, STDERR_FILENO);
+               if (fd > 2)
+                       (void)close (fd);
+       }
+       return (0);
+}
+
+#endif /* !HAVE_DAEMON */
+
diff --git a/bsd-daemon.h b/bsd-daemon.h
new file mode 100644 (file)
index 0000000..cd91ea0
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef _BSD_DAEMON_H
+#define _BSD_DAEMON_H
+
+#include "config.h"
+#ifndef HAVE_DAEMON
+int daemon(int nochdir, int noclose);
+#endif /* !HAVE_DAEMON */
+
+#endif /* _BSD_DAEMON_H */
diff --git a/bsd-login.c b/bsd-login.c
new file mode 100644 (file)
index 0000000..8c84272
--- /dev/null
@@ -0,0 +1,83 @@
+/*     $OpenBSD: login.c,v 1.5 1998/07/13 02:11:12 millert Exp $       */
+/*
+ * Copyright (c) 1988, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the University of
+ *     California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include "config.h"
+#ifndef HAVE_LOGIN
+
+#if defined(LIBC_SCCS) && !defined(lint)
+/* from: static char sccsid[] = "@(#)login.c   8.1 (Berkeley) 6/4/93"; */
+static char *rcsid = "$Id: bsd-login.c,v 1.1 1999/11/19 04:32:34 damien Exp $";
+#endif /* LIBC_SCCS and not lint */
+
+#include <sys/types.h>
+
+#include <fcntl.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <utmp.h>
+#include <stdio.h>
+
+void
+login(utp)
+       struct utmp *utp;
+{
+       struct utmp old_ut;
+       register int fd;
+       int tty;
+
+       tty = ttyslot();
+       if (tty > 0 && (fd = open(_PATH_UTMP, O_RDWR|O_CREAT, 0644)) >= 0) {
+               (void)lseek(fd, (off_t)(tty * sizeof(struct utmp)), SEEK_SET);
+               /*
+                * Prevent luser from zero'ing out ut_host.
+                * If the new ut_line is empty but the old one is not
+                * and ut_line and ut_name match, preserve the old ut_line.
+                */
+               if (read(fd, &old_ut, sizeof(struct utmp)) ==
+                   sizeof(struct utmp) && utp->ut_host[0] == '\0' &&
+                   old_ut.ut_host[0] != '\0' &&
+                   strncmp(old_ut.ut_line, utp->ut_line, UT_LINESIZE) == 0 &&
+                   strncmp(old_ut.ut_name, utp->ut_name, UT_NAMESIZE) == 0)
+                       (void)memcpy(utp->ut_host, old_ut.ut_host, UT_HOSTSIZE);
+               (void)lseek(fd, (off_t)(tty * sizeof(struct utmp)), SEEK_SET);
+               (void)write(fd, utp, sizeof(struct utmp));
+               (void)close(fd);
+       }
+       if ((fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) >= 0) {
+               (void)write(fd, utp, sizeof(struct utmp));
+               (void)close(fd);
+       }
+}
+
+#endif /* HAVE_LOGIN */
diff --git a/bsd-login.h b/bsd-login.h
new file mode 100644 (file)
index 0000000..26a8505
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef _BSD_LOGIN_H
+#define _BSD_LOGIN_H
+
+#include "config.h"
+#ifndef HAVE_LOGIN
+
+#include <utmp.h>
+
+void login(struct utmp *utp);
+
+#endif /* !HAVE_LOGIN */
+
+#endif /* _BSD_LOGIN_H */
similarity index 99%
rename from mktemp.c
rename to bsd-mktemp.c
index be03ac90986beb1268f94537b2ca27e1ccac0f94..cdef62da2264cf71eb678bad8e76152aef8d68f8 100644 (file)
--- a/mktemp.c
  * SUCH DAMAGE.
  */
 
+#include "config.h"
+
+#ifndef HAVE_MKDTEMP
+
 #if defined(LIBC_SCCS) && !defined(lint)
 static char rcsid[] = "$OpenBSD: mktemp.c,v 1.13 1998/06/30 23:03:13 deraadt Exp $";
 #endif /* LIBC_SCCS and not lint */
@@ -47,11 +51,8 @@ static char rcsid[] = "$OpenBSD: mktemp.c,v 1.13 1998/06/30 23:03:13 deraadt Exp
 #include <ctype.h>
 #include <unistd.h>
 
-#include "config.h"
 #include "helper.h"
 
-#ifndef HAVE_MKDTEMP
-
 static int _gettemp(char *, int *, int, int);
 
 int
similarity index 68%
rename from mktemp.h
rename to bsd-mktemp.h
index ac92cbae05da364f7f67d62ff9e8f71b96e922ab..faddc916ee224cef5bd21db940eaaecdaa6f028c 100644 (file)
--- a/mktemp.h
@@ -1,5 +1,5 @@
-#ifndef _MKTEMP_H
-#define _MKTEMP_H
+#ifndef _BSD_MKTEMP_H
+#define _BSD_MKTEMP_H
 
 #include "config.h"
 #ifndef HAVE_MKDTEMP
@@ -8,4 +8,4 @@ int mkstemp(char *path);
 char *mkdtemp(char *path);
 #endif /* !HAVE_MKDTEMP */
 
-#endif /* _MKTEMP_H */
+#endif /* _BSD_MKTEMP_H */
similarity index 100%
rename from strlcpy.c
rename to bsd-strlcpy.c
index 4df4080d6c91bbe1a00f3651016356f798f228e7..276c25c37fb178da827cd87bf546530118d7133f 100644 (file)
--- a/strlcpy.c
@@ -27,6 +27,9 @@
  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include "config.h"
+#ifndef HAVE_STRLCPY
+
 #if defined(LIBC_SCCS) && !defined(lint)
 static char *rcsid = "$OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp $";
 #endif /* LIBC_SCCS and not lint */
@@ -34,9 +37,6 @@ static char *rcsid = "$OpenBSD: strlcpy.c,v 1.4 1999/05/01 18:56:41 millert Exp
 #include <sys/types.h>
 #include <string.h>
 
-#include "config.h"
-#ifndef HAVE_STRLCPY
-
 /*
  * Copy src to string dst of size siz.  At most siz-1 characters
  * will be copied.  Always NUL terminates (unless siz == 0).
similarity index 56%
rename from strlcpy.h
rename to bsd-strlcpy.h
index 9afbd39c5538d68d1b081afc899f5783ed4cfdae..dafa44af86f454c503c056cd01b4f542b165433b 100644 (file)
--- a/strlcpy.h
@@ -1,9 +1,10 @@
-#ifndef _STRLCPY_H
-#define _STRLCPY_H
+#ifndef _BSD_STRLCPY_H
+#define _BSD_STRLCPY_H
 
 #include "config.h"
 #ifndef HAVE_STRLCPY
+#include <sys/types.h>
 size_t strlcpy(char *dst, const char *src, size_t siz);
 #endif /* !HAVE_STRLCPY */
 
-#endif /* _STRLCPY_H */
+#endif /* _BSD_STRLCPY_H */
index 0b54fd58a560dd89f123157d05a5eabd6979ac60..dd74b3b4f0f7bed4d0a50465d1f523899fee37ee 100644 (file)
@@ -60,6 +60,16 @@ AC_CHECK_HEADERS(pty.h endian.h paths.h lastlog.h shadow.h netgroup.h maillock.h
 dnl Checks for library functions.
 AC_CHECK_FUNCS(openpty strlcpy mkdtemp arc4random setproctitle setlogin)
 
+AC_CHECK_FUNC(login, 
+       [AC_DEFINE(HAVE_LOGIN)],
+       [AC_CHECK_LIB(bsd, login, [LIBS="$LIBS -lbsd"; AC_DEFINE(HAVE_LOGIN)])]
+)
+
+AC_CHECK_FUNC(daemon, 
+       [AC_DEFINE(HAVE_DAEMON)],
+       [AC_CHECK_LIB(bsd, daemon, [LIBS="$LIBS -lbsd"; AC_DEFINE(HAVE_DAEMON)])]
+)
+
 dnl Check whether use wants to disable the external ssh-askpass
 INSTALL_ASKPASS="yes"
 AC_MSG_CHECKING([whether to enable external ssh-askpass support])
@@ -156,7 +166,7 @@ done
 
 AC_MSG_CHECKING([whether libc defines __progname])
 AC_TRY_LINK([], 
-       [extern char *__progname;], 
+       [extern char *__progname; printf("%s", __progname);], 
        [
                AC_DEFINE(HAVE___PROGNAME)
                AC_MSG_RESULT(yes)
index 75349cf3efee80ce16d19a663575f892cd2d9d33..06245fdce8beed7fded8837d04466888ff2d8f29 100644 (file)
@@ -67,12 +67,12 @@ static /**/const char *const rcsid[] = { (char *)rcsid, "\100(#)" msg }
 #endif
 #ifdef HAVE_LIBPAM
 # include <security/pam_appl.h>
-#endif /* HAVE_PAM */
+#endif
 
 #include "version.h"
 #include "helper.h"
-#include "mktemp.h"
-#include "strlcpy.h"
+#include "bsd-strlcpy.h"
+#include "bsd-mktemp.h"
 
 /* Define this to be the path of the xauth program. */
 #ifndef XAUTH_PATH