[svn-upgrade] Integrating new upstream version, shadow (19990827)

This commit is contained in:
nekral-guest
2007-10-07 11:44:08 +00:00
parent 45c6603cc8
commit 446e664caa
71 changed files with 12874 additions and 3576 deletions

View File

@@ -1,6 +1,6 @@
# Makefile.in generated automatically by automake 1.3 from Makefile.am
# Makefile.in generated automatically by automake 1.4 from Makefile.am
# Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
# Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
@@ -11,7 +11,7 @@
# PARTICULAR PURPOSE.
SHELL = /bin/sh
SHELL = @SHELL@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
@@ -31,7 +31,7 @@ mandir = @mandir@
includedir = @includedir@
oldincludedir = /usr/include
DISTDIR =
DESTDIR =
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
@@ -45,7 +45,7 @@ AUTOMAKE = @AUTOMAKE@
AUTOHEADER = @AUTOHEADER@
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
INSTALL_DATA = @INSTALL_DATA@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
transform = @program_transform_name@
@@ -58,11 +58,13 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
host_alias = @host_alias@
host_triplet = @host@
AS = @AS@
CATALOGS = @CATALOGS@
CATOBJEXT = @CATOBJEXT@
CC = @CC@
CPP = @CPP@
DATADIRNAME = @DATADIRNAME@
DLLTOOL = @DLLTOOL@
GENCAT = @GENCAT@
GMOFILES = @GMOFILES@
GMSGFMT = @GMSGFMT@
@@ -86,6 +88,7 @@ MAKEINFO = @MAKEINFO@
MKINSTALLDIRS = @MKINSTALLDIRS@
MSGFMT = @MSGFMT@
NM = @NM@
OBJDUMP = @OBJDUMP@
PACKAGE = @PACKAGE@
POFILES = @POFILES@
POSUB = @POSUB@
@@ -99,10 +102,8 @@ l = @l@
AUTOMAKE_OPTIONS = 1.0 foreign
noinst_HEADERS = commonio.h defines.h dialchk.h dialup.h \
faillog.h getdef.h groupio.h md5.h pam_defs.h port.h prototypes.h \
pwauth.h pwio.h rcsid.h sgroupio.h shadowio.h snprintf.h \
tcfsio.h
noinst_HEADERS = commonio.h defines.h dialchk.h dialup.h faillog.h getdef.h groupio.h md5.h pam_defs.h port.h prototypes.h pwauth.h pwio.h rcsid.h sgroupio.h shadowio.h snprintf.h tcfsio.h
localedir = $(datadir)/locale
DEFS = -DLOCALEDIR=\"$(localedir)\" -I. -I$(srcdir) -I.. @DEFS@
@@ -115,24 +116,18 @@ DEFS = -DLOCALEDIR=\"$(localedir)\" -I. -I$(srcdir) -I.. @DEFS@
# sources for LIBOBJS (which are normally in libc)
# misc header sources
EXTRA_DIST = grdbm.c gsdbm.c pwdbm.c spdbm.c \
grpack.c gspack.c pwpack.c sppack.c \
gshadow_.h shadow_.h lastlog_.h snprintf.h
EXTRA_DIST = grdbm.c gsdbm.c pwdbm.c spdbm.c grpack.c gspack.c pwpack.c sppack.c gshadow_.h shadow_.h lastlog_.h snprintf.h
EXTRA_libshadow_a_SOURCESS = grent.c pwent.c mkdir.c rename.c rmdir.c strdup.c strcasecmp.c strerror.c strstr.c putgrent.c putpwent.c putspent.c sgetgrent.c sgetpwent.c sgetspent.c snprintf.c md5.c md5crypt.c
EXTRA_libshadow_a_SOURCESS = grent.c pwent.c \
mkdir.c rename.c rmdir.c strdup.c strcasecmp.c strerror.c strstr.c \
putgrent.c putpwent.c putspent.c \
sgetgrent.c sgetpwent.c sgetspent.c snprintf.c \
md5.c md5crypt.c
# We build libshadow for our tools.
noinst_LIBRARIES = libshadow.a
libshadow_a_SOURCES = commonio.c dialchk.c dialup.c encrypt.c \
fputsx.c getdef.c getpass.c groupio.c gshadow.c lockpw.c port.c \
pwauth.c pwio.c rad64.c sgroupio.c shadow.c shadowio.c utent.c \
tcfsio.c
libshadow_a_SOURCES = commonio.c dialchk.c dialup.c encrypt.c fputsx.c getdef.c getpass.c groupio.c gshadow.c lockpw.c port.c pwauth.c pwio.c rad64.c sgroupio.c shadow.c shadowio.c utent.c tcfsio.c
libshadow_a_LIBADD = @LIBOBJS@
@@ -167,9 +162,10 @@ fputsx.lo getdef.lo getpass.lo groupio.lo gshadow.lo lockpw.lo port.lo \
pwauth.lo pwio.lo rad64.lo sgroupio.lo shadow.lo shadowio.lo utent.lo \
tcfsio.lo
CFLAGS = @CFLAGS@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
LINK = $(LIBTOOL) --mode=link $(CC) $(CFLAGS) $(LDFLAGS) -o $@
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(LDFLAGS) -o $@
HEADERS = $(noinst_HEADERS)
DIST_COMMON = Makefile.am Makefile.in md5.c md5crypt.c mkdir.c \
@@ -181,15 +177,14 @@ strstr.c
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
TAR = tar
GZIP = --best
GZIP_ENV = --best
SOURCES = $(libshadow_a_SOURCES) $(libshadow_la_SOURCES)
OBJECTS = $(libshadow_a_OBJECTS) $(libshadow_la_OBJECTS)
all: Makefile $(LIBRARIES) $(LTLIBRARIES) $(HEADERS)
all: all-redirect
.SUFFIXES:
.SUFFIXES: .S .c .lo .o .s
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
cd $(top_srcdir) && $(AUTOMAKE) --foreign --include-deps lib/Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@@ -263,8 +258,8 @@ install-libLTLIBRARIES: $(lib_LTLIBRARIES)
$(mkinstalldirs) $(DESTDIR)$(libdir)
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
if test -f $$p; then \
echo "$(LIBTOOL) --mode=install $(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$p"; \
$(LIBTOOL) --mode=install $(INSTALL_DATA) $$p $(DESTDIR)$(libdir)/$$p; \
echo "$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p"; \
$(LIBTOOL) --mode=install $(INSTALL) $$p $(DESTDIR)$(libdir)/$$p; \
else :; fi; \
done
@@ -280,8 +275,12 @@ libshadow.la: $(libshadow_la_OBJECTS) $(libshadow_la_DEPENDENCIES)
tags: TAGS
ID: $(HEADERS) $(SOURCES) $(LISP)
list='$(SOURCES) $(HEADERS)'; \
unique=`for i in $$list; do echo $$i; done | \
awk ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
here=`pwd` && cd $(srcdir) \
&& mkid -f$$here/ID $(SOURCES) $(HEADERS) $(LISP)
&& mkid -f$$here/ID $$unique $(LISP)
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) $(LISP)
tags=; \
@@ -309,102 +308,115 @@ subdir = lib
distdir: $(DISTFILES)
@for file in $(DISTFILES); do \
d=$(srcdir); \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $$d/$$file $(distdir)/$$file; \
if test -d $$d/$$file; then \
cp -pr $$/$$file $(distdir)/$$file; \
else \
test -f $(distdir)/$$file \
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|| cp -p $$d/$$file $(distdir)/$$file || :; \
fi; \
done
commonio.o: commonio.c ../config.h rcsid.h defines.h gshadow_.h \
commonio.h
dialchk.o: dialchk.c ../config.h rcsid.h defines.h gshadow_.h \
prototypes.h dialup.h dialchk.h
dialup.o: dialup.c ../config.h rcsid.h prototypes.h defines.h gshadow_.h \
dialup.h
encrypt.o: encrypt.c ../config.h rcsid.h prototypes.h defines.h \
gshadow_.h
fputsx.lo fputsx.o: fputsx.c ../config.h defines.h gshadow_.h rcsid.h
getdef.lo getdef.o: getdef.c ../config.h rcsid.h prototypes.h defines.h \
gshadow_.h getdef.h
getpass.lo getpass.o: getpass.c ../config.h rcsid.h defines.h gshadow_.h
groupio.lo groupio.o: groupio.c ../config.h rcsid.h prototypes.h \
defines.h gshadow_.h commonio.h groupio.h
gshadow.lo gshadow.o: gshadow.c ../config.h rcsid.h prototypes.h \
commonio.lo commonio.o : commonio.c ../config.h rcsid.h defines.h \
gshadow_.h commonio.h
dialchk.lo dialchk.o : dialchk.c ../config.h rcsid.h defines.h \
gshadow_.h prototypes.h dialup.h dialchk.h
dialup.lo dialup.o : dialup.c ../config.h rcsid.h prototypes.h defines.h \
gshadow_.h dialup.h
encrypt.lo encrypt.o : encrypt.c ../config.h rcsid.h prototypes.h \
defines.h gshadow_.h
lockpw.lo lockpw.o: lockpw.c ../config.h
port.lo port.o: port.c ../config.h rcsid.h defines.h gshadow_.h port.h
fputsx.lo fputsx.o : fputsx.c ../config.h defines.h gshadow_.h rcsid.h
getdef.lo getdef.o : getdef.c ../config.h rcsid.h prototypes.h defines.h \
gshadow_.h getdef.h
getpass.lo getpass.o : getpass.c ../config.h rcsid.h defines.h \
gshadow_.h getdef.h
groupio.lo groupio.o : groupio.c ../config.h rcsid.h prototypes.h \
defines.h gshadow_.h commonio.h groupio.h
gshadow.lo gshadow.o : gshadow.c ../config.h rcsid.h prototypes.h \
defines.h gshadow_.h
lockpw.lo lockpw.o : lockpw.c ../config.h
port.lo port.o : port.c ../config.h rcsid.h defines.h gshadow_.h port.h
putgrent.o: putgrent.c ../config.h prototypes.h defines.h gshadow_.h
pwauth.lo pwauth.o: pwauth.c ../config.h rcsid.h prototypes.h defines.h \
pwauth.lo pwauth.o : pwauth.c ../config.h rcsid.h prototypes.h defines.h \
gshadow_.h pwauth.h getdef.h
pwio.lo pwio.o: pwio.c ../config.h rcsid.h prototypes.h defines.h \
pwio.lo pwio.o : pwio.c ../config.h rcsid.h prototypes.h defines.h \
gshadow_.h commonio.h pwio.h
rad64.lo rad64.o: rad64.c ../config.h rcsid.h
rad64.lo rad64.o : rad64.c ../config.h rcsid.h
sgetgrent.o: sgetgrent.c ../config.h rcsid.h defines.h gshadow_.h
sgetpwent.o: sgetpwent.c ../config.h rcsid.h defines.h gshadow_.h
sgroupio.lo sgroupio.o: sgroupio.c ../config.h rcsid.h prototypes.h \
sgroupio.lo sgroupio.o : sgroupio.c ../config.h rcsid.h prototypes.h \
defines.h gshadow_.h commonio.h sgroupio.h
shadowio.lo shadowio.o: shadowio.c ../config.h rcsid.h prototypes.h \
shadowio.lo shadowio.o : shadowio.c ../config.h rcsid.h prototypes.h \
defines.h gshadow_.h commonio.h shadowio.h
shadow.lo shadow.o: shadow.c ../config.h
tcfsio.lo tcfsio.o: tcfsio.c ../config.h
utent.lo utent.o: utent.c ../config.h
shadow.lo shadow.o : shadow.c ../config.h
tcfsio.lo tcfsio.o : tcfsio.c ../config.h
utent.lo utent.o : utent.c ../config.h
info:
dvi:
check: all
$(MAKE)
installcheck:
install-exec: install-libLTLIBRARIES
info-am:
info: info-am
dvi-am:
dvi: dvi-am
check-am: all-am
check: check-am
installcheck-am:
installcheck: installcheck-am
install-exec-am: install-libLTLIBRARIES
@$(NORMAL_INSTALL)
$(MAKE) install-exec-hook
$(MAKE) $(AM_MAKEFLAGS) install-exec-hook
install-exec: install-exec-am
install-data:
@$(NORMAL_INSTALL)
install: install-exec install-data all
@:
uninstall: uninstall-libLTLIBRARIES
install-data-am:
install-data: install-data-am
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
install: install-am
uninstall-am: uninstall-libLTLIBRARIES
uninstall: uninstall-am
all-am: Makefile $(LIBRARIES) $(LTLIBRARIES) $(HEADERS)
all-redirect: all-am
install-strip:
$(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' INSTALL_SCRIPT='$(INSTALL_PROGRAM)' install
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
installdirs:
$(mkinstalldirs) $(DATADIR)$(libdir)
$(mkinstalldirs) $(DESTDIR)$(libdir)
mostlyclean-generic:
-test -z "$(MOSTLYCLEANFILES)" || rm -f $(MOSTLYCLEANFILES)
clean-generic:
-test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
distclean-generic:
-rm -f Makefile $(DISTCLEANFILES)
-rm -f Makefile $(CONFIG_CLEAN_FILES)
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
-test -z "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
-test -z "$(BUILT_SOURCES)" || rm -f $(BUILT_SOURCES)
mostlyclean: mostlyclean-noinstLIBRARIES mostlyclean-compile \
mostlyclean-am: mostlyclean-noinstLIBRARIES mostlyclean-compile \
mostlyclean-libtool mostlyclean-libLTLIBRARIES \
mostlyclean-tags mostlyclean-generic
clean: clean-noinstLIBRARIES clean-compile clean-libtool \
clean-libLTLIBRARIES clean-tags clean-generic \
mostlyclean
mostlyclean: mostlyclean-am
distclean: distclean-noinstLIBRARIES distclean-compile \
clean-am: clean-noinstLIBRARIES clean-compile clean-libtool \
clean-libLTLIBRARIES clean-tags clean-generic \
mostlyclean-am
clean: clean-am
distclean-am: distclean-noinstLIBRARIES distclean-compile \
distclean-libtool distclean-libLTLIBRARIES \
distclean-tags distclean-generic clean
-rm -f config.status
distclean-tags distclean-generic clean-am
-rm -f libtool
maintainer-clean: maintainer-clean-noinstLIBRARIES \
distclean: distclean-am
maintainer-clean-am: maintainer-clean-noinstLIBRARIES \
maintainer-clean-compile maintainer-clean-libtool \
maintainer-clean-libLTLIBRARIES maintainer-clean-tags \
maintainer-clean-generic distclean
maintainer-clean-generic distclean-am
@echo "This command is intended for maintainers to use;"
@echo "it deletes files that may require special tools to rebuild."
maintainer-clean: maintainer-clean-am
.PHONY: mostlyclean-noinstLIBRARIES distclean-noinstLIBRARIES \
clean-noinstLIBRARIES maintainer-clean-noinstLIBRARIES \
mostlyclean-compile distclean-compile clean-compile \
@@ -413,8 +425,10 @@ clean-libtool maintainer-clean-libtool mostlyclean-libLTLIBRARIES \
distclean-libLTLIBRARIES clean-libLTLIBRARIES \
maintainer-clean-libLTLIBRARIES uninstall-libLTLIBRARIES \
install-libLTLIBRARIES tags mostlyclean-tags distclean-tags clean-tags \
maintainer-clean-tags distdir info dvi installcheck install-exec \
install-data install uninstall all installdirs mostlyclean-generic \
maintainer-clean-tags distdir info-am info dvi-am dvi check check-am \
installcheck-am installcheck install-exec-am install-exec \
install-data-am install-data install-am install uninstall-am uninstall \
all-redirect all-am all installdirs mostlyclean-generic \
distclean-generic clean-generic maintainer-clean-generic clean \
mostlyclean distclean maintainer-clean

View File

@@ -1,4 +1,4 @@
/* $Id: defines.h,v 1.14 1999/03/07 19:14:34 marekm Exp $ */
/* $Id: defines.h,v 1.15 1999/08/27 19:02:50 marekm Exp $ */
/* some useful defines */
#ifndef _DEFINES_H_
@@ -203,19 +203,13 @@ char *strchr(), *strrchr(), *strtok();
# define GTTY(fd, termio) tcgetattr(fd, termio)
# define TERMIO struct termios
# define USE_TERMIOS
#elif HAVE_TERMIO_H
#else /* assumed HAVE_TERMIO_H */
# include <sys/ioctl.h>
# include <termio.h>
# define STTY(fd, termio) ioctl(fd, TCSETA, termio)
# define GTTY(fd, termio) ioctl(fd, TCGETA, termio)
# define TEMRIO struct termio
# define USE_TERMIO
#elif HAVE_SGTTY_H
# include <sgtty.h>
# define STTY(fd, termio) stty(fd, termio)
# define GTTY(fd, termio) gtty(fd, termio)
# define TERMIO struct sgttyb
# define USE_SGTTY
#endif
/*

View File

@@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID("$Id: dialchk.c,v 1.5 1998/12/28 20:34:34 marekm Exp $")
RCSID("$Id: dialchk.c,v 1.6 1999/08/27 19:02:51 marekm Exp $")
#include <stdio.h>
#include "defines.h"
@@ -68,7 +68,7 @@ dialcheck(const char *tty, const char *sh)
if (dialup->du_passwd[0] == '\0')
return (1);
if (! (pass = getpass(_("Dialup Password:"))))
if (! (pass = getpass(_("Dialup Password: "))))
return (0);
cp = pw_encrypt (pass, dialup->du_passwd);

View File

@@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID("$Id: getdef.c,v 1.12 1999/03/07 19:14:36 marekm Exp $")
RCSID("$Id: getdef.c,v 1.13 1999/08/27 19:02:51 marekm Exp $")
#include "prototypes.h"
#include "defines.h"
@@ -71,6 +71,7 @@ static struct itemdef def_table[] = {
{ "FAIL_DELAY", NULL },
{ "FAKE_SHELL", NULL },
{ "FTMP_FILE", NULL },
{ "GETPASS_ASTERISKS", NULL },
{ "GID_MAX", NULL },
{ "GID_MIN", NULL },
{ "HUSHLOGIN_FILE", NULL },
@@ -116,6 +117,7 @@ static struct itemdef def_table[] = {
{ "ULIMIT", NULL },
{ "UMASK", NULL },
{ "USERDEL_CMD", NULL },
{ "USERGROUPS_ENAB", NULL }
};
#ifndef LOGINDEFS

View File

@@ -31,13 +31,15 @@
#include <config.h>
#include "rcsid.h"
RCSID("$Id: getpass.c,v 1.9 1999/06/07 16:40:44 marekm Exp $")
RCSID("$Id: getpass.c,v 1.10 1999/08/27 19:02:51 marekm Exp $")
#include "defines.h"
#include <signal.h>
#include <stdio.h>
#include "getdef.h"
/* new code, #undef if there are any problems... */
#define USE_SETJMP 1
@@ -64,26 +66,33 @@ sig_catch(int sig)
#define MAXLEN 127
#ifndef NEW_READPASS /* ./configure --enable-readpass */
#define OLD_READPASS 1
#endif
#ifndef OLD_READPASS
static char *
readpass(FILE *fp)
readpass(FILE *ifp, FILE *ofp, int with_echo, int max_asterisks)
{
static char input[MAXLEN + 1], asterix[MAXLEN + 1];
static char once;
char *cp, *ap, c;
int i;
if (max_asterisks < 0) {
/* traditional code using fgets() */
if (fgets(input, sizeof input, ifp) != input)
return NULL;
cp = strrchr(input, '\n');
if (cp)
*cp = '\0';
else
input[sizeof input - 1] = '\0';
return input;
}
if (!once) {
srandom(time(0)*getpid());
once = 1;
}
cp = input;
ap = asterix;
while (read(fileno(fp), &c, 1)) {
while (read(fileno(ifp), &c, 1)) {
switch (c) {
case '\n':
case '\r':
@@ -91,67 +100,70 @@ readpass(FILE *fp)
case '\b':
case 127:
if (cp > input) {
cp--; ap--;
for (i = 0; i < (*ap); i++) {
putc('\b', stdout);
putc(' ', stdout);
putc('\b', stdout);
}
} else
putc('\a', stdout); /* BEL */
cp--;
ap--;
for (i = *ap; i > 0; i--)
fputs("\b \b", ofp);
*cp = '\0';
*ap = 0;
} else {
putc('\a', ofp); /* BEL */
}
break;
case '\025': /* Ctrl-U = erase everything typed so far */
if (cp == input) {
putc('\a', ofp); /* BEL */
} else while (cp > input) {
cp--;
ap--;
for (i = *ap; i > 0; i--)
fputs("\b \b", ofp);
*cp = '\0';
*ap = 0;
}
break;
default:
*cp++ = c;
*ap++ = (random() % 4)+1;
for (i = 0; i < (*(ap-1)); i++)
putc('*', stdout);
if (with_echo) {
*ap = 1;
putc(c, ofp);
} else if (max_asterisks > 0) {
*ap = (random() % max_asterisks) + 1;
for (i = *ap; i > 0; i--)
putc('*', ofp);
} else {
*ap = 0;
}
ap++;
break;
}
fflush(stdout);
if (cp == input + MAXLEN)
fflush(ofp);
if (cp >= input + MAXLEN) {
putc('\a', ofp); /* BEL */
break;
}
}
endwhile:
*cp = 0;
putc('\n', stdout);
*cp = '\0';
putc('\n', ofp);
return input;
}
#else
static char *
readpass(FILE *fp)
{
static char input[MAXLEN + 1];
char *cp;
if (fgets(input, sizeof input, fp) == input) {
if ((cp = strrchr(input, '\n')))
*cp = '\0';
else
input[sizeof input - 1] = '\0';
#ifdef USE_SGTTY
putc('\n', stdout);
#endif
return input;
}
return NULL;
}
#endif
char *
libshadow_getpass(const char *prompt)
prompt_password(const char *prompt, int with_echo)
{
static char nostring[1] = "";
static char *return_value;
volatile int tty_opened;
static FILE *fp;
static FILE *ifp, *ofp;
volatile int is_tty;
#ifdef HAVE_SIGACTION
struct sigaction old_sigact;
#else
RETSIGTYPE (*old_signal)();
#endif
TERMIO new_modes;
TERMIO old_modes;
int max_asterisks = getdef_num("GETPASS_ASTERISKS", -1);
/*
* set a flag so the SIGINT signal can be re-sent if it
@@ -164,24 +176,26 @@ libshadow_getpass(const char *prompt)
/*
* if /dev/tty can't be opened, getpass() needs to read
* from stdin instead.
* from stdin and write to stderr instead.
*/
if ((fp = fopen ("/dev/tty", "r")) == 0) {
fp = stdin;
setbuf (fp, (char *) 0);
if (!(ifp = fopen("/dev/tty", "r+"))) {
ifp = stdin;
ofp = stderr;
} else {
ofp = ifp;
tty_opened = 1;
}
setbuf(ifp, (char *) 0);
/*
* the current tty modes must be saved so they can be
* restored later on. echo will be turned off, except
* for the newline character (BSD has to punt on this)
* for the newline character
*/
is_tty = 1;
if (GTTY(fileno(fp), &old_modes)) {
if (GTTY(fileno(ifp), &old_modes)) {
is_tty = 0;
#if 0 /* to make getpass work with redirected stdin */
return_value = NULL;
@@ -204,24 +218,25 @@ libshadow_getpass(const char *prompt)
sigact.sa_flags = 0;
sigaction(SIGINT, &sigact, &old_sigact);
#else
old_signal = signal (SIGINT, sig_catch);
#endif
new_modes = old_modes;
#ifdef USE_SGTTY
new_modes.sg_flags &= ~ECHO ;
#else
#ifdef OLD_READPASS
new_modes.c_lflag &= ~(ECHO|ECHOE|ECHOK);
#else
new_modes.c_lflag &= ~(ECHO|ECHOE|ECHOK|ICANON);
#endif
new_modes.c_lflag |= ECHONL;
old_signal = signal(SIGINT, sig_catch);
#endif
if (is_tty) {
if (STTY(fileno(fp), &new_modes))
TERMIO new_modes = old_modes;
if (max_asterisks < 0)
new_modes.c_lflag |= ICANON;
else
new_modes.c_lflag &= ~(ICANON);
if (with_echo)
new_modes.c_lflag |= (ECHO | ECHOE | ECHOK);
else
new_modes.c_lflag &= ~(ECHO | ECHOE | ECHOK);
new_modes.c_lflag |= ECHONL;
if (STTY(fileno(ifp), &new_modes))
goto out;
}
@@ -232,8 +247,8 @@ libshadow_getpass(const char *prompt)
* returned.
*/
if ((fputs(prompt, stdout) != EOF) && (fflush(stdout) != EOF))
return_value = readpass(fp);
if ((fputs(prompt, ofp) != EOF) && (fflush(ofp) != EOF))
return_value = readpass(ifp, ofp, with_echo, max_asterisks);
out:
/*
* the old SIGINT handler is restored after the tty
@@ -243,7 +258,7 @@ out:
*/
if (is_tty) {
if (STTY(fileno(fp), &old_modes))
if (STTY(fileno(ifp), &old_modes))
return_value = NULL;
}
@@ -254,7 +269,7 @@ out:
#endif
out2:
if (tty_opened)
(void) fclose (fp);
(void) fclose(ifp);
if (sig_caught) {
kill(getpid(), SIGINT);
@@ -266,3 +281,16 @@ out2:
}
return return_value;
}
char *
libshadow_getpass(const char *prompt)
{
return prompt_password(prompt, 0);
}
char *
getpass_with_echo(const char *prompt)
{
return prompt_password(prompt, 1);
}

View File

@@ -30,7 +30,7 @@
#include <config.h>
#include "rcsid.h"
RCSID("$Id: pwauth.c,v 1.9 1998/12/28 20:34:38 marekm Exp $")
RCSID("$Id: pwauth.c,v 1.10 1999/08/27 19:02:51 marekm Exp $")
#include <sys/types.h>
#include <signal.h>
@@ -53,10 +53,11 @@ RCSID("$Id: pwauth.c,v 1.9 1998/12/28 20:34:38 marekm Exp $")
#ifdef __linux__ /* standard password prompt by default */
static const char *PROMPT = gettext_noop("Password: ");
#else
static const char *PROMPT = gettext_noop("%s's Password:");
static const char *PROMPT = gettext_noop("%s's Password: ");
#endif
extern char *getpass();
extern char *getpass();
extern char *getpass_with_echo();
#ifdef AUTH_METHODS
/*
@@ -207,7 +208,7 @@ _old_auth(const char *cipher, const char *user, int reason, const char *input)
if (reason != PW_FTP && reason != PW_REXEC && !input) {
if (! (cp = getdef_str ("LOGIN_STRING")))
cp = PROMPT;
cp = _(PROMPT);
#ifdef SKEY
if (use_skey)
printf ("[%s]\n", challenge_info);
@@ -219,7 +220,7 @@ _old_auth(const char *cipher, const char *user, int reason, const char *input)
#endif
snprintf(prompt, sizeof prompt, cp, user);
clear = getpass(_(prompt));
clear = getpass(prompt);
if (!clear) {
static char c[1];
c[0] = '\0';
@@ -249,6 +250,35 @@ _old_auth(const char *cipher, const char *user, int reason, const char *input)
opieverify(&opie, (char *)NULL);
#endif
#if (defined(SKEY) || defined(OPIE))
/*
* If (1) The password fails to match, and
* (2) The password is empty and
* (3) We are using OPIE or S/Key, then
* ...Re-prompt, with echo on.
* -- AR 8/22/1999
*/
if (retval && !input[0] &&
(0
#ifdef SKEY
|| use_skey
#endif
#ifdef OPIE
|| use_opie
#endif
)) {
strncat(prompt, _("(Echo on) "),
(sizeof(prompt) - strlen(prompt)));
clear = getpass_with_echo(prompt);
if (!clear) {
static char c[1];
c[0] = '\0';
clear = c;
}
input = clear;
}
#endif
#ifdef SKEY
if (retval && use_skey) {
int passcheck = -1;
@@ -520,7 +550,7 @@ pw_auth(const char *command, const char *user, int reason, const char *input)
if (strlen (command) >= sizeof buf)
return -1;
strcpy (buf, command); /* safe (because of the above check) --marekm */
strcpy(buf, command); /* safe (because of the above check) --marekm */
/*
* Find each command and make sure it is NUL-terminated. Then