[svn-upgrade] Integrating new upstream version, shadow (4.0.4)
This commit is contained in:
4
src/.indent.pro
vendored
Normal file
4
src/.indent.pro
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
-kr
|
||||
-i8
|
||||
-bad
|
||||
-pcs
|
||||
@@ -1,12 +1,12 @@
|
||||
|
||||
EXTRA_DOST = .indent.pro
|
||||
EXTRA_DIST = .indent.pro
|
||||
|
||||
ubindir = ${prefix}/bin
|
||||
usbindir = ${prefix}/sbin
|
||||
|
||||
DEFS = -D_HAVE_CONFIG_H -DLOCALEDIR=\"$(datadir)/locale\"
|
||||
|
||||
INCLUDES = -I${top_srcdir} \
|
||||
INCLUDES = \
|
||||
-I${top_srcdir}/lib \
|
||||
-I$(top_srcdir)/libmisc
|
||||
|
||||
@@ -23,9 +23,24 @@ INCLUDES = -I${top_srcdir} \
|
||||
|
||||
bin_PROGRAMS = groups login su
|
||||
ubin_PROGRAMS = faillog lastlog chage chfn chsh expiry gpasswd newgrp passwd
|
||||
usbin_PROGRAMS = chpasswd dpasswd groupadd groupdel groupmod \
|
||||
logoutd mkpasswd newusers useradd userdel usermod grpck \
|
||||
pwck vipw grpconv grpunconv pwconv pwunconv
|
||||
usbin_PROGRAMS = \
|
||||
chpasswd \
|
||||
groupadd \
|
||||
groupdel \
|
||||
groupmod \
|
||||
grpck \
|
||||
grpconv \
|
||||
grpunconv \
|
||||
logoutd \
|
||||
mkpasswd \
|
||||
newusers \
|
||||
pwck \
|
||||
pwconv \
|
||||
pwunconv \
|
||||
useradd \
|
||||
userdel \
|
||||
usermod \
|
||||
vipw
|
||||
|
||||
noinst_PROGRAMS = id sulogin
|
||||
|
||||
@@ -55,7 +70,7 @@ usermod_LDADD = $(LDADD) $(LIBPAM)
|
||||
|
||||
install-exec-hook:
|
||||
ln -sf newgrp $(DESTDIR)$(bindir)/sg
|
||||
ln -sf vigr $(DESTDIR)$(bindir)/vipw
|
||||
ln -sf vipw $(DESTDIR)$(bindir)/vigr
|
||||
for i in $(suidbins); do \
|
||||
chmod 4755 $(DESTDIR)$(bindir)/$$i; \
|
||||
done
|
||||
|
||||
523
src/Makefile.in
523
src/Makefile.in
@@ -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,108 +14,151 @@
|
||||
|
||||
@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 = -D_HAVE_CONFIG_H -DLOCALEDIR=\"$(datadir)/locale\"
|
||||
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
|
||||
EXTRA_DIST = .indent.pro
|
||||
|
||||
ubindir = ${prefix}/bin
|
||||
usbindir = ${prefix}/sbin
|
||||
|
||||
DEFS = -D_HAVE_CONFIG_H -DLOCALEDIR=\"$(datadir)/locale\"
|
||||
|
||||
INCLUDES = -I${top_srcdir} \
|
||||
INCLUDES = \
|
||||
-I${top_srcdir}/lib \
|
||||
-I$(top_srcdir)/libmisc
|
||||
|
||||
@@ -132,9 +176,24 @@ INCLUDES = -I${top_srcdir} \
|
||||
# $prefix/bin and $prefix/sbin, no install-data hacks...)
|
||||
bin_PROGRAMS = groups login su
|
||||
ubin_PROGRAMS = faillog lastlog chage chfn chsh expiry gpasswd newgrp passwd
|
||||
usbin_PROGRAMS = chpasswd dpasswd groupadd groupdel groupmod \
|
||||
logoutd mkpasswd newusers useradd userdel usermod grpck \
|
||||
pwck vipw grpconv grpunconv pwconv pwunconv
|
||||
usbin_PROGRAMS = \
|
||||
chpasswd \
|
||||
groupadd \
|
||||
groupdel \
|
||||
groupmod \
|
||||
grpck \
|
||||
grpconv \
|
||||
grpunconv \
|
||||
logoutd \
|
||||
mkpasswd \
|
||||
newusers \
|
||||
pwck \
|
||||
pwconv \
|
||||
pwunconv \
|
||||
useradd \
|
||||
userdel \
|
||||
usermod \
|
||||
vipw
|
||||
|
||||
|
||||
noinst_PROGRAMS = id sulogin
|
||||
@@ -164,6 +223,7 @@ useradd_LDADD = $(LDADD) $(LIBPAM)
|
||||
userdel_LDADD = $(LDADD) $(LIBPAM)
|
||||
usermod_LDADD = $(LDADD) $(LIBPAM)
|
||||
subdir = src
|
||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||
CONFIG_HEADER = $(top_builddir)/config.h
|
||||
CONFIG_CLEAN_FILES =
|
||||
@@ -172,12 +232,12 @@ noinst_PROGRAMS = id$(EXEEXT) sulogin$(EXEEXT)
|
||||
ubin_PROGRAMS = faillog$(EXEEXT) lastlog$(EXEEXT) chage$(EXEEXT) \
|
||||
chfn$(EXEEXT) chsh$(EXEEXT) expiry$(EXEEXT) gpasswd$(EXEEXT) \
|
||||
newgrp$(EXEEXT) passwd$(EXEEXT)
|
||||
usbin_PROGRAMS = chpasswd$(EXEEXT) dpasswd$(EXEEXT) groupadd$(EXEEXT) \
|
||||
groupdel$(EXEEXT) groupmod$(EXEEXT) logoutd$(EXEEXT) \
|
||||
mkpasswd$(EXEEXT) newusers$(EXEEXT) useradd$(EXEEXT) \
|
||||
userdel$(EXEEXT) usermod$(EXEEXT) grpck$(EXEEXT) pwck$(EXEEXT) \
|
||||
vipw$(EXEEXT) grpconv$(EXEEXT) grpunconv$(EXEEXT) \
|
||||
pwconv$(EXEEXT) pwunconv$(EXEEXT)
|
||||
usbin_PROGRAMS = chpasswd$(EXEEXT) groupadd$(EXEEXT) groupdel$(EXEEXT) \
|
||||
groupmod$(EXEEXT) grpck$(EXEEXT) grpconv$(EXEEXT) \
|
||||
grpunconv$(EXEEXT) logoutd$(EXEEXT) mkpasswd$(EXEEXT) \
|
||||
newusers$(EXEEXT) pwck$(EXEEXT) pwconv$(EXEEXT) \
|
||||
pwunconv$(EXEEXT) useradd$(EXEEXT) userdel$(EXEEXT) \
|
||||
usermod$(EXEEXT) vipw$(EXEEXT)
|
||||
PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS) $(ubin_PROGRAMS) \
|
||||
$(usbin_PROGRAMS)
|
||||
|
||||
@@ -201,12 +261,6 @@ chsh_OBJECTS = chsh.$(OBJEXT)
|
||||
chsh_DEPENDENCIES = $(top_builddir)/libmisc/libmisc.la \
|
||||
$(top_builddir)/lib/libshadow.la
|
||||
chsh_LDFLAGS =
|
||||
dpasswd_SOURCES = dpasswd.c
|
||||
dpasswd_OBJECTS = dpasswd.$(OBJEXT)
|
||||
dpasswd_LDADD = $(LDADD)
|
||||
dpasswd_DEPENDENCIES = $(top_builddir)/libmisc/libmisc.la \
|
||||
$(top_builddir)/lib/libshadow.la
|
||||
dpasswd_LDFLAGS =
|
||||
expiry_SOURCES = expiry.c
|
||||
expiry_OBJECTS = expiry.$(OBJEXT)
|
||||
expiry_LDADD = $(LDADD)
|
||||
@@ -359,28 +413,26 @@ vipw_LDADD = $(LDADD)
|
||||
vipw_DEPENDENCIES = $(top_builddir)/libmisc/libmisc.la \
|
||||
$(top_builddir)/lib/libshadow.la
|
||||
vipw_LDFLAGS =
|
||||
|
||||
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
|
||||
CPPFLAGS = @CPPFLAGS@
|
||||
LDFLAGS = @LDFLAGS@
|
||||
LIBS = @LIBS@
|
||||
depcomp = $(SHELL) $(top_srcdir)/depcomp
|
||||
@AMDEP_TRUE@DEP_FILES = $(DEPDIR)/chage.Po $(DEPDIR)/chfn.Po \
|
||||
@AMDEP_TRUE@ $(DEPDIR)/chpasswd.Po $(DEPDIR)/chsh.Po \
|
||||
@AMDEP_TRUE@ $(DEPDIR)/dpasswd.Po $(DEPDIR)/expiry.Po \
|
||||
@AMDEP_TRUE@ $(DEPDIR)/faillog.Po $(DEPDIR)/gpasswd.Po \
|
||||
@AMDEP_TRUE@ $(DEPDIR)/groupadd.Po $(DEPDIR)/groupdel.Po \
|
||||
@AMDEP_TRUE@ $(DEPDIR)/groupmod.Po $(DEPDIR)/groups.Po \
|
||||
@AMDEP_TRUE@ $(DEPDIR)/grpck.Po $(DEPDIR)/grpconv.Po \
|
||||
@AMDEP_TRUE@ $(DEPDIR)/grpunconv.Po $(DEPDIR)/id.Po \
|
||||
@AMDEP_TRUE@ $(DEPDIR)/lastlog.Po $(DEPDIR)/login.Po \
|
||||
@AMDEP_TRUE@ $(DEPDIR)/logoutd.Po $(DEPDIR)/mkpasswd.Po \
|
||||
@AMDEP_TRUE@ $(DEPDIR)/newgrp.Po $(DEPDIR)/newusers.Po \
|
||||
@AMDEP_TRUE@ $(DEPDIR)/passwd.Po $(DEPDIR)/pwck.Po \
|
||||
@AMDEP_TRUE@ $(DEPDIR)/pwconv.Po $(DEPDIR)/pwunconv.Po \
|
||||
@AMDEP_TRUE@ $(DEPDIR)/su.Po $(DEPDIR)/suauth.Po \
|
||||
@AMDEP_TRUE@ $(DEPDIR)/sulogin.Po $(DEPDIR)/useradd.Po \
|
||||
@AMDEP_TRUE@ $(DEPDIR)/userdel.Po $(DEPDIR)/usermod.Po \
|
||||
@AMDEP_TRUE@ $(DEPDIR)/vipw.Po
|
||||
am__depfiles_maybe = depfiles
|
||||
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/chage.Po ./$(DEPDIR)/chfn.Po \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/chpasswd.Po ./$(DEPDIR)/chsh.Po \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/expiry.Po ./$(DEPDIR)/faillog.Po \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/gpasswd.Po ./$(DEPDIR)/groupadd.Po \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/groupdel.Po ./$(DEPDIR)/groupmod.Po \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/groups.Po ./$(DEPDIR)/grpck.Po \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/grpconv.Po ./$(DEPDIR)/grpunconv.Po \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/id.Po ./$(DEPDIR)/lastlog.Po \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/login.Po ./$(DEPDIR)/logoutd.Po \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/mkpasswd.Po ./$(DEPDIR)/newgrp.Po \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/newusers.Po ./$(DEPDIR)/passwd.Po \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/pwck.Po ./$(DEPDIR)/pwconv.Po \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/pwunconv.Po ./$(DEPDIR)/su.Po \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/suauth.Po ./$(DEPDIR)/sulogin.Po \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/useradd.Po ./$(DEPDIR)/userdel.Po \
|
||||
@AMDEP_TRUE@ ./$(DEPDIR)/usermod.Po ./$(DEPDIR)/vipw.Po
|
||||
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
|
||||
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \
|
||||
@@ -388,36 +440,25 @@ LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) \
|
||||
CCLD = $(CC)
|
||||
LINK = $(LIBTOOL) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
|
||||
$(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
CFLAGS = @CFLAGS@
|
||||
DIST_SOURCES = chage.c chfn.c chpasswd.c chsh.c dpasswd.c expiry.c \
|
||||
faillog.c gpasswd.c groupadd.c groupdel.c groupmod.c groups.c \
|
||||
grpck.c grpconv.c grpunconv.c id.c lastlog.c login.c logoutd.c \
|
||||
DIST_SOURCES = chage.c chfn.c chpasswd.c chsh.c expiry.c faillog.c \
|
||||
gpasswd.c groupadd.c groupdel.c groupmod.c groups.c grpck.c \
|
||||
grpconv.c grpunconv.c id.c lastlog.c login.c logoutd.c \
|
||||
mkpasswd.c newgrp.c newusers.c passwd.c pwck.c pwconv.c \
|
||||
pwunconv.c $(su_SOURCES) sulogin.c useradd.c userdel.c \
|
||||
usermod.c vipw.c
|
||||
DIST_COMMON = Makefile.am Makefile.in
|
||||
SOURCES = chage.c chfn.c chpasswd.c chsh.c dpasswd.c expiry.c faillog.c gpasswd.c groupadd.c groupdel.c groupmod.c groups.c grpck.c grpconv.c grpunconv.c id.c lastlog.c login.c logoutd.c mkpasswd.c newgrp.c newusers.c passwd.c pwck.c pwconv.c pwunconv.c $(su_SOURCES) sulogin.c useradd.c userdel.c usermod.c vipw.c
|
||||
DIST_COMMON = $(srcdir)/Makefile.in Makefile.am
|
||||
SOURCES = chage.c chfn.c chpasswd.c chsh.c expiry.c faillog.c gpasswd.c groupadd.c groupdel.c groupmod.c groups.c grpck.c grpconv.c grpunconv.c id.c lastlog.c login.c logoutd.c mkpasswd.c newgrp.c newusers.c passwd.c pwck.c pwconv.c pwunconv.c $(su_SOURCES) sulogin.c useradd.c userdel.c usermod.c vipw.c
|
||||
|
||||
all: all-am
|
||||
|
||||
.SUFFIXES:
|
||||
.SUFFIXES: .c .lo .o .obj
|
||||
|
||||
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 src/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)
|
||||
binPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
|
||||
install-binPROGRAMS: $(bin_PROGRAMS)
|
||||
@$(NORMAL_INSTALL)
|
||||
$(mkinstalldirs) $(DESTDIR)$(bindir)
|
||||
@@ -426,25 +467,34 @@ install-binPROGRAMS: $(bin_PROGRAMS)
|
||||
if test -f $$p \
|
||||
|| test -f $$p1 \
|
||||
; then \
|
||||
f=`echo $$p1|sed '$(transform);s/$$/$(EXEEXT)/'`; \
|
||||
echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/$$f"; \
|
||||
$(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(bindir)/$$f; \
|
||||
f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
|
||||
echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) $$p $(DESTDIR)$(bindir)/$$f"; \
|
||||
$(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(binPROGRAMS_INSTALL) $$p $(DESTDIR)$(bindir)/$$f || exit 1; \
|
||||
else :; fi; \
|
||||
done
|
||||
|
||||
uninstall-binPROGRAMS:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
@list='$(bin_PROGRAMS)'; for p in $$list; do \
|
||||
f=`echo $$p|sed 's/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
|
||||
f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
|
||||
echo " rm -f $(DESTDIR)$(bindir)/$$f"; \
|
||||
rm -f $(DESTDIR)$(bindir)/$$f; \
|
||||
done
|
||||
|
||||
clean-binPROGRAMS:
|
||||
-test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
|
||||
@list='$(bin_PROGRAMS)'; for p in $$list; do \
|
||||
f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
|
||||
echo " rm -f $$p $$f"; \
|
||||
rm -f $$p $$f ; \
|
||||
done
|
||||
|
||||
clean-noinstPROGRAMS:
|
||||
-test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS)
|
||||
@list='$(noinst_PROGRAMS)'; for p in $$list; do \
|
||||
f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
|
||||
echo " rm -f $$p $$f"; \
|
||||
rm -f $$p $$f ; \
|
||||
done
|
||||
ubinPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
|
||||
install-ubinPROGRAMS: $(ubin_PROGRAMS)
|
||||
@$(NORMAL_INSTALL)
|
||||
$(mkinstalldirs) $(DESTDIR)$(ubindir)
|
||||
@@ -453,22 +503,27 @@ install-ubinPROGRAMS: $(ubin_PROGRAMS)
|
||||
if test -f $$p \
|
||||
|| test -f $$p1 \
|
||||
; then \
|
||||
f=`echo $$p1|sed '$(transform);s/$$/$(EXEEXT)/'`; \
|
||||
echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(ubindir)/$$f"; \
|
||||
$(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(ubindir)/$$f; \
|
||||
f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
|
||||
echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(ubinPROGRAMS_INSTALL) $$p $(DESTDIR)$(ubindir)/$$f"; \
|
||||
$(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(ubinPROGRAMS_INSTALL) $$p $(DESTDIR)$(ubindir)/$$f || exit 1; \
|
||||
else :; fi; \
|
||||
done
|
||||
|
||||
uninstall-ubinPROGRAMS:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
@list='$(ubin_PROGRAMS)'; for p in $$list; do \
|
||||
f=`echo $$p|sed 's/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
|
||||
f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
|
||||
echo " rm -f $(DESTDIR)$(ubindir)/$$f"; \
|
||||
rm -f $(DESTDIR)$(ubindir)/$$f; \
|
||||
done
|
||||
|
||||
clean-ubinPROGRAMS:
|
||||
-test -z "$(ubin_PROGRAMS)" || rm -f $(ubin_PROGRAMS)
|
||||
@list='$(ubin_PROGRAMS)'; for p in $$list; do \
|
||||
f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
|
||||
echo " rm -f $$p $$f"; \
|
||||
rm -f $$p $$f ; \
|
||||
done
|
||||
usbinPROGRAMS_INSTALL = $(INSTALL_PROGRAM)
|
||||
install-usbinPROGRAMS: $(usbin_PROGRAMS)
|
||||
@$(NORMAL_INSTALL)
|
||||
$(mkinstalldirs) $(DESTDIR)$(usbindir)
|
||||
@@ -477,22 +532,26 @@ install-usbinPROGRAMS: $(usbin_PROGRAMS)
|
||||
if test -f $$p \
|
||||
|| test -f $$p1 \
|
||||
; then \
|
||||
f=`echo $$p1|sed '$(transform);s/$$/$(EXEEXT)/'`; \
|
||||
echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(usbindir)/$$f"; \
|
||||
$(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(INSTALL_PROGRAM) $$p $(DESTDIR)$(usbindir)/$$f; \
|
||||
f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
|
||||
echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(usbinPROGRAMS_INSTALL) $$p $(DESTDIR)$(usbindir)/$$f"; \
|
||||
$(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(usbinPROGRAMS_INSTALL) $$p $(DESTDIR)$(usbindir)/$$f || exit 1; \
|
||||
else :; fi; \
|
||||
done
|
||||
|
||||
uninstall-usbinPROGRAMS:
|
||||
@$(NORMAL_UNINSTALL)
|
||||
@list='$(usbin_PROGRAMS)'; for p in $$list; do \
|
||||
f=`echo $$p|sed 's/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
|
||||
f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
|
||||
echo " rm -f $(DESTDIR)$(usbindir)/$$f"; \
|
||||
rm -f $(DESTDIR)$(usbindir)/$$f; \
|
||||
done
|
||||
|
||||
clean-usbinPROGRAMS:
|
||||
-test -z "$(usbin_PROGRAMS)" || rm -f $(usbin_PROGRAMS)
|
||||
@list='$(usbin_PROGRAMS)'; for p in $$list; do \
|
||||
f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
|
||||
echo " rm -f $$p $$f"; \
|
||||
rm -f $$p $$f ; \
|
||||
done
|
||||
chage$(EXEEXT): $(chage_OBJECTS) $(chage_DEPENDENCIES)
|
||||
@rm -f chage$(EXEEXT)
|
||||
$(LINK) $(chage_LDFLAGS) $(chage_OBJECTS) $(chage_LDADD) $(LIBS)
|
||||
@@ -505,9 +564,6 @@ chpasswd$(EXEEXT): $(chpasswd_OBJECTS) $(chpasswd_DEPENDENCIES)
|
||||
chsh$(EXEEXT): $(chsh_OBJECTS) $(chsh_DEPENDENCIES)
|
||||
@rm -f chsh$(EXEEXT)
|
||||
$(LINK) $(chsh_LDFLAGS) $(chsh_OBJECTS) $(chsh_LDADD) $(LIBS)
|
||||
dpasswd$(EXEEXT): $(dpasswd_OBJECTS) $(dpasswd_DEPENDENCIES)
|
||||
@rm -f dpasswd$(EXEEXT)
|
||||
$(LINK) $(dpasswd_LDFLAGS) $(dpasswd_OBJECTS) $(dpasswd_LDADD) $(LIBS)
|
||||
expiry$(EXEEXT): $(expiry_OBJECTS) $(expiry_DEPENDENCIES)
|
||||
@rm -f expiry$(EXEEXT)
|
||||
$(LINK) $(expiry_LDFLAGS) $(expiry_OBJECTS) $(expiry_LDADD) $(LIBS)
|
||||
@@ -596,110 +652,161 @@ mostlyclean-compile:
|
||||
distclean-compile:
|
||||
-rm -f *.tab.c
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/chage.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/chfn.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/chpasswd.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/chsh.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/dpasswd.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/expiry.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/faillog.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/gpasswd.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/groupadd.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/groupdel.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/groupmod.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/groups.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/grpck.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/grpconv.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/grpunconv.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/id.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/lastlog.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/login.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/logoutd.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/mkpasswd.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/newgrp.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/newusers.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/passwd.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/pwck.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/pwconv.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/pwunconv.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/su.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/suauth.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/sulogin.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/useradd.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/userdel.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/usermod.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@$(DEPDIR)/vipw.Po@am__quote@
|
||||
|
||||
distclean-depend:
|
||||
-rm -rf $(DEPDIR)
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chage.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chfn.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chpasswd.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chsh.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/expiry.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/faillog.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gpasswd.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/groupadd.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/groupdel.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/groupmod.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/groups.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grpck.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grpconv.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grpunconv.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/id.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lastlog.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/login.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/logoutd.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mkpasswd.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/newgrp.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/newusers.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/passwd.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pwck.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pwconv.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pwunconv.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/su.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/suauth.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sulogin.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/useradd.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/userdel.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/usermod.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vipw.Po@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)/'`$<
|
||||
|
||||
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 \
|
||||
@@ -712,7 +819,6 @@ all-am: Makefile $(PROGRAMS)
|
||||
|
||||
installdirs:
|
||||
$(mkinstalldirs) $(DESTDIR)$(bindir) $(DESTDIR)$(ubindir) $(DESTDIR)$(usbindir)
|
||||
|
||||
install: install-am
|
||||
install-exec: install-exec-am
|
||||
install-data: install-data-am
|
||||
@@ -724,6 +830,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:
|
||||
@@ -731,7 +838,7 @@ 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"
|
||||
@@ -743,9 +850,10 @@ clean-am: clean-binPROGRAMS clean-generic 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
|
||||
|
||||
@@ -770,7 +878,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
|
||||
@@ -778,28 +887,36 @@ mostlyclean: mostlyclean-am
|
||||
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
|
||||
mostlyclean-libtool
|
||||
|
||||
pdf: pdf-am
|
||||
|
||||
pdf-am:
|
||||
|
||||
ps: ps-am
|
||||
|
||||
ps-am:
|
||||
|
||||
uninstall-am: uninstall-binPROGRAMS uninstall-info-am \
|
||||
uninstall-ubinPROGRAMS uninstall-usbinPROGRAMS
|
||||
|
||||
.PHONY: GTAGS all all-am check check-am clean clean-binPROGRAMS \
|
||||
.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
|
||||
clean-generic clean-libtool clean-noinstPROGRAMS \
|
||||
clean-ubinPROGRAMS clean-usbinPROGRAMS distclean \
|
||||
distclean-compile distclean-depend distclean-generic \
|
||||
distclean-libtool distclean-tags distdir dvi dvi-am info \
|
||||
info-am install install-am install-binPROGRAMS install-data \
|
||||
install-data-am install-exec install-exec-am install-info \
|
||||
install-info-am install-man install-strip install-ubinPROGRAMS \
|
||||
clean-ubinPROGRAMS clean-usbinPROGRAMS ctags distclean \
|
||||
distclean-compile distclean-generic distclean-libtool \
|
||||
distclean-tags distdir dvi dvi-am info info-am install \
|
||||
install-am install-binPROGRAMS install-data install-data-am \
|
||||
install-exec install-exec-am install-info install-info-am \
|
||||
install-man install-strip install-ubinPROGRAMS \
|
||||
install-usbinPROGRAMS installcheck installcheck-am installdirs \
|
||||
maintainer-clean maintainer-clean-generic mostlyclean \
|
||||
mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
|
||||
tags uninstall uninstall-am uninstall-binPROGRAMS \
|
||||
uninstall-info-am uninstall-ubinPROGRAMS \
|
||||
mostlyclean-compile mostlyclean-generic mostlyclean-libtool pdf \
|
||||
pdf-am ps ps-am tags uninstall uninstall-am \
|
||||
uninstall-binPROGRAMS uninstall-info-am uninstall-ubinPROGRAMS \
|
||||
uninstall-usbinPROGRAMS
|
||||
|
||||
|
||||
install-exec-hook:
|
||||
ln -sf newgrp $(DESTDIR)$(bindir)/sg
|
||||
ln -sf vigr $(DESTDIR)$(bindir)/vipw
|
||||
ln -sf vipw $(DESTDIR)$(bindir)/vigr
|
||||
for i in $(suidbins); do \
|
||||
chmod 4755 $(DESTDIR)$(bindir)/$$i; \
|
||||
done
|
||||
|
||||
250
src/chage.c
250
src/chage.c
@@ -30,7 +30,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID (PKG_VER "$Id: chage.c,v 1.27 2002/01/05 15:41:43 kloczek Exp $")
|
||||
RCSID (PKG_VER "$Id: chage.c,v 1.32 2003/06/19 17:57:15 kloczek Exp $")
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
@@ -39,6 +39,7 @@ RCSID (PKG_VER "$Id: chage.c,v 1.27 2002/01/05 15:41:43 kloczek Exp $")
|
||||
#include <time.h>
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
#ifdef SHADOWPWD
|
||||
#ifdef USE_PAM
|
||||
#include <security/pam_appl.h>
|
||||
#include <security/pam_misc.h>
|
||||
@@ -49,17 +50,23 @@ RCSID (PKG_VER "$Id: chage.c,v 1.27 2002/01/05 15:41:43 kloczek Exp $")
|
||||
*/
|
||||
static char *Prog;
|
||||
|
||||
static int
|
||||
dflg = 0, /* set last password change date */
|
||||
Eflg = 0, /* set account expiration date */
|
||||
Iflg = 0, /* set password inactive after expiration */
|
||||
lflg = 0, /* show account aging information */
|
||||
mflg = 0, /* set minimum number of days before password change */
|
||||
Mflg = 0, /* set maximim number of days before password change */
|
||||
Wflg = 0; /* set expiration warning days */
|
||||
|
||||
static int locks;
|
||||
|
||||
static long mindays;
|
||||
static long maxdays;
|
||||
static long lastday;
|
||||
|
||||
#ifdef SHADOWPWD
|
||||
static long warndays;
|
||||
static long inactdays;
|
||||
static long expdays;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* External identifiers
|
||||
@@ -70,17 +77,12 @@ extern char *l64a ();
|
||||
|
||||
#include "pwio.h"
|
||||
|
||||
#ifdef SHADOWPWD
|
||||
#include "shadowio.h"
|
||||
#endif
|
||||
|
||||
#ifdef NDBM
|
||||
extern int pw_dbm_mode;
|
||||
|
||||
#ifdef SHADOWPWD
|
||||
extern int sp_dbm_mode;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define EPOCH "1969-12-31"
|
||||
|
||||
@@ -111,17 +113,10 @@ int isnum (const char *s)
|
||||
|
||||
static void usage (void)
|
||||
{
|
||||
#ifdef SHADOWPWD
|
||||
fprintf (stderr,
|
||||
_("Usage: %s [-l] [-m min_days] [-M max_days] [-W warn]\n"
|
||||
"\t[-I inactive] [-E expire] [-d last_day] user\n"),
|
||||
Prog);
|
||||
#else
|
||||
fprintf (stderr,
|
||||
_
|
||||
("Usage: %s [-l] [-m min_days] [-M max_days] [-d last_day] user\n"),
|
||||
Prog);
|
||||
#endif
|
||||
("Usage: chage [-l] [-m min_days] [-M max_days] [-W warn]\n"
|
||||
" [-I inactive] [-E expire] [-d last_day] user\n"));
|
||||
exit (1);
|
||||
}
|
||||
|
||||
@@ -178,7 +173,6 @@ static int new_fields (void)
|
||||
else if ((lastday = strtoday (buf)) == -1)
|
||||
return 0;
|
||||
|
||||
#ifdef SHADOWPWD
|
||||
snprintf (buf, sizeof buf, "%ld", warndays);
|
||||
change_field (buf, sizeof buf, _("Password Expiration Warning"));
|
||||
if (((warndays = strtol (buf, &cp, 10)) == 0 && *cp)
|
||||
@@ -200,7 +194,6 @@ static int new_fields (void)
|
||||
expdays = -1;
|
||||
else if ((expdays = strtoday (buf)) == -1)
|
||||
return 0;
|
||||
#endif /* SHADOWPWD */
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -247,10 +240,8 @@ static void list_fields (void)
|
||||
|
||||
printf (_("Minimum:\t%ld\n"), mindays);
|
||||
printf (_("Maximum:\t%ld\n"), maxdays);
|
||||
#ifdef SHADOWPWD
|
||||
printf (_("Warning:\t%ld\n"), warndays);
|
||||
printf (_("Inactive:\t%ld\n"), inactdays);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The "last change" date is either "Never" or the date the password
|
||||
@@ -279,7 +270,6 @@ static void list_fields (void)
|
||||
print_date (expires);
|
||||
}
|
||||
|
||||
#ifdef SHADOWPWD
|
||||
/*
|
||||
* The account becomes inactive if the password is expired for more
|
||||
* than "inactdays". The expiration date is calculated and the
|
||||
@@ -308,7 +298,6 @@ static void list_fields (void)
|
||||
expires = expdays * SCALE;
|
||||
print_date (expires);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef USE_PAM
|
||||
@@ -318,6 +307,24 @@ static struct pam_conv conv = {
|
||||
};
|
||||
#endif /* USE_PAM */
|
||||
|
||||
/*
|
||||
* cleanup - unlock any locked password files
|
||||
*/
|
||||
|
||||
static void cleanup (int state)
|
||||
{
|
||||
switch (state) {
|
||||
case 2:
|
||||
if (locks)
|
||||
spw_unlock ();
|
||||
case 1:
|
||||
if (locks)
|
||||
pw_unlock ();
|
||||
case 0:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* chage - change a user's password aging information
|
||||
*
|
||||
@@ -325,40 +332,25 @@ static struct pam_conv conv = {
|
||||
*
|
||||
* The valid options are
|
||||
*
|
||||
* -m minimum number of days before password change (*)
|
||||
* -M maximim number of days before password change (*)
|
||||
* -d last password change date (*)
|
||||
* -l password aging information
|
||||
* -W expiration warning days (*)
|
||||
* -I password inactive after expiration (*)
|
||||
* -E account expiration date (*)
|
||||
* -m set minimum number of days before password change (*)
|
||||
* -M set maximim number of days before password change (*)
|
||||
* -d set last password change date (*)
|
||||
* -l show account aging information
|
||||
* -W set expiration warning days (*)
|
||||
* -I set password inactive after expiration (*)
|
||||
* -E set account expiration date (*)
|
||||
*
|
||||
* (*) requires root permission to execute.
|
||||
*
|
||||
* All of the time fields are entered in the internal format which is
|
||||
* either seconds or days.
|
||||
*
|
||||
* The options -W, -I and -E all depend on the SHADOWPWD macro being
|
||||
* defined.
|
||||
*/
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
int flag;
|
||||
int lflg = 0;
|
||||
int mflg = 0;
|
||||
int Mflg = 0;
|
||||
int dflg = 0;
|
||||
|
||||
#ifdef SHADOWPWD
|
||||
int Wflg = 0;
|
||||
int Iflg = 0;
|
||||
int Eflg = 0;
|
||||
const struct spwd *sp;
|
||||
struct spwd spwd;
|
||||
#else
|
||||
char new_age[5];
|
||||
#endif
|
||||
uid_t ruid;
|
||||
int amroot, pwrw;
|
||||
const struct passwd *pw;
|
||||
@@ -388,9 +380,7 @@ int main (int argc, char **argv)
|
||||
OPENLOG ("chage");
|
||||
|
||||
#ifdef NDBM
|
||||
#ifdef SHADOWPWD
|
||||
sp_dbm_mode = O_RDWR;
|
||||
#endif
|
||||
pw_dbm_mode = O_RDWR;
|
||||
#endif
|
||||
|
||||
@@ -402,13 +392,7 @@ int main (int argc, char **argv)
|
||||
* weeks.
|
||||
*/
|
||||
|
||||
#ifdef SHADOWPWD
|
||||
#define FLAGS "lm:M:W:I:E:d:"
|
||||
#else
|
||||
#define FLAGS "lm:M:d:"
|
||||
#endif
|
||||
while ((flag = getopt (argc, argv, FLAGS)) != EOF) {
|
||||
#undef FLAGS
|
||||
while ((flag = getopt (argc, argv, "lm:M:W:I:E:d:")) != EOF) {
|
||||
switch (flag) {
|
||||
case 'l':
|
||||
lflg++;
|
||||
@@ -428,7 +412,6 @@ int main (int argc, char **argv)
|
||||
else
|
||||
lastday = strtol (optarg, 0, 10);
|
||||
break;
|
||||
#ifdef SHADOWPWD
|
||||
case 'W':
|
||||
Wflg++;
|
||||
warndays = strtol (optarg, 0, 10);
|
||||
@@ -444,7 +427,6 @@ int main (int argc, char **argv)
|
||||
else
|
||||
expdays = strtol (optarg, 0, 10);
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
usage ();
|
||||
}
|
||||
@@ -458,12 +440,7 @@ int main (int argc, char **argv)
|
||||
if (argc != optind + 1)
|
||||
usage ();
|
||||
|
||||
#ifdef SHADOWPWD
|
||||
if (lflg && (mflg || Mflg || dflg || Wflg || Iflg || Eflg))
|
||||
#else
|
||||
if (lflg && (mflg || Mflg || dflg))
|
||||
#endif
|
||||
{
|
||||
if (lflg && (mflg || Mflg || dflg || Wflg || Iflg || Eflg)) {
|
||||
fprintf (stderr,
|
||||
_("%s: do not include \"l\" with other flags\n"),
|
||||
Prog);
|
||||
@@ -528,18 +505,7 @@ int main (int argc, char **argv)
|
||||
* file entries into memory. Then we get a pointer to the password
|
||||
* file entry for the requested user.
|
||||
*/
|
||||
#ifndef SHADOWPWD
|
||||
if (locks && !pw_lock ()) {
|
||||
fprintf (stderr, _("%s: can't lock password file\n"),
|
||||
Prog);
|
||||
SYSLOG ((LOG_ERR, "failed locking %s", PASSWD_FILE));
|
||||
closelog ();
|
||||
exit (1);
|
||||
}
|
||||
pwrw = locks;
|
||||
#else
|
||||
pwrw = 0;
|
||||
#endif
|
||||
if (!pw_open (pwrw ? O_RDWR : O_RDONLY)) {
|
||||
fprintf (stderr, _("%s: can't open password file\n"),
|
||||
Prog);
|
||||
@@ -559,7 +525,6 @@ int main (int argc, char **argv)
|
||||
pwent = *pw;
|
||||
STRFCPY (name, pwent.pw_name);
|
||||
|
||||
#ifdef SHADOWPWD
|
||||
/*
|
||||
* For shadow password files we have to lock the file and read in
|
||||
* the entries as was done for the password file. The user entries
|
||||
@@ -612,35 +577,6 @@ int main (int argc, char **argv)
|
||||
if (!Eflg)
|
||||
expdays = spwd.sp_expire;
|
||||
}
|
||||
#ifdef ATT_AGE
|
||||
else
|
||||
#endif /* ATT_AGE */
|
||||
#endif /* SHADOWPWD */
|
||||
#ifdef ATT_AGE
|
||||
{
|
||||
if (pwent.pw_age && strlen (pwent.pw_age) >= 2) {
|
||||
if (!Mflg)
|
||||
maxdays =
|
||||
c64i (pwent.pw_age[0]) * (WEEK /
|
||||
SCALE);
|
||||
if (!mflg)
|
||||
mindays =
|
||||
c64i (pwent.pw_age[1]) * (WEEK /
|
||||
SCALE);
|
||||
if (!dflg && strlen (pwent.pw_age) == 4)
|
||||
lastday =
|
||||
a64l (pwent.pw_age +
|
||||
2) * (WEEK / SCALE);
|
||||
} else {
|
||||
mindays = 0;
|
||||
maxdays = 10000L * (DAY / SCALE);
|
||||
lastday = -1;
|
||||
}
|
||||
#ifdef SHADOWPWD
|
||||
warndays = inactdays = expdays = -1;
|
||||
#endif /* SHADOWPWD */
|
||||
}
|
||||
#endif /* ATT_AGE */
|
||||
|
||||
/*
|
||||
* Print out the expiration fields if the user has requested the
|
||||
@@ -665,12 +601,7 @@ int main (int argc, char **argv)
|
||||
* user interactively change them.
|
||||
*/
|
||||
|
||||
#ifdef SHADOWPWD
|
||||
if (!mflg && !Mflg && !dflg && !Wflg && !Iflg && !Eflg)
|
||||
#else
|
||||
if (!mflg && !Mflg && !dflg)
|
||||
#endif
|
||||
{
|
||||
if (!mflg && !Mflg && !dflg && !Wflg && !Iflg && !Eflg) {
|
||||
printf (_("Changing the aging information for %s\n"),
|
||||
name);
|
||||
if (!new_fields ()) {
|
||||
@@ -681,7 +612,6 @@ int main (int argc, char **argv)
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
#ifdef SHADOWPWD
|
||||
/*
|
||||
* There was no shadow entry. The new entry will have the encrypted
|
||||
* password transferred from the normal password file along with the
|
||||
@@ -697,9 +627,6 @@ int main (int argc, char **argv)
|
||||
spwd.sp_flag = -1;
|
||||
|
||||
pwent.pw_passwd = SHADOW_PASSWD_STRING; /* XXX warning: const */
|
||||
#ifdef ATT_AGE
|
||||
pwent.pw_age = "";
|
||||
#endif
|
||||
if (!pw_update (&pwent)) {
|
||||
fprintf (stderr,
|
||||
_("%s: can't update password file\n"),
|
||||
@@ -715,9 +642,6 @@ int main (int argc, char **argv)
|
||||
endpwent ();
|
||||
#endif
|
||||
}
|
||||
#endif /* SHADOWPWD */
|
||||
|
||||
#ifdef SHADOWPWD
|
||||
|
||||
/*
|
||||
* Copy the fields back to the shadow file entry and write the
|
||||
@@ -741,44 +665,7 @@ int main (int argc, char **argv)
|
||||
closelog ();
|
||||
exit (1);
|
||||
}
|
||||
#else /* !SHADOWPWD */
|
||||
|
||||
/*
|
||||
* fill in the new_age string with the new values
|
||||
*/
|
||||
|
||||
if (maxdays > (63 * 7) && mindays == 0) {
|
||||
new_age[0] = '\0';
|
||||
} else {
|
||||
if (maxdays > (63 * 7))
|
||||
maxdays = 63 * 7;
|
||||
|
||||
if (mindays > (63 * 7))
|
||||
mindays = 63 * 7;
|
||||
|
||||
new_age[0] = i64c (maxdays / 7);
|
||||
new_age[1] = i64c ((mindays + 6) / 7);
|
||||
|
||||
if (lastday == 0)
|
||||
new_age[2] = '\0';
|
||||
else
|
||||
strcpy (new_age + 2, l64a (lastday / 7));
|
||||
|
||||
}
|
||||
pwent.pw_age = new_age;
|
||||
|
||||
if (!pw_update (&pwent)) {
|
||||
fprintf (stderr, _("%s: can't update password file\n"),
|
||||
Prog);
|
||||
cleanup (2);
|
||||
SYSLOG ((LOG_ERR, "failed updating %s", PASSWD_FILE));
|
||||
closelog ();
|
||||
exit (1);
|
||||
}
|
||||
#endif /* SHADOWPWD */
|
||||
|
||||
#ifdef NDBM
|
||||
#ifdef SHADOWPWD
|
||||
|
||||
/*
|
||||
* See if the shadow DBM file exists and try to update it.
|
||||
@@ -794,25 +681,8 @@ int main (int argc, char **argv)
|
||||
}
|
||||
endspent ();
|
||||
|
||||
#else /* !SHADOWPWD */
|
||||
|
||||
/*
|
||||
* See if the password DBM file exists and try to update it.
|
||||
*/
|
||||
|
||||
if (pw_dbm_present () && !pw_dbm_update (&pwent)) {
|
||||
fprintf (stderr,
|
||||
_("Error updating the DBM password entry.\n"));
|
||||
cleanup (2);
|
||||
SYSLOG ((LOG_ERR, "error updating DBM passwd entry"));
|
||||
closelog ();
|
||||
exit (1);
|
||||
}
|
||||
endpwent ();
|
||||
#endif /* SHADOWPWD */
|
||||
#endif /* NDBM */
|
||||
|
||||
#ifdef SHADOWPWD
|
||||
/*
|
||||
* Now close the shadow password file, which will cause all of the
|
||||
* entries to be re-written.
|
||||
@@ -827,7 +697,6 @@ int main (int argc, char **argv)
|
||||
closelog ();
|
||||
exit (1);
|
||||
}
|
||||
#endif /* SHADOWPWD */
|
||||
|
||||
/*
|
||||
* Close the password file. If any entries were modified, the file
|
||||
@@ -844,6 +713,7 @@ int main (int argc, char **argv)
|
||||
}
|
||||
cleanup (2);
|
||||
SYSLOG ((LOG_INFO, "changed password expiry for %s", name));
|
||||
|
||||
#ifdef USE_PAM
|
||||
if (!lflg) {
|
||||
if (retval == PAM_SUCCESS) {
|
||||
@@ -862,30 +732,22 @@ int main (int argc, char **argv)
|
||||
|
||||
if (retval == PAM_SUCCESS)
|
||||
pam_end (pamh, PAM_SUCCESS);
|
||||
|
||||
#endif /* USE_PAM */
|
||||
|
||||
closelog ();
|
||||
|
||||
|
||||
exit (0);
|
||||
/*NOTREACHED*/}
|
||||
|
||||
/*
|
||||
* cleanup - unlock any locked password files
|
||||
*/
|
||||
|
||||
static void cleanup (int state)
|
||||
{
|
||||
switch (state) {
|
||||
case 2:
|
||||
#ifdef SHADOWPWD
|
||||
if (locks)
|
||||
spw_unlock ();
|
||||
#endif
|
||||
case 1:
|
||||
#ifndef SHADOWPWD
|
||||
if (locks)
|
||||
pw_unlock ();
|
||||
#endif
|
||||
case 0:
|
||||
break;
|
||||
}
|
||||
/* NOTREACHED */
|
||||
}
|
||||
|
||||
#else /* !SHADOWPWD */
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"%s: not configured for shadow password support.\n",
|
||||
argv[0]);
|
||||
exit (1);
|
||||
}
|
||||
#endif /* !SHADOWPWD */
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID (PKG_VER "$Id: chfn.c,v 1.20 2002/01/05 15:41:43 kloczek Exp $")
|
||||
RCSID (PKG_VER "$Id: chfn.c,v 1.22 2003/06/19 18:11:01 kloczek Exp $")
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
@@ -41,6 +41,7 @@ RCSID (PKG_VER "$Id: chfn.c,v 1.20 2002/01/05 15:41:43 kloczek Exp $")
|
||||
#include "pwio.h"
|
||||
#include "getdef.h"
|
||||
#include "pwauth.h"
|
||||
#include "nscd.h"
|
||||
#ifdef HAVE_SHADOW_H
|
||||
#include <shadow.h>
|
||||
#endif
|
||||
@@ -595,6 +596,9 @@ int main (int argc, char **argv)
|
||||
exit (1);
|
||||
}
|
||||
SYSLOG ((LOG_INFO, "changed user `%s' information", user));
|
||||
|
||||
nscd_flush_cache ("passwd");
|
||||
|
||||
closelog ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID (PKG_VER "$Id: chpasswd.c,v 1.14 2002/01/05 15:41:43 kloczek Exp $")
|
||||
RCSID (PKG_VER "$Id: chpasswd.c,v 1.18 2003/06/19 18:11:01 kloczek Exp $")
|
||||
#include <stdio.h>
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
@@ -40,6 +40,7 @@ RCSID (PKG_VER "$Id: chpasswd.c,v 1.14 2002/01/05 15:41:43 kloczek Exp $")
|
||||
#ifdef SHADOWPWD
|
||||
#include "shadowio.h"
|
||||
#endif
|
||||
#include "nscd.h"
|
||||
#ifdef USE_PAM
|
||||
#include <security/pam_appl.h>
|
||||
#include <security/pam_misc.h>
|
||||
@@ -63,7 +64,7 @@ static void usage (void);
|
||||
|
||||
static void usage (void)
|
||||
{
|
||||
fprintf (stderr, _("usage: %s [-e]\n"), Prog);
|
||||
fprintf (stderr, _("Usage: %s [-e]\n"), Prog);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
@@ -87,10 +88,6 @@ int main (int argc, char **argv)
|
||||
#endif
|
||||
const struct passwd *pw;
|
||||
struct passwd newpw;
|
||||
|
||||
#ifdef ATT_AGE
|
||||
char newage[5];
|
||||
#endif
|
||||
int errors = 0;
|
||||
int line = 0;
|
||||
long now = time ((long *) 0) / (24L * 3600L);
|
||||
@@ -262,13 +259,6 @@ int main (int argc, char **argv)
|
||||
{
|
||||
newpw = *pw;
|
||||
newpw.pw_passwd = cp;
|
||||
#ifdef ATT_AGE
|
||||
if (newpw.pw_age[0]) {
|
||||
strcpy (newage, newpw.pw_age);
|
||||
strcpy (newage + 2, l64a (now / 7));
|
||||
newpw.pw_age = newage;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -329,6 +319,9 @@ int main (int argc, char **argv)
|
||||
Prog);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
nscd_flush_cache ("passwd");
|
||||
|
||||
pw_unlock ();
|
||||
|
||||
#ifdef USE_PAM
|
||||
|
||||
20
src/chsh.c
20
src/chsh.c
@@ -30,7 +30,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID (PKG_VER "$Id: chsh.c,v 1.20 2002/01/05 15:41:43 kloczek Exp $")
|
||||
RCSID (PKG_VER "$Id: chsh.c,v 1.23 2003/06/19 18:11:01 kloczek Exp $")
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
@@ -41,6 +41,7 @@ RCSID (PKG_VER "$Id: chsh.c,v 1.20 2002/01/05 15:41:43 kloczek Exp $")
|
||||
#include "pwio.h"
|
||||
#include "getdef.h"
|
||||
#include "pwauth.h"
|
||||
#include "nscd.h"
|
||||
#ifdef HAVE_SHADOW_H
|
||||
#include <shadow.h>
|
||||
#endif
|
||||
@@ -99,18 +100,12 @@ static void new_fields (void)
|
||||
|
||||
static int restricted_shell (const char *sh)
|
||||
{
|
||||
#if 0
|
||||
char *cp = Basename ((char *) sh);
|
||||
|
||||
return *cp == 'r' || *cp == 'R';
|
||||
#else
|
||||
/*
|
||||
* Shells not listed in /etc/shells are considered to be restricted.
|
||||
* Changed this to avoid confusion with "rc" (the plan9 shell - not
|
||||
* restricted despite the name starting with 'r'). --marekm
|
||||
*/
|
||||
return !check_shell (sh);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -256,10 +251,10 @@ int main (int argc, char **argv)
|
||||
}
|
||||
|
||||
/*
|
||||
* Non-privileged users are optionally authenticated (must enter
|
||||
* the password of the user whose information is being changed)
|
||||
* before any changes can be made. Idea from util-linux
|
||||
* chfn/chsh. --marekm
|
||||
* Non-privileged users are optionally authenticated (must enter
|
||||
* the password of the user whose information is being changed)
|
||||
* before any changes can be made. Idea from util-linux
|
||||
* chfn/chsh. --marekm
|
||||
*/
|
||||
|
||||
if (!amroot && getdef_bool ("CHFN_AUTH"))
|
||||
@@ -406,6 +401,9 @@ int main (int argc, char **argv)
|
||||
}
|
||||
SYSLOG ((LOG_INFO, "changed user `%s' shell to `%s'", user,
|
||||
loginsh));
|
||||
|
||||
nscd_flush_cache ("passwd");
|
||||
|
||||
closelog ();
|
||||
exit (0);
|
||||
}
|
||||
|
||||
241
src/dpasswd.c
241
src/dpasswd.c
@@ -1,241 +0,0 @@
|
||||
/*
|
||||
* Copyright 1990 - 1993, Julianne Frances Haugh
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of Julianne F. Haugh nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY JULIE HAUGH AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL JULIE HAUGH OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID (PKG_VER "$Id: dpasswd.c,v 1.15 2002/01/05 15:41:43 kloczek Exp $")
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <fcntl.h>
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
#include "dialup.h"
|
||||
#define DTMP "/etc/d_passwd.tmp"
|
||||
static int aflg = 0;
|
||||
static int dflg = 0;
|
||||
static char *Prog;
|
||||
|
||||
/* local function prototypes */
|
||||
static void usage (void);
|
||||
|
||||
static void usage (void)
|
||||
{
|
||||
fprintf (stderr, _("Usage: %s [-(a|d)] shell\n"), Prog);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
struct dialup *dial;
|
||||
struct dialup dent;
|
||||
struct stat sb;
|
||||
FILE *fp;
|
||||
char *sh = 0;
|
||||
char *cp;
|
||||
char pass[BUFSIZ];
|
||||
int fd;
|
||||
int found = 0;
|
||||
int opt;
|
||||
|
||||
Prog = Basename (argv[0]);
|
||||
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
OPENLOG (Prog);
|
||||
|
||||
while ((opt = getopt (argc, argv, "a:d:")) != EOF) {
|
||||
switch (opt) {
|
||||
case 'a':
|
||||
aflg++;
|
||||
sh = optarg;
|
||||
break;
|
||||
case 'd':
|
||||
dflg++;
|
||||
sh = optarg;
|
||||
break;
|
||||
default:
|
||||
usage ();
|
||||
}
|
||||
}
|
||||
if (!aflg && !dflg)
|
||||
aflg++;
|
||||
|
||||
if (!sh) {
|
||||
if (optind >= argc)
|
||||
usage ();
|
||||
else
|
||||
sh = argv[optind];
|
||||
}
|
||||
if (aflg + dflg != 1)
|
||||
usage ();
|
||||
|
||||
/*
|
||||
* Add a new shell to the password file, or update an existing
|
||||
* entry. Begin by getting an encrypted password for this shell.
|
||||
*/
|
||||
|
||||
if (aflg) {
|
||||
int tries = 3;
|
||||
|
||||
dent.du_shell = sh;
|
||||
dent.du_passwd = ""; /* XXX warning: const */
|
||||
|
||||
again:
|
||||
if (!(cp = getpass (_("Shell password: "))))
|
||||
exit (1);
|
||||
|
||||
STRFCPY (pass, cp);
|
||||
strzero (cp);
|
||||
|
||||
if (!(cp = getpass (_("re-enter Shell password: "))))
|
||||
exit (1);
|
||||
|
||||
if (strcmp (pass, cp)) {
|
||||
strzero (pass);
|
||||
strzero (cp);
|
||||
fprintf (stderr,
|
||||
_
|
||||
("%s: Passwords do not match, try again.\n"),
|
||||
Prog);
|
||||
|
||||
if (--tries)
|
||||
goto again;
|
||||
|
||||
exit (1);
|
||||
}
|
||||
strzero (cp);
|
||||
dent.du_passwd = pw_encrypt (pass, crypt_make_salt ());
|
||||
strzero (pass);
|
||||
}
|
||||
|
||||
/*
|
||||
* Create the temporary file for the updated dialup password
|
||||
* information to be placed into. Turn it into a (FILE *) for use by
|
||||
* putduent().
|
||||
*/
|
||||
|
||||
if ((fd = open (DTMP, O_CREAT | O_EXCL | O_RDWR, 0600)) < 0) {
|
||||
snprintf (pass, sizeof pass, _("%s: can't create %s"),
|
||||
Prog, DTMP);
|
||||
perror (pass);
|
||||
exit (1);
|
||||
}
|
||||
if (!(fp = fdopen (fd, "r+"))) {
|
||||
snprintf (pass, sizeof pass, _("%s: can't open %s"), Prog,
|
||||
DTMP);
|
||||
perror (pass);
|
||||
unlink (DTMP);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Scan the dialup password file for the named entry, copying out
|
||||
* other entries along the way. Copying stops when a match is found
|
||||
* or the file runs out.
|
||||
*/
|
||||
|
||||
while ((dial = getduent ())) {
|
||||
if (strcmp (dial->du_shell, sh) == 0) {
|
||||
found = 1;
|
||||
break;
|
||||
}
|
||||
if (putduent (dial, fp))
|
||||
goto failure;
|
||||
}
|
||||
|
||||
/*
|
||||
* To delete the entry, just don't copy it. To update the entry,
|
||||
* output the modified version - works with new entries as well.
|
||||
*/
|
||||
|
||||
if (dflg && !found) {
|
||||
fprintf (stderr, _("%s: Shell %s not found.\n"), Prog, sh);
|
||||
goto failure;
|
||||
}
|
||||
if (aflg)
|
||||
if (putduent (&dent, fp))
|
||||
goto failure;
|
||||
|
||||
/*
|
||||
* Now copy out the remaining entries. Flush and close the new file
|
||||
* before doing anything nasty to the existing file.
|
||||
*/
|
||||
|
||||
|
||||
while ((dial = getduent ()))
|
||||
if (putduent (dial, fp))
|
||||
goto failure;
|
||||
|
||||
if (fflush (fp))
|
||||
goto failure;
|
||||
|
||||
fclose (fp);
|
||||
|
||||
/*
|
||||
* If the original file did not exist, we must create a new file
|
||||
* with owner "root" and mode 400. Otherwise we copy the modes from
|
||||
* the existing file to the new file.
|
||||
*
|
||||
* After this is done the new file will replace the old file.
|
||||
*/
|
||||
|
||||
pwd_init ();
|
||||
|
||||
if (!stat (DIALPWD, &sb)) {
|
||||
chown (DTMP, sb.st_uid, sb.st_gid);
|
||||
chmod (DTMP, sb.st_mode);
|
||||
unlink (DIALPWD);
|
||||
} else {
|
||||
chown (DTMP, 0, 0);
|
||||
chmod (DTMP, 0400);
|
||||
}
|
||||
if (!link (DTMP, DIALPWD))
|
||||
unlink (DTMP);
|
||||
|
||||
if (aflg && !found)
|
||||
SYSLOG ((LOG_INFO, "added password for %s", sh));
|
||||
else if (aflg && found)
|
||||
SYSLOG ((LOG_INFO, "changed password for %s", sh));
|
||||
else if (dflg)
|
||||
SYSLOG ((LOG_INFO, "removed password for %s", sh));
|
||||
|
||||
closelog ();
|
||||
sync ();
|
||||
exit (0);
|
||||
|
||||
failure:
|
||||
unlink (DTMP);
|
||||
closelog ();
|
||||
exit (1);
|
||||
}
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID (PKG_VER "$Id: faillog.c,v 1.11 2002/01/05 15:41:43 kloczek Exp $")
|
||||
RCSID (PKG_VER "$Id: faillog.c,v 1.12 2003/04/25 22:32:36 kloczek Exp $")
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
@@ -74,7 +74,7 @@ static void usage (void)
|
||||
{
|
||||
fprintf (stderr,
|
||||
_
|
||||
("usage: %s [-a|-u user] [-m max] [-r] [-t days] [-l locksecs]\n"),
|
||||
("Usage: %s [-a|-u user] [-m max] [-r] [-t days] [-l locksecs]\n"),
|
||||
Prog);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID (PKG_VER "$Id: gpasswd.c,v 1.19 2002/01/05 15:41:43 kloczek Exp $")
|
||||
RCSID (PKG_VER "$Id: gpasswd.c,v 1.21 2003/06/19 18:11:01 kloczek Exp $")
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include <pwd.h>
|
||||
@@ -75,7 +75,7 @@ static int check_list (const char *);
|
||||
|
||||
static void usage (void)
|
||||
{
|
||||
fprintf (stderr, _("usage: %s [-r|-R] group\n"), Prog);
|
||||
fprintf (stderr, _("Usage: %s [-r|-R] group\n"), Prog);
|
||||
fprintf (stderr, _(" %s [-a user] group\n"), Prog);
|
||||
fprintf (stderr, _(" %s [-d user] group\n"), Prog);
|
||||
#ifdef SHADOWGRP
|
||||
@@ -649,4 +649,5 @@ int main (int argc, char **argv)
|
||||
#endif
|
||||
#endif
|
||||
exit (0);
|
||||
/*NOTREACHED*/}
|
||||
/* NOT REACHED */
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID (PKG_VER "$Id: groupadd.c,v 1.22 2002/01/06 14:09:07 kloczek Exp $")
|
||||
RCSID (PKG_VER "$Id: groupadd.c,v 1.27 2004/01/05 01:08:56 kloczek Exp $")
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include <grp.h>
|
||||
@@ -41,6 +41,7 @@ RCSID (PKG_VER "$Id: groupadd.c,v 1.22 2002/01/06 14:09:07 kloczek Exp $")
|
||||
#include "chkname.h"
|
||||
#include "getdef.h"
|
||||
#include "groupio.h"
|
||||
#include "nscd.h"
|
||||
#ifdef SHADOWGRP
|
||||
#include "sgroupio.h"
|
||||
#ifdef USE_PAM
|
||||
@@ -59,7 +60,7 @@ static int is_shadow_grp;
|
||||
#define E_USAGE 2 /* invalid command syntax */
|
||||
#define E_BAD_ARG 3 /* invalid argument to option */
|
||||
#define E_GID_IN_USE 4 /* gid not unique (when -o not used) */
|
||||
#define E_NAME_IN_USE 9 /* group name nut unique */
|
||||
#define E_NAME_IN_USE 9 /* group name not unique */
|
||||
#define E_GRP_UPDATE 10 /* can't update group file */
|
||||
|
||||
static char *group_name;
|
||||
@@ -98,7 +99,7 @@ static void fail_exit (int);
|
||||
|
||||
static void usage (void)
|
||||
{
|
||||
fprintf (stderr, _("usage: groupadd [-g gid [-o]] group\n"));
|
||||
fprintf (stderr, _("Usage: groupadd [-g gid [-o]] [-f] group\n"));
|
||||
exit (E_USAGE);
|
||||
}
|
||||
|
||||
@@ -208,7 +209,7 @@ static void grp_update (void)
|
||||
#endif /* NDBM */
|
||||
#endif /* SHADOWGRP */
|
||||
SYSLOG ((LOG_INFO, "new group: name=%s, gid=%u",
|
||||
group_name, (unsigned int)group_id));
|
||||
group_name, (unsigned int) group_id));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -575,6 +576,7 @@ int main (int argc, char **argv)
|
||||
find_new_gid ();
|
||||
|
||||
grp_update ();
|
||||
nscd_flush_cache ("group");
|
||||
|
||||
close_files ();
|
||||
|
||||
@@ -595,4 +597,5 @@ int main (int argc, char **argv)
|
||||
pam_end (pamh, PAM_SUCCESS);
|
||||
#endif /* USE_PAM */
|
||||
exit (E_SUCCESS);
|
||||
/*NOTREACHED*/}
|
||||
/* NOT REACHED */
|
||||
}
|
||||
|
||||
234
src/groupdel.c
234
src/groupdel.c
@@ -30,31 +30,28 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID(PKG_VER "$Id: groupdel.c,v 1.14 2000/10/09 19:02:20 kloczek Exp $")
|
||||
|
||||
RCSID (PKG_VER "$Id: groupdel.c,v 1.17 2003/06/19 18:11:01 kloczek Exp $")
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include <grp.h>
|
||||
#include <ctype.h>
|
||||
#include <fcntl.h>
|
||||
#include <pwd.h>
|
||||
|
||||
#ifdef USE_PAM
|
||||
#include <security/pam_appl.h>
|
||||
#include <security/pam_misc.h>
|
||||
#include <pwd.h>
|
||||
#endif /* USE_PAM */
|
||||
|
||||
#endif /* USE_PAM */
|
||||
#include "nscd.h"
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
|
||||
static char *group_name;
|
||||
static char *Prog;
|
||||
static int errors;
|
||||
static char *group_name;
|
||||
static char *Prog;
|
||||
static int errors;
|
||||
|
||||
#ifdef NDBM
|
||||
extern int gr_dbm_mode;
|
||||
extern int sg_dbm_mode;
|
||||
extern int gr_dbm_mode;
|
||||
extern int sg_dbm_mode;
|
||||
#endif
|
||||
|
||||
#include "groupio.h"
|
||||
@@ -76,21 +73,20 @@ static int is_shadow_grp;
|
||||
#define E_GRP_UPDATE 10 /* can't update group file */
|
||||
|
||||
/* local function prototypes */
|
||||
static void usage(void);
|
||||
static void grp_update(void);
|
||||
static void close_files(void);
|
||||
static void open_files(void);
|
||||
static void group_busy(gid_t);
|
||||
static void usage (void);
|
||||
static void grp_update (void);
|
||||
static void close_files (void);
|
||||
static void open_files (void);
|
||||
static void group_busy (gid_t);
|
||||
|
||||
/*
|
||||
* usage - display usage message and exit
|
||||
*/
|
||||
|
||||
static void
|
||||
usage(void)
|
||||
static void usage (void)
|
||||
{
|
||||
fprintf(stderr, _("usage: groupdel group\n"));
|
||||
exit(E_USAGE);
|
||||
fprintf (stderr, _("Usage: groupdel group\n"));
|
||||
exit (E_USAGE);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -99,15 +95,15 @@ usage(void)
|
||||
* grp_update() writes the new records to the group files.
|
||||
*/
|
||||
|
||||
static void
|
||||
grp_update(void)
|
||||
static void grp_update (void)
|
||||
{
|
||||
#ifdef NDBM
|
||||
struct group *ogrp;
|
||||
struct group *ogrp;
|
||||
#endif
|
||||
|
||||
if (!gr_remove(group_name)) {
|
||||
fprintf(stderr, _("%s: error removing group entry\n"), Prog);
|
||||
if (!gr_remove (group_name)) {
|
||||
fprintf (stderr, _("%s: error removing group entry\n"),
|
||||
Prog);
|
||||
errors++;
|
||||
}
|
||||
#ifdef NDBM
|
||||
@@ -116,16 +112,17 @@ grp_update(void)
|
||||
* Update the DBM group file
|
||||
*/
|
||||
|
||||
if (gr_dbm_present()) {
|
||||
if (gr_dbm_present ()) {
|
||||
if ((ogrp = getgrnam (group_name)) &&
|
||||
! gr_dbm_remove (ogrp)) {
|
||||
fprintf(stderr, _("%s: error removing group dbm entry\n"),
|
||||
Prog);
|
||||
!gr_dbm_remove (ogrp)) {
|
||||
fprintf (stderr,
|
||||
_("%s: error removing group dbm entry\n"),
|
||||
Prog);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
endgrent ();
|
||||
#endif /* NDBM */
|
||||
#endif /* NDBM */
|
||||
|
||||
#ifdef SHADOWGRP
|
||||
|
||||
@@ -133,9 +130,10 @@ grp_update(void)
|
||||
* Delete the shadow group entries as well.
|
||||
*/
|
||||
|
||||
if (is_shadow_grp && ! sgr_remove (group_name)) {
|
||||
fprintf(stderr, _("%s: error removing shadow group entry\n"),
|
||||
Prog);
|
||||
if (is_shadow_grp && !sgr_remove (group_name)) {
|
||||
fprintf (stderr,
|
||||
_("%s: error removing shadow group entry\n"),
|
||||
Prog);
|
||||
errors++;
|
||||
}
|
||||
#ifdef NDBM
|
||||
@@ -144,18 +142,19 @@ grp_update(void)
|
||||
* Update the DBM shadow group file
|
||||
*/
|
||||
|
||||
if (is_shadow_grp && sg_dbm_present()) {
|
||||
if (! sg_dbm_remove (group_name)) {
|
||||
fprintf(stderr,
|
||||
_("%s: error removing shadow group dbm entry\n"),
|
||||
Prog);
|
||||
if (is_shadow_grp && sg_dbm_present ()) {
|
||||
if (!sg_dbm_remove (group_name)) {
|
||||
fprintf (stderr,
|
||||
_
|
||||
("%s: error removing shadow group dbm entry\n"),
|
||||
Prog);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
endsgent ();
|
||||
#endif /* NDBM */
|
||||
#endif /* SHADOWGRP */
|
||||
SYSLOG((LOG_INFO, "remove group `%s'\n", group_name));
|
||||
#endif /* NDBM */
|
||||
#endif /* SHADOWGRP */
|
||||
SYSLOG ((LOG_INFO, "remove group `%s'\n", group_name));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -166,23 +165,24 @@ grp_update(void)
|
||||
* new group. This causes any modified entries to be written out.
|
||||
*/
|
||||
|
||||
static void
|
||||
close_files(void)
|
||||
static void close_files (void)
|
||||
{
|
||||
if (!gr_close()) {
|
||||
fprintf(stderr, _("%s: cannot rewrite group file\n"), Prog);
|
||||
if (!gr_close ()) {
|
||||
fprintf (stderr, _("%s: cannot rewrite group file\n"),
|
||||
Prog);
|
||||
errors++;
|
||||
}
|
||||
gr_unlock();
|
||||
gr_unlock ();
|
||||
#ifdef SHADOWGRP
|
||||
if (is_shadow_grp && !sgr_close()) {
|
||||
fprintf(stderr, _("%s: cannot rewrite shadow group file\n"),
|
||||
Prog);
|
||||
if (is_shadow_grp && !sgr_close ()) {
|
||||
fprintf (stderr,
|
||||
_("%s: cannot rewrite shadow group file\n"),
|
||||
Prog);
|
||||
errors++;
|
||||
}
|
||||
if (is_shadow_grp)
|
||||
sgr_unlock();
|
||||
#endif /* SHADOWGRP */
|
||||
sgr_unlock ();
|
||||
#endif /* SHADOWGRP */
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -191,29 +191,32 @@ close_files(void)
|
||||
* open_files() opens the two group files.
|
||||
*/
|
||||
|
||||
static void
|
||||
open_files(void)
|
||||
static void open_files (void)
|
||||
{
|
||||
if (!gr_lock()) {
|
||||
fprintf(stderr, _("%s: unable to lock group file\n"), Prog);
|
||||
exit(E_GRP_UPDATE);
|
||||
if (!gr_lock ()) {
|
||||
fprintf (stderr, _("%s: unable to lock group file\n"),
|
||||
Prog);
|
||||
exit (E_GRP_UPDATE);
|
||||
}
|
||||
if (!gr_open(O_RDWR)) {
|
||||
fprintf(stderr, _("%s: unable to open group file\n"), Prog);
|
||||
exit(E_GRP_UPDATE);
|
||||
if (!gr_open (O_RDWR)) {
|
||||
fprintf (stderr, _("%s: unable to open group file\n"),
|
||||
Prog);
|
||||
exit (E_GRP_UPDATE);
|
||||
}
|
||||
#ifdef SHADOWGRP
|
||||
if (is_shadow_grp && !sgr_lock()) {
|
||||
fprintf(stderr, _("%s: unable to lock shadow group file\n"),
|
||||
Prog);
|
||||
exit(E_GRP_UPDATE);
|
||||
if (is_shadow_grp && !sgr_lock ()) {
|
||||
fprintf (stderr,
|
||||
_("%s: unable to lock shadow group file\n"),
|
||||
Prog);
|
||||
exit (E_GRP_UPDATE);
|
||||
}
|
||||
if (is_shadow_grp && !sgr_open(O_RDWR)) {
|
||||
fprintf(stderr, _("%s: unable to open shadow group file\n"),
|
||||
Prog);
|
||||
exit(E_GRP_UPDATE);
|
||||
if (is_shadow_grp && !sgr_open (O_RDWR)) {
|
||||
fprintf (stderr,
|
||||
_("%s: unable to open shadow group file\n"),
|
||||
Prog);
|
||||
exit (E_GRP_UPDATE);
|
||||
}
|
||||
#endif /* SHADOWGRP */
|
||||
#endif /* SHADOWGRP */
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -224,10 +227,9 @@ open_files(void)
|
||||
* the group.
|
||||
*/
|
||||
|
||||
static void
|
||||
group_busy(gid_t gid)
|
||||
static void group_busy (gid_t gid)
|
||||
{
|
||||
struct passwd *pwd;
|
||||
struct passwd *pwd;
|
||||
|
||||
/*
|
||||
* Nice slow linear search.
|
||||
@@ -235,8 +237,7 @@ group_busy(gid_t gid)
|
||||
|
||||
setpwent ();
|
||||
|
||||
while ((pwd = getpwent ()) && pwd->pw_gid != gid)
|
||||
;
|
||||
while ((pwd = getpwent ()) && pwd->pw_gid != gid);
|
||||
|
||||
endpwent ();
|
||||
|
||||
@@ -251,16 +252,17 @@ group_busy(gid_t gid)
|
||||
* Can't remove the group.
|
||||
*/
|
||||
|
||||
fprintf(stderr, _("%s: cannot remove user's primary group.\n"), Prog);
|
||||
exit(E_GROUP_BUSY);
|
||||
fprintf (stderr, _("%s: cannot remove user's primary group.\n"),
|
||||
Prog);
|
||||
exit (E_GROUP_BUSY);
|
||||
}
|
||||
|
||||
#ifdef USE_PAM
|
||||
static struct pam_conv conv = {
|
||||
misc_conv,
|
||||
NULL
|
||||
misc_conv,
|
||||
NULL
|
||||
};
|
||||
#endif /* USE_PAM */
|
||||
#endif /* USE_PAM */
|
||||
|
||||
/*
|
||||
* main - groupdel command
|
||||
@@ -272,10 +274,10 @@ static struct pam_conv conv = {
|
||||
* The named group will be deleted.
|
||||
*/
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
struct group *grp;
|
||||
|
||||
#ifdef USE_PAM
|
||||
pam_handle_t *pamh = NULL;
|
||||
struct passwd *pampw;
|
||||
@@ -286,53 +288,55 @@ main(int argc, char **argv)
|
||||
* Get my name so that I can use it to report errors.
|
||||
*/
|
||||
|
||||
Prog = Basename(argv[0]);
|
||||
Prog = Basename (argv[0]);
|
||||
|
||||
setlocale(LC_ALL, "");
|
||||
bindtextdomain(PACKAGE, LOCALEDIR);
|
||||
textdomain(PACKAGE);
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
#ifdef USE_PAM
|
||||
retval = PAM_SUCCESS;
|
||||
|
||||
pampw = getpwuid(getuid());
|
||||
pampw = getpwuid (getuid ());
|
||||
if (pampw == NULL) {
|
||||
retval = PAM_USER_UNKNOWN;
|
||||
}
|
||||
|
||||
if (retval == PAM_SUCCESS) {
|
||||
retval = pam_start("shadow", pampw->pw_name, &conv, &pamh);
|
||||
retval =
|
||||
pam_start ("shadow", pampw->pw_name, &conv, &pamh);
|
||||
}
|
||||
|
||||
if (retval == PAM_SUCCESS) {
|
||||
retval = pam_authenticate(pamh, 0);
|
||||
retval = pam_authenticate (pamh, 0);
|
||||
if (retval != PAM_SUCCESS) {
|
||||
pam_end(pamh, retval);
|
||||
pam_end (pamh, retval);
|
||||
}
|
||||
}
|
||||
|
||||
if (retval == PAM_SUCCESS) {
|
||||
retval = pam_acct_mgmt(pamh, 0);
|
||||
retval = pam_acct_mgmt (pamh, 0);
|
||||
if (retval != PAM_SUCCESS) {
|
||||
pam_end(pamh, retval);
|
||||
pam_end (pamh, retval);
|
||||
}
|
||||
}
|
||||
|
||||
if (retval != PAM_SUCCESS) {
|
||||
fprintf (stderr, _("%s: PAM authentication failed\n"), Prog);
|
||||
fprintf (stderr, _("%s: PAM authentication failed\n"),
|
||||
Prog);
|
||||
exit (1);
|
||||
}
|
||||
#endif /* USE_PAM */
|
||||
#endif /* USE_PAM */
|
||||
|
||||
if (argc != 2)
|
||||
usage ();
|
||||
|
||||
group_name = argv[1];
|
||||
|
||||
OPENLOG(Prog);
|
||||
OPENLOG (Prog);
|
||||
|
||||
#ifdef SHADOWGRP
|
||||
is_shadow_grp = sgr_file_present();
|
||||
is_shadow_grp = sgr_file_present ();
|
||||
#endif
|
||||
|
||||
/*
|
||||
@@ -344,17 +348,17 @@ main(int argc, char **argv)
|
||||
gr_dbm_mode = O_RDWR;
|
||||
#ifdef SHADOWGRP
|
||||
sg_dbm_mode = O_RDWR;
|
||||
#endif /* SHADOWGRP */
|
||||
#endif /* NDBM */
|
||||
#endif /* SHADOWGRP */
|
||||
#endif /* NDBM */
|
||||
|
||||
/*
|
||||
* Start with a quick check to see if the group exists.
|
||||
*/
|
||||
|
||||
if (! (grp = getgrnam(group_name))) {
|
||||
fprintf(stderr, _("%s: group %s does not exist\n"),
|
||||
Prog, group_name);
|
||||
exit(E_NOTFOUND);
|
||||
if (!(grp = getgrnam (group_name))) {
|
||||
fprintf (stderr, _("%s: group %s does not exist\n"),
|
||||
Prog, group_name);
|
||||
exit (E_NOTFOUND);
|
||||
}
|
||||
#ifdef USE_NIS
|
||||
|
||||
@@ -363,19 +367,18 @@ main(int argc, char **argv)
|
||||
*/
|
||||
|
||||
if (__isgrNIS ()) {
|
||||
char *nis_domain;
|
||||
char *nis_master;
|
||||
char *nis_domain;
|
||||
char *nis_master;
|
||||
|
||||
fprintf(stderr, _("%s: group %s is a NIS group\n"),
|
||||
Prog, group_name);
|
||||
fprintf (stderr, _("%s: group %s is a NIS group\n"),
|
||||
Prog, group_name);
|
||||
|
||||
if (! yp_get_default_domain (&nis_domain) &&
|
||||
! yp_master (nis_domain, "group.byname",
|
||||
&nis_master)) {
|
||||
if (!yp_get_default_domain (&nis_domain) &&
|
||||
!yp_master (nis_domain, "group.byname", &nis_master)) {
|
||||
fprintf (stderr, _("%s: %s is the NIS master\n"),
|
||||
Prog, nis_master);
|
||||
Prog, nis_master);
|
||||
}
|
||||
exit(E_NOTFOUND);
|
||||
exit (E_NOTFOUND);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -394,14 +397,15 @@ main(int argc, char **argv)
|
||||
open_files ();
|
||||
|
||||
grp_update ();
|
||||
nscd_flush_cache ("group");
|
||||
|
||||
close_files ();
|
||||
|
||||
#ifdef USE_PAM
|
||||
if (retval == PAM_SUCCESS) {
|
||||
retval = pam_chauthtok(pamh, 0);
|
||||
retval = pam_chauthtok (pamh, 0);
|
||||
if (retval != PAM_SUCCESS) {
|
||||
pam_end(pamh, retval);
|
||||
pam_end (pamh, retval);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -411,8 +415,8 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (retval == PAM_SUCCESS)
|
||||
pam_end(pamh, PAM_SUCCESS);
|
||||
#endif /* USE_PAM */
|
||||
exit(errors == 0 ? E_SUCCESS : E_GRP_UPDATE);
|
||||
/*NOTREACHED*/
|
||||
pam_end (pamh, PAM_SUCCESS);
|
||||
#endif /* USE_PAM */
|
||||
exit (errors == 0 ? E_SUCCESS : E_GRP_UPDATE);
|
||||
/* NOT REACHED */
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID (PKG_VER "$Id: groupmod.c,v 1.19 2002/01/05 15:41:43 kloczek Exp $")
|
||||
RCSID (PKG_VER "$Id: groupmod.c,v 1.22 2003/06/19 18:11:01 kloczek Exp $")
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include <grp.h>
|
||||
@@ -45,6 +45,7 @@ RCSID (PKG_VER "$Id: groupmod.c,v 1.19 2002/01/05 15:41:43 kloczek Exp $")
|
||||
#include "chkname.h"
|
||||
#include "defines.h"
|
||||
#include "groupio.h"
|
||||
#include "nscd.h"
|
||||
#ifdef SHADOWGRP
|
||||
#include "sgroupio.h"
|
||||
static int is_shadow_grp;
|
||||
@@ -100,7 +101,7 @@ static void open_files (void);
|
||||
static void usage (void)
|
||||
{
|
||||
fprintf (stderr,
|
||||
_("usage: groupmod [-g gid [-o]] [-n name] group\n"));
|
||||
_("Usage: groupmod [-g gid [-o]] [-n name] group\n"));
|
||||
exit (E_USAGE);
|
||||
}
|
||||
|
||||
@@ -589,6 +590,7 @@ int main (int argc, char **argv)
|
||||
open_files ();
|
||||
|
||||
grp_update ();
|
||||
nscd_flush_cache ("group");
|
||||
|
||||
close_files ();
|
||||
|
||||
@@ -609,4 +611,5 @@ int main (int argc, char **argv)
|
||||
pam_end (pamh, PAM_SUCCESS);
|
||||
#endif /* USE_PAM */
|
||||
exit (E_SUCCESS);
|
||||
/*NOTREACHED*/}
|
||||
/* NOT REACHED */
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "sgroupio.h"
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID (PKG_VER "$Id: grpconv.c,v 1.12 2002/01/05 15:41:43 kloczek Exp $")
|
||||
RCSID (PKG_VER "$Id: grpconv.c,v 1.15 2003/06/19 18:11:01 kloczek Exp $")
|
||||
|
||||
static int group_locked = 0;
|
||||
static int gshadow_locked = 0;
|
||||
@@ -105,11 +105,6 @@ int main (int argc, char **argv)
|
||||
while ((gr = gr_next ())) {
|
||||
sg = sgr_locate (gr->gr_name);
|
||||
if (sg) {
|
||||
#if 0 /* because of sg_mem, but see below */
|
||||
if (strcmp (gr->gr_passwd, SHADOW_PASSWD_STRING) ==
|
||||
0)
|
||||
continue;
|
||||
#endif
|
||||
/* update existing shadow group entry */
|
||||
sgent = *sg;
|
||||
if (strcmp (gr->gr_passwd, SHADOW_PASSWD_STRING) !=
|
||||
@@ -167,12 +162,8 @@ int main (int argc, char **argv)
|
||||
#else /* !SHADOWGRP */
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
fprintf (stderr,
|
||||
_("%s: not configured for shadow group support.\n"),
|
||||
"%s: not configured for shadow group support.\n",
|
||||
argv[0]);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID (PKG_VER "$Id: grpunconv.c,v 1.11 2002/01/05 15:41:43 kloczek Exp $")
|
||||
RCSID (PKG_VER "$Id: grpunconv.c,v 1.13 2003/06/19 18:11:01 kloczek Exp $")
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -119,12 +119,8 @@ int main (int argc, char **argv)
|
||||
#else /* !SHADOWGRP */
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
fprintf (stderr,
|
||||
_("%s: not configured for shadow group support.\n"),
|
||||
"%s: not configured for shadow group support.\n",
|
||||
argv[0]);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
9
src/id.c
9
src/id.c
@@ -38,7 +38,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID (PKG_VER "$Id: id.c,v 1.11 2002/01/31 09:23:57 kloczek Exp $")
|
||||
RCSID (PKG_VER "$Id: id.c,v 1.13 2003/06/19 18:11:01 kloczek Exp $")
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include <grp.h>
|
||||
@@ -50,9 +50,9 @@ static void usage (void);
|
||||
static void usage (void)
|
||||
{
|
||||
#ifdef HAVE_GETGROUPS
|
||||
fprintf (stderr, _("usage: id [-a]\n"));
|
||||
fprintf (stderr, _("Usage: id [-a]\n"));
|
||||
#else
|
||||
fprintf (stderr, _("usage: id\n"));
|
||||
fprintf (stderr, _("Usage: id\n"));
|
||||
#endif
|
||||
exit (1);
|
||||
}
|
||||
@@ -187,4 +187,5 @@ static void usage (void)
|
||||
|
||||
putchar ('\n');
|
||||
exit (0);
|
||||
/*NOTREACHED*/}
|
||||
/* NOT REACHED */
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID (PKG_VER "$Id: lastlog.c,v 1.11 2002/01/05 15:41:43 kloczek Exp $")
|
||||
RCSID (PKG_VER "$Id: lastlog.c,v 1.13 2003/12/17 12:52:25 kloczek Exp $")
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
@@ -107,13 +107,13 @@ int main (int argc, char **argv)
|
||||
case 'h':
|
||||
fprintf (stdout,
|
||||
_
|
||||
("Usage: %s [<-u|--login> login-name] [<-t|--time> days] [<-h|--help>]\n"),
|
||||
("Usage: %s [{-u|--login} login] [{-t|--time} days] [{-h|--help}]\n"),
|
||||
argv[0]);
|
||||
exit (0);
|
||||
default:
|
||||
fprintf (stdout,
|
||||
_
|
||||
("Usage: %s [<-u|--login> login-name] [<-t|--time> days] [<-h|--help>]\n"),
|
||||
("Usage: %s [{-u|--login} login] [{-t|--time} days] [{-h|--help}]\n"),
|
||||
argv[0]);
|
||||
exit (1);
|
||||
}
|
||||
@@ -167,7 +167,7 @@ static void print_one (const struct passwd *pw)
|
||||
static int once;
|
||||
char *cp;
|
||||
struct tm *tm;
|
||||
|
||||
time_t ll_time;
|
||||
#ifdef HAVE_STRFTIME
|
||||
char ptime[80];
|
||||
#endif
|
||||
@@ -184,7 +184,8 @@ static void print_one (const struct passwd *pw)
|
||||
#endif
|
||||
once++;
|
||||
}
|
||||
tm = localtime (&lastlog.ll_time);
|
||||
ll_time = lastlog.ll_time;
|
||||
tm = localtime (&ll_time);
|
||||
#ifdef HAVE_STRFTIME
|
||||
strftime (ptime, sizeof (ptime), "%a %b %e %H:%M:%S %z %Y", tm);
|
||||
cp = ptime;
|
||||
|
||||
112
src/login.c
112
src/login.c
@@ -30,7 +30,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID (PKG_VER "$Id: login.c,v 1.26 2002/03/08 04:30:28 kloczek Exp $")
|
||||
RCSID (PKG_VER "$Id: login.c,v 1.35 2003/12/17 12:52:25 kloczek Exp $")
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
#include <sys/stat.h>
|
||||
@@ -38,11 +38,6 @@ RCSID (PKG_VER "$Id: login.c,v 1.26 2002/03/08 04:30:28 kloczek Exp $")
|
||||
#include <errno.h>
|
||||
#include <pwd.h>
|
||||
#include <grp.h>
|
||||
#if HAVE_UTMPX_H
|
||||
#include <utmpx.h>
|
||||
#else
|
||||
#include <utmp.h>
|
||||
#endif
|
||||
#include <signal.h>
|
||||
#if HAVE_LASTLOG_H
|
||||
#include <lastlog.h>
|
||||
@@ -53,11 +48,6 @@ RCSID (PKG_VER "$Id: login.c,v 1.26 2002/03/08 04:30:28 kloczek Exp $")
|
||||
#include "failure.h"
|
||||
#include "pwauth.h"
|
||||
#include "getdef.h"
|
||||
#include "dialchk.h"
|
||||
#ifdef SVR4_SI86_EUA
|
||||
#include <sys/proc.h>
|
||||
#include <sys/sysi86.h>
|
||||
#endif
|
||||
#ifdef RADIUS
|
||||
/*
|
||||
* Support for RADIUS authentication based on a hacked util-linux login
|
||||
@@ -182,7 +172,7 @@ static RETSIGTYPE alarm_handler (int);
|
||||
|
||||
static void usage (void)
|
||||
{
|
||||
fprintf (stderr, _("usage: %s [-p] [name]\n"), Prog);
|
||||
fprintf (stderr, _("Usage: %s [-p] [name]\n"), Prog);
|
||||
if (!amroot)
|
||||
exit (1);
|
||||
fprintf (stderr, _(" %s [-p] [-h host] [-f name]\n"), Prog);
|
||||
@@ -232,15 +222,10 @@ static void setup_tty (void)
|
||||
termio.c_iflag &= ~IXANY;
|
||||
termio.c_oflag |= (XTABS | OPOST | ONLCR);
|
||||
#endif
|
||||
#if 0
|
||||
termio.c_cc[VERASE] = getdef_num ("ERASECHAR", '\b');
|
||||
termio.c_cc[VKILL] = getdef_num ("KILLCHAR", '\025');
|
||||
#else
|
||||
/* leave these values unchanged if not specified in login.defs */
|
||||
termio.c_cc[VERASE] =
|
||||
getdef_num ("ERASECHAR", termio.c_cc[VERASE]);
|
||||
termio.c_cc[VKILL] = getdef_num ("KILLCHAR", termio.c_cc[VKILL]);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* ttymon invocation prefers this, but these settings won't come into
|
||||
@@ -636,36 +621,10 @@ int main (int argc, char **argv)
|
||||
if (rflg || fflg)
|
||||
usage ();
|
||||
|
||||
#ifdef SVR4
|
||||
/*
|
||||
* The "-h" option can't be used with a command-line username,
|
||||
* because telnetd invokes us as: login -h host TERM=...
|
||||
*/
|
||||
|
||||
if (!hflg)
|
||||
#endif
|
||||
{
|
||||
STRFCPY (username, argv[optind]);
|
||||
strzero (argv[optind]);
|
||||
++optind;
|
||||
}
|
||||
STRFCPY (username, argv[optind]);
|
||||
strzero (argv[optind]);
|
||||
++optind;
|
||||
}
|
||||
#ifdef SVR4
|
||||
/*
|
||||
* check whether ttymon has done the prompt for us already
|
||||
*/
|
||||
|
||||
{
|
||||
char *ttymon_prompt;
|
||||
|
||||
if ((ttymon_prompt = getenv ("TTYPROMPT")) != NULL
|
||||
&& (*ttymon_prompt != 0)) {
|
||||
/* read name, without prompt */
|
||||
login_prompt ((char *) 0, username,
|
||||
sizeof username);
|
||||
}
|
||||
}
|
||||
#endif /* SVR4 */
|
||||
if (optind < argc) /* now set command line variables */
|
||||
set_env (argc - optind, &argv[optind]);
|
||||
|
||||
@@ -911,19 +870,6 @@ int main (int argc, char **argv)
|
||||
if (preauth_flag)
|
||||
goto auth_ok;
|
||||
|
||||
/*
|
||||
* No password prompt if logging in from listed ttys (local
|
||||
* console). Passwords don't help much if you have physical
|
||||
* access to the hardware anyway... Suggested by Pavel
|
||||
* Machek <pavel@bug.ucw.cz>.
|
||||
* NOTE: password still required for root logins!
|
||||
*/
|
||||
if (pwd && (pwent.pw_uid != 0)
|
||||
&& is_listed ("NO_PASSWORD_CONSOLE", tty, 0)) {
|
||||
temp_pw[0] = '\0';
|
||||
pwent.pw_passwd = temp_pw;
|
||||
}
|
||||
|
||||
if (pw_auth
|
||||
(pwent.pw_passwd, username, reason,
|
||||
(char *) 0) == 0)
|
||||
@@ -974,18 +920,6 @@ int main (int argc, char **argv)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (getdef_bool ("DIALUPS_CHECK_ENAB")) {
|
||||
alarm (30);
|
||||
|
||||
if (!dialcheck (tty, pwent.pw_shell[0] ?
|
||||
pwent.pw_shell : "/bin/sh")) {
|
||||
SYSLOG ((LOG_WARN,
|
||||
"invalid dialup password for `%s' on `%s'",
|
||||
username, tty));
|
||||
failed = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!failed && pwent.pw_name && pwent.pw_uid == 0
|
||||
&& !is_console) {
|
||||
SYSLOG ((LOG_CRIT, "ILLEGAL ROOT LOGIN %s",
|
||||
@@ -1020,10 +954,18 @@ int main (int argc, char **argv)
|
||||
|
||||
#if HAVE_UTMPX_H
|
||||
failent = utxent;
|
||||
gettimeofday (&(failent.ut_tv), NULL);
|
||||
if (sizeof (failent.ut_tv) == sizeof (struct timeval))
|
||||
gettimeofday ((struct timeval *) &failent.ut_tv, NULL);
|
||||
else
|
||||
{
|
||||
struct timeval tv;
|
||||
gettimeofday (&tv, NULL);
|
||||
failent.ut_tv.tv_sec = tv.tv_sec;
|
||||
failent.ut_tv.tv_usec = tv.tv_usec;
|
||||
}
|
||||
#else
|
||||
failent = utent;
|
||||
time (&failent.ut_time);
|
||||
failent.ut_time = time (NULL);
|
||||
#endif
|
||||
if (pwd) {
|
||||
failent_user = pwent.pw_name;
|
||||
@@ -1124,10 +1066,6 @@ int main (int argc, char **argv)
|
||||
hostname);
|
||||
#endif
|
||||
|
||||
#ifdef SVR4_SI86_EUA
|
||||
sysi86 (SI86LIMUSER, EUA_ADD_USER); /* how do we test for fail? */
|
||||
#endif
|
||||
|
||||
#ifndef USE_PAM /* PAM handles this as well */
|
||||
/*
|
||||
* Have to do this while we still have root privileges, otherwise we
|
||||
@@ -1144,16 +1082,6 @@ int main (int argc, char **argv)
|
||||
pwent = *pwd;
|
||||
}
|
||||
}
|
||||
#else
|
||||
#ifdef ATT_AGE
|
||||
if (pwent.pw_age && pwent.pw_age[0]) {
|
||||
if (expire (&pwent)) {
|
||||
pwd = getpwnam (username);
|
||||
if (pwd)
|
||||
pwent = *pwd;
|
||||
}
|
||||
}
|
||||
#endif /* ATT_AGE */
|
||||
#endif /* SHADOWPWD */
|
||||
|
||||
#ifdef RADIUS
|
||||
@@ -1271,18 +1199,19 @@ int main (int argc, char **argv)
|
||||
}
|
||||
if (getdef_bool ("LASTLOG_ENAB")
|
||||
&& lastlog.ll_time != 0) {
|
||||
time_t ll_time = lastlog.ll_time;
|
||||
#ifdef HAVE_STRFTIME
|
||||
strftime (ptime, sizeof (ptime),
|
||||
"%a %b %e %H:%M:%S %z %Y",
|
||||
localtime (&lastlog.ll_time));
|
||||
localtime (&ll_time));
|
||||
printf (_("Last login: %s on %s"),
|
||||
ptime, lastlog.ll_line);
|
||||
#else
|
||||
printf (_("Last login: %.19s on %s"),
|
||||
ctime (&lastlog.ll_time),
|
||||
ctime (&ll_time),
|
||||
lastlog.ll_line);
|
||||
#endif
|
||||
#ifdef HAVE_LL_HOST /* SVR4 || __linux__ || SUN4 */
|
||||
#ifdef HAVE_LL_HOST /* __linux__ || SUN4 */
|
||||
if (lastlog.ll_host[0])
|
||||
printf (_(" from %.*s"),
|
||||
(int) sizeof lastlog.
|
||||
@@ -1370,5 +1299,6 @@ int main (int argc, char **argv)
|
||||
shell (tmp, pwent.pw_shell); /* fake shell */
|
||||
}
|
||||
shell (pwent.pw_shell, (char *) 0); /* exec the shell finally. */
|
||||
/*NOTREACHED*/ return 0;
|
||||
/* NOT REACHED */
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -30,21 +30,14 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID (PKG_VER "$Id: logoutd.c,v 1.18 2002/01/05 15:41:43 kloczek Exp $")
|
||||
RCSID (PKG_VER "$Id: logoutd.c,v 1.23 2003/06/19 18:11:01 kloczek Exp $")
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <utmp.h>
|
||||
#include <fcntl.h>
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
#ifdef SVR4
|
||||
#include <libgen.h>
|
||||
#endif
|
||||
#ifdef SVR4
|
||||
#define signal sigset
|
||||
#endif
|
||||
static char *Prog;
|
||||
|
||||
#ifndef DEFAULT_HUP_MESG
|
||||
@@ -55,14 +48,20 @@ static char *Prog;
|
||||
#define HUP_MESG_FILE "/etc/logoutd.mesg"
|
||||
#endif
|
||||
|
||||
/* local function prototypes */
|
||||
#if HAVE_UTMPX_H
|
||||
static int check_login (const struct utmpx *);
|
||||
#else
|
||||
static int check_login (const struct utmp *);
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
* check_login - check if user (struct utmp) allowed to stay logged in
|
||||
* check_login - check if user (struct utmpx/utmp) allowed to stay logged in
|
||||
*/
|
||||
#if HAVE_UTMPX_H
|
||||
static int check_login (const struct utmpx *ut)
|
||||
#else
|
||||
static int check_login (const struct utmp *ut)
|
||||
#endif
|
||||
{
|
||||
char user[sizeof (ut->ut_user) + 1];
|
||||
time_t now;
|
||||
@@ -80,17 +79,6 @@ static int check_login (const struct utmp *ut)
|
||||
*/
|
||||
if (!isttytime (user, ut->ut_line, now))
|
||||
return 0;
|
||||
#if 0
|
||||
/*
|
||||
* Check for how long they are allowed to stay logged in.
|
||||
* XXX - not implemented yet. Need to add a new field to
|
||||
* /etc/porttime (login time limit in minutes, or no limit,
|
||||
* based on username, tty, and time of login).
|
||||
*/
|
||||
if (now - ut->ut_time >
|
||||
get_time_limit (user, ut->ut_line, ut->ut_time))
|
||||
return 0;
|
||||
#endif
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -139,7 +127,7 @@ static void send_mesg_to_tty (int tty_fd)
|
||||
*
|
||||
* logoutd is started at system boot time and enforces the login
|
||||
* time and port restrictions specified in /etc/porttime. The
|
||||
* utmp file is periodically scanned and offending users are logged
|
||||
* utmpx/utmp file is periodically scanned and offending users are logged
|
||||
* off from the system.
|
||||
*/
|
||||
|
||||
@@ -148,7 +136,12 @@ int main (int argc, char **argv)
|
||||
int i;
|
||||
int status;
|
||||
pid_t pid;
|
||||
|
||||
#if HAVE_UTMPX_H
|
||||
struct utmpx *ut;
|
||||
#else
|
||||
struct utmp *ut;
|
||||
#endif
|
||||
char user[sizeof (ut->ut_user) + 1]; /* terminating NUL */
|
||||
char tty_name[sizeof (ut->ut_line) + 6]; /* /dev/ + NUL */
|
||||
int tty_fd;
|
||||
@@ -194,26 +187,34 @@ int main (int argc, char **argv)
|
||||
OPENLOG (Prog);
|
||||
|
||||
/*
|
||||
* Scan the UTMP file once per minute looking for users that
|
||||
* Scan the utmpx/utmp file once per minute looking for users that
|
||||
* are not supposed to still be logged in.
|
||||
*/
|
||||
|
||||
while (1) {
|
||||
|
||||
/*
|
||||
* Attempt to re-open the utmp file. The file is only
|
||||
* Attempt to re-open the utmpx/utmp file. The file is only
|
||||
* open while it is being used.
|
||||
*/
|
||||
|
||||
#if HAVE_UTMPX_H
|
||||
setutxent ();
|
||||
#else
|
||||
setutent ();
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Read all of the entries in the utmp file. The entries
|
||||
* Read all of the entries in the utmpx/utmp file. The entries
|
||||
* for login sessions will be checked to see if the user
|
||||
* is permitted to be signed on at this time.
|
||||
*/
|
||||
|
||||
#if HAVE_UTMPX_H
|
||||
while ((ut = getutxent ())) {
|
||||
#else
|
||||
while ((ut = getutent ())) {
|
||||
#endif
|
||||
#ifdef USER_PROCESS
|
||||
if (ut->ut_type != USER_PROCESS)
|
||||
continue;
|
||||
@@ -289,7 +290,11 @@ int main (int argc, char **argv)
|
||||
exit (0);
|
||||
}
|
||||
|
||||
#if HAVE_UTMPX_H
|
||||
endutxent ();
|
||||
#else
|
||||
endutent ();
|
||||
#endif
|
||||
|
||||
#ifndef DEBUG
|
||||
sleep (60);
|
||||
@@ -300,5 +305,6 @@ int main (int argc, char **argv)
|
||||
|
||||
while (wait (&status) != -1);
|
||||
}
|
||||
return 1; /* not reached */
|
||||
return 1;
|
||||
/* NOT REACHED */
|
||||
}
|
||||
|
||||
31
src/newgrp.c
31
src/newgrp.c
@@ -30,7 +30,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID (PKG_VER "$Id: newgrp.c,v 1.21 2002/01/06 15:00:07 kloczek Exp $")
|
||||
RCSID (PKG_VER "$Id: newgrp.c,v 1.26 2003/07/29 06:16:04 kloczek Exp $")
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#include <grp.h>
|
||||
@@ -58,9 +58,9 @@ static void usage (void);
|
||||
static void usage (void)
|
||||
{
|
||||
if (is_newgrp)
|
||||
fprintf (stderr, _("usage: newgrp [-] [group]\n"));
|
||||
fprintf (stderr, _("Usage: newgrp [-] [group]\n"));
|
||||
else
|
||||
fprintf (stderr, _("usage: sg group [[-c] command]\n"));
|
||||
fprintf (stderr, _("Usage: sg group [[-c] command]\n"));
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -89,11 +89,6 @@ int main (int argc, char **argv)
|
||||
struct sgrp *sgrp;
|
||||
#endif
|
||||
|
||||
#if ENABLE_NLS
|
||||
/* XXX - remove when gettext is safe to use in setuid programs */
|
||||
sanitize_env ();
|
||||
#endif
|
||||
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
@@ -152,10 +147,10 @@ int main (int argc, char **argv)
|
||||
* the login group ID of the current user.
|
||||
*
|
||||
* The valid syntax are
|
||||
* newgrp [ - ] [ groupid ]
|
||||
* newgrp [ -l ] [ groupid ]
|
||||
* sg [ - ]
|
||||
* sg [ - ] groupid [ command ]
|
||||
* newgrp [-] [groupid]
|
||||
* newgrp [-l] [groupid]
|
||||
* sg [-]
|
||||
* sg [-] groupid [[-c command]
|
||||
*/
|
||||
|
||||
if (argc > 0
|
||||
@@ -398,6 +393,7 @@ int main (int argc, char **argv)
|
||||
SYSLOG ((LOG_INFO,
|
||||
"user `%s' (login `%s' on %s) switched to group `%s'",
|
||||
name, loginname, tty, group));
|
||||
#ifdef USE_PAM
|
||||
if (getdef_bool ("CLOSE_SESSIONS")) {
|
||||
/*
|
||||
* We want to fork and exec the new shell in the child, leaving the
|
||||
@@ -450,6 +446,7 @@ int main (int argc, char **argv)
|
||||
signal (SIGTTIN, SIG_DFL);
|
||||
signal (SIGTTOU, SIG_DFL);
|
||||
}
|
||||
#endif /* USE_PAM */
|
||||
}
|
||||
#endif /* USE_SYSLOG */
|
||||
|
||||
@@ -574,20 +571,14 @@ int main (int argc, char **argv)
|
||||
addenv (*envp++, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* Sanitize_env() removes $HOME from the environment (maybe it
|
||||
* shouldn't - please tell me if you are sure that $HOME can't cause
|
||||
* security problems) - add it from user's passwd entry.
|
||||
*/
|
||||
addenv ("HOME", pwd->pw_dir);
|
||||
|
||||
/*
|
||||
* Exec the login shell and go away. We are trying to get back to
|
||||
* the previous environment which should be the user's login shell.
|
||||
*/
|
||||
|
||||
shell (prog, initflag ? (char *) 0 : cp);
|
||||
/*NOTREACHED*/ failure:
|
||||
/* NOTREACHED */
|
||||
failure:
|
||||
|
||||
/*
|
||||
* The previous code, when run as newgrp, re-exec'ed the shell in
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID (PKG_VER "$Id: newusers.c,v 1.15 2002/01/05 15:41:43 kloczek Exp $")
|
||||
RCSID (PKG_VER "$Id: newusers.c,v 1.18 2003/12/17 01:33:29 kloczek Exp $")
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include "prototypes.h"
|
||||
@@ -219,15 +219,6 @@ add_user (const char *name, const char *uid, uid_t * nuid, gid_t gid)
|
||||
|
||||
pwent.pw_name = xstrdup (name);
|
||||
pwent.pw_passwd = "x"; /* XXX warning: const */
|
||||
#ifdef ATT_AGE
|
||||
pwent.pw_age = "";
|
||||
#endif
|
||||
#ifdef ATT_COMMENT
|
||||
pwent.pw_comment = "";
|
||||
#endif
|
||||
#ifdef BSD_QUOTA
|
||||
pwent.pw_quota = 0;
|
||||
#endif
|
||||
pwent.pw_uid = i;
|
||||
pwent.pw_gid = gid;
|
||||
pwent.pw_gecos = ""; /* XXX warning: const */
|
||||
@@ -241,16 +232,6 @@ add_user (const char *name, const char *uid, uid_t * nuid, gid_t gid)
|
||||
static void update_passwd (struct passwd *pwd, const char *passwd)
|
||||
{
|
||||
pwd->pw_passwd = pw_encrypt (passwd, crypt_make_salt ());
|
||||
#ifdef ATT_AGE
|
||||
if (strlen (pwd->pw_age) == 4) {
|
||||
static char newage[5];
|
||||
extern char *l64a ();
|
||||
|
||||
strcpy (newage, pwd->pw_age);
|
||||
strcpy (newage + 2, l64a (time ((time_t *) 0) / WEEK));
|
||||
pwd->pw_age = newage;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -634,4 +615,5 @@ int main (int argc, char **argv)
|
||||
#endif /* USE_PAM */
|
||||
|
||||
exit (0);
|
||||
/*NOTREACHED*/}
|
||||
/* NOT REACHED */
|
||||
}
|
||||
|
||||
304
src/passwd.c
304
src/passwd.c
@@ -30,7 +30,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID (PKG_VER "$Id: passwd.c,v 1.24 2002/01/05 15:41:43 kloczek Exp $")
|
||||
RCSID (PKG_VER "$Id: passwd.c,v 1.30 2003/12/17 09:43:30 kloczek Exp $")
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
#include <sys/types.h>
|
||||
@@ -50,14 +50,11 @@ RCSID (PKG_VER "$Id: passwd.c,v 1.24 2002/01/05 15:41:43 kloczek Exp $")
|
||||
#endif
|
||||
#include <pwd.h>
|
||||
#include "pwauth.h"
|
||||
#ifdef HAVE_TCFS
|
||||
#include <tcfslib.h>
|
||||
#include "tcfsio.h"
|
||||
#endif
|
||||
#ifdef SHADOWPWD
|
||||
#include "shadowio.h"
|
||||
#endif
|
||||
#include "pwio.h"
|
||||
#include "nscd.h"
|
||||
#include "getdef.h"
|
||||
/*
|
||||
* exit status values
|
||||
@@ -113,19 +110,10 @@ static char crypt_passwd[128]; /* The "old-style" password, if present */
|
||||
static int do_update_pwd = 0;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TCFS
|
||||
static struct tcfspwd *tcfspword;
|
||||
static int tcfs_force = 0;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* External identifiers
|
||||
*/
|
||||
|
||||
#ifdef ATT_AGE
|
||||
extern char *l64a ();
|
||||
#endif
|
||||
|
||||
#ifdef NDBM
|
||||
extern int sp_dbm_mode;
|
||||
extern int pw_dbm_mode;
|
||||
@@ -135,10 +123,6 @@ extern int pw_dbm_mode;
|
||||
static void usage (int);
|
||||
|
||||
#ifndef USE_PAM
|
||||
#ifdef AUTH_METHODS
|
||||
static char *get_password (const char *);
|
||||
static int uses_default_method (const char *);
|
||||
#endif /* AUTH_METHODS */
|
||||
static int reuse (const char *, const struct passwd *);
|
||||
static int new_password (const struct passwd *);
|
||||
|
||||
@@ -160,9 +144,6 @@ static void update_noshadow (void);
|
||||
#ifdef SHADOWPWD
|
||||
static void update_shadow (void);
|
||||
#endif
|
||||
#ifdef HAVE_TCFS
|
||||
static void update_tcfs (void);
|
||||
#endif
|
||||
static long getnumber (const char *);
|
||||
|
||||
/*
|
||||
@@ -171,7 +152,7 @@ static long getnumber (const char *);
|
||||
|
||||
static void usage (int status)
|
||||
{
|
||||
fprintf (stderr, _("usage: %s [-f|-s] [name]\n"), Prog);
|
||||
fprintf (stderr, _("Usage: %s [-f|-s] [name]\n"), Prog);
|
||||
if (amroot) {
|
||||
fprintf (stderr,
|
||||
_
|
||||
@@ -184,48 +165,6 @@ static void usage (int status)
|
||||
}
|
||||
|
||||
#ifndef USE_PAM
|
||||
#ifdef AUTH_METHODS
|
||||
/*
|
||||
* get_password - locate encrypted password in authentication list
|
||||
*/
|
||||
|
||||
static char *get_password (const char *list)
|
||||
{
|
||||
char *cp, *end;
|
||||
static char buf[257];
|
||||
|
||||
STRFCPY (buf, list);
|
||||
for (cp = buf; cp; cp = end) {
|
||||
if ((end = strchr (cp, ';')))
|
||||
*end++ = 0;
|
||||
|
||||
if (cp[0] == '@')
|
||||
continue;
|
||||
|
||||
return cp;
|
||||
}
|
||||
return (char *) 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* uses_default_method - determine if "old-style" password present
|
||||
*
|
||||
* uses_default_method determines if a "old-style" password is present
|
||||
* in the authentication string, and if one is present it extracts it.
|
||||
*/
|
||||
|
||||
static int uses_default_method (const char *methods)
|
||||
{
|
||||
char *cp;
|
||||
|
||||
if ((cp = get_password (methods))) {
|
||||
STRFCPY (crypt_passwd, cp);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
#endif /* AUTH_METHODS */
|
||||
|
||||
static int reuse (const char *pass, const struct passwd *pw)
|
||||
{
|
||||
#ifdef HAVE_LIBCRACK_HIST
|
||||
@@ -273,22 +212,7 @@ static int reuse (const char *pass, const struct passwd *pw)
|
||||
* password.
|
||||
*/
|
||||
|
||||
#ifdef HAVE_TCFS
|
||||
tcfs_force = tcfs_force && amroot;
|
||||
|
||||
if ((tcfs_locate (name) && !tcfs_force)
|
||||
|| (!amroot && crypt_passwd[0])) {
|
||||
if (amroot) {
|
||||
printf (_
|
||||
("User %s has a TCFS key, his old password is required.\n"),
|
||||
name);
|
||||
printf (_
|
||||
("You can use -t option to force the change.\n"));
|
||||
}
|
||||
#else
|
||||
if (!amroot && crypt_passwd[0]) {
|
||||
#endif
|
||||
|
||||
if (!(clear = getpass (_("Old password: "))))
|
||||
return -1;
|
||||
|
||||
@@ -303,17 +227,9 @@ static int reuse (const char *pass, const struct passwd *pw)
|
||||
return -1;
|
||||
}
|
||||
STRFCPY (orig, clear);
|
||||
#ifdef HAVE_TCFS
|
||||
STRFCPY (tcfspword->tcfsorig, clear);
|
||||
#endif
|
||||
strzero (clear);
|
||||
strzero (cipher);
|
||||
} else {
|
||||
#ifdef HAVE_TCFS
|
||||
if (tcfs_locate (name))
|
||||
printf (_("Warning: user %s has a TCFS key.\n"),
|
||||
name);
|
||||
#endif
|
||||
orig[0] = '\0';
|
||||
}
|
||||
|
||||
@@ -380,9 +296,6 @@ Please use a combination of upper and lower case letters and numbers.\n"), getde
|
||||
memzero (pass, sizeof pass);
|
||||
return -1;
|
||||
}
|
||||
#ifdef HAVE_TCFS
|
||||
STRFCPY (tcfspword->tcfspass, pass);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Encrypt the password, then wipe the cleartext password.
|
||||
@@ -473,20 +386,9 @@ static void check_password (const struct passwd *pw)
|
||||
closelog ();
|
||||
exit (E_NOPERM);
|
||||
}
|
||||
#ifdef ATT_AGE
|
||||
/*
|
||||
* Can always be changed if there is no age info
|
||||
*/
|
||||
|
||||
if (!pw->pw_age[0])
|
||||
return;
|
||||
|
||||
last = a64l (pw->pw_age + 2) * WEEK;
|
||||
ok = last + c64i (pw->pw_age[1]) * WEEK;
|
||||
#else /* !ATT_AGE */
|
||||
last = 0;
|
||||
ok = 0;
|
||||
#endif /* !ATT_AGE */
|
||||
#endif /* !SHADOWPWD */
|
||||
if (now < ok) {
|
||||
fprintf (stderr,
|
||||
@@ -506,30 +408,6 @@ static void check_password (const struct passwd *pw)
|
||||
*/
|
||||
static char *insert_crypt_passwd (const char *string, const char *passwd)
|
||||
{
|
||||
#ifdef AUTH_METHODS
|
||||
if (string && *string) {
|
||||
char *cp, *result;
|
||||
|
||||
result = xmalloc (strlen (string) + strlen (passwd) + 1);
|
||||
cp = result;
|
||||
while (*string) {
|
||||
if (string[0] == ';') {
|
||||
*cp++ = *string++;
|
||||
} else if (string[0] == '@') {
|
||||
while (*string && *string != ';')
|
||||
*cp++ = *string++;
|
||||
} else {
|
||||
while (*passwd)
|
||||
*cp++ = *passwd++;
|
||||
|
||||
while (*string && *string != ';')
|
||||
string++;
|
||||
}
|
||||
}
|
||||
*cp = '\0';
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
return xstrdup (passwd);
|
||||
}
|
||||
#endif /* !USE_PAM */
|
||||
@@ -582,17 +460,7 @@ static void print_status (const struct passwd *pw)
|
||||
} else
|
||||
#endif
|
||||
{
|
||||
#ifdef ATT_AGE
|
||||
printf ("%s %s %s %d %d\n",
|
||||
pw->pw_name,
|
||||
pw_status (pw->pw_passwd),
|
||||
date_to_str (strlen (pw->pw_age) > 2 ?
|
||||
a64l (pw->pw_age + 2) * WEEK : 0L),
|
||||
pw->pw_age[0] ? c64i (pw->pw_age[1]) * 7 : 0,
|
||||
pw->pw_age[0] ? c64i (pw->pw_age[0]) * 7 : 10000);
|
||||
#else
|
||||
printf ("%s %s\n", pw->pw_name, pw_status (pw->pw_passwd));
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
@@ -602,9 +470,6 @@ static void fail_exit (int status)
|
||||
pw_unlock ();
|
||||
#ifdef SHADOWPWD
|
||||
spw_unlock ();
|
||||
#endif
|
||||
#ifdef HAVE_TCFS
|
||||
tcfs_unlock ();
|
||||
#endif
|
||||
exit (status);
|
||||
}
|
||||
@@ -644,12 +509,6 @@ static void update_noshadow (void)
|
||||
const struct passwd *pw;
|
||||
struct passwd *npw;
|
||||
|
||||
#ifdef ATT_AGE
|
||||
char age[5];
|
||||
long week = time ((time_t *) 0) / WEEK;
|
||||
char *cp;
|
||||
#endif
|
||||
|
||||
if (!pw_lock ()) {
|
||||
fprintf (stderr,
|
||||
_
|
||||
@@ -672,69 +531,6 @@ static void update_noshadow (void)
|
||||
if (!npw)
|
||||
oom ();
|
||||
npw->pw_passwd = update_crypt_pw (npw->pw_passwd);
|
||||
#ifdef ATT_AGE
|
||||
memzero (age, sizeof (age));
|
||||
STRFCPY (age, npw->pw_age);
|
||||
|
||||
/*
|
||||
* Just changing the password - update the last change date if there
|
||||
* is one, otherwise the age just disappears.
|
||||
*/
|
||||
if (do_update_age) {
|
||||
if (strlen (age) > 2) {
|
||||
cp = l64a (week);
|
||||
age[2] = cp[0];
|
||||
age[3] = cp[1];
|
||||
} else {
|
||||
age[0] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
if (xflg) {
|
||||
if (age_max > 0)
|
||||
age[0] = i64c ((age_max + 6) / 7);
|
||||
else
|
||||
age[0] = '.';
|
||||
|
||||
if (age[1] == '\0')
|
||||
age[1] = '.';
|
||||
}
|
||||
if (nflg) {
|
||||
if (age[0] == '\0')
|
||||
age[0] = 'z';
|
||||
|
||||
if (age_min > 0)
|
||||
age[1] = i64c ((age_min + 6) / 7);
|
||||
else
|
||||
age[1] = '.';
|
||||
}
|
||||
/*
|
||||
* The last change date is added by -n or -x if it's not already
|
||||
* there.
|
||||
*/
|
||||
if ((nflg || xflg) && strlen (age) <= 2) {
|
||||
cp = l64a (week);
|
||||
age[2] = cp[0];
|
||||
age[3] = cp[1];
|
||||
}
|
||||
|
||||
/*
|
||||
* Force password change - if last change date is present, it will
|
||||
* be set to (today - max - 1 week). Otherwise, just set min = max
|
||||
* = 0 (will disappear when password is changed).
|
||||
*/
|
||||
if (eflg) {
|
||||
if (strlen (age) > 2) {
|
||||
cp = l64a (week - c64i (age[0]) - 1);
|
||||
age[2] = cp[0];
|
||||
age[3] = cp[1];
|
||||
} else {
|
||||
strcpy (age, "..");
|
||||
}
|
||||
}
|
||||
|
||||
npw->pw_age = age;
|
||||
#endif
|
||||
if (!pw_update (npw)) {
|
||||
fprintf (stderr,
|
||||
_("Error updating the password entry.\n"));
|
||||
@@ -759,46 +555,6 @@ static void update_noshadow (void)
|
||||
pw_unlock ();
|
||||
}
|
||||
|
||||
#ifdef HAVE_TCFS
|
||||
static void update_tcfs (void)
|
||||
{
|
||||
if (!tcfs_force) {
|
||||
if (!tcfs_lock ()) {
|
||||
fprintf (stderr,
|
||||
_
|
||||
("Cannot lock the TCFS key database; try again later\n"));
|
||||
SYSLOG ((LOG_WARN,
|
||||
"can't lock TCFS key database"));
|
||||
exit (E_PWDBUSY);
|
||||
}
|
||||
if (!tcfs_open (O_RDWR)) {
|
||||
fprintf (stderr,
|
||||
_
|
||||
("Cannot open the TCFS key database.\n"));
|
||||
SYSLOG ((LOG_WARN,
|
||||
"can't open TCFS key database"));
|
||||
fail_exit (E_MISSING);
|
||||
}
|
||||
if (!tcfs_update (name, tcfspword)) {
|
||||
fprintf (stderr,
|
||||
_
|
||||
("Error updating the TCFS key database.\n"));
|
||||
SYSLOG ((LOG_ERR,
|
||||
"error updating TCFS key database"));
|
||||
fail_exit (E_FAILURE);
|
||||
}
|
||||
if (!tcfs_close ()) {
|
||||
fprintf (stderr,
|
||||
_("Cannot commit TCFS changes.\n"));
|
||||
SYSLOG ((LOG_ERR,
|
||||
"can't rewrite TCFS key database"));
|
||||
fail_exit (E_FAILURE);
|
||||
}
|
||||
tcfs_unlock ();
|
||||
}
|
||||
}
|
||||
#endif /* HAVE_TCFS */
|
||||
|
||||
#ifdef SHADOWPWD
|
||||
static void update_shadow (void)
|
||||
{
|
||||
@@ -904,7 +660,6 @@ static long getnumber (const char *str)
|
||||
* -f execute chfn command to interpret flags
|
||||
* -s execute chsh command to interpret flags
|
||||
* -k change password only if expired
|
||||
* -t force 'passwd' to change the password regardless of TCFS
|
||||
*
|
||||
* (*) requires root permission to execute.
|
||||
*
|
||||
@@ -990,31 +745,14 @@ int main (int argc, char **argv)
|
||||
*/
|
||||
|
||||
#ifdef SHADOWPWD
|
||||
|
||||
#define FLAGS "adlqr:uSekn:x:i:w:"
|
||||
#ifdef HAVE_TCFS
|
||||
#undef FLAGS
|
||||
#define FLAGS "adlqr:uSekn:x:i:w:t"
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#define FLAGS "adlqr:uS"
|
||||
#ifdef HAVE_TCFS
|
||||
#undef FLAGS
|
||||
#define FLAGS "adlqr:uSt"
|
||||
#endif
|
||||
|
||||
# define FLAGS "adlqr:uS"
|
||||
#endif
|
||||
|
||||
while ((flag = getopt (argc, argv, FLAGS)) != EOF) {
|
||||
#undef FLAGS
|
||||
switch (flag) {
|
||||
#ifdef HAVE_TCFS
|
||||
case 't':
|
||||
tcfs_force = 1;
|
||||
break;
|
||||
#endif
|
||||
#ifdef SHADOWPWD
|
||||
case 'x':
|
||||
age_max = getnumber (optarg);
|
||||
@@ -1204,21 +942,7 @@ int main (int argc, char **argv)
|
||||
*/
|
||||
|
||||
if (!anyflag) {
|
||||
#ifdef AUTH_METHODS
|
||||
if (strchr (cp, '@')) {
|
||||
if (pw_auth (cp, name, PW_CHANGE, (char *) 0)) {
|
||||
SYSLOG ((LOG_INFO,
|
||||
"password for `%s' changed by `%s'",
|
||||
name));
|
||||
closelog ();
|
||||
exit (E_NOPERM);
|
||||
} else if (!uses_default_method (cp)) {
|
||||
do_update_age = 1;
|
||||
goto done;
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
STRFCPY (crypt_passwd, cp);
|
||||
STRFCPY (crypt_passwd, cp);
|
||||
|
||||
/*
|
||||
* See if the user is permitted to change the password.
|
||||
@@ -1231,10 +955,6 @@ int main (int argc, char **argv)
|
||||
check_password (pw);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TCFS
|
||||
tcfspword =
|
||||
(struct tcfspwd *) calloc (1, sizeof (struct tcfspwd));
|
||||
#endif
|
||||
/*
|
||||
* Let the user know whose password is being changed.
|
||||
*/
|
||||
@@ -1251,9 +971,6 @@ int main (int argc, char **argv)
|
||||
do_update_pwd = 1;
|
||||
do_update_age = 1;
|
||||
}
|
||||
#ifdef AUTH_METHODS
|
||||
done:
|
||||
#endif
|
||||
#endif /* !USE_PAM */
|
||||
/*
|
||||
* Before going any further, raise the ulimit to prevent colliding
|
||||
@@ -1286,14 +1003,17 @@ int main (int argc, char **argv)
|
||||
#endif
|
||||
update_noshadow ();
|
||||
|
||||
#ifdef HAVE_TCFS
|
||||
if (tcfs_locate (name) && tcfs_file_present ())
|
||||
update_tcfs ();
|
||||
nscd_flush_cache ("passwd");
|
||||
nscd_flush_cache ("group");
|
||||
#ifdef SHADOWPWD
|
||||
nscd_flush_cache ("shadow");
|
||||
#endif
|
||||
|
||||
SYSLOG ((LOG_INFO, "password for `%s' changed by `%s'", name,
|
||||
myname));
|
||||
closelog ();
|
||||
if (!qflg)
|
||||
printf (_("Password changed.\n"));
|
||||
exit (E_SUCCESS);
|
||||
/*NOTREACHED*/}
|
||||
/* NOT REACHED */
|
||||
}
|
||||
|
||||
15
src/pwconv.c
15
src/pwconv.c
@@ -29,7 +29,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID (PKG_VER "$Id: pwconv.c,v 1.12 2002/01/05 15:41:44 kloczek Exp $")
|
||||
RCSID (PKG_VER "$Id: pwconv.c,v 1.15 2003/06/19 18:11:01 kloczek Exp $")
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -43,12 +43,13 @@ RCSID (PKG_VER "$Id: pwconv.c,v 1.12 2002/01/05 15:41:44 kloczek Exp $")
|
||||
#include "pwio.h"
|
||||
#include "shadowio.h"
|
||||
#include "getdef.h"
|
||||
#ifdef SHADOWPWD
|
||||
/*
|
||||
* exit status values
|
||||
*/
|
||||
#define E_SUCCESS 0 /* success */
|
||||
#define E_NOPERM 1 /* permission denied */
|
||||
#define E_USAGE 2 /* bad command syntax */
|
||||
#define E_USAGE 2 /* invalid command syntax */
|
||||
#define E_FAILURE 3 /* unexpected failure, nothing done */
|
||||
#define E_MISSING 4 /* unexpected failure, passwd file missing */
|
||||
#define E_PWDBUSY 5 /* passwd file(s) busy */
|
||||
@@ -181,3 +182,13 @@ int main (int argc, char **argv)
|
||||
pw_unlock ();
|
||||
exit (E_SUCCESS);
|
||||
}
|
||||
|
||||
#else /* !SHADOWPWD */
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"%s: not configured for shadow password support.\n",
|
||||
argv[0]);
|
||||
exit (1);
|
||||
}
|
||||
#endif /* !SHADOWPWD */
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID (PKG_VER "$Id: pwunconv.c,v 1.11 2002/01/05 15:41:44 kloczek Exp $")
|
||||
RCSID (PKG_VER "$Id: pwunconv.c,v 1.15 2003/06/19 18:11:01 kloczek Exp $")
|
||||
#include "defines.h"
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
@@ -40,19 +40,8 @@ RCSID (PKG_VER "$Id: pwunconv.c,v 1.11 2002/01/05 15:41:44 kloczek Exp $")
|
||||
#include "prototypes.h"
|
||||
#include "pwio.h"
|
||||
#include "shadowio.h"
|
||||
#ifndef SHADOWPWD
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
fprintf (stderr, _("%s: Shadow passwords are not configured.\n"),
|
||||
argv[0]);
|
||||
exit (1);
|
||||
}
|
||||
|
||||
#else /*{ */
|
||||
#include "nscd.h"
|
||||
#ifdef SHADOWPWD
|
||||
char *l64a ();
|
||||
|
||||
static int shadow_locked = 0, passwd_locked = 0;
|
||||
@@ -76,9 +65,6 @@ int main (int argc, char **argv)
|
||||
struct passwd pwent;
|
||||
const struct spwd *spwd;
|
||||
|
||||
#ifdef ATT_AGE
|
||||
char newage[5];
|
||||
#endif
|
||||
char *Prog = argv[0];
|
||||
|
||||
setlocale (LC_ALL, "");
|
||||
@@ -133,28 +119,6 @@ int main (int argc, char **argv)
|
||||
* to weeks and so on.
|
||||
*/
|
||||
|
||||
#ifdef ATT_AGE
|
||||
if (spwd->sp_max > (63 * WEEK / SCALE)
|
||||
&& spwd->sp_max < 10000)
|
||||
spwd->sp_max = (63 * WEEK / SCALE); /* 10000 is infinity */
|
||||
|
||||
if (spwd->sp_min >= 0 && spwd->sp_min <= 63 * 7 &&
|
||||
spwd->sp_max >= 0 && spwd->sp_max <= 63 * 7) {
|
||||
if (spwd->sp_lstchg == -1)
|
||||
spwd->sp_lstchg = 0;
|
||||
|
||||
spwd->sp_max /= WEEK / SCALE; /* turn it into weeks */
|
||||
spwd->sp_min /= WEEK / SCALE;
|
||||
spwd->sp_lstchg /= WEEK / SCALE;
|
||||
|
||||
strncpy (newage,
|
||||
l64a (spwd->sp_lstchg * (64L * 64L) +
|
||||
spwd->sp_min * (64L) +
|
||||
spwd->sp_max), 5);
|
||||
pwent.pw_age = newage;
|
||||
} else
|
||||
pwent.pw_age = "";
|
||||
#endif /* ATT_AGE */
|
||||
if (!pw_update (&pwent)) {
|
||||
fprintf (stderr,
|
||||
_("%s: can't update entry for user %s\n"),
|
||||
@@ -185,6 +149,21 @@ int main (int argc, char **argv)
|
||||
|
||||
spw_unlock ();
|
||||
pw_unlock ();
|
||||
|
||||
nscd_flush_cache ("passwd");
|
||||
#ifdef SHADOWPWD
|
||||
nscd_flush_cache ("shadow");
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#else /* !SHADOWPWD */
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
fprintf (stderr,
|
||||
"%s: not configured for shadow password support.\n",
|
||||
argv[0]);
|
||||
exit (1);
|
||||
}
|
||||
#endif /* !SHADOWPWD */
|
||||
|
||||
24
src/su.c
24
src/su.c
@@ -30,7 +30,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID (PKG_VER "$Id: su.c,v 1.22 2002/03/08 04:30:28 kloczek Exp $")
|
||||
RCSID (PKG_VER "$Id: su.c,v 1.26 2003/06/19 18:11:01 kloczek Exp $")
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#ifdef USE_PAM
|
||||
@@ -464,14 +464,6 @@ int main (int argc, char **argv)
|
||||
"Expired account %s", name));
|
||||
su_failure (tty);
|
||||
}
|
||||
#else
|
||||
#if defined(ATT_AGE)
|
||||
if (pwent.pw_age[0] && isexpired (&pwent)) {
|
||||
SYSLOG ((pwent.pw_uid ? LOG_WARN : LOG_CRIT,
|
||||
"Expired account %s", name));
|
||||
su_failure (tty);
|
||||
}
|
||||
#endif /* ATT_AGE */
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -494,9 +486,7 @@ int main (int argc, char **argv)
|
||||
|
||||
signal (SIGINT, SIG_DFL);
|
||||
cp = getdef_str ((pwent.pw_uid == 0) ? "ENV_SUPATH" : "ENV_PATH");
|
||||
#if 0
|
||||
addenv (cp ? cp : "PATH=/bin:/usr/bin", NULL);
|
||||
#else
|
||||
|
||||
/* XXX very similar code duplicated in libmisc/setupenv.c */
|
||||
if (!cp) {
|
||||
addenv ("PATH=/bin:/usr/bin", NULL);
|
||||
@@ -505,7 +495,6 @@ int main (int argc, char **argv)
|
||||
} else {
|
||||
addenv ("PATH", cp);
|
||||
}
|
||||
#endif
|
||||
|
||||
environ = newenvp; /* make new environment active */
|
||||
|
||||
@@ -597,12 +586,6 @@ int main (int argc, char **argv)
|
||||
if (fakelogin) {
|
||||
char *arg0;
|
||||
|
||||
#if 0 /* XXX - GNU su doesn't do this. --marekm */
|
||||
if (!hushed (&pwent)) {
|
||||
motd ();
|
||||
mailcheck ();
|
||||
}
|
||||
#endif
|
||||
cp = getdef_str ("SU_NAME");
|
||||
if (!cp)
|
||||
cp = Basename (pwent.pw_shell);
|
||||
@@ -630,5 +613,6 @@ int main (int argc, char **argv)
|
||||
}
|
||||
|
||||
shell (pwent.pw_shell, cp);
|
||||
/*NOTREACHED*/ exit (1);
|
||||
/* NOT REACHED */
|
||||
exit (1);
|
||||
}
|
||||
|
||||
197
src/suauth.c
197
src/suauth.c
@@ -25,26 +25,25 @@ struct passwd pwent;
|
||||
* strings output to the user or the syslog. -- chris
|
||||
*/
|
||||
|
||||
static int applies(const char *, char *);
|
||||
static int applies (const char *, char *);
|
||||
|
||||
int check_su_auth(const char *, const char *);
|
||||
int isgrp(const char *, const char *);
|
||||
int check_su_auth (const char *, const char *);
|
||||
int isgrp (const char *, const char *);
|
||||
|
||||
static int lines = 0;
|
||||
|
||||
|
||||
int
|
||||
check_su_auth(const char *actual_id, const char *wanted_id)
|
||||
int check_su_auth (const char *actual_id, const char *wanted_id)
|
||||
{
|
||||
int posn, endline;
|
||||
const char field[] = ":";
|
||||
FILE *authfile_fd;
|
||||
char temp[1024];
|
||||
char *to_users;
|
||||
char *from_users;
|
||||
char *action;
|
||||
int posn, endline;
|
||||
const char field[] = ":";
|
||||
FILE *authfile_fd;
|
||||
char temp[1024];
|
||||
char *to_users;
|
||||
char *from_users;
|
||||
char *action;
|
||||
|
||||
if (!(authfile_fd = fopen(SUAUTHFILE, "r"))) {
|
||||
if (!(authfile_fd = fopen (SUAUTHFILE, "r"))) {
|
||||
/*
|
||||
* If the file doesn't exist - default to the standard su
|
||||
* behaviour (no access control). If open fails for some
|
||||
@@ -53,23 +52,25 @@ check_su_auth(const char *actual_id, const char *wanted_id)
|
||||
*/
|
||||
if (errno == ENOENT)
|
||||
return NOACTION;
|
||||
SYSLOG((LOG_ERR, "could not open/read config file '%s': %m\n",
|
||||
SUAUTHFILE));
|
||||
SYSLOG ((LOG_ERR,
|
||||
"could not open/read config file '%s': %m\n",
|
||||
SUAUTHFILE));
|
||||
return DENY;
|
||||
}
|
||||
|
||||
while (fgets(temp, sizeof(temp), authfile_fd) != NULL) {
|
||||
while (fgets (temp, sizeof (temp), authfile_fd) != NULL) {
|
||||
lines++;
|
||||
|
||||
if (temp[endline = strlen(temp) - 1] != '\n') {
|
||||
SYSLOG((LOG_ERR,
|
||||
"%s, line %d: line too long or missing newline",
|
||||
SUAUTHFILE, lines));
|
||||
if (temp[endline = strlen (temp) - 1] != '\n') {
|
||||
SYSLOG ((LOG_ERR,
|
||||
"%s, line %d: line too long or missing newline",
|
||||
SUAUTHFILE, lines));
|
||||
continue;
|
||||
}
|
||||
|
||||
while (endline > 0 && (temp[endline-1] == ' '
|
||||
|| temp[endline-1] == '\t' || temp[endline-1] == '\n'))
|
||||
while (endline > 0 && (temp[endline - 1] == ' '
|
||||
|| temp[endline - 1] == '\t'
|
||||
|| temp[endline - 1] == '\n'))
|
||||
endline--;
|
||||
temp[endline] = '\0';
|
||||
|
||||
@@ -77,108 +78,117 @@ check_su_auth(const char *actual_id, const char *wanted_id)
|
||||
while (temp[posn] == ' ' || temp[posn] == '\t')
|
||||
posn++;
|
||||
|
||||
if (temp[posn] == '\n' || temp[posn] == '#' || temp[posn] == '\0') {
|
||||
if (temp[posn] == '\n' || temp[posn] == '#'
|
||||
|| temp[posn] == '\0') {
|
||||
continue;
|
||||
}
|
||||
if (!(to_users = strtok(temp + posn, field))
|
||||
|| !(from_users = strtok((char *)NULL, field))
|
||||
|| !(action = strtok((char *)NULL, field))
|
||||
|| strtok((char *)NULL, field)) {
|
||||
SYSLOG((LOG_ERR, "%s, line %d. Bad number of fields.\n",
|
||||
SUAUTHFILE, lines));
|
||||
if (!(to_users = strtok (temp + posn, field))
|
||||
|| !(from_users = strtok ((char *) NULL, field))
|
||||
|| !(action = strtok ((char *) NULL, field))
|
||||
|| strtok ((char *) NULL, field)) {
|
||||
SYSLOG ((LOG_ERR,
|
||||
"%s, line %d. Bad number of fields.\n",
|
||||
SUAUTHFILE, lines));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!applies(wanted_id, to_users))
|
||||
if (!applies (wanted_id, to_users))
|
||||
continue;
|
||||
if (!applies(actual_id, from_users))
|
||||
if (!applies (actual_id, from_users))
|
||||
continue;
|
||||
if (!strcmp(action, "DENY")) {
|
||||
SYSLOG((pwent.pw_uid ? LOG_NOTICE : LOG_WARN,
|
||||
"DENIED su from `%s' to `%s' (%s)\n",
|
||||
actual_id, wanted_id, SUAUTHFILE));
|
||||
fprintf(stderr, _("Access to su to that account DENIED.\n"));
|
||||
fclose(authfile_fd);
|
||||
if (!strcmp (action, "DENY")) {
|
||||
SYSLOG ((pwent.pw_uid ? LOG_NOTICE : LOG_WARN,
|
||||
"DENIED su from `%s' to `%s' (%s)\n",
|
||||
actual_id, wanted_id, SUAUTHFILE));
|
||||
fprintf (stderr,
|
||||
_
|
||||
("Access to su to that account DENIED.\n"));
|
||||
fclose (authfile_fd);
|
||||
return DENY;
|
||||
} else if (!strcmp(action, "NOPASS")) {
|
||||
SYSLOG((pwent.pw_uid ? LOG_INFO : LOG_NOTICE,
|
||||
"NO password asked for su from `%s' to `%s' (%s)\n",
|
||||
actual_id, wanted_id, SUAUTHFILE));
|
||||
fprintf(stderr, _("Password authentication bypassed.\n"));
|
||||
fclose(authfile_fd);
|
||||
} else if (!strcmp (action, "NOPASS")) {
|
||||
SYSLOG ((pwent.pw_uid ? LOG_INFO : LOG_NOTICE,
|
||||
"NO password asked for su from `%s' to `%s' (%s)\n",
|
||||
actual_id, wanted_id, SUAUTHFILE));
|
||||
fprintf (stderr,
|
||||
_("Password authentication bypassed.\n"));
|
||||
fclose (authfile_fd);
|
||||
return NOPWORD;
|
||||
} else if (!strcmp(action, "OWNPASS")) {
|
||||
SYSLOG((pwent.pw_uid ? LOG_INFO : LOG_NOTICE,
|
||||
"su from `%s' to `%s': asking for user's own password (%s)\n",
|
||||
actual_id, wanted_id, SUAUTHFILE));
|
||||
fprintf(stderr, _("Please enter your OWN password as authentication.\n"));
|
||||
fclose(authfile_fd);
|
||||
} else if (!strcmp (action, "OWNPASS")) {
|
||||
SYSLOG ((pwent.pw_uid ? LOG_INFO : LOG_NOTICE,
|
||||
"su from `%s' to `%s': asking for user's own password (%s)\n",
|
||||
actual_id, wanted_id, SUAUTHFILE));
|
||||
fprintf (stderr,
|
||||
_
|
||||
("Please enter your OWN password as authentication.\n"));
|
||||
fclose (authfile_fd);
|
||||
return OWNPWORD;
|
||||
} else {
|
||||
SYSLOG((LOG_ERR, "%s, line %d: unrecognised action!\n",
|
||||
SUAUTHFILE, lines));
|
||||
SYSLOG ((LOG_ERR,
|
||||
"%s, line %d: unrecognised action!\n",
|
||||
SUAUTHFILE, lines));
|
||||
}
|
||||
}
|
||||
fclose(authfile_fd);
|
||||
fclose (authfile_fd);
|
||||
return NOACTION;
|
||||
}
|
||||
|
||||
static int
|
||||
applies(const char *single, char *list)
|
||||
static int applies (const char *single, char *list)
|
||||
{
|
||||
const char split[] = ", ";
|
||||
char *tok;
|
||||
const char split[] = ", ";
|
||||
char *tok;
|
||||
|
||||
int state = 0;
|
||||
|
||||
for (tok = strtok(list, split); tok != NULL; tok = strtok(NULL, split)) {
|
||||
for (tok = strtok (list, split); tok != NULL;
|
||||
tok = strtok (NULL, split)) {
|
||||
|
||||
if (!strcmp(tok, "ALL")) {
|
||||
if (!strcmp (tok, "ALL")) {
|
||||
if (state != 0) {
|
||||
SYSLOG((LOG_ERR,
|
||||
"%s, line %d: ALL in bad place\n",
|
||||
SUAUTHFILE, lines));
|
||||
SYSLOG ((LOG_ERR,
|
||||
"%s, line %d: ALL in bad place\n",
|
||||
SUAUTHFILE, lines));
|
||||
return 0;
|
||||
}
|
||||
state = 1;
|
||||
} else if (!strcmp(tok, "EXCEPT")) {
|
||||
} else if (!strcmp (tok, "EXCEPT")) {
|
||||
if (state != 1) {
|
||||
SYSLOG((LOG_ERR,
|
||||
"%s, line %d: EXCEPT in bas place\n",
|
||||
SUAUTHFILE, lines));
|
||||
SYSLOG ((LOG_ERR,
|
||||
"%s, line %d: EXCEPT in bas place\n",
|
||||
SUAUTHFILE, lines));
|
||||
return 0;
|
||||
}
|
||||
state = 2;
|
||||
} else if (!strcmp(tok, "GROUP")) {
|
||||
} else if (!strcmp (tok, "GROUP")) {
|
||||
if ((state != 0) && (state != 2)) {
|
||||
SYSLOG((LOG_ERR,
|
||||
"%s, line %d: GROUP in bad place\n",
|
||||
SUAUTHFILE, lines));
|
||||
SYSLOG ((LOG_ERR,
|
||||
"%s, line %d: GROUP in bad place\n",
|
||||
SUAUTHFILE, lines));
|
||||
return 0;
|
||||
}
|
||||
state = (state == 0) ? 3 : 4;
|
||||
} else {
|
||||
switch (state) {
|
||||
case 0: /* No control words yet */
|
||||
if (!strcmp(tok, single))
|
||||
return 1;
|
||||
break;
|
||||
case 1: /* An all */
|
||||
SYSLOG((LOG_ERR, "%s, line %d: expect another token after ALL\n",
|
||||
SUAUTHFILE, lines));
|
||||
case 0: /* No control words yet */
|
||||
if (!strcmp (tok, single))
|
||||
return 1;
|
||||
break;
|
||||
case 1: /* An all */
|
||||
SYSLOG ((LOG_ERR,
|
||||
"%s, line %d: expect another token after ALL\n",
|
||||
SUAUTHFILE, lines));
|
||||
return 0;
|
||||
case 2: /* All except */
|
||||
if (!strcmp (tok, single))
|
||||
return 0;
|
||||
case 2: /* All except */
|
||||
if (!strcmp(tok, single))
|
||||
return 0;
|
||||
break;
|
||||
case 3: /* Group */
|
||||
if (isgrp(single, tok))
|
||||
return 1;
|
||||
break;
|
||||
case 4: /* All except group */
|
||||
if (isgrp(single, tok))
|
||||
return 0;
|
||||
/* FALL THRU */
|
||||
break;
|
||||
case 3: /* Group */
|
||||
if (isgrp (single, tok))
|
||||
return 1;
|
||||
break;
|
||||
case 4: /* All except group */
|
||||
if (isgrp (single, tok))
|
||||
return 0;
|
||||
/* FALL THRU */
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -187,16 +197,15 @@ applies(const char *single, char *list)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
isgrp(const char *name, const char *group)
|
||||
int isgrp (const char *name, const char *group)
|
||||
{
|
||||
struct group *grp;
|
||||
struct group *grp;
|
||||
|
||||
grp = getgrnam(group);
|
||||
grp = getgrnam (group);
|
||||
|
||||
if (!grp || !grp->gr_mem)
|
||||
return 0;
|
||||
|
||||
return is_on_list(grp->gr_mem, name);
|
||||
return is_on_list (grp->gr_mem, name);
|
||||
}
|
||||
#endif /* SU_ACCESS */
|
||||
#endif /* SU_ACCESS */
|
||||
|
||||
@@ -30,15 +30,10 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID (PKG_VER "$Id: sulogin.c,v 1.13 2002/01/05 15:41:44 kloczek Exp $")
|
||||
RCSID (PKG_VER "$Id: sulogin.c,v 1.17 2003/05/12 04:39:17 kloczek Exp $")
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
#include "getdef.h"
|
||||
#if HAVE_UTMPX_H
|
||||
#include <utmpx.h>
|
||||
#else
|
||||
#include <utmp.h>
|
||||
#endif
|
||||
#include <signal.h>
|
||||
#include <stdio.h>
|
||||
#include <pwd.h>
|
||||
@@ -49,15 +44,6 @@ static char pass[BUFSIZ];
|
||||
|
||||
static struct passwd pwent;
|
||||
|
||||
#if 0
|
||||
#if HAVE_UTMPX_H
|
||||
static struct utmpx utent;
|
||||
#else
|
||||
static struct utmp utent;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
extern char **newenvp;
|
||||
extern size_t newenvc;
|
||||
|
||||
@@ -209,20 +195,6 @@ static RETSIGTYPE catch (int sig)
|
||||
STRFCPY (pass, cp);
|
||||
strzero (cp);
|
||||
}
|
||||
#ifdef AUTH_METHODS
|
||||
if (pwent.pw_name && pwent.pw_passwd[0] == '@') {
|
||||
if (pw_auth
|
||||
(pwent.pw_passwd + 1, name, PW_LOGIN,
|
||||
(char *) 0)) {
|
||||
#ifdef USE_SYSLOG
|
||||
syslog (LOG_WARN,
|
||||
"Incorrect root authentication");
|
||||
#endif
|
||||
continue;
|
||||
}
|
||||
goto auth_done;
|
||||
}
|
||||
#endif
|
||||
if (valid (pass, &pwent)) /* check encrypted passwords ... */
|
||||
break; /* ... encrypted passwords matched */
|
||||
|
||||
@@ -232,9 +204,6 @@ static RETSIGTYPE catch (int sig)
|
||||
sleep (2);
|
||||
puts (_("Login incorrect"));
|
||||
}
|
||||
#ifdef AUTH_METHODS
|
||||
auth_done:
|
||||
#endif
|
||||
strzero (pass);
|
||||
alarm (0);
|
||||
signal (SIGALRM, SIG_DFL);
|
||||
@@ -245,26 +214,6 @@ static RETSIGTYPE catch (int sig)
|
||||
syslog (LOG_INFO, "System Maintenance Mode\n");
|
||||
#endif
|
||||
|
||||
#if 0 /* do we need all this? we are logging in as root anyway... --marekm */
|
||||
/*
|
||||
* Normally there would be a utmp entry for login to mung on to get
|
||||
* the tty name, date, etc. from. We don't need all that stuff
|
||||
* because we won't update the utmp or wtmp files. BUT!, we do need
|
||||
* the tty name so we can set the permissions and ownership.
|
||||
*/
|
||||
|
||||
if ((cp = ttyname (0))) { /* found entry in /dev/ */
|
||||
if (strncmp (cp, "/dev/", 5) == 0)
|
||||
cp += 5;
|
||||
|
||||
strncpy (utent.ut_line, cp, sizeof utent.ut_line);
|
||||
}
|
||||
if (getenv ("IFS")) /* don't export user IFS ... */
|
||||
addenv ("IFS= \t\n", NULL); /* ... instead, set a safe IFS */
|
||||
|
||||
setup (&pwent, 0); /* set UID, GID, HOME, etc ... */
|
||||
#endif
|
||||
|
||||
#ifdef USE_SYSLOG
|
||||
closelog ();
|
||||
#endif
|
||||
|
||||
281
src/useradd.c
281
src/useradd.c
@@ -30,7 +30,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID (PKG_VER "$Id: useradd.c,v 1.32 2002/01/10 13:01:28 kloczek Exp $")
|
||||
RCSID (PKG_VER "$Id: useradd.c,v 1.46.2.2 2004/01/14 06:41:06 kloczek Exp $")
|
||||
#include "prototypes.h"
|
||||
#include "defines.h"
|
||||
#include "chkname.h"
|
||||
@@ -55,6 +55,7 @@ RCSID (PKG_VER "$Id: useradd.c,v 1.32 2002/01/10 13:01:28 kloczek Exp $")
|
||||
#include "lastlog_.h"
|
||||
#endif
|
||||
#include "faillog.h"
|
||||
#include "nscd.h"
|
||||
#ifndef SKEL_DIR
|
||||
#define SKEL_DIR "/etc/skel"
|
||||
#endif
|
||||
@@ -108,26 +109,20 @@ static int do_grp_update = 0; /* group files need to be updated */
|
||||
static char *Prog;
|
||||
|
||||
static int
|
||||
bflg = 0, /* new default root of home directory */
|
||||
cflg = 0, /* comment (GECOS) field for new account */
|
||||
dflg = 0, /* home directory for new account */
|
||||
Dflg = 0, /* set/show new user default values */
|
||||
eflg = 0, /* days since 1970-01-01 when account is locked */
|
||||
fflg = 0, /* days until account with expired password is locked */
|
||||
gflg = 0, /* primary group ID for new account */
|
||||
Gflg = 0, /* secondary group set for new account */
|
||||
kflg = 0, /* specify a directory to fill new user directory */
|
||||
mflg = 0, /* create user's home directory if it doesn't exist */
|
||||
nflg = 0, /* create a group having the same name as the user */
|
||||
oflg = 0, /* permit non-unique user ID to be specified with -u */
|
||||
sflg = 0, /* shell program for new account */
|
||||
uflg = 0; /* specify user ID for new account */
|
||||
|
||||
#ifdef AUTH_METHODS
|
||||
static int Aflg = 0; /* specify authentication method for user */
|
||||
static char user_auth[1024];
|
||||
static char *auth_arg;
|
||||
#endif
|
||||
bflg = 0, /* new default root of home directory */
|
||||
cflg = 0, /* comment (GECOS) field for new account */
|
||||
dflg = 0, /* home directory for new account */
|
||||
Dflg = 0, /* set/show new user default values */
|
||||
eflg = 0, /* days since 1970-01-01 when account is locked */
|
||||
fflg = 0, /* days until account with expired password is locked */
|
||||
gflg = 0, /* primary group ID for new account */
|
||||
Gflg = 0, /* secondary group set for new account */
|
||||
kflg = 0, /* specify a directory to fill new user directory */
|
||||
mflg = 0, /* create user's home directory if it doesn't exist */
|
||||
nflg = 0, /* create a group having the same name as the user */
|
||||
oflg = 0, /* permit non-unique user ID to be specified with -u */
|
||||
sflg = 0, /* shell program for new account */
|
||||
uflg = 0; /* specify user ID for new account */
|
||||
|
||||
extern char *optarg;
|
||||
extern int optind;
|
||||
@@ -138,6 +133,7 @@ extern int pw_dbm_mode;
|
||||
#ifdef SHADOWPWD
|
||||
extern int sp_dbm_mode;
|
||||
#endif
|
||||
|
||||
extern int gr_dbm_mode;
|
||||
|
||||
#ifdef SHADOWGRP
|
||||
@@ -178,7 +174,7 @@ static int sg_dbm_added;
|
||||
*/
|
||||
#define E_SUCCESS 0 /* success */
|
||||
#define E_PW_UPDATE 1 /* can't update password file */
|
||||
#define E_USAGE 2 /* bad command syntax */
|
||||
#define E_USAGE 2 /* invalid command syntax */
|
||||
#define E_BAD_ARG 3 /* invalid argument to option */
|
||||
#define E_UID_IN_USE 4 /* uid already in use (and no -o) */
|
||||
#define E_NOTFOUND 6 /* specified group doesn't exist */
|
||||
@@ -186,21 +182,12 @@ static int sg_dbm_added;
|
||||
#define E_GRP_UPDATE 10 /* can't update group file */
|
||||
#define E_HOMEDIR 12 /* can't create home directory */
|
||||
|
||||
#ifdef SVR4
|
||||
#define DGROUP "defgroup="
|
||||
#define HOME "defparent="
|
||||
#define SHELL "defshell="
|
||||
#define INACT "definact="
|
||||
#define EXPIRE "defexpire="
|
||||
#define SKEL "defskel="
|
||||
#else
|
||||
#define DGROUP "GROUP="
|
||||
#define HOME "HOME="
|
||||
#define SHELL "SHELL="
|
||||
#define INACT "INACTIVE="
|
||||
#define EXPIRE "EXPIRE="
|
||||
#define SKEL "SKEL="
|
||||
#endif
|
||||
#define DGROUP "GROUP="
|
||||
#define HOME "HOME="
|
||||
#define SHELL "SHELL="
|
||||
#define INACT "INACTIVE="
|
||||
#define EXPIRE "EXPIRE="
|
||||
#define SKEL "SKEL="
|
||||
|
||||
/* local function prototypes */
|
||||
static void fail_exit (int);
|
||||
@@ -221,10 +208,6 @@ static void new_spent (struct spwd *);
|
||||
static void grp_update (void);
|
||||
static void find_new_uid (void);
|
||||
|
||||
#ifdef AUTH_METHODS
|
||||
static void convert_auth (char *, const char *);
|
||||
static int valid_auth (const char *);
|
||||
#endif
|
||||
static void process_flags (int argc, char **argv);
|
||||
static void close_files (void);
|
||||
static void open_files (void);
|
||||
@@ -354,7 +337,8 @@ static void get_defaults (void)
|
||||
*/
|
||||
|
||||
if (MATCH (buf, DGROUP)) {
|
||||
unsigned int val = (unsigned int) strtoul (cp, &ep, 10);
|
||||
unsigned int val =
|
||||
(unsigned int) strtoul (cp, &ep, 10);
|
||||
|
||||
if (*cp != '\0' && *ep == '\0') { /* valid number */
|
||||
def_group = val;
|
||||
@@ -378,7 +362,6 @@ static void get_defaults (void)
|
||||
/*
|
||||
* Default HOME filesystem
|
||||
*/
|
||||
|
||||
else if (MATCH (buf, HOME)) {
|
||||
def_home = xstrdup (cp);
|
||||
}
|
||||
@@ -386,15 +369,14 @@ static void get_defaults (void)
|
||||
/*
|
||||
* Default Login Shell command
|
||||
*/
|
||||
|
||||
else if (MATCH (buf, SHELL)) {
|
||||
def_shell = xstrdup (cp);
|
||||
}
|
||||
#ifdef SHADOWPWD
|
||||
|
||||
/*
|
||||
* Default Password Inactive value
|
||||
*/
|
||||
|
||||
else if (MATCH (buf, INACT)) {
|
||||
long val = strtol (cp, &ep, 10);
|
||||
|
||||
@@ -407,7 +389,6 @@ static void get_defaults (void)
|
||||
/*
|
||||
* Default account expiration date
|
||||
*/
|
||||
|
||||
else if (MATCH (buf, EXPIRE)) {
|
||||
def_expire = xstrdup (cp);
|
||||
}
|
||||
@@ -416,7 +397,6 @@ static void get_defaults (void)
|
||||
/*
|
||||
* Default Skeleton information
|
||||
*/
|
||||
|
||||
else if (MATCH (buf, SKEL)) {
|
||||
if (*cp == '\0')
|
||||
cp = SKEL_DIR; /* XXX warning: const */
|
||||
@@ -436,17 +416,6 @@ static void get_defaults (void)
|
||||
|
||||
static void show_defaults (void)
|
||||
{
|
||||
#ifdef SVR4
|
||||
printf (_("group=%s,%u basedir=%s skel=%s\n"),
|
||||
def_gname, (unsigned int) def_group, def_home,
|
||||
def_template);
|
||||
|
||||
printf (_("shell=%s "), def_shell);
|
||||
#ifdef SHADOWPWD
|
||||
printf (_("inactive=%ld expire=%s"), def_inactive, def_expire);
|
||||
#endif
|
||||
printf ("\n");
|
||||
#else /* !SVR4 */
|
||||
printf (_("GROUP=%u\n"), (unsigned int) def_group);
|
||||
printf (_("HOME=%s\n"), def_home);
|
||||
#ifdef SHADOWPWD
|
||||
@@ -455,7 +424,6 @@ static void show_defaults (void)
|
||||
#endif
|
||||
printf (_("SHELL=%s\n"), def_shell);
|
||||
printf (_("SKEL=%s\n"), def_template);
|
||||
#endif /* !SVR4 */
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -481,10 +449,6 @@ static int set_defaults (void)
|
||||
int out_shell = 0;
|
||||
int out_skel = 0;
|
||||
|
||||
#ifdef SVR4
|
||||
int out_gname = 0;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Create a temporary file to copy the new output to.
|
||||
*/
|
||||
@@ -524,14 +488,7 @@ static int set_defaults (void)
|
||||
fprintf (ofp, DGROUP "%u\n",
|
||||
(unsigned int) def_group);
|
||||
out_group++;
|
||||
}
|
||||
#ifdef SVR4
|
||||
else if (!out_gname && MATCH (buf, "defgname=")) {
|
||||
fprintf (ofp, "defgname=%s\n", def_gname);
|
||||
out_gname++;
|
||||
}
|
||||
#endif
|
||||
else if (!out_home && MATCH (buf, HOME)) {
|
||||
} else if (!out_home && MATCH (buf, HOME)) {
|
||||
fprintf (ofp, HOME "%s\n", def_home);
|
||||
out_home++;
|
||||
#ifdef SHADOWPWD
|
||||
@@ -541,9 +498,8 @@ static int set_defaults (void)
|
||||
} else if (!out_expire && MATCH (buf, EXPIRE)) {
|
||||
fprintf (ofp, EXPIRE "%s\n", def_expire);
|
||||
out_expire++;
|
||||
}
|
||||
#endif
|
||||
else if (!out_shell && MATCH (buf, SHELL)) {
|
||||
} else if (!out_shell && MATCH (buf, SHELL)) {
|
||||
fprintf (ofp, SHELL "%s\n", def_shell);
|
||||
out_shell++;
|
||||
} else if (!out_skel && MATCH (buf, SKEL)) {
|
||||
@@ -612,12 +568,16 @@ static int set_defaults (void)
|
||||
}
|
||||
#ifdef SHADOWPWD
|
||||
SYSLOG ((LOG_INFO,
|
||||
"defaults: group=%u, home=%s, inactive=%ld, expire=%s",
|
||||
(unsigned int) def_group, def_home, def_inactive,
|
||||
def_expire));
|
||||
"useradd defaults: GROUP=%u, HOME=%s, SHELL=%s, INACTIVE=%ld, "
|
||||
"EXPIRE=%s, SKEL=%s",
|
||||
(unsigned int) def_group, def_home, def_shell,
|
||||
def_inactive, def_expire, def_template));
|
||||
#else
|
||||
SYSLOG ((LOG_INFO, "defaults: group=%u, home=%s",
|
||||
(unsigned int) def_group, def_home));
|
||||
SYSLOG ((LOG_INFO,
|
||||
"useradd defaults: GROUP=%u, HOME=%s, SHELL=%s, "
|
||||
"SKEL=%s",
|
||||
(unsigned int) def_group, def_home, def_shell,
|
||||
def_template));
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
@@ -735,25 +695,17 @@ static void usage (void)
|
||||
{
|
||||
fprintf (stderr,
|
||||
_
|
||||
("usage: %s\t[-u uid [-o]] [-g group] [-G group,...] \n"),
|
||||
Prog);
|
||||
("Usage: useradd [-u uid [-o]] [-g group] [-G group,...] \n"));
|
||||
fprintf (stderr,
|
||||
_
|
||||
("\t\t[-d home] [-s shell] [-c comment] [-m [-k template]]\n"));
|
||||
fprintf (stderr, "\t\t");
|
||||
(" [-d home] [-s shell] [-c comment] [-m [-k template]]\n"));
|
||||
#ifdef SHADOWPWD
|
||||
fprintf (stderr, _("[-f inactive] [-e expire ] "));
|
||||
fprintf (stderr, _(" [-f inactive] [-e expire]\n"));
|
||||
#endif
|
||||
#ifdef AUTH_METHODS
|
||||
fprintf (stderr, _("[-A program] "));
|
||||
#endif
|
||||
fprintf (stderr, _("[-p passwd] name\n"));
|
||||
|
||||
fprintf (stderr,
|
||||
_(" %s\t-D [-g group] [-b base] [-s shell]\n"),
|
||||
Prog);
|
||||
_(" useradd -D [-g group] [-b base] [-s shell]\n"));
|
||||
#ifdef SHADOWPWD
|
||||
fprintf (stderr, _("\t\t[-f inactive] [-e expire ]\n"));
|
||||
fprintf (stderr, _(" [-f inactive] [-e expire]\n"));
|
||||
#endif
|
||||
|
||||
exit (E_USAGE);
|
||||
@@ -777,18 +729,9 @@ static void new_pwent (struct passwd *pwent)
|
||||
#endif
|
||||
pwent->pw_passwd = (char *) user_pass;
|
||||
|
||||
#ifdef ATT_AGE
|
||||
pwent->pw_age = (char *) "";
|
||||
#endif
|
||||
pwent->pw_uid = user_id;
|
||||
pwent->pw_gid = user_gid;
|
||||
pwent->pw_gecos = (char *) user_comment;
|
||||
#ifdef ATT_COMMENT
|
||||
pwent->pw_comment = (char *) "";
|
||||
#endif
|
||||
#ifdef BSD_QUOTA
|
||||
pwent->pw_quota = 0;
|
||||
#endif
|
||||
pwent->pw_dir = (char *) user_home;
|
||||
pwent->pw_shell = (char *) user_shell;
|
||||
}
|
||||
@@ -1073,77 +1016,6 @@ static void find_new_uid (void)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef AUTH_METHODS
|
||||
/*
|
||||
* convert_auth - convert the argument list to a authentication list
|
||||
*/
|
||||
|
||||
static void convert_auth (char *auths, const char *list)
|
||||
{
|
||||
char *cp, *end;
|
||||
char buf[257];
|
||||
|
||||
/*
|
||||
* Copy each method. DEFAULT is replaced by an encrypted string
|
||||
* if one can be found in the current authentication list.
|
||||
*/
|
||||
|
||||
strcpy (buf, list);
|
||||
auths[0] = '\0';
|
||||
for (cp = buf; cp; cp = end) {
|
||||
if (auths[0])
|
||||
strcat (auths, ";");
|
||||
|
||||
if ((end = strchr (cp, ',')))
|
||||
*end++ = '\0';
|
||||
|
||||
if (strcmp (cp, "DEFAULT") == 0) {
|
||||
strcat (auths, user_pass);
|
||||
} else {
|
||||
strcat (auths, "@");
|
||||
strcat (auths, cp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* valid_auth - check authentication list for validity
|
||||
*/
|
||||
|
||||
static int valid_auth (const char *methods)
|
||||
{
|
||||
char *cp, *end;
|
||||
char buf[257];
|
||||
int default_cnt = 0;
|
||||
|
||||
/*
|
||||
* Cursory checks, length and illegal characters
|
||||
*/
|
||||
|
||||
if ((int) strlen (methods) > 256)
|
||||
return 0;
|
||||
|
||||
if (!VALID (methods))
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* Pick each method apart and check it.
|
||||
*/
|
||||
|
||||
strcpy (buf, methods);
|
||||
for (cp = buf; cp; cp = end) {
|
||||
if ((end = strchr (cp, ',')))
|
||||
*end++ = '\0';
|
||||
|
||||
if (strcmp (cp, "DEFAULT") == 0) {
|
||||
if (default_cnt++ > 0)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
#endif /* AUTH_METHODS */
|
||||
|
||||
/*
|
||||
* process_flags - perform command line argument setting
|
||||
*
|
||||
@@ -1167,18 +1039,6 @@ static void process_flags (int argc, char **argv)
|
||||
while ((arg = getopt (argc, argv, FLAGS)) != EOF) {
|
||||
#undef FLAGS
|
||||
switch (arg) {
|
||||
#ifdef AUTH_METHODS
|
||||
case 'A':
|
||||
if (!valid_auth (optarg)) {
|
||||
fprintf (stderr,
|
||||
_("%s: invalid field `%s'\n"),
|
||||
Prog, optarg);
|
||||
exit (E_BAD_ARG);
|
||||
}
|
||||
auth_arg = optarg;
|
||||
Aflg++;
|
||||
break;
|
||||
#endif
|
||||
case 'b':
|
||||
if (!Dflg)
|
||||
usage ();
|
||||
@@ -1534,13 +1394,6 @@ static void usr_update (void)
|
||||
if (!oflg)
|
||||
find_new_uid ();
|
||||
|
||||
#ifdef AUTH_METHODS
|
||||
if (Aflg) {
|
||||
convert_auth (user_auth, auth_arg);
|
||||
user_pass = user_auth;
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Fill in the password structure with any new fields, making
|
||||
* copies of strings.
|
||||
@@ -1556,32 +1409,10 @@ static void usr_update (void)
|
||||
* happens so we know what we were trying to accomplish.
|
||||
*/
|
||||
|
||||
#ifdef AUTH_METHODS
|
||||
SYSLOG ((LOG_INFO,
|
||||
"new user: name=%s, uid=%u, gid=%u, home=%s, shell=%s, auth=%s",
|
||||
user_name, (unsigned int) user_id, (unsigned int) user_gid,
|
||||
user_home, user_shell, Aflg ? auth_arg : "DEFAULT"));
|
||||
#else
|
||||
SYSLOG ((LOG_INFO,
|
||||
"new user: name=%s, uid=%u, gid=%u, home=%s, shell=%s",
|
||||
user_name, (unsigned int) user_id, (unsigned int) user_gid,
|
||||
user_home, user_shell));
|
||||
#endif
|
||||
|
||||
#ifdef AUTH_METHODS
|
||||
/*
|
||||
* Attempt to add the new user to any authentication programs
|
||||
* which have been requested. Since this is more likely to fail
|
||||
* than the update of the password file, we do this first.
|
||||
*/
|
||||
|
||||
if (Aflg && pw_auth (user_auth, pwent.pw_name, PW_ADD, (char *) 0)) {
|
||||
fprintf (stderr,
|
||||
_("%s: error adding authentication method\n"),
|
||||
Prog);
|
||||
fail_exit (E_PW_UPDATE); /* XXX */
|
||||
}
|
||||
#endif /* AUTH_METHODS */
|
||||
user_name, (unsigned int) user_id,
|
||||
(unsigned int) user_gid, user_home, user_shell));
|
||||
|
||||
/*
|
||||
* Initialize faillog and lastlog entries for this UID in case
|
||||
@@ -1684,11 +1515,7 @@ static void create_home (void)
|
||||
fail_exit (E_HOMEDIR);
|
||||
}
|
||||
chown (user_home, user_id, user_gid);
|
||||
#if 1
|
||||
chmod (user_home, 0777 & ~getdef_num ("UMASK", 077));
|
||||
#else
|
||||
chmod (user_home, 0755);
|
||||
#endif
|
||||
chmod (user_home, 0777 & ~getdef_num ("UMASK", 022));
|
||||
home_added++;
|
||||
}
|
||||
}
|
||||
@@ -1717,6 +1544,7 @@ int main (int argc, char **argv)
|
||||
|
||||
sys_ngroups = sysconf (_SC_NGROUPS_MAX);
|
||||
user_groups = malloc ((1 + sys_ngroups) * sizeof (char *));
|
||||
user_groups[0] = (char *) 0;
|
||||
Prog = Basename (argv[0]);
|
||||
|
||||
setlocale (LC_ALL, "");
|
||||
@@ -1825,8 +1653,13 @@ int main (int argc, char **argv)
|
||||
}
|
||||
|
||||
/*
|
||||
* Do the hard stuff - open the files, create the user entries,
|
||||
* create the home directory, then close and update the files.
|
||||
* Do the hard stuff:
|
||||
* - open the files,
|
||||
* - create the user entries,
|
||||
* - create the home directory,
|
||||
* - create user mail spoll,
|
||||
* - flush nscd caches for passwd and group services,
|
||||
* - then close and update the files.
|
||||
*/
|
||||
|
||||
open_files ();
|
||||
@@ -1855,6 +1688,9 @@ int main (int argc, char **argv)
|
||||
Prog);
|
||||
}
|
||||
|
||||
nscd_flush_cache ("passwd");
|
||||
nscd_flush_cache ("group");
|
||||
|
||||
close_files ();
|
||||
|
||||
#ifdef USE_PAM
|
||||
@@ -1875,4 +1711,5 @@ int main (int argc, char **argv)
|
||||
#endif /* USE_PAM */
|
||||
|
||||
exit (E_SUCCESS);
|
||||
/*NOTREACHED*/}
|
||||
/* NOT REACHED */
|
||||
}
|
||||
|
||||
626
src/userdel.c
626
src/userdel.c
@@ -30,7 +30,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID (PKG_VER "$Id: userdel.c,v 1.21 2002/01/05 15:41:44 kloczek Exp $")
|
||||
RCSID (PKG_VER "$Id: userdel.c,v 1.29 2003/12/17 09:43:30 kloczek Exp $")
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
@@ -38,7 +38,6 @@ RCSID (PKG_VER "$Id: userdel.c,v 1.21 2002/01/05 15:41:44 kloczek Exp $")
|
||||
#include <grp.h>
|
||||
#include <ctype.h>
|
||||
#include <fcntl.h>
|
||||
#include <utmp.h>
|
||||
#ifdef USE_PAM
|
||||
#include <security/pam_appl.h>
|
||||
#include <security/pam_misc.h>
|
||||
@@ -48,12 +47,13 @@ RCSID (PKG_VER "$Id: userdel.c,v 1.21 2002/01/05 15:41:44 kloczek Exp $")
|
||||
#include "defines.h"
|
||||
#include "getdef.h"
|
||||
#include "pwauth.h"
|
||||
#include "nscd.h"
|
||||
/*
|
||||
* exit status values
|
||||
*/
|
||||
#define E_SUCCESS 0
|
||||
#define E_PW_UPDATE 1 /* can't update password file */
|
||||
#define E_USAGE 2 /* bad command syntax */
|
||||
#define E_USAGE 2 /* invalid command syntax */
|
||||
#define E_NOTFOUND 6 /* specified user doesn't exist */
|
||||
#define E_USER_BUSY 8 /* user currently logged in */
|
||||
#define E_GRP_UPDATE 10 /* can't update group file */
|
||||
@@ -85,11 +85,6 @@ extern int sg_dbm_mode;
|
||||
#include "shadowio.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TCFS
|
||||
#include <tcfslib.h>
|
||||
#include "tcfsio.h"
|
||||
#endif
|
||||
|
||||
#ifdef SHADOWGRP
|
||||
#include "sgroupio.h"
|
||||
#endif
|
||||
@@ -126,7 +121,7 @@ static void remove_mailbox (void);
|
||||
|
||||
static void usage (void)
|
||||
{
|
||||
fprintf (stderr, _("usage: %s [-r] name\n"), Prog);
|
||||
fprintf (stderr, _("Usage: %s [-r] name\n"), Prog);
|
||||
exit (E_USAGE);
|
||||
}
|
||||
|
||||
@@ -302,11 +297,6 @@ static void close_files (void)
|
||||
fprintf (stderr,
|
||||
_("%s: cannot rewrite shadow password file\n"),
|
||||
Prog);
|
||||
#endif
|
||||
#ifdef HAVE_TCFS
|
||||
if (!tcfs_close ())
|
||||
fprintf (stderr, _("%s: cannot rewrite TCFS key file\n"),
|
||||
Prog);
|
||||
#endif
|
||||
if (!gr_close ())
|
||||
fprintf (stderr, _("%s: cannot rewrite group file\n"),
|
||||
@@ -325,9 +315,6 @@ static void close_files (void)
|
||||
#ifdef SHADOWPWD
|
||||
if (is_shadow_pwd)
|
||||
(void) spw_unlock ();
|
||||
#endif
|
||||
#ifdef HAVE_TCFS
|
||||
(void) tcfs_unlock ();
|
||||
#endif
|
||||
(void) pw_unlock ();
|
||||
}
|
||||
@@ -348,10 +335,6 @@ static void fail_exit (int code)
|
||||
if (is_shadow_grp)
|
||||
sgr_unlock ();
|
||||
#endif
|
||||
#ifdef HAVE_TCFS
|
||||
(void) tcfs_unlock ();
|
||||
#endif
|
||||
|
||||
exit (code);
|
||||
}
|
||||
|
||||
@@ -386,18 +369,6 @@ static void open_files (void)
|
||||
Prog);
|
||||
fail_exit (E_PW_UPDATE);
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_TCFS
|
||||
if (!tcfs_lock ()) {
|
||||
fprintf (stderr, _("%s: cannot lock TCFS key file\n"),
|
||||
Prog);
|
||||
fail_exit (E_PW_UPDATE);
|
||||
}
|
||||
if (!tcfs_open (O_RDWR)) {
|
||||
fprintf (stderr, _("%s: cannot open TCFS key file\n"),
|
||||
Prog);
|
||||
fail_exit (E_PW_UPDATE);
|
||||
}
|
||||
#endif
|
||||
if (!gr_lock ()) {
|
||||
fprintf (stderr, _("%s: unable to lock group file\n"),
|
||||
@@ -432,111 +403,46 @@ static void open_files (void)
|
||||
|
||||
static void update_user (void)
|
||||
{
|
||||
#if defined(AUTH_METHODS) || defined(NDBM)
|
||||
struct passwd *pwd;
|
||||
#endif
|
||||
#ifdef AUTH_METHODS
|
||||
if (!pw_remove (user_name))
|
||||
fprintf (stderr,
|
||||
_("%s: error deleting password entry\n"), Prog);
|
||||
#ifdef SHADOWPWD
|
||||
struct spwd *spwd;
|
||||
|
||||
if (is_shadow_pwd && (spwd = spw_locate (user_name)) &&
|
||||
spwd->sp_pwdp[0] == '@') {
|
||||
if (pw_auth
|
||||
(spwd->sp_pwdp + 1, user_name, PW_DELETE,
|
||||
(char *) 0)) {
|
||||
SYSLOG ((LOG_ERR,
|
||||
"failed deleting auth `%s' for user `%s'\n",
|
||||
spwd->sp_pwdp + 1, user_name));
|
||||
fprintf (stderr,
|
||||
_("%s: error deleting authentication\n"),
|
||||
Prog);
|
||||
} else {
|
||||
SYSLOG ((LOG_INFO,
|
||||
"delete auth `%s' for user `%s'\n",
|
||||
spwd->sp_pwdp + 1, user_name));
|
||||
}
|
||||
}
|
||||
#endif /* SHADOWPWD */
|
||||
if ((pwd = pw_locate (user_name)) && pwd->pw_passwd[0] == '@') {
|
||||
if (pw_auth
|
||||
(pwd->pw_passwd + 1, user_name, PW_DELETE,
|
||||
(char *) 0)) {
|
||||
SYSLOG ((LOG_ERR,
|
||||
"failed deleting auth `%s' for user `%s'\n",
|
||||
pwd->pw_passwd + 1, user_name));
|
||||
fprintf (stderr,
|
||||
_("%s: error deleting authentication\n"),
|
||||
Prog);
|
||||
} else {
|
||||
SYSLOG ((LOG_INFO,
|
||||
"delete auth `%s' for user `%s'\n",
|
||||
pwd->pw_passwd + 1, user_name);}
|
||||
}
|
||||
#endif /* AUTH_METHODS */
|
||||
if (!pw_remove (user_name))
|
||||
fprintf (stderr,
|
||||
_
|
||||
("%s: error deleting password entry\n"),
|
||||
Prog);
|
||||
#ifdef SHADOWPWD
|
||||
if (is_shadow_pwd && !spw_remove (user_name))
|
||||
fprintf (stderr,
|
||||
_
|
||||
("%s: error deleting shadow password entry\n"),
|
||||
Prog);
|
||||
if (is_shadow_pwd && !spw_remove (user_name))
|
||||
fprintf (stderr,
|
||||
_("%s: error deleting shadow password entry\n"),
|
||||
Prog);
|
||||
#endif
|
||||
#ifdef HAVE_TCFS
|
||||
if (tcfs_locate (user_name)) {
|
||||
if (!tcfs_remove (user_name)) {
|
||||
SYSLOG ((LOG_ERR,
|
||||
"failed deleting TCFS entry for user `%s'\n",
|
||||
user_name));
|
||||
fprintf (stderr,
|
||||
_
|
||||
("%s: error deleting TCFS entry\n"),
|
||||
Prog);}
|
||||
else {
|
||||
SYSLOG ((LOG_INFO,
|
||||
"delete TCFS entry for user `%s'\n",
|
||||
user_name));}
|
||||
}
|
||||
#endif /* HAVE_TCFS */
|
||||
#ifdef NDBM
|
||||
if (pw_dbm_present ()) {
|
||||
if ((pwd = getpwnam (user_name))
|
||||
&& !pw_dbm_remove (pwd))
|
||||
if (pw_dbm_present ()) {
|
||||
if ((pwd = getpwnam (user_name))
|
||||
&& !pw_dbm_remove (pwd))
|
||||
fprintf (stderr,
|
||||
_
|
||||
("%s: error deleting password dbm entry\n"),
|
||||
Prog);
|
||||
/*
|
||||
* If the user's UID is a
|
||||
* duplicate the duplicated
|
||||
* entry needs to be updated
|
||||
* so that a UID match can
|
||||
* be found in the DBM
|
||||
* files.
|
||||
*/
|
||||
for (pw_rewind (), pwd = pw_next (); pwd;
|
||||
pwd = pw_next ()) {
|
||||
if (pwd->pw_uid == user_id) {
|
||||
pw_dbm_update (pwd); break;}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* If the user's UID is a duplicate the duplicated
|
||||
* entry needs to be updated so that a UID match can
|
||||
* be found in the DBM files.
|
||||
*/
|
||||
for (pw_rewind (), pwd = pw_next (); pwd; pwd = pw_next ()) {
|
||||
if (pwd->pw_uid == user_id)
|
||||
pw_dbm_update (pwd);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef SHADOWPWD
|
||||
if (is_shadow_pwd && sp_dbm_present ()
|
||||
&& !sp_dbm_remove (user_name))
|
||||
fprintf (stderr,
|
||||
_
|
||||
("%s: error deleting shadow passwd dbm entry\n"),
|
||||
Prog);
|
||||
if (is_shadow_pwd && sp_dbm_present ()
|
||||
&& !sp_dbm_remove (user_name))
|
||||
fprintf (stderr, _("%s: error deleting shadow passwd dbm entry\n"), Prog);
|
||||
#endif
|
||||
endpwent ();
|
||||
endpwent ();
|
||||
#endif /* NDBM */
|
||||
SYSLOG ((LOG_INFO, "delete user `%s'\n",
|
||||
user_name));}
|
||||
SYSLOG ((LOG_INFO, "delete user `%s'\n", user_name));
|
||||
}
|
||||
|
||||
/*
|
||||
* user_busy - see if user is logged in.
|
||||
@@ -546,29 +452,40 @@ static void update_user (void)
|
||||
* as well (at least when changing username or uid). --marekm
|
||||
*/
|
||||
|
||||
static void user_busy (const char *name, uid_t uid) {
|
||||
struct utmp *utent;
|
||||
static void user_busy (const char *name, uid_t uid)
|
||||
{
|
||||
|
||||
/*
|
||||
* We see if the user is logged in by looking for the user name
|
||||
* in the utmp file.
|
||||
*/
|
||||
setutent (); while ((utent = getutent ())) {
|
||||
/*
|
||||
* We see if the user is logged in by looking for the user name
|
||||
* in the utmp file.
|
||||
*/
|
||||
#if HAVE_UTMPX_H
|
||||
struct utmpx *utent;
|
||||
|
||||
setutxent ();
|
||||
while ((utent = getutxent ())) {
|
||||
#else
|
||||
struct utmp *utent;
|
||||
|
||||
setutent ();
|
||||
while ((utent = getutent ())) {
|
||||
#endif
|
||||
#ifdef USER_PROCESS
|
||||
if (utent->ut_type != USER_PROCESS)
|
||||
if (utent->ut_type != USER_PROCESS)
|
||||
continue;
|
||||
#else
|
||||
if (utent->ut_user[0] == '\0')
|
||||
if (utent->ut_user[0] == '\0')
|
||||
continue;
|
||||
#endif
|
||||
if (strncmp
|
||||
(utent->ut_user, name, sizeof utent->ut_user))
|
||||
if (strncmp (utent->ut_user, name, sizeof utent->ut_user))
|
||||
continue;
|
||||
fprintf (stderr,
|
||||
_
|
||||
("%s: user %s is currently logged in\n"),
|
||||
Prog, name); exit (E_USER_BUSY);}
|
||||
}
|
||||
fprintf (stderr,
|
||||
_
|
||||
("%s: user %s is currently logged in\n"),
|
||||
Prog, name);
|
||||
exit (E_USER_BUSY);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* user_cancel - cancel cron and at jobs
|
||||
@@ -608,249 +525,298 @@ exit 0
|
||||
==========
|
||||
*/
|
||||
|
||||
static void user_cancel (const char *user) {
|
||||
char *cmd;
|
||||
int pid, wpid;
|
||||
int status;
|
||||
if (!(cmd = getdef_str ("USERDEL_CMD")))
|
||||
return; pid = fork (); if (pid == 0) {
|
||||
execl (cmd, cmd, user, (char *) 0);
|
||||
if (errno == ENOENT) {
|
||||
perror (cmd); _exit (127);}
|
||||
else {
|
||||
perror (cmd); _exit (126);}
|
||||
}
|
||||
else
|
||||
if (pid == -1) {
|
||||
perror ("fork"); return;}
|
||||
static void user_cancel (const char *user)
|
||||
{
|
||||
char *cmd;
|
||||
int pid, wpid;
|
||||
int status;
|
||||
|
||||
do {
|
||||
wpid = wait (&status);} while (wpid != pid
|
||||
&& wpid != -1);}
|
||||
if (!(cmd = getdef_str ("USERDEL_CMD")))
|
||||
return;
|
||||
pid = fork ();
|
||||
if (pid == 0) {
|
||||
execl (cmd, cmd, user, (char *) 0);
|
||||
if (errno == ENOENT) {
|
||||
perror (cmd);
|
||||
_exit (127);
|
||||
} else {
|
||||
perror (cmd);
|
||||
_exit (126);
|
||||
}
|
||||
} else if (pid == -1) {
|
||||
perror ("fork");
|
||||
return;
|
||||
}
|
||||
do {
|
||||
wpid = wait (&status);
|
||||
} while (wpid != pid && wpid != -1);
|
||||
}
|
||||
|
||||
#ifdef EXTRA_CHECK_HOME_DIR
|
||||
static int
|
||||
path_prefix (const char *s1, const char *s2) {
|
||||
return (strncmp (s2, s1, strlen (s1)) == 0);}
|
||||
static int path_prefix (const char *s1, const char *s2)
|
||||
{
|
||||
return (strncmp (s2, s1, strlen (s1)) == 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int is_owner (uid_t uid, const char *path) {
|
||||
struct stat st; if (stat (path, &st))
|
||||
return -1; return (st.st_uid == uid);}
|
||||
static int is_owner (uid_t uid, const char *path)
|
||||
{
|
||||
struct stat st;
|
||||
|
||||
if (stat (path, &st))
|
||||
return -1;
|
||||
return (st.st_uid == uid);
|
||||
}
|
||||
|
||||
#ifndef NO_REMOVE_MAILBOX
|
||||
static void remove_mailbox (void) {
|
||||
const char *maildir;
|
||||
char mailfile[1024];
|
||||
int i; maildir = getdef_str ("MAIL_DIR");
|
||||
static void remove_mailbox (void)
|
||||
{
|
||||
const char *maildir;
|
||||
char mailfile[1024];
|
||||
int i;
|
||||
|
||||
maildir = getdef_str ("MAIL_DIR");
|
||||
#ifdef MAIL_SPOOL_DIR
|
||||
if (!maildir && !getdef_str ("MAIL_FILE"))
|
||||
maildir = MAIL_SPOOL_DIR;
|
||||
if (!maildir && !getdef_str ("MAIL_FILE"))
|
||||
maildir = MAIL_SPOOL_DIR;
|
||||
#endif
|
||||
if (!maildir)
|
||||
return;
|
||||
snprintf (mailfile, sizeof mailfile,
|
||||
"%s/%s", maildir, user_name); if (fflg) {
|
||||
unlink (mailfile); /* always remove, ignore errors */
|
||||
return;}
|
||||
i = is_owner (user_id, mailfile); if (i == 0) {
|
||||
fprintf (stderr,
|
||||
_
|
||||
("%s: warning: %s not owned by %s, not removing\n"),
|
||||
Prog, mailfile, user_name); return;}
|
||||
else
|
||||
if (i == -1)
|
||||
return; /* mailbox doesn't exist */
|
||||
if (unlink (mailfile)) {
|
||||
fprintf (stderr,
|
||||
_("%s: warning: can't remove "),
|
||||
Prog); perror (mailfile);}
|
||||
}
|
||||
if (!maildir)
|
||||
return;
|
||||
snprintf (mailfile, sizeof mailfile, "%s/%s", maildir, user_name);
|
||||
if (fflg) {
|
||||
unlink (mailfile); /* always remove, ignore errors */
|
||||
return;
|
||||
}
|
||||
i = is_owner (user_id, mailfile);
|
||||
if (i == 0) {
|
||||
fprintf (stderr,
|
||||
_
|
||||
("%s: warning: %s not owned by %s, not removing\n"),
|
||||
Prog, mailfile, user_name);
|
||||
return;
|
||||
} else if (i == -1)
|
||||
return; /* mailbox doesn't exist */
|
||||
if (unlink (mailfile)) {
|
||||
fprintf (stderr, _("%s: warning: can't remove "), Prog);
|
||||
perror (mailfile);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USE_PAM
|
||||
static struct pam_conv conv = {
|
||||
misc_conv, NULL};
|
||||
static struct pam_conv conv = {
|
||||
misc_conv, NULL
|
||||
};
|
||||
#endif /* USE_PAM */
|
||||
/*
|
||||
* main - userdel command
|
||||
*/
|
||||
int main (int argc, char **argv) {
|
||||
struct passwd *pwd; int arg; int errors = 0;
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
struct passwd *pwd;
|
||||
int arg;
|
||||
int errors = 0;
|
||||
|
||||
#ifdef USE_PAM
|
||||
pam_handle_t * pamh = NULL;
|
||||
struct passwd *pampw; int retval;
|
||||
pam_handle_t *pamh = NULL;
|
||||
struct passwd *pampw;
|
||||
int retval;
|
||||
#endif
|
||||
/*
|
||||
* Get my name so that I can use it to report errors.
|
||||
*/
|
||||
Prog = Basename (argv[0]);
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
/*
|
||||
* Get my name so that I can use it to report errors.
|
||||
*/
|
||||
Prog = Basename (argv[0]);
|
||||
setlocale (LC_ALL, "");
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
#ifdef USE_PAM
|
||||
retval = PAM_SUCCESS;
|
||||
pampw = getpwuid (getuid ()); if (pampw == NULL) {
|
||||
retval = PAM_USER_UNKNOWN;}
|
||||
retval = PAM_SUCCESS;
|
||||
pampw = getpwuid (getuid ());
|
||||
if (pampw == NULL) {
|
||||
retval = PAM_USER_UNKNOWN;
|
||||
}
|
||||
|
||||
if (retval == PAM_SUCCESS) {
|
||||
retval =
|
||||
pam_start ("shadow", pampw->pw_name, &conv,
|
||||
&pamh);}
|
||||
if (retval == PAM_SUCCESS)
|
||||
retval = pam_start ("shadow", pampw->pw_name, &conv,
|
||||
&pamh);
|
||||
|
||||
if (retval == PAM_SUCCESS) {
|
||||
retval = pam_authenticate (pamh, 0);
|
||||
if (retval != PAM_SUCCESS) {
|
||||
pam_end (pamh, retval);}
|
||||
}
|
||||
if (retval == PAM_SUCCESS) {
|
||||
retval = pam_authenticate (pamh, 0);
|
||||
if (retval != PAM_SUCCESS)
|
||||
pam_end (pamh, retval);
|
||||
}
|
||||
|
||||
if (retval == PAM_SUCCESS) {
|
||||
retval = pam_acct_mgmt (pamh, 0);
|
||||
if (retval != PAM_SUCCESS) {
|
||||
pam_end (pamh, retval);}
|
||||
}
|
||||
if (retval == PAM_SUCCESS) {
|
||||
retval = pam_acct_mgmt (pamh, 0);
|
||||
if (retval != PAM_SUCCESS)
|
||||
pam_end (pamh, retval);
|
||||
}
|
||||
|
||||
if (retval != PAM_SUCCESS) {
|
||||
fprintf (stderr,
|
||||
_
|
||||
("%s: PAM authentication failed\n"),
|
||||
Prog); exit (1);}
|
||||
if (retval != PAM_SUCCESS) {
|
||||
fprintf (stderr,
|
||||
_("%s: PAM authentication failed\n"), Prog);
|
||||
exit (1);
|
||||
}
|
||||
#endif /* USE_PAM */
|
||||
|
||||
OPENLOG (Prog);
|
||||
OPENLOG (Prog);
|
||||
#ifdef SHADOWPWD
|
||||
is_shadow_pwd = spw_file_present ();
|
||||
is_shadow_pwd = spw_file_present ();
|
||||
#endif
|
||||
#ifdef SHADOWGRP
|
||||
is_shadow_grp = sgr_file_present ();
|
||||
is_shadow_grp = sgr_file_present ();
|
||||
#endif
|
||||
/*
|
||||
* The open routines for the DBM files don't use read-write
|
||||
* as the mode, so we have to clue them in.
|
||||
*/
|
||||
/*
|
||||
* The open routines for the DBM files don't use read-write as the
|
||||
* mode, so we have to clue them in.
|
||||
*/
|
||||
#ifdef NDBM
|
||||
pw_dbm_mode = O_RDWR;
|
||||
pw_dbm_mode = O_RDWR;
|
||||
#ifdef SHADOWPWD
|
||||
sp_dbm_mode = O_RDWR;
|
||||
sp_dbm_mode = O_RDWR;
|
||||
#endif
|
||||
gr_dbm_mode = O_RDWR;
|
||||
gr_dbm_mode = O_RDWR;
|
||||
#ifdef SHADOWGRP
|
||||
sg_dbm_mode = O_RDWR;
|
||||
sg_dbm_mode = O_RDWR;
|
||||
#endif
|
||||
#endif
|
||||
while ((arg = getopt (argc, argv, "fr")) != EOF) {
|
||||
switch (arg) {
|
||||
case 'f': /* force remove even if not owned by user */
|
||||
fflg++; break; case 'r': /* remove home dir and mailbox */
|
||||
rflg++; break; default:
|
||||
usage ();}
|
||||
}
|
||||
|
||||
if (optind + 1 != argc)
|
||||
while ((arg = getopt (argc, argv, "fr")) != EOF) {
|
||||
switch (arg) {
|
||||
case 'f': /* force remove even if not owned by user */
|
||||
fflg++;
|
||||
break;
|
||||
case 'r': /* remove home dir and mailbox */
|
||||
rflg++;
|
||||
break;
|
||||
default:
|
||||
usage ();
|
||||
/*
|
||||
* Start with a quick check to see if the user exists.
|
||||
*/
|
||||
user_name = argv[argc - 1];
|
||||
if (!(pwd = getpwnam (user_name))) {
|
||||
fprintf (stderr,
|
||||
_("%s: user %s does not exist\n"),
|
||||
Prog, user_name); exit (E_NOTFOUND);}
|
||||
}
|
||||
}
|
||||
|
||||
if (optind + 1 != argc)
|
||||
usage ();
|
||||
/*
|
||||
* Start with a quick check to see if the user exists.
|
||||
*/
|
||||
user_name = argv[argc - 1];
|
||||
if (!(pwd = getpwnam (user_name))) {
|
||||
fprintf (stderr, _("%s: user %s does not exist\n"),
|
||||
Prog, user_name);
|
||||
exit (E_NOTFOUND);
|
||||
}
|
||||
#ifdef USE_NIS
|
||||
|
||||
/*
|
||||
* Now make sure it isn't an NIS user.
|
||||
*/
|
||||
/*
|
||||
* Now make sure it isn't an NIS user.
|
||||
*/
|
||||
|
||||
if (__ispwNIS ()) {
|
||||
char *nis_domain;
|
||||
char *nis_master;
|
||||
fprintf (stderr,
|
||||
_("%s: user %s is a NIS user\n"),
|
||||
Prog, user_name);
|
||||
if (!yp_get_default_domain (&nis_domain)
|
||||
&& !yp_master (nis_domain,
|
||||
"passwd.byname", &nis_master)) {
|
||||
if (__ispwNIS ()) {
|
||||
char *nis_domain;
|
||||
char *nis_master;
|
||||
|
||||
fprintf (stderr,
|
||||
_("%s: user %s is a NIS user\n"),
|
||||
Prog, user_name);
|
||||
if (!yp_get_default_domain (&nis_domain)
|
||||
&& !yp_master (nis_domain,
|
||||
"passwd.byname", &nis_master)) {
|
||||
fprintf (stderr,
|
||||
_("%s: %s is the NIS master\n"),
|
||||
Prog, nis_master);}
|
||||
exit (E_NOTFOUND);}
|
||||
Prog, nis_master);
|
||||
}
|
||||
exit (E_NOTFOUND);
|
||||
}
|
||||
#endif
|
||||
user_id = pwd->pw_uid;
|
||||
user_home = xstrdup (pwd->pw_dir);
|
||||
/*
|
||||
* Check to make certain the user isn't logged in.
|
||||
*/
|
||||
user_busy (user_name, user_id);
|
||||
/*
|
||||
* Do the hard stuff - open the files, create the user entries,
|
||||
* create the home directory, then close and update the files.
|
||||
*/
|
||||
open_files (); update_user (); update_groups ();
|
||||
user_id = pwd->pw_uid;
|
||||
user_home = xstrdup (pwd->pw_dir);
|
||||
/*
|
||||
* Check to make certain the user isn't logged in.
|
||||
*/
|
||||
user_busy (user_name, user_id);
|
||||
/*
|
||||
* Do the hard stuff - open the files, create the user entries,
|
||||
* create the home directory, then close and update the files.
|
||||
*/
|
||||
open_files ();
|
||||
update_user ();
|
||||
update_groups ();
|
||||
|
||||
nscd_flush_cache ("passwd");
|
||||
nscd_flush_cache ("group");
|
||||
#ifdef SHADOWPWD
|
||||
nscd_flush_cache ("shadow");
|
||||
#endif
|
||||
|
||||
#ifndef NO_REMOVE_MAILBOX
|
||||
if (rflg)
|
||||
remove_mailbox ();
|
||||
if (rflg)
|
||||
remove_mailbox ();
|
||||
#endif
|
||||
if (rflg && !fflg
|
||||
&& !is_owner (user_id, user_home)) {
|
||||
fprintf (stderr,
|
||||
_
|
||||
("%s: %s not owned by %s, not removing\n"),
|
||||
Prog, user_home, user_name);
|
||||
rflg = 0; errors++;}
|
||||
if (rflg && !fflg && !is_owner (user_id, user_home)) {
|
||||
fprintf (stderr,
|
||||
_("%s: %s not owned by %s, not removing\n"),
|
||||
Prog, user_home, user_name);
|
||||
rflg = 0;
|
||||
errors++;
|
||||
}
|
||||
|
||||
/* This may be slow, the above should be good enough. */
|
||||
#ifdef EXTRA_CHECK_HOME_DIR
|
||||
if (rflg && !fflg) {
|
||||
/*
|
||||
* For safety, refuse to remove the home directory
|
||||
* if it would result in removing some other user's
|
||||
* home directory. Still not perfect so be careful,
|
||||
* but should prevent accidents if someone has /home
|
||||
* or / as home directory... --marekm
|
||||
*/
|
||||
setpwent (); while ((pwd = getpwent ())) {
|
||||
if (rflg && !fflg) {
|
||||
/*
|
||||
* For safety, refuse to remove the home directory if it
|
||||
* would result in removing some other user's home
|
||||
* directory. Still not perfect so be careful, but should
|
||||
* prevent accidents if someone has /home or / as home
|
||||
* directory... --marekm
|
||||
*/
|
||||
setpwent ();
|
||||
while ((pwd = getpwent ())) {
|
||||
if (strcmp (pwd->pw_name, user_name) == 0)
|
||||
continue; if (path_prefix (user_home, pwd->pw_dir)) {
|
||||
fprintf (stderr,
|
||||
_
|
||||
("%s: not removing directory %s (would remove home of user %s)\n"),
|
||||
Prog, user_home, pwd->pw_name);
|
||||
rflg = 0; errors++; break;}
|
||||
}
|
||||
continue;
|
||||
if (path_prefix (user_home, pwd->pw_dir)) {
|
||||
fprintf (stderr,
|
||||
_
|
||||
("%s: not removing directory %s (would remove home of user %s)\n"),
|
||||
Prog, user_home, pwd->pw_name);
|
||||
rflg = 0;
|
||||
errors++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (rflg) {
|
||||
if (remove_tree (user_home)
|
||||
|| rmdir (user_home)) {
|
||||
if (rflg) {
|
||||
if (remove_tree (user_home)
|
||||
|| rmdir (user_home)) {
|
||||
fprintf (stderr,
|
||||
_
|
||||
("%s: error removing directory %s\n"),
|
||||
Prog, user_home); errors++;}
|
||||
}
|
||||
_("%s: error removing directory %s\n"),
|
||||
Prog, user_home);
|
||||
errors++;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Cancel any crontabs or at jobs. Have to do this before we
|
||||
* remove the entry from /etc/passwd.
|
||||
*/
|
||||
/*
|
||||
* Cancel any crontabs or at jobs. Have to do this before we remove
|
||||
* the entry from /etc/passwd.
|
||||
*/
|
||||
|
||||
user_cancel (user_name); close_files ();
|
||||
user_cancel (user_name);
|
||||
close_files ();
|
||||
#ifdef USE_PAM
|
||||
if (retval == PAM_SUCCESS) {
|
||||
retval = pam_chauthtok (pamh, 0);
|
||||
if (retval != PAM_SUCCESS) {
|
||||
pam_end (pamh, retval);}
|
||||
}
|
||||
if (retval == PAM_SUCCESS) {
|
||||
retval = pam_chauthtok (pamh, 0);
|
||||
if (retval != PAM_SUCCESS)
|
||||
pam_end (pamh, retval);
|
||||
}
|
||||
|
||||
if (retval != PAM_SUCCESS) {
|
||||
fprintf (stderr,
|
||||
_("%s: PAM chauthtok failed\n"),
|
||||
Prog); exit (1);}
|
||||
if (retval != PAM_SUCCESS)
|
||||
fprintf (stderr, _("%s: PAM chauthtok failed\n"), Prog);
|
||||
exit (1);
|
||||
|
||||
if (retval == PAM_SUCCESS)
|
||||
pam_end (pamh, PAM_SUCCESS);
|
||||
if (retval == PAM_SUCCESS)
|
||||
pam_end (pamh, PAM_SUCCESS);
|
||||
#endif /* USE_PAM */
|
||||
exit (errors ? E_HOMEDIR : E_SUCCESS);
|
||||
/*NOTREACHED*/}
|
||||
exit (errors ? E_HOMEDIR : E_SUCCESS);
|
||||
/* NOT REACHED */
|
||||
}
|
||||
|
||||
342
src/usermod.c
342
src/usermod.c
@@ -30,7 +30,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID (PKG_VER "$Id: usermod.c,v 1.25 2002/01/05 15:41:44 kloczek Exp $")
|
||||
RCSID (PKG_VER "$Id: usermod.c,v 1.31 2003/06/30 13:17:51 kloczek Exp $")
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <stdio.h>
|
||||
@@ -55,6 +55,7 @@ RCSID (PKG_VER "$Id: usermod.c,v 1.25 2002/01/05 15:41:44 kloczek Exp $")
|
||||
#include "lastlog_.h"
|
||||
#endif
|
||||
#include "pwauth.h"
|
||||
#include "nscd.h"
|
||||
#include "getdef.h"
|
||||
/*
|
||||
* exit status values
|
||||
@@ -66,12 +67,12 @@ RCSID (PKG_VER "$Id: usermod.c,v 1.25 2002/01/05 15:41:44 kloczek Exp $")
|
||||
#define E_USAGE 2 /* invalid command syntax */
|
||||
#define E_BAD_ARG 3 /* invalid argument to option */
|
||||
#define E_UID_IN_USE 4 /* uid already in use (and no -o) */
|
||||
/* #define E_BAD_PWFILE 5 *//* passwd file contains errors */
|
||||
/* #define E_BAD_PWFILE 5 *//* passwd file contains errors */
|
||||
#define E_NOTFOUND 6 /* specified user/group doesn't exist */
|
||||
#define E_USER_BUSY 8 /* user to modify is logged in */
|
||||
#define E_NAME_IN_USE 9 /* username already in use */
|
||||
#define E_GRP_UPDATE 10 /* can't update group file */
|
||||
/* #define E_NOSPACE 11 *//* insufficient space to move home dir */
|
||||
/* #define E_NOSPACE 11 *//* insufficient space to move home dir */
|
||||
#define E_HOMEDIR 12 /* unable to complete home dir move */
|
||||
#define VALID(s) (strcspn (s, ":\n") == strlen (s))
|
||||
static char *user_name;
|
||||
@@ -95,14 +96,6 @@ static char **user_groups; /* NULL-terminated list */
|
||||
|
||||
static char *Prog;
|
||||
|
||||
#ifdef AUTH_METHODS
|
||||
static char *auth_arg;
|
||||
static char user_auth[BUFSIZ];
|
||||
static int Aflg = 0; /* specify user defined authentication method */
|
||||
#else
|
||||
#define Aflg 0
|
||||
#endif
|
||||
|
||||
static int
|
||||
uflg = 0, /* specify new user ID */
|
||||
oflg = 0, /* permit non-unique user ID to be specified with -u */
|
||||
@@ -169,15 +162,6 @@ static int update_gshadow (void);
|
||||
#endif
|
||||
static int grp_update (void);
|
||||
|
||||
#ifdef AUTH_METHODS
|
||||
static char *get_password (const char *);
|
||||
static void split_auths (char *, char **);
|
||||
static void update_auths (const char *, const char *, char *);
|
||||
static void add_auths (const char *, const char *, char *);
|
||||
static void delete_auths (const char *, const char *, char *);
|
||||
static void convert_auth (char *, const char *, const char *);
|
||||
static int valid_auth (const char *);
|
||||
#endif
|
||||
static long get_number (const char *);
|
||||
static uid_t get_id (const char *);
|
||||
static void process_flags (int, char **);
|
||||
@@ -319,17 +303,14 @@ static void usage (void)
|
||||
{
|
||||
fprintf (stderr,
|
||||
_
|
||||
("usage: %s\t[-u uid [-o]] [-g group] [-G group,...] \n"),
|
||||
("Usage: %s\t[-u uid [-o]] [-g group] [-G group,...] \n"),
|
||||
Prog);
|
||||
fprintf (stderr,
|
||||
_
|
||||
("\t\t[-d home [-m]] [-s shell] [-c comment] [-l new_name]\n"));
|
||||
fprintf (stderr, "\t\t");
|
||||
#ifdef SHADOWPWD
|
||||
fprintf (stderr, _("[-f inactive] [-e expire ] "));
|
||||
#endif
|
||||
#ifdef AUTH_METHODS
|
||||
fprintf (stderr, _("[-A {DEFAULT|program},... ] "));
|
||||
fprintf (stderr, _("[-f inactive] [-e expire] "));
|
||||
#endif
|
||||
fprintf (stderr, _("[-p passwd] [-L|-U] name\n"));
|
||||
exit (E_USAGE);
|
||||
@@ -748,227 +729,6 @@ static int grp_update (void)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#ifdef AUTH_METHODS
|
||||
/*
|
||||
* get_password - locate encrypted password in authentication list
|
||||
*/
|
||||
|
||||
static char *get_password (const char *list)
|
||||
{
|
||||
char *cp, *end;
|
||||
static char buf[257];
|
||||
|
||||
strcpy (buf, list);
|
||||
for (cp = buf; cp; cp = end) {
|
||||
if ((end = strchr (cp, ';')))
|
||||
*end++ = 0;
|
||||
|
||||
if (cp[0] == '@')
|
||||
continue;
|
||||
|
||||
return cp;
|
||||
}
|
||||
return (char *) 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* split_auths - break up comma list into (char *) array
|
||||
*/
|
||||
|
||||
static void split_auths (char *list, char **array)
|
||||
{
|
||||
char *cp, *end;
|
||||
int i = 0;
|
||||
|
||||
for (cp = list; cp; cp = end) {
|
||||
if ((end = strchr (cp, ';')))
|
||||
*end++ = '\0';
|
||||
|
||||
array[i++] = cp;
|
||||
}
|
||||
array[i] = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* update_auths - find list of methods to update
|
||||
*/
|
||||
|
||||
static void update_auths (const char *old, const char *new, char *update)
|
||||
{
|
||||
char oldbuf[257], newbuf[257];
|
||||
char *oldv[32], *newv[32], *updatev[32];
|
||||
int i, j, k;
|
||||
|
||||
strcpy (oldbuf, old);
|
||||
split_auths (oldbuf, oldv);
|
||||
|
||||
strcpy (newbuf, new);
|
||||
split_auths (newbuf, newv);
|
||||
|
||||
for (i = j = k = 0; oldv[i]; i++) {
|
||||
for (j = 0; newv[j]; j++)
|
||||
if (strcmp (oldv[i], newv[j]) != 0)
|
||||
break;
|
||||
|
||||
if (newv[j] != (char *) 0)
|
||||
updatev[k++] = oldv[i];
|
||||
}
|
||||
updatev[k] = 0;
|
||||
|
||||
update[0] = '\0';
|
||||
for (i = 0; updatev[i]; i++) {
|
||||
if (i)
|
||||
strcat (update, ";");
|
||||
|
||||
strcat (update, updatev[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* add_auths - find list of methods to add
|
||||
*/
|
||||
|
||||
static void add_auths (const char *old, const char *new, char *add)
|
||||
{
|
||||
char oldbuf[257], newbuf[257];
|
||||
char *oldv[32], *newv[32], *addv[32];
|
||||
int i, j, k;
|
||||
|
||||
strcpy (oldbuf, old);
|
||||
split_auths (oldbuf, oldv);
|
||||
|
||||
strcpy (newbuf, new);
|
||||
split_auths (newbuf, newv);
|
||||
|
||||
for (i = j = k = 0; newv[i]; i++) {
|
||||
for (j = 0; oldv[j]; j++)
|
||||
if (strcmp (oldv[i], newv[j]) == 0)
|
||||
break;
|
||||
|
||||
if (oldv[j] == (char *) 0)
|
||||
addv[k++] = newv[i];
|
||||
}
|
||||
addv[k] = 0;
|
||||
|
||||
add[0] = '\0';
|
||||
for (i = 0; addv[i]; i++) {
|
||||
if (i)
|
||||
strcat (add, ";");
|
||||
|
||||
strcat (add, addv[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* delete_auths - find list of methods to delete
|
||||
*/
|
||||
|
||||
static void delete_auths (const char *old, const char *new, char *remove)
|
||||
{
|
||||
char oldbuf[257], newbuf[257];
|
||||
char *oldv[32], *newv[32], *removev[32];
|
||||
int i, j, k;
|
||||
|
||||
strcpy (oldbuf, old);
|
||||
split_auths (oldbuf, oldv);
|
||||
|
||||
strcpy (newbuf, new);
|
||||
split_auths (newbuf, newv);
|
||||
|
||||
for (i = j = k = 0; oldv[i]; i++) {
|
||||
for (j = 0; newv[j]; j++)
|
||||
if (strcmp (oldv[i], newv[j]) == 0)
|
||||
break;
|
||||
|
||||
if (newv[j] == (char *) 0)
|
||||
removev[k++] = oldv[i];
|
||||
}
|
||||
removev[k] = 0;
|
||||
|
||||
remove[0] = '\0';
|
||||
for (i = 0; removev[i]; i++) {
|
||||
if (i)
|
||||
strcat (remove, ";");
|
||||
|
||||
strcat (remove, removev[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* convert_auth - convert the argument list to a authentication list
|
||||
*/
|
||||
|
||||
static void
|
||||
convert_auth (char *auths, const char *oldauths, const char *list)
|
||||
{
|
||||
char *cp, *end;
|
||||
char *old;
|
||||
char buf[257];
|
||||
|
||||
/*
|
||||
* Copy each method. DEFAULT is replaced by an encrypted string if
|
||||
* one can be found in the current authentication list.
|
||||
*/
|
||||
|
||||
strcpy (buf, list);
|
||||
auths[0] = '\0';
|
||||
for (cp = buf; cp; cp = end) {
|
||||
if (auths[0])
|
||||
strcat (auths, ";");
|
||||
|
||||
if ((end = strchr (cp, ',')))
|
||||
*end++ = '\0';
|
||||
|
||||
if (strcmp (cp, "DEFAULT") == 0) {
|
||||
if ((old = get_password (oldauths)))
|
||||
strcat (auths, old);
|
||||
else
|
||||
strcat (auths, "!");
|
||||
} else {
|
||||
strcat (auths, "@");
|
||||
strcat (auths, cp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* valid_auth - check authentication list for validity
|
||||
*/
|
||||
|
||||
static int valid_auth (const char *methods)
|
||||
{
|
||||
char *cp, *end;
|
||||
char buf[257];
|
||||
int default_cnt = 0;
|
||||
|
||||
/*
|
||||
* Cursory checks, length and illegal characters
|
||||
*/
|
||||
|
||||
if ((int) strlen (methods) > 256)
|
||||
return 0;
|
||||
|
||||
if (!VALID (methods))
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* Pick each method apart and check it.
|
||||
*/
|
||||
|
||||
strcpy (buf, methods);
|
||||
for (cp = buf; cp; cp = end) {
|
||||
if ((end = strchr (cp, ',')))
|
||||
*end++ = '\0';
|
||||
|
||||
if (strcmp (cp, "DEFAULT") == 0) {
|
||||
if (default_cnt++ > 0)
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
static long get_number (const char *cp)
|
||||
{
|
||||
long val;
|
||||
@@ -1068,18 +828,6 @@ static void process_flags (int argc, char **argv)
|
||||
while ((arg = getopt (argc, argv, FLAGS)) != EOF) {
|
||||
#undef FLAGS
|
||||
switch (arg) {
|
||||
#ifdef AUTH_METHODS
|
||||
case 'A':
|
||||
if (!valid_auth (optarg)) {
|
||||
fprintf (stderr,
|
||||
_("%s: invalid field `%s'\n"),
|
||||
Prog, optarg);
|
||||
exit (E_BAD_ARG);
|
||||
}
|
||||
auth_arg = optarg;
|
||||
Aflg++;
|
||||
break;
|
||||
#endif
|
||||
case 'c':
|
||||
if (!VALID (optarg)) {
|
||||
fprintf (stderr,
|
||||
@@ -1334,10 +1082,6 @@ static void usr_update (void)
|
||||
struct spwd spent;
|
||||
const struct spwd *spwd = NULL;
|
||||
#endif
|
||||
#ifdef AUTH_METHODS
|
||||
char old_auth[BUFSIZ];
|
||||
char auth_buf[BUFSIZ];
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Locate the entry in /etc/passwd, which MUST exist.
|
||||
@@ -1365,71 +1109,7 @@ static void usr_update (void)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef AUTH_METHODS
|
||||
|
||||
#ifdef SHADOWPWD
|
||||
strcpy (old_auth, spwd ? spent.sp_pwdp : pwent.pw_passwd);
|
||||
#else
|
||||
strcpy (old_auth, pwent.pw_passwd);
|
||||
#endif
|
||||
|
||||
if (Aflg)
|
||||
convert_auth (user_auth, old_auth, auth_arg);
|
||||
|
||||
/*
|
||||
* XXX - this code needs some checking, changing the user name with
|
||||
* "usermod -l new old" clears the password for this user :-(. For
|
||||
* now, just don't define AUTH_METHODS and all will be well. Most
|
||||
* programs don't support "administrator defined authentication
|
||||
* methods" and PAM (when done) will be better anyway :-). --marekm
|
||||
*/
|
||||
if (lflg || (Aflg && strcmp (old_auth, user_auth) != 0)) {
|
||||
delete_auths (old_auth, user_auth, auth_buf);
|
||||
if (auth_buf[0] && pw_auth (auth_buf, user_name,
|
||||
PW_DELETE, (char *) 0)) {
|
||||
fprintf (stderr,
|
||||
_
|
||||
("%s: error deleting authentication method\n"),
|
||||
Prog);
|
||||
SYSLOG ((LOG_ERR, "error deleting auth for `%s'",
|
||||
user_name));
|
||||
fail_exit (E_PW_UPDATE);
|
||||
}
|
||||
add_auths (old_auth, user_auth, auth_buf);
|
||||
if (auth_buf[0] == '@' && pw_auth (auth_buf,
|
||||
lflg ? user_newname :
|
||||
user_name, PW_ADD,
|
||||
(char *) 0)) {
|
||||
fprintf (stderr,
|
||||
_
|
||||
("%s: error adding authentication method\n"),
|
||||
Prog);
|
||||
SYSLOG ((LOG_ERR, "error adding auth for `%s'",
|
||||
lflg ? user_newname : user_name));
|
||||
fail_exit (E_PW_UPDATE);
|
||||
}
|
||||
update_auths (old_auth, user_auth, auth_buf);
|
||||
if (lflg && auth_buf[0] == '@' && pw_auth (auth_buf,
|
||||
user_newname,
|
||||
PW_CHANGE,
|
||||
user_name)) {
|
||||
fprintf (stderr,
|
||||
_
|
||||
("%s: error changing authentication method\n"),
|
||||
Prog);
|
||||
SYSLOG ((LOG_ERR, "error changing auth for `%s'",
|
||||
lflg ? user_newname : user_name));
|
||||
fail_exit (E_PW_UPDATE);
|
||||
}
|
||||
#ifdef SHADOWPWD
|
||||
if (spwd)
|
||||
spent.sp_pwdp = user_auth;
|
||||
else
|
||||
#endif
|
||||
pwent.pw_passwd = user_auth;
|
||||
}
|
||||
#endif /* AUTH_METHODS */
|
||||
if (lflg || uflg || gflg || cflg || dflg || sflg || Aflg || pflg
|
||||
if (lflg || uflg || gflg || cflg || dflg || sflg || pflg
|
||||
|| Lflg || Uflg) {
|
||||
if (!pw_update (&pwent)) {
|
||||
fprintf (stderr,
|
||||
@@ -1464,7 +1144,7 @@ static void usr_update (void)
|
||||
#endif
|
||||
}
|
||||
#ifdef SHADOWPWD
|
||||
if (spwd && (lflg || eflg || fflg || Aflg || pflg || Lflg || Uflg)) {
|
||||
if (spwd && (lflg || eflg || fflg || pflg || Lflg || Uflg)) {
|
||||
if (!spw_update (&spent)) {
|
||||
fprintf (stderr,
|
||||
_
|
||||
@@ -1692,6 +1372,7 @@ int main (int argc, char **argv)
|
||||
|
||||
sys_ngroups = sysconf (_SC_NGROUPS_MAX);
|
||||
user_groups = malloc ((1 + sys_ngroups) * sizeof (char *));
|
||||
user_groups[0] = (char *) 0;
|
||||
/*
|
||||
* Get my name so that I can use it to report errors.
|
||||
*/
|
||||
@@ -1769,6 +1450,8 @@ int main (int argc, char **argv)
|
||||
open_files ();
|
||||
|
||||
usr_update ();
|
||||
nscd_flush_cache ("passwd");
|
||||
nscd_flush_cache ("group");
|
||||
|
||||
close_files ();
|
||||
|
||||
@@ -1817,4 +1500,5 @@ int main (int argc, char **argv)
|
||||
#endif /* USE_PAM */
|
||||
|
||||
exit (E_SUCCESS);
|
||||
/*NOTREACHED*/}
|
||||
/* NOT REACHED */
|
||||
}
|
||||
|
||||
15
src/vipw.c
15
src/vipw.c
@@ -23,7 +23,7 @@
|
||||
#include <config.h>
|
||||
|
||||
#include "rcsid.h"
|
||||
RCSID (PKG_VER "$Id: vipw.c,v 1.3 2002/01/05 15:41:44 kloczek Exp $")
|
||||
RCSID (PKG_VER "$Id: vipw.c,v 1.6 2003/06/19 18:11:01 kloczek Exp $")
|
||||
#include "defines.h"
|
||||
#include <errno.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -38,6 +38,7 @@ RCSID (PKG_VER "$Id: vipw.c,v 1.3 2002/01/05 15:41:44 kloczek Exp $")
|
||||
#include "shadowio.h"
|
||||
#include "groupio.h"
|
||||
#include "sgroupio.h"
|
||||
#include "nscd.h"
|
||||
static const char *progname, *filename, *fileeditname;
|
||||
static int filelocked = 0, createedit = 0;
|
||||
static int (*unlock) (void);
|
||||
@@ -150,12 +151,6 @@ vipwedit (const char *file, int (*file_lock) (void),
|
||||
if ((pid = fork ()) == -1)
|
||||
vipwexit ("fork", 1, 1);
|
||||
else if (!pid) {
|
||||
#if 0
|
||||
execlp (editor, editor, fileedit, (char *) 0);
|
||||
fprintf (stderr, "%s: %s: %s\n", progname, editor,
|
||||
strerror (errno));
|
||||
exit (1);
|
||||
#else
|
||||
/* use the system() call to invoke the editor so that it accepts
|
||||
command line args in the EDITOR and VISUAL environment vars */
|
||||
char *buf;
|
||||
@@ -171,7 +166,6 @@ vipwedit (const char *file, int (*file_lock) (void),
|
||||
exit (1);
|
||||
} else
|
||||
exit (0);
|
||||
#endif
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
@@ -265,5 +259,10 @@ int main (int argc, char **argv)
|
||||
vipwedit (GROUP_FILE, gr_lock, gr_unlock);
|
||||
}
|
||||
|
||||
nscd_flush_cache ("passwd");
|
||||
nscd_flush_cache ("group");
|
||||
#ifdef SHADOWPWD
|
||||
nscd_flush_cache ("shadow");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user