diff options
author | Balint Reczey <balint@balintreczey.hu> | 2021-11-07 15:18:49 +0100 |
---|---|---|
committer | Balint Reczey <balint@balintreczey.hu> | 2021-11-07 15:18:49 +0100 |
commit | 749c1780621163ca5108f164861324bafa9e0ae8 (patch) | |
tree | 51001872624a692018c45bf39276df94b603fb19 /libmisc | |
parent | d906ecd3b652d95af6ffb974a2f6669501bb9496 (diff) | |
download | shadow-749c1780621163ca5108f164861324bafa9e0ae8.tar.gz |
New upstream version 4.9upstream/4.9
Diffstat (limited to 'libmisc')
34 files changed, 840 insertions, 765 deletions
diff --git a/libmisc/Makefile.am b/libmisc/Makefile.am index 7f43161f..9766a7ec 100644 --- a/libmisc/Makefile.am +++ b/libmisc/Makefile.am @@ -3,9 +3,9 @@ EXTRA_DIST = .indent.pro xgetXXbyYY.c AM_CPPFLAGS = -I$(top_srcdir)/lib $(ECONF_CPPFLAGS) -noinst_LIBRARIES = libmisc.a +noinst_LTLIBRARIES = libmisc.la -libmisc_a_SOURCES = \ +libmisc_la_SOURCES = \ addgrps.c \ age.c \ audit_help.c \ @@ -74,6 +74,6 @@ libmisc_a_SOURCES = \ yesno.c if WITH_BTRFS -libmisc_a_SOURCES += btrfs.c +libmisc_la_SOURCES += btrfs.c endif diff --git a/libmisc/Makefile.in b/libmisc/Makefile.in index b591961f..e957ddee 100644 --- a/libmisc/Makefile.in +++ b/libmisc/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.16.1 from Makefile.am. +# Makefile.in generated by automake 1.15.1 from Makefile.am. # @configure_input@ -# Copyright (C) 1994-2018 Free Software Foundation, Inc. +# Copyright (C) 1994-2017 Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -91,8 +91,14 @@ host_triplet = @host@ @WITH_BTRFS_TRUE@am__append_1 = btrfs.c subdir = libmisc ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ - $(top_srcdir)/configure.ac +am__aclocal_m4_deps = $(top_srcdir)/m4/gettext.m4 \ + $(top_srcdir)/m4/iconv.m4 $(top_srcdir)/m4/lib-ld.m4 \ + $(top_srcdir)/m4/lib-link.m4 $(top_srcdir)/m4/lib-prefix.m4 \ + $(top_srcdir)/m4/libtool.m4 $(top_srcdir)/m4/ltoptions.m4 \ + $(top_srcdir)/m4/ltsugar.m4 $(top_srcdir)/m4/ltversion.m4 \ + $(top_srcdir)/m4/lt~obsolete.m4 $(top_srcdir)/m4/nls.m4 \ + $(top_srcdir)/m4/po.m4 $(top_srcdir)/m4/progtest.m4 \ + $(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.ac am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) @@ -100,15 +106,9 @@ mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = -LIBRARIES = $(noinst_LIBRARIES) -ARFLAGS = cru -AM_V_AR = $(am__v_AR_@AM_V@) -am__v_AR_ = $(am__v_AR_@AM_DEFAULT_V@) -am__v_AR_0 = @echo " AR " $@; -am__v_AR_1 = -libmisc_a_AR = $(AR) $(ARFLAGS) -libmisc_a_LIBADD = -am__libmisc_a_SOURCES_DIST = addgrps.c age.c audit_help.c basename.c \ +LTLIBRARIES = $(noinst_LTLIBRARIES) +libmisc_la_LIBADD = +am__libmisc_la_SOURCES_DIST = addgrps.c age.c audit_help.c basename.c \ chkname.c chkname.h chowndir.c chowntty.c cleanup.c \ cleanup_group.c cleanup_user.c console.c copydir.c entry.c \ env.c failure.c failure.h find_new_gid.c find_new_uid.c \ @@ -121,31 +121,26 @@ am__libmisc_a_SOURCES_DIST = addgrps.c age.c audit_help.c basename.c \ setupenv.c shell.c strtoday.c sub.c sulog.c ttytype.c tz.c \ ulimit.c user_busy.c utmp.c valid.c xgetpwnam.c xgetpwuid.c \ xgetgrnam.c xgetgrgid.c xgetspnam.c xmalloc.c yesno.c btrfs.c -@WITH_BTRFS_TRUE@am__objects_1 = btrfs.$(OBJEXT) -am_libmisc_a_OBJECTS = addgrps.$(OBJEXT) age.$(OBJEXT) \ - audit_help.$(OBJEXT) basename.$(OBJEXT) chkname.$(OBJEXT) \ - chowndir.$(OBJEXT) chowntty.$(OBJEXT) cleanup.$(OBJEXT) \ - cleanup_group.$(OBJEXT) cleanup_user.$(OBJEXT) \ - console.$(OBJEXT) copydir.$(OBJEXT) entry.$(OBJEXT) \ - env.$(OBJEXT) failure.$(OBJEXT) find_new_gid.$(OBJEXT) \ - find_new_uid.$(OBJEXT) find_new_sub_gids.$(OBJEXT) \ - find_new_sub_uids.$(OBJEXT) getdate.$(OBJEXT) \ - getgr_nam_gid.$(OBJEXT) getrange.$(OBJEXT) gettime.$(OBJEXT) \ - hushed.$(OBJEXT) idmapping.$(OBJEXT) isexpired.$(OBJEXT) \ - limits.$(OBJEXT) list.$(OBJEXT) log.$(OBJEXT) \ - loginprompt.$(OBJEXT) mail.$(OBJEXT) motd.$(OBJEXT) \ - myname.$(OBJEXT) obscure.$(OBJEXT) pam_pass.$(OBJEXT) \ - pam_pass_non_interactive.$(OBJEXT) prefix_flag.$(OBJEXT) \ - pwd2spwd.$(OBJEXT) pwdcheck.$(OBJEXT) pwd_init.$(OBJEXT) \ - remove_tree.$(OBJEXT) rlogin.$(OBJEXT) root_flag.$(OBJEXT) \ - salt.$(OBJEXT) setugid.$(OBJEXT) setupenv.$(OBJEXT) \ - shell.$(OBJEXT) strtoday.$(OBJEXT) sub.$(OBJEXT) \ - sulog.$(OBJEXT) ttytype.$(OBJEXT) tz.$(OBJEXT) \ - ulimit.$(OBJEXT) user_busy.$(OBJEXT) utmp.$(OBJEXT) \ - valid.$(OBJEXT) xgetpwnam.$(OBJEXT) xgetpwuid.$(OBJEXT) \ - xgetgrnam.$(OBJEXT) xgetgrgid.$(OBJEXT) xgetspnam.$(OBJEXT) \ - xmalloc.$(OBJEXT) yesno.$(OBJEXT) $(am__objects_1) -libmisc_a_OBJECTS = $(am_libmisc_a_OBJECTS) +@WITH_BTRFS_TRUE@am__objects_1 = btrfs.lo +am_libmisc_la_OBJECTS = addgrps.lo age.lo audit_help.lo basename.lo \ + chkname.lo chowndir.lo chowntty.lo cleanup.lo cleanup_group.lo \ + cleanup_user.lo console.lo copydir.lo entry.lo env.lo \ + failure.lo find_new_gid.lo find_new_uid.lo \ + find_new_sub_gids.lo find_new_sub_uids.lo getdate.lo \ + getgr_nam_gid.lo getrange.lo gettime.lo hushed.lo idmapping.lo \ + isexpired.lo limits.lo list.lo log.lo loginprompt.lo mail.lo \ + motd.lo myname.lo obscure.lo pam_pass.lo \ + pam_pass_non_interactive.lo prefix_flag.lo pwd2spwd.lo \ + pwdcheck.lo pwd_init.lo remove_tree.lo rlogin.lo root_flag.lo \ + salt.lo setugid.lo setupenv.lo shell.lo strtoday.lo sub.lo \ + sulog.lo ttytype.lo tz.lo ulimit.lo user_busy.lo utmp.lo \ + valid.lo xgetpwnam.lo xgetpwuid.lo xgetgrnam.lo xgetgrgid.lo \ + xgetspnam.lo xmalloc.lo yesno.lo $(am__objects_1) +libmisc_la_OBJECTS = $(am_libmisc_la_OBJECTS) +AM_V_lt = $(am__v_lt_@AM_V@) +am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) +am__v_lt_0 = --silent +am__v_lt_1 = AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false @@ -160,46 +155,10 @@ am__v_at_0 = @ am__v_at_1 = DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp -am__maybe_remake_depfiles = depfiles -am__depfiles_remade = ./$(DEPDIR)/addgrps.Po ./$(DEPDIR)/age.Po \ - ./$(DEPDIR)/audit_help.Po ./$(DEPDIR)/basename.Po \ - ./$(DEPDIR)/btrfs.Po ./$(DEPDIR)/chkname.Po \ - ./$(DEPDIR)/chowndir.Po ./$(DEPDIR)/chowntty.Po \ - ./$(DEPDIR)/cleanup.Po ./$(DEPDIR)/cleanup_group.Po \ - ./$(DEPDIR)/cleanup_user.Po ./$(DEPDIR)/console.Po \ - ./$(DEPDIR)/copydir.Po ./$(DEPDIR)/entry.Po ./$(DEPDIR)/env.Po \ - ./$(DEPDIR)/failure.Po ./$(DEPDIR)/find_new_gid.Po \ - ./$(DEPDIR)/find_new_sub_gids.Po \ - ./$(DEPDIR)/find_new_sub_uids.Po ./$(DEPDIR)/find_new_uid.Po \ - ./$(DEPDIR)/getdate.Po ./$(DEPDIR)/getgr_nam_gid.Po \ - ./$(DEPDIR)/getrange.Po ./$(DEPDIR)/gettime.Po \ - ./$(DEPDIR)/hushed.Po ./$(DEPDIR)/idmapping.Po \ - ./$(DEPDIR)/isexpired.Po ./$(DEPDIR)/limits.Po \ - ./$(DEPDIR)/list.Po ./$(DEPDIR)/log.Po \ - ./$(DEPDIR)/loginprompt.Po ./$(DEPDIR)/mail.Po \ - ./$(DEPDIR)/motd.Po ./$(DEPDIR)/myname.Po \ - ./$(DEPDIR)/obscure.Po ./$(DEPDIR)/pam_pass.Po \ - ./$(DEPDIR)/pam_pass_non_interactive.Po \ - ./$(DEPDIR)/prefix_flag.Po ./$(DEPDIR)/pwd2spwd.Po \ - ./$(DEPDIR)/pwd_init.Po ./$(DEPDIR)/pwdcheck.Po \ - ./$(DEPDIR)/remove_tree.Po ./$(DEPDIR)/rlogin.Po \ - ./$(DEPDIR)/root_flag.Po ./$(DEPDIR)/salt.Po \ - ./$(DEPDIR)/setugid.Po ./$(DEPDIR)/setupenv.Po \ - ./$(DEPDIR)/shell.Po ./$(DEPDIR)/strtoday.Po \ - ./$(DEPDIR)/sub.Po ./$(DEPDIR)/sulog.Po ./$(DEPDIR)/ttytype.Po \ - ./$(DEPDIR)/tz.Po ./$(DEPDIR)/ulimit.Po \ - ./$(DEPDIR)/user_busy.Po ./$(DEPDIR)/utmp.Po \ - ./$(DEPDIR)/valid.Po ./$(DEPDIR)/xgetgrgid.Po \ - ./$(DEPDIR)/xgetgrnam.Po ./$(DEPDIR)/xgetpwnam.Po \ - ./$(DEPDIR)/xgetpwuid.Po ./$(DEPDIR)/xgetspnam.Po \ - ./$(DEPDIR)/xmalloc.Po ./$(DEPDIR)/yesno.Po +am__depfiles_maybe = depfiles am__mv = mv -f COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -AM_V_lt = $(am__v_lt_@AM_V@) -am__v_lt_ = $(am__v_lt_@AM_DEFAULT_V@) -am__v_lt_0 = --silent -am__v_lt_1 = LTCOMPILE = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) \ $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \ @@ -227,8 +186,8 @@ am__v_YACC_ = $(am__v_YACC_@AM_DEFAULT_V@) am__v_YACC_0 = @echo " YACC " $@; am__v_YACC_1 = YLWRAP = $(top_srcdir)/ylwrap -SOURCES = $(libmisc_a_SOURCES) -DIST_SOURCES = $(am__libmisc_a_SOURCES_DIST) +SOURCES = $(libmisc_la_SOURCES) +DIST_SOURCES = $(am__libmisc_la_SOURCES_DIST) am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ @@ -282,7 +241,6 @@ ECONF_CPPFLAGS = @ECONF_CPPFLAGS@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ -GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ GMSGFMT = @GMSGFMT@ GMSGFMT_015 = @GMSGFMT_015@ GREP = @GREP@ @@ -311,9 +269,14 @@ LIBS = @LIBS@ LIBSELINUX = @LIBSELINUX@ LIBSEMANAGE = @LIBSEMANAGE@ LIBSKEY = @LIBSKEY@ +LIBSUBID_ABI = @LIBSUBID_ABI@ +LIBSUBID_ABI_MAJOR = @LIBSUBID_ABI_MAJOR@ +LIBSUBID_ABI_MICRO = @LIBSUBID_ABI_MICRO@ +LIBSUBID_ABI_MINOR = @LIBSUBID_ABI_MINOR@ LIBTCB = @LIBTCB@ LIBTOOL = @LIBTOOL@ LIPO = @LIPO@ +LIYESCRYPT = @LIYESCRYPT@ LN_S = @LN_S@ LTLIBICONV = @LTLIBICONV@ LTLIBINTL = @LTLIBINTL@ @@ -351,7 +314,6 @@ VENDORDIR = @VENDORDIR@ VERSION = @VERSION@ XGETTEXT = @XGETTEXT@ XGETTEXT_015 = @XGETTEXT_015@ -XGETTEXT_EXTRA_OPTIONS = @XGETTEXT_EXTRA_OPTIONS@ XMLCATALOG = @XMLCATALOG@ XML_CATALOG_FILE = @XML_CATALOG_FILE@ XSLTPROC = @XSLTPROC@ @@ -413,8 +375,8 @@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ EXTRA_DIST = .indent.pro xgetXXbyYY.c AM_CPPFLAGS = -I$(top_srcdir)/lib $(ECONF_CPPFLAGS) -noinst_LIBRARIES = libmisc.a -libmisc_a_SOURCES = addgrps.c age.c audit_help.c basename.c chkname.c \ +noinst_LTLIBRARIES = libmisc.la +libmisc_la_SOURCES = addgrps.c age.c audit_help.c basename.c chkname.c \ chkname.h chowndir.c chowntty.c cleanup.c cleanup_group.c \ cleanup_user.c console.c copydir.c entry.c env.c failure.c \ failure.h find_new_gid.c find_new_uid.c find_new_sub_gids.c \ @@ -448,8 +410,8 @@ Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status *config.status*) \ cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ *) \ - echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \ - cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ esac; $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) @@ -461,13 +423,19 @@ $(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps) cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh $(am__aclocal_m4_deps): -clean-noinstLIBRARIES: - -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) +clean-noinstLTLIBRARIES: + -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES) + @list='$(noinst_LTLIBRARIES)'; \ + locs=`for p in $$list; do echo $$p; done | \ + sed 's|^[^/]*$$|.|; s|/[^/]*$$||; s|$$|/so_locations|' | \ + sort -u`; \ + test -z "$$locs" || { \ + echo rm -f $${locs}; \ + rm -f $${locs}; \ + } -libmisc.a: $(libmisc_a_OBJECTS) $(libmisc_a_DEPENDENCIES) $(EXTRA_libmisc_a_DEPENDENCIES) - $(AM_V_at)-rm -f libmisc.a - $(AM_V_AR)$(libmisc_a_AR) libmisc.a $(libmisc_a_OBJECTS) $(libmisc_a_LIBADD) - $(AM_V_at)$(RANLIB) libmisc.a +libmisc.la: $(libmisc_la_OBJECTS) $(libmisc_la_DEPENDENCIES) $(EXTRA_libmisc_la_DEPENDENCIES) + $(AM_V_CCLD)$(LINK) $(libmisc_la_OBJECTS) $(libmisc_la_LIBADD) $(LIBS) mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -475,76 +443,70 @@ mostlyclean-compile: distclean-compile: -rm -f *.tab.c -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/addgrps.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/age.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audit_help.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/basename.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/btrfs.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chkname.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chowndir.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chowntty.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cleanup.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cleanup_group.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cleanup_user.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/console.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/copydir.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/entry.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/env.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/failure.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/find_new_gid.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/find_new_sub_gids.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/find_new_sub_uids.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/find_new_uid.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getdate.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getgr_nam_gid.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getrange.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gettime.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hushed.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/idmapping.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/isexpired.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/limits.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/list.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/loginprompt.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mail.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/motd.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/myname.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/obscure.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pam_pass.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pam_pass_non_interactive.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/prefix_flag.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pwd2spwd.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pwd_init.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pwdcheck.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/remove_tree.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rlogin.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/root_flag.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/salt.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/setugid.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/setupenv.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shell.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strtoday.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sub.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sulog.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ttytype.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tz.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ulimit.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/user_busy.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utmp.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/valid.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xgetgrgid.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xgetgrnam.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xgetpwnam.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xgetpwuid.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xgetspnam.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xmalloc.Po@am__quote@ # am--include-marker -@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/yesno.Po@am__quote@ # am--include-marker - -$(am__depfiles_remade): - @$(MKDIR_P) $(@D) - @echo '# dummy' >$@-t && $(am__mv) $@-t $@ - -am--depfiles: $(am__depfiles_remade) +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/addgrps.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/age.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audit_help.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/basename.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/btrfs.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chkname.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chowndir.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chowntty.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cleanup.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cleanup_group.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cleanup_user.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/console.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/copydir.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/entry.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/env.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/failure.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/find_new_gid.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/find_new_sub_gids.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/find_new_sub_uids.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/find_new_uid.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getdate.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getgr_nam_gid.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getrange.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gettime.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hushed.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/idmapping.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/isexpired.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/limits.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/list.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/log.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/loginprompt.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mail.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/motd.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/myname.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/obscure.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pam_pass.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pam_pass_non_interactive.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/prefix_flag.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pwd2spwd.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pwd_init.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pwdcheck.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/remove_tree.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/rlogin.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/root_flag.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/salt.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/setugid.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/setupenv.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shell.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/strtoday.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sub.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sulog.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ttytype.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tz.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ulimit.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/user_busy.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utmp.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/valid.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xgetgrgid.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xgetgrnam.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xgetpwnam.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xgetpwuid.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xgetspnam.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xmalloc.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/yesno.Plo@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< @@ -628,10 +590,7 @@ cscopelist-am: $(am__tagged_files) distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags -distdir: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) distdir-am - -distdir-am: $(DISTFILES) +distdir: $(DISTFILES) @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ @@ -663,7 +622,7 @@ distdir-am: $(DISTFILES) done check-am: all-am check: check-am -all-am: Makefile $(LIBRARIES) +all-am: Makefile $(LTLIBRARIES) installdirs: install: install-am install-exec: install-exec-am @@ -698,74 +657,11 @@ maintainer-clean-generic: -rm -f getdate.c clean: clean-am -clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \ +clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \ mostlyclean-am distclean: distclean-am - -rm -f ./$(DEPDIR)/addgrps.Po - -rm -f ./$(DEPDIR)/age.Po - -rm -f ./$(DEPDIR)/audit_help.Po - -rm -f ./$(DEPDIR)/basename.Po - -rm -f ./$(DEPDIR)/btrfs.Po - -rm -f ./$(DEPDIR)/chkname.Po - -rm -f ./$(DEPDIR)/chowndir.Po - -rm -f ./$(DEPDIR)/chowntty.Po - -rm -f ./$(DEPDIR)/cleanup.Po - -rm -f ./$(DEPDIR)/cleanup_group.Po - -rm -f ./$(DEPDIR)/cleanup_user.Po - -rm -f ./$(DEPDIR)/console.Po - -rm -f ./$(DEPDIR)/copydir.Po - -rm -f ./$(DEPDIR)/entry.Po - -rm -f ./$(DEPDIR)/env.Po - -rm -f ./$(DEPDIR)/failure.Po - -rm -f ./$(DEPDIR)/find_new_gid.Po - -rm -f ./$(DEPDIR)/find_new_sub_gids.Po - -rm -f ./$(DEPDIR)/find_new_sub_uids.Po - -rm -f ./$(DEPDIR)/find_new_uid.Po - -rm -f ./$(DEPDIR)/getdate.Po - -rm -f ./$(DEPDIR)/getgr_nam_gid.Po - -rm -f ./$(DEPDIR)/getrange.Po - -rm -f ./$(DEPDIR)/gettime.Po - -rm -f ./$(DEPDIR)/hushed.Po - -rm -f ./$(DEPDIR)/idmapping.Po - -rm -f ./$(DEPDIR)/isexpired.Po - -rm -f ./$(DEPDIR)/limits.Po - -rm -f ./$(DEPDIR)/list.Po - -rm -f ./$(DEPDIR)/log.Po - -rm -f ./$(DEPDIR)/loginprompt.Po - -rm -f ./$(DEPDIR)/mail.Po - -rm -f ./$(DEPDIR)/motd.Po - -rm -f ./$(DEPDIR)/myname.Po - -rm -f ./$(DEPDIR)/obscure.Po - -rm -f ./$(DEPDIR)/pam_pass.Po - -rm -f ./$(DEPDIR)/pam_pass_non_interactive.Po - -rm -f ./$(DEPDIR)/prefix_flag.Po - -rm -f ./$(DEPDIR)/pwd2spwd.Po - -rm -f ./$(DEPDIR)/pwd_init.Po - -rm -f ./$(DEPDIR)/pwdcheck.Po - -rm -f ./$(DEPDIR)/remove_tree.Po - -rm -f ./$(DEPDIR)/rlogin.Po - -rm -f ./$(DEPDIR)/root_flag.Po - -rm -f ./$(DEPDIR)/salt.Po - -rm -f ./$(DEPDIR)/setugid.Po - -rm -f ./$(DEPDIR)/setupenv.Po - -rm -f ./$(DEPDIR)/shell.Po - -rm -f ./$(DEPDIR)/strtoday.Po - -rm -f ./$(DEPDIR)/sub.Po - -rm -f ./$(DEPDIR)/sulog.Po - -rm -f ./$(DEPDIR)/ttytype.Po - -rm -f ./$(DEPDIR)/tz.Po - -rm -f ./$(DEPDIR)/ulimit.Po - -rm -f ./$(DEPDIR)/user_busy.Po - -rm -f ./$(DEPDIR)/utmp.Po - -rm -f ./$(DEPDIR)/valid.Po - -rm -f ./$(DEPDIR)/xgetgrgid.Po - -rm -f ./$(DEPDIR)/xgetgrnam.Po - -rm -f ./$(DEPDIR)/xgetpwnam.Po - -rm -f ./$(DEPDIR)/xgetpwuid.Po - -rm -f ./$(DEPDIR)/xgetspnam.Po - -rm -f ./$(DEPDIR)/xmalloc.Po - -rm -f ./$(DEPDIR)/yesno.Po + -rm -rf ./$(DEPDIR) -rm -f Makefile distclean-am: clean-am distclean-compile distclean-generic \ distclean-tags @@ -811,70 +707,7 @@ install-ps-am: installcheck-am: maintainer-clean: maintainer-clean-am - -rm -f ./$(DEPDIR)/addgrps.Po - -rm -f ./$(DEPDIR)/age.Po - -rm -f ./$(DEPDIR)/audit_help.Po - -rm -f ./$(DEPDIR)/basename.Po - -rm -f ./$(DEPDIR)/btrfs.Po - -rm -f ./$(DEPDIR)/chkname.Po - -rm -f ./$(DEPDIR)/chowndir.Po - -rm -f ./$(DEPDIR)/chowntty.Po - -rm -f ./$(DEPDIR)/cleanup.Po - -rm -f ./$(DEPDIR)/cleanup_group.Po - -rm -f ./$(DEPDIR)/cleanup_user.Po - -rm -f ./$(DEPDIR)/console.Po - -rm -f ./$(DEPDIR)/copydir.Po - -rm -f ./$(DEPDIR)/entry.Po - -rm -f ./$(DEPDIR)/env.Po - -rm -f ./$(DEPDIR)/failure.Po - -rm -f ./$(DEPDIR)/find_new_gid.Po - -rm -f ./$(DEPDIR)/find_new_sub_gids.Po - -rm -f ./$(DEPDIR)/find_new_sub_uids.Po - -rm -f ./$(DEPDIR)/find_new_uid.Po - -rm -f ./$(DEPDIR)/getdate.Po - -rm -f ./$(DEPDIR)/getgr_nam_gid.Po - -rm -f ./$(DEPDIR)/getrange.Po - -rm -f ./$(DEPDIR)/gettime.Po - -rm -f ./$(DEPDIR)/hushed.Po - -rm -f ./$(DEPDIR)/idmapping.Po - -rm -f ./$(DEPDIR)/isexpired.Po - -rm -f ./$(DEPDIR)/limits.Po - -rm -f ./$(DEPDIR)/list.Po - -rm -f ./$(DEPDIR)/log.Po - -rm -f ./$(DEPDIR)/loginprompt.Po - -rm -f ./$(DEPDIR)/mail.Po - -rm -f ./$(DEPDIR)/motd.Po - -rm -f ./$(DEPDIR)/myname.Po - -rm -f ./$(DEPDIR)/obscure.Po - -rm -f ./$(DEPDIR)/pam_pass.Po - -rm -f ./$(DEPDIR)/pam_pass_non_interactive.Po - -rm -f ./$(DEPDIR)/prefix_flag.Po - -rm -f ./$(DEPDIR)/pwd2spwd.Po - -rm -f ./$(DEPDIR)/pwd_init.Po - -rm -f ./$(DEPDIR)/pwdcheck.Po - -rm -f ./$(DEPDIR)/remove_tree.Po - -rm -f ./$(DEPDIR)/rlogin.Po - -rm -f ./$(DEPDIR)/root_flag.Po - -rm -f ./$(DEPDIR)/salt.Po - -rm -f ./$(DEPDIR)/setugid.Po - -rm -f ./$(DEPDIR)/setupenv.Po - -rm -f ./$(DEPDIR)/shell.Po - -rm -f ./$(DEPDIR)/strtoday.Po - -rm -f ./$(DEPDIR)/sub.Po - -rm -f ./$(DEPDIR)/sulog.Po - -rm -f ./$(DEPDIR)/ttytype.Po - -rm -f ./$(DEPDIR)/tz.Po - -rm -f ./$(DEPDIR)/ulimit.Po - -rm -f ./$(DEPDIR)/user_busy.Po - -rm -f ./$(DEPDIR)/utmp.Po - -rm -f ./$(DEPDIR)/valid.Po - -rm -f ./$(DEPDIR)/xgetgrgid.Po - -rm -f ./$(DEPDIR)/xgetgrnam.Po - -rm -f ./$(DEPDIR)/xgetpwnam.Po - -rm -f ./$(DEPDIR)/xgetpwuid.Po - -rm -f ./$(DEPDIR)/xgetspnam.Po - -rm -f ./$(DEPDIR)/xmalloc.Po - -rm -f ./$(DEPDIR)/yesno.Po + -rm -rf ./$(DEPDIR) -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic @@ -895,16 +728,16 @@ uninstall-am: .MAKE: install-am install-strip -.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \ - clean-generic clean-libtool clean-noinstLIBRARIES \ - cscopelist-am ctags ctags-am distclean distclean-compile \ - distclean-generic distclean-libtool distclean-tags distdir dvi \ - dvi-am html html-am info info-am install install-am \ - install-data install-data-am install-dvi install-dvi-am \ - install-exec install-exec-am install-html install-html-am \ - install-info install-info-am install-man install-pdf \ - install-pdf-am install-ps install-ps-am install-strip \ - installcheck installcheck-am installdirs maintainer-clean \ +.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-noinstLTLIBRARIES cscopelist-am ctags \ + ctags-am distclean distclean-compile distclean-generic \ + distclean-libtool distclean-tags distdir dvi dvi-am html \ + html-am info info-am install install-am install-data \ + install-data-am install-dvi install-dvi-am install-exec \ + install-exec-am install-html install-html-am install-info \ + install-info-am install-man install-pdf install-pdf-am \ + install-ps install-ps-am install-strip installcheck \ + installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags tags-am uninstall uninstall-am diff --git a/libmisc/addgrps.c b/libmisc/addgrps.c index 40fad994..76c172a5 100644 --- a/libmisc/addgrps.c +++ b/libmisc/addgrps.c @@ -57,6 +57,7 @@ int add_groups (const char *list) bool added; char *token; char buf[1024]; + int ret; if (strlen (list) >= sizeof (buf)) { errno = EINVAL; @@ -93,7 +94,7 @@ int add_groups (const char *list) grp = getgrnam (token); /* local, no need for xgetgrnam */ if (NULL == grp) { - fprintf (stderr, _("Warning: unknown group %s\n"), + fprintf (shadow_logfd, _("Warning: unknown group %s\n"), token); continue; } @@ -105,7 +106,7 @@ int add_groups (const char *list) } if (ngroups >= sysconf (_SC_NGROUPS_MAX)) { - fputs (_("Warning: too many groups\n"), stderr); + fputs (_("Warning: too many groups\n"), shadow_logfd); break; } tmp = (gid_t *) realloc (grouplist, (size_t)(ngroups + 1) * sizeof (GETGROUPS_T)); @@ -120,9 +121,12 @@ int add_groups (const char *list) } if (added) { - return setgroups ((size_t)ngroups, grouplist); + ret = setgroups ((size_t)ngroups, grouplist); + free (grouplist); + return ret; } + free (grouplist); return 0; } #else /* HAVE_SETGROUPS && !USE_PAM */ diff --git a/libmisc/audit_help.c b/libmisc/audit_help.c index 1aadaa37..b4e5f10e 100644 --- a/libmisc/audit_help.c +++ b/libmisc/audit_help.c @@ -59,7 +59,7 @@ void audit_help_open (void) return; } (void) fputs (_("Cannot open audit interface - aborting.\n"), - stderr); + shadow_logfd); exit (EXIT_FAILURE); } } diff --git a/libmisc/chowntty.c b/libmisc/chowntty.c index f6f5dbc5..a42ab622 100644 --- a/libmisc/chowntty.c +++ b/libmisc/chowntty.c @@ -62,6 +62,7 @@ void chown_tty (const struct passwd *info) grent = getgr_nam_gid (getdef_str ("TTYGROUP")); if (NULL != grent) { gid = grent->gr_gid; + gr_free (grent); } else { gid = info->pw_gid; } @@ -75,7 +76,7 @@ void chown_tty (const struct passwd *info) || (fchmod (STDIN_FILENO, (mode_t)getdef_num ("TTYPERM", 0600)) != 0)) { int err = errno; - fprintf (stderr, + fprintf (shadow_logfd, _("Unable to change owner or mode of tty stdin: %s"), strerror (err)); SYSLOG ((LOG_WARN, diff --git a/libmisc/cleanup_group.c b/libmisc/cleanup_group.c index d07adc71..a1233eac 100644 --- a/libmisc/cleanup_group.c +++ b/libmisc/cleanup_group.c @@ -203,7 +203,7 @@ void cleanup_report_del_group_gshadow (void *group_name) void cleanup_unlock_group (unused void *arg) { if (gr_unlock () == 0) { - fprintf (stderr, + fprintf (shadow_logfd, _("%s: failed to unlock %s\n"), Prog, gr_dbname ()); SYSLOG ((LOG_ERR, "failed to unlock %s", gr_dbname ())); @@ -223,7 +223,7 @@ void cleanup_unlock_group (unused void *arg) void cleanup_unlock_gshadow (unused void *arg) { if (sgr_unlock () == 0) { - fprintf (stderr, + fprintf (shadow_logfd, _("%s: failed to unlock %s\n"), Prog, sgr_dbname ()); SYSLOG ((LOG_ERR, "failed to unlock %s", sgr_dbname ())); diff --git a/libmisc/cleanup_user.c b/libmisc/cleanup_user.c index 6e497512..7422846a 100644 --- a/libmisc/cleanup_user.c +++ b/libmisc/cleanup_user.c @@ -120,7 +120,7 @@ void cleanup_report_add_user_shadow (void *user_name) void cleanup_unlock_passwd (unused void *arg) { if (pw_unlock () == 0) { - fprintf (stderr, + fprintf (shadow_logfd, _("%s: failed to unlock %s\n"), Prog, pw_dbname ()); SYSLOG ((LOG_ERR, "failed to unlock %s", pw_dbname ())); @@ -139,7 +139,7 @@ void cleanup_unlock_passwd (unused void *arg) void cleanup_unlock_shadow (unused void *arg) { if (spw_unlock () == 0) { - fprintf (stderr, + fprintf (shadow_logfd, _("%s: failed to unlock %s\n"), Prog, spw_dbname ()); SYSLOG ((LOG_ERR, "failed to unlock %s", spw_dbname ())); diff --git a/libmisc/copydir.c b/libmisc/copydir.c index e6aac6ec..015e1b68 100644 --- a/libmisc/copydir.c +++ b/libmisc/copydir.c @@ -125,11 +125,11 @@ static void error_acl (struct error_context *ctx, const char *fmt, ...) } va_start (ap, fmt); - (void) fprintf (stderr, _("%s: "), Prog); - if (vfprintf (stderr, fmt, ap) != 0) { - (void) fputs (_(": "), stderr); + (void) fprintf (shadow_logfd, _("%s: "), Prog); + if (vfprintf (shadow_logfd, fmt, ap) != 0) { + (void) fputs (_(": "), shadow_logfd); } - (void) fprintf (stderr, "%s\n", strerror (errno)); + (void) fprintf (shadow_logfd, "%s\n", strerror (errno)); va_end (ap); } @@ -248,7 +248,7 @@ int copy_tree (const char *src_root, const char *dst_root, } if (!S_ISDIR (sb.st_mode)) { - fprintf (stderr, + fprintf (shadow_logfd, "%s: %s is not a directory", Prog, src_root); return -1; @@ -484,7 +484,7 @@ static int copy_dir (const char *src, const char *dst, */ #ifdef WITH_SELINUX - if (set_selinux_file_context (dst) != 0) { + if (set_selinux_file_context (dst, S_IFDIR) != 0) { return -1; } #endif /* WITH_SELINUX */ @@ -605,7 +605,7 @@ static int copy_symlink (const char *src, const char *dst, } #ifdef WITH_SELINUX - if (set_selinux_file_context (dst) != 0) { + if (set_selinux_file_context (dst, S_IFLNK) != 0) { free (oldlink); return -1; } @@ -684,7 +684,7 @@ static int copy_special (const char *src, const char *dst, int err = 0; #ifdef WITH_SELINUX - if (set_selinux_file_context (dst) != 0) { + if (set_selinux_file_context (dst, statp->st_mode & S_IFMT) != 0) { return -1; } #endif /* WITH_SELINUX */ @@ -744,7 +744,8 @@ static int copy_file (const char *src, const char *dst, return -1; } #ifdef WITH_SELINUX - if (set_selinux_file_context (dst) != 0) { + if (set_selinux_file_context (dst, S_IFREG) != 0) { + (void) close (ifd); return -1; } #endif /* WITH_SELINUX */ @@ -771,12 +772,16 @@ static int copy_file (const char *src, const char *dst, && (errno != 0)) #endif /* WITH_ATTR */ ) { + if (ofd >= 0) { + (void) close (ofd); + } (void) close (ifd); return -1; } while ((cnt = read (ifd, buf, sizeof buf)) > 0) { if (write (ofd, buf, (size_t)cnt) != cnt) { + (void) close (ofd); (void) close (ifd); return -1; } @@ -786,6 +791,7 @@ static int copy_file (const char *src, const char *dst, #ifdef HAVE_FUTIMES if (futimes (ofd, mt) != 0) { + (void) close (ofd); return -1; } #endif /* HAVE_FUTIMES */ diff --git a/libmisc/env.c b/libmisc/env.c index 0b7c148f..47a55584 100644 --- a/libmisc/env.c +++ b/libmisc/env.c @@ -171,7 +171,7 @@ void addenv (const char *string, /*@null@*/const char *value) } newenvp = __newenvp; } else { - (void) fputs (_("Environment overflow\n"), stderr); + (void) fputs (_("Environment overflow\n"), shadow_logfd); newenvc--; free (newenvp[newenvc]); } diff --git a/libmisc/failure.c b/libmisc/failure.c index f6390a79..a1f3ec79 100644 --- a/libmisc/failure.c +++ b/libmisc/failure.c @@ -98,7 +98,7 @@ void failure (uid_t uid, const char *tty, struct faillog *fl) fl->fail_cnt++; } - strncpy (fl->fail_line, tty, sizeof fl->fail_line); + strncpy (fl->fail_line, tty, sizeof (fl->fail_line) - 1); (void) time (&fl->fail_time); /* diff --git a/libmisc/find_new_gid.c b/libmisc/find_new_gid.c index f93b4a37..d9a0b33f 100644 --- a/libmisc/find_new_gid.c +++ b/libmisc/find_new_gid.c @@ -74,7 +74,7 @@ static int get_ranges (bool sys_group, gid_t *min_id, gid_t *max_id, /* Check that the ranges make sense */ if (*max_id < *min_id) { - (void) fprintf (stderr, + (void) fprintf (shadow_logfd, _("%s: Invalid configuration: SYS_GID_MIN (%lu), " "GID_MIN (%lu), SYS_GID_MAX (%lu)\n"), Prog, (unsigned long) *min_id, @@ -97,7 +97,7 @@ static int get_ranges (bool sys_group, gid_t *min_id, gid_t *max_id, /* Check that the ranges make sense */ if (*max_id < *min_id) { - (void) fprintf (stderr, + (void) fprintf (shadow_logfd, _("%s: Invalid configuration: GID_MIN (%lu), " "GID_MAX (%lu)\n"), Prog, (unsigned long) *min_id, @@ -213,7 +213,7 @@ int find_new_gid (bool sys_group, * more likely to want to stop and address the * issue. */ - fprintf (stderr, + fprintf (shadow_logfd, _("%s: Encountered error attempting to use " "preferred GID: %s\n"), Prog, strerror (result)); @@ -243,7 +243,7 @@ int find_new_gid (bool sys_group, /* Create an array to hold all of the discovered GIDs */ used_gids = malloc (sizeof (bool) * (gid_max +1)); if (NULL == used_gids) { - fprintf (stderr, + fprintf (shadow_logfd, _("%s: failed to allocate memory: %s\n"), Prog, strerror (errno)); return -1; @@ -323,7 +323,7 @@ int find_new_gid (bool sys_group, * */ if (!nospam) { - fprintf (stderr, + fprintf (shadow_logfd, _("%s: Can't get unique system GID (%s). " "Suppressing additional messages.\n"), Prog, strerror (result)); @@ -366,7 +366,7 @@ int find_new_gid (bool sys_group, * */ if (!nospam) { - fprintf (stderr, + fprintf (shadow_logfd, _("%s: Can't get unique system GID (%s). " "Suppressing additional messages.\n"), Prog, strerror (result)); @@ -426,7 +426,7 @@ int find_new_gid (bool sys_group, * */ if (!nospam) { - fprintf (stderr, + fprintf (shadow_logfd, _("%s: Can't get unique GID (%s). " "Suppressing additional messages.\n"), Prog, strerror (result)); @@ -469,7 +469,7 @@ int find_new_gid (bool sys_group, * */ if (!nospam) { - fprintf (stderr, + fprintf (shadow_logfd, _("%s: Can't get unique GID (%s). " "Suppressing additional messages.\n"), Prog, strerror (result)); @@ -488,7 +488,7 @@ int find_new_gid (bool sys_group, } /* The code reached here and found no available IDs in the range */ - fprintf (stderr, + fprintf (shadow_logfd, _("%s: Can't get unique GID (no more available GIDs)\n"), Prog); SYSLOG ((LOG_WARN, "no more available GIDs on the system")); diff --git a/libmisc/find_new_sub_gids.c b/libmisc/find_new_sub_gids.c index ae8a937c..6d33dec6 100644 --- a/libmisc/find_new_sub_gids.c +++ b/libmisc/find_new_sub_gids.c @@ -46,8 +46,7 @@ * * Return 0 on success, -1 if no unused GIDs are available. */ -int find_new_sub_gids (const char *owner, - gid_t *range_start, unsigned long *range_count) +int find_new_sub_gids (gid_t *range_start, unsigned long *range_count) { unsigned long min, max; unsigned long count; @@ -61,7 +60,7 @@ int find_new_sub_gids (const char *owner, count = getdef_ulong ("SUB_GID_COUNT", 65536); if (min > max || count >= max || (min + count - 1) > max) { - (void) fprintf (stderr, + (void) fprintf (shadow_logfd, _("%s: Invalid configuration: SUB_GID_MIN (%lu)," " SUB_GID_MAX (%lu), SUB_GID_COUNT (%lu)\n"), Prog, min, max, count); @@ -70,7 +69,7 @@ int find_new_sub_gids (const char *owner, start = sub_gid_find_free_range(min, max, count); if (start == (gid_t)-1) { - fprintf (stderr, + fprintf (shadow_logfd, _("%s: Can't get unique subordinate GID range\n"), Prog); SYSLOG ((LOG_WARN, "no more available subordinate GIDs on the system")); diff --git a/libmisc/find_new_sub_uids.c b/libmisc/find_new_sub_uids.c index 12cb2d2e..be3a0df8 100644 --- a/libmisc/find_new_sub_uids.c +++ b/libmisc/find_new_sub_uids.c @@ -46,8 +46,7 @@ * * Return 0 on success, -1 if no unused UIDs are available. */ -int find_new_sub_uids (const char *owner, - uid_t *range_start, unsigned long *range_count) +int find_new_sub_uids (uid_t *range_start, unsigned long *range_count) { unsigned long min, max; unsigned long count; @@ -61,7 +60,7 @@ int find_new_sub_uids (const char *owner, count = getdef_ulong ("SUB_UID_COUNT", 65536); if (min > max || count >= max || (min + count - 1) > max) { - (void) fprintf (stderr, + (void) fprintf (shadow_logfd, _("%s: Invalid configuration: SUB_UID_MIN (%lu)," " SUB_UID_MAX (%lu), SUB_UID_COUNT (%lu)\n"), Prog, min, max, count); @@ -70,7 +69,7 @@ int find_new_sub_uids (const char *owner, start = sub_uid_find_free_range(min, max, count); if (start == (uid_t)-1) { - fprintf (stderr, + fprintf (shadow_logfd, _("%s: Can't get unique subordinate UID range\n"), Prog); SYSLOG ((LOG_WARN, "no more available subordinate UIDs on the system")); diff --git a/libmisc/find_new_uid.c b/libmisc/find_new_uid.c index 743cf0a5..30dc2ed6 100644 --- a/libmisc/find_new_uid.c +++ b/libmisc/find_new_uid.c @@ -74,7 +74,7 @@ static int get_ranges (bool sys_user, uid_t *min_id, uid_t *max_id, /* Check that the ranges make sense */ if (*max_id < *min_id) { - (void) fprintf (stderr, + (void) fprintf (shadow_logfd, _("%s: Invalid configuration: SYS_UID_MIN (%lu), " "UID_MIN (%lu), SYS_UID_MAX (%lu)\n"), Prog, (unsigned long) *min_id, @@ -97,7 +97,7 @@ static int get_ranges (bool sys_user, uid_t *min_id, uid_t *max_id, /* Check that the ranges make sense */ if (*max_id < *min_id) { - (void) fprintf (stderr, + (void) fprintf (shadow_logfd, _("%s: Invalid configuration: UID_MIN (%lu), " "UID_MAX (%lu)\n"), Prog, (unsigned long) *min_id, @@ -213,7 +213,7 @@ int find_new_uid(bool sys_user, * more likely to want to stop and address the * issue. */ - fprintf (stderr, + fprintf (shadow_logfd, _("%s: Encountered error attempting to use " "preferred UID: %s\n"), Prog, strerror (result)); @@ -243,7 +243,7 @@ int find_new_uid(bool sys_user, /* Create an array to hold all of the discovered UIDs */ used_uids = malloc (sizeof (bool) * (uid_max +1)); if (NULL == used_uids) { - fprintf (stderr, + fprintf (shadow_logfd, _("%s: failed to allocate memory: %s\n"), Prog, strerror (errno)); return -1; @@ -323,7 +323,7 @@ int find_new_uid(bool sys_user, * */ if (!nospam) { - fprintf (stderr, + fprintf (shadow_logfd, _("%s: Can't get unique system UID (%s). " "Suppressing additional messages.\n"), Prog, strerror (result)); @@ -366,7 +366,7 @@ int find_new_uid(bool sys_user, * */ if (!nospam) { - fprintf (stderr, + fprintf (shadow_logfd, _("%s: Can't get unique system UID (%s). " "Suppressing additional messages.\n"), Prog, strerror (result)); @@ -426,7 +426,7 @@ int find_new_uid(bool sys_user, * */ if (!nospam) { - fprintf (stderr, + fprintf (shadow_logfd, _("%s: Can't get unique UID (%s). " "Suppressing additional messages.\n"), Prog, strerror (result)); @@ -469,7 +469,7 @@ int find_new_uid(bool sys_user, * */ if (!nospam) { - fprintf (stderr, + fprintf (shadow_logfd, _("%s: Can't get unique UID (%s). " "Suppressing additional messages.\n"), Prog, strerror (result)); @@ -488,7 +488,7 @@ int find_new_uid(bool sys_user, } /* The code reached here and found no available IDs in the range */ - fprintf (stderr, + fprintf (shadow_logfd, _("%s: Can't get unique UID (no more available UIDs)\n"), Prog); SYSLOG ((LOG_WARN, "no more available UIDs on the system")); diff --git a/libmisc/getdate.c b/libmisc/getdate.c index b36188f6..390f9efd 100644 --- a/libmisc/getdate.c +++ b/libmisc/getdate.c @@ -1,9 +1,8 @@ -/* A Bison parser, made by GNU Bison 3.4.1. */ +/* A Bison parser, made by GNU Bison 3.0.4. */ /* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2019 Free Software Foundation, - Inc. + Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -41,14 +40,11 @@ define necessary library symbols; they are noted "INFRINGES ON USER NAME SPACE" below. */ -/* Undocumented macros, especially those whose name start with YY_, - are private implementation details. Do not rely on them. */ - /* Identify Bison output. */ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "3.4.1" +#define YYBISON_VERSION "3.0.4" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -65,8 +61,8 @@ -/* First part of user prologue. */ -#line 1 "getdate.y" +/* Copy the first part of user declarations. */ +#line 1 "getdate.y" /* yacc.c:339 */ /* ** Originally written by Steven M. Bellovin <smb@research.att.com> while @@ -237,17 +233,13 @@ static int yyRelSeconds; static int yyRelYear; -#line 241 "getdate.c" +#line 237 "getdate.c" /* yacc.c:339 */ # ifndef YY_NULLPTR -# if defined __cplusplus -# if 201103L <= __cplusplus -# define YY_NULLPTR nullptr -# else -# define YY_NULLPTR 0 -# endif +# if defined __cplusplus && 201103L <= __cplusplus +# define YY_NULLPTR nullptr # else -# define YY_NULLPTR ((void*)0) +# define YY_NULLPTR 0 # endif # endif @@ -311,16 +303,17 @@ extern int yydebug; /* Value type. */ #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED + union YYSTYPE { -#line 172 "getdate.y" +#line 172 "getdate.y" /* yacc.c:355 */ int Number; enum _MERIDIAN Meridian; -#line 322 "getdate.c" - +#line 315 "getdate.c" /* yacc.c:355 */ }; + typedef union YYSTYPE YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define YYSTYPE_IS_DECLARED 1 @@ -333,7 +326,9 @@ int yyparse (void); +/* Copy the second part of user declarations. */ +#line 332 "getdate.c" /* yacc.c:358 */ #ifdef short # undef short @@ -354,13 +349,13 @@ typedef signed char yytype_int8; #ifdef YYTYPE_UINT16 typedef YYTYPE_UINT16 yytype_uint16; #else -typedef unsigned short yytype_uint16; +typedef unsigned short int yytype_uint16; #endif #ifdef YYTYPE_INT16 typedef YYTYPE_INT16 yytype_int16; #else -typedef short yytype_int16; +typedef short int yytype_int16; #endif #ifndef YYSIZE_T @@ -372,7 +367,7 @@ typedef short yytype_int16; # include <stddef.h> /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else -# define YYSIZE_T unsigned +# define YYSIZE_T unsigned int # endif #endif @@ -408,6 +403,15 @@ typedef short yytype_int16; # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) #endif +#if !defined _Noreturn \ + && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) +# if defined _MSC_VER && 1200 <= _MSC_VER +# define _Noreturn __declspec (noreturn) +# else +# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) +# endif +#endif + /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ # define YYUSE(E) ((void) (E)) @@ -415,7 +419,7 @@ typedef short yytype_int16; # define YYUSE(E) /* empty */ #endif -#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ /* Suppress an incorrect diagnostic about yylval being uninitialized. */ # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ _Pragma ("GCC diagnostic push") \ @@ -435,8 +439,6 @@ typedef short yytype_int16; #endif -#define YY_ASSERT(E) ((void) (0 && (E))) - #if ! defined yyoverflow || YYERROR_VERBOSE /* The parser invokes alloca or malloc; define the necessary symbols. */ @@ -579,16 +581,16 @@ union yyalloc /* YYNSTATES -- Number of states. */ #define YYNSTATES 61 +/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned + by yylex, with out-of-bounds checking. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 273 -/* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM - as returned by yylex, with out-of-bounds checking. */ #define YYTRANSLATE(YYX) \ - ((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM - as returned by yylex. */ + as returned by yylex, without out-of-bounds checking. */ static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -780,22 +782,22 @@ static const yytype_uint8 yyr2[] = #define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(Token, Value) \ - do \ - if (yychar == YYEMPTY) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - YYPOPSTACK (yylen); \ - yystate = *yyssp; \ - goto yybackup; \ - } \ - else \ - { \ - yyerror (YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ - while (0) +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ + yyerror (YY_("syntax error: cannot back up")); \ + YYERROR; \ + } \ +while (0) /* Error token number */ #define YYTERROR 1 @@ -835,37 +837,37 @@ do { \ } while (0) -/*-----------------------------------. -| Print this symbol's value on YYO. | -`-----------------------------------*/ +/*----------------------------------------. +| Print this symbol's value on YYOUTPUT. | +`----------------------------------------*/ static void -yy_symbol_value_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep) +yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) { - FILE *yyoutput = yyo; - YYUSE (yyoutput); + FILE *yyo = yyoutput; + YYUSE (yyo); if (!yyvaluep) return; # ifdef YYPRINT if (yytype < YYNTOKENS) - YYPRINT (yyo, yytoknum[yytype], *yyvaluep); + YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); # endif YYUSE (yytype); } -/*---------------------------. -| Print this symbol on YYO. | -`---------------------------*/ +/*--------------------------------. +| Print this symbol on YYOUTPUT. | +`--------------------------------*/ static void -yy_symbol_print (FILE *yyo, int yytype, YYSTYPE const * const yyvaluep) +yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) { - YYFPRINTF (yyo, "%s %s (", + YYFPRINTF (yyoutput, "%s %s (", yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); - yy_symbol_value_print (yyo, yytype, yyvaluep); - YYFPRINTF (yyo, ")"); + yy_symbol_value_print (yyoutput, yytype, yyvaluep); + YYFPRINTF (yyoutput, ")"); } /*------------------------------------------------------------------. @@ -899,7 +901,7 @@ do { \ static void yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) { - unsigned long yylno = yyrline[yyrule]; + unsigned long int yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", @@ -910,7 +912,7 @@ yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) YYFPRINTF (stderr, " $%d = ", yyi + 1); yy_symbol_print (stderr, yystos[yyssp[yyi + 1 - yynrhs]], - &yyvsp[(yyi + 1) - (yynrhs)] + &(yyvsp[(yyi + 1) - (yynrhs)]) ); YYFPRINTF (stderr, "\n"); } @@ -1014,10 +1016,7 @@ yytnamerr (char *yyres, const char *yystr) case '\\': if (*++yyp != '\\') goto do_not_strip_quotes; - else - goto append; - - append: + /* Fall through. */ default: if (yyres) yyres[yyn] = *yyp; @@ -1035,7 +1034,7 @@ yytnamerr (char *yyres, const char *yystr) if (! yyres) return yystrlen (yystr); - return (YYSIZE_T) (yystpcpy (yyres, yystr) - yyres); + return yystpcpy (yyres, yystr) - yyres; } # endif @@ -1113,10 +1112,10 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, yyarg[yycount++] = yytname[yyx]; { YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); - if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) - yysize = yysize1; - else + if (! (yysize <= yysize1 + && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) return 2; + yysize = yysize1; } } } @@ -1128,7 +1127,6 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, case N: \ yyformat = S; \ break - default: /* Avoid compiler warnings. */ YYCASE_(0, YY_("syntax error")); YYCASE_(1, YY_("syntax error, unexpected %s")); YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); @@ -1140,10 +1138,9 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, { YYSIZE_T yysize1 = yysize + yystrlen (yyformat); - if (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM) - yysize = yysize1; - else + if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) return 2; + yysize = yysize1; } if (*yymsg_alloc < yysize) @@ -1269,33 +1266,23 @@ yyparse (void) yychar = YYEMPTY; /* Cause a token to be read. */ goto yysetstate; - /*------------------------------------------------------------. -| yynewstate -- push a new state, which is found in yystate. | +| yynewstate -- Push a new state, which is found in yystate. | `------------------------------------------------------------*/ -yynewstate: + yynewstate: /* In all cases, when you get here, the value and location stacks have just been pushed. So pushing a state here evens the stacks. */ yyssp++; - -/*--------------------------------------------------------------------. -| yynewstate -- set current state (the top of the stack) to yystate. | -`--------------------------------------------------------------------*/ -yysetstate: - YYDPRINTF ((stderr, "Entering state %d\n", yystate)); - YY_ASSERT (0 <= yystate && yystate < YYNSTATES); - *yyssp = (yytype_int16) yystate; + yysetstate: + *yyssp = yystate; if (yyss + yystacksize - 1 <= yyssp) -#if !defined yyoverflow && !defined YYSTACK_RELOCATE - goto yyexhaustedlab; -#else { /* Get the current used size of the three stacks, in elements. */ - YYSIZE_T yysize = (YYSIZE_T) (yyssp - yyss + 1); + YYSIZE_T yysize = yyssp - yyss + 1; -# if defined yyoverflow +#ifdef yyoverflow { /* Give user a chance to reallocate the stack. Use copies of these so that the &'s don't force the real ones into @@ -1311,10 +1298,14 @@ yysetstate: &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), &yystacksize); + yyss = yyss1; yyvs = yyvs1; } -# else /* defined YYSTACK_RELOCATE */ +#else /* no yyoverflow */ +# ifndef YYSTACK_RELOCATE + goto yyexhaustedlab; +# else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) goto yyexhaustedlab; @@ -1330,33 +1321,35 @@ yysetstate: goto yyexhaustedlab; YYSTACK_RELOCATE (yyss_alloc, yyss); YYSTACK_RELOCATE (yyvs_alloc, yyvs); -# undef YYSTACK_RELOCATE +# undef YYSTACK_RELOCATE if (yyss1 != yyssa) YYSTACK_FREE (yyss1); } # endif +#endif /* no yyoverflow */ yyssp = yyss + yysize - 1; yyvsp = yyvs + yysize - 1; YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long) yystacksize)); + (unsigned long int) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) YYABORT; } -#endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */ + + YYDPRINTF ((stderr, "Entering state %d\n", yystate)); if (yystate == YYFINAL) YYACCEPT; goto yybackup; - /*-----------. | yybackup. | `-----------*/ yybackup: + /* Do appropriate processing given the current state. Read a lookahead token if we need one and don't already have one. */ @@ -1414,6 +1407,7 @@ yybackup: YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; YY_IGNORE_MAYBE_UNINITIALIZED_END + goto yynewstate; @@ -1428,7 +1422,7 @@ yydefault: /*-----------------------------. -| yyreduce -- do a reduction. | +| yyreduce -- Do a reduction. | `-----------------------------*/ yyreduce: /* yyn is the number of a rule to reduce with. */ @@ -1448,70 +1442,70 @@ yyreduce: YY_REDUCE_PRINT (yyn); switch (yyn) { - case 4: -#line 192 "getdate.y" + case 4: +#line 192 "getdate.y" /* yacc.c:1646 */ { yyHaveTime++; } -#line 1457 "getdate.c" +#line 1451 "getdate.c" /* yacc.c:1646 */ break; case 5: -#line 195 "getdate.y" +#line 195 "getdate.y" /* yacc.c:1646 */ { yyHaveZone++; } -#line 1465 "getdate.c" +#line 1459 "getdate.c" /* yacc.c:1646 */ break; case 6: -#line 198 "getdate.y" +#line 198 "getdate.y" /* yacc.c:1646 */ { yyHaveDate++; } -#line 1473 "getdate.c" +#line 1467 "getdate.c" /* yacc.c:1646 */ break; case 7: -#line 201 "getdate.y" +#line 201 "getdate.y" /* yacc.c:1646 */ { yyHaveDay++; } -#line 1481 "getdate.c" +#line 1475 "getdate.c" /* yacc.c:1646 */ break; case 8: -#line 204 "getdate.y" +#line 204 "getdate.y" /* yacc.c:1646 */ { yyHaveRel++; } -#line 1489 "getdate.c" +#line 1483 "getdate.c" /* yacc.c:1646 */ break; case 10: -#line 210 "getdate.y" +#line 210 "getdate.y" /* yacc.c:1646 */ { yyHour = (yyvsp[-1].Number); yyMinutes = 0; yySeconds = 0; yyMeridian = (yyvsp[0].Meridian); } -#line 1500 "getdate.c" +#line 1494 "getdate.c" /* yacc.c:1646 */ break; case 11: -#line 216 "getdate.y" +#line 216 "getdate.y" /* yacc.c:1646 */ { yyHour = (yyvsp[-3].Number); yyMinutes = (yyvsp[-1].Number); yySeconds = 0; yyMeridian = (yyvsp[0].Meridian); } -#line 1511 "getdate.c" +#line 1505 "getdate.c" /* yacc.c:1646 */ break; case 12: -#line 222 "getdate.y" +#line 222 "getdate.y" /* yacc.c:1646 */ { yyHour = (yyvsp[-3].Number); yyMinutes = (yyvsp[-1].Number); @@ -1521,22 +1515,22 @@ yyreduce: ? -(yyvsp[0].Number) % 100 + (-(yyvsp[0].Number) / 100) * 60 : - ((yyvsp[0].Number) % 100 + ((yyvsp[0].Number) / 100) * 60)); } -#line 1525 "getdate.c" +#line 1519 "getdate.c" /* yacc.c:1646 */ break; case 13: -#line 231 "getdate.y" +#line 231 "getdate.y" /* yacc.c:1646 */ { yyHour = (yyvsp[-5].Number); yyMinutes = (yyvsp[-3].Number); yySeconds = (yyvsp[-1].Number); yyMeridian = (yyvsp[0].Meridian); } -#line 1536 "getdate.c" +#line 1530 "getdate.c" /* yacc.c:1646 */ break; case 14: -#line 237 "getdate.y" +#line 237 "getdate.y" /* yacc.c:1646 */ { yyHour = (yyvsp[-5].Number); yyMinutes = (yyvsp[-3].Number); @@ -1547,71 +1541,71 @@ yyreduce: ? -(yyvsp[0].Number) % 100 + (-(yyvsp[0].Number) / 100) * 60 : - ((yyvsp[0].Number) % 100 + ((yyvsp[0].Number) / 100) * 60)); } -#line 1551 "getdate.c" +#line 1545 "getdate.c" /* yacc.c:1646 */ break; case 15: -#line 249 "getdate.y" +#line 249 "getdate.y" /* yacc.c:1646 */ { yyTimezone = (yyvsp[0].Number); } -#line 1559 "getdate.c" +#line 1553 "getdate.c" /* yacc.c:1646 */ break; case 16: -#line 252 "getdate.y" +#line 252 "getdate.y" /* yacc.c:1646 */ { yyTimezone = (yyvsp[0].Number) - 60; } -#line 1567 "getdate.c" +#line 1561 "getdate.c" /* yacc.c:1646 */ break; case 17: -#line 256 "getdate.y" +#line 256 "getdate.y" /* yacc.c:1646 */ { yyTimezone = (yyvsp[-1].Number) - 60; } -#line 1575 "getdate.c" +#line 1569 "getdate.c" /* yacc.c:1646 */ break; case 18: -#line 261 "getdate.y" +#line 261 "getdate.y" /* yacc.c:1646 */ { yyDayOrdinal = 1; yyDayNumber = (yyvsp[0].Number); } -#line 1584 "getdate.c" +#line 1578 "getdate.c" /* yacc.c:1646 */ break; case 19: -#line 265 "getdate.y" +#line 265 "getdate.y" /* yacc.c:1646 */ { yyDayOrdinal = 1; yyDayNumber = (yyvsp[-1].Number); } -#line 1593 "getdate.c" +#line 1587 "getdate.c" /* yacc.c:1646 */ break; case 20: -#line 269 "getdate.y" +#line 269 "getdate.y" /* yacc.c:1646 */ { yyDayOrdinal = (yyvsp[-1].Number); yyDayNumber = (yyvsp[0].Number); } -#line 1602 "getdate.c" +#line 1596 "getdate.c" /* yacc.c:1646 */ break; case 21: -#line 275 "getdate.y" +#line 275 "getdate.y" /* yacc.c:1646 */ { yyMonth = (yyvsp[-2].Number); yyDay = (yyvsp[0].Number); } -#line 1611 "getdate.c" +#line 1605 "getdate.c" /* yacc.c:1646 */ break; case 22: -#line 279 "getdate.y" +#line 279 "getdate.y" /* yacc.c:1646 */ { /* Interpret as YYYY/MM/DD if $1 >= 1000, otherwise as MM/DD/YY. The goal in recognizing YYYY/MM/DD is solely to support legacy @@ -1630,71 +1624,71 @@ yyreduce: yyYear = (yyvsp[0].Number); } } -#line 1634 "getdate.c" +#line 1628 "getdate.c" /* yacc.c:1646 */ break; case 23: -#line 297 "getdate.y" +#line 297 "getdate.y" /* yacc.c:1646 */ { /* ISO 8601 format. yyyy-mm-dd. */ yyYear = (yyvsp[-2].Number); yyMonth = -(yyvsp[-1].Number); yyDay = -(yyvsp[0].Number); } -#line 1645 "getdate.c" +#line 1639 "getdate.c" /* yacc.c:1646 */ break; case 24: -#line 303 "getdate.y" +#line 303 "getdate.y" /* yacc.c:1646 */ { /* e.g. 17-JUN-1992. */ yyDay = (yyvsp[-2].Number); yyMonth = (yyvsp[-1].Number); yyYear = -(yyvsp[0].Number); } -#line 1656 "getdate.c" +#line 1650 "getdate.c" /* yacc.c:1646 */ break; case 25: -#line 309 "getdate.y" +#line 309 "getdate.y" /* yacc.c:1646 */ { yyMonth = (yyvsp[-1].Number); yyDay = (yyvsp[0].Number); } -#line 1665 "getdate.c" +#line 1659 "getdate.c" /* yacc.c:1646 */ break; case 26: -#line 313 "getdate.y" +#line 313 "getdate.y" /* yacc.c:1646 */ { yyMonth = (yyvsp[-3].Number); yyDay = (yyvsp[-2].Number); yyYear = (yyvsp[0].Number); } -#line 1675 "getdate.c" +#line 1669 "getdate.c" /* yacc.c:1646 */ break; case 27: -#line 318 "getdate.y" +#line 318 "getdate.y" /* yacc.c:1646 */ { yyMonth = (yyvsp[0].Number); yyDay = (yyvsp[-1].Number); } -#line 1684 "getdate.c" +#line 1678 "getdate.c" /* yacc.c:1646 */ break; case 28: -#line 322 "getdate.y" +#line 322 "getdate.y" /* yacc.c:1646 */ { yyMonth = (yyvsp[-1].Number); yyDay = (yyvsp[-2].Number); yyYear = (yyvsp[0].Number); } -#line 1694 "getdate.c" +#line 1688 "getdate.c" /* yacc.c:1646 */ break; case 29: -#line 329 "getdate.y" +#line 329 "getdate.y" /* yacc.c:1646 */ { yyRelSeconds = -yyRelSeconds; yyRelMinutes = -yyRelMinutes; @@ -1703,155 +1697,155 @@ yyreduce: yyRelMonth = -yyRelMonth; yyRelYear = -yyRelYear; } -#line 1707 "getdate.c" +#line 1701 "getdate.c" /* yacc.c:1646 */ break; case 31: -#line 340 "getdate.y" +#line 340 "getdate.y" /* yacc.c:1646 */ { yyRelYear += (yyvsp[-1].Number) * (yyvsp[0].Number); } -#line 1715 "getdate.c" +#line 1709 "getdate.c" /* yacc.c:1646 */ break; case 32: -#line 343 "getdate.y" +#line 343 "getdate.y" /* yacc.c:1646 */ { yyRelYear += (yyvsp[-1].Number) * (yyvsp[0].Number); } -#line 1723 "getdate.c" +#line 1717 "getdate.c" /* yacc.c:1646 */ break; case 33: -#line 346 "getdate.y" +#line 346 "getdate.y" /* yacc.c:1646 */ { yyRelYear++; } -#line 1731 "getdate.c" +#line 1725 "getdate.c" /* yacc.c:1646 */ break; case 34: -#line 349 "getdate.y" +#line 349 "getdate.y" /* yacc.c:1646 */ { yyRelMonth += (yyvsp[-1].Number) * (yyvsp[0].Number); } -#line 1739 "getdate.c" +#line 1733 "getdate.c" /* yacc.c:1646 */ break; case 35: -#line 352 "getdate.y" +#line 352 "getdate.y" /* yacc.c:1646 */ { yyRelMonth += (yyvsp[-1].Number) * (yyvsp[0].Number); } -#line 1747 "getdate.c" +#line 1741 "getdate.c" /* yacc.c:1646 */ break; case 36: -#line 355 "getdate.y" +#line 355 "getdate.y" /* yacc.c:1646 */ { yyRelMonth++; } -#line 1755 "getdate.c" +#line 1749 "getdate.c" /* yacc.c:1646 */ break; case 37: -#line 358 "getdate.y" +#line 358 "getdate.y" /* yacc.c:1646 */ { yyRelDay += (yyvsp[-1].Number) * (yyvsp[0].Number); } -#line 1763 "getdate.c" +#line 1757 "getdate.c" /* yacc.c:1646 */ break; case 38: -#line 361 "getdate.y" +#line 361 "getdate.y" /* yacc.c:1646 */ { yyRelDay += (yyvsp[-1].Number) * (yyvsp[0].Number); } -#line 1771 "getdate.c" +#line 1765 "getdate.c" /* yacc.c:1646 */ break; case 39: -#line 364 "getdate.y" +#line 364 "getdate.y" /* yacc.c:1646 */ { yyRelDay++; } -#line 1779 "getdate.c" +#line 1773 "getdate.c" /* yacc.c:1646 */ break; case 40: -#line 367 "getdate.y" +#line 367 "getdate.y" /* yacc.c:1646 */ { yyRelHour += (yyvsp[-1].Number) * (yyvsp[0].Number); } -#line 1787 "getdate.c" +#line 1781 "getdate.c" /* yacc.c:1646 */ break; case 41: -#line 370 "getdate.y" +#line 370 "getdate.y" /* yacc.c:1646 */ { yyRelHour += (yyvsp[-1].Number) * (yyvsp[0].Number); } -#line 1795 "getdate.c" +#line 1789 "getdate.c" /* yacc.c:1646 */ break; case 42: -#line 373 "getdate.y" +#line 373 "getdate.y" /* yacc.c:1646 */ { yyRelHour++; } -#line 1803 "getdate.c" +#line 1797 "getdate.c" /* yacc.c:1646 */ break; case 43: -#line 376 "getdate.y" +#line 376 "getdate.y" /* yacc.c:1646 */ { yyRelMinutes += (yyvsp[-1].Number) * (yyvsp[0].Number); } -#line 1811 "getdate.c" +#line 1805 "getdate.c" /* yacc.c:1646 */ break; case 44: -#line 379 "getdate.y" +#line 379 "getdate.y" /* yacc.c:1646 */ { yyRelMinutes += (yyvsp[-1].Number) * (yyvsp[0].Number); } -#line 1819 "getdate.c" +#line 1813 "getdate.c" /* yacc.c:1646 */ break; case 45: -#line 382 "getdate.y" +#line 382 "getdate.y" /* yacc.c:1646 */ { yyRelMinutes++; } -#line 1827 "getdate.c" +#line 1821 "getdate.c" /* yacc.c:1646 */ break; case 46: -#line 385 "getdate.y" +#line 385 "getdate.y" /* yacc.c:1646 */ { yyRelSeconds += (yyvsp[-1].Number) * (yyvsp[0].Number); } -#line 1835 "getdate.c" +#line 1829 "getdate.c" /* yacc.c:1646 */ break; case 47: -#line 388 "getdate.y" +#line 388 "getdate.y" /* yacc.c:1646 */ { yyRelSeconds += (yyvsp[-1].Number) * (yyvsp[0].Number); } -#line 1843 "getdate.c" +#line 1837 "getdate.c" /* yacc.c:1646 */ break; case 48: -#line 391 "getdate.y" +#line 391 "getdate.y" /* yacc.c:1646 */ { yyRelSeconds++; } -#line 1851 "getdate.c" +#line 1845 "getdate.c" /* yacc.c:1646 */ break; case 49: -#line 397 "getdate.y" +#line 397 "getdate.y" /* yacc.c:1646 */ { if ((yyHaveTime != 0) && (yyHaveDate != 0) && (yyHaveRel == 0)) yyYear = (yyvsp[0].Number); @@ -1882,28 +1876,27 @@ yyreduce: } } } -#line 1886 "getdate.c" +#line 1880 "getdate.c" /* yacc.c:1646 */ break; case 50: -#line 430 "getdate.y" +#line 430 "getdate.y" /* yacc.c:1646 */ { (yyval.Meridian) = MER24; } -#line 1894 "getdate.c" +#line 1888 "getdate.c" /* yacc.c:1646 */ break; case 51: -#line 434 "getdate.y" +#line 434 "getdate.y" /* yacc.c:1646 */ { (yyval.Meridian) = (yyvsp[0].Meridian); } -#line 1902 "getdate.c" +#line 1896 "getdate.c" /* yacc.c:1646 */ break; -#line 1906 "getdate.c" - +#line 1900 "getdate.c" /* yacc.c:1646 */ default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -1928,13 +1921,14 @@ yyreduce: /* Now 'shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ - { - const int yylhs = yyr1[yyn] - YYNTOKENS; - const int yyi = yypgoto[yylhs] + *yyssp; - yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp - ? yytable[yyi] - : yydefgoto[yylhs]); - } + + yyn = yyr1[yyn]; + + yystate = yypgoto[yyn - YYNTOKENS] + *yyssp; + if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp) + yystate = yytable[yystate]; + else + yystate = yydefgoto[yyn - YYNTOKENS]; goto yynewstate; @@ -2017,10 +2011,12 @@ yyerrlab: | yyerrorlab -- error raised explicitly by YYERROR. | `---------------------------------------------------*/ yyerrorlab: - /* Pacify compilers when the user code never invokes YYERROR and the - label yyerrorlab therefore never appears in user code. */ - if (0) - YYERROR; + + /* Pacify compilers like GCC when the user code never invokes + YYERROR and the label yyerrorlab therefore never appears in user + code. */ + if (/*CONSTCOND*/ 0) + goto yyerrorlab; /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ @@ -2082,7 +2078,6 @@ yyacceptlab: yyresult = 0; goto yyreturn; - /*-----------------------------------. | yyabortlab -- YYABORT comes here. | `-----------------------------------*/ @@ -2090,7 +2085,6 @@ yyabortlab: yyresult = 1; goto yyreturn; - #if !defined yyoverflow || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | @@ -2101,10 +2095,6 @@ yyexhaustedlab: /* Fall through. */ #endif - -/*-----------------------------------------------------. -| yyreturn -- parsing is finished, return the result. | -`-----------------------------------------------------*/ yyreturn: if (yychar != YYEMPTY) { @@ -2134,7 +2124,7 @@ yyreturn: #endif return yyresult; } -#line 439 "getdate.y" +#line 439 "getdate.y" /* yacc.c:1906 */ /* Month and day table. */ diff --git a/libmisc/gettime.c b/libmisc/gettime.c index 0e25a4b7..e882300c 100644 --- a/libmisc/gettime.c +++ b/libmisc/gettime.c @@ -61,23 +61,23 @@ epoch = strtoull (source_date_epoch, &endptr, 10); if ((errno == ERANGE && (epoch == ULLONG_MAX || epoch == 0)) || (errno != 0 && epoch == 0)) { - fprintf (stderr, + fprintf (shadow_logfd, _("Environment variable $SOURCE_DATE_EPOCH: strtoull: %s\n"), strerror(errno)); } else if (endptr == source_date_epoch) { - fprintf (stderr, + fprintf (shadow_logfd, _("Environment variable $SOURCE_DATE_EPOCH: No digits were found: %s\n"), endptr); } else if (*endptr != '\0') { - fprintf (stderr, + fprintf (shadow_logfd, _("Environment variable $SOURCE_DATE_EPOCH: Trailing garbage: %s\n"), endptr); } else if (epoch > ULONG_MAX) { - fprintf (stderr, + fprintf (shadow_logfd, _("Environment variable $SOURCE_DATE_EPOCH: value must be smaller than or equal to %lu but was found to be: %llu\n"), ULONG_MAX, epoch); } else if (epoch > fallback) { - fprintf (stderr, + fprintf (shadow_logfd, _("Environment variable $SOURCE_DATE_EPOCH: value must be smaller than or equal to the current time (%lu) but was found to be: %llu\n"), fallback, epoch); } else { diff --git a/libmisc/idmapping.c b/libmisc/idmapping.c index aea94936..3324f671 100644 --- a/libmisc/idmapping.c +++ b/libmisc/idmapping.c @@ -36,8 +36,8 @@ #include <stdio.h> #include "prototypes.h" #include "idmapping.h" -#include <sys/prctl.h> #if HAVE_SYS_CAPABILITY_H +#include <sys/prctl.h> #include <sys/capability.h> #endif @@ -47,19 +47,19 @@ struct map_range *get_map_ranges(int ranges, int argc, char **argv) int idx, argidx; if (ranges < 0 || argc < 0) { - fprintf(stderr, "%s: error calculating number of arguments\n", Prog); + fprintf(shadow_logfd, "%s: error calculating number of arguments\n", Prog); return NULL; } if (ranges != ((argc + 2) / 3)) { - fprintf(stderr, "%s: ranges: %u is wrong for argc: %d\n", Prog, ranges, argc); + fprintf(shadow_logfd, "%s: ranges: %u is wrong for argc: %d\n", Prog, ranges, argc); return NULL; } if ((ranges * 3) > argc) { - fprintf(stderr, "ranges: %u argc: %d\n", + fprintf(shadow_logfd, "ranges: %u argc: %d\n", ranges, argc); - fprintf(stderr, + fprintf(shadow_logfd, _( "%s: Not enough arguments to form %u mappings\n"), Prog, ranges); return NULL; @@ -67,7 +67,7 @@ struct map_range *get_map_ranges(int ranges, int argc, char **argv) mappings = calloc(ranges, sizeof(*mappings)); if (!mappings) { - fprintf(stderr, _( "%s: Memory allocation failure\n"), + fprintf(shadow_logfd, _( "%s: Memory allocation failure\n"), Prog); exit(EXIT_FAILURE); } @@ -88,24 +88,24 @@ struct map_range *get_map_ranges(int ranges, int argc, char **argv) return NULL; } if (ULONG_MAX - mapping->upper <= mapping->count || ULONG_MAX - mapping->lower <= mapping->count) { - fprintf(stderr, _( "%s: subuid overflow detected.\n"), Prog); + fprintf(shadow_logfd, _( "%s: subuid overflow detected.\n"), Prog); exit(EXIT_FAILURE); } if (mapping->upper > UINT_MAX || mapping->lower > UINT_MAX || mapping->count > UINT_MAX) { - fprintf(stderr, _( "%s: subuid overflow detected.\n"), Prog); + fprintf(shadow_logfd, _( "%s: subuid overflow detected.\n"), Prog); exit(EXIT_FAILURE); } if (mapping->lower + mapping->count > UINT_MAX || mapping->upper + mapping->count > UINT_MAX) { - fprintf(stderr, _( "%s: subuid overflow detected.\n"), Prog); + fprintf(shadow_logfd, _( "%s: subuid overflow detected.\n"), Prog); exit(EXIT_FAILURE); } if (mapping->lower + mapping->count < mapping->lower || mapping->upper + mapping->count < mapping->upper) { /* this one really shouldn't be possible given previous checks */ - fprintf(stderr, _( "%s: subuid overflow detected.\n"), Prog); + fprintf(shadow_logfd, _( "%s: subuid overflow detected.\n"), Prog); exit(EXIT_FAILURE); } } @@ -123,6 +123,25 @@ struct map_range *get_map_ranges(int ranges, int argc, char **argv) */ #define ULONG_DIGITS ((((sizeof(unsigned long) * CHAR_BIT) + 9)/10)*3) +#if HAVE_SYS_CAPABILITY_H +static inline bool maps_lower_root(int cap, int ranges, struct map_range *mappings) +{ + int idx; + struct map_range *mapping; + + if (cap != CAP_SETUID) + return false; + + mapping = mappings; + for (idx = 0; idx < ranges; idx++, mapping++) { + if (mapping->lower == 0) + return true; + } + + return false; +} +#endif + /* * The ruid refers to the caller's uid and is used to reset the effective uid * back to the callers real uid. @@ -157,19 +176,19 @@ void write_mapping(int proc_dir_fd, int ranges, struct map_range *mappings, } else if (strcmp(map_file, "gid_map") == 0) { cap = CAP_SETGID; } else { - fprintf(stderr, _("%s: Invalid map file %s specified\n"), Prog, map_file); + fprintf(shadow_logfd, _("%s: Invalid map file %s specified\n"), Prog, map_file); exit(EXIT_FAILURE); } /* Align setuid- and fscaps-based new{g,u}idmap behavior. */ if (geteuid() == 0 && geteuid() != ruid) { if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0) < 0) { - fprintf(stderr, _("%s: Could not prctl(PR_SET_KEEPCAPS)\n"), Prog); + fprintf(shadow_logfd, _("%s: Could not prctl(PR_SET_KEEPCAPS)\n"), Prog); exit(EXIT_FAILURE); } if (seteuid(ruid) < 0) { - fprintf(stderr, _("%s: Could not seteuid to %d\n"), Prog, ruid); + fprintf(shadow_logfd, _("%s: Could not seteuid to %d\n"), Prog, ruid); exit(EXIT_FAILURE); } } @@ -177,9 +196,15 @@ void write_mapping(int proc_dir_fd, int ranges, struct map_range *mappings, /* Lockdown new{g,u}idmap by dropping all unneeded capabilities. */ memset(data, 0, sizeof(data)); data[0].effective = CAP_TO_MASK(cap); + /* + * When uid 0 from the ancestor userns is supposed to be mapped into + * the child userns we need to retain CAP_SETFCAP. + */ + if (maps_lower_root(cap, ranges, mappings)) + data[0].effective |= CAP_TO_MASK(CAP_SETFCAP); data[0].permitted = data[0].effective; if (capset(&hdr, data) < 0) { - fprintf(stderr, _("%s: Could not set caps\n"), Prog); + fprintf(shadow_logfd, _("%s: Could not set caps\n"), Prog); exit(EXIT_FAILURE); } #endif @@ -197,7 +222,7 @@ void write_mapping(int proc_dir_fd, int ranges, struct map_range *mappings, mapping->lower, mapping->count); if ((written <= 0) || (written >= (bufsize - (pos - buf)))) { - fprintf(stderr, _("%s: snprintf failed!\n"), Prog); + fprintf(shadow_logfd, _("%s: snprintf failed!\n"), Prog); exit(EXIT_FAILURE); } pos += written; @@ -206,14 +231,15 @@ void write_mapping(int proc_dir_fd, int ranges, struct map_range *mappings, /* Write the mapping to the mapping file */ fd = openat(proc_dir_fd, map_file, O_WRONLY); if (fd < 0) { - fprintf(stderr, _("%s: open of %s failed: %s\n"), + fprintf(shadow_logfd, _("%s: open of %s failed: %s\n"), Prog, map_file, strerror(errno)); exit(EXIT_FAILURE); } if (write(fd, buf, pos - buf) != (pos - buf)) { - fprintf(stderr, _("%s: write to %s failed: %s\n"), + fprintf(shadow_logfd, _("%s: write to %s failed: %s\n"), Prog, map_file, strerror(errno)); exit(EXIT_FAILURE); } close(fd); + free(buf); } diff --git a/libmisc/idmapping.h b/libmisc/idmapping.h index 3f32db68..1a8efe68 100644 --- a/libmisc/idmapping.h +++ b/libmisc/idmapping.h @@ -40,5 +40,7 @@ extern struct map_range *get_map_ranges(int ranges, int argc, char **argv); extern void write_mapping(int proc_dir_fd, int ranges, struct map_range *mappings, const char *map_file, uid_t ruid); +extern void nss_init(char *nsswitch_path); + #endif /* _ID_MAPPING_H_ */ diff --git a/libmisc/limits.c b/libmisc/limits.c index f40e1716..31f738da 100644 --- a/libmisc/limits.c +++ b/libmisc/limits.c @@ -548,7 +548,7 @@ void setup_limits (const struct passwd *info) #ifdef LIMITS if (info->pw_uid != 0) { if ((setup_user_limits (info->pw_name) & LOGIN_ERROR_LOGIN) != 0) { - (void) fputs (_("Too many logins.\n"), stderr); + (void) fputs (_("Too many logins.\n"), shadow_logfd); (void) sleep (2); /* XXX: Should be FAIL_DELAY */ exit (EXIT_FAILURE); } diff --git a/libmisc/list.c b/libmisc/list.c index 2da734a7..8837fa12 100644 --- a/libmisc/list.c +++ b/libmisc/list.c @@ -241,6 +241,7 @@ bool is_on_list (char *const *list, const char *member) if ('\0' == *members) { *array = (char *) 0; + free (members); return array; } diff --git a/libmisc/log.c b/libmisc/log.c index eb84859e..68a9d7e2 100644 --- a/libmisc/log.c +++ b/libmisc/log.c @@ -100,9 +100,9 @@ void dolastlog ( ll_time = newlog.ll_time; (void) time (&ll_time); newlog.ll_time = ll_time; - strncpy (newlog.ll_line, line, sizeof newlog.ll_line); + strncpy (newlog.ll_line, line, sizeof (newlog.ll_line) - 1); #if HAVE_LL_HOST - strncpy (newlog.ll_host, host, sizeof newlog.ll_host); + strncpy (newlog.ll_host, host, sizeof (newlog.ll_host) - 1); #endif if ( (lseek (fd, offset, SEEK_SET) != offset) || (write (fd, (const void *) &newlog, sizeof newlog) != (ssize_t) sizeof newlog) diff --git a/libmisc/myname.c b/libmisc/myname.c index 05efdad3..e1b7f702 100644 --- a/libmisc/myname.c +++ b/libmisc/myname.c @@ -62,6 +62,9 @@ if ((NULL != pw) && (pw->pw_uid == ruid)) { return pw; } + if (NULL != pw) { + pw_free (pw); + } } return xgetpwuid (ruid); diff --git a/libmisc/obscure.c b/libmisc/obscure.c index 15da7603..dc69f768 100644 --- a/libmisc/obscure.c +++ b/libmisc/obscure.c @@ -272,6 +272,9 @@ static /*@observer@*//*@null@*/const char *obscure_msg ( #ifdef USE_BCRYPT || (strcmp (result, "BCRYPT") == 0) #endif +#ifdef USE_YESCRYPT + || (strcmp (result, "YESCRYPT") == 0) +#endif ) { return NULL; } diff --git a/libmisc/pam_pass.c b/libmisc/pam_pass.c index a89bb2c5..58a3d3f6 100644 --- a/libmisc/pam_pass.c +++ b/libmisc/pam_pass.c @@ -59,20 +59,20 @@ void do_pam_passwd (const char *user, bool silent, bool change_expired) ret = pam_start ("passwd", user, &conv, &pamh); if (ret != PAM_SUCCESS) { - fprintf (stderr, + fprintf (shadow_logfd, _("passwd: pam_start() failed, error %d\n"), ret); exit (10); /* XXX */ } ret = pam_chauthtok (pamh, flags); if (ret != PAM_SUCCESS) { - fprintf (stderr, _("passwd: %s\n"), pam_strerror (pamh, ret)); - fputs (_("passwd: password unchanged\n"), stderr); + fprintf (shadow_logfd, _("passwd: %s\n"), pam_strerror (pamh, ret)); + fputs (_("passwd: password unchanged\n"), shadow_logfd); pam_end (pamh, ret); exit (10); /* XXX */ } - fputs (_("passwd: password updated successfully\n"), stderr); + fputs (_("passwd: password updated successfully\n"), shadow_logfd); (void) pam_end (pamh, PAM_SUCCESS); } #else /* !USE_PAM */ diff --git a/libmisc/pam_pass_non_interactive.c b/libmisc/pam_pass_non_interactive.c index ded5c69e..3c95c88c 100644 --- a/libmisc/pam_pass_non_interactive.c +++ b/libmisc/pam_pass_non_interactive.c @@ -76,7 +76,7 @@ static int ni_conv (int num_msg, switch (msg[count]->msg_style) { case PAM_PROMPT_ECHO_ON: - fprintf (stderr, + fprintf (shadow_logfd, _("%s: PAM modules requesting echoing are not supported.\n"), Prog); goto failed_conversation; @@ -88,7 +88,7 @@ static int ni_conv (int num_msg, break; case PAM_ERROR_MSG: if ( (NULL == msg[count]->msg) - || (fprintf (stderr, "%s\n", msg[count]->msg) <0)) { + || (fprintf (shadow_logfd, "%s\n", msg[count]->msg) <0)) { goto failed_conversation; } responses[count].resp = NULL; @@ -101,7 +101,7 @@ static int ni_conv (int num_msg, responses[count].resp = NULL; break; default: - (void) fprintf (stderr, + (void) fprintf (shadow_logfd, _("%s: conversation type %d not supported.\n"), Prog, msg[count]->msg_style); goto failed_conversation; @@ -143,7 +143,7 @@ int do_pam_passwd_non_interactive (const char *pam_service, ret = pam_start (pam_service, username, &non_interactive_pam_conv, &pamh); if (ret != PAM_SUCCESS) { - fprintf (stderr, + fprintf (shadow_logfd, _("%s: (user %s) pam_start failure %d\n"), Prog, username, ret); return 1; @@ -152,7 +152,7 @@ int do_pam_passwd_non_interactive (const char *pam_service, non_interactive_password = password; ret = pam_chauthtok (pamh, 0); if (ret != PAM_SUCCESS) { - fprintf (stderr, + fprintf (shadow_logfd, _("%s: (user %s) pam_chauthtok() failed, error:\n" "%s\n"), Prog, username, pam_strerror (pamh, ret)); diff --git a/libmisc/prefix_flag.c b/libmisc/prefix_flag.c index d72f7e39..2e455c40 100644 --- a/libmisc/prefix_flag.c +++ b/libmisc/prefix_flag.c @@ -74,25 +74,31 @@ extern const char* process_prefix_flag (const char* short_opt, int argc, char ** * Parse the command line options. */ int i; - const char *prefix = NULL; + const char *prefix = NULL, *val; for (i = 0; i < argc; i++) { + val = NULL; if ( (strcmp (argv[i], "--prefix") == 0) + || ((strncmp (argv[i], "--prefix=", 9) == 0) + && (val = argv[i] + 9)) || (strcmp (argv[i], short_opt) == 0)) { if (NULL != prefix) { - fprintf (stderr, + fprintf (shadow_logfd, _("%s: multiple --prefix options\n"), Prog); exit (E_BAD_ARG); } - if (i + 1 == argc) { - fprintf (stderr, + if (val) { + prefix = val; + } else if (i + 1 == argc) { + fprintf (shadow_logfd, _("%s: option '%s' requires an argument\n"), Prog, argv[i]); exit (E_BAD_ARG); + } else { + prefix = argv[++ i]; } - prefix = argv[i + 1]; } } @@ -103,6 +109,12 @@ extern const char* process_prefix_flag (const char* short_opt, int argc, char ** return ""; /* if prefix is "/" then we ignore the flag option */ /* should we prevent symbolic link from being used as a prefix? */ + if ( prefix[0] != '/') { + fprintf (shadow_logfd, + _("%s: prefix must be an absolute path\n"), + Prog); + exit (E_BAD_ARG); + } size_t len; len = strlen(prefix) + strlen(PASSWD_FILE) + 2; passwd_db_file = xmalloc(len); diff --git a/libmisc/pwdcheck.c b/libmisc/pwdcheck.c index ec1f4744..bc6b66f8 100644 --- a/libmisc/pwdcheck.c +++ b/libmisc/pwdcheck.c @@ -51,7 +51,7 @@ void passwd_check (const char *user, const char *passwd, unused const char *prog if (pw_auth (passwd, user, PW_LOGIN, (char *) 0) != 0) { SYSLOG ((LOG_WARN, "incorrect password for `%s'", user)); (void) sleep (1); - fprintf (stderr, _("Incorrect password for %s.\n"), user); + fprintf (shadow_logfd, _("Incorrect password for %s.\n"), user); exit (EXIT_FAILURE); } } diff --git a/libmisc/root_flag.c b/libmisc/root_flag.c index 7f5e6110..e9a97d44 100644 --- a/libmisc/root_flag.c +++ b/libmisc/root_flag.c @@ -56,25 +56,31 @@ extern void process_root_flag (const char* short_opt, int argc, char **argv) * Parse the command line options. */ int i; - const char *newroot = NULL; + const char *newroot = NULL, *val; for (i = 0; i < argc; i++) { + val = NULL; if ( (strcmp (argv[i], "--root") == 0) + || ((strncmp (argv[i], "--root=", 7) == 0) + && (val = argv[i] + 7)) || (strcmp (argv[i], short_opt) == 0)) { if (NULL != newroot) { - fprintf (stderr, + fprintf (shadow_logfd, _("%s: multiple --root options\n"), Prog); exit (E_BAD_ARG); } - if (i + 1 == argc) { - fprintf (stderr, + if (val) { + newroot = val; + } else if (i + 1 == argc) { + fprintf (shadow_logfd, _("%s: option '%s' requires an argument\n"), Prog, argv[i]); exit (E_BAD_ARG); + } else { + newroot = argv[++ i]; } - newroot = argv[i + 1]; } } @@ -88,34 +94,34 @@ static void change_root (const char* newroot) /* Drop privileges */ if ( (setregid (getgid (), getgid ()) != 0) || (setreuid (getuid (), getuid ()) != 0)) { - fprintf (stderr, _("%s: failed to drop privileges (%s)\n"), + fprintf (shadow_logfd, _("%s: failed to drop privileges (%s)\n"), Prog, strerror (errno)); exit (EXIT_FAILURE); } if ('/' != newroot[0]) { - fprintf (stderr, + fprintf (shadow_logfd, _("%s: invalid chroot path '%s'\n"), Prog, newroot); exit (E_BAD_ARG); } if (access (newroot, F_OK) != 0) { - fprintf(stderr, + fprintf(shadow_logfd, _("%s: cannot access chroot directory %s: %s\n"), Prog, newroot, strerror (errno)); exit (E_BAD_ARG); } if (chdir (newroot) != 0) { - fprintf(stderr, + fprintf(shadow_logfd, _("%s: cannot chdir to chroot directory %s: %s\n"), Prog, newroot, strerror (errno)); exit (E_BAD_ARG); } if (chroot (newroot) != 0) { - fprintf(stderr, + fprintf(shadow_logfd, _("%s: unable to chroot to directory %s: %s\n"), Prog, newroot, strerror (errno)); exit (E_BAD_ARG); diff --git a/libmisc/salt.c b/libmisc/salt.c index e1a7ac80..91d528fd 100644 --- a/libmisc/salt.c +++ b/libmisc/salt.c @@ -11,30 +11,100 @@ #ident "$Id$" -#include <sys/time.h> -#include <stdlib.h> -#include <stdio.h> #include <assert.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#if HAVE_SYS_RANDOM_H +#include <sys/random.h> +#endif #include "prototypes.h" #include "defines.h" #include "getdef.h" +#if (defined CRYPT_GENSALT_IMPLEMENTS_AUTO_ENTROPY && \ + CRYPT_GENSALT_IMPLEMENTS_AUTO_ENTROPY) +#define USE_XCRYPT_GENSALT 1 +#else +#define USE_XCRYPT_GENSALT 0 +#endif + +/* Add the salt prefix. */ +#define MAGNUM(array,ch) (array)[0]=(array)[2]='$',(array)[1]=(ch),(array)[3]='\0' + +#ifdef USE_BCRYPT +/* Use $2b$ as prefix for compatibility with OpenBSD's bcrypt. */ +#define BCRYPTMAGNUM(array) (array)[0]=(array)[3]='$',(array)[1]='2',(array)[2]='b',(array)[4]='\0' +#define BCRYPT_SALT_SIZE 22 +/* Default number of rounds if not explicitly specified. */ +#define B_ROUNDS_DEFAULT 13 +/* Minimum number of rounds. */ +#define B_ROUNDS_MIN 4 +/* Maximum number of rounds. */ +#define B_ROUNDS_MAX 31 +#endif /* USE_BCRYPT */ + +#ifdef USE_SHA_CRYPT +/* Fixed salt len for sha{256,512}crypt. */ +#define SHA_CRYPT_SALT_SIZE 16 +/* Default number of rounds if not explicitly specified. */ +#define SHA_ROUNDS_DEFAULT 5000 +/* Minimum number of rounds. */ +#define SHA_ROUNDS_MIN 1000 +/* Maximum number of rounds. */ +#define SHA_ROUNDS_MAX 999999999 +#endif + +#ifdef USE_YESCRYPT +/* + * Default number of base64 characters used for the salt. + * 24 characters gives a 144 bits (18 bytes) salt. Unlike the more + * traditional 128 bits (16 bytes) salt, this 144 bits salt is always + * represented by the same number of base64 characters without padding + * issue, even with a non-standard base64 encoding scheme. + */ +#define YESCRYPT_SALT_SIZE 24 +/* Default cost if not explicitly specified. */ +#define Y_COST_DEFAULT 5 +/* Minimum cost. */ +#define Y_COST_MIN 1 +/* Maximum cost. */ +#define Y_COST_MAX 11 +#endif + +/* Fixed salt len for md5crypt. */ +#define MD5_CRYPT_SALT_SIZE 8 + +/* Generate salt of size salt_size. */ +#define MAX_SALT_SIZE 44 +#define MIN_SALT_SIZE 8 + +/* Maximum size of the generated salt string. */ +#define GENSALT_SETTING_SIZE 100 + /* local function prototypes */ -static void seedRNG (void); +static long read_random_bytes (void); +#if !USE_XCRYPT_GENSALT static /*@observer@*/const char *gensalt (size_t salt_size); +#endif /* !USE_XCRYPT_GENSALT */ #if defined(USE_SHA_CRYPT) || defined(USE_BCRYPT) static long shadow_random (long min, long max); #endif /* USE_SHA_CRYPT || USE_BCRYPT */ #ifdef USE_SHA_CRYPT -static /*@observer@*/const char *SHA_salt_rounds (/*@null@*/int *prefered_rounds); +static /*@observer@*/const unsigned long SHA_get_salt_rounds (/*@null@*/int *prefered_rounds); +static /*@observer@*/void SHA_salt_rounds_to_buf (char *buf, unsigned long rounds); #endif /* USE_SHA_CRYPT */ #ifdef USE_BCRYPT -static /*@observer@*/const char *gensalt_bcrypt (void); -static /*@observer@*/const char *BCRYPT_salt_rounds (/*@null@*/int *prefered_rounds); +static /*@observer@*/const unsigned long BCRYPT_get_salt_rounds (/*@null@*/int *prefered_rounds); +static /*@observer@*/void BCRYPT_salt_rounds_to_buf (char *buf, unsigned long rounds); #endif /* USE_BCRYPT */ +#ifdef USE_YESCRYPT +static /*@observer@*/const unsigned long YESCRYPT_get_salt_cost (/*@null@*/int *prefered_cost); +static /*@observer@*/void YESCRYPT_salt_cost_to_buf (char *buf, unsigned long cost); +#endif /* USE_YESCRYPT */ -#ifndef HAVE_L64A -static /*@observer@*/char *l64a(long value) +#if !USE_XCRYPT_GENSALT && !defined(HAVE_L64A) +static /*@observer@*/char *l64a (long value) { static char buf[8]; char *s = buf; @@ -65,40 +135,58 @@ static /*@observer@*/char *l64a(long value) *s = '\0'; - return(buf); + return buf; } -#endif /* !HAVE_L64A */ +#endif /* !USE_XCRYPT_GENSALT && !defined(HAVE_L64A) */ -static void seedRNG (void) +/* Read sizeof (long) random bytes from /dev/urandom. */ +static long read_random_bytes (void) { - struct timeval tv; - static int seeded = 0; + long randval = 0; + +#ifdef HAVE_ARC4RANDOM_BUF + /* arc4random_buf, if it exists, can never fail. */ + arc4random_buf (&randval, sizeof (randval)); + goto end; - if (0 == seeded) { - (void) gettimeofday (&tv, NULL); - srandom (tv.tv_sec ^ tv.tv_usec ^ getpid ()); - seeded = 1; +#elif defined(HAVE_GETENTROPY) + /* getentropy may exist but lack kernel support. */ + if (getentropy (&randval, sizeof (randval))) { + goto fail; } -} -/* - * Add the salt prefix. - */ -#define MAGNUM(array,ch) (array)[0]=(array)[2]='$',(array)[1]=(ch),(array)[3]='\0' -#ifdef USE_BCRYPT -/* - * Using the Prefix $2a$ to enable an anti-collision safety measure in musl libc. - * Negatively affects a subset of passwords containing the '\xff' character, - * which is not valid UTF-8 (so "unlikely to cause much annoyance"). - */ -#define BCRYPTMAGNUM(array) (array)[0]=(array)[3]='$',(array)[1]='2',(array)[2]='a',(array)[4]='\0' -#endif /* USE_BCRYPT */ + goto end; -#if defined(USE_SHA_CRYPT) || defined(USE_BCRYPT) -/* It is not clear what is the maximum value of random(). - * We assume 2^31-1.*/ -#define RANDOM_MAX 0x7FFFFFFF +#elif defined(HAVE_GETRANDOM) + /* Likewise getrandom. */ + if ((size_t) getrandom (&randval, sizeof (randval), 0) != sizeof (randval)) { + goto fail; + } + + goto end; + +#else + FILE *f = fopen ("/dev/urandom", "r"); + if (fread (&randval, sizeof (randval), 1, f) != 1) { + fclose(f); + goto fail; + } + + fclose(f); + goto end; +#endif + +fail: + fprintf (shadow_logfd, + _("Unable to obtain random bytes.\n")); + exit (1); + +end: + return randval; +} + +#if defined(USE_SHA_CRYPT) || defined(USE_BCRYPT) /* * Return a random number between min and max (both included). * @@ -108,8 +196,9 @@ static long shadow_random (long min, long max) { double drand; long ret; - seedRNG (); - drand = (double) (max - min + 1) * random () / RANDOM_MAX; + + drand = (double) (read_random_bytes () & RAND_MAX) / (double) RAND_MAX; + drand *= (double) (max - min + 1); /* On systems were this is not random() range is lower, we favor * higher numbers of salt. */ ret = (long) (max + 1 - drand); @@ -122,26 +211,17 @@ static long shadow_random (long min, long max) #endif /* USE_SHA_CRYPT || USE_BCRYPT */ #ifdef USE_SHA_CRYPT -/* Default number of rounds if not explicitly specified. */ -#define ROUNDS_DEFAULT 5000 -/* Minimum number of rounds. */ -#define ROUNDS_MIN 1000 -/* Maximum number of rounds. */ -#define ROUNDS_MAX 999999999 -/* - * Return a salt prefix specifying the rounds number for the SHA crypt methods. - */ -static /*@observer@*/const char *SHA_salt_rounds (/*@null@*/int *prefered_rounds) +/* Return the the rounds number for the SHA crypt methods. */ +static /*@observer@*/const unsigned long SHA_get_salt_rounds (/*@null@*/int *prefered_rounds) { - static char rounds_prefix[18]; /* Max size: rounds=999999999$ */ - long rounds; + unsigned long rounds; if (NULL == prefered_rounds) { long min_rounds = getdef_long ("SHA_CRYPT_MIN_ROUNDS", -1); long max_rounds = getdef_long ("SHA_CRYPT_MAX_ROUNDS", -1); if ((-1 == min_rounds) && (-1 == max_rounds)) { - return ""; + rounds = SHA_ROUNDS_DEFAULT; } if (-1 == min_rounds) { @@ -156,137 +236,208 @@ static /*@observer@*/const char *SHA_salt_rounds (/*@null@*/int *prefered_rounds max_rounds = min_rounds; } - rounds = shadow_random (min_rounds, max_rounds); + rounds = (unsigned long) shadow_random (min_rounds, max_rounds); } else if (0 == *prefered_rounds) { - return ""; + rounds = SHA_ROUNDS_DEFAULT; } else { - rounds = *prefered_rounds; + rounds = (unsigned long) *prefered_rounds; } /* Sanity checks. The libc should also check this, but this * protects against a rounds_prefix overflow. */ - if (rounds < ROUNDS_MIN) { - rounds = ROUNDS_MIN; + if (rounds < SHA_ROUNDS_MIN) { + rounds = SHA_ROUNDS_MIN; } - if (rounds > ROUNDS_MAX) { - rounds = ROUNDS_MAX; + if (rounds > SHA_ROUNDS_MAX) { + rounds = SHA_ROUNDS_MAX; } - (void) snprintf (rounds_prefix, sizeof rounds_prefix, - "rounds=%ld$", rounds); + return rounds; +} + +/* + * Fill a salt prefix specifying the rounds number for the SHA crypt methods + * to a buffer. + */ +static /*@observer@*/void SHA_salt_rounds_to_buf (char *buf, unsigned long rounds) +{ + const size_t buf_begin = strlen (buf); + + /* Nothing to do here if SHA_ROUNDS_DEFAULT is used. */ + if (rounds == SHA_ROUNDS_DEFAULT) { + return; + } + + /* + * Check if the result buffer is long enough. + * We are going to write a maximum of 17 bytes, + * plus one byte for the terminator. + * rounds=XXXXXXXXX$ + * 00000000011111111 + * 12345678901234567 + */ + assert (GENSALT_SETTING_SIZE > buf_begin + 17); - return rounds_prefix; + (void) snprintf (buf + buf_begin, 18, "rounds=%lu$", rounds); } #endif /* USE_SHA_CRYPT */ #ifdef USE_BCRYPT -/* Default number of rounds if not explicitly specified. */ -#define B_ROUNDS_DEFAULT 13 -/* Minimum number of rounds. */ -#define B_ROUNDS_MIN 4 -/* Maximum number of rounds. */ -#define B_ROUNDS_MAX 31 -/* - * Return a salt prefix specifying the rounds number for the BCRYPT method. - */ -static /*@observer@*/const char *BCRYPT_salt_rounds (/*@null@*/int *prefered_rounds) +/* Return the the rounds number for the BCRYPT method. */ +static /*@observer@*/const unsigned long BCRYPT_get_salt_rounds (/*@null@*/int *prefered_rounds) { - static char rounds_prefix[4]; /* Max size: 31$ */ - long rounds; + unsigned long rounds; if (NULL == prefered_rounds) { long min_rounds = getdef_long ("BCRYPT_MIN_ROUNDS", -1); long max_rounds = getdef_long ("BCRYPT_MAX_ROUNDS", -1); - if (((-1 == min_rounds) && (-1 == max_rounds)) || (0 == *prefered_rounds)) { + if ((-1 == min_rounds) && (-1 == max_rounds)) { rounds = B_ROUNDS_DEFAULT; - } - else { + } else { if (-1 == min_rounds) { min_rounds = max_rounds; } - + if (-1 == max_rounds) { max_rounds = min_rounds; } - + if (min_rounds > max_rounds) { max_rounds = min_rounds; } - - rounds = shadow_random (min_rounds, max_rounds); + + rounds = (unsigned long) shadow_random (min_rounds, max_rounds); } + } else if (0 == *prefered_rounds) { + rounds = B_ROUNDS_DEFAULT; } else { - rounds = *prefered_rounds; + rounds = (unsigned long) *prefered_rounds; } - /* - * Sanity checks. - * Use 19 as an upper bound for now, - * because musl doesn't allow rounds >= 20. - */ + /* Sanity checks. */ if (rounds < B_ROUNDS_MIN) { rounds = B_ROUNDS_MIN; } +#if USE_XCRYPT_GENSALT + if (rounds > B_ROUNDS_MAX) { + rounds = B_ROUNDS_MAX; + } +#else /* USE_XCRYPT_GENSALT */ + /* + * Use 19 as an upper bound for now, + * because musl doesn't allow rounds >= 20. + */ if (rounds > 19) { /* rounds = B_ROUNDS_MAX; */ rounds = 19; } +#endif /* USE_XCRYPT_GENSALT */ - (void) snprintf (rounds_prefix, sizeof rounds_prefix, - "%2.2ld$", rounds); - - return rounds_prefix; + return rounds; } -#define BCRYPT_SALT_SIZE 22 /* - * Generate a 22 character salt string for bcrypt. + * Fill a salt prefix specifying the rounds number for the BCRYPT method + * to a buffer. */ -static /*@observer@*/const char *gensalt_bcrypt (void) +static /*@observer@*/void BCRYPT_salt_rounds_to_buf (char *buf, unsigned long rounds) { - static char salt[32]; + const size_t buf_begin = strlen (buf); - salt[0] = '\0'; + /* + * Check if the result buffer is long enough. + * We are going to write three bytes, + * plus one byte for the terminator. + * XX$ + * 000 + * 123 + */ + assert (GENSALT_SETTING_SIZE > buf_begin + 3); - seedRNG (); - strcat (salt, l64a (random())); - do { - strcat (salt, l64a (random())); - } while (strlen (salt) < BCRYPT_SALT_SIZE); + (void) snprintf (buf + buf_begin, 4, "%2.2lu$", rounds); +} +#endif /* USE_BCRYPT */ - salt[BCRYPT_SALT_SIZE] = '\0'; +#ifdef USE_YESCRYPT +/* Return the the cost number for the YESCRYPT method. */ +static /*@observer@*/const unsigned long YESCRYPT_get_salt_cost (/*@null@*/int *prefered_cost) +{ + unsigned long cost; - return salt; + if (NULL == prefered_cost) { + cost = getdef_num ("YESCRYPT_COST_FACTOR", Y_COST_DEFAULT); + } else if (0 == *prefered_cost) { + cost = Y_COST_DEFAULT; + } else { + cost = (unsigned long) *prefered_cost; + } + + /* Sanity checks. */ + if (cost < Y_COST_MIN) { + cost = Y_COST_MIN; + } + + if (cost > Y_COST_MAX) { + cost = Y_COST_MAX; + } + + return cost; } -#endif /* USE_BCRYPT */ /* - * Generate salt of size salt_size. + * Fill a salt prefix specifying the cost for the YESCRYPT method + * to a buffer. */ -#define MAX_SALT_SIZE 16 -#define MIN_SALT_SIZE 8 +static /*@observer@*/void YESCRYPT_salt_cost_to_buf (char *buf, unsigned long cost) +{ + const size_t buf_begin = strlen (buf); + + /* + * Check if the result buffer is long enough. + * We are going to write four bytes, + * plus one byte for the terminator. + * jXX$ + * 0000 + * 1234 + */ + assert (GENSALT_SETTING_SIZE > buf_begin + 4); + buf[buf_begin + 0] = 'j'; + if (cost < 3) { + buf[buf_begin + 1] = 0x36 + cost; + } else if (cost < 6) { + buf[buf_begin + 1] = 0x34 + cost; + } else { + buf[buf_begin + 1] = 0x3b + cost; + } + buf[buf_begin + 2] = cost >= 3 ? 'T' : '5'; + buf[buf_begin + 3] = '$'; + buf[buf_begin + 4] = '\0'; +} +#endif /* USE_YESCRYPT */ + +#if !USE_XCRYPT_GENSALT static /*@observer@*/const char *gensalt (size_t salt_size) { - static char salt[32]; + static char salt[MAX_SALT_SIZE + 6]; - salt[0] = '\0'; + memset (salt, '\0', MAX_SALT_SIZE + 6); assert (salt_size >= MIN_SALT_SIZE && salt_size <= MAX_SALT_SIZE); - seedRNG (); - strcat (salt, l64a (random())); + strcat (salt, l64a (read_random_bytes ())); do { - strcat (salt, l64a (random())); + strcat (salt, l64a (read_random_bytes ())); } while (strlen (salt) < salt_size); salt[salt_size] = '\0'; return salt; } +#endif /* !USE_XCRYPT_GENSALT */ /* * Generate 8 base64 ASCII characters of random salt. If MD5_CRYPT_ENAB @@ -296,26 +447,23 @@ static /*@observer@*/const char *gensalt (size_t salt_size) * Other methods can be set with ENCRYPT_METHOD * * The method can be forced with the meth parameter. - * If NULL, the method will be defined according to the MD5_CRYPT_ENAB and - * ENCRYPT_METHOD login.defs variables. + * If NULL, the method will be defined according to the ENCRYPT_METHOD + * variable, and if not set according to the MD5_CRYPT_ENAB variable, + * which can both be set inside the login.defs file. * * If meth is specified, an additional parameter can be provided. * * For the SHA256 and SHA512 method, this specifies the number of rounds * (if not NULL). + * * For the YESCRYPT method, this specifies the cost factor (if not NULL). */ /*@observer@*/const char *crypt_make_salt (/*@null@*//*@observer@*/const char *meth, /*@null@*/void *arg) { - /* Max result size for the SHA methods: - * +3 $5$ - * +17 rounds=999999999$ - * +16 salt - * +1 \0 - */ - static char result[40]; - size_t salt_len = 8; + static char result[GENSALT_SETTING_SIZE]; + size_t salt_len = MAX_SALT_SIZE; const char *method; + unsigned long rounds = 0; - result[0] = '\0'; + memset (result, '\0', GENSALT_SETTING_SIZE); if (NULL != meth) method = meth; @@ -328,46 +476,80 @@ static /*@observer@*/const char *gensalt (size_t salt_size) if (0 == strcmp (method, "MD5")) { MAGNUM(result, '1'); + salt_len = MD5_CRYPT_SALT_SIZE; + rounds = 0; #ifdef USE_BCRYPT } else if (0 == strcmp (method, "BCRYPT")) { BCRYPTMAGNUM(result); - strcat(result, BCRYPT_salt_rounds((int *)arg)); + salt_len = BCRYPT_SALT_SIZE; + rounds = BCRYPT_get_salt_rounds ((int *) arg); + BCRYPT_salt_rounds_to_buf (result, rounds); #endif /* USE_BCRYPT */ +#ifdef USE_YESCRYPT + } else if (0 == strcmp (method, "YESCRYPT")) { + MAGNUM(result, 'y'); + salt_len = YESCRYPT_SALT_SIZE; + rounds = YESCRYPT_get_salt_cost ((int *) arg); + YESCRYPT_salt_cost_to_buf (result, rounds); +#endif /* USE_YESCRYPT */ #ifdef USE_SHA_CRYPT } else if (0 == strcmp (method, "SHA256")) { MAGNUM(result, '5'); - strcat(result, SHA_salt_rounds((int *)arg)); - salt_len = (size_t) shadow_random (8, 16); + salt_len = SHA_CRYPT_SALT_SIZE; + rounds = SHA_get_salt_rounds ((int *) arg); + SHA_salt_rounds_to_buf (result, rounds); } else if (0 == strcmp (method, "SHA512")) { MAGNUM(result, '6'); - strcat(result, SHA_salt_rounds((int *)arg)); - salt_len = (size_t) shadow_random (8, 16); + salt_len = SHA_CRYPT_SALT_SIZE; + rounds = SHA_get_salt_rounds ((int *) arg); + SHA_salt_rounds_to_buf (result, rounds); #endif /* USE_SHA_CRYPT */ } else if (0 != strcmp (method, "DES")) { - fprintf (stderr, + fprintf (shadow_logfd, _("Invalid ENCRYPT_METHOD value: '%s'.\n" "Defaulting to DES.\n"), method); - result[0] = '\0'; + salt_len = MAX_SALT_SIZE; + rounds = 0; + memset (result, '\0', GENSALT_SETTING_SIZE); } +#if USE_XCRYPT_GENSALT /* - * Concatenate a pseudo random salt. + * Prepare DES setting for crypt_gensalt(), if result + * has not been filled with anything previously. */ - assert (sizeof (result) > strlen (result) + salt_len); -#ifdef USE_BCRYPT - if (0 == strcmp (method, "BCRYPT")) { - strncat (result, gensalt_bcrypt (), - sizeof (result) - strlen (result) - 1); - return result; - } else { -#endif /* USE_BCRYPT */ - strncat (result, gensalt (salt_len), - sizeof (result) - strlen (result) - 1); -#ifdef USE_BCRYPT + if ('\0' == result[0]) { + /* Avoid -Wunused-but-set-variable. */ + salt_len = GENSALT_SETTING_SIZE - 1; + rounds = 0; + memset (result, '.', salt_len); + result[salt_len] = '\0'; } -#endif /* USE_BCRYPT */ + + char *retval = crypt_gensalt (result, rounds, NULL, 0); + + /* Should not happen, but... */ + if (NULL == retval) { + fprintf (shadow_logfd, + _("Unable to generate a salt from setting " + "\"%s\", check your settings in " + "ENCRYPT_METHOD and the corresponding " + "configuration for your selected hash " + "method.\n"), result); + + exit (1); + } + + return retval; +#else /* USE_XCRYPT_GENSALT */ + /* Check if the result buffer is long enough. */ + assert (GENSALT_SETTING_SIZE > strlen (result) + salt_len); + + /* Concatenate a pseudo random salt. */ + strncat (result, gensalt (salt_len), + GENSALT_SETTING_SIZE - strlen (result) - 1); return result; +#endif /* USE_XCRYPT_GENSALT */ } - diff --git a/libmisc/setupenv.c b/libmisc/setupenv.c index 24c6e678..74b18723 100644 --- a/libmisc/setupenv.c +++ b/libmisc/setupenv.c @@ -219,7 +219,7 @@ void setup_env (struct passwd *info) static char temp_pw_dir[] = "/"; if (!getdef_bool ("DEFAULT_HOME") || chdir ("/") == -1) { - fprintf (stderr, _("Unable to cd to '%s'\n"), + fprintf (shadow_logfd, _("Unable to cd to '%s'\n"), info->pw_dir); SYSLOG ((LOG_WARN, "unable to cd to `%s' for user `%s'\n", diff --git a/libmisc/user_busy.c b/libmisc/user_busy.c index 324bb946..3deebfc3 100644 --- a/libmisc/user_busy.c +++ b/libmisc/user_busy.c @@ -96,7 +96,7 @@ static int user_busy_utmp (const char *name) continue; } - fprintf (stderr, + fprintf (shadow_logfd, _("%s: user %s is currently logged in\n"), Prog, name); return 1; @@ -249,7 +249,7 @@ static int user_busy_processes (const char *name, uid_t uid) #ifdef ENABLE_SUBIDS sub_uid_close(); #endif - fprintf (stderr, + fprintf (shadow_logfd, _("%s: user %s is currently used by process %d\n"), Prog, name, pid); return 1; @@ -269,10 +269,11 @@ static int user_busy_processes (const char *name, uid_t uid) } if (check_status (name, task_path+6, uid) != 0) { (void) closedir (proc); + (void) closedir (task_dir); #ifdef ENABLE_SUBIDS sub_uid_close(); #endif - fprintf (stderr, + fprintf (shadow_logfd, _("%s: user %s is currently used by process %d\n"), Prog, name, pid); return 1; diff --git a/libmisc/utmp.c b/libmisc/utmp.c index ba69cf61..5dcd419f 100644 --- a/libmisc/utmp.c +++ b/libmisc/utmp.c @@ -257,25 +257,25 @@ static void updwtmpx (const char *filename, const struct utmpx *utx) utent->ut_type = USER_PROCESS; #endif /* HAVE_STRUCT_UTMP_UT_TYPE */ utent->ut_pid = getpid (); - strncpy (utent->ut_line, line, sizeof (utent->ut_line)); + strncpy (utent->ut_line, line, sizeof (utent->ut_line) - 1); #ifdef HAVE_STRUCT_UTMP_UT_ID if (NULL != ut) { strncpy (utent->ut_id, ut->ut_id, sizeof (utent->ut_id)); } else { /* XXX - assumes /dev/tty?? */ - strncpy (utent->ut_id, line + 3, sizeof (utent->ut_id)); + strncpy (utent->ut_id, line + 3, sizeof (utent->ut_id) - 1); } #endif /* HAVE_STRUCT_UTMP_UT_ID */ #ifdef HAVE_STRUCT_UTMP_UT_NAME strncpy (utent->ut_name, name, sizeof (utent->ut_name)); #endif /* HAVE_STRUCT_UTMP_UT_NAME */ #ifdef HAVE_STRUCT_UTMP_UT_USER - strncpy (utent->ut_user, name, sizeof (utent->ut_user)); + strncpy (utent->ut_user, name, sizeof (utent->ut_user) - 1); #endif /* HAVE_STRUCT_UTMP_UT_USER */ if (NULL != hostname) { struct addrinfo *info = NULL; #ifdef HAVE_STRUCT_UTMP_UT_HOST - strncpy (utent->ut_host, hostname, sizeof (utent->ut_host)); + strncpy (utent->ut_host, hostname, sizeof (utent->ut_host) - 1); #endif /* HAVE_STRUCT_UTMP_UT_HOST */ #ifdef HAVE_STRUCT_UTMP_UT_SYSLEN utent->ut_syslen = MIN (strlen (hostname), diff --git a/libmisc/xgetXXbyYY.c b/libmisc/xgetXXbyYY.c index 1b0b0013..11f45fc4 100644 --- a/libmisc/xgetXXbyYY.c +++ b/libmisc/xgetXXbyYY.c @@ -74,7 +74,7 @@ result = malloc(sizeof(LOOKUP_TYPE)); if (NULL == result) { - fprintf (stderr, _("%s: out of memory\n"), + fprintf (shadow_logfd, _("%s: out of memory\n"), "x" STRINGIZE(FUNCTION_NAME)); exit (13); } @@ -84,7 +84,7 @@ LOOKUP_TYPE *resbuf = NULL; buffer = (char *)realloc (buffer, length); if (NULL == buffer) { - fprintf (stderr, _("%s: out of memory\n"), + fprintf (shadow_logfd, _("%s: out of memory\n"), "x" STRINGIZE(FUNCTION_NAME)); exit (13); } @@ -132,7 +132,7 @@ if (result) { result = DUP_FUNCTION(result); if (NULL == result) { - fprintf (stderr, _("%s: out of memory\n"), + fprintf (shadow_logfd, _("%s: out of memory\n"), "x" STRINGIZE(FUNCTION_NAME)); exit (13); } diff --git a/libmisc/xmalloc.c b/libmisc/xmalloc.c index 41a3343c..6d686145 100644 --- a/libmisc/xmalloc.c +++ b/libmisc/xmalloc.c @@ -54,7 +54,7 @@ ptr = (char *) malloc (size); if (NULL == ptr) { - (void) fprintf (stderr, + (void) fprintf (shadow_logfd, _("%s: failed to allocate memory: %s\n"), Prog, strerror (errno)); exit (13); @@ -66,3 +66,10 @@ { return strcpy (xmalloc (strlen (str) + 1), str); } + +void xfree(void *ap) +{ + if (ap) { + free(ap); + } +} |