[svn-upgrade] Integrating new upstream version, shadow (4.0.4)
This commit is contained in:
@@ -3,7 +3,7 @@ EXTRA_DOST = .indent.pro
|
||||
|
||||
DEFS = -DHAVE_CONFIG_H
|
||||
|
||||
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/lib
|
||||
INCLUDES = -I$(top_srcdir)/lib
|
||||
|
||||
lib_LTLIBRARIES = libmisc.la
|
||||
|
||||
@@ -36,7 +36,6 @@ libmisc_la_SOURCES = \
|
||||
mail.c \
|
||||
motd.c \
|
||||
myname.c \
|
||||
nscd.c \
|
||||
obscure.c \
|
||||
pam_pass.c \
|
||||
pwd2spwd.c \
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# Makefile.in generated automatically by automake 1.5 from Makefile.am.
|
||||
# Makefile.in generated by automake 1.7.8 from Makefile.am.
|
||||
# @configure_input@
|
||||
|
||||
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
|
||||
# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003
|
||||
# Free Software Foundation, Inc.
|
||||
# This Makefile.in is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@@ -13,105 +14,148 @@
|
||||
|
||||
@SET_MAKE@
|
||||
|
||||
SHELL = @SHELL@
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
VPATH = @srcdir@
|
||||
prefix = @prefix@
|
||||
exec_prefix = @exec_prefix@
|
||||
|
||||
bindir = @bindir@
|
||||
sbindir = @sbindir@
|
||||
libexecdir = @libexecdir@
|
||||
datadir = @datadir@
|
||||
sysconfdir = @sysconfdir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
localstatedir = @localstatedir@
|
||||
libdir = @libdir@
|
||||
infodir = @infodir@
|
||||
mandir = @mandir@
|
||||
includedir = @includedir@
|
||||
oldincludedir = /usr/include
|
||||
pkgdatadir = $(datadir)/@PACKAGE@
|
||||
pkglibdir = $(libdir)/@PACKAGE@
|
||||
pkgincludedir = $(includedir)/@PACKAGE@
|
||||
top_builddir = ..
|
||||
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
|
||||
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
|
||||
INSTALL = @INSTALL@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
install_sh_DATA = $(install_sh) -c -m 644
|
||||
install_sh_PROGRAM = $(install_sh) -c
|
||||
install_sh_SCRIPT = $(install_sh) -c
|
||||
INSTALL_HEADER = $(INSTALL_DATA)
|
||||
transform = @program_transform_name@
|
||||
transform = $(program_transform_name)
|
||||
NORMAL_INSTALL = :
|
||||
PRE_INSTALL = :
|
||||
POST_INSTALL = :
|
||||
NORMAL_UNINSTALL = :
|
||||
PRE_UNINSTALL = :
|
||||
POST_UNINSTALL = :
|
||||
host_alias = @host_alias@
|
||||
host_triplet = @host@
|
||||
ACLOCAL = @ACLOCAL@
|
||||
AMDEP_FALSE = @AMDEP_FALSE@
|
||||
AMDEP_TRUE = @AMDEP_TRUE@
|
||||
AMTAR = @AMTAR@
|
||||
AS = @AS@
|
||||
AR = @AR@
|
||||
AUTOCONF = @AUTOCONF@
|
||||
AUTOHEADER = @AUTOHEADER@
|
||||
AUTOMAKE = @AUTOMAKE@
|
||||
AWK = @AWK@
|
||||
BUILD_INCLUDED_LIBINTL = @BUILD_INCLUDED_LIBINTL@
|
||||
CATALOGS = @CATALOGS@
|
||||
CATOBJEXT = @CATOBJEXT@
|
||||
CC = @CC@
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
CFLAGS = @CFLAGS@
|
||||
CPP = @CPP@
|
||||
DATADIRNAME = @DATADIRNAME@
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
CXX = @CXX@
|
||||
CXXCPP = @CXXCPP@
|
||||
CXXDEPMODE = @CXXDEPMODE@
|
||||
CXXFLAGS = @CXXFLAGS@
|
||||
CYGPATH_W = @CYGPATH_W@
|
||||
|
||||
DEFS = -DHAVE_CONFIG_H
|
||||
DEPDIR = @DEPDIR@
|
||||
DLLTOOL = @DLLTOOL@
|
||||
ECHO = @ECHO@
|
||||
ECHO_C = @ECHO_C@
|
||||
ECHO_N = @ECHO_N@
|
||||
ECHO_T = @ECHO_T@
|
||||
EGREP = @EGREP@
|
||||
EXEEXT = @EXEEXT@
|
||||
GENCAT = @GENCAT@
|
||||
GLIBC21 = @GLIBC21@
|
||||
GMOFILES = @GMOFILES@
|
||||
F77 = @F77@
|
||||
FFLAGS = @FFLAGS@
|
||||
GMSGFMT = @GMSGFMT@
|
||||
INSTALL_DATA = @INSTALL_DATA@
|
||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@
|
||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
||||
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
|
||||
INSTOBJEXT = @INSTOBJEXT@
|
||||
INTLBISON = @INTLBISON@
|
||||
INTLLIBS = @INTLLIBS@
|
||||
INTLOBJS = @INTLOBJS@
|
||||
INTL_LIBTOOL_SUFFIX_PREFIX = @INTL_LIBTOOL_SUFFIX_PREFIX@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBCRACK = @LIBCRACK@
|
||||
LIBCRYPT = @LIBCRYPT@
|
||||
LIBICONV = @LIBICONV@
|
||||
LIBINTL = @LIBINTL@
|
||||
LIBMD = @LIBMD@
|
||||
LIBOBJS = @LIBOBJS@
|
||||
LIBPAM = @LIBPAM@
|
||||
LIBS = @LIBS@
|
||||
LIBSKEY = @LIBSKEY@
|
||||
LIBTCFS = @LIBTCFS@
|
||||
LIBTOOL = @LIBTOOL@
|
||||
LN_S = @LN_S@
|
||||
LTLIBICONV = @LTLIBICONV@
|
||||
LTLIBINTL = @LTLIBINTL@
|
||||
LTLIBOBJS = @LTLIBOBJS@
|
||||
MAINT = @MAINT@
|
||||
MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
|
||||
MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
|
||||
MAKEINFO = @MAKEINFO@
|
||||
MKINSTALLDIRS = @MKINSTALLDIRS@
|
||||
MSGFMT = @MSGFMT@
|
||||
OBJDUMP = @OBJDUMP@
|
||||
MSGMERGE = @MSGMERGE@
|
||||
OBJEXT = @OBJEXT@
|
||||
PACKAGE = @PACKAGE@
|
||||
POFILES = @POFILES@
|
||||
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
|
||||
PACKAGE_NAME = @PACKAGE_NAME@
|
||||
PACKAGE_STRING = @PACKAGE_STRING@
|
||||
PACKAGE_TARNAME = @PACKAGE_TARNAME@
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
PATH_SEPARATOR = @PATH_SEPARATOR@
|
||||
POSUB = @POSUB@
|
||||
RANLIB = @RANLIB@
|
||||
SET_MAKE = @SET_MAKE@
|
||||
SHELL = @SHELL@
|
||||
STRIP = @STRIP@
|
||||
U = @U@
|
||||
USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@
|
||||
USE_NLS = @USE_NLS@
|
||||
VERSION = @VERSION@
|
||||
XGETTEXT = @XGETTEXT@
|
||||
YACC = @YACC@
|
||||
ac_ct_AR = @ac_ct_AR@
|
||||
ac_ct_CC = @ac_ct_CC@
|
||||
ac_ct_CXX = @ac_ct_CXX@
|
||||
ac_ct_F77 = @ac_ct_F77@
|
||||
ac_ct_RANLIB = @ac_ct_RANLIB@
|
||||
ac_ct_STRIP = @ac_ct_STRIP@
|
||||
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
|
||||
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
|
||||
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
|
||||
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
|
||||
am__include = @am__include@
|
||||
am__leading_dot = @am__leading_dot@
|
||||
am__quote = @am__quote@
|
||||
bindir = @bindir@
|
||||
build = @build@
|
||||
build_alias = @build_alias@
|
||||
build_cpu = @build_cpu@
|
||||
build_os = @build_os@
|
||||
build_vendor = @build_vendor@
|
||||
datadir = @datadir@
|
||||
exec_prefix = @exec_prefix@
|
||||
host = @host@
|
||||
host_alias = @host_alias@
|
||||
host_cpu = @host_cpu@
|
||||
host_os = @host_os@
|
||||
host_vendor = @host_vendor@
|
||||
includedir = @includedir@
|
||||
infodir = @infodir@
|
||||
install_sh = @install_sh@
|
||||
libdir = @libdir@
|
||||
libexecdir = @libexecdir@
|
||||
localstatedir = @localstatedir@
|
||||
mandir = @mandir@
|
||||
oldincludedir = @oldincludedir@
|
||||
prefix = @prefix@
|
||||
program_transform_name = @program_transform_name@
|
||||
sbindir = @sbindir@
|
||||
sharedstatedir = @sharedstatedir@
|
||||
sysconfdir = @sysconfdir@
|
||||
target_alias = @target_alias@
|
||||
|
||||
EXTRA_DOST = .indent.pro
|
||||
|
||||
DEFS = -DHAVE_CONFIG_H
|
||||
|
||||
INCLUDES = -I$(top_srcdir) -I$(top_srcdir)/lib
|
||||
INCLUDES = -I$(top_srcdir)/lib
|
||||
|
||||
lib_LTLIBRARIES = libmisc.la
|
||||
|
||||
@@ -144,7 +188,6 @@ libmisc_la_SOURCES = \
|
||||
mail.c \
|
||||
motd.c \
|
||||
myname.c \
|
||||
nscd.c \
|
||||
obscure.c \
|
||||
pam_pass.c \
|
||||
pwd2spwd.c \
|
||||
@@ -169,6 +212,7 @@ libmisc_la_SOURCES = \
|
||||
|
||||
libmisc_la_LIBADD = $(LIBCRACK)
|
||||
subdir = libmisc
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_HEADER = $(top_builddir)/config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
@@ -181,40 +225,39 @@ am_libmisc_la_OBJECTS = addgrps.lo age.lo basename.lo chkname.lo \
|
||||
entry.lo env.lo failure.lo fields.lo getdate.lo hushed.lo \
|
||||
isexpired.lo limits.lo list.lo log.lo login_access.lo \
|
||||
login_desrpc.lo login_krb.lo loginprompt.lo mail.lo motd.lo \
|
||||
myname.lo nscd.lo obscure.lo pam_pass.lo pwd2spwd.lo \
|
||||
pwdcheck.lo pwd_init.lo rlogin.lo salt.lo setugid.lo setup.lo \
|
||||
setupenv.lo shell.lo strtoday.lo sub.lo sulog.lo ttytype.lo \
|
||||
tz.lo ulimit.lo utmp.lo valid.lo xmalloc.lo
|
||||
myname.lo obscure.lo pam_pass.lo pwd2spwd.lo pwdcheck.lo \
|
||||
pwd_init.lo rlogin.lo salt.lo setugid.lo setup.lo setupenv.lo \
|
||||
shell.lo strtoday.lo sub.lo sulog.lo ttytype.lo tz.lo ulimit.lo \
|
||||
utmp.lo valid.lo xmalloc.lo
|
||||
libmisc_la_OBJECTS = $(am_libmisc_la_OBJECTS)
|
||||
|
||||
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBS = @LIBS@
|
||||
depcomp = $(SHELL) $(top_srcdir)/depcomp
|
||||
@AMDEP_TRUE@DEP_FILES = $(DEPDIR)/addgrps.Plo $(DEPDIR)/age.Plo \
|
||||
@AMDEP_TRUE@ $(DEPDIR)/basename.Plo $(DEPDIR)/chkname.Plo \
|
||||
@AMDEP_TRUE@ $(DEPDIR)/chkshell.Plo $(DEPDIR)/chowndir.Plo \
|
||||
@AMDEP_TRUE@ $(DEPDIR)/chowntty.Plo $(DEPDIR)/console.Plo \
|
||||
@AMDEP_TRUE@ $(DEPDIR)/copydir.Plo $(DEPDIR)/entry.Plo \
|
||||
@AMDEP_TRUE@ $(DEPDIR)/env.Plo $(DEPDIR)/failure.Plo \
|
||||
@AMDEP_TRUE@ $(DEPDIR)/fields.Plo $(DEPDIR)/getdate.Plo \
|
||||
@AMDEP_TRUE@ $(DEPDIR)/hushed.Plo $(DEPDIR)/isexpired.Plo \
|
||||
@AMDEP_TRUE@ $(DEPDIR)/limits.Plo $(DEPDIR)/list.Plo \
|
||||
@AMDEP_TRUE@ $(DEPDIR)/log.Plo $(DEPDIR)/login_access.Plo \
|
||||
@AMDEP_TRUE@ $(DEPDIR)/login_desrpc.Plo $(DEPDIR)/login_krb.Plo \
|
||||
@AMDEP_TRUE@ $(DEPDIR)/loginprompt.Plo $(DEPDIR)/mail.Plo \
|
||||
@AMDEP_TRUE@ $(DEPDIR)/motd.Plo $(DEPDIR)/myname.Plo \
|
||||
@AMDEP_TRUE@ $(DEPDIR)/nscd.Plo $(DEPDIR)/obscure.Plo \
|
||||
@AMDEP_TRUE@ $(DEPDIR)/pam_pass.Plo $(DEPDIR)/pwd2spwd.Plo \
|
||||
@AMDEP_TRUE@ $(DEPDIR)/pwd_init.Plo $(DEPDIR)/pwdcheck.Plo \
|
||||
@AMDEP_TRUE@ $(DEPDIR)/rlogin.Plo $(DEPDIR)/salt.Plo \
|
||||
@AMDEP_TRUE@ $(DEPDIR)/setugid.Plo $(DEPDIR)/setup.Plo \
|
||||
@AMDEP_TRUE@ $(DEPDIR)/setupenv.Plo $(DEPDIR)/shell.Plo \
|
||||
@AMDEP_TRUE@ $(DEPDIR)/strtoday.Plo $(DEPDIR)/sub.Plo \
|
||||
@AMDEP_TRUE@ $(DEPDIR)/sulog.Plo $(DEPDIR)/ttytype.Plo \
|
||||
@AMDEP_TRUE@ $(DEPDIR)/tz.Plo $(DEPDIR)/ulimit.Plo \
|
||||
@AMDEP_TRUE@ $(DEPDIR)/utmp.Plo $(DEPDIR)/valid.Plo \
|
||||
@AMDEP_TRUE@ $(DEPDIR)/xmalloc.Plo
|
||||
am__depfiles_maybe = depfiles
|
||||
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/addgrps.Plo ./$(DEPDIR)/age.Plo \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/basename.Plo ./$(DEPDIR)/chkname.Plo \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/chkshell.Plo ./$(DEPDIR)/chowndir.Plo \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/chowntty.Plo ./$(DEPDIR)/console.Plo \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/copydir.Plo ./$(DEPDIR)/entry.Plo \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/env.Plo ./$(DEPDIR)/failure.Plo \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/fields.Plo ./$(DEPDIR)/getdate.Plo \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/hushed.Plo ./$(DEPDIR)/isexpired.Plo \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/limits.Plo ./$(DEPDIR)/list.Plo \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/log.Plo ./$(DEPDIR)/login_access.Plo \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/login_desrpc.Plo \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/login_krb.Plo \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/loginprompt.Plo ./$(DEPDIR)/mail.Plo \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/motd.Plo ./$(DEPDIR)/myname.Plo \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/obscure.Plo ./$(DEPDIR)/pam_pass.Plo \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/pwd2spwd.Plo ./$(DEPDIR)/pwd_init.Plo \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/pwdcheck.Plo ./$(DEPDIR)/rlogin.Plo \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/salt.Plo ./$(DEPDIR)/setugid.Plo \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/setup.Plo ./$(DEPDIR)/setupenv.Plo \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/shell.Plo ./$(DEPDIR)/strtoday.Plo \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/sub.Plo ./$(DEPDIR)/sulog.Plo \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/ttytype.Plo ./$(DEPDIR)/tz.Plo \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/ulimit.Plo ./$(DEPDIR)/utmp.Plo \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/valid.Plo ./$(DEPDIR)/xmalloc.Plo
|
||||
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \
|
||||
@@ -222,52 +265,49 @@ LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \
|
||||
CCLD = $(CC)
|
||||
LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
$(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
CFLAGS = @CFLAGS@
|
||||
YACCCOMPILE = $(YACC) $(YFLAGS) $(AM_YFLAGS)
|
||||
LTYACCCOMPILE = $(LIBTOOL) --mode=compile $(YACC) $(YFLAGS) $(AM_YFLAGS)
|
||||
DIST_SOURCES = $(libmisc_la_SOURCES)
|
||||
DIST_COMMON = Makefile.am Makefile.in getdate.c
|
||||
DIST_COMMON = $(srcdir)/Makefile.in Makefile.am getdate.c
|
||||
SOURCES = $(libmisc_la_SOURCES)
|
||||
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .lo .o .obj .y
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
clean-libtool:
|
||||
-rm -rf .libs _libs
|
||||
|
||||
distclean-libtool:
|
||||
-rm -f libtool
|
||||
$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4)
|
||||
cd $(top_srcdir) && \
|
||||
$(AUTOMAKE) --gnu libmisc/Makefile
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
cd $(top_builddir) && \
|
||||
CONFIG_HEADERS= CONFIG_LINKS= \
|
||||
CONFIG_FILES=$(subdir)/$@ $(SHELL) ./config.status
|
||||
Makefile: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)
|
||||
libLTLIBRARIES_INSTALL = $(INSTALL)
|
||||
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
|
||||
@$(NORMAL_INSTALL)
|
||||
$(mkinstalldirs) $(DESTDIR)$(libdir)
|
||||
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
|
||||
if test -f $$p; then \
|
||||
echo " $(LIBTOOL) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(libdir)/$$p"; \
|
||||
$(LIBTOOL) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(libdir)/$$p; \
|
||||
f="`echo $$p | sed -e 's|^.*/||'`"; \
|
||||
echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(libdir)/$$f"; \
|
||||
$(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) $$p $(DESTDIR)$(libdir)/$$f; \
|
||||
else :; fi; \
|
||||
done
|
||||
|
||||
uninstall-libLTLIBRARIES:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
|
||||
p="`echo $$p | sed -e 's|^.*/||'`"; \
|
||||
echo " $(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p"; \
|
||||
$(LIBTOOL) --mode=uninstall rm -f $(DESTDIR)$(libdir)/$$p; \
|
||||
done
|
||||
|
||||
clean-libLTLIBRARIES:
|
||||
-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
|
||||
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
|
||||
dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
|
||||
test "$$dir" = "$$p" && dir=.; \
|
||||
echo "rm -f \"$${dir}/so_locations\""; \
|
||||
rm -f "$${dir}/so_locations"; \
|
||||
done
|
||||
libmisc.la: $(libmisc_la_OBJECTS) $(libmisc_la_DEPENDENCIES)
|
||||
$(LINK) -rpath $(libdir) $(libmisc_la_LDFLAGS) $(libmisc_la_OBJECTS) $(libmisc_la_LIBADD) $(LIBS)
|
||||
|
||||
@@ -277,134 +317,195 @@ mostlyclean-compile:
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/addgrps.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/age.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/basename.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/chkname.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/chkshell.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/chowndir.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/chowntty.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/console.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/copydir.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/entry.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/env.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/failure.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/fields.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/getdate.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/hushed.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/isexpired.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/limits.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/list.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/log.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/login_access.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/login_desrpc.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/login_krb.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/loginprompt.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/mail.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/motd.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/myname.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/nscd.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/obscure.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/pam_pass.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/pwd2spwd.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/pwd_init.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/pwdcheck.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/rlogin.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/salt.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/setugid.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/setup.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/setupenv.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/shell.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/strtoday.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/sub.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/sulog.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/ttytype.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/tz.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/ulimit.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/utmp.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/valid.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/xmalloc.Plo@am__quote@
|
||||
|
||||
distclean-depend:
|
||||
-rm -rf $(DEPDIR)
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/addgrps.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/age.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/basename.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chkname.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chkshell.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chowndir.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chowntty.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/console.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/copydir.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/entry.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/env.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/failure.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/fields.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getdate.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hushed.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/isexpired.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/limits.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/list.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/login_access.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/login_desrpc.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/login_krb.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/loginprompt.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mail.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/motd.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/myname.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/obscure.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pam_pass.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pwd2spwd.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pwd_init.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pwdcheck.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rlogin.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/salt.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/setugid.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/setup.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/setupenv.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shell.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strtoday.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sub.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sulog.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ttytype.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tz.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ulimit.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utmp.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/valid.Plo@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xmalloc.Plo@am__quote@
|
||||
|
||||
.c.o:
|
||||
@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
$(COMPILE) -c `test -f $< || echo '$(srcdir)/'`$<
|
||||
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
|
||||
@am__fastdepCC_TRUE@ -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
|
||||
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
|
||||
@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
|
||||
@am__fastdepCC_TRUE@ fi
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(COMPILE) -c `test -f '$<' || echo '$(srcdir)/'`$<
|
||||
|
||||
.c.obj:
|
||||
@AMDEP_TRUE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
$(COMPILE) -c `cygpath -w $<`
|
||||
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
|
||||
@am__fastdepCC_TRUE@ -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \
|
||||
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \
|
||||
@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
|
||||
@am__fastdepCC_TRUE@ fi
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(COMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`
|
||||
|
||||
.c.lo:
|
||||
@AMDEP_TRUE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@ depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
$(LTCOMPILE) -c -o $@ `test -f $< || echo '$(srcdir)/'`$<
|
||||
CCDEPMODE = @CCDEPMODE@
|
||||
@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
|
||||
@am__fastdepCC_TRUE@ -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
|
||||
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; \
|
||||
@am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \
|
||||
@am__fastdepCC_TRUE@ fi
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Plo' tmpdepfile='$(DEPDIR)/$*.TPlo' @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<
|
||||
|
||||
.y.c:
|
||||
$(YACCCOMPILE) $< && mv y.tab.c $@
|
||||
$(YACCCOMPILE) `test -f '$<' || echo '$(srcdir)/'`$<
|
||||
if test -f y.tab.h; then \
|
||||
if cmp -s y.tab.h $*.h; then \
|
||||
rm -f y.tab.h; \
|
||||
to=`echo "$*_H" | sed \
|
||||
-e 'y/abcdefghijklmnopqrstuvwxyz/ABCDEFGHIJKLMNOPQRSTUVWXYZ/' \
|
||||
-e 's/[^ABCDEFGHIJKLMNOPQRSTUVWXYZ]/_/g'`; \
|
||||
sed "/^#/ s/Y_TAB_H/$$to/g" y.tab.h >$*.ht; \
|
||||
rm -f y.tab.h; \
|
||||
if cmp -s $*.ht $*.h; then \
|
||||
rm -f $*.ht ;\
|
||||
else \
|
||||
mv y.tab.h $*.h; \
|
||||
mv $*.ht $*.h; \
|
||||
fi; \
|
||||
fi
|
||||
if test -f y.output; then \
|
||||
mv y.output $*.output; \
|
||||
fi
|
||||
sed '/^#/ s|y\.tab\.c|$@|' y.tab.c >$@t && mv $@t $@
|
||||
rm -f y.tab.c
|
||||
|
||||
mostlyclean-libtool:
|
||||
-rm -f *.lo
|
||||
|
||||
clean-libtool:
|
||||
-rm -rf .libs _libs
|
||||
|
||||
distclean-libtool:
|
||||
-rm -f libtool
|
||||
uninstall-info-am:
|
||||
|
||||
ETAGS = etags
|
||||
ETAGSFLAGS =
|
||||
|
||||
CTAGS = ctags
|
||||
CTAGSFLAGS =
|
||||
|
||||
tags: TAGS
|
||||
|
||||
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
|
||||
list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
mkid -fID $$unique $(LISP)
|
||||
mkid -fID $$unique
|
||||
|
||||
TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
tags=; \
|
||||
here=`pwd`; \
|
||||
list='$(SOURCES) $(HEADERS) $(TAGS_FILES)'; \
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \
|
||||
|| etags $(ETAGS_ARGS) $$tags $$unique $(LISP)
|
||||
test -z "$(ETAGS_ARGS)$$tags$$unique" \
|
||||
|| $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
|
||||
$$tags $$unique
|
||||
|
||||
ctags: CTAGS
|
||||
CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
|
||||
$(TAGS_FILES) $(LISP)
|
||||
tags=; \
|
||||
here=`pwd`; \
|
||||
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
|
||||
unique=`for i in $$list; do \
|
||||
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
|
||||
done | \
|
||||
$(AWK) ' { files[$$0] = 1; } \
|
||||
END { for (i in files) print i; }'`; \
|
||||
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|
||||
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
|
||||
$$tags $$unique
|
||||
|
||||
GTAGS:
|
||||
here=`CDPATH=: && cd $(top_builddir) && pwd` \
|
||||
here=`$(am__cd) $(top_builddir) && pwd` \
|
||||
&& cd $(top_srcdir) \
|
||||
&& gtags -i $(GTAGS_ARGS) $$here
|
||||
|
||||
distclean-tags:
|
||||
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH
|
||||
|
||||
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
|
||||
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
|
||||
|
||||
top_distdir = ..
|
||||
distdir = $(top_distdir)/$(PACKAGE)-$(VERSION)
|
||||
|
||||
distdir: $(DISTFILES)
|
||||
@for file in $(DISTFILES); do \
|
||||
if test -f $$file; then d=.; else d=$(srcdir); fi; \
|
||||
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
|
||||
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
|
||||
list='$(DISTFILES)'; for file in $$list; do \
|
||||
case $$file in \
|
||||
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
|
||||
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
|
||||
esac; \
|
||||
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
|
||||
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
|
||||
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
|
||||
$(mkinstalldirs) "$(distdir)/$$dir"; \
|
||||
dir="/$$dir"; \
|
||||
$(mkinstalldirs) "$(distdir)$$dir"; \
|
||||
else \
|
||||
dir=''; \
|
||||
fi; \
|
||||
if test -d $$d/$$file; then \
|
||||
cp -pR $$d/$$file $(distdir) \
|
||||
|| exit 1; \
|
||||
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
|
||||
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
|
||||
fi; \
|
||||
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
|
||||
else \
|
||||
test -f $(distdir)/$$file \
|
||||
|| cp -p $$d/$$file $(distdir)/$$file \
|
||||
@@ -417,7 +518,6 @@ all-am: Makefile $(LTLIBRARIES)
|
||||
|
||||
installdirs:
|
||||
$(mkinstalldirs) $(DESTDIR)$(libdir)
|
||||
|
||||
install: install-am
|
||||
install-exec: install-exec-am
|
||||
install-data: install-data-am
|
||||
@@ -429,6 +529,7 @@ install-am: all-am
|
||||
installcheck: installcheck-am
|
||||
install-strip:
|
||||
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
|
||||
INSTALL_STRIP_FLAG=-s \
|
||||
`test -z '$(STRIP)' || \
|
||||
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
|
||||
mostlyclean-generic:
|
||||
@@ -436,20 +537,22 @@ mostlyclean-generic:
|
||||
clean-generic:
|
||||
|
||||
distclean-generic:
|
||||
-rm -f Makefile $(CONFIG_CLEAN_FILES) stamp-h stamp-h[0-9]*
|
||||
-rm -f $(CONFIG_CLEAN_FILES)
|
||||
|
||||
maintainer-clean-generic:
|
||||
@echo "This command is intended for maintainers to use"
|
||||
@echo "it deletes files that may require special tools to rebuild."
|
||||
-rm -f getdate.c
|
||||
clean: clean-am
|
||||
|
||||
clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
|
||||
mostlyclean-am
|
||||
|
||||
distclean: distclean-am
|
||||
|
||||
distclean-am: clean-am distclean-compile distclean-depend \
|
||||
distclean-generic distclean-libtool distclean-tags
|
||||
-rm -rf ./$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
distclean-am: clean-am distclean-compile distclean-generic \
|
||||
distclean-libtool distclean-tags
|
||||
|
||||
dvi: dvi-am
|
||||
|
||||
@@ -470,7 +573,8 @@ install-man:
|
||||
installcheck-am:
|
||||
|
||||
maintainer-clean: maintainer-clean-am
|
||||
|
||||
-rm -rf ./$(DEPDIR)
|
||||
-rm -f Makefile
|
||||
maintainer-clean-am: distclean-am maintainer-clean-generic
|
||||
|
||||
mostlyclean: mostlyclean-am
|
||||
@@ -478,19 +582,28 @@ mostlyclean: mostlyclean-am
|
||||
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
|
||||
mostlyclean-libtool
|
||||
|
||||
pdf: pdf-am
|
||||
|
||||
pdf-am:
|
||||
|
||||
ps: ps-am
|
||||
|
||||
ps-am:
|
||||
|
||||
uninstall-am: uninstall-info-am uninstall-libLTLIBRARIES
|
||||
|
||||
.PHONY: GTAGS all all-am check check-am clean clean-generic \
|
||||
clean-libLTLIBRARIES clean-libtool distclean distclean-compile \
|
||||
distclean-depend distclean-generic distclean-libtool \
|
||||
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
|
||||
clean-libLTLIBRARIES clean-libtool ctags distclean \
|
||||
distclean-compile distclean-generic distclean-libtool \
|
||||
distclean-tags distdir dvi dvi-am info info-am install \
|
||||
install-am install-data install-data-am install-exec \
|
||||
install-exec-am install-info install-info-am \
|
||||
install-libLTLIBRARIES install-man install-strip installcheck \
|
||||
installcheck-am installdirs maintainer-clean \
|
||||
maintainer-clean-generic mostlyclean mostlyclean-compile \
|
||||
mostlyclean-generic mostlyclean-libtool tags uninstall \
|
||||
uninstall-am uninstall-info-am uninstall-libLTLIBRARIES
|
||||
mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
|
||||
tags uninstall uninstall-am uninstall-info-am \
|
||||
uninstall-libLTLIBRARIES
|
||||
|
||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
||||
|
||||
@@ -10,18 +10,14 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: addgrps.c,v 1.5 2001/09/01 04:19:15 kloczek Exp $")
|
||||
|
||||
RCSID ("$Id: addgrps.c,v 1.6 2003/04/22 10:59:21 kloczek Exp $")
|
||||
#define SEP ",:"
|
||||
|
||||
/*
|
||||
* Add groups with names from LIST (separated by commas or colons)
|
||||
* to the supplementary group set. Silently ignore groups which are
|
||||
* already there. Warning: uses strtok().
|
||||
*/
|
||||
|
||||
int
|
||||
add_groups(const char *list)
|
||||
int add_groups (const char *list)
|
||||
{
|
||||
GETGROUPS_T *grouplist, *tmp;
|
||||
int i, ngroups, added;
|
||||
@@ -29,51 +25,54 @@ add_groups(const char *list)
|
||||
char *token;
|
||||
char buf[1024];
|
||||
|
||||
if (strlen(list) >= sizeof(buf)) {
|
||||
if (strlen (list) >= sizeof (buf)) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
strcpy(buf, list);
|
||||
strcpy (buf, list);
|
||||
|
||||
i = 16;
|
||||
for (;;) {
|
||||
grouplist = malloc(i * sizeof(GETGROUPS_T));
|
||||
grouplist = malloc (i * sizeof (GETGROUPS_T));
|
||||
if (!grouplist)
|
||||
return -1;
|
||||
ngroups = getgroups(i, grouplist);
|
||||
ngroups = getgroups (i, grouplist);
|
||||
if (i > ngroups)
|
||||
break;
|
||||
/* not enough room, so try allocating a larger buffer */
|
||||
free(grouplist);
|
||||
free (grouplist);
|
||||
i *= 2;
|
||||
}
|
||||
if (ngroups < 0) {
|
||||
free(grouplist);
|
||||
free (grouplist);
|
||||
return -1;
|
||||
}
|
||||
|
||||
added = 0;
|
||||
for (token = strtok(buf, SEP); token; token = strtok(NULL, SEP)) {
|
||||
for (token = strtok (buf, SEP); token; token = strtok (NULL, SEP)) {
|
||||
|
||||
grp = getgrnam(token);
|
||||
grp = getgrnam (token);
|
||||
if (!grp) {
|
||||
fprintf(stderr, _("Warning: unknown group %s\n"), token);
|
||||
fprintf (stderr, _("Warning: unknown group %s\n"),
|
||||
token);
|
||||
continue;
|
||||
}
|
||||
|
||||
for (i = 0; i < ngroups && grouplist[i] != grp->gr_gid; i++)
|
||||
;
|
||||
for (i = 0; i < ngroups && grouplist[i] != grp->gr_gid;
|
||||
i++);
|
||||
|
||||
if (i < ngroups)
|
||||
continue;
|
||||
|
||||
if (ngroups >= sysconf(_SC_NGROUPS_MAX)) {
|
||||
fprintf(stderr, _("Warning: too many groups\n"));
|
||||
if (ngroups >= sysconf (_SC_NGROUPS_MAX)) {
|
||||
fprintf (stderr, _("Warning: too many groups\n"));
|
||||
break;
|
||||
}
|
||||
tmp = realloc(grouplist, (ngroups + 1) * sizeof(GETGROUPS_T));
|
||||
tmp =
|
||||
realloc (grouplist,
|
||||
(ngroups + 1) * sizeof (GETGROUPS_T));
|
||||
if (!tmp) {
|
||||
free(grouplist);
|
||||
free (grouplist);
|
||||
return -1;
|
||||
}
|
||||
tmp[ngroups++] = grp->gr_gid;
|
||||
@@ -82,7 +81,7 @@ add_groups(const char *list)
|
||||
}
|
||||
|
||||
if (added)
|
||||
return setgroups(ngroups, grouplist);
|
||||
return setgroups (ngroups, grouplist);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -41,27 +41,23 @@
|
||||
#if defined(SHADOWPWD)
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: age.c,v 1.7 2001/12/22 06:59:30 kloczek Exp $")
|
||||
|
||||
RCSID ("$Id: age.c,v 1.8 2003/04/22 10:59:21 kloczek Exp $")
|
||||
#ifndef PASSWD_PROGRAM
|
||||
#define PASSWD_PROGRAM "/bin/passwd"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* expire - force password change if password expired
|
||||
*
|
||||
* expire() calls /bin/passwd to change the user's password
|
||||
* if it has expired.
|
||||
*/
|
||||
|
||||
int
|
||||
expire(const struct passwd *pw, const struct spwd *sp)
|
||||
int expire (const struct passwd *pw, const struct spwd *sp)
|
||||
{
|
||||
int status;
|
||||
int child;
|
||||
int pid;
|
||||
int status;
|
||||
int child;
|
||||
int pid;
|
||||
|
||||
if (! sp)
|
||||
if (!sp)
|
||||
sp = pwd_to_spwd (pw);
|
||||
|
||||
/*
|
||||
@@ -69,19 +65,18 @@ expire(const struct passwd *pw, const struct spwd *sp)
|
||||
* force them to change their password.
|
||||
*/
|
||||
|
||||
switch (status = isexpired (pw, sp))
|
||||
{
|
||||
case 0:
|
||||
return 0;
|
||||
case 1:
|
||||
printf(_("Your password has expired."));
|
||||
break;
|
||||
case 2:
|
||||
printf(_("Your password is inactive."));
|
||||
break;
|
||||
case 3:
|
||||
printf(_("Your login has expired."));
|
||||
break;
|
||||
switch (status = isexpired (pw, sp)) {
|
||||
case 0:
|
||||
return 0;
|
||||
case 1:
|
||||
printf (_("Your password has expired."));
|
||||
break;
|
||||
case 2:
|
||||
printf (_("Your password is inactive."));
|
||||
break;
|
||||
case 3:
|
||||
printf (_("Your login has expired."));
|
||||
break;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -91,12 +86,11 @@ expire(const struct passwd *pw, const struct spwd *sp)
|
||||
* change that password.
|
||||
*/
|
||||
|
||||
if (status > 1 || sp->sp_max < sp->sp_min)
|
||||
{
|
||||
puts(_(" Contact the system administrator.\n"));
|
||||
exit(1);
|
||||
if (status > 1 || sp->sp_max < sp->sp_min) {
|
||||
puts (_(" Contact the system administrator.\n"));
|
||||
exit (1);
|
||||
}
|
||||
puts(_(" Choose a new password.\n"));
|
||||
puts (_(" Choose a new password.\n"));
|
||||
fflush (stdout);
|
||||
|
||||
/*
|
||||
@@ -125,26 +119,25 @@ expire(const struct passwd *pw, const struct spwd *sp)
|
||||
* passwd to work just like it would had they executed
|
||||
* it from the command line while logged in.
|
||||
*/
|
||||
if (setup_uid_gid(pw, 0))
|
||||
_exit(126);
|
||||
if (setup_uid_gid (pw, 0))
|
||||
_exit (126);
|
||||
|
||||
execl(PASSWD_PROGRAM, PASSWD_PROGRAM, pw->pw_name, (char *)0);
|
||||
execl (PASSWD_PROGRAM, PASSWD_PROGRAM, pw->pw_name,
|
||||
(char *) 0);
|
||||
err = errno;
|
||||
perror("Can't execute " PASSWD_PROGRAM);
|
||||
_exit((err == ENOENT) ? 127 : 126);
|
||||
perror ("Can't execute " PASSWD_PROGRAM);
|
||||
_exit ((err == ENOENT) ? 127 : 126);
|
||||
} else if (pid == -1) {
|
||||
perror("fork");
|
||||
exit(1);
|
||||
perror ("fork");
|
||||
exit (1);
|
||||
}
|
||||
while ((child = wait (&status)) != pid && child != -1)
|
||||
;
|
||||
while ((child = wait (&status)) != pid && child != -1);
|
||||
|
||||
if (child == pid && status == 0)
|
||||
return 1;
|
||||
|
||||
exit (1);
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
/*NOTREACHED*/}
|
||||
|
||||
/*
|
||||
* agecheck - see if warning is needed for password expiration
|
||||
@@ -153,13 +146,12 @@ expire(const struct passwd *pw, const struct spwd *sp)
|
||||
* to expire and warns the user of the pending password expiration.
|
||||
*/
|
||||
|
||||
void
|
||||
agecheck(const struct passwd *pw, const struct spwd *sp)
|
||||
void agecheck (const struct passwd *pw, const struct spwd *sp)
|
||||
{
|
||||
long now = time ((long *) 0) / SCALE;
|
||||
long remain;
|
||||
long now = time ((long *) 0) / SCALE;
|
||||
long remain;
|
||||
|
||||
if (! sp)
|
||||
if (!sp)
|
||||
sp = pwd_to_spwd (pw);
|
||||
|
||||
/*
|
||||
@@ -169,15 +161,17 @@ agecheck(const struct passwd *pw, const struct spwd *sp)
|
||||
|
||||
if (sp->sp_lstchg == -1 || sp->sp_max == -1 || sp->sp_warn == -1)
|
||||
return;
|
||||
if ((remain = (sp->sp_lstchg + sp->sp_max) - now) <= sp->sp_warn)
|
||||
{
|
||||
remain /= DAY/SCALE;
|
||||
if ((remain = (sp->sp_lstchg + sp->sp_max) - now) <= sp->sp_warn) {
|
||||
remain /= DAY / SCALE;
|
||||
if (remain > 1)
|
||||
printf(_("Your password will expire in %ld days.\n"), remain);
|
||||
printf (_
|
||||
("Your password will expire in %ld days.\n"),
|
||||
remain);
|
||||
else if (remain == 1)
|
||||
printf(_("Your password will expire tomorrow.\n"));
|
||||
printf (_
|
||||
("Your password will expire tomorrow.\n"));
|
||||
else if (remain == 0)
|
||||
printf(_("Your password will expire today.\n"));
|
||||
printf (_("Your password will expire today.\n"));
|
||||
}
|
||||
}
|
||||
#endif /* SHADOWPWD */
|
||||
#endif /* SHADOWPWD */
|
||||
|
||||
@@ -8,15 +8,12 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: basename.c,v 1.2 1997/12/07 23:27:00 marekm Exp $")
|
||||
|
||||
RCSID ("$Id: basename.c,v 1.3 2003/04/22 10:59:21 kloczek Exp $")
|
||||
#include "defines.h"
|
||||
#include "prototypes.h"
|
||||
|
||||
char *
|
||||
Basename(char *str)
|
||||
char *Basename (char *str)
|
||||
{
|
||||
char *cp = strrchr(str, '/');
|
||||
char *cp = strrchr (str, '/');
|
||||
|
||||
return cp ? cp+1 : str;
|
||||
return cp ? cp + 1 : str;
|
||||
}
|
||||
|
||||
@@ -6,20 +6,16 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: chkname.c,v 1.6 2002/01/10 13:04:34 kloczek Exp $")
|
||||
|
||||
RCSID ("$Id: chkname.c,v 1.8 2003/05/12 05:29:14 kloczek Exp $")
|
||||
#include <ctype.h>
|
||||
#include "defines.h"
|
||||
#include "chkname.h"
|
||||
|
||||
#if HAVE_UTMPX_H
|
||||
#include <utmpx.h>
|
||||
#else
|
||||
#include <utmp.h>
|
||||
#endif
|
||||
|
||||
static int
|
||||
good_name(const char *name)
|
||||
static int good_name (const char *name)
|
||||
{
|
||||
/*
|
||||
* User/group names must match [a-z_][a-z0-9_-]*
|
||||
@@ -29,17 +25,16 @@ good_name(const char *name)
|
||||
|
||||
while (*++name) {
|
||||
if (!((*name >= 'a' && *name <= 'z') ||
|
||||
(*name >= '0' && *name <= '9') ||
|
||||
*name == '_' || *name == '-' ||
|
||||
(*name == '$' && *(name+1) == NULL)))
|
||||
(*name >= '0' && *name <= '9') ||
|
||||
*name == '_' || *name == '-' ||
|
||||
(*name == '$' && *(name + 1) == '\0')))
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
check_user_name(const char *name)
|
||||
int check_user_name (const char *name)
|
||||
{
|
||||
#if HAVE_UTMPX_H
|
||||
struct utmpx ut;
|
||||
@@ -51,21 +46,20 @@ check_user_name(const char *name)
|
||||
* User names are limited by whatever utmp can
|
||||
* handle (usually max 8 characters).
|
||||
*/
|
||||
if (strlen(name) > sizeof(ut.ut_user))
|
||||
if (strlen (name) > sizeof (ut.ut_user))
|
||||
return 0;
|
||||
|
||||
return good_name(name);
|
||||
return good_name (name);
|
||||
}
|
||||
|
||||
int
|
||||
check_group_name(const char *name)
|
||||
int check_group_name (const char *name)
|
||||
{
|
||||
/*
|
||||
* Arbitrary limit for group names - max 16
|
||||
* characters (same as on HP-UX 10).
|
||||
*/
|
||||
if (strlen(name) > 16)
|
||||
if (strlen (name) > 16)
|
||||
return 0;
|
||||
|
||||
return good_name(name);
|
||||
return good_name (name);
|
||||
}
|
||||
|
||||
@@ -30,18 +30,15 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: chkshell.c,v 1.1 1997/12/07 23:27:00 marekm Exp $")
|
||||
|
||||
RCSID ("$Id: chkshell.c,v 1.2 2003/04/22 10:59:21 kloczek Exp $")
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
|
||||
#ifndef SHELLS_FILE
|
||||
#define SHELLS_FILE "/etc/shells"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* check_shell - see if the user's login shell is listed in /etc/shells
|
||||
*
|
||||
@@ -52,35 +49,34 @@ RCSID("$Id: chkshell.c,v 1.1 1997/12/07 23:27:00 marekm Exp $")
|
||||
* If getusershell() is available (Linux, *BSD, possibly others), use it
|
||||
* instead of re-implementing it.
|
||||
*/
|
||||
|
||||
int
|
||||
check_shell(const char *sh)
|
||||
int check_shell (const char *sh)
|
||||
{
|
||||
char *cp;
|
||||
char *cp;
|
||||
int found = 0;
|
||||
|
||||
#ifndef HAVE_GETUSERSHELL
|
||||
char buf[BUFSIZ];
|
||||
FILE *fp;
|
||||
char buf[BUFSIZ];
|
||||
FILE *fp;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GETUSERSHELL
|
||||
setusershell();
|
||||
while ((cp = getusershell())) {
|
||||
setusershell ();
|
||||
while ((cp = getusershell ())) {
|
||||
if (*cp == '#')
|
||||
continue;
|
||||
|
||||
if (strcmp(cp, sh) == 0) {
|
||||
if (strcmp (cp, sh) == 0) {
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
endusershell();
|
||||
endusershell ();
|
||||
#else
|
||||
if ((fp = fopen (SHELLS_FILE, "r")) == (FILE *) 0)
|
||||
return 0;
|
||||
|
||||
while (fgets (buf, sizeof(buf), fp)) {
|
||||
if ((cp = strrchr(buf, '\n')))
|
||||
while (fgets (buf, sizeof (buf), fp)) {
|
||||
if ((cp = strrchr (buf, '\n')))
|
||||
*cp = '\0';
|
||||
|
||||
if (buf[0] == '#')
|
||||
@@ -95,4 +91,3 @@ check_shell(const char *sh)
|
||||
#endif
|
||||
return found;
|
||||
}
|
||||
|
||||
|
||||
@@ -30,38 +30,35 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: chowndir.c,v 1.6 2000/08/26 18:27:17 marekm Exp $")
|
||||
|
||||
RCSID ("$Id: chowndir.c,v 1.7 2003/04/22 10:59:21 kloczek Exp $")
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
|
||||
/*
|
||||
* chown_tree - change ownership of files in a directory tree
|
||||
*
|
||||
* chown_dir() walks a directory tree and changes the ownership
|
||||
* of all files owned by the provided user ID.
|
||||
*/
|
||||
|
||||
int
|
||||
chown_tree(const char *root, uid_t old_uid, uid_t new_uid, gid_t old_gid, gid_t new_gid)
|
||||
chown_tree (const char *root, uid_t old_uid, uid_t new_uid, gid_t old_gid,
|
||||
gid_t new_gid)
|
||||
{
|
||||
char new_name[1024];
|
||||
int rc = 0;
|
||||
struct DIRECT *ent;
|
||||
struct stat sb;
|
||||
DIR *dir;
|
||||
char new_name[1024];
|
||||
int rc = 0;
|
||||
struct DIRECT *ent;
|
||||
struct stat sb;
|
||||
DIR *dir;
|
||||
|
||||
/*
|
||||
* Make certain the directory exists. This routine is called
|
||||
* directory by the invoker, or recursively.
|
||||
*/
|
||||
|
||||
if (access(root, F_OK) != 0)
|
||||
if (access (root, F_OK) != 0)
|
||||
return -1;
|
||||
|
||||
/*
|
||||
@@ -71,7 +68,7 @@ chown_tree(const char *root, uid_t old_uid, uid_t new_uid, gid_t old_gid, gid_t
|
||||
* old user ID.
|
||||
*/
|
||||
|
||||
if (! (dir = opendir (root)))
|
||||
if (!(dir = opendir (root)))
|
||||
return -1;
|
||||
|
||||
while ((ent = readdir (dir))) {
|
||||
@@ -81,7 +78,7 @@ chown_tree(const char *root, uid_t old_uid, uid_t new_uid, gid_t old_gid, gid_t
|
||||
*/
|
||||
|
||||
if (strcmp (ent->d_name, ".") == 0 ||
|
||||
strcmp (ent->d_name, "..") == 0)
|
||||
strcmp (ent->d_name, "..") == 0)
|
||||
continue;
|
||||
|
||||
/*
|
||||
@@ -89,16 +86,18 @@ chown_tree(const char *root, uid_t old_uid, uid_t new_uid, gid_t old_gid, gid_t
|
||||
* destination files.
|
||||
*/
|
||||
|
||||
if (strlen (root) + strlen (ent->d_name) + 2 > sizeof new_name)
|
||||
if (strlen (root) + strlen (ent->d_name) + 2 >
|
||||
sizeof new_name)
|
||||
break;
|
||||
|
||||
snprintf(new_name, sizeof new_name, "%s/%s", root, ent->d_name);
|
||||
snprintf (new_name, sizeof new_name, "%s/%s", root,
|
||||
ent->d_name);
|
||||
|
||||
/* Don't follow symbolic links! */
|
||||
if (LSTAT(new_name, &sb) == -1)
|
||||
if (LSTAT (new_name, &sb) == -1)
|
||||
continue;
|
||||
|
||||
if (S_ISDIR(sb.st_mode) && !S_ISLNK(sb.st_mode)) {
|
||||
if (S_ISDIR (sb.st_mode) && !S_ISLNK (sb.st_mode)) {
|
||||
|
||||
/*
|
||||
* Do the entire subdirectory.
|
||||
@@ -110,12 +109,13 @@ chown_tree(const char *root, uid_t old_uid, uid_t new_uid, gid_t old_gid, gid_t
|
||||
}
|
||||
#ifndef HAVE_LCHOWN
|
||||
/* don't use chown (follows symbolic links!) */
|
||||
if (S_ISLNK(sb.st_mode))
|
||||
if (S_ISLNK (sb.st_mode))
|
||||
continue;
|
||||
#endif
|
||||
if (sb.st_uid == old_uid)
|
||||
LCHOWN(new_name, new_uid,
|
||||
sb.st_gid == old_gid ? new_gid:sb.st_gid);
|
||||
LCHOWN (new_name, new_uid,
|
||||
sb.st_gid ==
|
||||
old_gid ? new_gid : sb.st_gid);
|
||||
}
|
||||
closedir (dir);
|
||||
|
||||
@@ -123,10 +123,11 @@ chown_tree(const char *root, uid_t old_uid, uid_t new_uid, gid_t old_gid, gid_t
|
||||
* Now do the root of the tree
|
||||
*/
|
||||
|
||||
if (! stat (root, &sb)) {
|
||||
if (!stat (root, &sb)) {
|
||||
if (sb.st_uid == old_uid)
|
||||
LCHOWN(root, new_uid,
|
||||
sb.st_gid == old_gid ? new_gid:sb.st_gid);
|
||||
LCHOWN (root, new_uid,
|
||||
sb.st_gid ==
|
||||
old_gid ? new_gid : sb.st_gid);
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
@@ -30,28 +30,22 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: chowntty.c,v 1.9 2001/06/23 11:09:02 marekm Exp $")
|
||||
|
||||
RCSID ("$Id: chowntty.c,v 1.10 2003/04/22 10:59:21 kloczek Exp $")
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <grp.h>
|
||||
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
#include <pwd.h>
|
||||
#include "getdef.h"
|
||||
|
||||
/*
|
||||
* is_my_tty -- determine if "tty" is the same as TTY stdin is using
|
||||
*/
|
||||
|
||||
static int
|
||||
is_my_tty(const char *tty)
|
||||
static int is_my_tty (const char *tty)
|
||||
{
|
||||
struct stat by_name, by_fd;
|
||||
struct stat by_name, by_fd;
|
||||
|
||||
if (stat (tty, &by_name) || fstat (0, &by_fd))
|
||||
return 0;
|
||||
@@ -67,12 +61,11 @@ is_my_tty(const char *tty)
|
||||
* with TTYPERM modes
|
||||
*/
|
||||
|
||||
void
|
||||
chown_tty(const char *tty, const struct passwd *info)
|
||||
void chown_tty (const char *tty, const struct passwd *info)
|
||||
{
|
||||
char buf[200], full_tty[200];
|
||||
char *group; /* TTY group name or number */
|
||||
struct group *grent;
|
||||
char *group; /* TTY group name or number */
|
||||
struct group *grent;
|
||||
gid_t gid;
|
||||
|
||||
/*
|
||||
@@ -80,7 +73,7 @@ chown_tty(const char *tty, const struct passwd *info)
|
||||
* ID. Otherwise, use the user's primary group ID.
|
||||
*/
|
||||
|
||||
if (! (group = getdef_str ("TTYGROUP")))
|
||||
if (!(group = getdef_str ("TTYGROUP")))
|
||||
gid = info->pw_gid;
|
||||
else if (group[0] >= '0' && group[0] <= '9')
|
||||
gid = atoi (group);
|
||||
@@ -95,31 +88,32 @@ chown_tty(const char *tty, const struct passwd *info)
|
||||
*/
|
||||
|
||||
if (*tty != '/') {
|
||||
snprintf(full_tty, sizeof full_tty, "/dev/%s", tty);
|
||||
snprintf (full_tty, sizeof full_tty, "/dev/%s", tty);
|
||||
tty = full_tty;
|
||||
}
|
||||
|
||||
if (! is_my_tty (tty)) {
|
||||
SYSLOG((LOG_WARN, "unable to determine TTY name, got %s\n",
|
||||
tty));
|
||||
closelog();
|
||||
if (!is_my_tty (tty)) {
|
||||
SYSLOG ((LOG_WARN,
|
||||
"unable to determine TTY name, got %s\n", tty));
|
||||
closelog ();
|
||||
exit (1);
|
||||
}
|
||||
|
||||
if (chown(tty, info->pw_uid, gid) ||
|
||||
chmod(tty, getdef_num("TTYPERM", 0600))) {
|
||||
|
||||
if (chown (tty, info->pw_uid, gid) ||
|
||||
chmod (tty, getdef_num ("TTYPERM", 0600))) {
|
||||
int err = errno;
|
||||
|
||||
snprintf(buf, sizeof buf, _("Unable to change tty %s"), tty);
|
||||
perror(buf);
|
||||
SYSLOG((LOG_WARN, "unable to change tty `%s' for user `%s'\n",
|
||||
tty, info->pw_name));
|
||||
closelog();
|
||||
snprintf (buf, sizeof buf, _("Unable to change tty %s"),
|
||||
tty);
|
||||
perror (buf);
|
||||
SYSLOG ((LOG_WARN,
|
||||
"unable to change tty `%s' for user `%s'\n", tty,
|
||||
info->pw_name));
|
||||
closelog ();
|
||||
|
||||
if (!(err == EROFS && info->pw_uid == 0))
|
||||
exit(1);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
#ifdef __linux__
|
||||
/*
|
||||
* Please don't add code to chown /dev/vcs* to the user logging in -
|
||||
|
||||
@@ -33,15 +33,14 @@
|
||||
#include "getdef.h"
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: console.c,v 1.5 1998/12/28 20:34:44 marekm Exp $")
|
||||
RCSID ("$Id: console.c,v 1.6 2003/04/22 10:59:21 kloczek Exp $")
|
||||
|
||||
/*
|
||||
* This is now rather generic function which decides if "tty" is listed
|
||||
* under "cfgin" in config (directly or indirectly). Fallback to default if
|
||||
* something is bad.
|
||||
*/
|
||||
int
|
||||
is_listed(const char *cfgin, const char *tty, int def)
|
||||
int is_listed (const char *cfgin, const char *tty, int def)
|
||||
{
|
||||
FILE *fp;
|
||||
char buf[200], *cons, *s;
|
||||
@@ -51,7 +50,7 @@ is_listed(const char *cfgin, const char *tty, int def)
|
||||
* fallback to default.
|
||||
*/
|
||||
|
||||
if ((cons = getdef_str(cfgin)) == NULL)
|
||||
if ((cons = getdef_str (cfgin)) == NULL)
|
||||
return def;
|
||||
|
||||
/*
|
||||
@@ -60,9 +59,9 @@ is_listed(const char *cfgin, const char *tty, int def)
|
||||
*/
|
||||
|
||||
if (*cons != '/') {
|
||||
cons = strcpy(buf, cons);
|
||||
while ((s = strtok(cons, ":")) != NULL) {
|
||||
if (strcmp(s, tty) == 0)
|
||||
cons = strcpy (buf, cons);
|
||||
while ((s = strtok (cons, ":")) != NULL) {
|
||||
if (strcmp (s, tty) == 0)
|
||||
return 1;
|
||||
|
||||
cons = NULL;
|
||||
@@ -75,17 +74,17 @@ is_listed(const char *cfgin, const char *tty, int def)
|
||||
* console - otherwise root will never be allowed to login.
|
||||
*/
|
||||
|
||||
if ((fp = fopen(cons, "r")) == NULL)
|
||||
if ((fp = fopen (cons, "r")) == NULL)
|
||||
return def;
|
||||
|
||||
/*
|
||||
* See if this tty is listed in the console file.
|
||||
*/
|
||||
|
||||
while (fgets(buf, sizeof(buf), fp) != NULL) {
|
||||
buf[strlen(buf) - 1] = '\0';
|
||||
if (strcmp(buf, tty) == 0) {
|
||||
(void) fclose(fp);
|
||||
while (fgets (buf, sizeof (buf), fp) != NULL) {
|
||||
buf[strlen (buf) - 1] = '\0';
|
||||
if (strcmp (buf, tty) == 0) {
|
||||
(void) fclose (fp);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -94,7 +93,7 @@ is_listed(const char *cfgin, const char *tty, int def)
|
||||
* This tty isn't a console.
|
||||
*/
|
||||
|
||||
(void) fclose(fp);
|
||||
(void) fclose (fp);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -108,8 +107,7 @@ is_listed(const char *cfgin, const char *tty, int def)
|
||||
* that would allow an unauthorized root login.
|
||||
*/
|
||||
|
||||
int
|
||||
console(const char *tty)
|
||||
int console (const char *tty)
|
||||
{
|
||||
return is_listed("CONSOLE", tty, 1);
|
||||
return is_listed ("CONSOLE", tty, 1);
|
||||
}
|
||||
|
||||
@@ -30,36 +30,31 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: copydir.c,v 1.8 2001/06/28 18:27:29 marekm Exp $")
|
||||
|
||||
RCSID ("$Id: copydir.c,v 1.9 2003/04/22 10:59:21 kloczek Exp $")
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
|
||||
static const char *src_orig;
|
||||
static const char *dst_orig;
|
||||
|
||||
struct link_name {
|
||||
dev_t ln_dev;
|
||||
ino_t ln_ino;
|
||||
int ln_count;
|
||||
char *ln_name;
|
||||
struct link_name *ln_next;
|
||||
struct link_name {
|
||||
dev_t ln_dev;
|
||||
ino_t ln_ino;
|
||||
int ln_count;
|
||||
char *ln_name;
|
||||
struct link_name *ln_next;
|
||||
};
|
||||
static struct link_name *links;
|
||||
static struct link_name *links;
|
||||
|
||||
/*
|
||||
* remove_link - delete a link from the link list
|
||||
*/
|
||||
|
||||
static void
|
||||
remove_link(struct link_name *ln)
|
||||
static void remove_link (struct link_name *ln)
|
||||
{
|
||||
struct link_name *lp;
|
||||
|
||||
@@ -69,11 +64,11 @@ remove_link(struct link_name *ln)
|
||||
free (ln);
|
||||
return;
|
||||
}
|
||||
for (lp = links;lp;lp = lp->ln_next)
|
||||
for (lp = links; lp; lp = lp->ln_next)
|
||||
if (lp->ln_next == ln)
|
||||
break;
|
||||
|
||||
if (! lp)
|
||||
if (!lp)
|
||||
return;
|
||||
|
||||
lp->ln_next = lp->ln_next->ln_next;
|
||||
@@ -85,16 +80,16 @@ remove_link(struct link_name *ln)
|
||||
* check_link - see if a file is really a link
|
||||
*/
|
||||
|
||||
static struct link_name *
|
||||
check_link(const char *name, const struct stat *sb)
|
||||
static struct link_name *check_link (const char *name,
|
||||
const struct stat *sb)
|
||||
{
|
||||
struct link_name *lp;
|
||||
int src_len;
|
||||
int dst_len;
|
||||
int name_len;
|
||||
struct link_name *lp;
|
||||
int src_len;
|
||||
int dst_len;
|
||||
int name_len;
|
||||
int len;
|
||||
|
||||
for (lp = links;lp;lp = lp->ln_next)
|
||||
for (lp = links; lp; lp = lp->ln_next)
|
||||
if (lp->ln_dev == sb->st_dev && lp->ln_ino == sb->st_ino)
|
||||
return lp;
|
||||
|
||||
@@ -109,8 +104,8 @@ check_link(const char *name, const struct stat *sb)
|
||||
lp->ln_ino = sb->st_ino;
|
||||
lp->ln_count = sb->st_nlink;
|
||||
len = name_len - src_len + dst_len + 1;
|
||||
lp->ln_name = xmalloc(len);
|
||||
snprintf(lp->ln_name, len, "%s%s", dst_orig, name + src_len);
|
||||
lp->ln_name = xmalloc (len);
|
||||
snprintf (lp->ln_name, len, "%s%s", dst_orig, name + src_len);
|
||||
lp->ln_next = links;
|
||||
links = lp;
|
||||
|
||||
@@ -125,20 +120,21 @@ check_link(const char *name, const struct stat *sb)
|
||||
*/
|
||||
|
||||
int
|
||||
copy_tree(const char *src_root, const char *dst_root, uid_t uid, gid_t gid)
|
||||
copy_tree (const char *src_root, const char *dst_root, uid_t uid,
|
||||
gid_t gid)
|
||||
{
|
||||
char src_name[1024];
|
||||
char dst_name[1024];
|
||||
char buf[1024];
|
||||
int ifd;
|
||||
int ofd;
|
||||
int err = 0;
|
||||
int cnt;
|
||||
int set_orig = 0;
|
||||
struct DIRECT *ent;
|
||||
struct stat sb;
|
||||
struct link_name *lp;
|
||||
DIR *dir;
|
||||
char src_name[1024];
|
||||
char dst_name[1024];
|
||||
char buf[1024];
|
||||
int ifd;
|
||||
int ofd;
|
||||
int err = 0;
|
||||
int cnt;
|
||||
int set_orig = 0;
|
||||
struct DIRECT *ent;
|
||||
struct stat sb;
|
||||
struct link_name *lp;
|
||||
DIR *dir;
|
||||
|
||||
/*
|
||||
* Make certain both directories exist. This routine is called
|
||||
@@ -146,7 +142,7 @@ copy_tree(const char *src_root, const char *dst_root, uid_t uid, gid_t gid)
|
||||
* target is created. It assumes the target directory exists.
|
||||
*/
|
||||
|
||||
if (access(src_root, F_OK) != 0 || access(dst_root, F_OK) != 0)
|
||||
if (access (src_root, F_OK) != 0 || access (dst_root, F_OK) != 0)
|
||||
return -1;
|
||||
|
||||
/*
|
||||
@@ -157,7 +153,7 @@ copy_tree(const char *src_root, const char *dst_root, uid_t uid, gid_t gid)
|
||||
* is made set-ID.
|
||||
*/
|
||||
|
||||
if (! (dir = opendir (src_root)))
|
||||
if (!(dir = opendir (src_root)))
|
||||
return -1;
|
||||
|
||||
if (src_orig == 0) {
|
||||
@@ -172,7 +168,7 @@ copy_tree(const char *src_root, const char *dst_root, uid_t uid, gid_t gid)
|
||||
*/
|
||||
|
||||
if (strcmp (ent->d_name, ".") == 0 ||
|
||||
strcmp (ent->d_name, "..") == 0)
|
||||
strcmp (ent->d_name, "..") == 0)
|
||||
continue;
|
||||
|
||||
/*
|
||||
@@ -180,22 +176,26 @@ copy_tree(const char *src_root, const char *dst_root, uid_t uid, gid_t gid)
|
||||
* destination files.
|
||||
*/
|
||||
|
||||
if (strlen (src_root) + strlen (ent->d_name) + 2 > sizeof src_name) {
|
||||
if (strlen (src_root) + strlen (ent->d_name) + 2 >
|
||||
sizeof src_name) {
|
||||
err++;
|
||||
break;
|
||||
}
|
||||
snprintf(src_name, sizeof src_name, "%s/%s", src_root, ent->d_name);
|
||||
snprintf (src_name, sizeof src_name, "%s/%s", src_root,
|
||||
ent->d_name);
|
||||
|
||||
if (strlen (dst_root) + strlen (ent->d_name) + 2 > sizeof dst_name) {
|
||||
if (strlen (dst_root) + strlen (ent->d_name) + 2 >
|
||||
sizeof dst_name) {
|
||||
err++;
|
||||
break;
|
||||
}
|
||||
snprintf(dst_name, sizeof dst_name, "%s/%s", dst_root, ent->d_name);
|
||||
snprintf (dst_name, sizeof dst_name, "%s/%s", dst_root,
|
||||
ent->d_name);
|
||||
|
||||
if (LSTAT(src_name, &sb) == -1)
|
||||
if (LSTAT (src_name, &sb) == -1)
|
||||
continue;
|
||||
|
||||
if (S_ISDIR(sb.st_mode)) {
|
||||
if (S_ISDIR (sb.st_mode)) {
|
||||
|
||||
/*
|
||||
* Create a new target directory, make it owned by
|
||||
@@ -203,8 +203,9 @@ copy_tree(const char *src_root, const char *dst_root, uid_t uid, gid_t gid)
|
||||
*/
|
||||
|
||||
mkdir (dst_name, sb.st_mode & 0777);
|
||||
chown (dst_name, uid == (uid_t) -1 ? sb.st_uid:uid,
|
||||
gid == (gid_t) -1 ? sb.st_gid:gid);
|
||||
chown (dst_name,
|
||||
uid == (uid_t) - 1 ? sb.st_uid : uid,
|
||||
gid == (gid_t) - 1 ? sb.st_gid : gid);
|
||||
|
||||
if (copy_tree (src_name, dst_name, uid, gid)) {
|
||||
err++;
|
||||
@@ -217,10 +218,10 @@ copy_tree(const char *src_root, const char *dst_root, uid_t uid, gid_t gid)
|
||||
* Copy any symbolic links
|
||||
*/
|
||||
|
||||
if (S_ISLNK(sb.st_mode)) {
|
||||
char oldlink[1024];
|
||||
char dummy[1024];
|
||||
int len;
|
||||
if (S_ISLNK (sb.st_mode)) {
|
||||
char oldlink[1024];
|
||||
char dummy[1024];
|
||||
int len;
|
||||
|
||||
/*
|
||||
* Get the name of the file which the link points
|
||||
@@ -230,17 +231,21 @@ copy_tree(const char *src_root, const char *dst_root, uid_t uid, gid_t gid)
|
||||
* destinateion directory name.
|
||||
*/
|
||||
|
||||
if ((len = readlink(src_name, oldlink, sizeof(oldlink) - 1)) < 0) {
|
||||
if ((len =
|
||||
readlink (src_name, oldlink,
|
||||
sizeof (oldlink) - 1)) < 0) {
|
||||
err++;
|
||||
break;
|
||||
}
|
||||
oldlink[len] = '\0'; /* readlink() does not NUL-terminate */
|
||||
if (!strncmp(oldlink, src_orig, strlen(src_orig))) {
|
||||
snprintf(dummy, sizeof dummy, "%s%s",
|
||||
dst_orig, oldlink + strlen(src_orig));
|
||||
strcpy(oldlink, dummy);
|
||||
oldlink[len] = '\0'; /* readlink() does not NUL-terminate */
|
||||
if (!strncmp
|
||||
(oldlink, src_orig, strlen (src_orig))) {
|
||||
snprintf (dummy, sizeof dummy, "%s%s",
|
||||
dst_orig,
|
||||
oldlink + strlen (src_orig));
|
||||
strcpy (oldlink, dummy);
|
||||
}
|
||||
if (symlink(oldlink, dst_name)) {
|
||||
if (symlink (oldlink, dst_name)) {
|
||||
err++;
|
||||
break;
|
||||
}
|
||||
@@ -273,11 +278,13 @@ copy_tree(const char *src_root, const char *dst_root, uid_t uid, gid_t gid)
|
||||
* would be nice to copy everything ...
|
||||
*/
|
||||
|
||||
if (!S_ISREG(sb.st_mode)) {
|
||||
if (mknod (dst_name, sb.st_mode & ~07777, sb.st_rdev) ||
|
||||
chown (dst_name, uid == (uid_t) -1 ? sb.st_uid:uid,
|
||||
gid == (gid_t) -1 ? sb.st_gid:gid) ||
|
||||
chmod (dst_name, sb.st_mode & 07777)) {
|
||||
if (!S_ISREG (sb.st_mode)) {
|
||||
if (mknod
|
||||
(dst_name, sb.st_mode & ~07777, sb.st_rdev)
|
||||
|| chown (dst_name,
|
||||
uid == (uid_t) - 1 ? sb.st_uid : uid,
|
||||
gid == (gid_t) - 1 ? sb.st_gid : gid)
|
||||
|| chmod (dst_name, sb.st_mode & 07777)) {
|
||||
err++;
|
||||
break;
|
||||
}
|
||||
@@ -293,10 +300,12 @@ copy_tree(const char *src_root, const char *dst_root, uid_t uid, gid_t gid)
|
||||
err++;
|
||||
break;
|
||||
}
|
||||
if ((ofd = open (dst_name, O_WRONLY|O_CREAT|O_TRUNC, 0)) < 0 ||
|
||||
chown (dst_name, uid == (uid_t) -1 ? sb.st_uid:uid,
|
||||
gid == (gid_t) -1 ? sb.st_gid:gid) ||
|
||||
chmod (dst_name, sb.st_mode & 07777)) {
|
||||
if ((ofd =
|
||||
open (dst_name, O_WRONLY | O_CREAT | O_TRUNC, 0)) < 0
|
||||
|| chown (dst_name,
|
||||
uid == (uid_t) - 1 ? sb.st_uid : uid,
|
||||
gid == (gid_t) - 1 ? sb.st_gid : gid)
|
||||
|| chmod (dst_name, sb.st_mode & 07777)) {
|
||||
close (ifd);
|
||||
err++;
|
||||
break;
|
||||
@@ -321,7 +330,7 @@ copy_tree(const char *src_root, const char *dst_root, uid_t uid, gid_t gid)
|
||||
src_orig = 0;
|
||||
dst_orig = 0;
|
||||
}
|
||||
return err ? -1:0;
|
||||
return err ? -1 : 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -331,20 +340,19 @@ copy_tree(const char *src_root, const char *dst_root, uid_t uid, gid_t gid)
|
||||
* and directories.
|
||||
*/
|
||||
|
||||
int
|
||||
remove_tree(const char *root)
|
||||
int remove_tree (const char *root)
|
||||
{
|
||||
char new_name[1024];
|
||||
int err = 0;
|
||||
struct DIRECT *ent;
|
||||
struct stat sb;
|
||||
DIR *dir;
|
||||
char new_name[1024];
|
||||
int err = 0;
|
||||
struct DIRECT *ent;
|
||||
struct stat sb;
|
||||
DIR *dir;
|
||||
|
||||
/*
|
||||
* Make certain the directory exists.
|
||||
*/
|
||||
|
||||
if (access(root, F_OK) != 0)
|
||||
if (access (root, F_OK) != 0)
|
||||
return -1;
|
||||
|
||||
/*
|
||||
@@ -364,22 +372,24 @@ remove_tree(const char *root)
|
||||
*/
|
||||
|
||||
if (strcmp (ent->d_name, ".") == 0 ||
|
||||
strcmp (ent->d_name, "..") == 0)
|
||||
strcmp (ent->d_name, "..") == 0)
|
||||
continue;
|
||||
|
||||
/*
|
||||
* Make the filename for the current entry.
|
||||
*/
|
||||
|
||||
if (strlen (root) + strlen (ent->d_name) + 2 > sizeof new_name) {
|
||||
if (strlen (root) + strlen (ent->d_name) + 2 >
|
||||
sizeof new_name) {
|
||||
err++;
|
||||
break;
|
||||
}
|
||||
snprintf(new_name, sizeof new_name, "%s/%s", root, ent->d_name);
|
||||
if (LSTAT(new_name, &sb) == -1)
|
||||
snprintf (new_name, sizeof new_name, "%s/%s", root,
|
||||
ent->d_name);
|
||||
if (LSTAT (new_name, &sb) == -1)
|
||||
continue;
|
||||
|
||||
if (S_ISDIR(sb.st_mode)) {
|
||||
if (S_ISDIR (sb.st_mode)) {
|
||||
|
||||
/*
|
||||
* Recursively delete this directory.
|
||||
@@ -399,5 +409,5 @@ remove_tree(const char *root)
|
||||
}
|
||||
closedir (dir);
|
||||
|
||||
return err ? -1:0;
|
||||
return err ? -1 : 0;
|
||||
}
|
||||
|
||||
@@ -30,38 +30,29 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: entry.c,v 1.4 2000/08/26 18:27:17 marekm Exp $")
|
||||
|
||||
RCSID ("$Id: entry.c,v 1.6 2003/05/03 16:14:33 kloczek Exp $")
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
#include <pwd.h>
|
||||
extern struct passwd *fgetpwent ();
|
||||
|
||||
extern struct passwd *fgetpwent ();
|
||||
|
||||
void
|
||||
pw_entry(const char *name, struct passwd *pwent)
|
||||
void pw_entry (const char *name, struct passwd *pwent)
|
||||
{
|
||||
struct passwd *passwd;
|
||||
struct passwd *passwd;
|
||||
|
||||
#ifdef SHADOWPWD
|
||||
struct spwd *spwd;
|
||||
#ifdef ATT_AGE
|
||||
char *l64a ();
|
||||
char *cp;
|
||||
#endif
|
||||
struct spwd *spwd;
|
||||
#endif
|
||||
|
||||
if (! (passwd = getpwnam (name))) {
|
||||
if (!(passwd = getpwnam (name))) {
|
||||
pwent->pw_name = (char *) 0;
|
||||
return;
|
||||
} else {
|
||||
} else {
|
||||
pwent->pw_name = xstrdup (passwd->pw_name);
|
||||
pwent->pw_uid = passwd->pw_uid;
|
||||
pwent->pw_gid = passwd->pw_gid;
|
||||
#ifdef ATT_COMMENT
|
||||
pwent->pw_comment = xstrdup (passwd->pw_comment);
|
||||
#endif
|
||||
pwent->pw_gecos = xstrdup (passwd->pw_gecos);
|
||||
pwent->pw_dir = xstrdup (passwd->pw_dir);
|
||||
pwent->pw_shell = xstrdup (passwd->pw_shell);
|
||||
@@ -69,31 +60,11 @@ pw_entry(const char *name, struct passwd *pwent)
|
||||
setspent ();
|
||||
if ((spwd = getspnam (name))) {
|
||||
pwent->pw_passwd = xstrdup (spwd->sp_pwdp);
|
||||
#ifdef ATT_AGE
|
||||
pwent->pw_age = (char *) xmalloc (5);
|
||||
|
||||
if (spwd->sp_max > (63*7))
|
||||
spwd->sp_max = (63*7);
|
||||
if (spwd->sp_min > (63*7))
|
||||
spwd->sp_min = (63*7);
|
||||
|
||||
pwent->pw_age[0] = i64c (spwd->sp_max / 7);
|
||||
pwent->pw_age[1] = i64c (spwd->sp_min / 7);
|
||||
|
||||
cp = l64a (spwd->sp_lstchg / 7);
|
||||
pwent->pw_age[2] = cp[0];
|
||||
pwent->pw_age[3] = cp[1];
|
||||
|
||||
pwent->pw_age[4] = '\0';
|
||||
#endif
|
||||
endspent ();
|
||||
return;
|
||||
}
|
||||
endspent ();
|
||||
#endif
|
||||
pwent->pw_passwd = xstrdup (passwd->pw_passwd);
|
||||
#ifdef ATT_AGE
|
||||
pwent->pw_age = xstrdup (passwd->pw_age);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,33 +30,30 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: env.c,v 1.9 1999/03/07 19:14:38 marekm Exp $")
|
||||
|
||||
RCSID ("$Id: env.c,v 1.10 2003/04/22 10:59:22 kloczek Exp $")
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
|
||||
/*
|
||||
* NEWENVP_STEP must be a power of two. This is the number
|
||||
* of (char *) pointers to allocate at a time, to avoid using
|
||||
* realloc() too often.
|
||||
*/
|
||||
*/
|
||||
#define NEWENVP_STEP 16
|
||||
|
||||
size_t newenvc = 0;
|
||||
char **newenvp = NULL;
|
||||
extern char **environ;
|
||||
|
||||
static const char *forbid[] = {
|
||||
"_RLD_=",
|
||||
"BASH_ENV=", /* GNU creeping featurism strikes again... */
|
||||
"BASH_ENV=", /* GNU creeping featurism strikes again... */
|
||||
"ENV=",
|
||||
"HOME=",
|
||||
"IFS=",
|
||||
"KRB_CONF=",
|
||||
"LD_", /* anything with the LD_ prefix */
|
||||
"LD_", /* anything with the LD_ prefix */
|
||||
"LIBPATH=",
|
||||
"MAIL=",
|
||||
"NLSPATH=",
|
||||
@@ -71,33 +68,31 @@ static const char *forbid[] = {
|
||||
static const char *noslash[] = {
|
||||
"LANG=",
|
||||
"LANGUAGE=",
|
||||
"LC_", /* anything with the LC_ prefix */
|
||||
"LC_", /* anything with the LC_ prefix */
|
||||
(char *) 0
|
||||
};
|
||||
|
||||
/*
|
||||
* initenv() must be called once before using addenv().
|
||||
*/
|
||||
void
|
||||
initenv(void)
|
||||
void initenv (void)
|
||||
{
|
||||
newenvp = (char **)xmalloc(NEWENVP_STEP * sizeof(char *));
|
||||
newenvp = (char **) xmalloc (NEWENVP_STEP * sizeof (char *));
|
||||
*newenvp = NULL;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
addenv(const char *string, const char *value)
|
||||
void addenv (const char *string, const char *value)
|
||||
{
|
||||
char *cp, *newstring;
|
||||
size_t i;
|
||||
size_t n;
|
||||
|
||||
if (value) {
|
||||
newstring = xmalloc(strlen(string) + strlen(value) + 2);
|
||||
sprintf(newstring, "%s=%s", string, value);
|
||||
newstring = xmalloc (strlen (string) + strlen (value) + 2);
|
||||
sprintf (newstring, "%s=%s", string, value);
|
||||
} else {
|
||||
newstring = xstrdup(string);
|
||||
newstring = xstrdup (string);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -105,22 +100,22 @@ addenv(const char *string, const char *value)
|
||||
* just ignore the whole string.
|
||||
*/
|
||||
|
||||
cp = strchr(newstring, '=');
|
||||
cp = strchr (newstring, '=');
|
||||
if (!cp) {
|
||||
free(newstring);
|
||||
free (newstring);
|
||||
return;
|
||||
}
|
||||
|
||||
n = (size_t)(cp - newstring);
|
||||
n = (size_t) (cp - newstring);
|
||||
|
||||
for (i = 0; i < newenvc; i++) {
|
||||
if (strncmp(newstring, newenvp[i], n) == 0 &&
|
||||
if (strncmp (newstring, newenvp[i], n) == 0 &&
|
||||
(newenvp[i][n] == '=' || newenvp[i][n] == '\0'))
|
||||
break;
|
||||
}
|
||||
|
||||
if (i < newenvc) {
|
||||
free(newenvp[i]);
|
||||
free (newenvp[i]);
|
||||
newenvp[i] = newstring;
|
||||
return;
|
||||
}
|
||||
@@ -144,8 +139,8 @@ addenv(const char *string, const char *value)
|
||||
* happily go on, else print a message.
|
||||
*/
|
||||
|
||||
newsize = (newenvc + NEWENVP_STEP) * sizeof(char *);
|
||||
__newenvp = (char **)realloc(newenvp, newsize);
|
||||
newsize = (newenvc + NEWENVP_STEP) * sizeof (char *);
|
||||
__newenvp = (char **) realloc (newenvp, newsize);
|
||||
|
||||
if (__newenvp) {
|
||||
/*
|
||||
@@ -157,8 +152,8 @@ addenv(const char *string, const char *value)
|
||||
environ = __newenvp;
|
||||
newenvp = __newenvp;
|
||||
} else {
|
||||
fprintf(stderr, _("Environment overflow\n"));
|
||||
free(newenvp[--newenvc]);
|
||||
fprintf (stderr, _("Environment overflow\n"));
|
||||
free (newenvp[--newenvc]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,35 +168,36 @@ addenv(const char *string, const char *value)
|
||||
/*
|
||||
* set_env - copy command line arguments into the environment
|
||||
*/
|
||||
void
|
||||
set_env(int argc, char * const *argv)
|
||||
void set_env (int argc, char *const *argv)
|
||||
{
|
||||
int noname = 1;
|
||||
char variable[1024];
|
||||
char *cp;
|
||||
int noname = 1;
|
||||
char variable[1024];
|
||||
char *cp;
|
||||
|
||||
for ( ; argc > 0; argc--, argv++) {
|
||||
if (strlen(*argv) >= sizeof variable)
|
||||
for (; argc > 0; argc--, argv++) {
|
||||
if (strlen (*argv) >= sizeof variable)
|
||||
continue; /* ignore long entries */
|
||||
|
||||
if (! (cp = strchr (*argv, '='))) {
|
||||
snprintf(variable, sizeof variable, "L%d", noname++);
|
||||
addenv(variable, *argv);
|
||||
if (!(cp = strchr (*argv, '='))) {
|
||||
snprintf (variable, sizeof variable, "L%d",
|
||||
noname++);
|
||||
addenv (variable, *argv);
|
||||
} else {
|
||||
const char **p;
|
||||
|
||||
for (p = forbid; *p; p++)
|
||||
if (strncmp(*argv, *p, strlen(*p)) == 0)
|
||||
if (strncmp (*argv, *p, strlen (*p)) == 0)
|
||||
break;
|
||||
|
||||
if (*p) {
|
||||
strncpy(variable, *argv, cp - *argv);
|
||||
strncpy (variable, *argv, cp - *argv);
|
||||
variable[cp - *argv] = '\0';
|
||||
printf(_("You may not change $%s\n"), variable);
|
||||
printf (_("You may not change $%s\n"),
|
||||
variable);
|
||||
continue;
|
||||
}
|
||||
|
||||
addenv(*argv, NULL);
|
||||
addenv (*argv, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -215,8 +211,7 @@ set_env(int argc, char * const *argv)
|
||||
* but... I feel better with that silly precaution. -j.
|
||||
*/
|
||||
|
||||
void
|
||||
sanitize_env(void)
|
||||
void sanitize_env (void)
|
||||
{
|
||||
char **envp = environ;
|
||||
const char **bad;
|
||||
@@ -225,7 +220,7 @@ sanitize_env(void)
|
||||
|
||||
for (cur = envp; *cur; cur++) {
|
||||
for (bad = forbid; *bad; bad++) {
|
||||
if (strncmp(*cur, *bad, strlen(*bad)) == 0) {
|
||||
if (strncmp (*cur, *bad, strlen (*bad)) == 0) {
|
||||
for (move = cur; *move; move++)
|
||||
*move = *(move + 1);
|
||||
cur--;
|
||||
@@ -236,10 +231,10 @@ sanitize_env(void)
|
||||
|
||||
for (cur = envp; *cur; cur++) {
|
||||
for (bad = noslash; *bad; bad++) {
|
||||
if (strncmp(*cur, *bad, strlen(*bad)) != 0)
|
||||
if (strncmp (*cur, *bad, strlen (*bad)) != 0)
|
||||
continue;
|
||||
if (!strchr(*cur, '/'))
|
||||
continue; /* OK */
|
||||
if (!strchr (*cur, '/'))
|
||||
continue; /* OK */
|
||||
for (move = cur; *move; move++)
|
||||
*move = *(move + 1);
|
||||
cur--;
|
||||
@@ -247,4 +242,3 @@ sanitize_env(void)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,8 +30,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: failure.c,v 1.6 1998/12/28 20:34:46 marekm Exp $")
|
||||
|
||||
RCSID ("$Id: failure.c,v 1.9 2003/04/25 21:11:08 kloczek Exp $")
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include "defines.h"
|
||||
@@ -39,19 +38,14 @@ RCSID("$Id: failure.c,v 1.6 1998/12/28 20:34:46 marekm Exp $")
|
||||
#include "getdef.h"
|
||||
#include "failure.h"
|
||||
|
||||
#include <utmp.h>
|
||||
|
||||
#define YEAR (365L*DAY)
|
||||
|
||||
/*
|
||||
* failure - make failure entry
|
||||
*
|
||||
* failure() creates a new (struct faillog) entry or updates an
|
||||
* existing one with the current failed login information.
|
||||
*/
|
||||
|
||||
void
|
||||
failure(uid_t uid, const char *tty, struct faillog *fl)
|
||||
void failure (uid_t uid, const char *tty, struct faillog *fl)
|
||||
{
|
||||
int fd;
|
||||
|
||||
@@ -59,7 +53,7 @@ failure(uid_t uid, const char *tty, struct faillog *fl)
|
||||
* Don't do anything if failure logging isn't set up.
|
||||
*/
|
||||
|
||||
if ((fd = open(FAILLOG_FILE, O_RDWR)) < 0)
|
||||
if ((fd = open (FAILLOG_FILE, O_RDWR)) < 0)
|
||||
return;
|
||||
|
||||
/*
|
||||
@@ -68,9 +62,9 @@ failure(uid_t uid, const char *tty, struct faillog *fl)
|
||||
* share just about everything else ...
|
||||
*/
|
||||
|
||||
lseek(fd, (off_t) (sizeof *fl) * uid, SEEK_SET);
|
||||
if (read(fd, (char *) fl, sizeof *fl) != sizeof *fl)
|
||||
memzero(fl, sizeof *fl);
|
||||
lseek (fd, (off_t) (sizeof *fl) * uid, SEEK_SET);
|
||||
if (read (fd, (char *) fl, sizeof *fl) != sizeof *fl)
|
||||
memzero (fl, sizeof *fl);
|
||||
|
||||
/*
|
||||
* Update the record. We increment the failure count to log the
|
||||
@@ -82,8 +76,8 @@ failure(uid_t uid, const char *tty, struct faillog *fl)
|
||||
if (fl->fail_cnt + 1 > 0)
|
||||
fl->fail_cnt++;
|
||||
|
||||
strncpy(fl->fail_line, tty, sizeof fl->fail_line);
|
||||
time(&fl->fail_time);
|
||||
strncpy (fl->fail_line, tty, sizeof fl->fail_line);
|
||||
time (&fl->fail_time);
|
||||
|
||||
/*
|
||||
* Seek back to the correct position in the file and write the
|
||||
@@ -92,13 +86,12 @@ failure(uid_t uid, const char *tty, struct faillog *fl)
|
||||
* seem that great.
|
||||
*/
|
||||
|
||||
lseek(fd, (off_t) (sizeof *fl) * uid, SEEK_SET);
|
||||
write(fd, (char *) fl, sizeof *fl);
|
||||
close(fd);
|
||||
lseek (fd, (off_t) (sizeof *fl) * uid, SEEK_SET);
|
||||
write (fd, (char *) fl, sizeof *fl);
|
||||
close (fd);
|
||||
}
|
||||
|
||||
static int
|
||||
too_many_failures(const struct faillog *fl)
|
||||
static int too_many_failures (const struct faillog *fl)
|
||||
{
|
||||
time_t now;
|
||||
|
||||
@@ -106,11 +99,11 @@ too_many_failures(const struct faillog *fl)
|
||||
return 0;
|
||||
|
||||
if (fl->fail_locktime == 0)
|
||||
return 1; /* locked until reset manually */
|
||||
return 1; /* locked until reset manually */
|
||||
|
||||
time(&now);
|
||||
if (fl->fail_time + fl->fail_locktime > now)
|
||||
return 0; /* enough time since last failure */
|
||||
time (&now);
|
||||
if (fl->fail_time + fl->fail_locktime < now)
|
||||
return 0; /* enough time since last failure */
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -124,17 +117,16 @@ too_many_failures(const struct faillog *fl)
|
||||
* the password is valid.
|
||||
*/
|
||||
|
||||
int
|
||||
failcheck(uid_t uid, struct faillog *fl, int failed)
|
||||
int failcheck (uid_t uid, struct faillog *fl, int failed)
|
||||
{
|
||||
int fd;
|
||||
struct faillog fail;
|
||||
int fd;
|
||||
struct faillog fail;
|
||||
|
||||
/*
|
||||
* Suppress the check if the log file isn't there.
|
||||
*/
|
||||
|
||||
if ((fd = open(FAILLOG_FILE, O_RDWR)) < 0)
|
||||
if ((fd = open (FAILLOG_FILE, O_RDWR)) < 0)
|
||||
return 1;
|
||||
|
||||
/*
|
||||
@@ -150,13 +142,13 @@ failcheck(uid_t uid, struct faillog *fl, int failed)
|
||||
*/
|
||||
|
||||
lseek (fd, (off_t) (sizeof *fl) * uid, SEEK_SET);
|
||||
if (read(fd, (char *) fl, sizeof *fl) != sizeof *fl) {
|
||||
close(fd);
|
||||
if (read (fd, (char *) fl, sizeof *fl) != sizeof *fl) {
|
||||
close (fd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (too_many_failures(fl)) {
|
||||
close(fd);
|
||||
if (too_many_failures (fl)) {
|
||||
close (fd);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -185,16 +177,16 @@ failcheck(uid_t uid, struct faillog *fl, int failed)
|
||||
* message which is displayed at login time.
|
||||
*/
|
||||
|
||||
void
|
||||
failprint(const struct faillog *fail)
|
||||
void failprint (const struct faillog *fail)
|
||||
{
|
||||
struct tm *tp;
|
||||
struct tm *tp;
|
||||
|
||||
#if HAVE_STRFTIME
|
||||
char lasttimeb[256];
|
||||
char *lasttime = lasttimeb;
|
||||
char lasttimeb[256];
|
||||
char *lasttime = lasttimeb;
|
||||
const char *fmt;
|
||||
#else
|
||||
char *lasttime;
|
||||
char *lasttime;
|
||||
#endif
|
||||
time_t NOW;
|
||||
|
||||
@@ -202,7 +194,7 @@ failprint(const struct faillog *fail)
|
||||
return;
|
||||
|
||||
tp = localtime (&(fail->fail_time));
|
||||
time(&NOW);
|
||||
time (&NOW);
|
||||
|
||||
#if HAVE_STRFTIME
|
||||
/*
|
||||
@@ -216,7 +208,7 @@ failprint(const struct faillog *fail)
|
||||
fmt = "%A %T";
|
||||
else
|
||||
fmt = "%T";
|
||||
strftime(lasttimeb, sizeof lasttimeb, fmt, tp);
|
||||
strftime (lasttimeb, sizeof lasttimeb, fmt, tp);
|
||||
#else
|
||||
|
||||
/*
|
||||
@@ -236,7 +228,8 @@ failprint(const struct faillog *fail)
|
||||
lasttime++;
|
||||
#endif
|
||||
printf (_("%d %s since last login. Last was %s on %s.\n"),
|
||||
fail->fail_cnt, fail->fail_cnt > 1 ? _("failures"):_("failure"),
|
||||
fail->fail_cnt,
|
||||
fail->fail_cnt > 1 ? _("failures") : _("failure"),
|
||||
lasttime, fail->fail_line);
|
||||
}
|
||||
|
||||
@@ -247,8 +240,7 @@ failprint(const struct faillog *fail)
|
||||
* maintains a record of all login failures.
|
||||
*/
|
||||
|
||||
void
|
||||
failtmp(const struct utmp *failent)
|
||||
void failtmp (const struct utmp *failent)
|
||||
{
|
||||
char *ftmp;
|
||||
int fd;
|
||||
@@ -258,7 +250,7 @@ failtmp(const struct utmp *failent)
|
||||
* in login.defs, don't do this.
|
||||
*/
|
||||
|
||||
if (!(ftmp = getdef_str("FTMP_FILE")))
|
||||
if (!(ftmp = getdef_str ("FTMP_FILE")))
|
||||
return;
|
||||
|
||||
/*
|
||||
@@ -266,13 +258,13 @@ failtmp(const struct utmp *failent)
|
||||
* feature to be used.
|
||||
*/
|
||||
|
||||
if ((fd = open(ftmp, O_WRONLY|O_APPEND)) == -1)
|
||||
if ((fd = open (ftmp, O_WRONLY | O_APPEND)) == -1)
|
||||
return;
|
||||
|
||||
/*
|
||||
* Output the new failure record and close the log file.
|
||||
*/
|
||||
|
||||
write(fd, (const char *) failent, sizeof *failent);
|
||||
close(fd);
|
||||
write (fd, (const char *) failent, sizeof *failent);
|
||||
close (fd);
|
||||
}
|
||||
|
||||
@@ -30,13 +30,11 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: fields.c,v 1.5 1997/12/07 23:27:04 marekm Exp $")
|
||||
|
||||
RCSID ("$Id: fields.c,v 1.6 2003/04/22 10:59:22 kloczek Exp $")
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include "prototypes.h"
|
||||
|
||||
/*
|
||||
* valid_field - insure that a field contains all legal characters
|
||||
*
|
||||
@@ -44,14 +42,12 @@ RCSID("$Id: fields.c,v 1.5 1997/12/07 23:27:04 marekm Exp $")
|
||||
* characters. If any illegal characters are found, valid_field
|
||||
* returns -1. Zero is returned for success.
|
||||
*/
|
||||
|
||||
int
|
||||
valid_field(const char *field, const char *illegal)
|
||||
int valid_field (const char *field, const char *illegal)
|
||||
{
|
||||
const char *cp;
|
||||
|
||||
for (cp = field; *cp && isprint(*cp & 0x7F) && !strchr(illegal, *cp); cp++)
|
||||
;
|
||||
for (cp = field;
|
||||
*cp && isprint (*cp & 0x7F) && !strchr (illegal, *cp); cp++);
|
||||
|
||||
if (*cp)
|
||||
return -1;
|
||||
@@ -66,20 +62,19 @@ valid_field(const char *field, const char *illegal)
|
||||
* current value.
|
||||
*/
|
||||
|
||||
void
|
||||
change_field(char *buf, size_t maxsize, const char *prompt)
|
||||
void change_field (char *buf, size_t maxsize, const char *prompt)
|
||||
{
|
||||
char newf[200];
|
||||
char *cp;
|
||||
|
||||
if (maxsize > sizeof(newf))
|
||||
maxsize = sizeof(newf);
|
||||
if (maxsize > sizeof (newf))
|
||||
maxsize = sizeof (newf);
|
||||
|
||||
printf ("\t%s [%s]: ", prompt, buf);
|
||||
if (fgets(newf, maxsize, stdin) != newf)
|
||||
if (fgets (newf, maxsize, stdin) != newf)
|
||||
return;
|
||||
|
||||
if (!(cp = strchr(newf, '\n')))
|
||||
if (!(cp = strchr (newf, '\n')))
|
||||
return;
|
||||
*cp = '\0';
|
||||
|
||||
@@ -90,15 +85,14 @@ change_field(char *buf, size_t maxsize, const char *prompt)
|
||||
* entering a space. --marekm
|
||||
*/
|
||||
|
||||
while (--cp >= newf && isspace(*cp))
|
||||
;
|
||||
while (--cp >= newf && isspace (*cp));
|
||||
*++cp = '\0';
|
||||
|
||||
cp = newf;
|
||||
while (*cp && isspace(*cp))
|
||||
while (*cp && isspace (*cp))
|
||||
cp++;
|
||||
|
||||
strncpy(buf, cp, maxsize - 1);
|
||||
strncpy (buf, cp, maxsize - 1);
|
||||
buf[maxsize - 1] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
1456
libmisc/getdate.c
1456
libmisc/getdate.c
File diff suppressed because it is too large
Load Diff
@@ -519,17 +519,6 @@ static TABLE const TimezoneTable[] = {
|
||||
{ "bst", tDAYZONE, HOUR ( 0) }, /* British Summer */
|
||||
{ "wat", tZONE, HOUR ( 1) }, /* West Africa */
|
||||
{ "at", tZONE, HOUR ( 2) }, /* Azores */
|
||||
#if 0
|
||||
/* For completeness. BST is also British Summer, and GST is
|
||||
* also Guam Standard. */
|
||||
{ "bst", tZONE, HOUR ( 3) }, /* Brazil Standard */
|
||||
{ "gst", tZONE, HOUR ( 3) }, /* Greenland Standard */
|
||||
#endif
|
||||
#if 0
|
||||
{ "nft", tZONE, HOUR (3.5) }, /* Newfoundland */
|
||||
{ "nst", tZONE, HOUR (3.5) }, /* Newfoundland Standard */
|
||||
{ "ndt", tDAYZONE, HOUR (3.5) }, /* Newfoundland Daylight */
|
||||
#endif
|
||||
{ "ast", tZONE, HOUR ( 4) }, /* Atlantic Standard */
|
||||
{ "adt", tDAYZONE, HOUR ( 4) }, /* Atlantic Daylight */
|
||||
{ "est", tZONE, HOUR ( 5) }, /* Eastern Standard */
|
||||
@@ -559,32 +548,13 @@ static TABLE const TimezoneTable[] = {
|
||||
{ "fst", tDAYZONE, -HOUR (1) }, /* French Summer */
|
||||
{ "eet", tZONE, -HOUR (2) }, /* Eastern Europe, USSR Zone 1 */
|
||||
{ "bt", tZONE, -HOUR (3) }, /* Baghdad, USSR Zone 2 */
|
||||
#if 0
|
||||
{ "it", tZONE, -HOUR (3.5) },/* Iran */
|
||||
#endif
|
||||
{ "zp4", tZONE, -HOUR (4) }, /* USSR Zone 3 */
|
||||
{ "zp5", tZONE, -HOUR (5) }, /* USSR Zone 4 */
|
||||
#if 0
|
||||
{ "ist", tZONE, -HOUR (5.5) },/* Indian Standard */
|
||||
#endif
|
||||
{ "zp6", tZONE, -HOUR (6) }, /* USSR Zone 5 */
|
||||
#if 0
|
||||
/* For completeness. NST is also Newfoundland Standard, and SST is
|
||||
* also Swedish Summer. */
|
||||
{ "nst", tZONE, -HOUR (6.5) },/* North Sumatra */
|
||||
{ "sst", tZONE, -HOUR (7) }, /* South Sumatra, USSR Zone 6 */
|
||||
#endif /* 0 */
|
||||
{ "wast", tZONE, -HOUR (7) }, /* West Australian Standard */
|
||||
{ "wadt", tDAYZONE, -HOUR (7) }, /* West Australian Daylight */
|
||||
#if 0
|
||||
{ "jt", tZONE, -HOUR (7.5) },/* Java (3pm in Cronusland!) */
|
||||
#endif
|
||||
{ "cct", tZONE, -HOUR (8) }, /* China Coast, USSR Zone 7 */
|
||||
{ "jst", tZONE, -HOUR (9) }, /* Japan Standard, USSR Zone 8 */
|
||||
#if 0
|
||||
{ "cast", tZONE, -HOUR (9.5) },/* Central Australian Standard */
|
||||
{ "cadt", tDAYZONE, -HOUR (9.5) },/* Central Australian Daylight */
|
||||
#endif
|
||||
{ "east", tZONE, -HOUR (10) }, /* Eastern Australian Standard */
|
||||
{ "eadt", tDAYZONE, -HOUR (10) }, /* Eastern Australian Daylight */
|
||||
{ "gst", tZONE, -HOUR (10) }, /* Guam Standard, USSR Zone 9 */
|
||||
|
||||
@@ -30,24 +30,20 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: hushed.c,v 1.4 2000/08/26 18:27:17 marekm Exp $")
|
||||
|
||||
RCSID ("$Id: hushed.c,v 1.5 2003/04/22 10:59:22 kloczek Exp $")
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include "defines.h"
|
||||
#include "prototypes.h"
|
||||
#include "getdef.h"
|
||||
#include <pwd.h>
|
||||
|
||||
/*
|
||||
* hushed - determine if a user receives login messages
|
||||
*
|
||||
* Look in the hushed-logins file (or user's home directory) to see
|
||||
* if the user is to receive the login-time messages.
|
||||
*/
|
||||
|
||||
int
|
||||
hushed(const struct passwd *pw)
|
||||
int hushed (const struct passwd *pw)
|
||||
{
|
||||
char *hushfile;
|
||||
char buf[BUFSIZ];
|
||||
@@ -59,7 +55,7 @@ hushed(const struct passwd *pw)
|
||||
* defined, default to a noisy login.
|
||||
*/
|
||||
|
||||
if ( (hushfile=getdef_str("HUSHLOGIN_FILE")) == NULL )
|
||||
if ((hushfile = getdef_str ("HUSHLOGIN_FILE")) == NULL)
|
||||
return 0;
|
||||
|
||||
/*
|
||||
@@ -68,8 +64,9 @@ hushed(const struct passwd *pw)
|
||||
*/
|
||||
|
||||
if (hushfile[0] != '/') {
|
||||
snprintf(buf, sizeof(buf), "%s/%s", pw->pw_dir, hushfile);
|
||||
return (access(buf, F_OK) == 0);
|
||||
snprintf (buf, sizeof (buf), "%s/%s", pw->pw_dir,
|
||||
hushfile);
|
||||
return (access (buf, F_OK) == 0);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -77,14 +74,15 @@ hushed(const struct passwd *pw)
|
||||
* and see if this user is in there.
|
||||
*/
|
||||
|
||||
if ((fp = fopen(hushfile, "r")) == NULL)
|
||||
if ((fp = fopen (hushfile, "r")) == NULL)
|
||||
return 0;
|
||||
|
||||
for (found = 0;! found && fgets (buf, sizeof buf, fp);) {
|
||||
for (found = 0; !found && fgets (buf, sizeof buf, fp);) {
|
||||
buf[strlen (buf) - 1] = '\0';
|
||||
found = ! strcmp (buf,
|
||||
buf[0] == '/' ? pw->pw_shell:pw->pw_name);
|
||||
found = !strcmp (buf,
|
||||
buf[0] ==
|
||||
'/' ? pw->pw_shell : pw->pw_name);
|
||||
}
|
||||
(void) fclose(fp);
|
||||
(void) fclose (fp);
|
||||
return found;
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
#include <time.h>
|
||||
#include "rcsid.h"
|
||||
|
||||
RCSID("$Id: isexpired.c,v 1.9 2002/01/06 14:02:39 kloczek Exp $")
|
||||
RCSID ("$Id: isexpired.c,v 1.11 2003/05/03 16:14:33 kloczek Exp $")
|
||||
|
||||
/*
|
||||
* isexpired - determine if account is expired yet
|
||||
@@ -49,18 +49,16 @@ RCSID("$Id: isexpired.c,v 1.9 2002/01/06 14:02:39 kloczek Exp $")
|
||||
* isexpired calculates the expiration date based on the
|
||||
* password expiration criteria.
|
||||
*/
|
||||
|
||||
/*ARGSUSED*/
|
||||
|
||||
/*ARGSUSED*/
|
||||
#ifdef SHADOWPWD
|
||||
int
|
||||
isexpired(const struct passwd *pw, const struct spwd *sp)
|
||||
int isexpired (const struct passwd *pw, const struct spwd *sp)
|
||||
{
|
||||
long now;
|
||||
long now;
|
||||
|
||||
now = time ((time_t *) 0) / SCALE;
|
||||
|
||||
if (!sp)
|
||||
sp = pwd_to_spwd(pw);
|
||||
sp = pwd_to_spwd (pw);
|
||||
|
||||
/*
|
||||
* Quick and easy - there is an expired account field
|
||||
@@ -79,11 +77,12 @@ isexpired(const struct passwd *pw, const struct spwd *sp)
|
||||
* if /etc/shadow doesn't exist, getspnam() still succeeds and
|
||||
* returns sp_lstchg==0 (must change password) instead of -1!
|
||||
*/
|
||||
if (sp->sp_lstchg == 0 && !strcmp(pw->pw_passwd, SHADOW_PASSWD_STRING))
|
||||
if (sp->sp_lstchg == 0
|
||||
&& !strcmp (pw->pw_passwd, SHADOW_PASSWD_STRING))
|
||||
return 1;
|
||||
|
||||
if (sp->sp_lstchg > 0 && sp->sp_max >= 0 && sp->sp_inact >= 0 &&
|
||||
now >= sp->sp_lstchg + sp->sp_max + sp->sp_inact)
|
||||
now >= sp->sp_lstchg + sp->sp_max + sp->sp_inact)
|
||||
return 2;
|
||||
|
||||
/*
|
||||
@@ -93,12 +92,8 @@ isexpired(const struct passwd *pw, const struct spwd *sp)
|
||||
*/
|
||||
|
||||
if (sp->sp_lstchg == -1 ||
|
||||
sp->sp_max == -1 || sp->sp_max >= (10000L*DAY/SCALE))
|
||||
sp->sp_max == -1 || sp->sp_max >= (10000L * DAY / SCALE))
|
||||
return 0;
|
||||
#ifdef ATT_AGE
|
||||
if (pw->pw_age[0] == '\0' || pw->pw_age[0] == '/')
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Calculate today's day and the day on which the password
|
||||
@@ -108,10 +103,6 @@ isexpired(const struct passwd *pw, const struct spwd *sp)
|
||||
|
||||
if (now >= sp->sp_lstchg + sp->sp_max)
|
||||
return 1;
|
||||
#ifdef ATT_AGE
|
||||
if (a64l (pw->pw_age + 2) + c64i (pw->pw_age[1]) < now / 7)
|
||||
return 1;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
#endif /* SHADOWPWD */
|
||||
#endif /* SHADOWPWD */
|
||||
|
||||
194
libmisc/limits.c
194
libmisc/limits.c
@@ -35,32 +35,24 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: limits.c,v 1.10 1999/08/27 19:02:51 marekm Exp $")
|
||||
|
||||
RCSID ("$Id: limits.c,v 1.14 2003/05/05 21:44:15 kloczek Exp $")
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
#include <pwd.h>
|
||||
#include "getdef.h"
|
||||
|
||||
#ifdef HAVE_SYS_RESOURCE_H
|
||||
#include <sys/resource.h>
|
||||
#define LIMITS
|
||||
#endif
|
||||
|
||||
#ifdef LIMITS
|
||||
|
||||
#ifndef LIMITS_FILE
|
||||
#define LIMITS_FILE "/etc/limits"
|
||||
#endif
|
||||
|
||||
#define LOGIN_ERROR_RLIMIT 1
|
||||
#define LOGIN_ERROR_LOGIN 2
|
||||
|
||||
/* Set a limit on a resource */
|
||||
/*
|
||||
* rlimit - RLIMIT_XXXX
|
||||
@@ -68,94 +60,105 @@ RCSID("$Id: limits.c,v 1.10 1999/08/27 19:02:51 marekm Exp $")
|
||||
* multiplier - value*multiplier is the actual limit
|
||||
*/
|
||||
static int
|
||||
setrlimit_value(unsigned int rlimit, const char *value, unsigned int multiplier)
|
||||
setrlimit_value (unsigned int rlimit, const char *value,
|
||||
unsigned int multiplier)
|
||||
{
|
||||
struct rlimit rlim;
|
||||
long limit;
|
||||
char **endptr = (char **) &value;
|
||||
const char *value_orig = value;
|
||||
|
||||
limit = strtol(value, endptr, 10);
|
||||
if (limit == 0 && value_orig == *endptr) /* no chars read */
|
||||
limit = strtol (value, endptr, 10);
|
||||
if (limit == 0 && value_orig == *endptr) /* no chars read */
|
||||
return 0;
|
||||
limit *= multiplier;
|
||||
rlim.rlim_cur = limit;
|
||||
rlim.rlim_max = limit;
|
||||
if (setrlimit(rlimit, &rlim))
|
||||
if (setrlimit (rlimit, &rlim))
|
||||
return LOGIN_ERROR_RLIMIT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
set_prio(const char *value)
|
||||
static int set_prio (const char *value)
|
||||
{
|
||||
int prio;
|
||||
char **endptr = (char **) &value;
|
||||
|
||||
prio = strtol(value, endptr, 10);
|
||||
prio = strtol (value, endptr, 10);
|
||||
if ((prio == 0) && (value == *endptr))
|
||||
return 0;
|
||||
if (setpriority(PRIO_PROCESS, 0, prio))
|
||||
if (setpriority (PRIO_PROCESS, 0, prio))
|
||||
return LOGIN_ERROR_RLIMIT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
set_umask(const char *value)
|
||||
static int set_umask (const char *value)
|
||||
{
|
||||
mode_t mask;
|
||||
char **endptr = (char **) &value;
|
||||
|
||||
mask = strtol(value, endptr, 8) & 0777;
|
||||
mask = strtol (value, endptr, 8) & 0777;
|
||||
if ((mask == 0) && (value == *endptr))
|
||||
return 0;
|
||||
umask(mask);
|
||||
umask (mask);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Counts the number of user logins and check against the limit */
|
||||
static int
|
||||
check_logins(const char *name, const char *maxlogins)
|
||||
static int check_logins (const char *name, const char *maxlogins)
|
||||
{
|
||||
#if HAVE_UTMPX_H
|
||||
struct utmpx *ut;
|
||||
#else
|
||||
struct utmp *ut;
|
||||
#endif
|
||||
unsigned int limit, count;
|
||||
char **endptr = (char **) &maxlogins;
|
||||
const char *ml_orig = maxlogins;
|
||||
|
||||
limit = strtol(maxlogins, endptr, 10);
|
||||
if (limit == 0 && ml_orig == *endptr) /* no chars read */
|
||||
limit = strtol (maxlogins, endptr, 10);
|
||||
if (limit == 0 && ml_orig == *endptr) /* no chars read */
|
||||
return 0;
|
||||
|
||||
if (limit == 0) /* maximum 0 logins ? */ {
|
||||
SYSLOG((LOG_WARN, "No logins allowed for `%s'\n", name));
|
||||
if (limit == 0) { /* maximum 0 logins ? */
|
||||
SYSLOG ((LOG_WARN, "No logins allowed for `%s'\n", name));
|
||||
return LOGIN_ERROR_LOGIN;
|
||||
}
|
||||
|
||||
setutent();
|
||||
count = 0;
|
||||
while ((ut = getutent())) {
|
||||
#if HAVE_UTMPX_H
|
||||
setutxent ();
|
||||
while ((ut = getutxent ())) {
|
||||
#else
|
||||
setutent ();
|
||||
while ((ut = getutent ())) {
|
||||
#endif
|
||||
#ifdef USER_PROCESS
|
||||
if (ut->ut_type != USER_PROCESS)
|
||||
continue;
|
||||
#endif
|
||||
if (ut->ut_user[0] == '\0')
|
||||
continue;
|
||||
if (strncmp(name, ut->ut_user, sizeof(ut->ut_user)) != 0)
|
||||
if (strncmp (name, ut->ut_user, sizeof (ut->ut_user)) != 0)
|
||||
continue;
|
||||
if (++count > limit)
|
||||
break;
|
||||
}
|
||||
endutent();
|
||||
#if HAVE_UTMPX_H
|
||||
endutxent ();
|
||||
#else
|
||||
endutent ();
|
||||
#endif
|
||||
/*
|
||||
* This is called after setutmp(), so the number of logins counted
|
||||
* includes the user who is currently trying to log in.
|
||||
*/
|
||||
if (count > limit) {
|
||||
SYSLOG((LOG_WARN, "Too many logins (max %d) for %s\n",
|
||||
limit, name));
|
||||
SYSLOG ((LOG_WARN, "Too many logins (max %d) for %s\n",
|
||||
limit, name));
|
||||
return LOGIN_ERROR_LOGIN;
|
||||
}
|
||||
return 0;
|
||||
@@ -191,103 +194,103 @@ check_logins(const char *name, const char *maxlogins)
|
||||
* buf - the limits string
|
||||
* name - the username
|
||||
*/
|
||||
static int
|
||||
do_user_limits(const char *buf, const char *name)
|
||||
static int do_user_limits (const char *buf, const char *name)
|
||||
{
|
||||
const char *pp;
|
||||
int retval = 0;
|
||||
|
||||
pp = buf;
|
||||
|
||||
while (*pp != '\0') switch(*pp++) {
|
||||
while (*pp != '\0')
|
||||
switch (*pp++) {
|
||||
#ifdef RLIMIT_AS
|
||||
case 'a':
|
||||
case 'A':
|
||||
/* RLIMIT_AS - max address space (KB) */
|
||||
retval |= setrlimit_value(RLIMIT_AS, pp, 1024);
|
||||
retval |= setrlimit_value (RLIMIT_AS, pp, 1024);
|
||||
#endif
|
||||
#ifdef RLIMIT_CPU
|
||||
case 't':
|
||||
case 'T':
|
||||
/* RLIMIT_CPU - max CPU time (MIN) */
|
||||
retval |= setrlimit_value(RLIMIT_CPU, pp, 60);
|
||||
retval |= setrlimit_value (RLIMIT_CPU, pp, 60);
|
||||
break;
|
||||
#endif
|
||||
#ifdef RLIMIT_DATA
|
||||
case 'd':
|
||||
case 'D':
|
||||
/* RLIMIT_DATA - max data size (KB) */
|
||||
retval |= setrlimit_value(RLIMIT_DATA, pp, 1024);
|
||||
retval |= setrlimit_value (RLIMIT_DATA, pp, 1024);
|
||||
break;
|
||||
#endif
|
||||
#ifdef RLIMIT_FSIZE
|
||||
case 'f':
|
||||
case 'F':
|
||||
/* RLIMIT_FSIZE - Maximum filesize (KB) */
|
||||
retval |= setrlimit_value(RLIMIT_FSIZE, pp, 1024);
|
||||
retval |= setrlimit_value (RLIMIT_FSIZE, pp, 1024);
|
||||
break;
|
||||
#endif
|
||||
#ifdef RLIMIT_NPROC
|
||||
case 'u':
|
||||
case 'U':
|
||||
/* RLIMIT_NPROC - max number of processes */
|
||||
retval |= setrlimit_value(RLIMIT_NPROC, pp, 1);
|
||||
retval |= setrlimit_value (RLIMIT_NPROC, pp, 1);
|
||||
break;
|
||||
#endif
|
||||
#ifdef RLIMIT_CORE
|
||||
case 'c':
|
||||
case 'C':
|
||||
/* RLIMIT_CORE - max core file size (KB) */
|
||||
retval |= setrlimit_value(RLIMIT_CORE, pp, 1024);
|
||||
retval |= setrlimit_value (RLIMIT_CORE, pp, 1024);
|
||||
break;
|
||||
#endif
|
||||
#ifdef RLIMIT_MEMLOCK
|
||||
case 'm':
|
||||
case 'M':
|
||||
/* RLIMIT_MEMLOCK - max locked-in-memory address space (KB) */
|
||||
retval |= setrlimit_value(RLIMIT_MEMLOCK, pp, 1024);
|
||||
/* RLIMIT_MEMLOCK - max locked-in-memory address space (KB) */
|
||||
retval |=
|
||||
setrlimit_value (RLIMIT_MEMLOCK, pp, 1024);
|
||||
break;
|
||||
#endif
|
||||
#ifdef RLIMIT_NOFILE
|
||||
case 'n':
|
||||
case 'N':
|
||||
/* RLIMIT_NOFILE - max number of open files */
|
||||
retval |= setrlimit_value(RLIMIT_NOFILE, pp, 1);
|
||||
retval |= setrlimit_value (RLIMIT_NOFILE, pp, 1);
|
||||
break;
|
||||
#endif
|
||||
#ifdef RLIMIT_RSS
|
||||
case 'r':
|
||||
case 'R':
|
||||
/* RLIMIT_RSS - max resident set size (KB) */
|
||||
retval |= setrlimit_value(RLIMIT_RSS, pp, 1024);
|
||||
retval |= setrlimit_value (RLIMIT_RSS, pp, 1024);
|
||||
break;
|
||||
#endif
|
||||
#ifdef RLIMIT_STACK
|
||||
case 's':
|
||||
case 'S':
|
||||
/* RLIMIT_STACK - max stack size (KB) */
|
||||
retval |= setrlimit_value(RLIMIT_STACK, pp, 1024);
|
||||
retval |= setrlimit_value (RLIMIT_STACK, pp, 1024);
|
||||
break;
|
||||
#endif
|
||||
case 'k':
|
||||
case 'K':
|
||||
retval |= set_umask(pp);
|
||||
retval |= set_umask (pp);
|
||||
break;
|
||||
case 'l':
|
||||
case 'L':
|
||||
/* LIMIT the number of concurent logins */
|
||||
retval |= check_logins(name, pp);
|
||||
retval |= check_logins (name, pp);
|
||||
break;
|
||||
case 'p':
|
||||
case 'P':
|
||||
retval |= set_prio(pp);
|
||||
retval |= set_prio (pp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
static int
|
||||
setup_user_limits(const char *uname)
|
||||
static int setup_user_limits (const char *uname)
|
||||
{
|
||||
/* TODO: allow and use @group syntax --cristiang */
|
||||
FILE *fil;
|
||||
@@ -298,28 +301,25 @@ setup_user_limits(const char *uname)
|
||||
char tempbuf[1024];
|
||||
|
||||
/* init things */
|
||||
memzero(buf, sizeof(buf));
|
||||
memzero(name, sizeof(name));
|
||||
memzero(limits, sizeof(limits));
|
||||
memzero(deflimits, sizeof(deflimits));
|
||||
memzero(tempbuf, sizeof(tempbuf));
|
||||
memzero (buf, sizeof (buf));
|
||||
memzero (name, sizeof (name));
|
||||
memzero (limits, sizeof (limits));
|
||||
memzero (deflimits, sizeof (deflimits));
|
||||
memzero (tempbuf, sizeof (tempbuf));
|
||||
|
||||
/* start the checks */
|
||||
fil = fopen(LIMITS_FILE, "r");
|
||||
fil = fopen (LIMITS_FILE, "r");
|
||||
if (fil == NULL) {
|
||||
#if 0 /* no limits file is ok, not everyone is a BOFH :-). --marekm */
|
||||
SYSLOG((LOG_WARN, NO_LIMITS, uname, LIMITS_FILE));
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
/* The limits file have the following format:
|
||||
* - '#' (comment) chars only as first chars on a line;
|
||||
* - username must start on first column
|
||||
* A better (smarter) checking should be done --cristiang */
|
||||
while (fgets(buf, 1024, fil) != NULL) {
|
||||
if (buf[0]=='#' || buf[0]=='\n')
|
||||
while (fgets (buf, 1024, fil) != NULL) {
|
||||
if (buf[0] == '#' || buf[0] == '\n')
|
||||
continue;
|
||||
memzero(tempbuf, sizeof(tempbuf));
|
||||
memzero (tempbuf, sizeof (tempbuf));
|
||||
/* a valid line should have a username, then spaces,
|
||||
* then limits
|
||||
* we allow the format:
|
||||
@@ -328,30 +328,29 @@ setup_user_limits(const char *uname)
|
||||
* Imposing a limit should be done with care, so a wrong
|
||||
* entry means no care anyway :-). A '-' as a limits
|
||||
* strings means no limits --cristiang */
|
||||
if (sscanf(buf, "%s%[ACDFMNRSTULPacdfmnrstulp0-9 \t-]",
|
||||
name, tempbuf) == 2) {
|
||||
if (strcmp(name, uname) == 0) {
|
||||
strcpy(limits, tempbuf);
|
||||
if (sscanf (buf, "%s%[ACDFMNRSTULPacdfmnrstulp0-9 \t-]",
|
||||
name, tempbuf) == 2) {
|
||||
if (strcmp (name, uname) == 0) {
|
||||
strcpy (limits, tempbuf);
|
||||
break;
|
||||
} else if (strcmp(name, "*") == 0) {
|
||||
strcpy(deflimits, tempbuf);
|
||||
} else if (strcmp (name, "*") == 0) {
|
||||
strcpy (deflimits, tempbuf);
|
||||
}
|
||||
}
|
||||
}
|
||||
fclose(fil);
|
||||
fclose (fil);
|
||||
if (limits[0] == '\0') {
|
||||
/* no user specific limits */
|
||||
if (deflimits[0] == '\0') /* no default limits */
|
||||
if (deflimits[0] == '\0') /* no default limits */
|
||||
return 0;
|
||||
strcpy(limits, deflimits); /* use the default limits */
|
||||
strcpy (limits, deflimits); /* use the default limits */
|
||||
}
|
||||
return do_user_limits(limits, uname);
|
||||
return do_user_limits (limits, uname);
|
||||
}
|
||||
#endif /* LIMITS */
|
||||
#endif /* LIMITS */
|
||||
|
||||
|
||||
static void
|
||||
setup_usergroups(const struct passwd *info)
|
||||
static void setup_usergroups (const struct passwd *info)
|
||||
{
|
||||
const struct group *grp;
|
||||
mode_t oldmask;
|
||||
@@ -362,10 +361,10 @@ setup_usergroups(const struct passwd *info)
|
||||
* (examples: 022 -> 002, 077 -> 007).
|
||||
*/
|
||||
if (info->pw_uid != 0 && info->pw_uid == info->pw_gid) {
|
||||
grp = getgrgid(info->pw_gid);
|
||||
if (grp && (strcmp(info->pw_name, grp->gr_name) == 0)) {
|
||||
oldmask = umask(0777);
|
||||
umask((oldmask & ~070) | ((oldmask >> 3) & 070));
|
||||
grp = getgrgid (info->pw_gid);
|
||||
if (grp && (strcmp (info->pw_name, grp->gr_name) == 0)) {
|
||||
oldmask = umask (0777);
|
||||
umask ((oldmask & ~070) | ((oldmask >> 3) & 070));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -374,15 +373,14 @@ setup_usergroups(const struct passwd *info)
|
||||
* set the process nice, ulimit, and umask from the password file entry
|
||||
*/
|
||||
|
||||
void
|
||||
setup_limits(const struct passwd *info)
|
||||
void setup_limits (const struct passwd *info)
|
||||
{
|
||||
char *cp;
|
||||
int i;
|
||||
long l;
|
||||
char *cp;
|
||||
int i;
|
||||
long l;
|
||||
|
||||
if (getdef_bool("USERGROUPS_ENAB"))
|
||||
setup_usergroups(info);
|
||||
if (getdef_bool ("USERGROUPS_ENAB"))
|
||||
setup_usergroups (info);
|
||||
|
||||
/*
|
||||
* See if the GECOS field contains values for NICE, UMASK or ULIMIT.
|
||||
@@ -390,16 +388,18 @@ setup_limits(const struct passwd *info)
|
||||
* values the defaults for this login session.
|
||||
*/
|
||||
|
||||
if (getdef_bool("QUOTAS_ENAB")) {
|
||||
if (getdef_bool ("QUOTAS_ENAB")) {
|
||||
#ifdef LIMITS
|
||||
if (info->pw_uid != 0)
|
||||
if (setup_user_limits(info->pw_name) & LOGIN_ERROR_LOGIN) {
|
||||
fprintf(stderr, _("Too many logins.\n"));
|
||||
sleep(2);
|
||||
exit(1);
|
||||
}
|
||||
if (setup_user_limits (info->pw_name) &
|
||||
LOGIN_ERROR_LOGIN) {
|
||||
fprintf (stderr, _("Too many logins.\n"));
|
||||
sleep (2);
|
||||
exit (1);
|
||||
}
|
||||
#endif
|
||||
for (cp = info->pw_gecos ; cp != NULL ; cp = strchr (cp, ',')) {
|
||||
for (cp = info->pw_gecos; cp != NULL;
|
||||
cp = strchr (cp, ',')) {
|
||||
if (*cp == ',')
|
||||
cp++;
|
||||
|
||||
@@ -412,7 +412,7 @@ setup_limits(const struct passwd *info)
|
||||
}
|
||||
if (strncmp (cp, "ulimit=", 7) == 0) {
|
||||
l = strtol (cp + 7, (char **) 0, 10);
|
||||
set_filesize_limit(l);
|
||||
set_filesize_limit (l);
|
||||
continue;
|
||||
}
|
||||
if (strncmp (cp, "umask=", 6) == 0) {
|
||||
|
||||
@@ -33,11 +33,9 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: list.c,v 1.3 1997/12/07 23:27:05 marekm Exp $")
|
||||
|
||||
RCSID ("$Id: list.c,v 1.4 2003/04/22 10:59:22 kloczek Exp $")
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
|
||||
/*
|
||||
* add_list - add a member to a list of group members
|
||||
*
|
||||
@@ -45,19 +43,17 @@ RCSID("$Id: list.c,v 1.3 1997/12/07 23:27:05 marekm Exp $")
|
||||
* name, and if not present it is added to a freshly allocated
|
||||
* list of users.
|
||||
*/
|
||||
|
||||
char **
|
||||
add_list(char **list, const char *member)
|
||||
char **add_list (char **list, const char *member)
|
||||
{
|
||||
int i;
|
||||
char **tmp;
|
||||
int i;
|
||||
char **tmp;
|
||||
|
||||
/*
|
||||
* Scan the list for the new name. Return the original list
|
||||
* pointer if it is present.
|
||||
*/
|
||||
|
||||
for (i = 0;list[i] != (char *) 0;i++)
|
||||
for (i = 0; list[i] != (char *) 0; i++)
|
||||
if (strcmp (list[i], member) == 0)
|
||||
return list;
|
||||
|
||||
@@ -74,7 +70,7 @@ add_list(char **list, const char *member)
|
||||
* is returned to the invoker.
|
||||
*/
|
||||
|
||||
for (i = 0;list[i] != (char *) 0;i++)
|
||||
for (i = 0; list[i] != (char *) 0; i++)
|
||||
tmp[i] = list[i];
|
||||
|
||||
tmp[i++] = xstrdup (member);
|
||||
@@ -91,18 +87,17 @@ add_list(char **list, const char *member)
|
||||
* list of users.
|
||||
*/
|
||||
|
||||
char **
|
||||
del_list(char **list, const char *member)
|
||||
char **del_list (char **list, const char *member)
|
||||
{
|
||||
int i, j;
|
||||
char **tmp;
|
||||
int i, j;
|
||||
char **tmp;
|
||||
|
||||
/*
|
||||
* Scan the list for the old name. Return the original list
|
||||
* pointer if it is not present.
|
||||
*/
|
||||
|
||||
for (i = j = 0;list[i] != (char *) 0;i++)
|
||||
for (i = j = 0; list[i] != (char *) 0; i++)
|
||||
if (strcmp (list[i], member))
|
||||
j++;
|
||||
|
||||
@@ -122,7 +117,7 @@ del_list(char **list, const char *member)
|
||||
* is returned to the invoker.
|
||||
*/
|
||||
|
||||
for (i = j = 0;list[i] != (char *) 0;i++)
|
||||
for (i = j = 0; list[i] != (char *) 0; i++)
|
||||
if (strcmp (list[i], member))
|
||||
tmp[j++] = list[i];
|
||||
|
||||
@@ -131,30 +126,27 @@ del_list(char **list, const char *member)
|
||||
return tmp;
|
||||
}
|
||||
|
||||
char **
|
||||
dup_list(char * const *list)
|
||||
char **dup_list (char *const *list)
|
||||
{
|
||||
int i;
|
||||
char **tmp;
|
||||
|
||||
for (i = 0; list[i]; i++)
|
||||
;
|
||||
for (i = 0; list[i]; i++);
|
||||
|
||||
tmp = (char **) xmalloc((i + 1) * sizeof(char *));
|
||||
tmp = (char **) xmalloc ((i + 1) * sizeof (char *));
|
||||
|
||||
i = 0;
|
||||
while (*list)
|
||||
tmp[i++] = xstrdup(*list++);
|
||||
tmp[i++] = xstrdup (*list++);
|
||||
|
||||
tmp[i] = (char *) 0;
|
||||
return tmp;
|
||||
}
|
||||
|
||||
int
|
||||
is_on_list(char * const *list, const char *member)
|
||||
int is_on_list (char *const *list, const char *member)
|
||||
{
|
||||
while (*list) {
|
||||
if (strcmp(*list, member) == 0)
|
||||
if (strcmp (*list, member) == 0)
|
||||
return 1;
|
||||
list++;
|
||||
}
|
||||
@@ -165,13 +157,12 @@ is_on_list(char * const *list, const char *member)
|
||||
* comma_to_list - convert comma-separated list to (char *) array
|
||||
*/
|
||||
|
||||
char **
|
||||
comma_to_list(const char *comma)
|
||||
char **comma_to_list (const char *comma)
|
||||
{
|
||||
char *members;
|
||||
char **array;
|
||||
int i;
|
||||
char *cp, *cp2;
|
||||
char *members;
|
||||
char **array;
|
||||
int i;
|
||||
char *cp, *cp2;
|
||||
|
||||
/*
|
||||
* Make a copy since we are going to be modifying the list
|
||||
@@ -183,7 +174,7 @@ comma_to_list(const char *comma)
|
||||
* Count the number of commas in the list
|
||||
*/
|
||||
|
||||
for (cp = members, i = 0;;i++)
|
||||
for (cp = members, i = 0;; i++)
|
||||
if ((cp2 = strchr (cp, ',')))
|
||||
cp = cp2 + 1;
|
||||
else
|
||||
@@ -215,7 +206,7 @@ comma_to_list(const char *comma)
|
||||
* array of pointers.
|
||||
*/
|
||||
|
||||
for (cp = members, i = 0;;i++) {
|
||||
for (cp = members, i = 0;; i++) {
|
||||
array[i] = cp;
|
||||
if ((cp2 = strchr (cp, ','))) {
|
||||
*cp2++ = '\0';
|
||||
|
||||
@@ -30,8 +30,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: log.c,v 1.5 1998/04/16 19:57:44 marekm Exp $")
|
||||
|
||||
RCSID ("$Id: log.c,v 1.7 2003/12/17 12:52:25 kloczek Exp $")
|
||||
#include <sys/types.h>
|
||||
#include <pwd.h>
|
||||
#include <fcntl.h>
|
||||
@@ -42,7 +41,6 @@ RCSID("$Id: log.c,v 1.5 1998/04/16 19:57:44 marekm Exp $")
|
||||
#else
|
||||
#include "lastlog_.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* dolastlog - create lastlog entry
|
||||
*
|
||||
@@ -50,19 +48,20 @@ RCSID("$Id: log.c,v 1.5 1998/04/16 19:57:44 marekm Exp $")
|
||||
* UID is extracted from the global (struct passwd) entry and the
|
||||
* TTY information is gotten from the (struct utmp).
|
||||
*/
|
||||
|
||||
void
|
||||
dolastlog(struct lastlog *ll, const struct passwd *pw, const char *line, const char *host)
|
||||
dolastlog (struct lastlog *ll, const struct passwd *pw, const char *line,
|
||||
const char *host)
|
||||
{
|
||||
int fd;
|
||||
off_t offset;
|
||||
struct lastlog newlog;
|
||||
int fd;
|
||||
off_t offset;
|
||||
struct lastlog newlog;
|
||||
time_t ll_time;
|
||||
|
||||
/*
|
||||
* If the file does not exist, don't create it.
|
||||
*/
|
||||
|
||||
if ((fd = open(LASTLOG_FILE, O_RDWR)) == -1)
|
||||
if ((fd = open (LASTLOG_FILE, O_RDWR)) == -1)
|
||||
return;
|
||||
|
||||
/*
|
||||
@@ -72,8 +71,8 @@ dolastlog(struct lastlog *ll, const struct passwd *pw, const char *line, const c
|
||||
|
||||
offset = (unsigned long) pw->pw_uid * sizeof newlog;
|
||||
|
||||
if (lseek(fd, offset, SEEK_SET) != offset) {
|
||||
close(fd);
|
||||
if (lseek (fd, offset, SEEK_SET) != offset) {
|
||||
close (fd);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -83,18 +82,18 @@ dolastlog(struct lastlog *ll, const struct passwd *pw, const char *line, const c
|
||||
* the way we read the old one in.
|
||||
*/
|
||||
|
||||
if (read(fd, (char *) &newlog, sizeof newlog) != sizeof newlog)
|
||||
memzero(&newlog, sizeof newlog);
|
||||
if (read (fd, (char *) &newlog, sizeof newlog) != sizeof newlog)
|
||||
memzero (&newlog, sizeof newlog);
|
||||
if (ll)
|
||||
*ll = newlog;
|
||||
|
||||
time(&newlog.ll_time);
|
||||
strncpy(newlog.ll_line, line, sizeof newlog.ll_line);
|
||||
ll_time = newlog.ll_time;
|
||||
time (&ll_time);
|
||||
strncpy (newlog.ll_line, line, sizeof newlog.ll_line);
|
||||
#if HAVE_LL_HOST
|
||||
strncpy(newlog.ll_host, host, sizeof newlog.ll_host);
|
||||
strncpy (newlog.ll_host, host, sizeof newlog.ll_host);
|
||||
#endif
|
||||
if (lseek(fd, offset, SEEK_SET) == offset)
|
||||
write(fd, (char *) &newlog, sizeof newlog);
|
||||
close(fd);
|
||||
if (lseek (fd, offset, SEEK_SET) == offset)
|
||||
write (fd, (char *) &newlog, sizeof newlog);
|
||||
close (fd);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,18 +23,16 @@
|
||||
|
||||
#ifdef LOGIN_ACCESS
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: login_access.c,v 1.6 1998/01/29 23:22:34 marekm Exp $")
|
||||
RCSID ("$Id: login_access.c,v 1.9 2003/05/05 21:44:15 kloczek Exp $")
|
||||
#include "prototypes.h"
|
||||
|
||||
/*
|
||||
* This module implements a simple but effective form of login access
|
||||
* control based on login names and on host (or domain) names, internet
|
||||
* addresses (or network numbers), or on terminal line names in case of
|
||||
* non-networked logins. Diagnostics are reported through syslog(3).
|
||||
*
|
||||
* Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This module implements a simple but effective form of login access
|
||||
* control based on login names and on host (or domain) names, internet
|
||||
* addresses (or network numbers), or on terminal line names in case of
|
||||
* non-networked logins. Diagnostics are reported through syslog(3).
|
||||
*
|
||||
* Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
|
||||
*/
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include <syslog.h>
|
||||
@@ -50,13 +48,9 @@ RCSID("$Id: login_access.c,v 1.6 1998/01/29 23:22:34 marekm Exp $")
|
||||
#include <stdlib.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h> /* for inet_ntoa() */
|
||||
|
||||
extern struct group *getgrnam();
|
||||
extern int innetgr();
|
||||
#if 0 /* should be defined by <errno.h> */
|
||||
extern int errno;
|
||||
#endif
|
||||
#include <arpa/inet.h> /* for inet_ntoa() */
|
||||
extern struct group *getgrnam ();
|
||||
extern int innetgr ();
|
||||
|
||||
#if !defined(MAXHOSTNAMELEN) || (MAXHOSTNAMELEN < 64)
|
||||
#undef MAXHOSTNAMELEN
|
||||
@@ -71,270 +65,260 @@ extern int errno;
|
||||
|
||||
/* Delimiters for fields and for lists of users, ttys or hosts. */
|
||||
|
||||
static char fs[] = ":"; /* field separator */
|
||||
static char sep[] = ", \t"; /* list-element separator */
|
||||
static char fs[] = ":"; /* field separator */
|
||||
static char sep[] = ", \t"; /* list-element separator */
|
||||
|
||||
/* Constants to be used in assignments only, not in comparisons... */
|
||||
|
||||
#define YES 1
|
||||
#define NO 0
|
||||
|
||||
static int list_match();
|
||||
static int user_match();
|
||||
static int from_match();
|
||||
static int string_match();
|
||||
static int list_match ();
|
||||
static int user_match ();
|
||||
static int from_match ();
|
||||
static int string_match ();
|
||||
|
||||
/* login_access - match username/group and host/tty with access control file */
|
||||
|
||||
int
|
||||
login_access(const char *user, const char *from)
|
||||
int login_access (const char *user, const char *from)
|
||||
{
|
||||
FILE *fp;
|
||||
char line[BUFSIZ];
|
||||
char *perm; /* becomes permission field */
|
||||
char *users; /* becomes list of login names */
|
||||
char *froms; /* becomes list of terminals or hosts */
|
||||
int match = NO;
|
||||
int end;
|
||||
int lineno = 0; /* for diagnostics */
|
||||
FILE *fp;
|
||||
char line[BUFSIZ];
|
||||
char *perm; /* becomes permission field */
|
||||
char *users; /* becomes list of login names */
|
||||
char *froms; /* becomes list of terminals or hosts */
|
||||
int match = NO;
|
||||
int end;
|
||||
int lineno = 0; /* for diagnostics */
|
||||
|
||||
/*
|
||||
* Process the table one line at a time and stop at the first match.
|
||||
* Blank lines and lines that begin with a '#' character are ignored.
|
||||
* Non-comment lines are broken at the ':' character. All fields are
|
||||
* mandatory. The first field should be a "+" or "-" character. A
|
||||
* non-existing table means no access control.
|
||||
*/
|
||||
/*
|
||||
* Process the table one line at a time and stop at the first match.
|
||||
* Blank lines and lines that begin with a '#' character are ignored.
|
||||
* Non-comment lines are broken at the ':' character. All fields are
|
||||
* mandatory. The first field should be a "+" or "-" character. A
|
||||
* non-existing table means no access control.
|
||||
*/
|
||||
|
||||
if ((fp = fopen(TABLE, "r"))) {
|
||||
while (!match && fgets(line, sizeof(line), fp)) {
|
||||
lineno++;
|
||||
if (line[end = strlen(line) - 1] != '\n') {
|
||||
syslog(LOG_ERR, "%s: line %d: missing newline or line too long",
|
||||
TABLE, lineno);
|
||||
continue;
|
||||
}
|
||||
if (line[0] == '#')
|
||||
continue; /* comment line */
|
||||
while (end > 0 && isspace(line[end - 1]))
|
||||
end--;
|
||||
line[end] = 0; /* strip trailing whitespace */
|
||||
if (line[0] == 0) /* skip blank lines */
|
||||
continue;
|
||||
if (!(perm = strtok(line, fs))
|
||||
|| !(users = strtok((char *) 0, fs))
|
||||
|| !(froms = strtok((char *) 0, fs))
|
||||
|| strtok((char *) 0, fs)) {
|
||||
syslog(LOG_ERR, "%s: line %d: bad field count", TABLE, lineno);
|
||||
continue;
|
||||
}
|
||||
if (perm[0] != '+' && perm[0] != '-') {
|
||||
syslog(LOG_ERR, "%s: line %d: bad first field", TABLE, lineno);
|
||||
continue;
|
||||
}
|
||||
match = (list_match(froms, from, from_match)
|
||||
&& list_match(users, user, user_match));
|
||||
if ((fp = fopen (TABLE, "r"))) {
|
||||
while (!match && fgets (line, sizeof (line), fp)) {
|
||||
lineno++;
|
||||
if (line[end = strlen (line) - 1] != '\n') {
|
||||
syslog (LOG_ERR,
|
||||
"%s: line %d: missing newline or line too long",
|
||||
TABLE, lineno);
|
||||
continue;
|
||||
}
|
||||
if (line[0] == '#')
|
||||
continue; /* comment line */
|
||||
while (end > 0 && isspace (line[end - 1]))
|
||||
end--;
|
||||
line[end] = 0; /* strip trailing whitespace */
|
||||
if (line[0] == 0) /* skip blank lines */
|
||||
continue;
|
||||
if (!(perm = strtok (line, fs))
|
||||
|| !(users = strtok ((char *) 0, fs))
|
||||
|| !(froms = strtok ((char *) 0, fs))
|
||||
|| strtok ((char *) 0, fs)) {
|
||||
syslog (LOG_ERR,
|
||||
"%s: line %d: bad field count",
|
||||
TABLE, lineno);
|
||||
continue;
|
||||
}
|
||||
if (perm[0] != '+' && perm[0] != '-') {
|
||||
syslog (LOG_ERR,
|
||||
"%s: line %d: bad first field",
|
||||
TABLE, lineno);
|
||||
continue;
|
||||
}
|
||||
match = (list_match (froms, from, from_match)
|
||||
&& list_match (users, user, user_match));
|
||||
}
|
||||
(void) fclose (fp);
|
||||
} else if (errno != ENOENT) {
|
||||
syslog (LOG_ERR, "cannot open %s: %m", TABLE);
|
||||
}
|
||||
(void) fclose(fp);
|
||||
} else if (errno != ENOENT) {
|
||||
syslog(LOG_ERR, "cannot open %s: %m", TABLE);
|
||||
}
|
||||
return (match == 0 || (line[0] == '+'));
|
||||
return (match == 0 || (line[0] == '+'));
|
||||
}
|
||||
|
||||
/* list_match - match an item against a list of tokens with exceptions */
|
||||
|
||||
static int
|
||||
list_match(char *list, const char *item, int (*match_fn)())
|
||||
static int list_match (char *list, const char *item, int (*match_fn) ())
|
||||
{
|
||||
char *tok;
|
||||
int match = NO;
|
||||
char *tok;
|
||||
int match = NO;
|
||||
|
||||
/*
|
||||
* Process tokens one at a time. We have exhausted all possible matches
|
||||
* when we reach an "EXCEPT" token or the end of the list. If we do find
|
||||
* a match, look for an "EXCEPT" list and recurse to determine whether
|
||||
* the match is affected by any exceptions.
|
||||
*/
|
||||
/*
|
||||
* Process tokens one at a time. We have exhausted all possible matches
|
||||
* when we reach an "EXCEPT" token or the end of the list. If we do find
|
||||
* a match, look for an "EXCEPT" list and recurse to determine whether
|
||||
* the match is affected by any exceptions.
|
||||
*/
|
||||
|
||||
for (tok = strtok(list, sep); tok != 0; tok = strtok((char *) 0, sep)) {
|
||||
if (strcasecmp(tok, "EXCEPT") == 0) /* EXCEPT: give up */
|
||||
break;
|
||||
if ((match = (*match_fn) (tok, item))) /* YES */
|
||||
break;
|
||||
}
|
||||
/* Process exceptions to matches. */
|
||||
for (tok = strtok (list, sep); tok != 0;
|
||||
tok = strtok ((char *) 0, sep)) {
|
||||
if (strcasecmp (tok, "EXCEPT") == 0) /* EXCEPT: give up */
|
||||
break;
|
||||
if ((match = (*match_fn) (tok, item))) /* YES */
|
||||
break;
|
||||
}
|
||||
/* Process exceptions to matches. */
|
||||
|
||||
if (match != NO) {
|
||||
while ((tok = strtok((char *) 0, sep)) && strcasecmp(tok, "EXCEPT"))
|
||||
/* VOID */ ;
|
||||
if (tok == 0 || list_match((char *) 0, item, match_fn) == NO)
|
||||
return (match);
|
||||
}
|
||||
return (NO);
|
||||
if (match != NO) {
|
||||
while ((tok = strtok ((char *) 0, sep))
|
||||
&& strcasecmp (tok, "EXCEPT"))
|
||||
/* VOID */ ;
|
||||
if (tok == 0
|
||||
|| list_match ((char *) 0, item, match_fn) == NO)
|
||||
return (match);
|
||||
}
|
||||
return (NO);
|
||||
}
|
||||
|
||||
/* myhostname - figure out local machine name */
|
||||
|
||||
static char *
|
||||
myhostname(void)
|
||||
static char *myhostname (void)
|
||||
{
|
||||
static char name[MAXHOSTNAMELEN + 1] = "";
|
||||
static char name[MAXHOSTNAMELEN + 1] = "";
|
||||
|
||||
if (name[0] == 0) {
|
||||
gethostname(name, sizeof(name));
|
||||
name[MAXHOSTNAMELEN] = 0;
|
||||
}
|
||||
return (name);
|
||||
if (name[0] == 0) {
|
||||
gethostname (name, sizeof (name));
|
||||
name[MAXHOSTNAMELEN] = 0;
|
||||
}
|
||||
return (name);
|
||||
}
|
||||
|
||||
/* netgroup_match - match group against machine or user */
|
||||
|
||||
static int
|
||||
netgroup_match(const char *group, const char *machine, const char *user)
|
||||
netgroup_match (const char *group, const char *machine, const char *user)
|
||||
{
|
||||
#if 0 /* original code */
|
||||
#ifdef NIS
|
||||
static char *mydomain = 0;
|
||||
|
||||
if (mydomain == 0)
|
||||
yp_get_default_domain(&mydomain);
|
||||
return (innetgr(group, machine, user, mydomain));
|
||||
#else
|
||||
syslog(LOG_ERR, "NIS netgroup support not configured");
|
||||
return (NO);
|
||||
#endif
|
||||
#else /* works better with glibc? */
|
||||
static char *mydomain = 0;
|
||||
|
||||
if (mydomain == 0) {
|
||||
static char domain[MAXHOSTNAMELEN+1];
|
||||
static char domain[MAXHOSTNAMELEN + 1];
|
||||
|
||||
getdomainname(domain, MAXHOSTNAMELEN);
|
||||
getdomainname (domain, MAXHOSTNAMELEN);
|
||||
mydomain = domain;
|
||||
}
|
||||
|
||||
return innetgr(group, machine, user, mydomain);
|
||||
#endif
|
||||
return innetgr (group, machine, user, mydomain);
|
||||
}
|
||||
|
||||
/* user_match - match a username against one token */
|
||||
|
||||
static int
|
||||
user_match(const char *tok, const char *string)
|
||||
static int user_match (const char *tok, const char *string)
|
||||
{
|
||||
struct group *group;
|
||||
struct group *group;
|
||||
|
||||
#ifdef PRIMARY_GROUP_MATCH
|
||||
struct passwd *userinf;
|
||||
struct passwd *userinf;
|
||||
#endif
|
||||
int i;
|
||||
char *at;
|
||||
int i;
|
||||
char *at;
|
||||
|
||||
/*
|
||||
* If a token has the magic value "ALL" the match always succeeds.
|
||||
* Otherwise, return YES if the token fully matches the username, or if
|
||||
* the token is a group that contains the username.
|
||||
*/
|
||||
|
||||
if ((at = strchr(tok + 1, '@')) != 0) { /* split user@host pattern */
|
||||
*at = 0;
|
||||
return (user_match(tok, string) && from_match(at + 1, myhostname()));
|
||||
} else if (tok[0] == '@') { /* netgroup */
|
||||
return (netgroup_match(tok + 1, (char *) 0, string));
|
||||
} else if (string_match(tok, string)) { /* ALL or exact match */
|
||||
return (YES);
|
||||
} else if ((group = getgrnam(tok))) { /* try group membership */
|
||||
for (i = 0; group->gr_mem[i]; i++)
|
||||
if (strcasecmp(string, group->gr_mem[i]) == 0)
|
||||
return (YES);
|
||||
#ifdef PRIMARY_GROUP_MATCH
|
||||
/*
|
||||
* If the sting is an user whose initial GID matches the token,
|
||||
* accept it. May avoid excessively long lines in /etc/group.
|
||||
* Radu-Adrian Feurdean <raf@licj.soroscj.ro>
|
||||
*
|
||||
* XXX - disabled by default for now. Need to verify that
|
||||
* getpwnam() doesn't have some nasty side effects. --marekm
|
||||
* If a token has the magic value "ALL" the match always succeeds.
|
||||
* Otherwise, return YES if the token fully matches the username, or if
|
||||
* the token is a group that contains the username.
|
||||
*/
|
||||
if ((userinf = getpwnam(string)))
|
||||
if (userinf->pw_gid == group->gr_gid)
|
||||
|
||||
if ((at = strchr (tok + 1, '@')) != 0) { /* split user@host pattern */
|
||||
*at = 0;
|
||||
return (user_match (tok, string)
|
||||
&& from_match (at + 1, myhostname ()));
|
||||
} else if (tok[0] == '@') { /* netgroup */
|
||||
return (netgroup_match (tok + 1, (char *) 0, string));
|
||||
} else if (string_match (tok, string)) { /* ALL or exact match */
|
||||
return (YES);
|
||||
} else if ((group = getgrnam (tok))) { /* try group membership */
|
||||
for (i = 0; group->gr_mem[i]; i++)
|
||||
if (strcasecmp (string, group->gr_mem[i]) == 0)
|
||||
return (YES);
|
||||
#ifdef PRIMARY_GROUP_MATCH
|
||||
/*
|
||||
* If the sting is an user whose initial GID matches the token,
|
||||
* accept it. May avoid excessively long lines in /etc/group.
|
||||
* Radu-Adrian Feurdean <raf@licj.soroscj.ro>
|
||||
*
|
||||
* XXX - disabled by default for now. Need to verify that
|
||||
* getpwnam() doesn't have some nasty side effects. --marekm
|
||||
*/
|
||||
if ((userinf = getpwnam (string)))
|
||||
if (userinf->pw_gid == group->gr_gid)
|
||||
return (YES);
|
||||
#endif
|
||||
}
|
||||
return (NO);
|
||||
}
|
||||
return (NO);
|
||||
}
|
||||
|
||||
static char *
|
||||
resolve_hostname(string)
|
||||
char *string;
|
||||
static char *resolve_hostname (string)
|
||||
char *string;
|
||||
{
|
||||
#if 1
|
||||
/*
|
||||
* Resolve hostname to numeric IP address, as suggested
|
||||
* by Dave Hagewood <admin@arrowweb.com>. --marekm
|
||||
*/
|
||||
struct hostent *hp;
|
||||
/*
|
||||
* Resolve hostname to numeric IP address, as suggested
|
||||
* by Dave Hagewood <admin@arrowweb.com>. --marekm
|
||||
*/
|
||||
struct hostent *hp;
|
||||
|
||||
hp = gethostbyname(string);
|
||||
if (hp)
|
||||
return inet_ntoa(*((struct in_addr *) *(hp->h_addr_list)));
|
||||
hp = gethostbyname (string);
|
||||
if (hp)
|
||||
return
|
||||
inet_ntoa (*((struct in_addr *) *(hp->h_addr_list)));
|
||||
|
||||
syslog(LOG_ERR, "%s - unknown host", string);
|
||||
#endif
|
||||
return string;
|
||||
syslog (LOG_ERR, "%s - unknown host", string);
|
||||
return string;
|
||||
}
|
||||
|
||||
/* from_match - match a host or tty against a list of tokens */
|
||||
|
||||
static int
|
||||
from_match(const char *tok, const char *string)
|
||||
static int from_match (const char *tok, const char *string)
|
||||
{
|
||||
int tok_len;
|
||||
int str_len;
|
||||
int tok_len;
|
||||
int str_len;
|
||||
|
||||
/*
|
||||
* If a token has the magic value "ALL" the match always succeeds. Return
|
||||
* YES if the token fully matches the string. If the token is a domain
|
||||
* name, return YES if it matches the last fields of the string. If the
|
||||
* token has the magic value "LOCAL", return YES if the string does not
|
||||
* contain a "." character. If the token is a network number, return YES
|
||||
* if it matches the head of the string.
|
||||
*/
|
||||
/*
|
||||
* If a token has the magic value "ALL" the match always succeeds. Return
|
||||
* YES if the token fully matches the string. If the token is a domain
|
||||
* name, return YES if it matches the last fields of the string. If the
|
||||
* token has the magic value "LOCAL", return YES if the string does not
|
||||
* contain a "." character. If the token is a network number, return YES
|
||||
* if it matches the head of the string.
|
||||
*/
|
||||
|
||||
if (tok[0] == '@') { /* netgroup */
|
||||
return (netgroup_match(tok + 1, string, (char *) 0));
|
||||
} else if (string_match(tok, string)) { /* ALL or exact match */
|
||||
return (YES);
|
||||
} else if (tok[0] == '.') { /* domain: match last fields */
|
||||
if ((str_len = strlen(string)) > (tok_len = strlen(tok))
|
||||
&& strcasecmp(tok, string + str_len - tok_len) == 0)
|
||||
return (YES);
|
||||
} else if (strcasecmp(tok, "LOCAL") == 0) { /* local: no dots */
|
||||
if (strchr(string, '.') == 0)
|
||||
return (YES);
|
||||
} else if (tok[(tok_len = strlen(tok)) - 1] == '.' /* network */
|
||||
&& strncmp(tok, resolve_hostname(string), tok_len) == 0) {
|
||||
return (YES);
|
||||
}
|
||||
return (NO);
|
||||
if (tok[0] == '@') { /* netgroup */
|
||||
return (netgroup_match (tok + 1, string, (char *) 0));
|
||||
} else if (string_match (tok, string)) { /* ALL or exact match */
|
||||
return (YES);
|
||||
} else if (tok[0] == '.') { /* domain: match last fields */
|
||||
if ((str_len = strlen (string)) > (tok_len = strlen (tok))
|
||||
&& strcasecmp (tok, string + str_len - tok_len) == 0)
|
||||
return (YES);
|
||||
} else if (strcasecmp (tok, "LOCAL") == 0) { /* local: no dots */
|
||||
if (strchr (string, '.') == 0)
|
||||
return (YES);
|
||||
} else if (tok[(tok_len = strlen (tok)) - 1] == '.' /* network */
|
||||
&& strncmp (tok, resolve_hostname (string),
|
||||
tok_len) == 0) {
|
||||
return (YES);
|
||||
}
|
||||
return (NO);
|
||||
}
|
||||
|
||||
/* string_match - match a string against one token */
|
||||
|
||||
static int
|
||||
string_match(const char *tok, const char *string)
|
||||
static int string_match (const char *tok, const char *string)
|
||||
{
|
||||
|
||||
/*
|
||||
* If the token has the magic value "ALL" the match always succeeds.
|
||||
* Otherwise, return YES if the token fully matches the string.
|
||||
*/
|
||||
/*
|
||||
* If the token has the magic value "ALL" the match always succeeds.
|
||||
* Otherwise, return YES if the token fully matches the string.
|
||||
*/
|
||||
|
||||
if (strcasecmp(tok, "ALL") == 0) { /* all: always matches */
|
||||
return (YES);
|
||||
} else if (strcasecmp(tok, string) == 0) { /* try exact match */
|
||||
return (YES);
|
||||
}
|
||||
return (NO);
|
||||
if (strcasecmp (tok, "ALL") == 0) { /* all: always matches */
|
||||
return (YES);
|
||||
} else if (strcasecmp (tok, string) == 0) { /* try exact match */
|
||||
return (YES);
|
||||
}
|
||||
return (NO);
|
||||
}
|
||||
#endif /* LOGIN_ACCESS */
|
||||
#endif /* LOGIN_ACCESS */
|
||||
|
||||
@@ -23,55 +23,52 @@
|
||||
|
||||
#ifdef DES_RPC
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: login_desrpc.c,v 1.7 1999/06/07 16:40:44 marekm Exp $")
|
||||
|
||||
RCSID ("$Id: login_desrpc.c,v 1.8 2003/04/22 10:59:22 kloczek Exp $")
|
||||
#include "defines.h"
|
||||
|
||||
/*
|
||||
* Decrypt the user's secret secure RPC key and stores it into the
|
||||
* keyserver. Returns 0 if successful, -1 on failure.
|
||||
*
|
||||
* Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Decrypt the user's secret secure RPC key and stores it into the
|
||||
* keyserver. Returns 0 if successful, -1 on failure.
|
||||
*
|
||||
* Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <rpc/rpc.h>
|
||||
#include <rpc/key_prot.h>
|
||||
|
||||
#if !(defined __GLIBC__ && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ > 0)))
|
||||
/* these don't seem to be in any header file (libc-5.4.33) */
|
||||
/* but will be in glibc 2.1 <rpc/auth.h> and <rpc/auth_des.h> */
|
||||
extern int getnetname(char *);
|
||||
extern int getsecretkey(const char *, char *, const char *);
|
||||
extern int key_setsecret(const char *);
|
||||
extern int getnetname (char *);
|
||||
extern int getsecretkey (const char *, char *, const char *);
|
||||
extern int key_setsecret (const char *);
|
||||
#endif
|
||||
|
||||
int
|
||||
login_desrpc(const char *passwd)
|
||||
int login_desrpc (const char *passwd)
|
||||
{
|
||||
char netname[MAXNETNAMELEN + 1];
|
||||
char secretkey[HEXKEYBYTES + 1];
|
||||
|
||||
if (getnetname(netname) == 0)
|
||||
if (getnetname (netname) == 0)
|
||||
return -1;
|
||||
|
||||
if (getsecretkey(netname, secretkey, passwd) == 0)
|
||||
if (getsecretkey (netname, secretkey, passwd) == 0)
|
||||
return -1;
|
||||
|
||||
if (secretkey[0] == 0) {
|
||||
fprintf(stderr,
|
||||
_("Password does not decrypt secret key for %s.\n"),
|
||||
netname);
|
||||
fprintf (stderr,
|
||||
_
|
||||
("Password does not decrypt secret key for %s.\n"),
|
||||
netname);
|
||||
return -1;
|
||||
}
|
||||
if (key_setsecret(secretkey) < 0) {
|
||||
fprintf(stderr,
|
||||
_("Could not set %s's secret key: is the keyserv daemon running?\n"),
|
||||
netname);
|
||||
if (key_setsecret (secretkey) < 0) {
|
||||
fprintf (stderr,
|
||||
_
|
||||
("Could not set %s's secret key: is the keyserv daemon running?\n"),
|
||||
netname);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
extern int errno; /* warning: ANSI C forbids an empty source file */
|
||||
extern int errno; /* warning: ANSI C forbids an empty source file */
|
||||
#endif
|
||||
|
||||
@@ -23,39 +23,36 @@
|
||||
|
||||
#ifdef KERBEROS
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: login_krb.c,v 1.3 1998/01/29 23:22:34 marekm Exp $")
|
||||
|
||||
RCSID ("$Id: login_krb.c,v 1.4 2003/04/22 10:59:22 kloczek Exp $")
|
||||
#include <krb.h>
|
||||
|
||||
/*
|
||||
* Do an equivalent to kinit here. We need to do the kinit before trying to
|
||||
* cd to the home directory, because it might be on a remote filesystem that
|
||||
* uses Kerberos authentication. We also need to do this after we've
|
||||
* setuid() to the user, or krb_get_pw_in_tkt() won't know where to put the
|
||||
* ticket.
|
||||
*
|
||||
* We don't really care about whether or not it succeeds; if it fails, we'll
|
||||
* just carry on bravely.
|
||||
*
|
||||
* NB: we assume: local realm, same username and password as supplied to login.
|
||||
*
|
||||
* Security note: if pp is NULL, login doesn't have the password. This is
|
||||
* common when it's called by rlogind. Since this is almost always a remote
|
||||
* connection, we don't want to risk asking for the password by supplying a
|
||||
* NULL pp to krb_get_pw_in_tkt(), because somebody could be listening. So
|
||||
* we'll just forget the whole thing. -jdd
|
||||
*/
|
||||
|
||||
int
|
||||
login_kerberos(const char *username, const char *password)
|
||||
/*
|
||||
* Do an equivalent to kinit here. We need to do the kinit before trying to
|
||||
* cd to the home directory, because it might be on a remote filesystem that
|
||||
* uses Kerberos authentication. We also need to do this after we've
|
||||
* setuid() to the user, or krb_get_pw_in_tkt() won't know where to put the
|
||||
* ticket.
|
||||
*
|
||||
* We don't really care about whether or not it succeeds; if it fails, we'll
|
||||
* just carry on bravely.
|
||||
*
|
||||
* NB: we assume: local realm, same username and password as supplied to login.
|
||||
*
|
||||
* Security note: if pp is NULL, login doesn't have the password. This is
|
||||
* common when it's called by rlogind. Since this is almost always a remote
|
||||
* connection, we don't want to risk asking for the password by supplying a
|
||||
* NULL pp to krb_get_pw_in_tkt(), because somebody could be listening. So
|
||||
* we'll just forget the whole thing. -jdd
|
||||
*/
|
||||
int login_kerberos (const char *username, const char *password)
|
||||
{
|
||||
char realm[REALM_SZ];
|
||||
char realm[REALM_SZ];
|
||||
|
||||
(void) krb_get_lrealm(realm, 1);
|
||||
if (password != 0)
|
||||
(void) krb_get_pw_in_tkt(username, "", realm, "krbtgt",
|
||||
realm, DEFAULT_TKT_LIFE, password);
|
||||
(void) krb_get_lrealm (realm, 1);
|
||||
if (password != 0)
|
||||
(void) krb_get_pw_in_tkt (username, "", realm, "krbtgt",
|
||||
realm, DEFAULT_TKT_LIFE,
|
||||
password);
|
||||
}
|
||||
#else
|
||||
extern int errno; /* warning: ANSI C forbids an empty source file */
|
||||
#endif /* KERBEROS */
|
||||
extern int errno; /* warning: ANSI C forbids an empty source file */
|
||||
#endif /* KERBEROS */
|
||||
|
||||
@@ -30,19 +30,16 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: loginprompt.c,v 1.6 2000/08/26 18:27:17 marekm Exp $")
|
||||
|
||||
RCSID ("$Id: loginprompt.c,v 1.7 2003/04/22 10:59:22 kloczek Exp $")
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <ctype.h>
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
#include "getdef.h"
|
||||
|
||||
static void
|
||||
login_exit(int sig)
|
||||
static void login_exit (int sig)
|
||||
{
|
||||
exit(1);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -52,19 +49,20 @@ login_exit(int sig)
|
||||
* is set in login.defs, this file is displayed before the prompt.
|
||||
*/
|
||||
|
||||
void
|
||||
login_prompt(const char *prompt, char *name, int namesize)
|
||||
void login_prompt (const char *prompt, char *name, int namesize)
|
||||
{
|
||||
char buf[1024];
|
||||
char buf[1024];
|
||||
|
||||
#define MAX_ENV 32
|
||||
char *envp[MAX_ENV];
|
||||
int envc;
|
||||
char *cp;
|
||||
int i;
|
||||
FILE *fp;
|
||||
RETSIGTYPE (*sigquit)(int);
|
||||
char *envp[MAX_ENV];
|
||||
int envc;
|
||||
char *cp;
|
||||
int i;
|
||||
FILE *fp;
|
||||
|
||||
RETSIGTYPE (*sigquit) (int);
|
||||
#ifdef SIGTSTP
|
||||
RETSIGTYPE (*sigtstp)(int);
|
||||
RETSIGTYPE (*sigtstp) (int);
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -74,9 +72,9 @@ login_prompt(const char *prompt, char *name, int namesize)
|
||||
* thing for that signal.
|
||||
*/
|
||||
|
||||
sigquit = signal(SIGQUIT, login_exit);
|
||||
sigquit = signal (SIGQUIT, login_exit);
|
||||
#ifdef SIGTSTP
|
||||
sigtstp = signal(SIGTSTP, login_exit);
|
||||
sigtstp = signal (SIGTSTP, login_exit);
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -85,16 +83,16 @@ login_prompt(const char *prompt, char *name, int namesize)
|
||||
*/
|
||||
|
||||
if (prompt) {
|
||||
cp = getdef_str("ISSUE_FILE");
|
||||
if (cp && (fp = fopen(cp, "r"))) {
|
||||
while ((i = getc(fp)) != EOF)
|
||||
putc(i, stdout);
|
||||
cp = getdef_str ("ISSUE_FILE");
|
||||
if (cp && (fp = fopen (cp, "r"))) {
|
||||
while ((i = getc (fp)) != EOF)
|
||||
putc (i, stdout);
|
||||
|
||||
fclose(fp);
|
||||
fclose (fp);
|
||||
}
|
||||
gethostname(buf, sizeof buf);
|
||||
printf(prompt, buf);
|
||||
fflush(stdout);
|
||||
gethostname (buf, sizeof buf);
|
||||
printf (prompt, buf);
|
||||
fflush (stdout);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -102,14 +100,14 @@ login_prompt(const char *prompt, char *name, int namesize)
|
||||
* removed.
|
||||
*/
|
||||
|
||||
memzero(buf, sizeof buf);
|
||||
if (fgets(buf, sizeof buf, stdin) != buf)
|
||||
exit(1);
|
||||
memzero (buf, sizeof buf);
|
||||
if (fgets (buf, sizeof buf, stdin) != buf)
|
||||
exit (1);
|
||||
|
||||
cp = strchr(buf, '\n');
|
||||
cp = strchr (buf, '\n');
|
||||
if (!cp)
|
||||
exit(1);
|
||||
*cp = '\0'; /* remove \n [ must be there ] */
|
||||
exit (1);
|
||||
*cp = '\0'; /* remove \n [ must be there ] */
|
||||
|
||||
/*
|
||||
* Skip leading whitespace. This makes " username" work right.
|
||||
@@ -117,12 +115,10 @@ login_prompt(const char *prompt, char *name, int namesize)
|
||||
* character into the username.
|
||||
*/
|
||||
|
||||
for (cp = buf;*cp == ' ' || *cp == '\t';cp++)
|
||||
;
|
||||
for (cp = buf; *cp == ' ' || *cp == '\t'; cp++);
|
||||
|
||||
for (i = 0; i < namesize - 1 && isgraph(*cp); name[i++] = *cp++)
|
||||
;
|
||||
while (isgraph(*cp))
|
||||
for (i = 0; i < namesize - 1 && isgraph (*cp); name[i++] = *cp++);
|
||||
while (isgraph (*cp))
|
||||
cp++;
|
||||
|
||||
if (*cp)
|
||||
@@ -136,30 +132,31 @@ login_prompt(const char *prompt, char *name, int namesize)
|
||||
* to do this, and I just take the easy way out.
|
||||
*/
|
||||
|
||||
if (*cp != '\0') { /* process new variables */
|
||||
if (*cp != '\0') { /* process new variables */
|
||||
char *nvar;
|
||||
int count = 1;
|
||||
|
||||
for (envc = 0; envc < MAX_ENV; envc++) {
|
||||
nvar = strtok(envc ? (char *)0 : cp, " \t,");
|
||||
nvar = strtok (envc ? (char *) 0 : cp, " \t,");
|
||||
if (!nvar)
|
||||
break;
|
||||
if (strchr(nvar, '=')) {
|
||||
if (strchr (nvar, '=')) {
|
||||
envp[envc] = nvar;
|
||||
} else {
|
||||
envp[envc] = xmalloc(strlen(nvar) + 32);
|
||||
sprintf(envp[envc], "L%d=%s", count++, nvar);
|
||||
envp[envc] = xmalloc (strlen (nvar) + 32);
|
||||
sprintf (envp[envc], "L%d=%s", count++,
|
||||
nvar);
|
||||
}
|
||||
}
|
||||
set_env(envc, envp);
|
||||
set_env (envc, envp);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set the SIGQUIT handler back to its original value
|
||||
*/
|
||||
|
||||
signal(SIGQUIT, sigquit);
|
||||
signal (SIGQUIT, sigquit);
|
||||
#ifdef SIGTSTP
|
||||
signal(SIGTSTP, sigtstp);
|
||||
signal (SIGTSTP, sigtstp);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -37,43 +37,41 @@
|
||||
#include "getdef.h"
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: mail.c,v 1.7 1998/12/28 20:34:49 marekm Exp $")
|
||||
RCSID ("$Id: mail.c,v 1.8 2003/04/22 10:59:22 kloczek Exp $")
|
||||
|
||||
void
|
||||
mailcheck(void)
|
||||
void mailcheck (void)
|
||||
{
|
||||
struct stat statbuf;
|
||||
char *mailbox;
|
||||
|
||||
if (!getdef_bool("MAIL_CHECK_ENAB"))
|
||||
if (!getdef_bool ("MAIL_CHECK_ENAB"))
|
||||
return;
|
||||
|
||||
/*
|
||||
* Check incoming mail in Maildir format - J.
|
||||
*/
|
||||
if ((mailbox = getenv("MAILDIR"))) {
|
||||
if ((mailbox = getenv ("MAILDIR"))) {
|
||||
char *newmail;
|
||||
|
||||
newmail = xmalloc(strlen(mailbox) + 5);
|
||||
sprintf(newmail, "%s/new", mailbox);
|
||||
if (stat(newmail, &statbuf) != -1 && statbuf.st_size != 0) {
|
||||
newmail = xmalloc (strlen (mailbox) + 5);
|
||||
sprintf (newmail, "%s/new", mailbox);
|
||||
if (stat (newmail, &statbuf) != -1 && statbuf.st_size != 0) {
|
||||
if (statbuf.st_mtime > statbuf.st_atime) {
|
||||
free(newmail);
|
||||
puts(_("You have new mail."));
|
||||
free (newmail);
|
||||
puts (_("You have new mail."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
free(newmail);
|
||||
free (newmail);
|
||||
}
|
||||
|
||||
if (!(mailbox = getenv("MAIL")))
|
||||
if (!(mailbox = getenv ("MAIL")))
|
||||
return;
|
||||
|
||||
if (stat(mailbox, &statbuf) == -1 || statbuf.st_size == 0)
|
||||
puts(_("No mail."));
|
||||
if (stat (mailbox, &statbuf) == -1 || statbuf.st_size == 0)
|
||||
puts (_("No mail."));
|
||||
else if (statbuf.st_atime > statbuf.st_mtime)
|
||||
puts(_("You have mail."));
|
||||
puts (_("You have mail."));
|
||||
else
|
||||
puts(_("You have new mail."));
|
||||
puts (_("You have new mail."));
|
||||
}
|
||||
|
||||
|
||||
@@ -30,13 +30,11 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: motd.c,v 1.3 1997/12/07 23:27:07 marekm Exp $")
|
||||
|
||||
RCSID ("$Id: motd.c,v 1.4 2003/04/22 10:59:22 kloczek Exp $")
|
||||
#include <stdio.h>
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
#include "getdef.h"
|
||||
|
||||
/*
|
||||
* motd -- output the /etc/motd file
|
||||
*
|
||||
@@ -44,22 +42,21 @@ RCSID("$Id: motd.c,v 1.3 1997/12/07 23:27:07 marekm Exp $")
|
||||
* it to the user's terminal at login time. The MOTD_FILE configuration
|
||||
* option is a colon-delimited list of filenames.
|
||||
*/
|
||||
|
||||
void
|
||||
motd(void)
|
||||
void motd (void)
|
||||
{
|
||||
FILE *fp;
|
||||
char motdlist[BUFSIZ], *motdfile, *mb;
|
||||
register int c;
|
||||
FILE *fp;
|
||||
char motdlist[BUFSIZ], *motdfile, *mb;
|
||||
register int c;
|
||||
|
||||
if ((mb = getdef_str("MOTD_FILE")) == NULL)
|
||||
if ((mb = getdef_str ("MOTD_FILE")) == NULL)
|
||||
return;
|
||||
|
||||
strncpy(motdlist, mb, sizeof(motdlist));
|
||||
motdlist[sizeof(motdlist)-1] = '\0';
|
||||
strncpy (motdlist, mb, sizeof (motdlist));
|
||||
motdlist[sizeof (motdlist) - 1] = '\0';
|
||||
|
||||
for (mb = motdlist ; (motdfile = strtok(mb,":")) != NULL ; mb = NULL) {
|
||||
if ((fp = fopen(motdfile, "r")) != NULL) {
|
||||
for (mb = motdlist; (motdfile = strtok (mb, ":")) != NULL;
|
||||
mb = NULL) {
|
||||
if ((fp = fopen (motdfile, "r")) != NULL) {
|
||||
while ((c = getc (fp)) != EOF)
|
||||
putchar (c);
|
||||
fclose (fp);
|
||||
|
||||
@@ -11,18 +11,15 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: myname.c,v 1.2 1997/12/07 23:27:07 marekm Exp $")
|
||||
|
||||
RCSID ("$Id: myname.c,v 1.3 2003/04/22 10:59:22 kloczek Exp $")
|
||||
#include "defines.h"
|
||||
#include <pwd.h>
|
||||
#include "prototypes.h"
|
||||
|
||||
struct passwd *
|
||||
get_my_pwent(void)
|
||||
struct passwd *get_my_pwent (void)
|
||||
{
|
||||
struct passwd *pw;
|
||||
const char *cp = getlogin();
|
||||
uid_t ruid = getuid();
|
||||
const char *cp = getlogin ();
|
||||
uid_t ruid = getuid ();
|
||||
|
||||
/*
|
||||
* Try getlogin() first - if it fails or returns a non-existent
|
||||
@@ -34,8 +31,8 @@ get_my_pwent(void)
|
||||
* XXX - when running from su, will return the current user (not
|
||||
* the original user, like getlogin() does). Does this matter?
|
||||
*/
|
||||
if (cp && *cp && (pw = getpwnam(cp)) && pw->pw_uid == ruid)
|
||||
if (cp && *cp && (pw = getpwnam (cp)) && pw->pw_uid == ruid)
|
||||
return pw;
|
||||
|
||||
return getpwuid(ruid);
|
||||
return getpwuid (ruid);
|
||||
}
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
/* Copyright (c) 1999 SuSE GmbH Nuerenberg, Germany
|
||||
Author: Thorsten Kukuk <kukuk@suse.de> */
|
||||
|
||||
#include <assert.h>
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/un.h>
|
||||
|
||||
/* Version number of the daemon interface */
|
||||
#define NSCD_VERSION 2
|
||||
/* Path for the Unix domain socket. */
|
||||
#define _PATH_NSCDSOCKET "/var/run/.nscd_socket"
|
||||
|
||||
/* Available services. */
|
||||
typedef enum
|
||||
{
|
||||
GETPWBYNAME,
|
||||
GETPWBYUID,
|
||||
GETGRBYNAME,
|
||||
GETGRBYGID,
|
||||
GETHOSTBYNAME,
|
||||
GETHOSTBYNAMEv6,
|
||||
GETHOSTBYADDR,
|
||||
GETHOSTBYADDRv6,
|
||||
LASTDBREQ = GETHOSTBYADDRv6,
|
||||
SHUTDOWN, /* Shut the server down. */
|
||||
GETSTAT, /* Get the server statistic. */
|
||||
INVALIDATE, /* Invalidate one special cache. */
|
||||
LASTREQ
|
||||
} request_type;
|
||||
|
||||
/* Header common to all requests */
|
||||
typedef struct
|
||||
{
|
||||
int version; /* Version number of the daemon interface. */
|
||||
request_type type; /* Service requested. */
|
||||
#if defined(__alpha__)
|
||||
int64_t key_len; /* Key length is 64bit on Alpha. */
|
||||
#else
|
||||
int32_t key_len; /* Key length, 32bit on most plattforms. */
|
||||
#endif
|
||||
} request_header;
|
||||
|
||||
/* Create a socket connected to a name. */
|
||||
static int
|
||||
nscd_open_socket (void)
|
||||
{
|
||||
struct sockaddr_un addr;
|
||||
int sock;
|
||||
|
||||
sock = socket (PF_UNIX, SOCK_STREAM, 0);
|
||||
if (sock < 0)
|
||||
return -1;
|
||||
|
||||
addr.sun_family = AF_UNIX;
|
||||
assert (sizeof (addr.sun_path) >= sizeof (_PATH_NSCDSOCKET));
|
||||
strcpy (addr.sun_path, _PATH_NSCDSOCKET);
|
||||
if (connect (sock, (struct sockaddr *) &addr, sizeof (addr)) < 0)
|
||||
{
|
||||
close (sock);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return sock;
|
||||
}
|
||||
|
||||
int
|
||||
nscd_flush_cache (char *service)
|
||||
{
|
||||
int sock = nscd_open_socket ();
|
||||
request_header req;
|
||||
ssize_t nbytes;
|
||||
|
||||
if (sock == -1)
|
||||
return -1;
|
||||
|
||||
req.version = NSCD_VERSION;
|
||||
req.type = INVALIDATE;
|
||||
req.key_len = strlen (service) + 1;
|
||||
nbytes = write (sock, &req, sizeof (request_header));
|
||||
if (nbytes != sizeof (request_header))
|
||||
{
|
||||
close (sock);
|
||||
return -1;
|
||||
}
|
||||
|
||||
nbytes = write (sock, (void *)service, req.key_len);
|
||||
|
||||
close (sock);
|
||||
return (nbytes != req.key_len ? (-1) : 0);
|
||||
}
|
||||
@@ -30,34 +30,28 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: obscure.c,v 1.9 1999/03/07 19:14:40 marekm Exp $")
|
||||
RCSID ("$Id: obscure.c,v 1.11 2003/05/05 21:44:15 kloczek Exp $")
|
||||
|
||||
/*
|
||||
* This version of obscure.c contains modifications to support "cracklib"
|
||||
* by Alec Muffet (alec.muffett@uk.sun.com). You must obtain the Cracklib
|
||||
* library source code for this function to operate.
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
|
||||
#include "getdef.h"
|
||||
|
||||
/*
|
||||
* can't be a palindrome - like `R A D A R' or `M A D A M'
|
||||
*/
|
||||
|
||||
/*ARGSUSED*/
|
||||
static int
|
||||
palindrome(const char *old, const char *new)
|
||||
/*ARGSUSED*/ static int palindrome (const char *old, const char *new)
|
||||
{
|
||||
int i, j;
|
||||
int i, j;
|
||||
|
||||
i = strlen (new);
|
||||
|
||||
for (j = 0;j < i;j++)
|
||||
for (j = 0; j < i; j++)
|
||||
if (new[i - j - 1] != new[j])
|
||||
return 0;
|
||||
|
||||
@@ -68,9 +62,7 @@ palindrome(const char *old, const char *new)
|
||||
* more than half of the characters are different ones.
|
||||
*/
|
||||
|
||||
/*ARGSUSED*/
|
||||
static int
|
||||
similar(const char *old, const char *new)
|
||||
/*ARGSUSED*/ static int similar (const char *old, const char *new)
|
||||
{
|
||||
int i, j;
|
||||
|
||||
@@ -80,11 +72,11 @@ similar(const char *old, const char *new)
|
||||
* the new password is long enough. Please feel free to suggest
|
||||
* something better... --marekm
|
||||
*/
|
||||
if (strlen(new) >= 8)
|
||||
if (strlen (new) >= 8)
|
||||
return 0;
|
||||
|
||||
for (i = j = 0; new[i] && old[i]; i++)
|
||||
if (strchr(new, old[i]))
|
||||
if (strchr (new, old[i]))
|
||||
j++;
|
||||
|
||||
if (i >= j * 2)
|
||||
@@ -97,18 +89,16 @@ similar(const char *old, const char *new)
|
||||
* a nice mix of characters.
|
||||
*/
|
||||
|
||||
/*ARGSUSED*/
|
||||
static int
|
||||
simple(const char *old, const char *new)
|
||||
/*ARGSUSED*/ static int simple (const char *old, const char *new)
|
||||
{
|
||||
int digits = 0;
|
||||
int uppers = 0;
|
||||
int lowers = 0;
|
||||
int others = 0;
|
||||
int size;
|
||||
int i;
|
||||
int digits = 0;
|
||||
int uppers = 0;
|
||||
int lowers = 0;
|
||||
int others = 0;
|
||||
int size;
|
||||
int i;
|
||||
|
||||
for (i = 0;new[i];i++) {
|
||||
for (i = 0; new[i]; i++) {
|
||||
if (isdigit (new[i]))
|
||||
digits++;
|
||||
else if (isupper (new[i]))
|
||||
@@ -125,10 +115,14 @@ simple(const char *old, const char *new)
|
||||
*/
|
||||
|
||||
size = 9;
|
||||
if (digits) size--;
|
||||
if (uppers) size--;
|
||||
if (lowers) size--;
|
||||
if (others) size--;
|
||||
if (digits)
|
||||
size--;
|
||||
if (uppers)
|
||||
size--;
|
||||
if (lowers)
|
||||
size--;
|
||||
if (others)
|
||||
size--;
|
||||
|
||||
if (size <= i)
|
||||
return 0;
|
||||
@@ -136,52 +130,53 @@ simple(const char *old, const char *new)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static char *
|
||||
str_lower(char *string)
|
||||
static char *str_lower (char *string)
|
||||
{
|
||||
char *cp;
|
||||
|
||||
for (cp = string; *cp; cp++)
|
||||
*cp = tolower(*cp);
|
||||
*cp = tolower (*cp);
|
||||
return string;
|
||||
}
|
||||
|
||||
static const char *
|
||||
password_check(const char *old, const char *new, const struct passwd *pwdp)
|
||||
static const char *password_check (const char *old, const char *new,
|
||||
const struct passwd *pwdp)
|
||||
{
|
||||
const char *msg = NULL;
|
||||
char *oldmono, *newmono, *wrapped;
|
||||
|
||||
#ifdef HAVE_LIBCRACK
|
||||
char *dictpath;
|
||||
|
||||
#ifdef HAVE_LIBCRACK_PW
|
||||
char *FascistCheckPw();
|
||||
char *FascistCheckPw ();
|
||||
#else
|
||||
char *FascistCheck();
|
||||
char *FascistCheck ();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
if (strcmp(new, old) == 0)
|
||||
if (strcmp (new, old) == 0)
|
||||
return "no change";
|
||||
|
||||
newmono = str_lower(xstrdup(new));
|
||||
oldmono = str_lower(xstrdup(old));
|
||||
wrapped = xmalloc(strlen(oldmono) * 2 + 1);
|
||||
newmono = str_lower (xstrdup (new));
|
||||
oldmono = str_lower (xstrdup (old));
|
||||
wrapped = xmalloc (strlen (oldmono) * 2 + 1);
|
||||
strcpy (wrapped, oldmono);
|
||||
strcat (wrapped, oldmono);
|
||||
|
||||
if (palindrome(oldmono, newmono))
|
||||
if (palindrome (oldmono, newmono))
|
||||
msg = "a palindrome";
|
||||
|
||||
if (!msg && strcmp(oldmono, newmono) == 0)
|
||||
if (!msg && strcmp (oldmono, newmono) == 0)
|
||||
msg = "case changes only";
|
||||
|
||||
if (!msg && similar(oldmono, newmono))
|
||||
if (!msg && similar (oldmono, newmono))
|
||||
msg = "too similar";
|
||||
|
||||
if (!msg && simple(old, new))
|
||||
if (!msg && simple (old, new))
|
||||
msg = "too simple";
|
||||
|
||||
if (!msg && strstr(wrapped, newmono))
|
||||
if (!msg && strstr (wrapped, newmono))
|
||||
msg = "rotated";
|
||||
|
||||
#ifdef HAVE_LIBCRACK
|
||||
@@ -189,49 +184,44 @@ password_check(const char *old, const char *new, const struct passwd *pwdp)
|
||||
* Invoke Alec Muffett's cracklib routines.
|
||||
*/
|
||||
|
||||
if (!msg && (dictpath = getdef_str("CRACKLIB_DICTPATH")))
|
||||
if (!msg && (dictpath = getdef_str ("CRACKLIB_DICTPATH")))
|
||||
#ifdef HAVE_LIBCRACK_PW
|
||||
msg = FascistCheckPw(new, dictpath, pwdp);
|
||||
msg = FascistCheckPw (new, dictpath, pwdp);
|
||||
#else
|
||||
msg = FascistCheck(new, dictpath);
|
||||
msg = FascistCheck (new, dictpath);
|
||||
#endif
|
||||
#endif
|
||||
strzero(newmono);
|
||||
strzero(oldmono);
|
||||
strzero(wrapped);
|
||||
free(newmono);
|
||||
free(oldmono);
|
||||
free(wrapped);
|
||||
strzero (newmono);
|
||||
strzero (oldmono);
|
||||
strzero (wrapped);
|
||||
free (newmono);
|
||||
free (oldmono);
|
||||
free (wrapped);
|
||||
|
||||
return msg;
|
||||
}
|
||||
|
||||
/*ARGSUSED*/
|
||||
static const char *
|
||||
obscure_msg(const char *old, const char *new, const struct passwd *pwdp)
|
||||
/*ARGSUSED*/
|
||||
static const char *obscure_msg (const char *old, const char *new,
|
||||
const struct passwd *pwdp)
|
||||
{
|
||||
int maxlen, oldlen, newlen;
|
||||
char *new1, *old1;
|
||||
const char *msg;
|
||||
|
||||
oldlen = strlen(old);
|
||||
newlen = strlen(new);
|
||||
oldlen = strlen (old);
|
||||
newlen = strlen (new);
|
||||
|
||||
#if 0 /* why not check the password when set for the first time? --marekm */
|
||||
if (old[0] == '\0')
|
||||
return NULL;
|
||||
#endif
|
||||
|
||||
if ( newlen < getdef_num("PASS_MIN_LEN", 0) )
|
||||
if (newlen < getdef_num ("PASS_MIN_LEN", 0))
|
||||
return "too short";
|
||||
|
||||
/*
|
||||
* Remaining checks are optional.
|
||||
*/
|
||||
if (!getdef_bool("OBSCURE_CHECKS_ENAB"))
|
||||
if (!getdef_bool ("OBSCURE_CHECKS_ENAB"))
|
||||
return NULL;
|
||||
|
||||
msg = password_check(old, new, pwdp);
|
||||
msg = password_check (old, new, pwdp);
|
||||
if (msg)
|
||||
return msg;
|
||||
|
||||
@@ -241,26 +231,26 @@ obscure_msg(const char *old, const char *new, const struct passwd *pwdp)
|
||||
Example: "password$%^&*123". So check it again, this time
|
||||
truncated to the maximum length. Idea from npasswd. --marekm */
|
||||
|
||||
if (getdef_bool("MD5_CRYPT_ENAB"))
|
||||
return NULL; /* unlimited password length */
|
||||
if (getdef_bool ("MD5_CRYPT_ENAB"))
|
||||
return NULL; /* unlimited password length */
|
||||
|
||||
maxlen = getdef_num("PASS_MAX_LEN", 8);
|
||||
maxlen = getdef_num ("PASS_MAX_LEN", 8);
|
||||
if (oldlen <= maxlen && newlen <= maxlen)
|
||||
return NULL;
|
||||
|
||||
new1 = xstrdup(new);
|
||||
old1 = xstrdup(old);
|
||||
new1 = xstrdup (new);
|
||||
old1 = xstrdup (old);
|
||||
if (newlen > maxlen)
|
||||
new1[maxlen] = '\0';
|
||||
if (oldlen > maxlen)
|
||||
old1[maxlen] = '\0';
|
||||
|
||||
msg = password_check(old1, new1, pwdp);
|
||||
msg = password_check (old1, new1, pwdp);
|
||||
|
||||
memzero(new1, newlen);
|
||||
memzero(old1, oldlen);
|
||||
free(new1);
|
||||
free(old1);
|
||||
memzero (new1, newlen);
|
||||
memzero (old1, oldlen);
|
||||
free (new1);
|
||||
free (old1);
|
||||
|
||||
return msg;
|
||||
}
|
||||
@@ -273,14 +263,13 @@ obscure_msg(const char *old, const char *new, const struct passwd *pwdp)
|
||||
* check passwords.
|
||||
*/
|
||||
|
||||
int
|
||||
obscure(const char *old, const char *new, const struct passwd *pwdp)
|
||||
int obscure (const char *old, const char *new, const struct passwd *pwdp)
|
||||
{
|
||||
const char *msg = obscure_msg(old, new, pwdp);
|
||||
const char *msg = obscure_msg (old, new, pwdp);
|
||||
|
||||
if (msg) {
|
||||
printf(_("Bad password: %s. "), msg);
|
||||
printf (_("Bad password: %s. "), msg);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#ifdef USE_PAM
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: pam_pass.c,v 1.7 2001/06/28 20:47:06 kloczek Exp $")
|
||||
RCSID ("$Id: pam_pass.c,v 1.9 2003/07/29 09:05:39 kloczek Exp $")
|
||||
|
||||
/*
|
||||
* Change the user's password using PAM. Requires libpam and libpam_misc
|
||||
@@ -11,23 +11,18 @@ RCSID("$Id: pam_pass.c,v 1.7 2001/06/28 20:47:06 kloczek Exp $")
|
||||
* so you may have to port it if you want to use this code on non-Linux
|
||||
* systems with PAM (such as Solaris 2.6). --marekm
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "defines.h"
|
||||
|
||||
#include "pam_defs.h"
|
||||
|
||||
static const struct pam_conv conv = {
|
||||
misc_conv,
|
||||
NULL
|
||||
};
|
||||
|
||||
void
|
||||
do_pam_passwd(const char *user, int silent, int change_expired)
|
||||
void do_pam_passwd (const char *user, int silent, int change_expired)
|
||||
{
|
||||
pam_handle_t *pamh = NULL;
|
||||
int flags = 0, ret;
|
||||
@@ -37,22 +32,24 @@ do_pam_passwd(const char *user, int silent, int change_expired)
|
||||
if (change_expired)
|
||||
flags |= PAM_CHANGE_EXPIRED_AUTHTOK;
|
||||
|
||||
ret = pam_start("passwd", user, &conv, &pamh);
|
||||
ret = pam_start ("passwd", user, &conv, &pamh);
|
||||
if (ret != PAM_SUCCESS) {
|
||||
fprintf(stderr, _("passwd: pam_start() failed, error %d\n"),
|
||||
ret);
|
||||
exit(10); /* XXX */
|
||||
fprintf (stderr,
|
||||
_("passwd: pam_start() failed, error %d\n"), ret);
|
||||
exit (10); /* XXX */
|
||||
}
|
||||
|
||||
ret = pam_chauthtok(pamh, flags);
|
||||
ret = pam_chauthtok (pamh, flags);
|
||||
if (ret != PAM_SUCCESS) {
|
||||
fprintf(stderr, _("passwd: %s\n"), pam_strerror(pamh, ret));
|
||||
pam_end(pamh, ret);
|
||||
exit(10); /* XXX */
|
||||
fprintf (stderr, _("passwd: %s\n"),
|
||||
pam_strerror (pamh, ret));
|
||||
pam_end (pamh, ret);
|
||||
exit (10); /* XXX */
|
||||
}
|
||||
|
||||
pam_end(pamh, PAM_SUCCESS);
|
||||
fputs(_("passwd: password updated successfully\n"), stderr);
|
||||
pam_end (pamh, PAM_SUCCESS);
|
||||
}
|
||||
#else /* !USE_PAM */
|
||||
extern int errno; /* warning: ANSI C forbids an empty source file */
|
||||
#endif /* !USE_PAM */
|
||||
#else /* !USE_PAM */
|
||||
extern int errno; /* warning: ANSI C forbids an empty source file */
|
||||
#endif /* !USE_PAM */
|
||||
|
||||
@@ -32,14 +32,12 @@
|
||||
#ifdef SHADOWPWD
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: pwd2spwd.c,v 1.3 1997/12/07 23:27:07 marekm Exp $")
|
||||
|
||||
RCSID ("$Id: pwd2spwd.c,v 1.5 2003/05/03 16:14:34 kloczek Exp $")
|
||||
#include <sys/types.h>
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
#include <pwd.h>
|
||||
|
||||
extern time_t time ();
|
||||
extern time_t time ();
|
||||
|
||||
/*
|
||||
* pwd_to_spwd - create entries for new spwd structure
|
||||
@@ -48,8 +46,7 @@ extern time_t time ();
|
||||
* information in the pointed-to (struct passwd).
|
||||
*/
|
||||
|
||||
struct spwd *
|
||||
pwd_to_spwd(const struct passwd *pw)
|
||||
struct spwd *pwd_to_spwd (const struct passwd *pw)
|
||||
{
|
||||
static struct spwd sp;
|
||||
|
||||
@@ -60,33 +57,13 @@ pwd_to_spwd(const struct passwd *pw)
|
||||
sp.sp_namp = pw->pw_name;
|
||||
sp.sp_pwdp = pw->pw_passwd;
|
||||
|
||||
#ifdef ATT_AGE
|
||||
/*
|
||||
* AT&T-style password aging maps the sp_min, sp_max, and
|
||||
* sp_lstchg information from the pw_age field, which appears
|
||||
* after the encrypted password.
|
||||
*/
|
||||
if (pw->pw_age[0]) {
|
||||
sp.sp_max = (c64i(pw->pw_age[0]) * WEEK) / SCALE;
|
||||
|
||||
if (pw->pw_age[1])
|
||||
sp.sp_min = (c64i(pw->pw_age[1]) * WEEK) / SCALE;
|
||||
else
|
||||
sp.sp_min = (10000L * DAY) / SCALE;
|
||||
|
||||
if (pw->pw_age[1] && pw->pw_age[2])
|
||||
sp.sp_lstchg = (a64l(pw->pw_age + 2) * WEEK) / SCALE;
|
||||
else
|
||||
sp.sp_lstchg = time((time_t *) 0) / SCALE;
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
/*
|
||||
* Defaults used if there is no pw_age information.
|
||||
*/
|
||||
sp.sp_min = 0;
|
||||
sp.sp_max = (10000L * DAY) / SCALE;
|
||||
sp.sp_lstchg = time((time_t *) 0) / SCALE;
|
||||
sp.sp_lstchg = time ((time_t *) 0) / SCALE;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -100,4 +77,4 @@ pwd_to_spwd(const struct passwd *pw)
|
||||
|
||||
return &sp;
|
||||
}
|
||||
#endif /* SHADOWPWD */
|
||||
#endif /* SHADOWPWD */
|
||||
|
||||
@@ -2,72 +2,67 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: pwd_init.c,v 1.1 1997/12/07 23:27:07 marekm Exp $")
|
||||
|
||||
RCSID ("$Id: pwd_init.c,v 1.2 2003/04/22 10:59:22 kloczek Exp $")
|
||||
#include "defines.h"
|
||||
#include <signal.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef HAVE_SYS_RESOURCE_H
|
||||
#include <sys/resource.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* pwd_init - ignore signals, and set resource limits to safe
|
||||
* values. Call this before modifying password files, so that
|
||||
* it is less likely to fail in the middle of operation.
|
||||
*/
|
||||
void
|
||||
pwd_init(void)
|
||||
void pwd_init (void)
|
||||
{
|
||||
#ifdef HAVE_SYS_RESOURCE_H
|
||||
struct rlimit rlim;
|
||||
|
||||
#ifdef RLIMIT_CORE
|
||||
rlim.rlim_cur = rlim.rlim_max = 0;
|
||||
setrlimit(RLIMIT_CORE, &rlim);
|
||||
setrlimit (RLIMIT_CORE, &rlim);
|
||||
#endif
|
||||
rlim.rlim_cur = rlim.rlim_max = RLIM_INFINITY;
|
||||
#ifdef RLIMIT_AS
|
||||
setrlimit(RLIMIT_AS, &rlim);
|
||||
setrlimit (RLIMIT_AS, &rlim);
|
||||
#endif
|
||||
#ifdef RLIMIT_CPU
|
||||
setrlimit(RLIMIT_CPU, &rlim);
|
||||
setrlimit (RLIMIT_CPU, &rlim);
|
||||
#endif
|
||||
#ifdef RLIMIT_DATA
|
||||
setrlimit(RLIMIT_DATA, &rlim);
|
||||
setrlimit (RLIMIT_DATA, &rlim);
|
||||
#endif
|
||||
#ifdef RLIMIT_FSIZE
|
||||
setrlimit(RLIMIT_FSIZE, &rlim);
|
||||
setrlimit (RLIMIT_FSIZE, &rlim);
|
||||
#endif
|
||||
#ifdef RLIMIT_NOFILE
|
||||
setrlimit(RLIMIT_NOFILE, &rlim);
|
||||
setrlimit (RLIMIT_NOFILE, &rlim);
|
||||
#endif
|
||||
#ifdef RLIMIT_RSS
|
||||
setrlimit(RLIMIT_RSS, &rlim);
|
||||
setrlimit (RLIMIT_RSS, &rlim);
|
||||
#endif
|
||||
#ifdef RLIMIT_STACK
|
||||
setrlimit(RLIMIT_STACK, &rlim);
|
||||
setrlimit (RLIMIT_STACK, &rlim);
|
||||
#endif
|
||||
#else /* !HAVE_SYS_RESOURCE_H */
|
||||
set_filesize_limit(30000);
|
||||
#else /* !HAVE_SYS_RESOURCE_H */
|
||||
set_filesize_limit (30000);
|
||||
/* don't know how to set the other limits... */
|
||||
#endif /* !HAVE_SYS_RESOURCE_H */
|
||||
#endif /* !HAVE_SYS_RESOURCE_H */
|
||||
|
||||
signal(SIGALRM, SIG_IGN);
|
||||
signal(SIGHUP, SIG_IGN);
|
||||
signal(SIGINT, SIG_IGN);
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
signal(SIGQUIT, SIG_IGN);
|
||||
signal(SIGTERM, SIG_IGN);
|
||||
signal (SIGALRM, SIG_IGN);
|
||||
signal (SIGHUP, SIG_IGN);
|
||||
signal (SIGINT, SIG_IGN);
|
||||
signal (SIGPIPE, SIG_IGN);
|
||||
signal (SIGQUIT, SIG_IGN);
|
||||
signal (SIGTERM, SIG_IGN);
|
||||
#ifdef SIGTSTP
|
||||
signal(SIGTSTP, SIG_IGN);
|
||||
signal (SIGTSTP, SIG_IGN);
|
||||
#endif
|
||||
#ifdef SIGTTOU
|
||||
signal(SIGTTOU, SIG_IGN);
|
||||
signal (SIGTTOU, SIG_IGN);
|
||||
#endif
|
||||
|
||||
umask(077);
|
||||
}
|
||||
|
||||
umask (077);
|
||||
}
|
||||
|
||||
@@ -1,69 +1,62 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: pwdcheck.c,v 1.1 2000/10/15 17:07:26 kloczek Exp $")
|
||||
|
||||
RCSID ("$Id: pwdcheck.c,v 1.2 2003/04/22 10:59:22 kloczek Exp $")
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
|
||||
#include <pwd.h>
|
||||
#include "pwauth.h"
|
||||
|
||||
#ifdef HAVE_SHADOW_H
|
||||
#include <shadow.h>
|
||||
#endif
|
||||
|
||||
#ifdef USE_PAM
|
||||
#include "pam_defs.h"
|
||||
#endif
|
||||
|
||||
#define WRONGPWD2 "incorrect password for `%s'"
|
||||
|
||||
void
|
||||
passwd_check(const char *user, const char *passwd, const char *progname)
|
||||
passwd_check (const char *user, const char *passwd, const char *progname)
|
||||
{
|
||||
#ifdef USE_PAM
|
||||
pam_handle_t *pamh = NULL;
|
||||
int retcode;
|
||||
struct pam_conv conv = { misc_conv, NULL };
|
||||
|
||||
if (pam_start(progname, user, &conv, &pamh)) {
|
||||
bailout:
|
||||
SYSLOG((LOG_WARN, WRONGPWD2, user));
|
||||
sleep(1);
|
||||
fprintf(stderr, _("Incorrect password for %s.\n"), user);
|
||||
exit(1);
|
||||
if (pam_start (progname, user, &conv, &pamh)) {
|
||||
bailout:
|
||||
SYSLOG ((LOG_WARN, WRONGPWD2, user));
|
||||
sleep (1);
|
||||
fprintf (stderr, _("Incorrect password for %s.\n"), user);
|
||||
exit (1);
|
||||
}
|
||||
if (pam_authenticate(pamh, 0))
|
||||
if (pam_authenticate (pamh, 0))
|
||||
goto bailout;
|
||||
|
||||
retcode = pam_acct_mgmt(pamh, 0);
|
||||
retcode = pam_acct_mgmt (pamh, 0);
|
||||
if (retcode == PAM_NEW_AUTHTOK_REQD) {
|
||||
retcode = pam_chauthtok(pamh, PAM_CHANGE_EXPIRED_AUTHTOK);
|
||||
retcode = pam_chauthtok (pamh, PAM_CHANGE_EXPIRED_AUTHTOK);
|
||||
} else if (retcode)
|
||||
goto bailout;
|
||||
|
||||
if (pam_setcred(pamh, 0))
|
||||
if (pam_setcred (pamh, 0))
|
||||
goto bailout;
|
||||
|
||||
/* no need to establish a session; this isn't a session-oriented
|
||||
* activity... */
|
||||
|
||||
#else /* !USE_PAM */
|
||||
#else /* !USE_PAM */
|
||||
|
||||
#ifdef SHADOWPWD
|
||||
struct spwd *sp;
|
||||
|
||||
if ((sp = getspnam(user)))
|
||||
if ((sp = getspnam (user)))
|
||||
passwd = sp->sp_pwdp;
|
||||
endspent();
|
||||
endspent ();
|
||||
#endif
|
||||
if (pw_auth(passwd, user, PW_LOGIN, (char *) 0) != 0) {
|
||||
SYSLOG((LOG_WARN, WRONGPWD2, user));
|
||||
sleep(1);
|
||||
fprintf(stderr, _("Incorrect password for %s.\n"), user);
|
||||
exit(1);
|
||||
if (pw_auth (passwd, user, PW_LOGIN, (char *) 0) != 0) {
|
||||
SYSLOG ((LOG_WARN, WRONGPWD2, user));
|
||||
sleep (1);
|
||||
fprintf (stderr, _("Incorrect password for %s.\n"), user);
|
||||
exit (1);
|
||||
}
|
||||
#endif /* !USE_PAM */
|
||||
#endif /* !USE_PAM */
|
||||
}
|
||||
|
||||
|
||||
110
libmisc/rlogin.c
110
libmisc/rlogin.c
@@ -32,92 +32,105 @@
|
||||
#ifdef RLOGIN
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: rlogin.c,v 1.5 1999/08/27 19:02:51 marekm Exp $")
|
||||
|
||||
RCSID ("$Id: rlogin.c,v 1.6 2003/04/22 10:59:22 kloczek Exp $")
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <pwd.h>
|
||||
|
||||
extern int ruserok();
|
||||
extern int ruserok ();
|
||||
|
||||
static struct {
|
||||
int spd_name;
|
||||
int spd_baud;
|
||||
} speed_table [] = {
|
||||
int spd_name;
|
||||
int spd_baud;
|
||||
} speed_table[] =
|
||||
{
|
||||
#ifdef B50
|
||||
{ B50, 50 },
|
||||
{
|
||||
B50, 50},
|
||||
#endif
|
||||
#ifdef B75
|
||||
{ B75, 75 },
|
||||
{
|
||||
B75, 75},
|
||||
#endif
|
||||
#ifdef B110
|
||||
{ B110, 110 },
|
||||
{
|
||||
B110, 110},
|
||||
#endif
|
||||
#ifdef B134
|
||||
{ B134, 134 },
|
||||
{
|
||||
B134, 134},
|
||||
#endif
|
||||
#ifdef B150
|
||||
{ B150, 150 },
|
||||
{
|
||||
B150, 150},
|
||||
#endif
|
||||
#ifdef B200
|
||||
{ B200, 200 },
|
||||
{
|
||||
B200, 200},
|
||||
#endif
|
||||
#ifdef B300
|
||||
{ B300, 300 },
|
||||
{
|
||||
B300, 300},
|
||||
#endif
|
||||
#ifdef B600
|
||||
{ B600, 600 },
|
||||
{
|
||||
B600, 600},
|
||||
#endif
|
||||
#ifdef B1200
|
||||
{ B1200, 1200 },
|
||||
{
|
||||
B1200, 1200},
|
||||
#endif
|
||||
#ifdef B1800
|
||||
{ B1800, 1800 },
|
||||
{
|
||||
B1800, 1800},
|
||||
#endif
|
||||
#ifdef B2400
|
||||
{ B2400, 2400 },
|
||||
{
|
||||
B2400, 2400},
|
||||
#endif
|
||||
#ifdef B4800
|
||||
{ B4800, 4800 },
|
||||
{
|
||||
B4800, 4800},
|
||||
#endif
|
||||
#ifdef B9600
|
||||
{ B9600, 9600 },
|
||||
{
|
||||
B9600, 9600},
|
||||
#endif
|
||||
#ifdef B19200
|
||||
{ B19200, 19200 },
|
||||
{
|
||||
B19200, 19200},
|
||||
#endif
|
||||
#ifdef B38400
|
||||
{ B38400, 38400 },
|
||||
{
|
||||
B38400, 38400},
|
||||
#endif
|
||||
{ -1, -1 }
|
||||
{
|
||||
-1, -1}
|
||||
};
|
||||
|
||||
static void
|
||||
get_remote_string(char *buf, int size)
|
||||
static void get_remote_string (char *buf, int size)
|
||||
{
|
||||
for (;;) {
|
||||
if (read (0, buf, 1) != 1)
|
||||
exit (1);
|
||||
exit (1);
|
||||
if (*buf == '\0')
|
||||
return;
|
||||
if (--size > 0)
|
||||
++buf;
|
||||
}
|
||||
/*NOTREACHED*/
|
||||
}
|
||||
/*NOTREACHED*/}
|
||||
|
||||
int
|
||||
do_rlogin(const char *remote_host, char *name, int namelen, char *term, int termlen)
|
||||
do_rlogin (const char *remote_host, char *name, int namelen, char *term,
|
||||
int termlen)
|
||||
{
|
||||
struct passwd *pwd;
|
||||
char remote_name[32];
|
||||
char *cp;
|
||||
int remote_speed = 9600;
|
||||
int speed_name = B9600;
|
||||
int i;
|
||||
TERMIO termio;
|
||||
struct passwd *pwd;
|
||||
char remote_name[32];
|
||||
char *cp;
|
||||
int remote_speed = 9600;
|
||||
int speed_name = B9600;
|
||||
int i;
|
||||
TERMIO termio;
|
||||
|
||||
get_remote_string (remote_name, sizeof remote_name);
|
||||
get_remote_string (name, namelen);
|
||||
@@ -126,12 +139,11 @@ do_rlogin(const char *remote_host, char *name, int namelen, char *term, int term
|
||||
if ((cp = strchr (term, '/'))) {
|
||||
*cp++ = '\0';
|
||||
|
||||
if (! (remote_speed = atoi (cp)))
|
||||
if (!(remote_speed = atoi (cp)))
|
||||
remote_speed = 9600;
|
||||
}
|
||||
for (i = 0;speed_table[i].spd_baud != remote_speed &&
|
||||
speed_table[i].spd_name != -1;i++)
|
||||
;
|
||||
for (i = 0; speed_table[i].spd_baud != remote_speed &&
|
||||
speed_table[i].spd_name != -1; i++);
|
||||
|
||||
if (speed_table[i].spd_name != -1)
|
||||
speed_name = speed_table[i].spd_name;
|
||||
@@ -140,18 +152,18 @@ do_rlogin(const char *remote_host, char *name, int namelen, char *term, int term
|
||||
* Put the terminal in cooked mode with echo turned on.
|
||||
*/
|
||||
|
||||
GTTY(0, &termio);
|
||||
termio.c_iflag |= ICRNL|IXON;
|
||||
termio.c_oflag |= OPOST|ONLCR;
|
||||
termio.c_lflag |= ICANON|ECHO|ECHOE;
|
||||
GTTY (0, &termio);
|
||||
termio.c_iflag |= ICRNL | IXON;
|
||||
termio.c_oflag |= OPOST | ONLCR;
|
||||
termio.c_lflag |= ICANON | ECHO | ECHOE;
|
||||
#ifdef CBAUD
|
||||
termio.c_cflag = (termio.c_cflag & ~CBAUD) | speed_name;
|
||||
#else
|
||||
termio.c_cflag = (termio.c_cflag) | speed_name;
|
||||
#endif
|
||||
STTY(0, &termio);
|
||||
STTY (0, &termio);
|
||||
|
||||
if (! (pwd = getpwnam (name)))
|
||||
if (!(pwd = getpwnam (name)))
|
||||
return 0;
|
||||
|
||||
/*
|
||||
@@ -165,7 +177,7 @@ do_rlogin(const char *remote_host, char *name, int namelen, char *term, int term
|
||||
return 0;
|
||||
#else
|
||||
return ruserok (remote_host, pwd->pw_uid == 0,
|
||||
remote_name, name) == RUSEROK;
|
||||
remote_name, name) == RUSEROK;
|
||||
#endif
|
||||
}
|
||||
#endif /* RLOGIN */
|
||||
#endif /* RLOGIN */
|
||||
|
||||
@@ -8,16 +8,13 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: salt.c,v 1.5 1997/12/07 23:27:09 marekm Exp $")
|
||||
|
||||
RCSID ("$Id: salt.c,v 1.6 2003/04/22 10:59:22 kloczek Exp $")
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
#include <sys/time.h>
|
||||
|
||||
#if 1
|
||||
#include "getdef.h"
|
||||
|
||||
extern char *l64a();
|
||||
extern char *l64a ();
|
||||
|
||||
/*
|
||||
* Generate 8 base64 ASCII characters of random salt. If MD5_CRYPT_ENAB
|
||||
@@ -25,45 +22,42 @@ extern char *l64a();
|
||||
* (magic) and pw_encrypt() will execute the MD5-based FreeBSD-compatible
|
||||
* version of crypt() instead of the standard one.
|
||||
*/
|
||||
char *
|
||||
crypt_make_salt(void)
|
||||
char *crypt_make_salt (void)
|
||||
{
|
||||
struct timeval tv;
|
||||
static char result[40];
|
||||
|
||||
result[0] = '\0';
|
||||
if (getdef_bool("MD5_CRYPT_ENAB")) {
|
||||
strcpy(result, "$1$"); /* magic for the new MD5 crypt() */
|
||||
if (getdef_bool ("MD5_CRYPT_ENAB")) {
|
||||
strcpy (result, "$1$"); /* magic for the new MD5 crypt() */
|
||||
}
|
||||
|
||||
/*
|
||||
* Generate 8 chars of salt, the old crypt() will use only first 2.
|
||||
*/
|
||||
gettimeofday(&tv, (struct timezone *) 0);
|
||||
strcat(result, l64a(tv.tv_usec));
|
||||
strcat(result, l64a(tv.tv_sec + getpid() + clock()));
|
||||
gettimeofday (&tv, (struct timezone *) 0);
|
||||
strcat (result, l64a (tv.tv_usec));
|
||||
strcat (result, l64a (tv.tv_sec + getpid () + clock ()));
|
||||
|
||||
if (strlen(result) > 3 + 8) /* magic+salt */
|
||||
if (strlen (result) > 3 + 8) /* magic+salt */
|
||||
result[11] = '\0';
|
||||
|
||||
return result;
|
||||
}
|
||||
#else
|
||||
|
||||
/*
|
||||
* This is the old style random salt generator...
|
||||
*/
|
||||
char *
|
||||
crypt_make_salt(void)
|
||||
char *crypt_make_salt (void)
|
||||
{
|
||||
time_t now;
|
||||
static unsigned long x;
|
||||
static char result[3];
|
||||
|
||||
time(&now);
|
||||
x += now + getpid() + clock();
|
||||
result[0] = i64c(((x >> 18) ^ (x >> 6)) & 077);
|
||||
result[1] = i64c(((x >> 12) ^ x) & 077);
|
||||
time (&now);
|
||||
x += now + getpid () + clock ();
|
||||
result[0] = i64c (((x >> 18) ^ (x >> 6)) & 077);
|
||||
result[1] = i64c (((x >> 12) ^ x) & 077);
|
||||
result[2] = '\0';
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -34,35 +34,29 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: setugid.c,v 1.6 1998/07/23 22:13:16 marekm Exp $")
|
||||
|
||||
RCSID ("$Id: setugid.c,v 1.7 2003/04/22 10:59:22 kloczek Exp $")
|
||||
#include <stdio.h>
|
||||
#include <grp.h>
|
||||
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
#include <pwd.h>
|
||||
|
||||
#include "getdef.h"
|
||||
|
||||
/*
|
||||
* setup_uid_gid() split in two functions for PAM support -
|
||||
* pam_setcred() needs to be called after initgroups(), but
|
||||
* before setuid().
|
||||
*/
|
||||
|
||||
int
|
||||
setup_groups(const struct passwd *info)
|
||||
int setup_groups (const struct passwd *info)
|
||||
{
|
||||
/*
|
||||
* Set the real group ID to the primary group ID in the password
|
||||
* file.
|
||||
*/
|
||||
if (setgid (info->pw_gid) == -1) {
|
||||
perror("setgid");
|
||||
SYSLOG((LOG_ERR, "bad group ID `%d' for user `%s': %m\n",
|
||||
info->pw_gid, info->pw_name));
|
||||
closelog();
|
||||
perror ("setgid");
|
||||
SYSLOG ((LOG_ERR, "bad group ID `%d' for user `%s': %m\n",
|
||||
info->pw_gid, info->pw_name));
|
||||
closelog ();
|
||||
return -1;
|
||||
}
|
||||
#ifdef HAVE_INITGROUPS
|
||||
@@ -70,33 +64,32 @@ setup_groups(const struct passwd *info)
|
||||
* For systems which support multiple concurrent groups, go get
|
||||
* the group set from the /etc/group file.
|
||||
*/
|
||||
if (initgroups(info->pw_name, info->pw_gid) == -1) {
|
||||
perror("initgroups");
|
||||
SYSLOG((LOG_ERR, "initgroups failed for user `%s': %m\n",
|
||||
info->pw_name));
|
||||
closelog();
|
||||
if (initgroups (info->pw_name, info->pw_gid) == -1) {
|
||||
perror ("initgroups");
|
||||
SYSLOG ((LOG_ERR, "initgroups failed for user `%s': %m\n",
|
||||
info->pw_name));
|
||||
closelog ();
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
change_uid(const struct passwd *info)
|
||||
int change_uid (const struct passwd *info)
|
||||
{
|
||||
/*
|
||||
* Set the real UID to the UID value in the password file.
|
||||
*/
|
||||
#ifndef BSD
|
||||
if (setuid(info->pw_uid))
|
||||
if (setuid (info->pw_uid))
|
||||
#else
|
||||
if (setreuid(info->pw_uid, info->pw_uid))
|
||||
if (setreuid (info->pw_uid, info->pw_uid))
|
||||
#endif
|
||||
{
|
||||
perror("setuid");
|
||||
SYSLOG((LOG_ERR, "bad user ID `%d' for user `%s': %m\n",
|
||||
(int) info->pw_uid, info->pw_name));
|
||||
closelog();
|
||||
perror ("setuid");
|
||||
SYSLOG ((LOG_ERR, "bad user ID `%d' for user `%s': %m\n",
|
||||
(int) info->pw_uid, info->pw_name));
|
||||
closelog ();
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
@@ -113,21 +106,21 @@ change_uid(const struct passwd *info)
|
||||
* Returns 0 on success, or -1 on failure.
|
||||
*/
|
||||
|
||||
int
|
||||
setup_uid_gid(const struct passwd *info, int is_console)
|
||||
int setup_uid_gid (const struct passwd *info, int is_console)
|
||||
{
|
||||
if (setup_groups(info) < 0)
|
||||
if (setup_groups (info) < 0)
|
||||
return -1;
|
||||
|
||||
#ifdef HAVE_INITGROUPS
|
||||
if (is_console) {
|
||||
char *cp = getdef_str("CONSOLE_GROUPS");
|
||||
if (cp && add_groups(cp))
|
||||
perror("Warning: add_groups");
|
||||
}
|
||||
#endif /* HAVE_INITGROUPS */
|
||||
char *cp = getdef_str ("CONSOLE_GROUPS");
|
||||
|
||||
if (change_uid(info) < 0)
|
||||
if (cp && add_groups (cp))
|
||||
perror ("Warning: add_groups");
|
||||
}
|
||||
#endif /* HAVE_INITGROUPS */
|
||||
|
||||
if (change_uid (info) < 0)
|
||||
return -1;
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -30,12 +30,10 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: setup.c,v 1.3 1997/12/07 23:27:09 marekm Exp $")
|
||||
|
||||
RCSID ("$Id: setup.c,v 1.4 2003/04/22 10:59:22 kloczek Exp $")
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
#include <pwd.h>
|
||||
|
||||
/*
|
||||
* setup - initialize login environment
|
||||
*
|
||||
@@ -49,24 +47,22 @@ RCSID("$Id: setup.c,v 1.3 1997/12/07 23:27:09 marekm Exp $")
|
||||
* set the HOME, SHELL, MAIL, PATH, and LOGNAME or USER environmental
|
||||
* variables.
|
||||
*/
|
||||
|
||||
void
|
||||
setup(struct passwd *info)
|
||||
void setup (struct passwd *info)
|
||||
{
|
||||
/*
|
||||
* Set resource limits.
|
||||
*/
|
||||
setup_limits(info);
|
||||
setup_limits (info);
|
||||
|
||||
/*
|
||||
* Set the real group ID, do initgroups, and set the real user ID
|
||||
* to the value in the password file.
|
||||
*/
|
||||
if (setup_uid_gid(info, 0))
|
||||
exit(1);
|
||||
if (setup_uid_gid (info, 0))
|
||||
exit (1);
|
||||
|
||||
/*
|
||||
* Change to the home directory, and set up environment.
|
||||
*/
|
||||
setup_env(info);
|
||||
setup_env (info);
|
||||
}
|
||||
|
||||
@@ -34,51 +34,47 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: setupenv.c,v 1.11 2001/11/06 15:50:25 kloczek Exp $")
|
||||
|
||||
RCSID ("$Id: setupenv.c,v 1.13 2003/05/05 21:44:15 kloczek Exp $")
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
#include <pwd.h>
|
||||
#include "getdef.h"
|
||||
|
||||
static void
|
||||
addenv_path(const char *varname, const char *dirname, const char *filename)
|
||||
addenv_path (const char *varname, const char *dirname,
|
||||
const char *filename)
|
||||
{
|
||||
char *buf;
|
||||
|
||||
buf = xmalloc(strlen(dirname) + strlen(filename) + 2);
|
||||
sprintf(buf, "%s/%s", dirname, filename);
|
||||
addenv(varname, buf);
|
||||
free(buf);
|
||||
buf = xmalloc (strlen (dirname) + strlen (filename) + 2);
|
||||
sprintf (buf, "%s/%s", dirname, filename);
|
||||
addenv (varname, buf);
|
||||
free (buf);
|
||||
}
|
||||
|
||||
|
||||
#ifndef USE_PAM
|
||||
static void
|
||||
read_env_file(const char *filename)
|
||||
static void read_env_file (const char *filename)
|
||||
{
|
||||
FILE *fp;
|
||||
char buf[1024];
|
||||
char *cp, *name, *val;
|
||||
|
||||
fp = fopen(filename, "r");
|
||||
fp = fopen (filename, "r");
|
||||
if (!fp)
|
||||
return;
|
||||
while (fgets(buf, sizeof buf, fp) == buf) {
|
||||
cp = strrchr(buf, '\n');
|
||||
while (fgets (buf, sizeof buf, fp) == buf) {
|
||||
cp = strrchr (buf, '\n');
|
||||
if (!cp)
|
||||
break;
|
||||
*cp = '\0';
|
||||
|
||||
cp = buf;
|
||||
/* ignore whitespace and comments */
|
||||
while (*cp && isspace(*cp))
|
||||
while (*cp && isspace (*cp))
|
||||
cp++;
|
||||
if (*cp == '\0' || *cp == '#')
|
||||
continue;
|
||||
@@ -87,14 +83,14 @@ read_env_file(const char *filename)
|
||||
* (for example, the "export NAME" shell commands)
|
||||
*/
|
||||
name = cp;
|
||||
while (*cp && !isspace(*cp) && *cp != '=')
|
||||
while (*cp && !isspace (*cp) && *cp != '=')
|
||||
cp++;
|
||||
if (*cp != '=')
|
||||
continue;
|
||||
/* NUL-terminate the name */
|
||||
*cp++ = '\0';
|
||||
val = cp;
|
||||
#if 0 /* XXX untested, and needs rewrite with fewer goto's :-) */
|
||||
#if 0 /* XXX untested, and needs rewrite with fewer goto's :-) */
|
||||
/*
|
||||
(state, char_type) -> (state, action)
|
||||
|
||||
@@ -102,28 +98,28 @@ read_env_file(const char *filename)
|
||||
char_type: normal, white, backslash, single, double
|
||||
action: remove_curr, remove_curr_skip_next, remove_prev, finish XXX
|
||||
*/
|
||||
no_quote:
|
||||
no_quote:
|
||||
if (*cp == '\\') {
|
||||
/* remove the backslash */
|
||||
remove_char(cp);
|
||||
remove_char (cp);
|
||||
/* skip over the next character */
|
||||
if (*cp)
|
||||
cp++;
|
||||
goto no_quote;
|
||||
} else if (*cp == '\'') {
|
||||
/* remove the quote */
|
||||
remove_char(cp);
|
||||
remove_char (cp);
|
||||
/* now within single quotes */
|
||||
goto s_quote;
|
||||
} else if (*cp == '"') {
|
||||
/* remove the quote */
|
||||
remove_char(cp);
|
||||
remove_char (cp);
|
||||
/* now within double quotes */
|
||||
goto d_quote;
|
||||
} else if (*cp == '\0') {
|
||||
/* end of string */
|
||||
goto finished;
|
||||
} else if (isspace(*cp)) {
|
||||
} else if (isspace (*cp)) {
|
||||
/* unescaped whitespace - end of string */
|
||||
*cp = '\0';
|
||||
goto finished;
|
||||
@@ -131,10 +127,10 @@ no_quote:
|
||||
cp++;
|
||||
goto no_quote;
|
||||
}
|
||||
s_quote:
|
||||
s_quote:
|
||||
if (*cp == '\'') {
|
||||
/* remove the quote */
|
||||
remove_char(cp);
|
||||
remove_char (cp);
|
||||
/* unquoted again */
|
||||
goto no_quote;
|
||||
} else if (*cp == '\0') {
|
||||
@@ -145,10 +141,10 @@ s_quote:
|
||||
cp++;
|
||||
goto s_quote;
|
||||
}
|
||||
d_quote:
|
||||
d_quote:
|
||||
if (*cp == '\"') {
|
||||
/* remove the quote */
|
||||
remove_char(cp);
|
||||
remove_char (cp);
|
||||
/* unquoted again */
|
||||
goto no_quote;
|
||||
} else if (*cp == '\\') {
|
||||
@@ -156,28 +152,29 @@ d_quote:
|
||||
/* if backslash followed by double quote, remove backslash
|
||||
else skip over the backslash and following char */
|
||||
if (*cp == '"')
|
||||
remove_char(cp - 1);
|
||||
remove_char (cp - 1);
|
||||
else if (*cp)
|
||||
cp++;
|
||||
goto d_quote;
|
||||
} eise if (*cp == '\0') {
|
||||
}
|
||||
eise if (*cp == '\0') {
|
||||
/* end of string */
|
||||
goto finished;
|
||||
} else {
|
||||
/* preserve everything within double quotes */
|
||||
goto d_quote;
|
||||
}
|
||||
finished:
|
||||
#endif /* 0 */
|
||||
finished:
|
||||
#endif /* 0 */
|
||||
/*
|
||||
* XXX - should handle quotes, backslash escapes, etc.
|
||||
* like the shell does.
|
||||
*/
|
||||
addenv(name, val);
|
||||
addenv (name, val);
|
||||
}
|
||||
fclose(fp);
|
||||
fclose (fp);
|
||||
}
|
||||
#endif /* USE_PAM */
|
||||
#endif /* USE_PAM */
|
||||
|
||||
|
||||
/*
|
||||
@@ -186,8 +183,7 @@ finished:
|
||||
* variables.
|
||||
*/
|
||||
|
||||
void
|
||||
setup_env(struct passwd *info)
|
||||
void setup_env (struct passwd *info)
|
||||
{
|
||||
#ifndef USE_PAM
|
||||
char *envf;
|
||||
@@ -205,18 +201,19 @@ setup_env(struct passwd *info)
|
||||
* this a configurable option. --marekm
|
||||
*/
|
||||
|
||||
if (chdir(info->pw_dir) == -1) {
|
||||
if (chdir (info->pw_dir) == -1) {
|
||||
static char temp_pw_dir[] = "/";
|
||||
if (!getdef_bool("DEFAULT_HOME") || chdir("/") == -1) {
|
||||
fprintf(stderr, _("Unable to cd to \"%s\"\n"),
|
||||
info->pw_dir);
|
||||
SYSLOG((LOG_WARN,
|
||||
"unable to cd to `%s' for user `%s'\n",
|
||||
info->pw_dir, info->pw_name));
|
||||
closelog();
|
||||
|
||||
if (!getdef_bool ("DEFAULT_HOME") || chdir ("/") == -1) {
|
||||
fprintf (stderr, _("Unable to cd to \"%s\"\n"),
|
||||
info->pw_dir);
|
||||
SYSLOG ((LOG_WARN,
|
||||
"unable to cd to `%s' for user `%s'\n",
|
||||
info->pw_dir, info->pw_name));
|
||||
closelog ();
|
||||
exit (1);
|
||||
}
|
||||
puts(_("No directory, logging in with HOME=/"));
|
||||
puts (_("No directory, logging in with HOME=/"));
|
||||
info->pw_dir = temp_pw_dir;
|
||||
}
|
||||
|
||||
@@ -224,67 +221,64 @@ setup_env(struct passwd *info)
|
||||
* Create the HOME environmental variable and export it.
|
||||
*/
|
||||
|
||||
addenv("HOME", info->pw_dir);
|
||||
addenv ("HOME", info->pw_dir);
|
||||
|
||||
/*
|
||||
* Create the SHELL environmental variable and export it.
|
||||
*/
|
||||
|
||||
if (info->pw_shell == (char *) 0 || ! *info->pw_shell) {
|
||||
if (info->pw_shell == (char *) 0 || !*info->pw_shell) {
|
||||
static char temp_pw_shell[] = "/bin/sh";
|
||||
|
||||
info->pw_shell = temp_pw_shell;
|
||||
}
|
||||
|
||||
addenv("SHELL", info->pw_shell);
|
||||
addenv ("SHELL", info->pw_shell);
|
||||
|
||||
/*
|
||||
* Create the PATH environmental variable and export it.
|
||||
*/
|
||||
|
||||
cp = getdef_str((info->pw_uid == 0) ? "ENV_SUPATH" : "ENV_PATH");
|
||||
#if 0
|
||||
addenv(cp ? cp : "PATH=/bin:/usr/bin", NULL);
|
||||
#else
|
||||
cp = getdef_str ((info->pw_uid == 0) ? "ENV_SUPATH" : "ENV_PATH");
|
||||
if (!cp) {
|
||||
/* not specified, use a minimal default */
|
||||
addenv("PATH=/bin:/usr/bin", NULL);
|
||||
} else if (strchr(cp, '=')) {
|
||||
addenv ("PATH=/bin:/usr/bin", NULL);
|
||||
} else if (strchr (cp, '=')) {
|
||||
/* specified as name=value (PATH=...) */
|
||||
addenv(cp, NULL);
|
||||
addenv (cp, NULL);
|
||||
} else {
|
||||
/* only value specified without "PATH=" */
|
||||
addenv("PATH", cp);
|
||||
addenv ("PATH", cp);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Export the user name. For BSD derived systems, it's "USER", for
|
||||
* all others it's "LOGNAME". We set both of them.
|
||||
*/
|
||||
|
||||
addenv("USER", info->pw_name);
|
||||
addenv("LOGNAME", info->pw_name);
|
||||
addenv ("USER", info->pw_name);
|
||||
addenv ("LOGNAME", info->pw_name);
|
||||
|
||||
/*
|
||||
* MAILDIR environment variable for Qmail
|
||||
*/
|
||||
if ((cp=getdef_str("QMAIL_DIR")))
|
||||
addenv_path("MAILDIR", info->pw_dir, cp);
|
||||
if ((cp = getdef_str ("QMAIL_DIR")))
|
||||
addenv_path ("MAILDIR", info->pw_dir, cp);
|
||||
|
||||
/*
|
||||
* Create the MAIL environmental variable and export it. login.defs
|
||||
* knows the prefix.
|
||||
*/
|
||||
|
||||
if ((cp=getdef_str("MAIL_DIR")))
|
||||
addenv_path("MAIL", cp, info->pw_name);
|
||||
else if ((cp=getdef_str("MAIL_FILE")))
|
||||
addenv_path("MAIL", info->pw_dir, cp);
|
||||
if ((cp = getdef_str ("MAIL_DIR")))
|
||||
addenv_path ("MAIL", cp, info->pw_name);
|
||||
else if ((cp = getdef_str ("MAIL_FILE")))
|
||||
addenv_path ("MAIL", info->pw_dir, cp);
|
||||
else {
|
||||
#if defined(MAIL_SPOOL_FILE)
|
||||
addenv_path("MAIL", info->pw_dir, MAIL_SPOOL_FILE);
|
||||
addenv_path ("MAIL", info->pw_dir, MAIL_SPOOL_FILE);
|
||||
#elif defined(MAIL_SPOOL_DIR)
|
||||
addenv_path("MAIL", MAIL_SPOOL_DIR, info->pw_name);
|
||||
addenv_path ("MAIL", MAIL_SPOOL_DIR, info->pw_name);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -292,7 +286,7 @@ setup_env(struct passwd *info)
|
||||
/*
|
||||
* Read environment from optional config file. --marekm
|
||||
*/
|
||||
if ((envf = getdef_str("ENVIRON_FILE")))
|
||||
read_env_file(envf);
|
||||
if ((envf = getdef_str ("ENVIRON_FILE")))
|
||||
read_env_file (envf);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -30,14 +30,11 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: shell.c,v 1.7 1998/12/28 20:34:53 marekm Exp $")
|
||||
|
||||
RCSID ("$Id: shell.c,v 1.9 2003/05/05 21:49:56 kloczek Exp $")
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
|
||||
|
||||
extern char **newenvp;
|
||||
extern size_t newenvc;
|
||||
|
||||
@@ -54,8 +51,7 @@ extern size_t newenvc;
|
||||
* the file. If all that fails, give up in disgust ...
|
||||
*/
|
||||
|
||||
void
|
||||
shell(const char *file, const char *arg)
|
||||
void shell (const char *file, const char *arg)
|
||||
{
|
||||
char arg0[1024];
|
||||
int err;
|
||||
@@ -71,11 +67,12 @@ shell(const char *file, const char *arg)
|
||||
*/
|
||||
|
||||
if (arg == (char *) 0) {
|
||||
snprintf(arg0, sizeof arg0, "-%s", Basename((char *) file));
|
||||
snprintf (arg0, sizeof arg0, "-%s",
|
||||
Basename ((char *) file));
|
||||
arg = arg0;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
printf (_("Executing shell %s\n"), file);
|
||||
printf ("Executing shell %s\n", file);
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -98,7 +95,7 @@ shell(const char *file, const char *arg)
|
||||
*/
|
||||
|
||||
if (err == ENOEXEC) {
|
||||
FILE *fp;
|
||||
FILE *fp;
|
||||
|
||||
if ((fp = fopen (file, "r"))) {
|
||||
if (getc (fp) == '#' && getc (fp) == '!') {
|
||||
@@ -119,8 +116,8 @@ shell(const char *file, const char *arg)
|
||||
* up in disgust ...
|
||||
*/
|
||||
|
||||
snprintf(arg0, sizeof arg0, _("Cannot execute %s"), file);
|
||||
snprintf (arg0, sizeof arg0, _("Cannot execute %s"), file);
|
||||
errno = err;
|
||||
perror(arg0);
|
||||
exit(1);
|
||||
perror (arg0);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
@@ -34,18 +34,13 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: strtoday.c,v 1.8 1999/03/07 19:14:42 marekm Exp $")
|
||||
|
||||
RCSID ("$Id: strtoday.c,v 1.9 2003/04/22 10:59:22 kloczek Exp $")
|
||||
#include "defines.h"
|
||||
|
||||
#ifndef USE_GETDATE
|
||||
#define USE_GETDATE 1
|
||||
#endif
|
||||
|
||||
#if USE_GETDATE
|
||||
|
||||
#include "getdate.h"
|
||||
|
||||
/*
|
||||
* strtoday() now uses get_date() (borrowed from GNU shellutils)
|
||||
* which can handle many date formats, for example:
|
||||
@@ -60,8 +55,7 @@ RCSID("$Id: strtoday.c,v 1.8 1999/03/07 19:14:42 marekm Exp $")
|
||||
* 24-sep-72
|
||||
* 24sep72
|
||||
*/
|
||||
long
|
||||
strtoday(const char *str)
|
||||
long strtoday (const char *str)
|
||||
{
|
||||
time_t t;
|
||||
|
||||
@@ -73,20 +67,18 @@ strtoday(const char *str)
|
||||
if (!str || *str == '\0')
|
||||
return -1;
|
||||
|
||||
t = get_date(str, (time_t *) 0);
|
||||
if (t == (time_t) -1)
|
||||
t = get_date (str, (time_t *) 0);
|
||||
if (t == (time_t) - 1)
|
||||
return -1;
|
||||
/* convert seconds to days since 1970-01-01 */
|
||||
return (t + DAY/2)/DAY;
|
||||
return (t + DAY / 2) / DAY;
|
||||
}
|
||||
|
||||
#else /* !USE_GETDATE */
|
||||
#else /* !USE_GETDATE */
|
||||
/*
|
||||
* Old code, just in case get_date() doesn't work as expected...
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#ifdef HAVE_STRPTIME
|
||||
/*
|
||||
* for now we allow just one format, but we can define more later
|
||||
@@ -102,14 +94,15 @@ static char *date_formats[] = {
|
||||
* current month, and the cummulative number of days in the preceding
|
||||
* months. they are declared so that january is 1, not 0.
|
||||
*/
|
||||
static short days[13] = { 0,
|
||||
31, 28, 31, 30, 31, 30, /* JAN - JUN */
|
||||
31, 31, 30, 31, 30, 31
|
||||
}; /* JUL - DEC */
|
||||
|
||||
static short days[13] = { 0,
|
||||
31, 28, 31, 30, 31, 30, /* JAN - JUN */
|
||||
31, 31, 30, 31, 30, 31 }; /* JUL - DEC */
|
||||
|
||||
static short juldays[13] = { 0,
|
||||
0, 31, 59, 90, 120, 151, /* JAN - JUN */
|
||||
181, 212, 243, 273, 304, 334 }; /* JUL - DEC */
|
||||
static short juldays[13] = { 0,
|
||||
0, 31, 59, 90, 120, 151, /* JAN - JUN */
|
||||
181, 212, 243, 273, 304, 334
|
||||
}; /* JUL - DEC */
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -120,34 +113,33 @@ static short juldays[13] = { 0,
|
||||
* it having a day number of 0.
|
||||
*/
|
||||
|
||||
long
|
||||
strtoday(const char *str)
|
||||
long strtoday (const char *str)
|
||||
{
|
||||
#ifdef HAVE_STRPTIME
|
||||
struct tm tp;
|
||||
char * const *fmt;
|
||||
char *const *fmt;
|
||||
char *cp;
|
||||
time_t result;
|
||||
|
||||
memzero(&tp, sizeof tp);
|
||||
memzero (&tp, sizeof tp);
|
||||
for (fmt = date_formats; *fmt; fmt++) {
|
||||
cp = strptime((char *) str, *fmt, &tp);
|
||||
cp = strptime ((char *) str, *fmt, &tp);
|
||||
if (!cp || *cp != '\0')
|
||||
continue;
|
||||
|
||||
result = mktime(&tp);
|
||||
if (result == (time_t) -1)
|
||||
result = mktime (&tp);
|
||||
if (result == (time_t) - 1)
|
||||
continue;
|
||||
|
||||
return result / DAY; /* success */
|
||||
return result / DAY; /* success */
|
||||
}
|
||||
return -1;
|
||||
#else
|
||||
char slop[2];
|
||||
int month;
|
||||
int day;
|
||||
int year;
|
||||
long total;
|
||||
char slop[2];
|
||||
int month;
|
||||
int day;
|
||||
int year;
|
||||
long total;
|
||||
|
||||
/*
|
||||
* start by separating the month, day and year. the order
|
||||
@@ -198,10 +190,11 @@ strtoday(const char *str)
|
||||
*/
|
||||
|
||||
total = (long) ((year - 1970) * 365L) + (((year + 1) - 1970) / 4);
|
||||
total += (long) juldays[month] + (month > 2 && (year % 4) == 0 ? 1:0);
|
||||
total += (long) juldays[month] + (month > 2
|
||||
&& (year % 4) == 0 ? 1 : 0);
|
||||
total += (long) day - 1;
|
||||
|
||||
return total;
|
||||
#endif /* HAVE_STRPTIME */
|
||||
#endif /* HAVE_STRPTIME */
|
||||
}
|
||||
#endif /* !USE_GETDATE */
|
||||
#endif /* !USE_GETDATE */
|
||||
|
||||
@@ -30,17 +30,13 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: sub.c,v 1.6 1999/03/07 19:14:43 marekm Exp $")
|
||||
|
||||
RCSID ("$Id: sub.c,v 1.7 2003/04/22 10:59:22 kloczek Exp $")
|
||||
#include <sys/types.h>
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
|
||||
#include <pwd.h>
|
||||
|
||||
#define BAD_SUBROOT2 "invalid root `%s' for user `%s'\n"
|
||||
#define NO_SUBROOT2 "no subsystem root `%s' for user `%s'\n"
|
||||
|
||||
/*
|
||||
* subsystem - change to subsystem root
|
||||
*
|
||||
@@ -49,18 +45,16 @@ RCSID("$Id: sub.c,v 1.6 1999/03/07 19:14:43 marekm Exp $")
|
||||
* directory will be used as the root of a new filesystem which
|
||||
* the user is actually logged into.
|
||||
*/
|
||||
|
||||
void
|
||||
subsystem(const struct passwd *pw)
|
||||
void subsystem (const struct passwd *pw)
|
||||
{
|
||||
/*
|
||||
* The new root directory must begin with a "/" character.
|
||||
*/
|
||||
|
||||
if (pw->pw_dir[0] != '/') {
|
||||
printf(_("Invalid root directory \"%s\"\n"), pw->pw_dir);
|
||||
SYSLOG((LOG_WARN, BAD_SUBROOT2, pw->pw_dir, pw->pw_name));
|
||||
closelog();
|
||||
printf (_("Invalid root directory \"%s\"\n"), pw->pw_dir);
|
||||
SYSLOG ((LOG_WARN, BAD_SUBROOT2, pw->pw_dir, pw->pw_name));
|
||||
closelog ();
|
||||
exit (1);
|
||||
}
|
||||
|
||||
@@ -70,9 +64,10 @@ subsystem(const struct passwd *pw)
|
||||
*/
|
||||
|
||||
if (chdir (pw->pw_dir) || chroot (pw->pw_dir)) {
|
||||
printf(_("Can't change root directory to \"%s\"\n"), pw->pw_dir);
|
||||
SYSLOG((LOG_WARN, NO_SUBROOT2, pw->pw_dir, pw->pw_name));
|
||||
closelog();
|
||||
printf (_("Can't change root directory to \"%s\"\n"),
|
||||
pw->pw_dir);
|
||||
SYSLOG ((LOG_WARN, NO_SUBROOT2, pw->pw_dir, pw->pw_name));
|
||||
closelog ();
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,8 +30,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: sulog.c,v 1.6 2001/08/23 23:17:37 kloczek Exp $")
|
||||
|
||||
RCSID ("$Id: sulog.c,v 1.7 2003/04/22 10:59:22 kloczek Exp $")
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
@@ -39,13 +38,11 @@ RCSID("$Id: sulog.c,v 1.6 2001/08/23 23:17:37 kloczek Exp $")
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
#include "getdef.h"
|
||||
|
||||
/*
|
||||
* sulog - log a SU command execution result
|
||||
*/
|
||||
|
||||
void
|
||||
sulog(const char *tty, int success, const char *oldname, const char *name)
|
||||
sulog (const char *tty, int success, const char *oldname, const char *name)
|
||||
{
|
||||
char *sulog_file;
|
||||
time_t now;
|
||||
@@ -53,22 +50,22 @@ sulog(const char *tty, int success, const char *oldname, const char *name)
|
||||
FILE *fp;
|
||||
mode_t oldmask;
|
||||
|
||||
if ((sulog_file = getdef_str("SULOG_FILE")) == (char *) 0)
|
||||
if ((sulog_file = getdef_str ("SULOG_FILE")) == (char *) 0)
|
||||
return;
|
||||
|
||||
oldmask = umask(077);
|
||||
fp = fopen(sulog_file, "a+");
|
||||
umask(oldmask);
|
||||
oldmask = umask (077);
|
||||
fp = fopen (sulog_file, "a+");
|
||||
umask (oldmask);
|
||||
if (fp == (FILE *) 0)
|
||||
return; /* can't open or create logfile */
|
||||
return; /* can't open or create logfile */
|
||||
|
||||
time(&now);
|
||||
tm = localtime(&now);
|
||||
time (&now);
|
||||
tm = localtime (&now);
|
||||
|
||||
fprintf(fp, "SU %.02d/%.02d %.02d:%.02d %c %s %s-%s\n",
|
||||
tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min,
|
||||
success ? '+':'-', tty, oldname, name);
|
||||
fprintf (fp, "SU %.02d/%.02d %.02d:%.02d %c %s %s-%s\n",
|
||||
tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min,
|
||||
success ? '+' : '-', tty, oldname, name);
|
||||
|
||||
fflush(fp);
|
||||
fclose(fp);
|
||||
fflush (fp);
|
||||
fclose (fp);
|
||||
}
|
||||
|
||||
@@ -30,41 +30,38 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: ttytype.c,v 1.5 1997/12/07 23:27:10 marekm Exp $")
|
||||
|
||||
RCSID ("$Id: ttytype.c,v 1.6 2003/04/22 10:59:22 kloczek Exp $")
|
||||
#include <stdio.h>
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
#include "getdef.h"
|
||||
|
||||
extern char *getenv();
|
||||
extern char *getenv ();
|
||||
|
||||
/*
|
||||
* ttytype - set ttytype from port to terminal type mapping database
|
||||
*/
|
||||
|
||||
void
|
||||
ttytype(const char *line)
|
||||
void ttytype (const char *line)
|
||||
{
|
||||
FILE *fp;
|
||||
char buf[BUFSIZ];
|
||||
char *typefile;
|
||||
char *cp;
|
||||
char type[BUFSIZ];
|
||||
char port[BUFSIZ];
|
||||
FILE *fp;
|
||||
char buf[BUFSIZ];
|
||||
char *typefile;
|
||||
char *cp;
|
||||
char type[BUFSIZ];
|
||||
char port[BUFSIZ];
|
||||
|
||||
if (getenv ("TERM"))
|
||||
return;
|
||||
if ((typefile=getdef_str("TTYTYPE_FILE")) == NULL )
|
||||
if ((typefile = getdef_str ("TTYTYPE_FILE")) == NULL)
|
||||
return;
|
||||
if (access(typefile, F_OK))
|
||||
if (access (typefile, F_OK))
|
||||
return;
|
||||
|
||||
if (! (fp = fopen (typefile, "r"))) {
|
||||
if (!(fp = fopen (typefile, "r"))) {
|
||||
perror (typefile);
|
||||
return;
|
||||
}
|
||||
while (fgets(buf, sizeof buf, fp)) {
|
||||
while (fgets (buf, sizeof buf, fp)) {
|
||||
if (buf[0] == '#')
|
||||
continue;
|
||||
|
||||
@@ -73,17 +70,17 @@ ttytype(const char *line)
|
||||
|
||||
#if defined(SUN) || defined(BSD) || defined(SUN4)
|
||||
if ((sscanf (buf, "%s \"%*[^\"]\" %s", port, type) == 2 ||
|
||||
sscanf (buf, "%s %*s %s", port, type) == 2) &&
|
||||
strcmp (line, port) == 0)
|
||||
sscanf (buf, "%s %*s %s", port, type) == 2) &&
|
||||
strcmp (line, port) == 0)
|
||||
break;
|
||||
#else /* USG */
|
||||
#else /* USG */
|
||||
if (sscanf (buf, "%s %s", type, port) == 2 &&
|
||||
strcmp (line, port) == 0)
|
||||
strcmp (line, port) == 0)
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
if (! feof (fp) && ! ferror (fp))
|
||||
addenv("TERM", type);
|
||||
if (!feof (fp) && !ferror (fp))
|
||||
addenv ("TERM", type);
|
||||
|
||||
fclose (fp);
|
||||
}
|
||||
|
||||
18
libmisc/tz.c
18
libmisc/tz.c
@@ -30,38 +30,34 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: tz.c,v 1.4 1998/01/29 23:22:36 marekm Exp $")
|
||||
|
||||
RCSID ("$Id: tz.c,v 1.5 2003/04/22 10:59:22 kloczek Exp $")
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "defines.h"
|
||||
#include "getdef.h"
|
||||
|
||||
/*
|
||||
* tz - return local timezone name
|
||||
*
|
||||
* tz() determines the name of the local timezone by reading the
|
||||
* contents of the file named by ``fname''.
|
||||
*/
|
||||
|
||||
char *
|
||||
tz(const char *fname)
|
||||
char *tz (const char *fname)
|
||||
{
|
||||
FILE *fp = 0;
|
||||
static char tzbuf[BUFSIZ];
|
||||
const char *def_tz;
|
||||
|
||||
if ((fp = fopen(fname,"r")) == NULL ||
|
||||
fgets (tzbuf, sizeof (tzbuf), fp) == NULL) {
|
||||
if (! (def_tz = getdef_str ("ENV_TZ")) || def_tz[0] == '/')
|
||||
if ((fp = fopen (fname, "r")) == NULL ||
|
||||
fgets (tzbuf, sizeof (tzbuf), fp) == NULL) {
|
||||
if (!(def_tz = getdef_str ("ENV_TZ")) || def_tz[0] == '/')
|
||||
def_tz = "TZ=CST6CDT";
|
||||
|
||||
strcpy (tzbuf, def_tz);
|
||||
} else
|
||||
tzbuf[strlen(tzbuf) - 1] = '\0';
|
||||
tzbuf[strlen (tzbuf) - 1] = '\0';
|
||||
|
||||
if (fp)
|
||||
(void) fclose(fp);
|
||||
(void) fclose (fp);
|
||||
|
||||
return tzbuf;
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: ulimit.c,v 1.2 1997/12/07 23:27:11 marekm Exp $")
|
||||
|
||||
RCSID ("$Id: ulimit.c,v 1.3 2003/04/22 10:59:22 kloczek Exp $")
|
||||
#if HAVE_ULIMIT_H
|
||||
#include <ulimit.h>
|
||||
|
||||
#ifndef UL_SETFSIZE
|
||||
#ifdef UL_SFILLIM
|
||||
#define UL_SETFSIZE UL_SFILLIM
|
||||
@@ -13,22 +11,19 @@ RCSID("$Id: ulimit.c,v 1.2 1997/12/07 23:27:11 marekm Exp $")
|
||||
#define UL_SETFSIZE 2
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#elif HAVE_SYS_RESOURCE_H
|
||||
#include <sys/time.h> /* for struct timeval on sunos4 */
|
||||
#include <sys/time.h> /* for struct timeval on sunos4 */
|
||||
/* XXX - is the above ok or should it be <time.h> on ultrix? */
|
||||
#include <sys/resource.h>
|
||||
#endif
|
||||
|
||||
void
|
||||
set_filesize_limit(int blocks)
|
||||
void set_filesize_limit (int blocks)
|
||||
{
|
||||
#if HAVE_ULIMIT_H
|
||||
ulimit(UL_SETFSIZE, blocks);
|
||||
ulimit (UL_SETFSIZE, blocks);
|
||||
#elif defined(RLIMIT_FSIZE)
|
||||
struct rlimit rlimit_fsize;
|
||||
|
||||
rlimit_fsize.rlim_cur = rlimit_fsize.rlim_max = 512L * blocks;
|
||||
setrlimit(RLIMIT_FSIZE, &rlimit_fsize);
|
||||
setrlimit (RLIMIT_FSIZE, &rlimit_fsize);
|
||||
#endif
|
||||
}
|
||||
|
||||
300
libmisc/utmp.c
300
libmisc/utmp.c
@@ -41,17 +41,16 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: utmp.c,v 1.10 2002/03/08 04:30:30 kloczek Exp $")
|
||||
|
||||
RCSID ("$Id: utmp.c,v 1.14 2003/12/17 12:52:25 kloczek Exp $")
|
||||
#if HAVE_UTMPX_H
|
||||
struct utmpx utxent;
|
||||
#endif
|
||||
struct utmp utent;
|
||||
|
||||
extern struct utmp *getutent();
|
||||
extern struct utmp *getutline();
|
||||
extern void setutent();
|
||||
extern void endutent();
|
||||
extern struct utmp *getutent ();
|
||||
extern struct utmp *getutline ();
|
||||
extern void setutent ();
|
||||
extern void endutent ();
|
||||
|
||||
#define NO_UTENT \
|
||||
"No utmp entry. You must exec \"login\" from the lowest level \"sh\""
|
||||
@@ -72,21 +71,21 @@ extern void endutent();
|
||||
* command line flags.
|
||||
*/
|
||||
|
||||
#if defined(__linux__) /* XXX */
|
||||
#if defined(__linux__) /* XXX */
|
||||
|
||||
void
|
||||
checkutmp(int picky)
|
||||
void checkutmp (int picky)
|
||||
{
|
||||
char *line;
|
||||
struct utmp *ut;
|
||||
pid_t pid = getpid();
|
||||
pid_t pid = getpid ();
|
||||
|
||||
setutent();
|
||||
setutent ();
|
||||
|
||||
/* First, try to find a valid utmp entry for this process. */
|
||||
while ((ut = getutent()))
|
||||
while ((ut = getutent ()))
|
||||
if (ut->ut_pid == pid && ut->ut_line[0] && ut->ut_id[0] &&
|
||||
(ut->ut_type==LOGIN_PROCESS || ut->ut_type==USER_PROCESS))
|
||||
(ut->ut_type == LOGIN_PROCESS
|
||||
|| ut->ut_type == USER_PROCESS))
|
||||
break;
|
||||
|
||||
/* If there is one, just use it, otherwise create a new one. */
|
||||
@@ -94,54 +93,55 @@ checkutmp(int picky)
|
||||
utent = *ut;
|
||||
} else {
|
||||
if (picky) {
|
||||
puts(NO_UTENT);
|
||||
exit(1);
|
||||
puts (NO_UTENT);
|
||||
exit (1);
|
||||
}
|
||||
line = ttyname(0);
|
||||
line = ttyname (0);
|
||||
if (!line) {
|
||||
puts(NO_TTY);
|
||||
exit(1);
|
||||
puts (NO_TTY);
|
||||
exit (1);
|
||||
}
|
||||
if (strncmp(line, "/dev/", 5) == 0)
|
||||
if (strncmp (line, "/dev/", 5) == 0)
|
||||
line += 5;
|
||||
memset((void *) &utent, 0, sizeof utent);
|
||||
memset ((void *) &utent, 0, sizeof utent);
|
||||
utent.ut_type = LOGIN_PROCESS;
|
||||
utent.ut_pid = pid;
|
||||
strncpy(utent.ut_line, line, sizeof utent.ut_line);
|
||||
strncpy (utent.ut_line, line, sizeof utent.ut_line);
|
||||
/* XXX - assumes /dev/tty?? */
|
||||
strncpy(utent.ut_id, utent.ut_line + 3, sizeof utent.ut_id);
|
||||
strcpy(utent.ut_user, "LOGIN");
|
||||
time(&utent.ut_time);
|
||||
strncpy (utent.ut_id, utent.ut_line + 3,
|
||||
sizeof utent.ut_id);
|
||||
strcpy (utent.ut_user, "LOGIN");
|
||||
utent.ut_time = time (NULL);
|
||||
}
|
||||
}
|
||||
|
||||
#elif defined(LOGIN_PROCESS)
|
||||
|
||||
void
|
||||
checkutmp(int picky)
|
||||
void checkutmp (int picky)
|
||||
{
|
||||
char *line;
|
||||
struct utmp *ut;
|
||||
|
||||
#if HAVE_UTMPX_H
|
||||
struct utmpx *utx;
|
||||
#endif
|
||||
pid_t pid = getpid();
|
||||
pid_t pid = getpid ();
|
||||
|
||||
#if HAVE_UTMPX_H
|
||||
setutxent();
|
||||
setutxent ();
|
||||
#endif
|
||||
setutent();
|
||||
setutent ();
|
||||
|
||||
if (picky) {
|
||||
#if HAVE_UTMPX_H
|
||||
while ((utx = getutxent()))
|
||||
while ((utx = getutxent ()))
|
||||
if (utx->ut_pid == pid)
|
||||
break;
|
||||
|
||||
if (utx)
|
||||
utxent = *utx;
|
||||
#endif
|
||||
while ((ut = getutent()))
|
||||
while ((ut = getutent ()))
|
||||
if (ut->ut_pid == pid)
|
||||
break;
|
||||
|
||||
@@ -149,13 +149,13 @@ checkutmp(int picky)
|
||||
utent = *ut;
|
||||
|
||||
#if HAVE_UTMPX_H
|
||||
endutxent();
|
||||
endutxent ();
|
||||
#endif
|
||||
endutent();
|
||||
endutent ();
|
||||
|
||||
if (!ut) {
|
||||
puts(NO_UTENT);
|
||||
exit(1);
|
||||
puts (NO_UTENT);
|
||||
exit (1);
|
||||
}
|
||||
#ifndef UNIXPC
|
||||
|
||||
@@ -167,53 +167,64 @@ checkutmp(int picky)
|
||||
*/
|
||||
|
||||
if (utent.ut_line[0] == '\0')
|
||||
#endif /* !UNIXPC */
|
||||
#endif /* !UNIXPC */
|
||||
{
|
||||
if (!(line = ttyname(0))) {
|
||||
puts(NO_TTY);
|
||||
exit(1);
|
||||
if (!(line = ttyname (0))) {
|
||||
puts (NO_TTY);
|
||||
exit (1);
|
||||
}
|
||||
if (strncmp(line, "/dev/", 5) == 0)
|
||||
if (strncmp (line, "/dev/", 5) == 0)
|
||||
line += 5;
|
||||
strncpy(utent.ut_line, line, sizeof utent.ut_line);
|
||||
strncpy (utent.ut_line, line,
|
||||
sizeof utent.ut_line);
|
||||
#if HAVE_UTMPX_H
|
||||
strncpy(utxent.ut_line, line, sizeof utxent.ut_line);
|
||||
strncpy (utxent.ut_line, line,
|
||||
sizeof utxent.ut_line);
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
if (!(line = ttyname(0))) {
|
||||
puts(NO_TTY);
|
||||
exit(1);
|
||||
if (!(line = ttyname (0))) {
|
||||
puts (NO_TTY);
|
||||
exit (1);
|
||||
}
|
||||
if (strncmp(line, "/dev/", 5) == 0)
|
||||
if (strncmp (line, "/dev/", 5) == 0)
|
||||
line += 5;
|
||||
|
||||
strncpy (utent.ut_line, line, sizeof utent.ut_line);
|
||||
if ((ut = getutline(&utent)))
|
||||
strncpy(utent.ut_id, ut->ut_id, sizeof ut->ut_id);
|
||||
strncpy (utent.ut_line, line, sizeof utent.ut_line);
|
||||
if ((ut = getutline (&utent)))
|
||||
strncpy (utent.ut_id, ut->ut_id, sizeof ut->ut_id);
|
||||
|
||||
strcpy(utent.ut_user, "LOGIN");
|
||||
utent.ut_pid = getpid();
|
||||
strcpy (utent.ut_user, "LOGIN");
|
||||
utent.ut_pid = getpid ();
|
||||
utent.ut_type = LOGIN_PROCESS;
|
||||
time(&utent.ut_time);
|
||||
utent.ut_time = time (NULL);
|
||||
#if HAVE_UTMPX_H
|
||||
strncpy(utxent.ut_line, line, sizeof utxent.ut_line);
|
||||
if ((utx = getutxline(&utxent)))
|
||||
strncpy(utxent.ut_id, utx->ut_id, sizeof utxent.ut_id);
|
||||
strncpy (utxent.ut_line, line, sizeof utxent.ut_line);
|
||||
if ((utx = getutxline (&utxent)))
|
||||
strncpy (utxent.ut_id, utx->ut_id,
|
||||
sizeof utxent.ut_id);
|
||||
|
||||
strcpy(utxent.ut_user, "LOGIN");
|
||||
strcpy (utxent.ut_user, "LOGIN");
|
||||
utxent.ut_pid = utent.ut_pid;
|
||||
utxent.ut_type = utent.ut_type;
|
||||
gettimeofday((struct timeval *) &utxent.ut_tv, NULL);
|
||||
if (sizeof (utxent.ut_tv) == sizeof (struct timeval))
|
||||
gettimeofday ((struct timeval *) &utxent.ut_tv,
|
||||
NULL);
|
||||
else {
|
||||
struct timeval tv;
|
||||
|
||||
gettimeofday (&tv, NULL);
|
||||
utxent.ut_tv.tv_sec = tv.tv_sec;
|
||||
utxent.ut_tv.tv_usec = tv.tv_usec;
|
||||
}
|
||||
utent.ut_time = utxent.ut_tv.tv_sec;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#else /* !USG */
|
||||
#else /* !USG */
|
||||
|
||||
void
|
||||
checkutmp(int picky)
|
||||
void checkutmp (int picky)
|
||||
{
|
||||
char *line;
|
||||
|
||||
@@ -221,8 +232,8 @@ checkutmp(int picky)
|
||||
* Hand-craft a new utmp entry.
|
||||
*/
|
||||
|
||||
memzero(&utent, sizeof utent);
|
||||
if (! (line = ttyname (0))) {
|
||||
memzero (&utent, sizeof utent);
|
||||
if (!(line = ttyname (0))) {
|
||||
puts (NO_TTY);
|
||||
exit (1);
|
||||
}
|
||||
@@ -230,10 +241,10 @@ checkutmp(int picky)
|
||||
line += 5;
|
||||
|
||||
(void) strncpy (utent.ut_line, line, sizeof utent.ut_line);
|
||||
(void) time (&utent.ut_time);
|
||||
utent.ut_time = time (NULL);
|
||||
}
|
||||
|
||||
#endif /* !USG */
|
||||
#endif /* !USG */
|
||||
|
||||
|
||||
/*
|
||||
@@ -242,34 +253,32 @@ checkutmp(int picky)
|
||||
*/
|
||||
|
||||
#ifndef HAVE_UPDWTMP
|
||||
static void
|
||||
updwtmp(const char *filename, const struct utmp *ut)
|
||||
static void updwtmp (const char *filename, const struct utmp *ut)
|
||||
{
|
||||
int fd;
|
||||
|
||||
fd = open(filename, O_APPEND | O_WRONLY, 0);
|
||||
fd = open (filename, O_APPEND | O_WRONLY, 0);
|
||||
if (fd >= 0) {
|
||||
write(fd, (const char *) ut, sizeof(*ut));
|
||||
close(fd);
|
||||
write (fd, (const char *) ut, sizeof (*ut));
|
||||
close (fd);
|
||||
}
|
||||
}
|
||||
#endif /* ! HAVE_UPDWTMP */
|
||||
#endif /* ! HAVE_UPDWTMP */
|
||||
|
||||
#ifdef HAVE_UTMPX_H
|
||||
#ifndef HAVE_UPDWTMPX
|
||||
static void
|
||||
updwtmpx(const char *filename, const struct utmpx *utx)
|
||||
static void updwtmpx (const char *filename, const struct utmpx *utx)
|
||||
{
|
||||
int fd;
|
||||
|
||||
fd = open(filename, O_APPEND | O_WRONLY, 0);
|
||||
fd = open (filename, O_APPEND | O_WRONLY, 0);
|
||||
if (fd >= 0) {
|
||||
write(fd, (const char *) utx, sizeof(*utx));
|
||||
close(fd);
|
||||
write (fd, (const char *) utx, sizeof (*utx));
|
||||
close (fd);
|
||||
}
|
||||
}
|
||||
#endif /* ! HAVE_UPDWTMPX */
|
||||
#endif /* ! HAVE_UTMPX_H */
|
||||
#endif /* ! HAVE_UPDWTMPX */
|
||||
#endif /* ! HAVE_UTMPX_H */
|
||||
|
||||
|
||||
/*
|
||||
@@ -279,30 +288,28 @@ updwtmpx(const char *filename, const struct utmpx *utx)
|
||||
* USER_PROCESS. the wtmp file will be updated as well.
|
||||
*/
|
||||
|
||||
#if defined(__linux__) /* XXX */
|
||||
#if defined(__linux__) /* XXX */
|
||||
|
||||
void
|
||||
setutmp(const char *name, const char *line, const char *host)
|
||||
void setutmp (const char *name, const char *line, const char *host)
|
||||
{
|
||||
utent.ut_type = USER_PROCESS;
|
||||
strncpy(utent.ut_user, name, sizeof utent.ut_user);
|
||||
time(&utent.ut_time);
|
||||
strncpy (utent.ut_user, name, sizeof utent.ut_user);
|
||||
utent.ut_time = time (NULL);
|
||||
/* other fields already filled in by checkutmp above */
|
||||
setutent();
|
||||
pututline(&utent);
|
||||
endutent();
|
||||
updwtmp(_WTMP_FILE, &utent);
|
||||
setutent ();
|
||||
pututline (&utent);
|
||||
endutent ();
|
||||
updwtmp (_WTMP_FILE, &utent);
|
||||
}
|
||||
|
||||
#elif HAVE_UTMPX_H
|
||||
|
||||
void
|
||||
setutmp(const char *name, const char *line, const char *host)
|
||||
void setutmp (const char *name, const char *line, const char *host)
|
||||
{
|
||||
struct utmp *utmp, utline;
|
||||
struct utmpx *utmpx, utxline;
|
||||
pid_t pid = getpid ();
|
||||
int found_utmpx = 0, found_utmp = 0;
|
||||
struct utmp *utmp, utline;
|
||||
struct utmpx *utmpx, utxline;
|
||||
pid_t pid = getpid ();
|
||||
int found_utmpx = 0, found_utmp = 0;
|
||||
|
||||
/*
|
||||
* The canonical device name doesn't include "/dev/"; skip it
|
||||
@@ -338,7 +345,7 @@ setutmp(const char *name, const char *line, const char *host)
|
||||
* entry with the device name in it.
|
||||
*/
|
||||
|
||||
if (! found_utmpx) {
|
||||
if (!found_utmpx) {
|
||||
memset ((void *) &utxline, 0, sizeof utxline);
|
||||
strncpy (utxline.ut_line, line, sizeof utxline.ut_line);
|
||||
utxline.ut_pid = getpid ();
|
||||
@@ -346,20 +353,20 @@ setutmp(const char *name, const char *line, const char *host)
|
||||
utxline = *utmpx;
|
||||
if (strncmp (utxline.ut_line, "/dev/", 5) == 0) {
|
||||
memmove (utxline.ut_line, utxline.ut_line + 5,
|
||||
sizeof utxline.ut_line - 5);
|
||||
sizeof utxline.ut_line - 5);
|
||||
utxline.ut_line[sizeof utxline.ut_line - 5] = '\0';
|
||||
}
|
||||
}
|
||||
if (! found_utmp) {
|
||||
if (!found_utmp) {
|
||||
memset ((void *) &utline, 0, sizeof utline);
|
||||
strncpy (utline.ut_line, utxline.ut_line,
|
||||
sizeof utline.ut_line);
|
||||
sizeof utline.ut_line);
|
||||
utline.ut_pid = utxline.ut_pid;
|
||||
} else {
|
||||
utline = *utmp;
|
||||
if (strncmp (utline.ut_line, "/dev/", 5) == 0) {
|
||||
memmove (utline.ut_line, utline.ut_line + 5,
|
||||
sizeof utline.ut_line - 5);
|
||||
sizeof utline.ut_line - 5);
|
||||
utline.ut_line[sizeof utline.ut_line - 5] = '\0';
|
||||
}
|
||||
}
|
||||
@@ -375,101 +382,28 @@ setutmp(const char *name, const char *line, const char *host)
|
||||
|
||||
utline.ut_type = utxline.ut_type = USER_PROCESS;
|
||||
|
||||
gettimeofday(&utxline.ut_tv, NULL);
|
||||
if (sizeof (utxline.ut_tv) == sizeof (struct timeval))
|
||||
gettimeofday ((struct timeval *) &utxline.ut_tv, NULL);
|
||||
else {
|
||||
struct timeval tv;
|
||||
|
||||
gettimeofday (&tv, NULL);
|
||||
utxline.ut_tv.tv_sec = tv.tv_sec;
|
||||
utxline.ut_tv.tv_usec = tv.tv_usec;
|
||||
}
|
||||
utline.ut_time = utxline.ut_tv.tv_sec;
|
||||
|
||||
strncpy(utxline.ut_host, host ? host : "", sizeof utxline.ut_host);
|
||||
strncpy (utxline.ut_host, host ? host : "",
|
||||
sizeof utxline.ut_host);
|
||||
|
||||
pututxline (&utxline);
|
||||
pututline (&utline);
|
||||
|
||||
updwtmpx(_WTMP_FILE "x", &utxline);
|
||||
updwtmp(_WTMP_FILE, &utline);
|
||||
updwtmpx (_WTMP_FILE "x", &utxline);
|
||||
updwtmp (_WTMP_FILE, &utline);
|
||||
|
||||
utxent = utxline;
|
||||
utent = utline;
|
||||
}
|
||||
|
||||
#else /* !SVR4 */
|
||||
|
||||
void
|
||||
setutmp(const char *name, const char *line)
|
||||
{
|
||||
struct utmp utmp;
|
||||
int fd;
|
||||
int found = 0;
|
||||
|
||||
if ((fd = open(_UTMP_FILE, O_RDWR)) < 0)
|
||||
return;
|
||||
|
||||
#if !defined(SUN) && !defined(BSD) && !defined(SUN4) /* XXX */
|
||||
while (!found && read(fd, (char *)&utmp, sizeof utmp) == sizeof utmp) {
|
||||
if (! strncmp (line, utmp.ut_line, (int) sizeof utmp.ut_line))
|
||||
found++;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (! found) {
|
||||
|
||||
/*
|
||||
* This is a brand-new entry. Clear it out and fill it in
|
||||
* later.
|
||||
*/
|
||||
|
||||
memzero(&utmp, sizeof utmp);
|
||||
strncpy(utmp.ut_line, line, (int) sizeof utmp.ut_line);
|
||||
}
|
||||
|
||||
/*
|
||||
* Fill in the parts of the UTMP entry. BSD has just the name,
|
||||
* while System V has the name, PID and a type.
|
||||
*/
|
||||
|
||||
strncpy(utmp.ut_user, name, sizeof utent.ut_user);
|
||||
#ifdef USER_PROCESS
|
||||
utmp.ut_type = USER_PROCESS;
|
||||
utmp.ut_pid = getpid ();
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Put in the current time (common to everyone)
|
||||
*/
|
||||
|
||||
(void) time (&utmp.ut_time);
|
||||
|
||||
#ifdef UT_HOST
|
||||
/*
|
||||
* Update the host name field for systems with networking support
|
||||
*/
|
||||
|
||||
(void) strncpy (utmp.ut_host, utent.ut_host, (int) sizeof utmp.ut_host);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Locate the correct position in the UTMP file for this
|
||||
* entry.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_TTYSLOT
|
||||
(void) lseek (fd, (off_t) (sizeof utmp) * ttyslot (), SEEK_SET);
|
||||
#else
|
||||
if (found) /* Back up a splot */
|
||||
lseek (fd, (off_t) - sizeof utmp, SEEK_CUR);
|
||||
else /* Otherwise, go to the end of the file */
|
||||
lseek (fd, (off_t) 0, SEEK_END);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Scribble out the new entry and close the file. We're done
|
||||
* with UTMP, next we do WTMP (which is real easy, put it on
|
||||
* the end of the file.
|
||||
*/
|
||||
|
||||
(void) write (fd, (char *) &utmp, sizeof utmp);
|
||||
(void) close (fd);
|
||||
|
||||
updwtmp(_WTMP_FILE, &utmp);
|
||||
utent = utmp;
|
||||
}
|
||||
|
||||
#endif /* SVR4 */
|
||||
|
||||
@@ -30,14 +30,12 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: valid.c,v 1.4 1999/03/07 19:14:44 marekm Exp $")
|
||||
|
||||
RCSID ("$Id: valid.c,v 1.5 2003/04/22 10:59:22 kloczek Exp $")
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
#include <pwd.h>
|
||||
|
||||
/*
|
||||
* valid - compare encrypted passwords
|
||||
*
|
||||
@@ -48,9 +46,7 @@ RCSID("$Id: valid.c,v 1.4 1999/03/07 19:14:44 marekm Exp $")
|
||||
* is used to indicate that a dummy salt must be used to encrypt the
|
||||
* password anyway.
|
||||
*/
|
||||
|
||||
int
|
||||
valid(const char *password, const struct passwd *ent)
|
||||
int valid (const char *password, const struct passwd *ent)
|
||||
{
|
||||
const char *encrypted;
|
||||
const char *salt;
|
||||
@@ -62,8 +58,8 @@ valid(const char *password, const struct passwd *ent)
|
||||
* routine is meant to waste CPU time.
|
||||
*/
|
||||
|
||||
if (ent->pw_name && ! ent->pw_passwd[0]) {
|
||||
if (! password[0])
|
||||
if (ent->pw_name && !ent->pw_passwd[0]) {
|
||||
if (!password[0])
|
||||
return (1); /* user entered nothing */
|
||||
else
|
||||
return (0); /* user entered something! */
|
||||
@@ -86,7 +82,7 @@ valid(const char *password, const struct passwd *ent)
|
||||
* looking at execution time.
|
||||
*/
|
||||
|
||||
encrypted = pw_encrypt(password, salt);
|
||||
encrypted = pw_encrypt (password, salt);
|
||||
|
||||
/*
|
||||
* One last time we must deal with there being no password file
|
||||
@@ -94,7 +90,7 @@ valid(const char *password, const struct passwd *ent)
|
||||
* cause non-existent users to not be validated.
|
||||
*/
|
||||
|
||||
if (ent->pw_name && strcmp(encrypted, ent->pw_passwd) == 0)
|
||||
if (ent->pw_name && strcmp (encrypted, ent->pw_passwd) == 0)
|
||||
return (1);
|
||||
else
|
||||
return (0);
|
||||
|
||||
@@ -10,29 +10,24 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID("$Id: xmalloc.c,v 1.3 1998/12/28 20:34:56 marekm Exp $")
|
||||
|
||||
RCSID ("$Id: xmalloc.c,v 1.4 2003/04/22 10:59:22 kloczek Exp $")
|
||||
#include <stdio.h>
|
||||
|
||||
#include "defines.h"
|
||||
extern char *malloc ();
|
||||
|
||||
extern char *malloc();
|
||||
|
||||
char *
|
||||
xmalloc(size_t size)
|
||||
char *xmalloc (size_t size)
|
||||
{
|
||||
char *ptr;
|
||||
|
||||
ptr = malloc(size);
|
||||
ptr = malloc (size);
|
||||
if (!ptr && size) {
|
||||
fprintf(stderr, _("malloc(%d) failed\n"), (int) size);
|
||||
exit(13);
|
||||
fprintf (stderr, _("malloc(%d) failed\n"), (int) size);
|
||||
exit (13);
|
||||
}
|
||||
return ptr;
|
||||
}
|
||||
|
||||
char *
|
||||
xstrdup(const char *str)
|
||||
char *xstrdup (const char *str)
|
||||
{
|
||||
return strcpy(xmalloc(strlen(str) + 1), str);
|
||||
return strcpy (xmalloc (strlen (str) + 1), str);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user