svn rev #3269: trunk/ bsd/ gssftp/ftp/ gssftp/ftpd/ libmissing/ libpty/ telnet/libtelnet/ ...
ghudson@MIT.EDU
ghudson at MIT.EDU
Mon Jul 20 13:21:25 EDT 2009
Commit By: ghudson
Log Message:
Unify how we handle missing system functions. Create a new library
named libmissing containing all of the replacement functions, and use
AC_REPLACE_FUNCS for all of them. Eliminate KRB5_NEED_PROTO and just
prototype functions in k5-platform.h if they're not present in libc.
Stop relying on libkrb5support for asprintf and strlcpy.
Changed Files:
U trunk/Makefile.in
U trunk/aclocal.m4
U trunk/bsd/Makefile.in
U trunk/bsd/defines.h
U trunk/bsd/krlogind.c
U trunk/bsd/login.c
D trunk/bsd/setenv.c
U trunk/configure.ac
U trunk/gssftp/ftp/Makefile.in
U trunk/gssftp/ftp/pclose.c
U trunk/gssftp/ftpd/Makefile.in
U trunk/gssftp/ftpd/deps
U trunk/gssftp/ftpd/ftpd.c
U trunk/k5-platform.h
A trunk/libmissing/
A trunk/libmissing/Makefile.in
A trunk/libmissing/asprintf.c
A trunk/libmissing/daemon.c
A trunk/libmissing/deps
A trunk/libmissing/dummy.c
A trunk/libmissing/getdtablesize.c
A trunk/libmissing/getopt.c
A trunk/libmissing/herror.c
A trunk/libmissing/parsetos.c
A trunk/libmissing/setenv.c
A trunk/libmissing/setsid.c
A trunk/libmissing/strcasecmp.c
A trunk/libmissing/strdup.c
A trunk/libmissing/strerror.c
A trunk/libmissing/strftime.c
A trunk/libmissing/strlcpy.c
U trunk/libpty/Makefile.in
U trunk/pre.in
U trunk/telnet/libtelnet/Makefile.in
U trunk/telnet/libtelnet/deps
U trunk/telnet/libtelnet/forward.c
D trunk/telnet/libtelnet/getopt.c
D trunk/telnet/libtelnet/herror.c
U trunk/telnet/libtelnet/misc-proto.h
U trunk/telnet/libtelnet/misc.c
D trunk/telnet/libtelnet/parsetos.c
D trunk/telnet/libtelnet/setenv.c
D trunk/telnet/libtelnet/setsid.c
D trunk/telnet/libtelnet/strcasecmp.c
D trunk/telnet/libtelnet/strchr.c
D trunk/telnet/libtelnet/strdup.c
D trunk/telnet/libtelnet/strerror.c
D trunk/telnet/libtelnet/strftime.c
D trunk/telnet/libtelnet/strrchr.c
U trunk/telnet/telnet/Makefile.in
U trunk/telnet/telnet/commands.c
U trunk/telnet/telnet/main.c
U trunk/telnet/telnetd/Makefile.in
U trunk/telnet/telnetd/ext.h
U trunk/tests/resolve/Makefile.in
Modified: trunk/Makefile.in
===================================================================
--- trunk/Makefile.in 2009-07-14 19:23:11 UTC (rev 3268)
+++ trunk/Makefile.in 2009-07-20 17:21:24 UTC (rev 3269)
@@ -1,4 +1,4 @@
mydir=.
BUILDTOP=$(REL)$(C)
-SUBDIRS= libpty bsd gssftp telnet tests
+SUBDIRS= libmissing libpty bsd gssftp telnet tests
Modified: trunk/aclocal.m4
===================================================================
--- trunk/aclocal.m4 2009-07-14 19:23:11 UTC (rev 3268)
+++ trunk/aclocal.m4 2009-07-20 17:21:24 UTC (rev 3269)
@@ -457,12 +457,6 @@
AC_CHECK_FUNCS(setutent setutxent updwtmp updwtmpx)
])dnl
dnl
-dnl
-AC_DEFUN(KRB5_AC_NEED_DAEMON, [
-KRB5_NEED_PROTO([#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif],daemon,1)])dnl
-dnl
dnl Check if stdarg or varargs is available *and compiles*; prefer stdarg.
dnl (This was sent to djm for incorporation into autoconf 3/12/1996. KR)
dnl
@@ -506,32 +500,6 @@
])dnl
dnl
-dnl Check if we need the prototype for a function - we give it a bogus
-dnl prototype and if it complains - then a valid prototype exists on the
-dnl system.
-dnl
-dnl KRB5_NEED_PROTO(includes, function, [bypass])
-dnl if $3 set, don't see if library defined.
-dnl Useful for case where we will define in libkrb5 the function if need be
-dnl but want to know if a prototype exists in either case on system.
-dnl
-AC_DEFUN([KRB5_NEED_PROTO], [
-ifelse([$3], ,[if test "x$ac_cv_func_$2" = xyes; then])
-AC_CACHE_CHECK([if $2 needs a prototype provided], krb5_cv_func_$2_noproto,
-AC_TRY_COMPILE([$1],
-[#undef $2
-struct k5foo {int foo; } xx;
-extern int $2 (struct k5foo*);
-$2(&xx);
-],
-krb5_cv_func_$2_noproto=yes,krb5_cv_func_$2_noproto=no))
-if test $krb5_cv_func_$2_noproto = yes; then
- AC_DEFINE([NEED_]translit($2, [a-z], [A-Z])[_PROTO], 1, dnl
-[define if the system header files are missing prototype for $2()])
-fi
-ifelse([$3], ,[fi])
-])dnl
-dnl
dnl =============================================================
dnl Internal function for testing for getsockname arguments
dnl
Modified: trunk/bsd/Makefile.in
===================================================================
--- trunk/bsd/Makefile.in 2009-07-14 19:23:11 UTC (rev 3268)
+++ trunk/bsd/Makefile.in 2009-07-20 17:21:24 UTC (rev 3269)
@@ -1,19 +1,13 @@
mydir=bsd
BUILDTOP=$(REL)..
-SETENVSRC=@SETENVSRC@
-SETENVOBJ=@SETENVOBJ@
-
LOGINLIBS=@LOGINLIBS@
-DAEMONOBJ=@DAEMONOBJ@
-GETDOBJ=@GETDOBJ@
KRSHDLIBS=@KRSHDLIBS@
SRCS= $(srcdir)/krcp.c $(srcdir)/krlogin.c $(srcdir)/krsh.c $(srcdir)/kcmd.c \
$(srcdir)/forward.c $(srcdir)/login.c $(srcdir)/krshd.c \
$(srcdir)/krlogind.c
-OBJS= krcp.o krlogin.o krsh.o kcmd.o forward.o $(SETENVOBJ) login.o krshd.o \
- krlogind.o $(DAEMONOBJ) $(GETDOBJ)
+OBJS= krcp.o krlogin.o krsh.o kcmd.o forward.o login.o krshd.o krlogind.o
UCB_RLOGIN = @UCB_RLOGIN@
UCB_RSH = @UCB_RSH@
@@ -38,14 +32,14 @@
$(top_srcdir)/mkinstalldirs $(DESTDIR)$(CLIENT_BINDIR)
$(top_srcdir)/mkinstalldirs $(DESTDIR)$(CLIENT_MANDIR)
-rsh: krsh.o kcmd.o forward.o $(SETENVOBJ) $(GETDOBJ)
- $(CC_LINK) -o rsh krsh.o kcmd.o forward.o $(SETENVOBJ) $(GETDOBJ) $(KRB5_BASE_LIBS) $(LIBS)
+rsh: krsh.o kcmd.o forward.o $(MISSING_DEPLIB)
+ $(CC_LINK) -o rsh krsh.o kcmd.o forward.o $(MISSING_LIB) $(KRB5_BASE_LIBS) $(LIBS)
-rcp: krcp.o kcmd.o forward.o $(SETENVOBJ) $(GETDOBJ)
- $(CC_LINK) -o rcp krcp.o kcmd.o forward.o $(SETENVOBJ) $(GETDOBJ) $(KRB5_BASE_LIBS) $(LIBS)
+rcp: krcp.o kcmd.o forward.o $(MISSING_DEPLIB)
+ $(CC_LINK) -o rcp krcp.o kcmd.o forward.o $(MISSING_LIB) $(KRB5_BASE_LIBS) $(LIBS)
-rlogin: krlogin.o kcmd.o forward.o $(SETENVOBJ) $(GETDOBJ)
- $(CC_LINK) -o rlogin krlogin.o kcmd.o forward.o $(SETENVOBJ) $(GETDOBJ) $(KRB5_BASE_LIBS) $(LIBS)
+rlogin: krlogin.o kcmd.o forward.o $(MISSING_DEPLIB)
+ $(CC_LINK) -o rlogin krlogin.o kcmd.o forward.o $(MISSING_LIB) $(KRB5_BASE_LIBS) $(LIBS)
install::
for f in rsh rcp rlogin; do \
@@ -56,11 +50,11 @@
) || exit 1; \
done
-kshd: krshd.o kcmd.o forward.o $(SETENVOBJ) $(GETDOBJ) $(PTY_DEPLIB)
- $(CC_LINK) -o kshd krshd.o kcmd.o forward.o $(SETENVOBJ) $(GETDOBJ) $(KRSHDLIBS) $(PTY_LIB) $(UTIL_LIB) $(KRB5_BASE_LIBS) $(LIBS)
+kshd: krshd.o kcmd.o forward.o $(PTY_DEPLIB) $(MISSING_DEPLIB)
+ $(CC_LINK) -o kshd krshd.o kcmd.o forward.o $(KRSHDLIBS) $(PTY_LIB) $(UTIL_LIB) $(MISSING_LIB) $(KRB5_BASE_LIBS) $(LIBS)
-klogind: krlogind.o kcmd.o forward.o $(SETENVOBJ) $(DAEMONOBJ) $(GETDOBJ) $(PTY_DEPLIB)
- $(CC_LINK) -o klogind krlogind.o kcmd.o forward.o $(SETENVOBJ) $(DAEMONOBJ) $(GETDOBJ) $(PTY_LIB) $(UTIL_LIB) $(KRB5_BASE_LIBS) $(LIBS)
+klogind: krlogind.o kcmd.o forward.o $(PTY_DEPLIB) $(MISSING_DEPLIB)
+ $(CC_LINK) -o klogind krlogind.o kcmd.o forward.o $(PTY_LIB) $(UTIL_LIB) $(MISSING_LIB) $(KRB5_BASE_LIBS) $(LIBS)
install::
for f in kshd klogind; do \
@@ -74,8 +68,8 @@
# No program name transformation is done with login.krb5 since it is directly
# referenced by klogind.
#
-login.krb5: login.o $(SETENVOBJ) $(GETDOBJ) $(PTY_DEPLIB)
- $(CC_LINK) -o login.krb5 login.o $(SETENVOBJ) $(GETDOBJ) $(LOGINLIBS) $(PTY_LIB) $(KRB5_BASE_LIBS) $(LIBS)
+login.krb5: login.o $(PTY_DEPLIB) $(MISSING_DEPLIB)
+ $(CC_LINK) -o login.krb5 login.o $(LOGINLIBS) $(PTY_LIB) $(KRB5_BASE_LIBS) $(MISSING_LIB) $(LIBS)
install::
$(INSTALL_PROGRAM) login.krb5 $(DESTDIR)$(SERVER_BINDIR)/login.krb5
Modified: trunk/bsd/defines.h
===================================================================
--- trunk/bsd/defines.h 2009-07-14 19:23:11 UTC (rev 3268)
+++ trunk/bsd/defines.h 2009-07-20 17:21:24 UTC (rev 3269)
@@ -57,10 +57,6 @@
int princ_maps_to_lname(krb5_principal principal, char *luser);
int default_realm(krb5_principal principal);
-#ifdef NEED_SETENV
-extern int setenv(char *, char *, int);
-#endif
-
#include "fake-addrinfo.h"
#ifdef KRB_DEFS
Modified: trunk/bsd/krlogind.c
===================================================================
--- trunk/bsd/krlogind.c 2009-07-14 19:23:11 UTC (rev 3268)
+++ trunk/bsd/krlogind.c 2009-07-20 17:21:24 UTC (rev 3269)
@@ -300,10 +300,6 @@
static int Pfd;
-#if defined(NEED_DAEMON_PROTO)
-extern int daemon(int, int);
-#endif
-
#if (defined(_AIX) && defined(i386)) || defined(ibm032) || (defined(vax) && !defined(ultrix)) || (defined(SunOS) && SunOS > 40) || defined(solaris20)
#define VHANG_FIRST
#endif
Modified: trunk/bsd/login.c
===================================================================
--- trunk/bsd/login.c 2009-07-14 19:23:11 UTC (rev 3268)
+++ trunk/bsd/login.c 2009-07-20 17:21:24 UTC (rev 3269)
@@ -234,10 +234,6 @@
#define MAXENVIRON 32
-#ifdef NEED_SETENV
-extern int setenv(char *, char *, int);
-#endif
-
/*
* This bounds the time given to login. Not a define so it can
* be patched on machines where it's too small.
Deleted: trunk/bsd/setenv.c
Modified: trunk/configure.ac
===================================================================
--- trunk/configure.ac 2009-07-14 19:23:11 UTC (rev 3268)
+++ trunk/configure.ac 2009-07-20 17:21:24 UTC (rev 3269)
@@ -19,8 +19,8 @@
AC_MSG_ERROR([Specify -with-krb5= krb5 exec-prefix or path to krb5-config])
fi
KRB5_CFLAGS=`$krb5_config --cflags`
-KRB5_BASE_LIBS=`$krb5_config --libs krb5`" -lkrb5support"
-GSS_LIBS=`$krb5_config --libs gssapi`" -lkrb5support"
+KRB5_BASE_LIBS=`$krb5_config --libs krb5`
+GSS_LIBS=`$krb5_config --libs gssapi`
KRB5_BINDIR=`$krb5_config --exec-prefix`/bin
KRB5_SBINDIR=`$krb5_config --exec-prefix`/sbin
AC_SUBST(KRB5_CFLAGS)
@@ -60,7 +60,6 @@
CHECK_WAIT_TYPE
DECLARE_SYS_ERRLIST
KRB5_AC_MAINTAINER_MODE
-KRB5_AC_NEED_DAEMON
KRB5_AC_INET6
KRB5_AC_LIBUTIL
KRB5_SIGTYPE
@@ -99,54 +98,15 @@
AC_CHECK_FUNCS(_getpty cgetent getcwd getenv gettosbyname getusershell getutmp)
AC_CHECK_FUNCS(getutmpx grantpt inet_aton initgroups isatty killpg killpg)
AC_CHECK_FUNCS(line_push logwtmp openpty ptsname revoke rmufile rresvport_af)
-AC_CHECK_FUNCS(setenv seteuid setlogin setpgid setpriority setresuid setreuid)
-AC_CHECK_FUNCS(setsid setutent setutsent setutxent strerror strlcpy strsave)
-AC_CHECK_FUNCS(tcgetpgrp tcsetpgrp ttyname unsetenv updwtmp updwtmpx utimes)
-AC_CHECK_FUNCS(utmpname utmpxname vhangup vasprintf vsnprintf waitpid)
+AC_CHECK_FUNCS(seteuid setlogin setpgid setpriority setresuid setreuid)
+AC_CHECK_FUNCS(setutent setutsent setutxent strsave tcgetpgrp tcsetpgrp)
+AC_CHECK_FUNCS(ttyname unsetenv updwtmp updwtmpx utimes utmpname utmpxname)
+AC_CHECK_FUNCS(vhangup vsnprintf waitpid)
-# Wishlist item: consolidate all of the replacement functions into a
-# new library (perhaps "libroken", according to tradition) and use
-# AC_REPLACE_FUNCS for all of them. This would require moving getenv
-# out of setenv.c or just punting it.
+# Determine which functions to define in libmissing.
+AC_REPLACE_FUNCS(daemon getdtablesize getopt herror parsetos setenv setsid)
+AC_REPLACE_FUNCS(strcasecmp strdup strerror strftime strlcpy vasprintf)
-# bsd defines daemon if it is not provided.
-DAEMONOBJ=
-AC_CHECK_FUNCS(daemon,, DAEMONOBJ=daemon.o)
-AC_SUBST(DAEMONOBJ)
-
-# ftpd and bsd define getdtablesize if it is not provided.
-GETDOBJ=
-AC_CHECK_FUNCS(getdtablesize,, GETDOBJ=getdtablesize.o)
-AC_SUBST(GETDOBJ)
-
-# libtelnet, ftpd, and bsd define setenv if it is not provided.
-if test $ac_cv_func_setenv = no || test $ac_cv_func_unsetenv = no \
- || test $ac_cv_func_getenv = no; then
- SETENVOBJ=setenv.o
- AC_SUBST([SETENVOBJ])
- AC_DEFINE([NEED_SETENV],1,[Define if setenv needs to be defined])
-fi
-
-# libtelnet defines these functions if not provided, using the
-# autoconf LIBOBJS mechanism.
-AC_REPLACE_FUNCS(getopt herror parsetos setsid strcasecmp strdup strerror)
-AC_REPLACE_FUNCS(strftime)
-
-KRB5_NEED_PROTO([#include <stdlib.h>],setenv,1)
-KRB5_NEED_PROTO([#include <stdlib.h>],unsetenv,1)
-KRB5_NEED_PROTO([#include <unistd.h>
-#include <stdlib.h>],parsetos,1)
-dnl
-KRB5_NEED_PROTO([#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>],herror,1)
-KRB5_NEED_PROTO([#include <unistd.h>
-],revoke)
-KRB5_NEED_PROTO([#include <stdarg.h>
-#include <stdio.h>
-],vasprintf)
-
# Determine libraries for login and ftpd.
LOGINLIBS=
FTPD_LIBS=
@@ -356,33 +316,6 @@
fi
fi
-KRB5_NEED_PROTO([#ifdef HAVE_UTMP_H
-#include <utmp.h>
-#endif
-#ifdef HAVE_UTMPX_H
-#include <utmpx.h>
-#endif
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-],getutmp)
-dnl
-
-KRB5_NEED_PROTO([#include <sys/types.h>
-#ifdef HAVE_UTMP_H
-#include <utmp.h>
-#endif
-#ifdef HAVE_LIBUTIL_H
-#include <libutil.h>
-#endif
-#ifdef HAVE_UTIL_H
-#include <util.h>
-#endif
-],logwtmp)
-
# ----- End of utmp stuff -----
AC_MSG_CHECKING([arguments to getpgrp])
@@ -489,7 +422,7 @@
fi
AC_SUBST(HAVE_RUNTEST)
-V5_AC_OUTPUT_MAKEFILE(. bsd libpty
+V5_AC_OUTPUT_MAKEFILE(. bsd libmissing libpty
gssftp gssftp/ftp gssftp/ftpd
telnet telnet/libtelnet telnet/telnet telnet/telnetd
tests tests/resolve)
Modified: trunk/gssftp/ftp/Makefile.in
===================================================================
--- trunk/gssftp/ftp/Makefile.in 2009-07-14 19:23:11 UTC (rev 3268)
+++ trunk/gssftp/ftp/Makefile.in 2009-07-20 17:21:24 UTC (rev 3269)
@@ -22,8 +22,8 @@
all:: ftp
all-windows:: $(OUTPRE)ftp.exe
-ftp: $(OBJS)
- $(CC_LINK) -o ftp $(OBJS) $(GSS_LIBS) $(LIBS)
+ftp: $(OBJS) $(MISSING_DEPLIB)
+ $(CC_LINK) -o ftp $(OBJS) $(MISSING_LIB) $(GSS_LIBS) $(LIBS)
$(OUTPRE)ftp.exe: $(OBJS) $(GLIB) $(KLIB)
link $(EXE_LINKOPTS) -out:$@ $** ws2_32.lib advapi32.lib $(SCLIB)
Modified: trunk/gssftp/ftp/pclose.c
===================================================================
--- trunk/gssftp/ftp/pclose.c 2009-07-14 19:23:11 UTC (rev 3268)
+++ trunk/gssftp/ftp/pclose.c 2009-07-20 17:21:24 UTC (rev 3269)
@@ -28,15 +28,6 @@
static int *popen_pid;
static int nfiles;
-#ifndef HAVE_GETDTABLESIZE
-#include <sys/resource.h>
-int getdtablesize() {
- struct rlimit rl;
- getrlimit(RLIMIT_NOFILE, &rl);
- return rl.rlim_cur;
-}
-#endif
-
FILE *
mypopen(cmd,mode)
char *cmd;
Modified: trunk/gssftp/ftpd/Makefile.in
===================================================================
--- trunk/gssftp/ftpd/Makefile.in 2009-07-14 19:23:11 UTC (rev 3268)
+++ trunk/gssftp/ftpd/Makefile.in 2009-07-20 17:21:24 UTC (rev 3269)
@@ -5,27 +5,23 @@
PROG_LIBPATH=-L$(TOPLIBD)
PROG_RPATH=$(KRB5_LIBDIR)
-SETENVOBJ=@SETENVOBJ@
-GETDOBJ=@GETDOBJ@
FTPD_LIBS=@FTPD_LIBS@
SRCS = $(srcdir)/ftpd.c ftpcmd.c $(srcdir)/popen.c \
$(srcdir)/vers.c \
$(srcdir)/../ftp/glob.c \
$(srcdir)/../ftp/radix.c \
- $(srcdir)/../ftp/secure.c \
- $(srcdir)/../../bsd/getdtablesize.c \
- $(srcdir)/../../bsd/setenv.c
+ $(srcdir)/../ftp/secure.c
OBJS = ftpd.o ftpcmd.o glob.o popen.o vers.o radix.o \
- secure.o $(GETDOBJ) $(SETENVOBJ)
+ secure.o
LOCALINCLUDES = -I$(srcdir)/.. -I$(srcdir)
all:: ftpd
-ftpd: $(OBJS) $(PTY_DEPLIB)
- $(CC_LINK) -o $@ $(OBJS) $(FTPD_LIBS) $(PTY_LIB) $(UTIL_LIB) $(GSS_LIBS) $(LIBS)
+ftpd: $(OBJS) $(PTY_DEPLIB) $(MISSING_DEPLIB)
+ $(CC_LINK) -o $@ $(OBJS) $(FTPD_LIBS) $(PTY_LIB) $(UTIL_LIB) $(MISSING_LIB) $(GSS_LIBS) $(LIBS)
generate-files-mac: ftpcmd.c
@@ -57,12 +53,6 @@
secure.o: $(srcdir)/../ftp/secure.c
$(CC) -c $(ALL_CFLAGS) $(srcdir)/../ftp/secure.c
-getdtablesize.o: $(srcdir)/../../bsd/getdtablesize.c
- $(CC) -c $(ALL_CFLAGS) $(srcdir)/../../bsd/getdtablesize.c
-
-setenv.o: $(srcdir)/../../bsd/setenv.c
- $(CC) -c $(ALL_CFLAGS) $(srcdir)/../../bsd/setenv.c
-
ftpd.o: $(srcdir)/pathnames.h
secure.o: $(srcdir)/secure.h
Modified: trunk/gssftp/ftpd/deps
===================================================================
--- trunk/gssftp/ftpd/deps 2009-07-14 19:23:11 UTC (rev 3268)
+++ trunk/gssftp/ftpd/deps 2009-07-20 17:21:24 UTC (rev 3269)
@@ -17,5 +17,3 @@
$(srcdir)/../ftp/radix.c
$(OUTPRE)secure.$(OBJEXT): $(BUILDTOP)/autoconf.h $(srcdir)/../arpa/ftp.h \
$(srcdir)/../ftp/secure.c $(srcdir)/../ftp/secure.h
-$(OUTPRE)getdtablesize.$(OBJEXT): $(SRCTOP)/bsd/getdtablesize.c
-$(OUTPRE)setenv.$(OBJEXT): $(SRCTOP)/bsd/setenv.c
Modified: trunk/gssftp/ftpd/ftpd.c
===================================================================
--- trunk/gssftp/ftpd/ftpd.c 2009-07-14 19:23:11 UTC (rev 3268)
+++ trunk/gssftp/ftpd/ftpd.c 2009-07-20 17:21:24 UTC (rev 3269)
@@ -100,10 +100,6 @@
#include <k5-platform.h>
-#ifdef NEED_SETENV
-extern int setenv(char *, char *, int);
-#endif
-
#ifndef L_SET
#define L_SET 0
#endif
Modified: trunk/k5-platform.h
===================================================================
--- trunk/k5-platform.h 2009-07-14 19:23:11 UTC (rev 3268)
+++ trunk/k5-platform.h 2009-07-20 17:21:24 UTC (rev 3269)
@@ -45,45 +45,73 @@
#include <fcntl.h>
#include <errno.h>
-/* Provide strlcpy/strlcat interfaces. */
-#ifndef HAVE_STRLCPY
-#define strlcpy krb5int_strlcpy
-#define strlcat krb5int_strlcat
-extern size_t krb5int_strlcpy(char *dst, const char *src, size_t siz);
-extern size_t krb5int_strlcat(char *dst, const char *src, size_t siz);
+/* Prototypes for system functions possibly defined in libmissing. */
+
+#ifndef HAVE_DAEMON
+int daemon(int nochdir, int noclose);
#endif
-#ifndef HAVE_VASPRINTF
+#ifndef HAVE_GETDTABLESIZE
+int getdtablesize(void);
+#endif
-extern int krb5int_vasprintf(char **, const char *, va_list)
-#if !defined(__cplusplus) && (__GNUC__ > 2)
- __attribute__((__format__(__printf__, 2, 0)))
+#ifndef HAVE_GETOPT
+int getopt(int nargc, char *const *nargv, const char *ostr);
#endif
- ;
-extern int krb5int_asprintf(char **, const char *, ...)
-#if !defined(__cplusplus) && (__GNUC__ > 2)
- __attribute__((__format__(__printf__, 2, 3)))
+
+#ifndef HAVE_HERROR
+void herror(const char *s);
#endif
- ;
-#define vasprintf krb5int_vasprintf
-/* Assume HAVE_ASPRINTF iff HAVE_VASPRINTF. */
-#define asprintf krb5int_asprintf
+#ifndef HAVE_PARSETOS
+int parsetos(char *name, char *proto);
+#endif
-#elif defined(NEED_VASPRINTF_PROTO)
+#ifndef HAVE_SETENV
+int setenv(char *name, char *value, int rewrite);
+void unsetenv(char *name);
+#endif
-extern int vasprintf(char **, const char *, va_list)
+#ifndef HAVE_SETSID
+int setsid(void);
+#endif
+
+#ifndef HAVE_STRCASECMP
+int strcasecmp(const char *s1, const char *s2);
+int strncasecmp(const char *s1, const char *s2, size_t n);
+#endif
+
+#ifndef HAVE_STRDUP
+char *strdup(const char *str);
+#endif
+
+#ifndef HAVE_STRERROR
+char *strerror(int num);
+#endif
+
+#ifndef HAVE_STRFTIME
+size_t strftime(char *s, size_t maxsize, const char *format,
+ const struct tm *t);
+#endif
+
+#ifndef HAVE_STRLCPY
+size_t strlcpy(char *dst, const char *src, size_t siz);
+size_t strlcat(char *dst, const char *src, size_t siz);
+#endif
+
+#ifndef HAVE_VASPRINTF
+int vasprintf(char **, const char *, va_list)
#if !defined(__cplusplus) && (__GNUC__ > 2)
__attribute__((__format__(__printf__, 2, 0)))
#endif
;
-extern int asprintf(char **, const char *, ...)
+int asprintf(char **, const char *, ...)
#if !defined(__cplusplus) && (__GNUC__ > 2)
__attribute__((__format__(__printf__, 2, 3)))
#endif
;
-#endif /* have vasprintf and prototype? */
+#endif /* NEED_VASPRINTF_PROTO */
/* Return true if the snprintf return value RESULT reflects a buffer
overflow for the buffer size SIZE.
Added: trunk/libmissing/Makefile.in
===================================================================
--- trunk/libmissing/Makefile.in 2009-07-14 19:23:11 UTC (rev 3268)
+++ trunk/libmissing/Makefile.in 2009-07-20 17:21:24 UTC (rev 3269)
@@ -0,0 +1,31 @@
+mydir=libmissing
+BUILDTOP=$(REL)..
+
+LIBOBJS=@LIBOBJS@
+
+OBJS= dummy.o $(LIBOBJS)
+
+SRCS= $(srcdir)/dummy.c \
+ $(srcdir)/asprintf.c \
+ $(srcdir)/daemon.c \
+ $(srcdir)/getdtablesize.c \
+ $(srcdir)/getopt.c \
+ $(srcdir)/herror.c \
+ $(srcdir)/parsetos.c \
+ $(srcdir)/setenv.c \
+ $(srcdir)/setsid.c \
+ $(srcdir)/strcasecmp.c \
+ $(srcdir)/strdup.c \
+ $(srcdir)/strerror.c \
+ $(srcdir)/strftime.c \
+ $(srcdir)/strlcpy.c
+
+all:: libmissing.a
+
+clean::
+ $(RM) libmissing.a
+
+libmissing.a: $(OBJS)
+ $(RM) $@
+ $(AR) cq $@ $(OBJS)
+ $(RANLIB) $@
Added: trunk/libmissing/asprintf.c
===================================================================
--- trunk/libmissing/asprintf.c 2009-07-14 19:23:11 UTC (rev 3268)
+++ trunk/libmissing/asprintf.c 2009-07-20 17:21:24 UTC (rev 3269)
@@ -0,0 +1,99 @@
+/*
+ * printf.c
+ *
+ * Copyright 2003, 2004, 2005, 2007, 2008 Massachusetts Institute of Technology.
+ * All Rights Reserved.
+ *
+ * Export of this software from the United States of America may
+ * require a specific license from the United States Government.
+ * It is the responsibility of any person or organization contemplating
+ * export to obtain such a license before exporting.
+ *
+ * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
+ * distribute this software and its documentation for any purpose and
+ * without fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright notice and
+ * this permission notice appear in supporting documentation, and that
+ * the name of M.I.T. not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission. Furthermore if you modify this software you must label
+ * your software as modified software and not distribute it in such a
+ * fashion that it might be confused with the original M.I.T. software.
+ * M.I.T. makes no representations about the suitability of
+ * this software for any purpose. It is provided "as is" without express
+ * or implied warranty.
+ *
+ *
+ * Provide {,v}asprintf for platforms that don't have them.
+ */
+
+/* On error: BSD: Set *ret to NULL. GNU: *ret is undefined.
+
+ Since we want to be able to use the GNU version directly, we need
+ provide only the weaker guarantee in this version. */
+int
+vasprintf(char **ret, const char *format, va_list ap)
+{
+ va_list ap2;
+ char *str = NULL, *nstr;
+ size_t len = 80;
+ int len2;
+
+ while (1) {
+ if (len >= INT_MAX || len == 0)
+ goto fail;
+ nstr = realloc(str, len);
+ if (nstr == NULL)
+ goto fail;
+ str = nstr;
+ va_copy(ap2, ap);
+ len2 = vsnprintf(str, len, format, ap2);
+ va_end(ap2);
+ /* ISO C vsnprintf returns the needed length. Some old
+ vsnprintf implementations return -1 on truncation. */
+ if (len2 < 0) {
+ /* Don't know how much space we need, just that we didn't
+ supply enough; get a bigger buffer and try again. */
+ if (len <= SIZE_MAX/2)
+ len *= 2;
+ else if (len < SIZE_MAX)
+ len = SIZE_MAX;
+ else
+ goto fail;
+ } else if ((unsigned int) len2 >= SIZE_MAX) {
+ /* Need more space than we can request. */
+ goto fail;
+ } else if ((size_t) len2 >= len) {
+ /* Need more space, but we know how much. */
+ len = (size_t) len2 + 1;
+ } else {
+ /* Success! */
+ break;
+ }
+ }
+ /* We might've allocated more than we need, if we're still using
+ the initial guess, or we got here by doubling. */
+ if ((size_t) len2 < len - 1) {
+ nstr = realloc(str, (size_t) len2 + 1);
+ if (nstr)
+ str = nstr;
+ }
+ *ret = str;
+ return len2;
+
+fail:
+ free(str);
+ return -1;
+}
+
+int
+asprintf(char **ret, const char *format, ...)
+{
+ va_list ap;
+ int n;
+
+ va_start(ap, format);
+ n = krb5int_vasprintf(ret, format, ap);
+ va_end(ap);
+ return n;
+}
Copied: trunk/libmissing/daemon.c (from rev 3268, trunk/bsd/daemon.c)
Added: trunk/libmissing/deps
===================================================================
--- trunk/libmissing/deps 2009-07-14 19:23:11 UTC (rev 3268)
+++ trunk/libmissing/deps 2009-07-20 17:21:24 UTC (rev 3269)
@@ -0,0 +1,21 @@
+#
+# Generated makefile dependencies follow.
+#
+$(OUTPRE)dummy.$(OBJEXT): dummy.c
+$(OUTPRE)asprintf.$(OBJEXT): asprintf.c
+$(OUTPRE)daemon.$(OBJEXT): $(BUILDTOP)/autoconf.h daemon.c
+$(OUTPRE)getdtablesize.$(OBJEXT): getdtablesize.c
+$(OUTPRE)getopt.$(OBJEXT): $(BUILDTOP)/autoconf.h getopt.c
+$(OUTPRE)herror.$(OBJEXT): $(BUILDTOP)/autoconf.h herror.c
+$(OUTPRE)parsetos.$(OBJEXT): $(BUILDTOP)/autoconf.h \
+ parsetos.c
+$(OUTPRE)setenv.$(OBJEXT): setenv.c
+$(OUTPRE)setsid.$(OBJEXT): $(BUILDTOP)/autoconf.h setsid.c
+$(OUTPRE)strcasecmp.$(OBJEXT): $(BUILDTOP)/autoconf.h \
+ strcasecmp.c
+$(OUTPRE)strdup.$(OBJEXT): $(BUILDTOP)/autoconf.h strdup.c
+$(OUTPRE)strerror.$(OBJEXT): $(BUILDTOP)/autoconf.h \
+ strerror.c
+$(OUTPRE)strftime.$(OBJEXT): $(BUILDTOP)/autoconf.h \
+ strftime.c
+$(OUTPRE)strlcpy.$(OBJEXT): strlcpy.c
Added: trunk/libmissing/dummy.c
===================================================================
--- trunk/libmissing/dummy.c 2009-07-14 19:23:11 UTC (rev 3268)
+++ trunk/libmissing/dummy.c 2009-07-20 17:21:24 UTC (rev 3269)
@@ -0,0 +1 @@
+int lib_missing_dummy = 0;
Copied: trunk/libmissing/getdtablesize.c (from rev 3268, trunk/bsd/getdtablesize.c)
Copied: trunk/libmissing/getopt.c (from rev 3268, trunk/telnet/libtelnet/getopt.c)
Copied: trunk/libmissing/herror.c (from rev 3268, trunk/telnet/libtelnet/herror.c)
===================================================================
--- trunk/telnet/libtelnet/herror.c 2009-07-14 19:23:11 UTC (rev 3268)
+++ trunk/libmissing/herror.c 2009-07-20 17:21:24 UTC (rev 3269)
@@ -0,0 +1,70 @@
+/*
+ * 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.
+ */
+
+/* based on @(#)herror.c 8.1 (Berkeley) 6/4/93 */
+
+#include <autoconf.h>
+
+#include <stdio.h>
+
+char *h_errlist[] = {
+ "Error 0",
+ "Unknown host", /* 1 HOST_NOT_FOUND */
+ "Host name lookup failure", /* 2 TRY_AGAIN */
+ "Unknown server error", /* 3 NO_RECOVERY */
+ "No address associated with name", /* 4 NO_ADDRESS */
+};
+int h_nerr = { sizeof(h_errlist)/sizeof(h_errlist[0]) };
+
+int h_errno; /* In some version of SunOS this is necessary */
+
+/*
+ * herror --
+ * print the error indicated by the h_errno value.
+ */
+herror(s)
+ const char *s;
+{
+ if (s && *s) {
+ fprintf(stderr, "%s: ", s);
+ }
+ if ((h_errno < 0) || (h_errno >= h_nerr)) {
+ fprintf(stderr, "Unknown error\n");
+ } else if (h_errno == 0) {
+#if defined(sun)
+ fprintf(stderr, "Host unknown\n");
+#endif /* defined(sun) */
+ } else {
+ fprintf(stderr, "%s\n", h_errlist[h_errno]);
+ }
+}
Copied: trunk/libmissing/parsetos.c (from rev 3268, trunk/telnet/libtelnet/parsetos.c)
===================================================================
--- trunk/telnet/libtelnet/parsetos.c 2009-07-14 19:23:11 UTC (rev 3268)
+++ trunk/libmissing/parsetos.c 2009-07-20 17:21:24 UTC (rev 3269)
@@ -0,0 +1,40 @@
+
+/*
+ * The routine parsetos() for UNICOS 6.0/6.1, as well as more traditional
+ * Unix systems. This is part of UNICOS 7.0 and later.
+ */
+
+#include <autoconf.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include <netdb.h>
+#include <errno.h>
+
+#define MIN_TOS 0
+#define MAX_TOS 255
+
+int
+parsetos(char *name, char *proto)
+{
+#if 0
+ register char *c;
+#endif
+ int tos;
+
+#ifdef HAVE_GETTOSBYNAME
+ struct tosent *tosp;
+
+ tosp = gettosbyname(name, proto);
+ if (tosp)
+ tos = tosp->t_tos;
+ else
+#endif
+ tos = (int)strtol(name, (char **)NULL, 0);
+
+ if (tos < MIN_TOS || tos > MAX_TOS) {
+ return (-1);
+ }
+ return (tos);
+}
Copied: trunk/libmissing/setenv.c (from rev 3268, trunk/bsd/setenv.c)
===================================================================
--- trunk/bsd/setenv.c 2009-07-14 19:23:11 UTC (rev 3268)
+++ trunk/libmissing/setenv.c 2009-07-20 17:21:24 UTC (rev 3269)
@@ -0,0 +1,161 @@
+/*
+ * Copyright (c) 1987 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley. The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+/* based on @(#)setenv.c 5.2 (Berkeley) 6/27/88 */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+static char *_findenv(char *, int*);
+/*
+ * setenv --
+ * Set the value of the environmental variable "name" to be
+ * "value". If rewrite is set, replace any current value.
+ */
+int
+setenv(name, value, rewrite)
+ register char *name, *value;
+ int rewrite;
+{
+ extern char **environ;
+ static int alloced; /* if allocated space before */
+ register char *C;
+ int l_value, offset;
+
+ if (*value == '=') /* no `=' in value */
+ ++value;
+ l_value = strlen(value);
+ if ((C = _findenv(name, &offset))) { /* find if already exists */
+ if (!rewrite)
+ return(0);
+ if (strlen(C) >= l_value) { /* old larger; copy over */
+ while ((*C++ = *value++));
+ return(0);
+ }
+ }
+ else { /* create new slot */
+ register int cnt;
+ register char **P;
+
+ for (P = environ, cnt = 0; *P; ++P, ++cnt);
+ if (alloced) { /* just increase size */
+ environ = (char **)realloc((char *)environ,
+ (u_int)(sizeof(char *) * (cnt + 2)));
+ if (!environ)
+ return(-1);
+ }
+ else { /* get new space */
+ alloced = 1; /* copy old entries into it */
+ P = (char **)malloc((u_int)(sizeof(char *) *
+ (cnt + 2)));
+ if (!P)
+ return(-1);
+ memcpy(P, environ, cnt * sizeof(char *));
+ environ = P;
+ }
+ environ[cnt + 1] = NULL;
+ offset = cnt;
+ }
+ for (C = name; *C && *C != '='; ++C); /* no `=' in name */
+ if (!(environ[offset] = /* name + `=' + value */
+ malloc((u_int)((int)(C - name) + l_value + 2))))
+ return(-1);
+ for (C = environ[offset]; (*C = *name++) &&( *C != '='); ++C);
+ for (*C++ = '='; (*C++ = *value++););
+ return(0);
+}
+
+/*
+ * unsetenv(name) --
+ * Delete environmental variable "name".
+ */
+void
+unsetenv(name)
+ char *name;
+{
+ extern char **environ;
+ register char **P;
+ int offset;
+
+ while (_findenv(name, &offset)) /* if set multiple times */
+ for (P = &environ[offset];; ++P)
+ if (!(*P = *(P + 1)))
+ break;
+}
+/*
+ * Copyright (c) 1987 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley. The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+/* based on @(#)getenv.c 5.5 (Berkeley) 6/27/88 */
+
+#ifndef HAVE_GETENV
+/*
+ * getenv --
+ * Returns ptr to value associated with name, if any, else NULL.
+ */
+char *
+getenv(name)
+ char *name;
+{
+ int offset;
+
+ return(_findenv(name, &offset));
+}
+#endif
+
+/*
+ * _findenv --
+ * Returns pointer to value associated with name, if any, else NULL.
+ * Sets offset to be the offset of the name/value combination in the
+ * environmental array, for use by setenv(3) and unsetenv(3).
+ * Explicitly removes '=' in argument name.
+ *
+ * This routine *should* be a static; don't use it.
+ */
+static char *
+_findenv(name, offset)
+ register char *name;
+ int *offset;
+{
+ extern char **environ;
+ register unsigned int len;
+ register char **P, *C;
+
+ for (C = name, len = 0; *C && *C != '='; ++C, ++len);
+ for (P = environ; *P; ++P)
+ if (!strncmp(*P, name, len))
+ if (*(C = *P + len) == '=') {
+ *offset = P - environ;
+ return(++C);
+ }
+ return(NULL);
+}
Copied: trunk/libmissing/setsid.c (from rev 3268, trunk/telnet/libtelnet/setsid.c)
Copied: trunk/libmissing/strcasecmp.c (from rev 3268, trunk/telnet/libtelnet/strcasecmp.c)
Copied: trunk/libmissing/strdup.c (from rev 3268, trunk/telnet/libtelnet/strdup.c)
Copied: trunk/libmissing/strerror.c (from rev 3268, trunk/telnet/libtelnet/strerror.c)
Copied: trunk/libmissing/strftime.c (from rev 3268, trunk/telnet/libtelnet/strftime.c)
Added: trunk/libmissing/strlcpy.c
===================================================================
--- trunk/libmissing/strlcpy.c 2009-07-14 19:23:11 UTC (rev 3268)
+++ trunk/libmissing/strlcpy.c 2009-07-20 17:21:24 UTC (rev 3269)
@@ -0,0 +1,86 @@
+/* Provide strlcpy and strlcat for platforms that don't have them. */
+
+/*
+ * Copyright (c) 1998 Todd C. Miller <Todd.Miller at courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/types.h>
+#include <string.h>
+
+/*
+ * Copy src to string dst of size siz. At most siz-1 characters
+ * will be copied. Always NUL terminates (unless siz == 0).
+ * Returns strlen(src); if retval >= siz, truncation occurred.
+ */
+size_t
+strlcpy(char *dst, const char *src, size_t siz)
+{
+ char *d = dst;
+ const char *s = src;
+ size_t n = siz;
+
+ /* Copy as many bytes as will fit */
+ if (n != 0) {
+ while (--n != 0) {
+ if ((*d++ = *s++) == '\0')
+ break;
+ }
+ }
+
+ /* Not enough room in dst, add NUL and traverse rest of src */
+ if (n == 0) {
+ if (siz != 0)
+ *d = '\0'; /* NUL-terminate dst */
+ while (*s++)
+ ;
+ }
+
+ return(s - src - 1); /* count does not include NUL */
+}
+
+/*
+ * Appends src to string dst of size siz (unlike strncat, siz is the
+ * full size of dst, not space left). At most siz-1 characters
+ * will be copied. Always NUL terminates (unless siz <= strlen(dst)).
+ * Returns strlen(src) + MIN(siz, strlen(initial dst)).
+ * If retval >= siz, truncation occurred.
+ */
+size_t
+strlcat(char *dst, const char *src, size_t siz)
+{
+ char *d = dst;
+ const char *s = src;
+ size_t n = siz;
+ size_t dlen;
+
+ /* Find the end of dst and adjust bytes left but don't go past end */
+ while (n-- != 0 && *d != '\0')
+ d++;
+ dlen = d - dst;
+ n = siz - dlen;
+
+ if (n == 0)
+ return(dlen + strlen(s));
+ while (*s != '\0') {
+ if (n != 1) {
+ *d++ = *s;
+ n--;
+ }
+ s++;
+ }
+ *d = '\0';
+
+ return(dlen + (s - src)); /* count does not include NUL */
+}
Modified: trunk/libpty/Makefile.in
===================================================================
--- trunk/libpty/Makefile.in 2009-07-14 19:23:11 UTC (rev 3268)
+++ trunk/libpty/Makefile.in 2009-07-20 17:21:24 UTC (rev 3269)
@@ -17,8 +17,8 @@
$(CC_LINK) -o dump-utmp dump-utmp.o
dump-utmp.o: dump-utmp.c
-pty_paranoia: pty_paranoia.o $(COM_ERR_DEPLIB) $(PTY_DEPLIB)
- $(CC_LINK) -o pty_paranoia pty_paranoia.o $(PTY_LIB) $(LIBS)
+pty_paranoia: pty_paranoia.o $(COM_ERR_DEPLIB) $(PTY_DEPLIB) $(MISSING_LIB)
+ $(CC_LINK) -o pty_paranoia pty_paranoia.o $(PTY_LIB) $(MISSING_LIB) $(LIBS)
check-paranoia: pty_paranoia
$(VALGRIND) ./pty_paranoia
Modified: trunk/pre.in
===================================================================
--- trunk/pre.in 2009-07-14 19:23:11 UTC (rev 3268)
+++ trunk/pre.in 2009-07-20 17:21:24 UTC (rev 3269)
@@ -197,6 +197,8 @@
GSS_LIBS = @GSS_LIBS@
PTY_DEPLIB = $(BUILDTOP)/libpty/libpty.a
PTY_LIB = -L$(BUILDTOP)/libpty -lpty
+MISSING_DEPLIB = $(BUILDTOP)/libmissing/libmissing.a
+MISSING_LIB = -L$(BUILDTOP)/libmissing -lmissing
# libutil for NetBSD, et al. for openpty(), etc.
UTIL_LIB = @UTIL_LIB@
Modified: trunk/telnet/libtelnet/Makefile.in
===================================================================
--- trunk/telnet/libtelnet/Makefile.in 2009-07-14 19:23:11 UTC (rev 3268)
+++ trunk/telnet/libtelnet/Makefile.in 2009-07-20 17:21:24 UTC (rev 3269)
@@ -27,8 +27,6 @@
DEFINES = -DTELNET_BUFSIZE=65535 $(AUTH_DEF)
LIBOBJS=@LIBOBJS@
-SETENVOBJ=@SETENVOBJ@
-
LIBBASE=telnet
LIBMAJOR=0
LIBMINOR=0
@@ -42,19 +40,10 @@
$(srcdir)/kerberos5.c \
$(srcdir)/forward.c \
$(srcdir)/enc_des.c \
- $(srcdir)/setenv.c \
- $(srcdir)/getent.c \
- $(srcdir)/parsetos.c \
- $(srcdir)/strdup.c \
- $(srcdir)/strcasecmp.c \
- $(srcdir)/strchr.c \
- $(srcdir)/strrchr.c \
- $(srcdir)/strftime.c \
- $(srcdir)/strerror.c
+ $(srcdir)/getent.c
-OBJS= auth.o encrypt.o genget.o \
- misc.o kerberos5.o forward.o enc_des.o \
- $(LIBOBJS) getent.o $(SETENVOBJ)
+OBJS= auth.o encrypt.o genget.o misc.o \
+ kerberos5.o forward.o enc_des.o getent.o
TELNET_H= $(srcdir)/../arpa/telnet.h
Modified: trunk/telnet/libtelnet/deps
===================================================================
--- trunk/telnet/libtelnet/deps 2009-07-14 19:23:11 UTC (rev 3268)
+++ trunk/telnet/libtelnet/deps 2009-07-20 17:21:24 UTC (rev 3269)
@@ -19,19 +19,5 @@
$(OUTPRE)enc_des.$(OBJEXT): $(BUILDTOP)/autoconf.h \
$(srcdir)/../arpa/telnet.h enc-proto.h enc_des.c encrypt.h \
key-proto.h misc-proto.h
-$(OUTPRE)setenv.$(OBJEXT): $(BUILDTOP)/autoconf.h misc-proto.h \
- setenv.c
$(OUTPRE)getent.$(OBJEXT): $(BUILDTOP)/autoconf.h getent.c \
gettytab.h
-$(OUTPRE)parsetos.$(OBJEXT): $(BUILDTOP)/autoconf.h \
- misc-proto.h parsetos.c
-$(OUTPRE)strdup.$(OBJEXT): $(BUILDTOP)/autoconf.h strdup.c
-$(OUTPRE)strcasecmp.$(OBJEXT): $(BUILDTOP)/autoconf.h \
- strcasecmp.c
-$(OUTPRE)strchr.$(OBJEXT): $(BUILDTOP)/autoconf.h strchr.c
-$(OUTPRE)strrchr.$(OBJEXT): $(BUILDTOP)/autoconf.h \
- strrchr.c
-$(OUTPRE)strftime.$(OBJEXT): $(BUILDTOP)/autoconf.h \
- strftime.c
-$(OUTPRE)strerror.$(OBJEXT): $(BUILDTOP)/autoconf.h \
- strerror.c
Modified: trunk/telnet/libtelnet/forward.c
===================================================================
--- trunk/telnet/libtelnet/forward.c 2009-07-14 19:23:11 UTC (rev 3268)
+++ trunk/telnet/libtelnet/forward.c 2009-07-20 17:21:24 UTC (rev 3269)
@@ -37,10 +37,6 @@
#include "krb5forw.h"
-#if defined(NEED_SETENV) || defined(NEED_SETENV_PROTO)
-extern int setenv(char *, char *, int);
-#endif
-
extern char *line; /* see sys_term.c */
/* Decode, decrypt and store the forwarded creds in the local ccache. */
Deleted: trunk/telnet/libtelnet/getopt.c
Deleted: trunk/telnet/libtelnet/herror.c
Modified: trunk/telnet/libtelnet/misc-proto.h
===================================================================
--- trunk/telnet/libtelnet/misc-proto.h 2009-07-14 19:23:11 UTC (rev 3268)
+++ trunk/telnet/libtelnet/misc-proto.h 2009-07-20 17:21:24 UTC (rev 3269)
@@ -73,16 +73,4 @@
char *telnet_getenv (char *);
char *telnet_gets (char *, char *, int, int);
-
-#ifdef NEED_PARSETOS
-int parsetos(char *, char *);
#endif
-
-#ifdef NEED_SETENV
-int setenv(const char *, const char *, int);
-#ifndef HAVE_UNSETENV
-void unsetenv(const char *);
-#endif
-#endif
-
-#endif
Modified: trunk/telnet/libtelnet/misc.c
===================================================================
--- trunk/telnet/libtelnet/misc.c 2009-07-14 19:23:11 UTC (rev 3268)
+++ trunk/telnet/libtelnet/misc.c 2009-07-20 17:21:24 UTC (rev 3269)
@@ -71,8 +71,6 @@
auth_encrypt_user(name)
const char *name;
{
- extern char *strdup();
-
if (UserNameRequested)
free(UserNameRequested);
UserNameRequested = name ? strdup(name) : 0;
Deleted: trunk/telnet/libtelnet/parsetos.c
Deleted: trunk/telnet/libtelnet/setenv.c
Deleted: trunk/telnet/libtelnet/setsid.c
Deleted: trunk/telnet/libtelnet/strcasecmp.c
Deleted: trunk/telnet/libtelnet/strchr.c
Deleted: trunk/telnet/libtelnet/strdup.c
Deleted: trunk/telnet/libtelnet/strerror.c
Deleted: trunk/telnet/libtelnet/strftime.c
Deleted: trunk/telnet/libtelnet/strrchr.c
Modified: trunk/telnet/telnet/Makefile.in
===================================================================
--- trunk/telnet/telnet/Makefile.in 2009-07-14 19:23:11 UTC (rev 3268)
+++ trunk/telnet/telnet/Makefile.in 2009-07-20 17:21:24 UTC (rev 3269)
@@ -45,8 +45,8 @@
all:: telnet
-telnet: $(OBJS) ../libtelnet/libtelnet.a
- $(CC_LINK) -o $@ $(OBJS) ../libtelnet/libtelnet.a $(KRB5_BASE_LIBS) $(LIBS)
+telnet: $(OBJS) ../libtelnet/libtelnet.a $(MISSING_DEPLIB)
+ $(CC_LINK) -o $@ $(OBJS) ../libtelnet/libtelnet.a $(MISSING_LIB) $(KRB5_BASE_LIBS) $(LIBS)
clean::
$(RM) telnet
Modified: trunk/telnet/telnet/commands.c
===================================================================
--- trunk/telnet/telnet/commands.c 2009-07-14 19:23:11 UTC (rev 3268)
+++ trunk/telnet/telnet/commands.c 2009-07-20 17:21:24 UTC (rev 3269)
@@ -138,10 +138,6 @@
send_tncmd (void (*func)(), char *, char *);
static int help(int, char **);
-#ifdef NEED_HERROR_PROTO
-extern void herror(const char *);
-#endif
-
typedef struct {
char *name; /* command name */
char *help; /* help string (NULL for no help) */
Modified: trunk/telnet/telnet/main.c
===================================================================
--- trunk/telnet/telnet/main.c 2009-07-14 19:23:11 UTC (rev 3268)
+++ trunk/telnet/telnet/main.c 2009-07-20 17:21:24 UTC (rev 3269)
@@ -56,10 +56,6 @@
#include "externs.h"
#include "defines.h"
-#ifdef NEED_PARSETOS_PROTO
-extern int parsetos(char *, char *);
-#endif
-
#if 0
#define FORWARD
#endif
Modified: trunk/telnet/telnetd/Makefile.in
===================================================================
--- trunk/telnet/telnetd/Makefile.in 2009-07-14 19:23:11 UTC (rev 3268)
+++ trunk/telnet/telnetd/Makefile.in 2009-07-20 17:21:24 UTC (rev 3269)
@@ -42,8 +42,7 @@
$(srcdir)/sys_term.c \
$(srcdir)/utility.c \
$(srcdir)/global.c \
- $(srcdir)/authenc.c \
- $(GETTYSRC)
+ $(srcdir)/authenc.c
OBJS= telnetd.o \
termio-tn.o \
termios-tn.o \
@@ -53,13 +52,12 @@
sys_term.o \
utility.o \
global.o \
- authenc.o \
- $(GETTYOBJ)
+ authenc.o
all:: telnetd
-telnetd: $(OBJS) $(PTY_DEPLIB) ../libtelnet/libtelnet.a
- $(CC_LINK) -o $@ $(OBJS) ../libtelnet/libtelnet.a $(PTY_LIB) $(UTIL_LIB) $(KRB5_BASE_LIBS) $(LIBS)
+telnetd: $(OBJS) $(PTY_DEPLIB) ../libtelnet/libtelnet.a $(MISSING_DEPLIB)
+ $(CC_LINK) -o $@ $(OBJS) ../libtelnet/libtelnet.a $(PTY_LIB) $(UTIL_LIB) $(MISSING_LIB) $(KRB5_BASE_LIBS) $(LIBS)
clean::
$(RM) telnetd
Modified: trunk/telnet/telnetd/ext.h
===================================================================
--- trunk/telnet/telnetd/ext.h 2009-07-14 19:23:11 UTC (rev 3268)
+++ trunk/telnet/telnetd/ext.h 2009-07-20 17:21:24 UTC (rev 3269)
@@ -233,10 +233,3 @@
#if defined(CRAY2) && defined(UNICOS5)
extern int needtermstat;
#endif
-
-#ifdef NEED_UNSETENV_PROTO
-extern void unsetenv(const char *);
-#endif
-#ifdef NEED_SETENV_PROTO
-extern void setenv(const char *, const char *, int);
-#endif
Modified: trunk/tests/resolve/Makefile.in
===================================================================
--- trunk/tests/resolve/Makefile.in 2009-07-14 19:23:11 UTC (rev 3268)
+++ trunk/tests/resolve/Makefile.in 2009-07-20 17:21:24 UTC (rev 3269)
@@ -10,14 +10,14 @@
all:: resolve addrinfo-test fake-addrinfo-test
# KRB5_BASE_LIBS is a cheap way of getting network libraries here.
-resolve: resolve.o
- $(CC_LINK) -o $@ resolve.o $(KRB5_BASE_LIBS) $(LIBS)
+resolve: resolve.o $(MISSING_DEPLIB)
+ $(CC_LINK) -o $@ resolve.o $(MISSING_LIB) $(KRB5_BASE_LIBS) $(LIBS)
-addrinfo-test: addrinfo-test.o
- $(CC_LINK) -o $@ addrinfo-test.o $(KRB5_BASE_LIBS) $(LIBS)
+addrinfo-test: addrinfo-test.o $(MISSING_DEPLIB)
+ $(CC_LINK) -o $@ addrinfo-test.o $(MISSING_LIB) $(KRB5_BASE_LIBS) $(LIBS)
-fake-addrinfo-test: fake-addrinfo-test.o
- $(CC_LINK) -o $@ fake-addrinfo-test.o $(KRB5_BASE_LIBS) $(LIBS)
+fake-addrinfo-test: fake-addrinfo-test.o $(MISSING_DEPLIB)
+ $(CC_LINK) -o $@ fake-addrinfo-test.o $(MISSING_LIB) $(KRB5_BASE_LIBS) $(LIBS)
check:: resolve addrinfo-test fake-addrinfo-test
$(VALGRIND) ./resolve
More information about the Krb5-appl-commits
mailing list