summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBalint Reczey <balint@balintreczey.hu>2022-01-21 23:41:15 +0100
committerBalint Reczey <balint@balintreczey.hu>2022-01-21 23:41:15 +0100
commit0c04b92a9afe5e09a20307d8a5ec98d97ed00f47 (patch)
tree27f51b8f32e23b65d2ef2bbbae00c19fd036e81d /src
parent749c1780621163ca5108f164861324bafa9e0ae8 (diff)
downloadshadow-0c04b92a9afe5e09a20307d8a5ec98d97ed00f47.tar.gz
New upstream version 4.11.1+dfsg1upstream/4.11.1+dfsg1
Diffstat (limited to 'src')
-rw-r--r--src/Makefile.am18
-rw-r--r--src/Makefile.in318
-rw-r--r--src/chage.c73
-rw-r--r--src/check_subid_range.c5
-rw-r--r--src/chfn.c42
-rw-r--r--src/chgpasswd.c40
-rw-r--r--src/chpasswd.c42
-rw-r--r--src/chsh.c38
-rw-r--r--src/expiry.c42
-rw-r--r--src/faillog.c45
-rw-r--r--src/free_subid_range.c11
-rw-r--r--src/get_subid_owners.c11
-rw-r--r--src/getsubids.c (renamed from src/list_subid_ranges.c)14
-rw-r--r--src/gpasswd.c50
-rw-r--r--src/groupadd.c38
-rw-r--r--src/groupdel.c40
-rw-r--r--src/groupmems.c44
-rw-r--r--src/groupmod.c38
-rw-r--r--src/groups.c59
-rw-r--r--src/grpck.c42
-rw-r--r--src/grpconv.c36
-rw-r--r--src/grpunconv.c38
-rw-r--r--src/id.c49
-rw-r--r--src/lastlog.c46
-rw-r--r--src/login.c60
-rw-r--r--src/login_nopam.c9
-rw-r--r--src/logoutd.c38
-rw-r--r--src/new_subid_range.c11
-rw-r--r--src/newgidmap.c32
-rw-r--r--src/newgrp.c58
-rw-r--r--src/newuidmap.c34
-rw-r--r--src/newusers.c40
-rw-r--r--src/nologin.c24
-rw-r--r--src/passwd.c69
-rw-r--r--src/pwck.c39
-rw-r--r--src/pwconv.c36
-rw-r--r--src/pwunconv.c38
-rw-r--r--src/su.c102
-rw-r--r--src/suauth.c35
-rw-r--r--src/sulogin.c40
-rw-r--r--src/useradd.c207
-rw-r--r--src/userdel.c50
-rw-r--r--src/usermod.c365
-rw-r--r--src/vipw.c37
44 files changed, 898 insertions, 1605 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 35027013..a1a2e4e3 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -10,6 +10,7 @@ sgidperms = 2755
AM_CPPFLAGS = \
-I${top_srcdir}/lib \
-I$(top_srcdir)/libmisc \
+ -I$(top_srcdir) \
-DLOCALEDIR=\"$(datadir)/locale\"
# XXX why are login and su in /bin anyway (other than for
@@ -95,8 +96,8 @@ LIBCRYPT_NOPAM = $(LIBCRYPT)
endif
chage_LDADD = $(LDADD) $(LIBPAM_SUID) $(LIBAUDIT) $(LIBSELINUX) $(LIBECONF)
-newuidmap_LDADD = $(LDADD) $(LIBAUDIT) $(LIBSELINUX) $(LIBCAP) -ldl
-newgidmap_LDADD = $(LDADD) $(LIBAUDIT) $(LIBSELINUX) $(LIBCAP) -ldl
+newuidmap_LDADD = $(LDADD) $(LIBAUDIT) $(LIBSELINUX) $(LIBCAP) $(LIBECONF) -ldl
+newgidmap_LDADD = $(LDADD) $(LIBAUDIT) $(LIBSELINUX) $(LIBCAP) $(LIBECONF) -ldl
chfn_LDADD = $(LDADD) $(LIBPAM) $(LIBAUDIT) $(LIBSELINUX) $(LIBCRYPT_NOPAM) $(LIBSKEY) $(LIBMD) $(LIBECONF)
chgpasswd_LDADD = $(LDADD) $(LIBPAM_SUID) $(LIBAUDIT) $(LIBSELINUX) $(LIBCRYPT) $(LIBECONF)
chsh_LDADD = $(LDADD) $(LIBPAM) $(LIBAUDIT) $(LIBSELINUX) $(LIBCRYPT_NOPAM) $(LIBSKEY) $(LIBMD) $(LIBECONF)
@@ -157,8 +158,8 @@ if FCAPS
setcap cap_setgid+ep $(DESTDIR)$(ubindir)/newgidmap
endif
-noinst_PROGRAMS += list_subid_ranges \
- get_subid_owners \
+bin_PROGRAMS += getsubids
+noinst_PROGRAMS += get_subid_owners \
new_subid_range \
free_subid_range \
check_subid_range
@@ -174,15 +175,16 @@ MISCLIBS = \
$(LIBCRYPT) \
$(LIBTCB)
-list_subid_ranges_LDADD = \
+getsubids_LDADD = \
$(top_builddir)/lib/libshadow.la \
$(top_builddir)/libmisc/libmisc.la \
$(top_builddir)/libsubid/libsubid.la \
$(MISCLIBS) -ldl
-list_subid_ranges_CPPFLAGS = \
+getsubids_CPPFLAGS = \
-I$(top_srcdir)/lib \
-I$(top_srcdir)/libmisc \
+ -I$(top_srcdir) \
-I$(top_srcdir)/libsubid
get_subid_owners_LDADD = \
@@ -194,11 +196,13 @@ get_subid_owners_LDADD = \
get_subid_owners_CPPFLAGS = \
-I$(top_srcdir)/lib \
-I$(top_srcdir)/libmisc \
+ -I$(top_srcdir) \
-I$(top_srcdir)/libsubid
new_subid_range_CPPFLAGS = \
-I$(top_srcdir)/lib \
-I$(top_srcdir)/libmisc \
+ -I$(top_srcdir) \
-I$(top_srcdir)/libsubid
new_subid_range_LDADD = \
@@ -210,6 +214,7 @@ new_subid_range_LDADD = \
free_subid_range_CPPFLAGS = \
-I$(top_srcdir)/lib \
-I$(top_srcdir)/libmisc \
+ -I$(top_srcdir) \
-I$(top_srcdir)/libsubid
free_subid_range_LDADD = \
@@ -220,6 +225,7 @@ free_subid_range_LDADD = \
check_subid_range_CPPFLAGS = \
-I$(top_srcdir)/lib \
+ -I$(top_srcdir) \
-I$(top_srcdir)/libmisc
check_subid_range_LDADD = \
diff --git a/src/Makefile.in b/src/Makefile.in
index c820270f..5aeb65c1 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -1,7 +1,7 @@
-# Makefile.in generated by automake 1.15.1 from Makefile.am.
+# Makefile.in generated by automake 1.16.1 from Makefile.am.
# @configure_input@
-# Copyright (C) 1994-2017 Free Software Foundation, Inc.
+# Copyright (C) 1994-2018 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
@@ -88,11 +88,12 @@ PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
-bin_PROGRAMS = groups$(EXEEXT) login$(EXEEXT) $(am__EXEEXT_1)
+bin_PROGRAMS = groups$(EXEEXT) login$(EXEEXT) $(am__EXEEXT_1) \
+ $(am__EXEEXT_2)
sbin_PROGRAMS = nologin$(EXEEXT)
ubin_PROGRAMS = faillog$(EXEEXT) lastlog$(EXEEXT) chage$(EXEEXT) \
chfn$(EXEEXT) chsh$(EXEEXT) expiry$(EXEEXT) gpasswd$(EXEEXT) \
- newgrp$(EXEEXT) passwd$(EXEEXT) $(am__EXEEXT_3)
+ newgrp$(EXEEXT) passwd$(EXEEXT) $(am__EXEEXT_4)
@ENABLE_SUBIDS_TRUE@am__append_1 = newgidmap newuidmap
@WITH_SU_TRUE@am__append_2 = su
usbin_PROGRAMS = chgpasswd$(EXEEXT) chpasswd$(EXEEXT) \
@@ -102,13 +103,13 @@ usbin_PROGRAMS = chgpasswd$(EXEEXT) chpasswd$(EXEEXT) \
pwck$(EXEEXT) pwconv$(EXEEXT) pwunconv$(EXEEXT) \
useradd$(EXEEXT) userdel$(EXEEXT) usermod$(EXEEXT) \
vipw$(EXEEXT)
-noinst_PROGRAMS = id$(EXEEXT) sulogin$(EXEEXT) $(am__EXEEXT_2)
+noinst_PROGRAMS = id$(EXEEXT) sulogin$(EXEEXT) $(am__EXEEXT_3)
@WITH_SU_TRUE@am__append_3 = su
@WITH_TCB_FALSE@am__append_4 = passwd
@ACCT_TOOLS_SETUID_TRUE@am__append_5 = chgpasswd chpasswd groupadd groupdel groupmod newusers useradd userdel usermod
@ENABLE_SUBIDS_TRUE@@FCAPS_FALSE@am__append_6 = newgidmap newuidmap
-@ENABLE_SUBIDS_TRUE@am__append_7 = list_subid_ranges \
-@ENABLE_SUBIDS_TRUE@ get_subid_owners \
+@ENABLE_SUBIDS_TRUE@am__append_7 = getsubids
+@ENABLE_SUBIDS_TRUE@am__append_8 = get_subid_owners \
@ENABLE_SUBIDS_TRUE@ new_subid_range \
@ENABLE_SUBIDS_TRUE@ free_subid_range \
@ENABLE_SUBIDS_TRUE@ check_subid_range
@@ -131,14 +132,14 @@ CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
CONFIG_CLEAN_VPATH_FILES =
@WITH_SU_TRUE@am__EXEEXT_1 = su$(EXEEXT)
+@ENABLE_SUBIDS_TRUE@am__EXEEXT_2 = getsubids$(EXEEXT)
am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(sbindir)" \
"$(DESTDIR)$(ubindir)" "$(DESTDIR)$(usbindir)"
-@ENABLE_SUBIDS_TRUE@am__EXEEXT_2 = list_subid_ranges$(EXEEXT) \
-@ENABLE_SUBIDS_TRUE@ get_subid_owners$(EXEEXT) \
+@ENABLE_SUBIDS_TRUE@am__EXEEXT_3 = get_subid_owners$(EXEEXT) \
@ENABLE_SUBIDS_TRUE@ new_subid_range$(EXEEXT) \
@ENABLE_SUBIDS_TRUE@ free_subid_range$(EXEEXT) \
@ENABLE_SUBIDS_TRUE@ check_subid_range$(EXEEXT)
-@ENABLE_SUBIDS_TRUE@am__EXEEXT_3 = newgidmap$(EXEEXT) \
+@ENABLE_SUBIDS_TRUE@am__EXEEXT_4 = newgidmap$(EXEEXT) \
@ENABLE_SUBIDS_TRUE@ newuidmap$(EXEEXT)
PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS) $(sbin_PROGRAMS) \
$(ubin_PROGRAMS) $(usbin_PROGRAMS)
@@ -220,6 +221,13 @@ get_subid_owners_OBJECTS = \
@ENABLE_SUBIDS_TRUE@ $(top_builddir)/libmisc/libmisc.la \
@ENABLE_SUBIDS_TRUE@ $(top_builddir)/libsubid/libsubid.la \
@ENABLE_SUBIDS_TRUE@ $(am__DEPENDENCIES_5)
+getsubids_SOURCES = getsubids.c
+getsubids_OBJECTS = getsubids-getsubids.$(OBJEXT)
+@ENABLE_SUBIDS_TRUE@getsubids_DEPENDENCIES = \
+@ENABLE_SUBIDS_TRUE@ $(top_builddir)/lib/libshadow.la \
+@ENABLE_SUBIDS_TRUE@ $(top_builddir)/libmisc/libmisc.la \
+@ENABLE_SUBIDS_TRUE@ $(top_builddir)/libsubid/libsubid.la \
+@ENABLE_SUBIDS_TRUE@ $(am__DEPENDENCIES_5)
gpasswd_SOURCES = gpasswd.c
gpasswd_OBJECTS = gpasswd.$(OBJEXT)
gpasswd_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \
@@ -273,14 +281,6 @@ lastlog_SOURCES = lastlog.c
lastlog_OBJECTS = lastlog.$(OBJEXT)
lastlog_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \
$(am__DEPENDENCIES_1)
-list_subid_ranges_SOURCES = list_subid_ranges.c
-list_subid_ranges_OBJECTS = \
- list_subid_ranges-list_subid_ranges.$(OBJEXT)
-@ENABLE_SUBIDS_TRUE@list_subid_ranges_DEPENDENCIES = \
-@ENABLE_SUBIDS_TRUE@ $(top_builddir)/lib/libshadow.la \
-@ENABLE_SUBIDS_TRUE@ $(top_builddir)/libmisc/libmisc.la \
-@ENABLE_SUBIDS_TRUE@ $(top_builddir)/libsubid/libsubid.la \
-@ENABLE_SUBIDS_TRUE@ $(am__DEPENDENCIES_5)
am_login_OBJECTS = login.$(OBJEXT) login_nopam.$(OBJEXT)
login_OBJECTS = $(am_login_OBJECTS)
login_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \
@@ -303,7 +303,7 @@ new_subid_range_OBJECTS = new_subid_range-new_subid_range.$(OBJEXT)
newgidmap_SOURCES = newgidmap.c
newgidmap_OBJECTS = newgidmap.$(OBJEXT)
newgidmap_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
newgrp_SOURCES = newgrp.c
newgrp_OBJECTS = newgrp.$(OBJEXT)
newgrp_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \
@@ -311,7 +311,7 @@ newgrp_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \
newuidmap_SOURCES = newuidmap.c
newuidmap_OBJECTS = newuidmap.$(OBJEXT)
newuidmap_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \
- $(am__DEPENDENCIES_1)
+ $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
newusers_SOURCES = newusers.c
newusers_OBJECTS = newusers.$(OBJEXT)
newusers_DEPENDENCIES = $(am__DEPENDENCIES_2) $(am__DEPENDENCIES_1) \
@@ -383,7 +383,30 @@ am__v_at_0 = @
am__v_at_1 =
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
-am__depfiles_maybe = depfiles
+am__maybe_remake_depfiles = depfiles
+am__depfiles_remade = ./$(DEPDIR)/chage.Po \
+ ./$(DEPDIR)/check_subid_range-check_subid_range.Po \
+ ./$(DEPDIR)/chfn.Po ./$(DEPDIR)/chgpasswd.Po \
+ ./$(DEPDIR)/chpasswd.Po ./$(DEPDIR)/chsh.Po \
+ ./$(DEPDIR)/expiry.Po ./$(DEPDIR)/faillog.Po \
+ ./$(DEPDIR)/free_subid_range-free_subid_range.Po \
+ ./$(DEPDIR)/get_subid_owners-get_subid_owners.Po \
+ ./$(DEPDIR)/getsubids-getsubids.Po ./$(DEPDIR)/gpasswd.Po \
+ ./$(DEPDIR)/groupadd.Po ./$(DEPDIR)/groupdel.Po \
+ ./$(DEPDIR)/groupmems.Po ./$(DEPDIR)/groupmod.Po \
+ ./$(DEPDIR)/groups.Po ./$(DEPDIR)/grpck.Po \
+ ./$(DEPDIR)/grpconv.Po ./$(DEPDIR)/grpunconv.Po \
+ ./$(DEPDIR)/id.Po ./$(DEPDIR)/lastlog.Po ./$(DEPDIR)/login.Po \
+ ./$(DEPDIR)/login_nopam.Po ./$(DEPDIR)/logoutd.Po \
+ ./$(DEPDIR)/new_subid_range-new_subid_range.Po \
+ ./$(DEPDIR)/newgidmap.Po ./$(DEPDIR)/newgrp.Po \
+ ./$(DEPDIR)/newuidmap.Po ./$(DEPDIR)/newusers.Po \
+ ./$(DEPDIR)/nologin.Po ./$(DEPDIR)/passwd.Po \
+ ./$(DEPDIR)/pwck.Po ./$(DEPDIR)/pwconv.Po \
+ ./$(DEPDIR)/pwunconv.Po ./$(DEPDIR)/su.Po \
+ ./$(DEPDIR)/suauth.Po ./$(DEPDIR)/sulogin.Po \
+ ./$(DEPDIR)/useradd.Po ./$(DEPDIR)/userdel.Po \
+ ./$(DEPDIR)/usermod.Po ./$(DEPDIR)/vipw.Po
am__mv = mv -f
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
@@ -405,20 +428,20 @@ am__v_CCLD_0 = @echo " CCLD " $@;
am__v_CCLD_1 =
SOURCES = chage.c check_subid_range.c chfn.c chgpasswd.c chpasswd.c \
chsh.c expiry.c faillog.c free_subid_range.c \
- get_subid_owners.c gpasswd.c groupadd.c groupdel.c groupmems.c \
- groupmod.c groups.c grpck.c grpconv.c grpunconv.c id.c \
- lastlog.c list_subid_ranges.c $(login_SOURCES) logoutd.c \
- new_subid_range.c newgidmap.c newgrp.c newuidmap.c newusers.c \
- nologin.c passwd.c pwck.c pwconv.c pwunconv.c $(su_SOURCES) \
- sulogin.c useradd.c userdel.c usermod.c vipw.c
+ get_subid_owners.c getsubids.c gpasswd.c groupadd.c groupdel.c \
+ groupmems.c groupmod.c groups.c grpck.c grpconv.c grpunconv.c \
+ id.c lastlog.c $(login_SOURCES) logoutd.c new_subid_range.c \
+ newgidmap.c newgrp.c newuidmap.c newusers.c nologin.c passwd.c \
+ pwck.c pwconv.c pwunconv.c $(su_SOURCES) sulogin.c useradd.c \
+ userdel.c usermod.c vipw.c
DIST_SOURCES = chage.c check_subid_range.c chfn.c chgpasswd.c \
chpasswd.c chsh.c expiry.c faillog.c free_subid_range.c \
- get_subid_owners.c gpasswd.c groupadd.c groupdel.c groupmems.c \
- groupmod.c groups.c grpck.c grpconv.c grpunconv.c id.c \
- lastlog.c list_subid_ranges.c $(login_SOURCES) logoutd.c \
- new_subid_range.c newgidmap.c newgrp.c newuidmap.c newusers.c \
- nologin.c passwd.c pwck.c pwconv.c pwunconv.c $(su_SOURCES) \
- sulogin.c useradd.c userdel.c usermod.c vipw.c
+ get_subid_owners.c getsubids.c gpasswd.c groupadd.c groupdel.c \
+ groupmems.c groupmod.c groups.c grpck.c grpconv.c grpunconv.c \
+ id.c lastlog.c $(login_SOURCES) logoutd.c new_subid_range.c \
+ newgidmap.c newgrp.c newuidmap.c newusers.c nologin.c passwd.c \
+ pwck.c pwconv.c pwunconv.c $(su_SOURCES) sulogin.c useradd.c \
+ userdel.c usermod.c vipw.c
am__can_run_installinfo = \
case $$AM_UPDATE_INFO_DIR in \
n|no|NO) false;; \
@@ -613,6 +636,7 @@ sgidperms = 2755
AM_CPPFLAGS = \
-I${top_srcdir}/lib \
-I$(top_srcdir)/libmisc \
+ -I$(top_srcdir) \
-DLOCALEDIR=\"$(datadir)/locale\"
suidusbins = $(am__append_5)
@@ -630,8 +654,8 @@ LDADD = $(INTLLIBS) \
@USE_PAM_FALSE@LIBCRYPT_NOPAM = $(LIBCRYPT)
@USE_PAM_TRUE@LIBCRYPT_NOPAM =
chage_LDADD = $(LDADD) $(LIBPAM_SUID) $(LIBAUDIT) $(LIBSELINUX) $(LIBECONF)
-newuidmap_LDADD = $(LDADD) $(LIBAUDIT) $(LIBSELINUX) $(LIBCAP) -ldl
-newgidmap_LDADD = $(LDADD) $(LIBAUDIT) $(LIBSELINUX) $(LIBCAP) -ldl
+newuidmap_LDADD = $(LDADD) $(LIBAUDIT) $(LIBSELINUX) $(LIBCAP) $(LIBECONF) -ldl
+newgidmap_LDADD = $(LDADD) $(LIBAUDIT) $(LIBSELINUX) $(LIBCAP) $(LIBECONF) -ldl
chfn_LDADD = $(LDADD) $(LIBPAM) $(LIBAUDIT) $(LIBSELINUX) $(LIBCRYPT_NOPAM) $(LIBSKEY) $(LIBMD) $(LIBECONF)
chgpasswd_LDADD = $(LDADD) $(LIBPAM_SUID) $(LIBAUDIT) $(LIBSELINUX) $(LIBCRYPT) $(LIBECONF)
chsh_LDADD = $(LDADD) $(LIBPAM) $(LIBAUDIT) $(LIBSELINUX) $(LIBCRYPT_NOPAM) $(LIBSKEY) $(LIBMD) $(LIBECONF)
@@ -679,15 +703,16 @@ vipw_LDADD = $(LDADD) $(LIBAUDIT) $(LIBSELINUX) $(LIBECONF)
@ENABLE_SUBIDS_TRUE@ $(LIBCRYPT) \
@ENABLE_SUBIDS_TRUE@ $(LIBTCB)
-@ENABLE_SUBIDS_TRUE@list_subid_ranges_LDADD = \
+@ENABLE_SUBIDS_TRUE@getsubids_LDADD = \
@ENABLE_SUBIDS_TRUE@ $(top_builddir)/lib/libshadow.la \
@ENABLE_SUBIDS_TRUE@ $(top_builddir)/libmisc/libmisc.la \
@ENABLE_SUBIDS_TRUE@ $(top_builddir)/libsubid/libsubid.la \
@ENABLE_SUBIDS_TRUE@ $(MISCLIBS) -ldl
-@ENABLE_SUBIDS_TRUE@list_subid_ranges_CPPFLAGS = \
+@ENABLE_SUBIDS_TRUE@getsubids_CPPFLAGS = \
@ENABLE_SUBIDS_TRUE@ -I$(top_srcdir)/lib \
@ENABLE_SUBIDS_TRUE@ -I$(top_srcdir)/libmisc \
+@ENABLE_SUBIDS_TRUE@ -I$(top_srcdir) \
@ENABLE_SUBIDS_TRUE@ -I$(top_srcdir)/libsubid
@ENABLE_SUBIDS_TRUE@get_subid_owners_LDADD = \
@@ -699,11 +724,13 @@ vipw_LDADD = $(LDADD) $(LIBAUDIT) $(LIBSELINUX) $(LIBECONF)
@ENABLE_SUBIDS_TRUE@get_subid_owners_CPPFLAGS = \
@ENABLE_SUBIDS_TRUE@ -I$(top_srcdir)/lib \
@ENABLE_SUBIDS_TRUE@ -I$(top_srcdir)/libmisc \
+@ENABLE_SUBIDS_TRUE@ -I$(top_srcdir) \
@ENABLE_SUBIDS_TRUE@ -I$(top_srcdir)/libsubid
@ENABLE_SUBIDS_TRUE@new_subid_range_CPPFLAGS = \
@ENABLE_SUBIDS_TRUE@ -I$(top_srcdir)/lib \
@ENABLE_SUBIDS_TRUE@ -I$(top_srcdir)/libmisc \
+@ENABLE_SUBIDS_TRUE@ -I$(top_srcdir) \
@ENABLE_SUBIDS_TRUE@ -I$(top_srcdir)/libsubid
@ENABLE_SUBIDS_TRUE@new_subid_range_LDADD = \
@@ -715,6 +742,7 @@ vipw_LDADD = $(LDADD) $(LIBAUDIT) $(LIBSELINUX) $(LIBECONF)
@ENABLE_SUBIDS_TRUE@free_subid_range_CPPFLAGS = \
@ENABLE_SUBIDS_TRUE@ -I$(top_srcdir)/lib \
@ENABLE_SUBIDS_TRUE@ -I$(top_srcdir)/libmisc \
+@ENABLE_SUBIDS_TRUE@ -I$(top_srcdir) \
@ENABLE_SUBIDS_TRUE@ -I$(top_srcdir)/libsubid
@ENABLE_SUBIDS_TRUE@free_subid_range_LDADD = \
@@ -725,6 +753,7 @@ vipw_LDADD = $(LDADD) $(LIBAUDIT) $(LIBSELINUX) $(LIBECONF)
@ENABLE_SUBIDS_TRUE@check_subid_range_CPPFLAGS = \
@ENABLE_SUBIDS_TRUE@ -I$(top_srcdir)/lib \
+@ENABLE_SUBIDS_TRUE@ -I$(top_srcdir) \
@ENABLE_SUBIDS_TRUE@ -I$(top_srcdir)/libmisc
@ENABLE_SUBIDS_TRUE@check_subid_range_LDADD = \
@@ -753,8 +782,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__depfiles_maybe)'; \
- cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+ echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles)'; \
+ cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__maybe_remake_depfiles);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
@@ -1011,6 +1040,10 @@ get_subid_owners$(EXEEXT): $(get_subid_owners_OBJECTS) $(get_subid_owners_DEPEND
@rm -f get_subid_owners$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(get_subid_owners_OBJECTS) $(get_subid_owners_LDADD) $(LIBS)
+getsubids$(EXEEXT): $(getsubids_OBJECTS) $(getsubids_DEPENDENCIES) $(EXTRA_getsubids_DEPENDENCIES)
+ @rm -f getsubids$(EXEEXT)
+ $(AM_V_CCLD)$(LINK) $(getsubids_OBJECTS) $(getsubids_LDADD) $(LIBS)
+
gpasswd$(EXEEXT): $(gpasswd_OBJECTS) $(gpasswd_DEPENDENCIES) $(EXTRA_gpasswd_DEPENDENCIES)
@rm -f gpasswd$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(gpasswd_OBJECTS) $(gpasswd_LDADD) $(LIBS)
@@ -1055,10 +1088,6 @@ lastlog$(EXEEXT): $(lastlog_OBJECTS) $(lastlog_DEPENDENCIES) $(EXTRA_lastlog_DEP
@rm -f lastlog$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(lastlog_OBJECTS) $(lastlog_LDADD) $(LIBS)
-list_subid_ranges$(EXEEXT): $(list_subid_ranges_OBJECTS) $(list_subid_ranges_DEPENDENCIES) $(EXTRA_list_subid_ranges_DEPENDENCIES)
- @rm -f list_subid_ranges$(EXEEXT)
- $(AM_V_CCLD)$(LINK) $(list_subid_ranges_OBJECTS) $(list_subid_ranges_LDADD) $(LIBS)
-
login$(EXEEXT): $(login_OBJECTS) $(login_DEPENDENCIES) $(EXTRA_login_DEPENDENCIES)
@rm -f login$(EXEEXT)
$(AM_V_CCLD)$(LINK) $(login_OBJECTS) $(login_LDADD) $(LIBS)
@@ -1137,48 +1166,54 @@ mostlyclean-compile:
distclean-compile:
-rm -f *.tab.c
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chage.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_subid_range-check_subid_range.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chfn.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chgpasswd.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chpasswd.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chsh.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/expiry.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/faillog.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/free_subid_range-free_subid_range.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/get_subid_owners-get_subid_owners.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gpasswd.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/groupadd.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/groupdel.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/groupmems.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/groupmod.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/groups.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grpck.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grpconv.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grpunconv.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/id.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lastlog.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/list_subid_ranges-list_subid_ranges.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/login.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/login_nopam.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/logoutd.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/new_subid_range-new_subid_range.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/newgidmap.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/newgrp.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/newuidmap.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/newusers.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nologin.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/passwd.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pwck.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pwconv.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pwunconv.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/su.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/suauth.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sulogin.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/useradd.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/userdel.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/usermod.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vipw.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chage.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/check_subid_range-check_subid_range.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chfn.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chgpasswd.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chpasswd.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/chsh.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/expiry.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/faillog.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/free_subid_range-free_subid_range.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/get_subid_owners-get_subid_owners.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/getsubids-getsubids.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gpasswd.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/groupadd.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/groupdel.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/groupmems.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/groupmod.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/groups.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grpck.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grpconv.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/grpunconv.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/id.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/lastlog.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/login.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/login_nopam.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/logoutd.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/new_subid_range-new_subid_range.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/newgidmap.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/newgrp.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/newuidmap.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/newusers.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/nologin.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/passwd.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pwck.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pwconv.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pwunconv.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/su.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/suauth.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sulogin.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/useradd.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/userdel.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/usermod.Po@am__quote@ # am--include-marker
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vipw.Po@am__quote@ # am--include-marker
+
+$(am__depfiles_remade):
+ @$(MKDIR_P) $(@D)
+ @echo '# dummy' >$@-t && $(am__mv) $@-t $@
+
+am--depfiles: $(am__depfiles_remade)
.c.o:
@am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@@ -1243,19 +1278,19 @@ get_subid_owners-get_subid_owners.obj: get_subid_owners.c
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(get_subid_owners_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o get_subid_owners-get_subid_owners.obj `if test -f 'get_subid_owners.c'; then $(CYGPATH_W) 'get_subid_owners.c'; else $(CYGPATH_W) '$(srcdir)/get_subid_owners.c'; fi`
-list_subid_ranges-list_subid_ranges.o: list_subid_ranges.c
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(list_subid_ranges_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT list_subid_ranges-list_subid_ranges.o -MD -MP -MF $(DEPDIR)/list_subid_ranges-list_subid_ranges.Tpo -c -o list_subid_ranges-list_subid_ranges.o `test -f 'list_subid_ranges.c' || echo '$(srcdir)/'`list_subid_ranges.c
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/list_subid_ranges-list_subid_ranges.Tpo $(DEPDIR)/list_subid_ranges-list_subid_ranges.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='list_subid_ranges.c' object='list_subid_ranges-list_subid_ranges.o' libtool=no @AMDEPBACKSLASH@
+getsubids-getsubids.o: getsubids.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(getsubids_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT getsubids-getsubids.o -MD -MP -MF $(DEPDIR)/getsubids-getsubids.Tpo -c -o getsubids-getsubids.o `test -f 'getsubids.c' || echo '$(srcdir)/'`getsubids.c
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/getsubids-getsubids.Tpo $(DEPDIR)/getsubids-getsubids.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='getsubids.c' object='getsubids-getsubids.o' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(list_subid_ranges_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o list_subid_ranges-list_subid_ranges.o `test -f 'list_subid_ranges.c' || echo '$(srcdir)/'`list_subid_ranges.c
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(getsubids_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o getsubids-getsubids.o `test -f 'getsubids.c' || echo '$(srcdir)/'`getsubids.c
-list_subid_ranges-list_subid_ranges.obj: list_subid_ranges.c
-@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(list_subid_ranges_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT list_subid_ranges-list_subid_ranges.obj -MD -MP -MF $(DEPDIR)/list_subid_ranges-list_subid_ranges.Tpo -c -o list_subid_ranges-list_subid_ranges.obj `if test -f 'list_subid_ranges.c'; then $(CYGPATH_W) 'list_subid_ranges.c'; else $(CYGPATH_W) '$(srcdir)/list_subid_ranges.c'; fi`
-@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/list_subid_ranges-list_subid_ranges.Tpo $(DEPDIR)/list_subid_ranges-list_subid_ranges.Po
-@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='list_subid_ranges.c' object='list_subid_ranges-list_subid_ranges.obj' libtool=no @AMDEPBACKSLASH@
+getsubids-getsubids.obj: getsubids.c
+@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(getsubids_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT getsubids-getsubids.obj -MD -MP -MF $(DEPDIR)/getsubids-getsubids.Tpo -c -o getsubids-getsubids.obj `if test -f 'getsubids.c'; then $(CYGPATH_W) 'getsubids.c'; else $(CYGPATH_W) '$(srcdir)/getsubids.c'; fi`
+@am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/getsubids-getsubids.Tpo $(DEPDIR)/getsubids-getsubids.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='getsubids.c' object='getsubids-getsubids.obj' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
-@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(list_subid_ranges_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o list_subid_ranges-list_subid_ranges.obj `if test -f 'list_subid_ranges.c'; then $(CYGPATH_W) 'list_subid_ranges.c'; else $(CYGPATH_W) '$(srcdir)/list_subid_ranges.c'; fi`
+@am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(getsubids_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o getsubids-getsubids.obj `if test -f 'getsubids.c'; then $(CYGPATH_W) 'getsubids.c'; else $(CYGPATH_W) '$(srcdir)/getsubids.c'; fi`
new_subid_range-new_subid_range.o: new_subid_range.c
@am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(new_subid_range_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT new_subid_range-new_subid_range.o -MD -MP -MF $(DEPDIR)/new_subid_range-new_subid_range.Tpo -c -o new_subid_range-new_subid_range.o `test -f 'new_subid_range.c' || echo '$(srcdir)/'`new_subid_range.c
@@ -1329,7 +1364,10 @@ cscopelist-am: $(am__tagged_files)
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-distdir: $(DISTFILES)
+distdir: $(BUILT_SOURCES)
+ $(MAKE) $(AM_MAKEFLAGS) distdir-am
+
+distdir-am: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
list='$(DISTFILES)'; \
@@ -1400,7 +1438,48 @@ clean-am: clean-binPROGRAMS clean-generic clean-libtool \
clean-usbinPROGRAMS mostlyclean-am
distclean: distclean-am
- -rm -rf ./$(DEPDIR)
+ -rm -f ./$(DEPDIR)/chage.Po
+ -rm -f ./$(DEPDIR)/check_subid_range-check_subid_range.Po
+ -rm -f ./$(DEPDIR)/chfn.Po
+ -rm -f ./$(DEPDIR)/chgpasswd.Po
+ -rm -f ./$(DEPDIR)/chpasswd.Po
+ -rm -f ./$(DEPDIR)/chsh.Po
+ -rm -f ./$(DEPDIR)/expiry.Po
+ -rm -f ./$(DEPDIR)/faillog.Po
+ -rm -f ./$(DEPDIR)/free_subid_range-free_subid_range.Po
+ -rm -f ./$(DEPDIR)/get_subid_owners-get_subid_owners.Po
+ -rm -f ./$(DEPDIR)/getsubids-getsubids.Po
+ -rm -f ./$(DEPDIR)/gpasswd.Po
+ -rm -f ./$(DEPDIR)/groupadd.Po
+ -rm -f ./$(DEPDIR)/groupdel.Po
+ -rm -f ./$(DEPDIR)/groupmems.Po
+ -rm -f ./$(DEPDIR)/groupmod.Po
+ -rm -f ./$(DEPDIR)/groups.Po
+ -rm -f ./$(DEPDIR)/grpck.Po
+ -rm -f ./$(DEPDIR)/grpconv.Po
+ -rm -f ./$(DEPDIR)/grpunconv.Po
+ -rm -f ./$(DEPDIR)/id.Po
+ -rm -f ./$(DEPDIR)/lastlog.Po
+ -rm -f ./$(DEPDIR)/login.Po
+ -rm -f ./$(DEPDIR)/login_nopam.Po
+ -rm -f ./$(DEPDIR)/logoutd.Po
+ -rm -f ./$(DEPDIR)/new_subid_range-new_subid_range.Po
+ -rm -f ./$(DEPDIR)/newgidmap.Po
+ -rm -f ./$(DEPDIR)/newgrp.Po
+ -rm -f ./$(DEPDIR)/newuidmap.Po
+ -rm -f ./$(DEPDIR)/newusers.Po
+ -rm -f ./$(DEPDIR)/nologin.Po
+ -rm -f ./$(DEPDIR)/passwd.Po
+ -rm -f ./$(DEPDIR)/pwck.Po
+ -rm -f ./$(DEPDIR)/pwconv.Po
+ -rm -f ./$(DEPDIR)/pwunconv.Po
+ -rm -f ./$(DEPDIR)/su.Po
+ -rm -f ./$(DEPDIR)/suauth.Po
+ -rm -f ./$(DEPDIR)/sulogin.Po
+ -rm -f ./$(DEPDIR)/useradd.Po
+ -rm -f ./$(DEPDIR)/userdel.Po
+ -rm -f ./$(DEPDIR)/usermod.Po
+ -rm -f ./$(DEPDIR)/vipw.Po
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-tags
@@ -1446,7 +1525,48 @@ install-ps-am:
installcheck-am:
maintainer-clean: maintainer-clean-am
- -rm -rf ./$(DEPDIR)
+ -rm -f ./$(DEPDIR)/chage.Po
+ -rm -f ./$(DEPDIR)/check_subid_range-check_subid_range.Po
+ -rm -f ./$(DEPDIR)/chfn.Po
+ -rm -f ./$(DEPDIR)/chgpasswd.Po
+ -rm -f ./$(DEPDIR)/chpasswd.Po
+ -rm -f ./$(DEPDIR)/chsh.Po
+ -rm -f ./$(DEPDIR)/expiry.Po
+ -rm -f ./$(DEPDIR)/faillog.Po
+ -rm -f ./$(DEPDIR)/free_subid_range-free_subid_range.Po
+ -rm -f ./$(DEPDIR)/get_subid_owners-get_subid_owners.Po
+ -rm -f ./$(DEPDIR)/getsubids-getsubids.Po
+ -rm -f ./$(DEPDIR)/gpasswd.Po
+ -rm -f ./$(DEPDIR)/groupadd.Po
+ -rm -f ./$(DEPDIR)/groupdel.Po
+ -rm -f ./$(DEPDIR)/groupmems.Po
+ -rm -f ./$(DEPDIR)/groupmod.Po
+ -rm -f ./$(DEPDIR)/groups.Po
+ -rm -f ./$(DEPDIR)/grpck.Po
+ -rm -f ./$(DEPDIR)/grpconv.Po
+ -rm -f ./$(DEPDIR)/grpunconv.Po
+ -rm -f ./$(DEPDIR)/id.Po
+ -rm -f ./$(DEPDIR)/lastlog.Po
+ -rm -f ./$(DEPDIR)/login.Po
+ -rm -f ./$(DEPDIR)/login_nopam.Po
+ -rm -f ./$(DEPDIR)/logoutd.Po
+ -rm -f ./$(DEPDIR)/new_subid_range-new_subid_range.Po
+ -rm -f ./$(DEPDIR)/newgidmap.Po
+ -rm -f ./$(DEPDIR)/newgrp.Po
+ -rm -f ./$(DEPDIR)/newuidmap.Po
+ -rm -f ./$(DEPDIR)/newusers.Po
+ -rm -f ./$(DEPDIR)/nologin.Po
+ -rm -f ./$(DEPDIR)/passwd.Po
+ -rm -f ./$(DEPDIR)/pwck.Po
+ -rm -f ./$(DEPDIR)/pwconv.Po
+ -rm -f ./$(DEPDIR)/pwunconv.Po
+ -rm -f ./$(DEPDIR)/su.Po
+ -rm -f ./$(DEPDIR)/suauth.Po
+ -rm -f ./$(DEPDIR)/sulogin.Po
+ -rm -f ./$(DEPDIR)/useradd.Po
+ -rm -f ./$(DEPDIR)/userdel.Po
+ -rm -f ./$(DEPDIR)/usermod.Po
+ -rm -f ./$(DEPDIR)/vipw.Po
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
@@ -1468,7 +1588,7 @@ uninstall-am: uninstall-binPROGRAMS uninstall-sbinPROGRAMS \
.MAKE: install-am install-strip
-.PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \
+.PHONY: CTAGS GTAGS TAGS all all-am am--depfiles check check-am clean \
clean-binPROGRAMS clean-generic clean-libtool \
clean-noinstPROGRAMS clean-sbinPROGRAMS clean-ubinPROGRAMS \
clean-usbinPROGRAMS cscopelist-am ctags ctags-am distclean \
diff --git a/src/chage.c b/src/chage.c
index f0dc0067..ced3a3e8 100644
--- a/src/chage.c
+++ b/src/chage.c
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 1989 - 1994, Julianne Frances Haugh
- * Copyright (c) 1996 - 2000, Marek Michałkiewicz
- * Copyright (c) 2000 - 2006, Tomasz Kłoczko
- * Copyright (c) 2007 - 2011, Nicolas François
- * All rights reserved.
+ * SPDX-FileCopyrightText: 1989 - 1994, Julianne Frances Haugh
+ * SPDX-FileCopyrightText: 1996 - 2000, Marek Michałkiewicz
+ * SPDX-FileCopyrightText: 2000 - 2006, Tomasz Kłoczko
+ * SPDX-FileCopyrightText: 2007 - 2011, Nicolas François
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the copyright holders or contributors may not be used to
- * endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * SPDX-License-Identifier: BSD-3-Clause
*/
#include <config.h>
@@ -52,6 +29,7 @@
#include "defines.h"
#include "pwio.h"
#include "shadowio.h"
+#include "shadowlog.h"
#ifdef WITH_TCB
#include "tcbfuncs.h"
#endif
@@ -62,7 +40,6 @@
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static bool
dflg = false, /* set last password change date */
@@ -90,7 +67,6 @@ static long expdate;
/* local function prototypes */
static /*@noreturn@*/void usage (int status);
-static void date_to_str (char *buf, size_t maxsize, time_t date);
static int new_fields (void);
static void print_date (time_t date);
static void list_fields (void);
@@ -161,19 +137,6 @@ static /*@noreturn@*/void usage (int status)
exit (status);
}
-static void date_to_str (char *buf, size_t maxsize, time_t date)
-{
- struct tm *tp;
-
- tp = gmtime (&date);
-#ifdef HAVE_STRFTIME
- (void) strftime (buf, maxsize, "%Y-%m-%d", tp);
-#else
- (void) snprintf (buf, maxsize, "%04d-%02d-%02d",
- tp->tm_year + 1900, tp->tm_mon + 1, tp->tm_mday);
-#endif /* HAVE_STRFTIME */
-}
-
/*
* new_fields - change the user's password aging information interactively.
*
@@ -207,7 +170,7 @@ static int new_fields (void)
if (-1 == lstchgdate || lstchgdate > LONG_MAX / SCALE) {
strcpy (buf, "-1");
} else {
- date_to_str (buf, sizeof buf, (time_t) (lstchgdate * SCALE));
+ date_to_str (sizeof(buf), buf, lstchgdate * SCALE);
}
change_field (buf, sizeof buf, _("Last Password Change (YYYY-MM-DD)"));
@@ -238,7 +201,7 @@ static int new_fields (void)
if (-1 == expdate || LONG_MAX / SCALE < expdate) {
strcpy (buf, "-1");
} else {
- date_to_str (buf, sizeof buf, (time_t) (expdate * SCALE));
+ date_to_str (sizeof(buf), buf, expdate * SCALE);
}
change_field (buf, sizeof buf,
@@ -258,12 +221,11 @@ static int new_fields (void)
static void print_date (time_t date)
{
-#ifdef HAVE_STRFTIME
struct tm *tp;
char buf[80];
char format[80];
- if( iflg ) {
+ if (iflg) {
(void) snprintf (format, 80, "%%Y-%%m-%%d");
}
else {
@@ -277,20 +239,6 @@ static void print_date (time_t date)
(void) strftime (buf, sizeof buf, format, tp);
(void) puts (buf);
}
-#else
- struct tm *tp;
- char *cp = NULL;
-
- tp = gmtime (&date);
- if (NULL != tp) {
- cp = asctime (tp);
- }
- if (NULL != cp) {
- (void) printf ("%6.6s, %4.4s\n", cp + 4, cp + 20);
- } else {
- (void) printf ("time_t: %lu\n", date);
- }
-#endif
}
/*
@@ -815,7 +763,8 @@ int main (int argc, char **argv)
* Get the program name so that error messages can use it.
*/
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
sanitize_env ();
(void) setlocale (LC_ALL, "");
diff --git a/src/check_subid_range.c b/src/check_subid_range.c
index 8a9d5258..38703b60 100644
--- a/src/check_subid_range.c
+++ b/src/check_subid_range.c
@@ -16,9 +16,9 @@
#include "prototypes.h"
#include "subordinateio.h"
#include "idmapping.h"
+#include "shadowlog.h"
const char *Prog;
-FILE *shadow_logfd = NULL;
int main(int argc, char **argv)
{
@@ -26,7 +26,8 @@ int main(int argc, char **argv)
unsigned long start, count;
bool check_uids;
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
if (argc != 5)
exit(1);
diff --git a/src/chfn.c b/src/chfn.c
index fc529c0b..1c2f1cce 100644
--- a/src/chfn.c
+++ b/src/chfn.c
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 1989 - 1994, Julianne Frances Haugh
- * Copyright (c) 1996 - 2000, Marek Michałkiewicz
- * Copyright (c) 2001 - 2006, Tomasz Kłoczko
- * Copyright (c) 2007 - 2011, Nicolas François
- * All rights reserved.
+ * SPDX-FileCopyrightText: 1989 - 1994, Julianne Frances Haugh
+ * SPDX-FileCopyrightText: 1996 - 2000, Marek Michałkiewicz
+ * SPDX-FileCopyrightText: 2001 - 2006, Tomasz Kłoczko
+ * SPDX-FileCopyrightText: 2007 - 2011, Nicolas François
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the copyright holders or contributors may not be used to
- * endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * SPDX-License-Identifier: BSD-3-Clause
*/
#include <config.h>
@@ -52,12 +29,12 @@
#include "pwio.h"
/*@-exitarg@*/
#include "exitcodes.h"
+#include "shadowlog.h"
/*
* Global variables.
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static char fullnm[BUFSIZ];
static char roomno[BUFSIZ];
static char workph[BUFSIZ];
@@ -277,7 +254,7 @@ static void process_flags (int argc, char **argv)
{NULL, 0, NULL, '\0'}
};
- /*
+ /*
* The remaining arguments will be processed one by one and executed
* by this command. The name is the last argument if it does not
* begin with a "-", otherwise the name is determined from the
@@ -392,7 +369,7 @@ static void check_perms (const struct passwd *pw)
/*
* Non-privileged users are optionally authenticated (must enter the
* password of the user whose information is being changed) before
- * any changes can be made. Idea from util-linux chfn/chsh.
+ * any changes can be made. Idea from util-linux chfn/chsh.
* --marekm
*/
if (!amroot && getdef_bool ("CHFN_AUTH")) {
@@ -640,7 +617,8 @@ int main (int argc, char **argv)
* prefix to most error messages.
*/
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
sanitize_env ();
(void) setlocale (LC_ALL, "");
diff --git a/src/chgpasswd.c b/src/chgpasswd.c
index 56f3e882..d17acb67 100644
--- a/src/chgpasswd.c
+++ b/src/chgpasswd.c
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 1990 - 1994, Julianne Frances Haugh
- * Copyright (c) 2006 , Tomasz Kłoczko
- * Copyright (c) 2006 , Jonas Meurer
- * Copyright (c) 2007 - 2011, Nicolas François
- * All rights reserved.
+ * SPDX-FileCopyrightText: 1990 - 1994, Julianne Frances Haugh
+ * SPDX-FileCopyrightText: 2006 , Tomasz Kłoczko
+ * SPDX-FileCopyrightText: 2006 , Jonas Meurer
+ * SPDX-FileCopyrightText: 2007 - 2011, Nicolas François
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the copyright holders or contributors may not be used to
- * endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * SPDX-License-Identifier: BSD-3-Clause
*/
#include <config.h>
@@ -54,12 +31,12 @@
#endif
/*@-exitarg@*/
#include "exitcodes.h"
+#include "shadowlog.h"
/*
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static bool eflg = false;
static bool md5flg = false;
#if defined(USE_SHA_CRYPT) || defined(USE_BCRYPT) || defined(USE_YESCRYPT)
@@ -438,7 +415,8 @@ int main (int argc, char **argv)
int line = 0;
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
@@ -593,7 +571,7 @@ int main (int argc, char **argv)
newgr.gr_passwd = cp;
}
- /*
+ /*
* The updated group file entry is then put back and will
* be written to the group file later, after all the
* other entries have been updated as well.
diff --git a/src/chpasswd.c b/src/chpasswd.c
index 8a012273..cd2d1cf0 100644
--- a/src/chpasswd.c
+++ b/src/chpasswd.c
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 1990 - 1994, Julianne Frances Haugh
- * Copyright (c) 1996 - 2000, Marek Michałkiewicz
- * Copyright (c) 2000 - 2006, Tomasz Kłoczko
- * Copyright (c) 2007 - 2011, Nicolas François
- * All rights reserved.
+ * SPDX-FileCopyrightText: 1990 - 1994, Julianne Frances Haugh
+ * SPDX-FileCopyrightText: 1996 - 2000, Marek Michałkiewicz
+ * SPDX-FileCopyrightText: 2000 - 2006, Tomasz Kłoczko
+ * SPDX-FileCopyrightText: 2007 - 2011, Nicolas François
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the copyright holders or contributors may not be used to
- * endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * SPDX-License-Identifier: BSD-3-Clause
*/
#include <config.h>
@@ -51,12 +28,12 @@
#include "shadowio.h"
/*@-exitarg@*/
#include "exitcodes.h"
+#include "shadowlog.h"
/*
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static bool eflg = false;
static bool md5flg = false;
#if defined(USE_SHA_CRYPT) || defined(USE_BCRYPT) || defined(USE_YESCRYPT)
@@ -430,7 +407,8 @@ int main (int argc, char **argv)
int line = 0;
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
@@ -515,7 +493,7 @@ int main (int argc, char **argv)
newpwd = cp;
#ifdef USE_PAM
- if (use_pam){
+ if (use_pam) {
if (do_pam_passwd_non_interactive ("chpasswd", name, newpwd) != 0) {
fprintf (stderr,
_("%s: (line %d, user %s) password not changed\n"),
@@ -633,7 +611,7 @@ int main (int argc, char **argv)
newpw.pw_passwd = cp;
}
- /*
+ /*
* The updated password file entry is then put back and will
* be written to the password file later, after all the
* other entries have been updated as well.
diff --git a/src/chsh.c b/src/chsh.c
index 1cafb8b6..21d1c3ef 100644
--- a/src/chsh.c
+++ b/src/chsh.c
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 1989 - 1994, Julianne Frances Haugh
- * Copyright (c) 1996 - 2000, Marek Michałkiewicz
- * Copyright (c) 2001 - 2006, Tomasz Kłoczko
- * Copyright (c) 2007 - 2011, Nicolas François
- * All rights reserved.
+ * SPDX-FileCopyrightText: 1989 - 1994, Julianne Frances Haugh
+ * SPDX-FileCopyrightText: 1996 - 2000, Marek Michałkiewicz
+ * SPDX-FileCopyrightText: 2001 - 2006, Tomasz Kłoczko
+ * SPDX-FileCopyrightText: 2007 - 2011, Nicolas François
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the copyright holders or contributors may not be used to
- * endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * SPDX-License-Identifier: BSD-3-Clause
*/
#include <config.h>
@@ -51,6 +28,7 @@
#endif
/*@-exitarg@*/
#include "exitcodes.h"
+#include "shadowlog.h"
#ifndef SHELLS_FILE
#define SHELLS_FILE "/etc/shells"
@@ -59,7 +37,6 @@
* Global variables
*/
const char *Prog; /* Program name */
-FILE *shadow_logfd = NULL;
static bool amroot; /* Real UID is root */
static char loginsh[BUFSIZ]; /* Name of new login shell */
/* command line options */
@@ -442,7 +419,8 @@ int main (int argc, char **argv)
* most error messages.
*/
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
diff --git a/src/expiry.c b/src/expiry.c
index 1d200716..112c08c2 100644
--- a/src/expiry.c
+++ b/src/expiry.c
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 1994 , Julianne Frances Haugh
- * Copyright (c) 1996 - 2000, Marek Michałkiewicz
- * Copyright (c) 2001 - 2006, Tomasz Kłoczko
- * Copyright (c) 2007 - 2011, Nicolas François
- * All rights reserved.
+ * SPDX-FileCopyrightText: 1994 , Julianne Frances Haugh
+ * SPDX-FileCopyrightText: 1996 - 2000, Marek Michałkiewicz
+ * SPDX-FileCopyrightText: 2001 - 2006, Tomasz Kłoczko
+ * SPDX-FileCopyrightText: 2007 - 2011, Nicolas François
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the copyright holders or contributors may not be used to
- * endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * SPDX-License-Identifier: BSD-3-Clause
*/
#include <config.h>
@@ -43,10 +20,10 @@
#include "prototypes.h"
/*@-exitarg@*/
#include "exitcodes.h"
+#include "shadowlog.h"
/* Global variables */
const char *Prog;
-FILE *shadow_logfd = NULL;
static bool cflg = false;
/* local function prototypes */
@@ -133,7 +110,7 @@ static void process_flags (int argc, char **argv)
}
}
-/*
+/*
* expiry - check and enforce password expiration policy
*
* expiry checks (-c) the current password expiration and forces (-f)
@@ -145,11 +122,12 @@ int main (int argc, char **argv)
struct spwd *spwd;
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
sanitize_env ();
- /*
+ /*
* Start by disabling all of the keyboard signals.
*/
(void) signal (SIGHUP, catch_signals);
diff --git a/src/faillog.c b/src/faillog.c
index d09f1511..d33fe9b6 100644
--- a/src/faillog.c
+++ b/src/faillog.c
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 1989 - 1993, Julianne Frances Haugh
- * Copyright (c) 1996 - 2000, Marek Michałkiewicz
- * Copyright (c) 2002 - 2006, Tomasz Kłoczko
- * Copyright (c) 2007 - 2011, Nicolas François
- * All rights reserved.
+ * SPDX-FileCopyrightText: 1989 - 1993, Julianne Frances Haugh
+ * SPDX-FileCopyrightText: 1996 - 2000, Marek Michałkiewicz
+ * SPDX-FileCopyrightText: 2002 - 2006, Tomasz Kłoczko
+ * SPDX-FileCopyrightText: 2007 - 2011, Nicolas François
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the copyright holders or contributors may not be used to
- * endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * SPDX-License-Identifier: BSD-3-Clause
*/
#include <config.h>
@@ -46,6 +23,7 @@
#include "prototypes.h"
/*@-exitarg@*/
#include "exitcodes.h"
+#include "shadowlog.h"
/* local function prototypes */
static /*@noreturn@*/void usage (int status);
@@ -62,7 +40,6 @@ static void reset (void);
* Global variables
*/
const char *Prog; /* Program name */
-FILE *shadow_logfd = NULL;
static FILE *fail; /* failure file stream */
static time_t seconds; /* that number of days in seconds */
static unsigned long umin; /* if uflg and has_umin, only display users with uid >= umin */
@@ -111,11 +88,8 @@ static void print_one (/*@null@*/const struct passwd *pw, bool force)
off_t offset;
struct faillog fl;
time_t now;
-
-#ifdef HAVE_STRFTIME
char *cp;
char ptime[80];
-#endif
if (NULL == pw) {
return;
@@ -168,13 +142,11 @@ static void print_one (/*@null@*/const struct passwd *pw, bool force)
fprintf (stderr, "Cannot read time from faillog.\n");
return;
}
-#ifdef HAVE_STRFTIME
strftime (ptime, sizeof (ptime), "%D %H:%M:%S %z", tm);
cp = ptime;
-#endif
+
printf ("%-9s %5d %5d ",
pw->pw_name, fl.fail_cnt, fl.fail_max);
- /* FIXME: cp is not defined ifndef HAVE_STRFTIME */
printf ("%s %s", cp, fl.fail_line);
if (0 != fl.fail_locktime) {
if ( ((fl.fail_time + fl.fail_locktime) > now)
@@ -574,7 +546,8 @@ int main (int argc, char **argv)
* most error messages.
*/
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
diff --git a/src/free_subid_range.c b/src/free_subid_range.c
index 1e666371..a2d2e8e0 100644
--- a/src/free_subid_range.c
+++ b/src/free_subid_range.c
@@ -1,13 +1,15 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
#include <stdio.h>
#include <unistd.h>
#include "subid.h"
#include "stdlib.h"
#include "prototypes.h"
+#include "shadowlog.h"
/* Test program for the subid freeing routine */
const char *Prog;
-FILE *shadow_logfd = NULL;
void usage(void)
{
@@ -24,7 +26,8 @@ int main(int argc, char *argv[])
bool group = false; // get subuids by default
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
while ((c = getopt(argc, argv, "g")) != EOF) {
switch(c) {
case 'g': group = true; break;
@@ -39,9 +42,9 @@ int main(int argc, char *argv[])
range.start = atoi(argv[1]);
range.count = atoi(argv[2]);
if (group)
- ok = ungrant_subgid_range(&range);
+ ok = subid_ungrant_gid_range(&range);
else
- ok = ungrant_subuid_range(&range);
+ ok = subid_ungrant_uid_range(&range);
if (!ok) {
fprintf(stderr, "Failed freeing id range\n");
diff --git a/src/get_subid_owners.c b/src/get_subid_owners.c
index f9a266ba..b0f46397 100644
--- a/src/get_subid_owners.c
+++ b/src/get_subid_owners.c
@@ -1,10 +1,12 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
#include <stdio.h>
#include "subid.h"
#include "stdlib.h"
#include "prototypes.h"
+#include "shadowlog.h"
const char *Prog;
-FILE *shadow_logfd = NULL;
void usage(void)
{
@@ -20,16 +22,17 @@ int main(int argc, char *argv[])
uid_t *uids;
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
if (argc < 2) {
usage();
}
if (argc == 3 && strcmp(argv[1], "-g") == 0)
- n = get_subgid_owners(atoi(argv[2]), &uids);
+ n = subid_get_gid_owners(atoi(argv[2]), &uids);
else if (argc == 2 && strcmp(argv[1], "-h") == 0)
usage();
else
- n = get_subuid_owners(atoi(argv[1]), &uids);
+ n = subid_get_uid_owners(atoi(argv[1]), &uids);
if (n < 0) {
fprintf(stderr, "No owners found\n");
exit(1);
diff --git a/src/list_subid_ranges.c b/src/getsubids.c
index f649a002..4384cfae 100644
--- a/src/list_subid_ranges.c
+++ b/src/getsubids.c
@@ -1,10 +1,13 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
#include "subid.h"
-#include "stdlib.h"
#include "prototypes.h"
+#include "shadowlog.h"
const char *Prog;
-FILE *shadow_logfd = NULL;
void usage(void)
{
@@ -21,17 +24,18 @@ int main(int argc, char *argv[])
const char *owner;
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
if (argc < 2)
usage();
owner = argv[1];
if (argc == 3 && strcmp(argv[1], "-g") == 0) {
owner = argv[2];
- count = get_subgid_ranges(owner, &ranges);
+ count = subid_get_gid_ranges(owner, &ranges);
} else if (argc == 2 && strcmp(argv[1], "-h") == 0) {
usage();
} else {
- count = get_subuid_ranges(owner, &ranges);
+ count = subid_get_uid_ranges(owner, &ranges);
}
if (!ranges) {
fprintf(stderr, "Error fetching ranges\n");
diff --git a/src/gpasswd.c b/src/gpasswd.c
index a43d9a59..c7c9477d 100644
--- a/src/gpasswd.c
+++ b/src/gpasswd.c
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 1990 - 1994, Julianne Frances Haugh
- * Copyright (c) 1996 - 2000, Marek Michałkiewicz
- * Copyright (c) 2001 - 2006, Tomasz Kłoczko
- * Copyright (c) 2007 - 2011, Nicolas François
- * All rights reserved.
+ * SPDX-FileCopyrightText: 1990 - 1994, Julianne Frances Haugh
+ * SPDX-FileCopyrightText: 1996 - 2000, Marek Michałkiewicz
+ * SPDX-FileCopyrightText: 2001 - 2006, Tomasz Kłoczko
+ * SPDX-FileCopyrightText: 2007 - 2011, Nicolas François
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the copyright holders or contributors may not be used to
- * endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * SPDX-License-Identifier: BSD-3-Clause
*/
#include <config.h>
@@ -53,12 +30,12 @@
/*@-exitarg@*/
#include "exitcodes.h"
+#include "shadowlog.h"
/*
* Global variables
*/
/* The name of this command, as it is invoked */
const char *Prog;
-FILE *shadow_logfd = NULL;
#ifdef SHADOWGRP
/* Indicate if shadow groups are enabled on the system
@@ -989,7 +966,8 @@ int main (int argc, char **argv)
*/
bywho = getuid ();
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
OPENLOG ("gpasswd");
setbuf (stdout, NULL);
@@ -1207,11 +1185,13 @@ int main (int argc, char **argv)
sssd_flush_cache (SSSD_DB_GROUP);
#ifdef SHADOWGRP
- if (sgent.sg_adm) {
- xfree(sgent.sg_adm);
- }
- if (sgent.sg_mem) {
- xfree(sgent.sg_mem);
+ if (is_shadowgrp) {
+ if (sgent.sg_adm) {
+ xfree(sgent.sg_adm);
+ }
+ if (sgent.sg_mem) {
+ xfree(sgent.sg_mem);
+ }
}
#endif
if (grent.gr_mem) {
diff --git a/src/groupadd.c b/src/groupadd.c
index d7f68b1a..66ccb53e 100644
--- a/src/groupadd.c
+++ b/src/groupadd.c
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 1991 - 1993, Julianne Frances Haugh
- * Copyright (c) 1996 - 2000, Marek Michałkiewicz
- * Copyright (c) 2000 - 2006, Tomasz Kłoczko
- * Copyright (c) 2007 - 2011, Nicolas François
- * All rights reserved.
+ * SPDX-FileCopyrightText: 1991 - 1993, Julianne Frances Haugh
+ * SPDX-FileCopyrightText: 1996 - 2000, Marek Michałkiewicz
+ * SPDX-FileCopyrightText: 2000 - 2006, Tomasz Kłoczko
+ * SPDX-FileCopyrightText: 2007 - 2011, Nicolas François
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the copyright holders or contributors may not be used to
- * endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * SPDX-License-Identifier: BSD-3-Clause
*/
#include <config.h>
@@ -56,6 +33,7 @@
#ifdef SHADOWGRP
#include "sgroupio.h"
#endif
+#include "shadowlog.h"
/*
* exit status values
@@ -72,7 +50,6 @@
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static /*@null@*/char *group_name;
static gid_t group_id;
@@ -599,7 +576,8 @@ int main (int argc, char **argv)
* Get my name so that I can use it to report errors.
*/
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
diff --git a/src/groupdel.c b/src/groupdel.c
index 5c893128..c84faa79 100644
--- a/src/groupdel.c
+++ b/src/groupdel.c
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 1991 - 1994, Julianne Frances Haugh
- * Copyright (c) 1996 - 2000, Marek Michałkiewicz
- * Copyright (c) 2000 - 2006, Tomasz Kłoczko
- * Copyright (c) 2007 - 2011, Nicolas François
- * All rights reserved.
+ * SPDX-FileCopyrightText: 1991 - 1994, Julianne Frances Haugh
+ * SPDX-FileCopyrightText: 1996 - 2000, Marek Michałkiewicz
+ * SPDX-FileCopyrightText: 2000 - 2006, Tomasz Kłoczko
+ * SPDX-FileCopyrightText: 2007 - 2011, Nicolas François
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the copyright holders or contributors may not be used to
- * endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * SPDX-License-Identifier: BSD-3-Clause
*/
#include <config.h>
@@ -54,11 +31,11 @@
#ifdef SHADOWGRP
#include "sgroupio.h"
#endif
+#include "shadowlog.h"
/*
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static char *group_name;
static gid_t group_id = -1;
@@ -358,7 +335,7 @@ static void process_flags (int argc, char **argv)
* main - groupdel command
*
* The syntax of the groupdel command is
- *
+ *
* groupdel group
*
* The named group will be deleted.
@@ -377,7 +354,8 @@ int main (int argc, char **argv)
* Get my name so that I can use it to report errors.
*/
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
diff --git a/src/groupmems.c b/src/groupmems.c
index 654a8f3a..a0e3266b 100644
--- a/src/groupmems.c
+++ b/src/groupmems.c
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 2000 , International Business Machines
- * George Kraft IV, gk4@us.ibm.com, 03/23/2000
- * Copyright (c) 2000 - 2006, Tomasz Kłoczko
- * Copyright (c) 2007 - 2011, Nicolas François
- * All rights reserved.
+ * SPDX-FileCopyrightText: 2000 , International Business Machines
+ * SPDX-FileCopyrightText: 2000 , George Kraft IV, gk4@us.ibm.com, 03/23/2000
+ * SPDX-FileCopyrightText: 2000 - 2006, Tomasz Kłoczko
+ * SPDX-FileCopyrightText: 2007 - 2011, Nicolas François
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the copyright holders or contributors may not be used to
- * endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * SPDX-License-Identifier: BSD-3-Clause
*/
#include <config.h>
@@ -47,6 +24,7 @@
#ifdef SHADOWGRP
#include "sgroupio.h"
#endif
+#include "shadowlog.h"
/* Exit Status Values */
/*@-exitarg@*/
@@ -65,7 +43,6 @@
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static char *adduser = NULL;
static char *deluser = NULL;
@@ -85,7 +62,7 @@ static bool sgr_locked = false;
static char *whoami (void);
static void add_user (const char *user,
const struct group *grp);
-static void remove_user (const char *user,
+static void remove_user (const char *user,
const struct group *grp);
static void purge_members (const struct group *grp);
static void display_members (const char *const *members);
@@ -197,7 +174,7 @@ static void add_user (const char *user,
/*
* remove_user - Remove an user from a given group
*/
-static void remove_user (const char *user,
+static void remove_user (const char *user,
const struct group *grp)
{
struct group *newgrp;
@@ -587,7 +564,7 @@ static void close_files (void)
#endif
}
-int main (int argc, char **argv)
+int main (int argc, char **argv)
{
char *name;
const struct group *grp;
@@ -596,7 +573,8 @@ int main (int argc, char **argv)
* Get my name so that I can use it to report errors.
*/
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
diff --git a/src/groupmod.c b/src/groupmod.c
index acd6f350..006eca1c 100644
--- a/src/groupmod.c
+++ b/src/groupmod.c
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 1991 - 1994, Julianne Frances Haugh
- * Copyright (c) 1996 - 2000, Marek Michałkiewicz
- * Copyright (c) 2000 - 2006, Tomasz Kłoczko
- * Copyright (c) 2007 - 2011, Nicolas François
- * All rights reserved.
+ * SPDX-FileCopyrightText: 1991 - 1994, Julianne Frances Haugh
+ * SPDX-FileCopyrightText: 1996 - 2000, Marek Michałkiewicz
+ * SPDX-FileCopyrightText: 2000 - 2006, Tomasz Kłoczko
+ * SPDX-FileCopyrightText: 2007 - 2011, Nicolas François
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the copyright holders or contributors may not be used to
- * endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * SPDX-License-Identifier: BSD-3-Clause
*/
#include <config.h>
@@ -56,6 +33,7 @@
#ifdef SHADOWGRP
#include "sgroupio.h"
#endif
+#include "shadowlog.h"
/*
* exit status values
*/
@@ -76,7 +54,6 @@
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
#ifdef SHADOWGRP
static bool is_shadow_grp;
@@ -793,7 +770,8 @@ int main (int argc, char **argv)
* Get my name so that I can use it to report errors.
*/
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
diff --git a/src/groups.c b/src/groups.c
index 3bfd4830..12bd224b 100644
--- a/src/groups.c
+++ b/src/groups.c
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 1991 - 1993, Julianne Frances Haugh
- * Copyright (c) 1996 - 2000, Marek Michałkiewicz
- * Copyright (c) 2001 - 2006, Tomasz Kłoczko
- * Copyright (c) 2007 - 2008, Nicolas François
- * All rights reserved.
+ * SPDX-FileCopyrightText: 1991 - 1993, Julianne Frances Haugh
+ * SPDX-FileCopyrightText: 1996 - 2000, Marek Michałkiewicz
+ * SPDX-FileCopyrightText: 2001 - 2006, Tomasz Kłoczko
+ * SPDX-FileCopyrightText: 2007 - 2008, Nicolas François
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the copyright holders or contributors may not be used to
- * endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * SPDX-License-Identifier: BSD-3-Clause
*/
#include <config.h>
@@ -39,11 +16,11 @@
#include <stdio.h>
#include "defines.h"
#include "prototypes.h"
+#include "shadowlog.h"
/*
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
/* local function prototypes */
static void print_groups (const char *member);
@@ -107,18 +84,12 @@ static void print_groups (const char *member)
*/
int main (int argc, char **argv)
{
-#ifdef HAVE_GETGROUPS
long sys_ngroups;
GETGROUPS_T *groups;
-#else
- char *logname;
- char *getlogin ();
-#endif
-#ifdef HAVE_GETGROUPS
sys_ngroups = sysconf (_SC_NGROUPS_MAX);
groups = (GETGROUPS_T *) malloc (sizeof (GETGROUPS_T) * sys_ngroups);
-#endif
+
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
(void) textdomain (PACKAGE);
@@ -127,7 +98,8 @@ int main (int argc, char **argv)
* Get the program name so that error messages can use it.
*/
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
if (argc == 1) {
@@ -136,7 +108,6 @@ int main (int argc, char **argv)
* current user.
*/
-#ifdef HAVE_GETGROUPS
int i;
int pri_grp; /* TODO: should be GETGROUPS_T */
/*
@@ -195,18 +166,6 @@ int main (int argc, char **argv)
}
}
(void) putchar ('\n');
-#else
- /*
- * This system does not have the getgroups() system call, so
- * I must check the groups file directly.
- */
- logname = getlogin ();
- if (NULL != logname) {
- print_groups (logname);
- } else {
- exit (EXIT_FAILURE);
- }
-#endif
} else {
/*
diff --git a/src/grpck.c b/src/grpck.c
index b594851b..7accac94 100644
--- a/src/grpck.c
+++ b/src/grpck.c
@@ -1,34 +1,11 @@
/*
- * Copyright (c) 1992 - 1994, Julianne Frances Haugh
- * Copyright (c) 1996 - 2000, Marek Michałkiewicz
- * Copyright (c) 2001 , Michał Moskal
- * Copyright (c) 2001 - 2006, Tomasz Kłoczko
- * Copyright (c) 2007 - 2011, Nicolas François
- * All rights reserved.
+ * SPDX-FileCopyrightText: 1992 - 1994, Julianne Frances Haugh
+ * SPDX-FileCopyrightText: 1996 - 2000, Marek Michałkiewicz
+ * SPDX-FileCopyrightText: 2001 , Michał Moskal
+ * SPDX-FileCopyrightText: 2001 - 2006, Tomasz Kłoczko
+ * SPDX-FileCopyrightText: 2007 - 2011, Nicolas François
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the copyright holders or contributors may not be used to
- * endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * SPDX-License-Identifier: BSD-3-Clause
*/
#include <config.h>
@@ -45,6 +22,7 @@
#include "nscd.h"
#include "sssd.h"
#include "prototypes.h"
+#include "shadowlog.h"
#ifdef SHADOWGRP
#include "sgroupio.h"
@@ -66,7 +44,6 @@
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static const char *grp_file = GROUP_FILE;
static bool use_system_grp_file = true;
@@ -718,7 +695,7 @@ static void check_sgr_file (int *errors, bool *changed)
}
/*
- * All shadow group file deletions wind up here.
+ * All shadow group file deletions wind up here.
* This code removes the current entry from the
* linked list. When done, it skips back to the top
* of the loop to try out the next list element.
@@ -841,7 +818,8 @@ int main (int argc, char **argv)
* Get my name so that I can use it to report errors.
*/
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
diff --git a/src/grpconv.c b/src/grpconv.c
index aecafa40..57d8d58e 100644
--- a/src/grpconv.c
+++ b/src/grpconv.c
@@ -1,32 +1,9 @@
/*
- * Copyright (c) 1996 - 2000, Marek Michałkiewicz
- * Copyright (c) 2002 - 2006, Tomasz Kłoczko
- * Copyright (c) 2011 , Nicolas François
- * All rights reserved.
+ * SPDX-FileCopyrightText: 1996 - 2000, Marek Michałkiewicz
+ * SPDX-FileCopyrightText: 2002 - 2006, Tomasz Kłoczko
+ * SPDX-FileCopyrightText: 2011 , Nicolas François
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the copyright holders or contributors may not be used to
- * endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * SPDX-License-Identifier: BSD-3-Clause
*/
/*
@@ -55,11 +32,11 @@
#ifdef SHADOWGRP
#include "groupio.h"
#include "sgroupio.h"
+#include "shadowlog.h"
/*
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static bool gr_locked = false;
static bool sgr_locked = false;
@@ -147,7 +124,8 @@ int main (int argc, char **argv)
struct sgrp sgent;
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
diff --git a/src/grpunconv.c b/src/grpunconv.c
index d750e2bd..fc6cecf9 100644
--- a/src/grpunconv.c
+++ b/src/grpunconv.c
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 1996 , Michael Meskes
- * Copyright (c) 1996 - 2000, Marek Michałkiewicz
- * Copyright (c) 2002 - 2006, Tomasz Kłoczko
- * Copyright (c) 2008 - 2011, Nicolas François
- * All rights reserved.
+ * SPDX-FileCopyrightText: 1996 , Michael Meskes
+ * SPDX-FileCopyrightText: 1996 - 2000, Marek Michałkiewicz
+ * SPDX-FileCopyrightText: 2002 - 2006, Tomasz Kłoczko
+ * SPDX-FileCopyrightText: 2008 - 2011, Nicolas François
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the copyright holders or contributors may not be used to
- * endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * SPDX-License-Identifier: BSD-3-Clause
*/
/*
@@ -55,11 +32,11 @@
#ifdef SHADOWGRP
#include "groupio.h"
#include "sgroupio.h"
+#include "shadowlog.h"
/*
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static bool gr_locked = false;
static bool sgr_locked = false;
@@ -146,7 +123,8 @@ int main (int argc, char **argv)
const struct sgrp *sg;
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
diff --git a/src/id.c b/src/id.c
index 4462ae09..49521093 100644
--- a/src/id.c
+++ b/src/id.c
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 1991 - 1994, Julianne Frances Haugh
- * Copyright (c) 1996 - 2000, Marek Michałkiewicz
- * Copyright (c) 2001 - 2006, Tomasz Kłoczko
- * Copyright (c) 2007 - 2008, Nicolas François
- * All rights reserved.
+ * SPDX-FileCopyrightText: 1991 - 1994, Julianne Frances Haugh
+ * SPDX-FileCopyrightText: 1996 - 2000, Marek Michałkiewicz
+ * SPDX-FileCopyrightText: 2001 - 2006, Tomasz Kłoczko
+ * SPDX-FileCopyrightText: 2007 - 2008, Nicolas François
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the copyright holders or contributors may not be used to
- * endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * SPDX-License-Identifier: BSD-3-Clause
*/
/*
@@ -52,11 +29,7 @@ static void usage (void);
static void usage (void)
{
-#ifdef HAVE_GETGROUPS
(void) fputs (_("Usage: id [-a]\n"), stderr);
-#else
- (void) fputs (_("Usage: id\n"), stderr);
-#endif
exit (EXIT_FAILURE);
}
@@ -73,11 +46,9 @@ static void usage (void)
* gid_t for everything. Some systems have a small and fixed NGROUPS,
* usually about 16 or 32. Others use bigger values.
*/
-#ifdef HAVE_GETGROUPS
GETGROUPS_T *groups;
int ngroups;
bool aflg = 0;
-#endif
struct passwd *pw;
struct group *gr;
@@ -92,8 +63,8 @@ static void usage (void)
* work if the system library is recompiled.
*/
sys_ngroups = sysconf (_SC_NGROUPS_MAX);
-#ifdef HAVE_GETGROUPS
groups = (GETGROUPS_T *) malloc (sizeof (GETGROUPS_T) * sys_ngroups);
+
/*
* See if the -a flag has been given to print out the concurrent
* group set.
@@ -106,11 +77,6 @@ static void usage (void)
aflg = true;
}
}
-#else
- if (argc > 1) {
- usage ();
- }
-#endif
ruid = getuid ();
euid = geteuid ();
@@ -161,7 +127,7 @@ static void usage (void)
(void) printf (" EGID=%lu", (unsigned long) egid);
}
}
-#ifdef HAVE_GETGROUPS
+
/*
* Print out the concurrent group set if the user has requested it.
* The group numbers will be printed followed by their names.
@@ -195,7 +161,6 @@ static void usage (void)
}
}
free (groups);
-#endif
/*
* Finish off the line.
diff --git a/src/lastlog.c b/src/lastlog.c
index 1b1803e1..3c0fc9c6 100644
--- a/src/lastlog.c
+++ b/src/lastlog.c
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 1989 - 1994, Julianne Frances Haugh
- * Copyright (c) 1996 - 2000, Marek Michałkiewicz
- * Copyright (c) 2000 - 2006, Tomasz Kłoczko
- * Copyright (c) 2007 - 2011, Nicolas François
- * All rights reserved.
+ * SPDX-FileCopyrightText: 1989 - 1994, Julianne Frances Haugh
+ * SPDX-FileCopyrightText: 1996 - 2000, Marek Michałkiewicz
+ * SPDX-FileCopyrightText: 2000 - 2006, Tomasz Kłoczko
+ * SPDX-FileCopyrightText: 2007 - 2011, Nicolas François
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the copyright holders or contributors may not be used to
- * endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * SPDX-License-Identifier: BSD-3-Clause
*/
#include <config.h>
@@ -50,6 +27,7 @@
#include "getdef.h"
/*@-exitarg@*/
#include "exitcodes.h"
+#include "shadowlog.h"
/*
* Needed for MkLinux DR1/2/2.1 - J.
@@ -62,7 +40,6 @@
* Global variables
*/
const char *Prog; /* Program name */
-FILE *shadow_logfd = NULL;
static FILE *lastlogfile; /* lastlog file stream */
static unsigned long umin; /* if uflg and has_umin, only display users with uid >= umin */
static bool has_umin = false;
@@ -108,10 +85,7 @@ static void print_one (/*@null@*/const struct passwd *pw)
time_t ll_time;
off_t offset;
struct lastlog ll;
-
-#ifdef HAVE_STRFTIME
char ptime[80];
-#endif
#ifdef HAVE_LL_HOST
int maxIPv6Addrlen;
@@ -177,13 +151,8 @@ static void print_one (/*@null@*/const struct passwd *pw)
ll_time = ll.ll_time;
tm = localtime (&ll_time);
-#ifdef HAVE_STRFTIME
strftime (ptime, sizeof (ptime), "%a %b %e %H:%M:%S %z %Y", tm);
cp = ptime;
-#else
- cp = asctime (tm);
- cp[24] = '\0';
-#endif
if (ll.ll_time == (time_t) 0) {
cp = _("**Never logged in**\0");
@@ -318,7 +287,8 @@ int main (int argc, char **argv)
* most error messages.
*/
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
diff --git a/src/login.c b/src/login.c
index 7ec2401e..bb85c758 100644
--- a/src/login.c
+++ b/src/login.c
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 1989 - 1994, Julianne Frances Haugh
- * Copyright (c) 1996 - 2001, Marek Michałkiewicz
- * Copyright (c) 2001 - 2006, Tomasz Kłoczko
- * Copyright (c) 2007 - 2012, Nicolas François
- * All rights reserved.
+ * SPDX-FileCopyrightText: 1989 - 1994, Julianne Frances Haugh
+ * SPDX-FileCopyrightText: 1996 - 2001, Marek Michałkiewicz
+ * SPDX-FileCopyrightText: 2001 - 2006, Tomasz Kłoczko
+ * SPDX-FileCopyrightText: 2007 - 2012, Nicolas François
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the copyright holders or contributors may not be used to
- * endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * SPDX-License-Identifier: BSD-3-Clause
*/
#include <config.h>
@@ -53,6 +30,7 @@
#include "pwauth.h"
/*@-exitarg@*/
#include "exitcodes.h"
+#include "shadowlog.h"
#ifdef USE_PAM
#include "pam_defs.h"
@@ -83,7 +61,6 @@ static pam_handle_t *pamh = NULL;
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static const char *hostname = "";
static /*@null@*/ /*@only@*/char *username = NULL;
@@ -217,7 +194,7 @@ static void setup_tty (void)
/*
* ttymon invocation prefers this, but these settings
- * won't come into effect after the first username login
+ * won't come into effect after the first username login
*/
(void) STTY (0, &termio);
}
@@ -401,7 +378,7 @@ static void init_env (void)
}
}
#endif /* !USE_PAM */
- /*
+ /*
* Add the clock frequency so that profiling commands work
* correctly.
*/
@@ -520,7 +497,7 @@ static void update_utmp (const char *user,
* of reasons, such as X servers or network logins.
*
* the flags which login supports are
- *
+ *
* -p - preserve the environment
* -r - perform autologin protocol for rlogin
* -f - do not perform authentication, user is preauthenticated
@@ -534,7 +511,7 @@ int main (int argc, char **argv)
#ifdef RLOGIN
char term[128] = "";
#endif /* RLOGIN */
-#if defined(HAVE_STRFTIME) && !defined(USE_PAM)
+#if !defined(USE_PAM)
char ptime[80];
#endif
unsigned int delay;
@@ -578,7 +555,8 @@ int main (int argc, char **argv)
amroot = (getuid () == 0);
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
if (geteuid() != 0) {
fprintf (stderr, _("%s: Cannot possibly work without effective root\n"), Prog);
@@ -650,7 +628,7 @@ int main (int argc, char **argv)
(void) umask (getdef_num ("UMASK", GETDEF_DEFAULT_UMASK));
{
- /*
+ /*
* Use the ULIMIT in the login.defs file, and if
* there isn't one, use the default value. The
* user may have one for themselves, but otherwise,
@@ -983,12 +961,12 @@ int main (int argc, char **argv)
if (strcmp (user_passwd, "") == 0) {
char *prevent_no_auth = getdef_str("PREVENT_NO_AUTH");
- if(prevent_no_auth == NULL) {
+ if (prevent_no_auth == NULL) {
prevent_no_auth = "superuser";
}
- if(strcmp(prevent_no_auth, "yes") == 0) {
+ if (strcmp(prevent_no_auth, "yes") == 0) {
failed = true;
- } else if( (pwd->pw_uid == 0)
+ } else if ((pwd->pw_uid == 0)
&& (strcmp(prevent_no_auth, "superuser") == 0)) {
failed = true;
}
@@ -1288,6 +1266,7 @@ int main (int argc, char **argv)
env++;
}
}
+ (void) pam_end (pamh, PAM_SUCCESS | PAM_DATA_SILENT);
#endif
(void) setlocale (LC_ALL, "");
@@ -1319,16 +1298,11 @@ int main (int argc, char **argv)
&& (ll.ll_time != 0)) {
time_t ll_time = ll.ll_time;
-#ifdef HAVE_STRFTIME
(void) strftime (ptime, sizeof (ptime),
"%a %b %e %H:%M:%S %z %Y",
localtime (&ll_time));
printf (_("Last login: %s on %s"),
ptime, ll.ll_line);
-#else
- printf (_("Last login: %.19s on %s"),
- ctime (&ll_time), ll.ll_line);
-#endif
#ifdef HAVE_LL_HOST /* __linux__ || SUN4 */
if ('\0' != ll.ll_host[0]) {
printf (_(" from %.*s"),
diff --git a/src/login_nopam.c b/src/login_nopam.c
index 68a37755..df6ba882 100644
--- a/src/login_nopam.c
+++ b/src/login_nopam.c
@@ -1,4 +1,9 @@
/* Taken from logdaemon-5.0, only minimal changes. --marekm */
+/*
+ * SPDX-FileCopyrightText: 1990 - 1995, Wietse Venema.
+ *
+ * SPDX-License-Identifier: Unlicense
+ */
/************************************************************************
* Copyright 1995 by Wietse Venema. All rights reserved. Individual files
@@ -10,7 +15,7 @@
*
* Redistribution and use in source and binary forms are permitted
* provided that this entire copyright notice is duplicated in all such
-* copies.
+* copies.
*
* This software is provided "as is" and without any expressed or implied
* warranties, including, without limitation, the implied warranties of
@@ -30,7 +35,7 @@
* control based on login names and on host (or domain) names, internet
* addresses (or network numbers), or on terminal line names in case of
* non-networked logins. Diagnostics are reported through syslog(3).
- *
+ *
* Author: Wietse Venema, Eindhoven University of Technology, The Netherlands.
*/
#include <sys/types.h>
diff --git a/src/logoutd.c b/src/logoutd.c
index 780c29f8..d369acf4 100644
--- a/src/logoutd.c
+++ b/src/logoutd.c
@@ -1,32 +1,9 @@
/*
- * Copyright (c) 1991 - 1993, Julianne Frances Haugh
- * Copyright (c) 1996 - 2000, Marek Michałkiewicz
- * Copyright (c) 2001 - 2006, Tomasz Kłoczko
- * All rights reserved.
+ * SPDX-FileCopyrightText: 1991 - 1993, Julianne Frances Haugh
+ * SPDX-FileCopyrightText: 1996 - 2000, Marek Michałkiewicz
+ * SPDX-FileCopyrightText: 2001 - 2006, Tomasz Kłoczko
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the copyright holders or contributors may not be used to
- * endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * SPDX-License-Identifier: BSD-3-Clause
*/
#include <config.h>
@@ -40,11 +17,11 @@
#include <sys/types.h>
#include "defines.h"
#include "prototypes.h"
+#include "shadowlog.h"
/*
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
#ifndef DEFAULT_HUP_MESG
#define DEFAULT_HUP_MESG _("login time exceeded\n\n")
@@ -188,7 +165,8 @@ int main (int argc, char **argv)
* Start syslogging everything
*/
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
OPENLOG ("logoutd");
@@ -198,7 +176,7 @@ int main (int argc, char **argv)
*/
while (true) {
- /*
+ /*
* Attempt to re-open the utmpx/utmp file. The file is only
* open while it is being used.
*/
diff --git a/src/new_subid_range.c b/src/new_subid_range.c
index 721f9547..6cb294d4 100644
--- a/src/new_subid_range.c
+++ b/src/new_subid_range.c
@@ -1,13 +1,15 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+
#include <stdio.h>
#include <unistd.h>
#include "subid.h"
#include "stdlib.h"
#include "prototypes.h"
+#include "shadowlog.h"
/* Test program for the subid creation routine */
const char *Prog;
-FILE *shadow_logfd = NULL;
void usage(void)
{
@@ -27,7 +29,8 @@ int main(int argc, char *argv[])
bool ok;
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
while ((c = getopt(argc, argv, "gn")) != EOF) {
switch(c) {
case 'n': makenew = true; break;
@@ -45,9 +48,9 @@ int main(int argc, char *argv[])
if (argc > 1)
range.count = atoi(argv[1]);
if (group)
- ok = grant_subgid_range(&range, !makenew);
+ ok = subid_grant_gid_range(&range, !makenew);
else
- ok = grant_subuid_range(&range, !makenew);
+ ok = subid_grant_uid_range(&range, !makenew);
if (!ok) {
fprintf(stderr, "Failed creating new id range\n");
diff --git a/src/newgidmap.c b/src/newgidmap.c
index 51a2eb44..ebf16cde 100644
--- a/src/newgidmap.c
+++ b/src/newgidmap.c
@@ -1,30 +1,7 @@
/*
- * Copyright (c) 2013 Eric Biederman
- * All rights reserved.
+ * SPDX-FileCopyrightText: 2013 Eric Biederman
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the copyright holders or contributors may not be used to
- * endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * SPDX-License-Identifier: BSD-3-Clause
*/
#include <config.h>
@@ -41,12 +18,12 @@
#include "subordinateio.h"
#include "getdef.h"
#include "idmapping.h"
+#include "shadowlog.h"
/*
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static bool verify_range(struct passwd *pw, struct map_range *range, bool *allow_setgroups)
@@ -177,7 +154,8 @@ int main(int argc, char **argv)
bool allow_setgroups = false;
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
/*
* The valid syntax are
diff --git a/src/newgrp.c b/src/newgrp.c
index 2b9293b4..cb88f6d7 100644
--- a/src/newgrp.c
+++ b/src/newgrp.c
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 1990 - 1994, Julianne Frances Haugh
- * Copyright (c) 1996 - 2000, Marek Michałkiewicz
- * Copyright (c) 2001 - 2006, Tomasz Kłoczko
- * Copyright (c) 2007 - 2008, Nicolas François
- * All rights reserved.
+ * SPDX-FileCopyrightText: 1990 - 1994, Julianne Frances Haugh
+ * SPDX-FileCopyrightText: 1996 - 2000, Marek Michałkiewicz
+ * SPDX-FileCopyrightText: 2001 - 2006, Tomasz Kłoczko
+ * SPDX-FileCopyrightText: 2007 - 2008, Nicolas François
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the copyright holders or contributors may not be used to
- * endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * SPDX-License-Identifier: BSD-3-Clause
*/
#include <config.h>
@@ -44,12 +21,12 @@
#include "prototypes.h"
/*@-exitarg@*/
#include "exitcodes.h"
+#include "shadowlog.h"
/*
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
extern char **newenvp;
extern char **environ;
@@ -163,8 +140,8 @@ static void check_perms (const struct group *grp,
spwd = xgetspnam (pwd->pw_name);
if (NULL != spwd) {
pwd->pw_passwd = xstrdup (spwd->sp_pwdp);
+ spw_free (spwd);
}
- spw_free (spwd);
if ((pwd->pw_passwd[0] == '\0') && (grp->gr_passwd[0] != '\0')) {
needspasswd = true;
@@ -445,7 +422,8 @@ int main (int argc, char **argv)
* don't need to re-exec anything. -- JWP
*/
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
is_newgrp = (strcmp (Prog, "newgrp") == 0);
OPENLOG (is_newgrp ? "newgrp" : "sg");
argc--;
@@ -494,7 +472,7 @@ int main (int argc, char **argv)
initflag = true;
}
if (!is_newgrp) {
- /*
+ /*
* Do the command line for everything that is
* not "newgrp".
*/
@@ -533,7 +511,7 @@ int main (int argc, char **argv)
group = argv[0];
} else {
/*
- * get the group file entry for her login group id.
+ * get the group file entry for her login group id.
* the entry must exist, simply to be annoying.
*
* Perhaps in the past, but the default behavior now depends on the
@@ -595,17 +573,17 @@ int main (int argc, char **argv)
* now we put her in the new group. The password file entry for her
* current user id has been gotten. If there was no optional group
* argument she will have her real and effective group id set to the
- * set to the value from her password file entry.
+ * set to the value from her password file entry.
*
* If run as newgrp, or as sg with no command, this process exec's
- * an interactive subshell with the effective GID of the new group.
+ * an interactive subshell with the effective GID of the new group.
* If run as sg with a command, that command is exec'ed in this
* subshell. When this process terminates, either because the user
* exits, or the command completes, the parent of this process
* resumes with the current GID.
*
* If a group is explicitly specified on the command line, the
- * interactive shell or command is run with that effective GID.
+ * interactive shell or command is run with that effective GID.
* Access will be denied if no entry for that group can be found in
* /etc/group. If the current user name appears in the members list
* for that group, access will be granted immediately; if not, the
@@ -650,7 +628,7 @@ int main (int argc, char **argv)
}
#endif /* HAVE_SETGROUPS */
/*
- * For splitted groups (due to limitations of NIS), check all
+ * For splitted groups (due to limitations of NIS), check all
* groups of the same GID like the requested group for
* membership of the current user.
*/
@@ -698,7 +676,7 @@ int main (int argc, char **argv)
#ifdef HAVE_SETGROUPS
/*
* I am going to try to add her new group id to her concurrent group
- * set. If the group id is already present i'll just skip this part.
+ * set. If the group id is already present i'll just skip this part.
* If the group doesn't fit, i'll complain loudly and skip this
* part.
*/
@@ -854,7 +832,7 @@ int main (int argc, char **argv)
/*
* The previous code, when run as newgrp, re-exec'ed the shell in
- * the current process with the original gid on error conditions.
+ * the current process with the original gid on error conditions.
* See the comment above. This historical behavior now has the
* effect of creating unlogged extraneous shell layers when the
* command line has an error or there is an authentication failure.
@@ -867,7 +845,7 @@ int main (int argc, char **argv)
if (NULL != group) {
snprintf (audit_buf, sizeof(audit_buf),
"changing new-group=%s", group);
- audit_logger (AUDIT_CHGRP_ID, Prog,
+ audit_logger (AUDIT_CHGRP_ID, Prog,
audit_buf, NULL,
(unsigned int) getuid (), 0);
} else {
diff --git a/src/newuidmap.c b/src/newuidmap.c
index bdd9cadf..9aa2ddcc 100644
--- a/src/newuidmap.c
+++ b/src/newuidmap.c
@@ -1,30 +1,7 @@
/*
- * Copyright (c) 2013 Eric Biederman
- * All rights reserved.
+ * SPDX-FileCopyrightText: 2013 Eric Biederman
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the copyright holders or contributors may not be used to
- * endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * SPDX-License-Identifier: BSD-3-Clause
*/
#include <config.h>
@@ -41,12 +18,12 @@
#include "subordinateio.h"
#include "getdef.h"
#include "idmapping.h"
+#include "shadowlog.h"
/*
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static bool verify_range(struct passwd *pw, struct map_range *range)
{
@@ -107,7 +84,8 @@ int main(int argc, char **argv)
int written;
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
/*
* The valid syntax are
@@ -148,7 +126,7 @@ int main(int argc, char **argv)
(unsigned long) getuid ()));
return EXIT_FAILURE;
}
-
+
/* Get the effective uid and effective gid of the target process */
if (fstat(proc_dir_fd, &st) < 0) {
fprintf(stderr, _("%s: Could not stat directory for target %u\n"),
diff --git a/src/newusers.c b/src/newusers.c
index 16bf7229..c1d29f83 100644
--- a/src/newusers.c
+++ b/src/newusers.c
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 1990 - 1993, Julianne Frances Haugh
- * Copyright (c) 1996 - 2000, Marek Michałkiewicz
- * Copyright (c) 2000 - 2006, Tomasz Kłoczko
- * Copyright (c) 2007 - 2011, Nicolas François
- * All rights reserved.
+ * SPDX-FileCopyrightText: 1990 - 1993, Julianne Frances Haugh
+ * SPDX-FileCopyrightText: 1996 - 2000, Marek Michałkiewicz
+ * SPDX-FileCopyrightText: 2000 - 2006, Tomasz Kłoczko
+ * SPDX-FileCopyrightText: 2007 - 2011, Nicolas François
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the copyright holders or contributors may not be used to
- * endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * SPDX-License-Identifier: BSD-3-Clause
*/
/*
@@ -70,12 +47,12 @@
#include "subordinateio.h"
#endif /* ENABLE_SUBIDS */
#include "chkname.h"
+#include "shadowlog.h"
/*
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static bool rflg = false; /* create a system account */
#ifndef USE_PAM
@@ -428,7 +405,7 @@ static int add_user (const char *name, uid_t uid, gid_t gid)
}
#ifndef USE_PAM
-/*
+/*
* update_passwd - update the password in the passwd entry
*
* Return 0 if successful.
@@ -1071,7 +1048,8 @@ int main (int argc, char **argv)
#endif /* USE_PAM */
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
diff --git a/src/nologin.c b/src/nologin.c
index b137f9cd..a7442818 100644
--- a/src/nologin.c
+++ b/src/nologin.c
@@ -1,27 +1,7 @@
/*
- * Copyright (c) 2004 The FreeBSD Project.
- * All rights reserved.
+ * SPDX-FileCopyrightText: 2004 The FreeBSD Project.
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
+ * SPDX-License-Identifier: BSD-2-Clause
*/
diff --git a/src/passwd.c b/src/passwd.c
index 9d7df331..80531ec6 100644
--- a/src/passwd.c
+++ b/src/passwd.c
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 1989 - 1994, Julianne Frances Haugh
- * Copyright (c) 1996 - 2000, Marek Michałkiewicz
- * Copyright (c) 2001 - 2006, Tomasz Kłoczko
- * Copyright (c) 2007 - 2011, Nicolas François
- * All rights reserved.
+ * SPDX-FileCopyrightText: 1989 - 1994, Julianne Frances Haugh
+ * SPDX-FileCopyrightText: 1996 - 2000, Marek Michałkiewicz
+ * SPDX-FileCopyrightText: 2001 - 2006, Tomasz Kłoczko
+ * SPDX-FileCopyrightText: 2007 - 2011, Nicolas François
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the copyright holders or contributors may not be used to
- * endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * SPDX-License-Identifier: BSD-3-Clause
*/
#include <config.h>
@@ -50,6 +27,7 @@
#include "pwauth.h"
#include "pwio.h"
#include "shadowio.h"
+#include "shadowlog.h"
/*
* exit status values
@@ -66,7 +44,6 @@
* Global variables
*/
const char *Prog; /* Program name */
-FILE *shadow_logfd = NULL;
static char *name; /* The name of user whose password is being changed */
static char *myname; /* The current user's name */
@@ -135,7 +112,6 @@ static int new_password (const struct passwd *);
static void check_password (const struct passwd *, const struct spwd *);
#endif /* !USE_PAM */
-static /*@observer@*/const char *date_to_str (time_t);
static /*@observer@*/const char *pw_status (const char *);
static void print_status (const struct passwd *);
static /*@noreturn@*/void fail_exit (int);
@@ -328,7 +304,7 @@ static int new_password (const struct passwd *pw)
/*
* If enabled, warn about weak passwords even if you are
- * root (enter this password again to use it anyway).
+ * root (enter this password again to use it anyway).
* --marekm
*/
if (amroot && !warned && getdef_bool ("PASS_ALWAYS_WARN")
@@ -447,21 +423,6 @@ static void check_password (const struct passwd *pw, const struct spwd *sp)
}
#endif /* !USE_PAM */
-static /*@observer@*/const char *date_to_str (time_t t)
-{
- static char buf[80];
- struct tm *tm;
-
- tm = gmtime (&t);
-#ifdef HAVE_STRFTIME
- (void) strftime (buf, sizeof buf, "%m/%d/%Y", tm);
-#else /* !HAVE_STRFTIME */
- (void) snprintf (buf, sizeof buf, "%02d/%02d/%04d",
- tm->tm_mon + 1, tm->tm_mday, tm->tm_year + 1900);
-#endif /* !HAVE_STRFTIME */
- return buf;
-}
-
static /*@observer@*/const char *pw_status (const char *pass)
{
if (*pass == '*' || *pass == '!') {
@@ -478,21 +439,26 @@ static /*@observer@*/const char *pw_status (const char *pass)
*/
static void print_status (const struct passwd *pw)
{
+ char date[80];
struct spwd *sp;
sp = getspnam (pw->pw_name); /* local, no need for xgetspnam */
if (NULL != sp) {
+ date_to_str (sizeof(date), date, sp->sp_lstchg * SCALE),
(void) printf ("%s %s %s %lld %lld %lld %lld\n",
pw->pw_name,
pw_status (sp->sp_pwdp),
- date_to_str (sp->sp_lstchg * SCALE),
+ date,
((long long)sp->sp_min * SCALE) / DAY,
((long long)sp->sp_max * SCALE) / DAY,
((long long)sp->sp_warn * SCALE) / DAY,
((long long)sp->sp_inact * SCALE) / DAY);
- } else {
+ } else if (NULL != pw->pw_passwd) {
(void) printf ("%s %s\n",
pw->pw_name, pw_status (pw->pw_passwd));
+ } else {
+ (void) fprintf(stderr, _("%s: malformed password data obtained for user %s\n"),
+ Prog, pw->pw_name);
}
}
@@ -758,7 +724,8 @@ int main (int argc, char **argv)
* most error messages.
*/
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
@@ -1042,7 +1009,7 @@ int main (int argc, char **argv)
STRFCPY (crypt_passwd, cp);
/*
- * See if the user is permitted to change the password.
+ * See if the user is permitted to change the password.
* Otherwise, go ahead and set a new password.
*/
check_password (pw, sp);
@@ -1106,7 +1073,7 @@ int main (int argc, char **argv)
(void) printf (_("%s: password changed.\n"), Prog);
#endif /* USE_PAM */
} else {
- (void) printf (_("%s: password expiry information changed.\n"), Prog);
+ (void) printf (_("%s: password changed.\n"), Prog);
}
}
diff --git a/src/pwck.c b/src/pwck.c
index 4248944a..ee1df500 100644
--- a/src/pwck.c
+++ b/src/pwck.c
@@ -1,34 +1,11 @@
/*
- * Copyright (c) 1992 - 1994, Julianne Frances Haugh
- * Copyright (c) 1996 - 2000, Marek Michałkiewicz
- * Copyright (c) 2001 , Michał Moskal
- * Copyright (c) 2001 - 2006, Tomasz Kłoczko
- * Copyright (c) 2007 - 2011, Nicolas François
- * All rights reserved.
+ * SPDX-FileCopyrightText: 1992 - 1994, Julianne Frances Haugh
+ * SPDX-FileCopyrightText: 1996 - 2000, Marek Michałkiewicz
+ * SPDX-FileCopyrightText: 2001 , Michał Moskal
+ * SPDX-FileCopyrightText: 2001 - 2006, Tomasz Kłoczko
+ * SPDX-FileCopyrightText: 2007 - 2011, Nicolas François
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the copyright holders or contributors may not be used to
- * endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * SPDX-License-Identifier: BSD-3-Clause
*/
#include <config.h>
@@ -52,6 +29,7 @@
#ifdef WITH_TCB
#include "tcbfuncs.h"
#endif /* WITH_TCB */
+#include "shadowlog.h"
/*
* Exit codes
@@ -70,7 +48,6 @@
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static bool use_system_pw_file = true;
static bool use_system_spw_file = true;
@@ -857,6 +834,8 @@ int main (int argc, char **argv)
* Get my name so that I can use it to report errors.
*/
Prog = Basename (argv[0]);
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
diff --git a/src/pwconv.c b/src/pwconv.c
index 85ad9699..21d36e7f 100644
--- a/src/pwconv.c
+++ b/src/pwconv.c
@@ -1,32 +1,9 @@
/*
- * Copyright (c) 1996 - 2000, Marek Michałkiewicz
- * Copyright (c) 2002 - 2006, Tomasz Kłoczko
- * Copyright (c) 2009 - 2012, Nicolas François
- * All rights reserved.
+ * SPDX-FileCopyrightText: 1996 - 2000, Marek Michałkiewicz
+ * SPDX-FileCopyrightText: 2002 - 2006, Tomasz Kłoczko
+ * SPDX-FileCopyrightText: 2009 - 2012, Nicolas François
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the copyright holders or contributors may not be used to
- * endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * SPDX-License-Identifier: BSD-3-Clause
*/
/*
@@ -73,6 +50,7 @@
#include "shadowio.h"
#include "nscd.h"
#include "sssd.h"
+#include "shadowlog.h"
/*
* exit status values
@@ -89,7 +67,6 @@
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static bool spw_locked = false;
static bool pw_locked = false;
@@ -177,7 +154,8 @@ int main (int argc, char **argv)
struct spwd spent;
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
diff --git a/src/pwunconv.c b/src/pwunconv.c
index a5ee999e..b8624359 100644
--- a/src/pwunconv.c
+++ b/src/pwunconv.c
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 1989 - 1994, Julianne Frances Haugh
- * Copyright (c) 1996 - 2000, Marek Michałkiewicz
- * Copyright (c) 2001 - 2005, Tomasz Kłoczko
- * Copyright (c) 2008 - 2012, Nicolas François
- * All rights reserved.
+ * SPDX-FileCopyrightText: 1989 - 1994, Julianne Frances Haugh
+ * SPDX-FileCopyrightText: 1996 - 2000, Marek Michałkiewicz
+ * SPDX-FileCopyrightText: 2001 - 2005, Tomasz Kłoczko
+ * SPDX-FileCopyrightText: 2008 - 2012, Nicolas François
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the copyright holders or contributors may not be used to
- * endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * SPDX-License-Identifier: BSD-3-Clause
*/
#include <config.h>
@@ -48,12 +25,12 @@
#include "shadowio.h"
/*@-exitarg@*/
#include "exitcodes.h"
+#include "shadowlog.h"
/*
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static bool spw_locked = false;
static bool pw_locked = false;
@@ -138,7 +115,8 @@ int main (int argc, char **argv)
const struct spwd *spwd;
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
diff --git a/src/su.c b/src/su.c
index 04011afa..792e57a0 100644
--- a/src/su.c
+++ b/src/su.c
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 1989 - 1994, Julianne Frances Haugh
- * Copyright (c) 1996 - 2000, Marek Michałkiewicz
- * Copyright (c) 2000 - 2006, Tomasz Kłoczko
- * Copyright (c) 2007 - 2013, Nicolas François
- * All rights reserved.
+ * SPDX-FileCopyrightText: 1989 - 1994, Julianne Frances Haugh
+ * SPDX-FileCopyrightText: 1996 - 2000, Marek Michałkiewicz
+ * SPDX-FileCopyrightText: 2000 - 2006, Tomasz Kłoczko
+ * SPDX-FileCopyrightText: 2007 - 2013, Nicolas François
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the copyright holders or contributors may not be used to
- * endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * SPDX-License-Identifier: BSD-3-Clause
*/
/* Some parts substantially derived from an ancestor of:
@@ -77,12 +54,12 @@
#endif /* USE_PAM */
/*@-exitarg@*/
#include "exitcodes.h"
+#include "shadowlog.h"
/*
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static /*@observer@*/const char *caller_tty = NULL; /* Name of tty SU is run from */
static bool caller_is_root = false;
static uid_t caller_uid;
@@ -295,6 +272,21 @@ static void prepare_pam_close_session (void)
sigset_t ourset;
int status;
int ret;
+ struct sigaction action;
+
+ /* reset SIGCHLD handling to default */
+ action.sa_handler = SIG_DFL;
+ sigemptyset (&action.sa_mask);
+ action.sa_flags = 0;
+ if (0 == caught && sigaction (SIGCHLD, &action, NULL) != 0) {
+ fprintf (stderr,
+ _("%s: signal masking malfunction\n"),
+ Prog);
+ SYSLOG ((LOG_WARN, "Will not execute %s", shellstr));
+ closelog ();
+ exit (1);
+ /* Only the child returns. See above. */
+ }
pid_child = fork ();
if (pid_child == 0) { /* child shell */
@@ -318,11 +310,7 @@ static void prepare_pam_close_session (void)
caught = SIGTERM;
}
if (0 == caught) {
- struct sigaction action;
-
action.sa_handler = catch_signals;
- sigemptyset (&action.sa_mask);
- action.sa_flags = 0;
sigemptyset (&ourset);
if ( (sigaddset (&ourset, SIGTERM) != 0)
@@ -397,22 +385,28 @@ static void prepare_pam_close_session (void)
snprintf (kill_msg, sizeof kill_msg, _(" ...killed.\n"));
snprintf (wait_msg, sizeof wait_msg, _(" ...waiting for child to terminate.\n"));
+ /* Any signals other than SIGCHLD and SIGALRM will no longer have any effect,
+ * so it's time to block all of them. */
+ sigfillset (&ourset);
+ if (sigprocmask (SIG_BLOCK, &ourset, NULL) != 0) {
+ fprintf (stderr, _("%s: signal masking malfunction\n"), Prog);
+ kill_child (0);
+ /* Never reach (_exit called). */
+ }
+
+ /* Send SIGKILL to the child if it doesn't
+ * exit within 2 seconds (after SIGTERM) */
(void) signal (SIGALRM, kill_child);
(void) signal (SIGCHLD, catch_signals);
(void) alarm (2);
- sigemptyset (&ourset);
- if ((sigaddset (&ourset, SIGALRM) != 0)
- || (sigprocmask (SIG_BLOCK, &ourset, NULL) != 0)) {
- fprintf (stderr, _("%s: signal masking malfunction\n"), Prog);
- kill_child (0);
- } else {
- while (0 == waitpid (pid_child, &status, WNOHANG)) {
- sigsuspend (&ourset);
- }
- pid_child = 0;
- (void) sigprocmask (SIG_UNBLOCK, &ourset, NULL);
+ (void) sigdelset (&ourset, SIGALRM);
+ (void) sigdelset (&ourset, SIGCHLD);
+
+ while (0 == waitpid (pid_child, &status, WNOHANG)) {
+ sigsuspend (&ourset);
}
+ pid_child = 0;
(void) fputs (_(" ...terminated.\n"), stderr);
}
@@ -508,13 +502,13 @@ static void check_perms_nopam (const struct passwd *pw)
if (strcmp (pw->pw_passwd, "") == 0) {
char *prevent_no_auth = getdef_str("PREVENT_NO_AUTH");
- if(prevent_no_auth == NULL) {
+ if (prevent_no_auth == NULL) {
prevent_no_auth = "superuser";
}
- if(strcmp(prevent_no_auth, "yes") == 0) {
+ if (strcmp(prevent_no_auth, "yes") == 0) {
fprintf(stderr, _("Password field is empty, this is forbidden for all accounts.\n"));
exit(1);
- } else if( (pw->pw_uid == 0)
+ } else if ((pw->pw_uid == 0)
&& (strcmp(prevent_no_auth, "superuser") == 0)) {
fprintf(stderr, _("Password field is empty, this is forbidden for super-user.\n"));
exit(1);
@@ -579,7 +573,7 @@ static void check_perms_nopam (const struct passwd *pw)
oldsig = signal (SIGQUIT, die);
/*
- * See if the system defined authentication method is being used.
+ * See if the system defined authentication method is being used.
* The first character of an administrator defined method is an '@'
* character.
*/
@@ -717,7 +711,8 @@ static void save_caller_context (char **argv)
* most error messages.
*/
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
caller_uid = getuid ();
caller_is_root = (caller_uid == 0);
@@ -1156,12 +1151,9 @@ int main (int argc, char **argv)
}
}
- /*
- * PAM_DATA_SILENT is not supported by some modules, and
- * there is no strong need to clean up the process space's
- * memory since we will either call exec or exit.
- pam_end (pamh, PAM_SUCCESS | PAM_DATA_SILENT);
- */
+#ifdef USE_PAM
+ (void) pam_end (pamh, PAM_SUCCESS | PAM_DATA_SILENT);
+#endif
endpwent ();
endspent ();
diff --git a/src/suauth.c b/src/suauth.c
index 619a593b..2641d334 100644
--- a/src/suauth.c
+++ b/src/suauth.c
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 1990 - 1994, Julianne Frances Haugh
- * Copyright (c) 1996 - 2000, Marek Michałkiewicz
- * Copyright (c) 2002 - 2005, Tomasz Kłoczko
- * Copyright (c) 2007 - 2008, Nicolas François
- * All rights reserved.
+ * SPDX-FileCopyrightText: 1990 - 1994, Julianne Frances Haugh
+ * SPDX-FileCopyrightText: 1996 - 2000, Marek Michałkiewicz
+ * SPDX-FileCopyrightText: 2002 - 2005, Tomasz Kłoczko
+ * SPDX-FileCopyrightText: 2007 - 2008, Nicolas François
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the copyright holders or contributors may not be used to
- * endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * SPDX-License-Identifier: BSD-3-Clause
*/
#include <config.h>
@@ -50,7 +27,7 @@
#ifdef SU_ACCESS
-/* Really, I could do with a few const char's here defining all the
+/* Really, I could do with a few const char's here defining all the
* strings output to the user or the syslog. -- chris
*/
static int applies (const char *, char *);
diff --git a/src/sulogin.c b/src/sulogin.c
index 8f181505..4d38daf6 100644
--- a/src/sulogin.c
+++ b/src/sulogin.c
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 1989 - 1994, Julianne Frances Haugh
- * Copyright (c) 1996 - 2000, Marek Michałkiewicz
- * Copyright (c) 2002 - 2006, Tomasz Kłoczko
- * Copyright (c) 2007 - 2010, Nicolas François
- * All rights reserved.
+ * SPDX-FileCopyrightText: 1989 - 1994, Julianne Frances Haugh
+ * SPDX-FileCopyrightText: 1996 - 2000, Marek Michałkiewicz
+ * SPDX-FileCopyrightText: 2002 - 2006, Tomasz Kłoczko
+ * SPDX-FileCopyrightText: 2007 - 2010, Nicolas François
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the copyright holders or contributors may not be used to
- * endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * SPDX-License-Identifier: BSD-3-Clause
*/
#include <config.h>
@@ -45,12 +22,12 @@
#include "pwauth.h"
/*@-exitarg@*/
#include "exitcodes.h"
+#include "shadowlog.h"
/*
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static char name[BUFSIZ];
static char pass[BUFSIZ];
@@ -107,7 +84,8 @@ static RETSIGTYPE catch_signals (unused int sig)
#endif
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
(void) textdomain (PACKAGE);
@@ -211,7 +189,7 @@ static RETSIGTYPE catch_signals (unused int sig)
/*
* XXX - can't enter single user mode if root password is
* empty. I think this doesn't happen very often :-). But
- * it will work with standard getpass() (no NULL on EOF).
+ * it will work with standard getpass() (no NULL on EOF).
* --marekm
*/
if ((NULL == cp) || ('\0' == *cp)) {
diff --git a/src/useradd.c b/src/useradd.c
index 127177e2..456b9de5 100644
--- a/src/useradd.c
+++ b/src/useradd.c
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 1991 - 1994, Julianne Frances Haugh
- * Copyright (c) 1996 - 2000, Marek Michałkiewicz
- * Copyright (c) 2000 - 2006, Tomasz Kłoczko
- * Copyright (c) 2007 - 2012, Nicolas François
- * All rights reserved.
+ * SPDX-FileCopyrightText: 1991 - 1994, Julianne Frances Haugh
+ * SPDX-FileCopyrightText: 1996 - 2000, Marek Michałkiewicz
+ * SPDX-FileCopyrightText: 2000 - 2006, Tomasz Kłoczko
+ * SPDX-FileCopyrightText: 2007 - 2012, Nicolas François
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the copyright holders or contributors may not be used to
- * endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * SPDX-License-Identifier: BSD-3-Clause
*/
#include <config.h>
@@ -41,6 +18,7 @@
#include <getopt.h>
#include <grp.h>
#include <lastlog.h>
+#include <libgen.h>
#include <pwd.h>
#ifdef ACCT_TOOLS_SETUID
#ifdef USE_PAM
@@ -78,6 +56,7 @@
#ifdef WITH_TCB
#include "tcbfuncs.h"
#endif
+#include "shadowlog.h"
#ifndef SKEL_DIR
#define SKEL_DIR "/etc/skel"
@@ -96,7 +75,6 @@
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
/*
* These defaults are used if there is no defaults file.
@@ -107,6 +85,7 @@ static const char *def_home = "/home";
static const char *def_shell = "/bin/bash";
static const char *def_template = SKEL_DIR;
static const char *def_create_mail_spool = "yes";
+static const char *def_log_init = "yes";
static long def_inactive = -1;
static const char *def_expire = "";
@@ -142,9 +121,7 @@ static bool is_sub_gid = false;
static bool sub_uid_locked = false;
static bool sub_gid_locked = false;
static uid_t sub_uid_start; /* New subordinate uid range */
-static unsigned long sub_uid_count;
static gid_t sub_gid_start; /* New subordinate gid range */
-static unsigned long sub_gid_count;
#endif /* ENABLE_SUBIDS */
static bool pw_locked = false;
static bool gr_locked = false;
@@ -209,6 +186,7 @@ static bool home_added = false;
#define DEXPIRE "EXPIRE="
#define DSKEL "SKEL="
#define DCREATE_MAIL_SPOOL "CREATE_MAIL_SPOOL="
+#define DLOG_INIT "LOG_INIT="
/* local function prototypes */
static void fail_exit (int);
@@ -234,7 +212,7 @@ static void open_shadow (void);
static void faillog_reset (uid_t);
static void lastlog_reset (uid_t);
static void tallylog_reset (const char *);
-static void usr_update (void);
+static void usr_update (unsigned long subuid_count, unsigned long subgid_count);
static void create_home (void);
static void create_mail (void);
static void check_uid_range(int rflg, uid_t user_id);
@@ -362,7 +340,7 @@ static void get_defaults (void)
char buf[1024];
char *cp;
- if(prefix[0]) {
+ if (prefix[0]) {
size_t len;
int wlen;
@@ -415,7 +393,6 @@ static void get_defaults (void)
} else {
def_group = grp->gr_gid;
def_gname = xstrdup (grp->gr_name);
- gr_free(grp);
}
}
@@ -463,8 +440,8 @@ static void get_defaults (void)
if ('\0' == *cp) {
cp = SKEL_DIR; /* XXX warning: const */
}
-
- if(prefix[0]) {
+
+ if (prefix[0]) {
size_t len;
int wlen;
char* _def_template; /* avoid const warning */
@@ -490,10 +467,20 @@ static void get_defaults (void)
def_create_mail_spool = xstrdup (cp);
}
+
+ /*
+ * By default do we add the user to the lastlog and faillog databases ?
+ */
+ else if (MATCH (buf, DLOG_INIT)) {
+ if (*cp == '\0') {
+ cp = def_log_init; /* XXX warning: const */
+ }
+ def_log_init = xstrdup (cp);
+ }
}
(void) fclose (fp);
getdef_err:
- if(prefix[0]) {
+ if (prefix[0]) {
free(default_file);
}
}
@@ -513,6 +500,7 @@ static void show_defaults (void)
printf ("SHELL=%s\n", def_shell);
printf ("SKEL=%s\n", def_template);
printf ("CREATE_MAIL_SPOOL=%s\n", def_create_mail_spool);
+ printf ("LOG_INIT=%s\n", def_log_init);
}
/*
@@ -528,6 +516,7 @@ static int set_defaults (void)
FILE *ofp;
char buf[1024];
char *new_file = NULL;
+ char *new_file_dup = NULL;
char *default_file = USER_DEFAULTS_FILE;
char *cp;
int ofd;
@@ -539,6 +528,7 @@ static int set_defaults (void)
bool out_shell = false;
bool out_skel = false;
bool out_create_mail_spool = false;
+ bool out_log_init = false;
size_t len;
int ret = -1;
@@ -554,7 +544,7 @@ static int set_defaults (void)
wlen = snprintf(new_file, len, "%s%s%s", prefix, prefix[0]?"/":"", NEW_USER_FILE);
assert (wlen <= (int) len -1);
- if(prefix[0]) {
+ if (prefix[0]) {
len = strlen(prefix) + strlen(USER_DEFAULTS_FILE) + 2;
default_file = malloc(len);
if (default_file == NULL) {
@@ -567,6 +557,24 @@ static int set_defaults (void)
assert (wlen == (int) len -1);
}
+ new_file_dup = strdup(new_file);
+ if (new_file_dup == NULL) {
+ fprintf (stderr,
+ _("%s: cannot create directory for defaults file\n"),
+ Prog);
+ goto setdef_err;
+ }
+
+ ret = mkdir(dirname(new_file_dup), 0755);
+ if (-1 == ret && EEXIST != errno) {
+ fprintf (stderr,
+ _("%s: cannot create directory for defaults file\n"),
+ Prog);
+ free(new_file_dup);
+ goto setdef_err;
+ }
+ free(new_file_dup);
+
/*
* Create a temporary file to copy the new output to.
*/
@@ -638,6 +646,12 @@ static int set_defaults (void)
DCREATE_MAIL_SPOOL "%s\n",
def_create_mail_spool);
out_create_mail_spool = true;
+ } else if (!out_log_init
+ && MATCH (buf, DLOG_INIT)) {
+ fprintf (ofp,
+ DLOG_INIT "%s\n",
+ def_log_init);
+ out_log_init = true;
} else
fprintf (ofp, "%s\n", buf);
}
@@ -664,7 +678,8 @@ static int set_defaults (void)
if (!out_create_mail_spool)
fprintf (ofp, DCREATE_MAIL_SPOOL "%s\n", def_create_mail_spool);
-
+ if (!out_log_init)
+ fprintf (ofp, DLOG_INIT "%s\n", def_log_init);
/*
* Flush and close the file. Check for errors to make certain
* the new file is intact.
@@ -710,14 +725,14 @@ static int set_defaults (void)
#endif
SYSLOG ((LOG_INFO,
"useradd defaults: GROUP=%u, HOME=%s, SHELL=%s, INACTIVE=%ld, "
- "EXPIRE=%s, SKEL=%s, CREATE_MAIL_SPOOL=%s",
+ "EXPIRE=%s, SKEL=%s, CREATE_MAIL_SPOOL=%s, LOG_INIT=%s",
(unsigned int) def_group, def_home, def_shell,
def_inactive, def_expire, def_template,
- def_create_mail_spool));
+ def_create_mail_spool, def_log_init));
ret = 0;
setdef_err:
free(new_file);
- if(prefix[0]) {
+ if (prefix[0]) {
free(default_file);
}
@@ -1044,7 +1059,7 @@ static void grp_update (void)
fail_exit (E_GRP_UPDATE); /* XXX */
}
- /*
+ /*
* Add the username to the list of group members and
* update the group entry to reflect the change.
*/
@@ -1119,7 +1134,7 @@ static void grp_update (void)
fail_exit (E_GRP_UPDATE); /* XXX */
}
- /*
+ /*
* Add the username to the list of group members and
* update the group entry to reflect the change.
*/
@@ -1529,7 +1544,7 @@ static void process_flags (int argc, char **argv)
user_home = uh;
}
- if(prefix[0]) {
+ if (prefix[0]) {
size_t len = strlen(prefix) + strlen(user_home) + 2;
int wlen;
char* _prefix_user_home; /* to avoid const warning */
@@ -1557,6 +1572,14 @@ static void process_flags (int argc, char **argv)
create_mail_spool = def_create_mail_spool;
+ if (!lflg) {
+ /* If we are missing the flag lflg aka -l, check the defaults
+ * file to see if we need to disable it as a default*/
+ if (strcmp (def_log_init, "no") == 0) {
+ lflg = true;
+ }
+ }
+
if (!rflg) {
/* for system accounts defaults are ignored and we
* do not create a home dir */
@@ -2084,7 +2107,7 @@ static void tallylog_reset (const char *user_name)
* usr_update() creates the password file entries for this user
* and will update the group entries if required.
*/
-static void usr_update (void)
+static void usr_update (unsigned long subuid_count, unsigned long subgid_count)
{
struct passwd pwent;
struct spwd spent;
@@ -2147,14 +2170,14 @@ static void usr_update (void)
}
#ifdef ENABLE_SUBIDS
if (is_sub_uid &&
- (sub_uid_add(user_name, sub_uid_start, sub_uid_count) == 0)) {
+ (sub_uid_add(user_name, sub_uid_start, subuid_count) == 0)) {
fprintf (stderr,
_("%s: failed to prepare the new %s entry\n"),
Prog, sub_uid_dbname ());
fail_exit (E_SUB_UID_UPDATE);
}
if (is_sub_gid &&
- (sub_gid_add(user_name, sub_gid_start, sub_gid_count) == 0)) {
+ (sub_gid_add(user_name, sub_gid_start, subgid_count) == 0)) {
fprintf (stderr,
_("%s: failed to prepare the new %s entry\n"),
Prog, sub_uid_dbname ());
@@ -2322,11 +2345,16 @@ static void create_mail (void)
mode_t mode;
spool = getdef_str ("MAIL_DIR");
+#ifdef MAIL_SPOOL_DIR
+ if ((NULL == spool) && (getdef_str ("MAIL_FILE") == NULL)) {
+ spool = MAIL_SPOOL_DIR;
+ }
+#endif /* MAIL_SPOOL_DIR */
if (NULL == spool) {
- spool = "/var/mail";
+ return;
}
file = alloca (strlen (prefix) + strlen (spool) + strlen (user_name) + 2);
- if(prefix[0])
+ if (prefix[0])
sprintf (file, "%s/%s/%s", prefix, spool, user_name);
else
sprintf (file, "%s/%s", spool, user_name);
@@ -2380,18 +2408,18 @@ static void check_uid_range(int rflg, uid_t user_id)
{
uid_t uid_min ;
uid_t uid_max ;
- if(rflg){
+ if (rflg) {
uid_min = (uid_t)getdef_ulong("SYS_UID_MIN",101UL);
uid_max = (uid_t)getdef_ulong("SYS_UID_MAX",getdef_ulong("UID_MIN",1000UL)-1);
- if(uid_min <= uid_max){
- if(user_id < uid_min || user_id >uid_max)
+ if (uid_min <= uid_max) {
+ if (user_id < uid_min || user_id >uid_max)
fprintf(stderr, _("%s warning: %s's uid %d outside of the SYS_UID_MIN %d and SYS_UID_MAX %d range.\n"), Prog, user_name, user_id, uid_min, uid_max);
}
}else{
uid_min = (uid_t)getdef_ulong("UID_MIN", 1000UL);
uid_max = (uid_t)getdef_ulong("UID_MAX", 6000UL);
- if(uid_min <= uid_max){
- if(user_id < uid_min || user_id >uid_max)
+ if (uid_min <= uid_max) {
+ if (user_id < uid_min || user_id >uid_max)
fprintf(stderr, _("%s warning: %s's uid %d outside of the UID_MIN %d and UID_MAX %d range.\n"), Prog, user_name, user_id, uid_min, uid_max);
}
}
@@ -2412,15 +2440,16 @@ int main (int argc, char **argv)
#ifdef ENABLE_SUBIDS
uid_t uid_min;
uid_t uid_max;
- unsigned long subuid_count;
- unsigned long subgid_count;
#endif
+ unsigned long subuid_count = 0;
+ unsigned long subgid_count = 0;
/*
* Get my name so that I can use it to report errors.
*/
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
@@ -2473,14 +2502,14 @@ int main (int argc, char **argv)
{
struct passwd *pampw;
pampw = getpwuid (getuid ()); /* local, no need for xgetpwuid */
- if (pampw == NULL) {
+ if (pampw == NULL && getuid ()) {
fprintf (stderr,
_("%s: Cannot determine your user name.\n"),
Prog);
fail_exit (1);
}
- retval = pam_start ("useradd", pampw->pw_name, &conv, &pamh);
+ retval = pam_start ("useradd", pampw?pampw->pw_name:"root", &conv, &pamh);
}
if (PAM_SUCCESS == retval) {
@@ -2589,7 +2618,7 @@ int main (int argc, char **argv)
}
}
- if(uflg)
+ if (uflg)
check_uid_range(rflg,user_id);
#ifdef WITH_TCB
if (getdef_bool ("USE_TCB")) {
@@ -2616,16 +2645,16 @@ int main (int argc, char **argv)
}
#ifdef ENABLE_SUBIDS
- if (is_sub_uid && sub_uid_count != 0) {
- if (find_new_sub_uids(&sub_uid_start, &sub_uid_count) < 0) {
+ if (is_sub_uid && subuid_count != 0) {
+ if (find_new_sub_uids(&sub_uid_start, &subuid_count) < 0) {
fprintf (stderr,
_("%s: can't create subordinate user IDs\n"),
Prog);
fail_exit(E_SUB_UID_UPDATE);
}
}
- if (is_sub_gid && sub_gid_count != 0) {
- if (find_new_sub_gids(&sub_gid_start, &sub_gid_count) < 0) {
+ if (is_sub_gid && subgid_count != 0) {
+ if (find_new_sub_gids(&sub_gid_start, &subgid_count) < 0) {
fprintf (stderr,
_("%s: can't create subordinate group IDs\n"),
Prog);
@@ -2634,29 +2663,14 @@ int main (int argc, char **argv)
}
#endif /* ENABLE_SUBIDS */
- usr_update ();
-
- if (mflg) {
- create_home ();
- if (home_added) {
- copy_tree (def_template, prefix_user_home, false, false,
- (uid_t)-1, user_id, (gid_t)-1, user_gid);
- } else {
- fprintf (stderr,
- _("%s: warning: the home directory %s already exists.\n"
- "%s: Not copying any file from skel directory into it.\n"),
- Prog, user_home, Prog);
- }
-
- }
-
- /* Do not create mail directory for system accounts */
- if (!rflg) {
- create_mail ();
- }
+ usr_update (subuid_count, subgid_count);
close_files ();
+ nscd_flush_cache ("passwd");
+ nscd_flush_cache ("group");
+ sssd_flush_cache (SSSD_DB_PASSWD | SSSD_DB_GROUP);
+
/*
* tallylog_reset needs to be able to lookup
* a valid existing user name,
@@ -2682,15 +2696,30 @@ int main (int argc, char **argv)
}
#endif /* WITH_SELINUX */
+ if (mflg) {
+ create_home ();
+ if (home_added) {
+ copy_tree (def_template, prefix_user_home, false, true,
+ (uid_t)-1, user_id, (gid_t)-1, user_gid);
+ } else {
+ fprintf (stderr,
+ _("%s: warning: the home directory %s already exists.\n"
+ "%s: Not copying any file from skel directory into it.\n"),
+ Prog, user_home, Prog);
+ }
+
+ }
+
+ /* Do not create mail directory for system accounts */
+ if (!rflg) {
+ create_mail ();
+ }
+
if (run_parts ("/etc/shadow-maint/useradd-post.d", (char*)user_name,
"useradd")) {
exit(1);
}
- nscd_flush_cache ("passwd");
- nscd_flush_cache ("group");
- sssd_flush_cache (SSSD_DB_PASSWD | SSSD_DB_GROUP);
-
return E_SUCCESS;
}
diff --git a/src/userdel.c b/src/userdel.c
index 79a7c899..7012b0e0 100644
--- a/src/userdel.c
+++ b/src/userdel.c
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 1991 - 1994, Julianne Frances Haugh
- * Copyright (c) 1996 - 2000, Marek Michałkiewicz
- * Copyright (c) 2000 - 2006, Tomasz Kłoczko
- * Copyright (c) 2007 - 2012, Nicolas François
- * All rights reserved.
+ * SPDX-FileCopyrightText: 1991 - 1994, Julianne Frances Haugh
+ * SPDX-FileCopyrightText: 1996 - 2000, Marek Michałkiewicz
+ * SPDX-FileCopyrightText: 2000 - 2006, Tomasz Kłoczko
+ * SPDX-FileCopyrightText: 2007 - 2012, Nicolas François
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the copyright holders or contributors may not be used to
- * endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * SPDX-License-Identifier: BSD-3-Clause
*/
#include <config.h>
@@ -72,6 +49,7 @@
#ifdef ENABLE_SUBIDS
#include "subordinateio.h"
#endif /* ENABLE_SUBIDS */
+#include "shadowlog.h"
/*
* exit status values
@@ -91,7 +69,6 @@
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static char *user_name;
static uid_t user_id;
@@ -1016,7 +993,8 @@ int main (int argc, char **argv)
* Get my name so that I can use it to report errors.
*/
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
(void) textdomain (PACKAGE);
@@ -1046,7 +1024,7 @@ int main (int argc, char **argv)
{NULL, 0, NULL, '\0'}
};
while ((c = getopt_long (argc, argv,
-#ifdef WITH_SELINUX
+#ifdef WITH_SELINUX
"fhrR:P:Z",
#else /* !WITH_SELINUX */
"fhrR:P:",
@@ -1067,7 +1045,7 @@ int main (int argc, char **argv)
break;
case 'P': /* no-op, handled in process_prefix_flag () */
break;
-#ifdef WITH_SELINUX
+#ifdef WITH_SELINUX
case 'Z':
if (prefix[0]) {
fprintf (stderr,
@@ -1168,9 +1146,9 @@ int main (int argc, char **argv)
}
user_id = pwd->pw_uid;
user_gid = pwd->pw_gid;
-
- if(prefix[0]) {
-
+
+ if (prefix[0]) {
+
size_t len = strlen(prefix) + strlen(pwd->pw_dir) + 2;
int wlen;
user_home = xmalloc(len);
@@ -1347,7 +1325,7 @@ int main (int argc, char **argv)
* Cancel any crontabs or at jobs. Have to do this before we remove
* the entry from /etc/passwd.
*/
- if(prefix[0] == '\0')
+ if (prefix[0] == '\0')
user_cancel (user_name);
close_files ();
diff --git a/src/usermod.c b/src/usermod.c
index 03bb9b9d..9473a7d7 100644
--- a/src/usermod.c
+++ b/src/usermod.c
@@ -1,33 +1,10 @@
/*
- * Copyright (c) 1991 - 1994, Julianne Frances Haugh
- * Copyright (c) 1996 - 2000, Marek Michałkiewicz
- * Copyright (c) 2000 - 2006, Tomasz Kłoczko
- * Copyright (c) 2007 - 2011, Nicolas François
- * All rights reserved.
+ * SPDX-FileCopyrightText: 1991 - 1994, Julianne Frances Haugh
+ * SPDX-FileCopyrightText: 1996 - 2000, Marek Michałkiewicz
+ * SPDX-FileCopyrightText: 2000 - 2006, Tomasz Kłoczko
+ * SPDX-FileCopyrightText: 2007 - 2011, Nicolas François
*
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. The name of the copyright holders or contributors may not be used to
- * endorse or promote products derived from this software without
- * specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ * SPDX-License-Identifier: BSD-3-Clause
*/
#include <config.h>
@@ -74,6 +51,7 @@
#ifdef WITH_TCB
#include "tcbfuncs.h"
#endif
+#include "shadowlog.h"
/*
* exit status values
@@ -105,7 +83,6 @@
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static char *user_name;
static char *user_newname;
@@ -147,6 +124,7 @@ static bool
mflg = false, /* create user's home directory if it doesn't exist */
oflg = false, /* permit non-unique user ID to be specified with -u */
pflg = false, /* new encrypted password */
+ rflg = false, /* remove a user from a single group */
sflg = false, /* new shell program */
#ifdef WITH_SELINUX
Zflg = false, /* new selinux user */
@@ -184,10 +162,7 @@ static bool sub_gid_locked = false;
/* local function prototypes */
-static void date_to_str (/*@unique@*//*@out@*/char *buf, size_t maxsize,
- long int date);
static int get_groups (char *);
-static struct group * get_local_group (char * grp_name);
static /*@noreturn@*/void usage (int status);
static void new_pwent (struct passwd *);
static void new_spent (struct spwd *);
@@ -201,9 +176,7 @@ static void grp_update (void);
static void process_flags (int, char **);
static void close_files (void);
-static void close_group_files (void);
static void open_files (void);
-static void open_group_files (void);
static void usr_update (void);
static void move_home (void);
static void update_lastlog (void);
@@ -215,28 +188,6 @@ static void move_mailbox (void);
extern int allow_bad_names;
-static void date_to_str (/*@unique@*//*@out@*/char *buf, size_t maxsize,
- long int date)
-{
- struct tm *tp;
-
- if (date < 0) {
- strncpy (buf, "never", maxsize);
- } else {
- time_t t = (time_t) date;
- tp = gmtime (&t);
-#ifdef HAVE_STRFTIME
- strftime (buf, maxsize, "%Y-%m-%d", tp);
-#else
- (void) snprintf (buf, maxsize, "%04d-%02d-%02d",
- tp->tm_year + 1900,
- tp->tm_mon + 1,
- tp->tm_mday);
-#endif /* HAVE_STRFTIME */
- }
- buf[maxsize - 1] = '\0';
-}
-
/*
* get_groups - convert a list of group names to an array of group IDs
*
@@ -261,11 +212,6 @@ static int get_groups (char *list)
}
/*
- * Open the group files
- */
- open_group_files ();
-
- /*
* So long as there is some data to be converted, strip off each
* name and look it up. A mix of numerical and string values for
* group identifiers is permitted.
@@ -284,7 +230,7 @@ static int get_groups (char *list)
* Names starting with digits are treated as numerical GID
* values, otherwise the string is looked up as is.
*/
- grp = get_local_group (list);
+ grp = prefix_getgr_nam_gid (list);
/*
* There must be a match, either by GID value or by
@@ -334,8 +280,6 @@ static int get_groups (char *list)
gr_free ((struct group *)grp);
} while (NULL != list);
- close_group_files ();
-
user_groups[ngroups] = (char *) 0;
/*
@@ -348,44 +292,6 @@ static int get_groups (char *list)
return 0;
}
-/*
- * get_local_group - checks if a given group name exists locally
- *
- * get_local_group() checks if a given group name exists locally.
- * If the name exists the group information is returned, otherwise NULL is
- * returned.
- */
-static struct group * get_local_group(char * grp_name)
-{
- const struct group *grp;
- struct group *result_grp = NULL;
- long long int gid;
- char *endptr;
-
- gid = strtoll (grp_name, &endptr, 10);
- if ( ('\0' != *grp_name)
- && ('\0' == *endptr)
- && (ERANGE != errno)
- && (gid == (gid_t)gid)) {
- grp = gr_locate_gid ((gid_t) gid);
- }
- else {
- grp = gr_locate(grp_name);
- }
-
- if (grp != NULL) {
- result_grp = __gr_dup (grp);
- if (NULL == result_grp) {
- fprintf (stderr,
- _("%s: Out of memory. Cannot find group '%s'.\n"),
- Prog, grp_name);
- fail_exit (E_GRP_UPDATE);
- }
- }
-
- return result_grp;
-}
-
#ifdef ENABLE_SUBIDS
struct ulong_range
{
@@ -418,7 +324,6 @@ static struct ulong_range getulong_range(const char *str)
result.last = (unsigned long int)last;
out:
return result;
-
}
struct ulong_range_list_entry {
@@ -473,6 +378,9 @@ static /*@noreturn@*/void usage (int status)
(void) fputs (_(" -a, --append append the user to the supplemental GROUPS\n"
" mentioned by the -G option without removing\n"
" the user from other groups\n"), usageout);
+ (void) fputs (_(" -r, --remove remove the user from only the supplemental GROUPS\n"
+ " mentioned by the -G option without removing\n"
+ " the user from other groups\n"), usageout);
(void) fputs (_(" -h, --help display this help message and exit\n"), usageout);
(void) fputs (_(" -l, --login NEW_LOGIN new value of the login name\n"), usageout);
(void) fputs (_(" -L, --lock lock the user account\n"), usageout);
@@ -629,6 +537,12 @@ static void new_pwent (struct passwd *pwent)
SYSLOG ((LOG_INFO,
"change user '%s' home from '%s' to '%s'",
pwent->pw_name, pwent->pw_dir, user_newhome));
+
+ if (strlen(user_newhome) > 1
+ && '/' == user_newhome[strlen(user_newhome)-1]) {
+ user_newhome[strlen(user_newhome)-1]='\0';
+ }
+
pwent->pw_dir = user_newhome;
}
if (sflg) {
@@ -676,10 +590,8 @@ static void new_spent (struct spwd *spent)
if (eflg) {
/* log dates rather than numbers of days. */
char new_exp[16], old_exp[16];
- date_to_str (new_exp, sizeof(new_exp),
- user_newexpire * DAY);
- date_to_str (old_exp, sizeof(old_exp),
- user_expire * DAY);
+ date_to_str (sizeof(new_exp), new_exp, user_newexpire * DAY);
+ date_to_str (sizeof(old_exp), old_exp, user_expire * DAY);
#ifdef WITH_AUDIT
audit_logger (AUDIT_USER_CHAUTHTOK, Prog,
"changing expiration date",
@@ -800,6 +712,14 @@ static void update_group (void)
continue;
}
+ /*
+ * If rflg+Gflg is passed in AKA -rG invert is_member flag, which removes
+ * mentioned groups while leaving the others.
+ */
+ if (Gflg && rflg && was_member) {
+ is_member = !is_member;
+ }
+
ngrp = __gr_dup (grp);
if (NULL == ngrp) {
fprintf (stderr,
@@ -915,6 +835,14 @@ static void update_gshadow (void)
continue;
}
+ /*
+ * If rflg+Gflg is passed in AKA -rG invert is_member, to remove targeted
+ * groups while leaving the user apart of groups not mentioned
+ */
+ if (Gflg && rflg && was_member) {
+ is_member = !is_member;
+ }
+
nsgrp = __sgr_dup (sgrp);
if (NULL == nsgrp) {
fprintf (stderr,
@@ -997,7 +925,7 @@ static void update_gshadow (void)
changed = false;
- /*
+ /*
* Update the group entry to reflect the changes.
*/
if (sgr_update (nsgrp) == 0) {
@@ -1063,6 +991,7 @@ static void process_flags (int argc, char **argv)
{"move-home", no_argument, NULL, 'm'},
{"non-unique", no_argument, NULL, 'o'},
{"password", required_argument, NULL, 'p'},
+ {"remove", no_argument, NULL, 'r'},
{"root", required_argument, NULL, 'R'},
{"prefix", required_argument, NULL, 'P'},
{"shell", required_argument, NULL, 's'},
@@ -1080,7 +1009,7 @@ static void process_flags (int argc, char **argv)
{NULL, 0, NULL, '\0'}
};
while ((c = getopt_long (argc, argv,
- "abc:d:e:f:g:G:hl:Lmop:R:s:u:UP:"
+ "abc:d:e:f:g:G:hl:Lmop:rR:s:u:UP:"
#ifdef ENABLE_SUBIDS
"v:w:V:W:"
#endif /* ENABLE_SUBIDS */
@@ -1122,18 +1051,14 @@ static void process_flags (int argc, char **argv)
}
break;
case 'e':
- if ('\0' != *optarg) {
- user_newexpire = strtoday (optarg);
- if (user_newexpire < -1) {
- fprintf (stderr,
- _("%s: invalid date '%s'\n"),
- Prog, optarg);
- exit (E_BAD_ARG);
- }
- user_newexpire *= DAY / SCALE;
- } else {
- user_newexpire = -1;
+ user_newexpire = strtoday (optarg);
+ if (user_newexpire < -1) {
+ fprintf (stderr,
+ _("%s: invalid date '%s'\n"),
+ Prog, optarg);
+ exit (E_BAD_ARG);
}
+ user_newexpire *= DAY / SCALE;
eflg = true;
break;
case 'f':
@@ -1190,6 +1115,9 @@ static void process_flags (int argc, char **argv)
user_pass = optarg;
pflg = true;
break;
+ case 'r':
+ rflg = true;
+ break;
case 'R': /* no-op, handled in process_root_flag () */
break;
case 'P': /* no-op, handled in process_prefix_flag () */
@@ -1329,7 +1257,7 @@ static void process_flags (int argc, char **argv)
if (!gflg) {
user_newgid = user_gid;
}
- if(prefix[0]) {
+ if (prefix[0]) {
size_t len = strlen(prefix) + strlen(user_home) + 2;
int wlen;
prefix_user_home = xmalloc(len);
@@ -1391,6 +1319,20 @@ static void process_flags (int argc, char **argv)
usage (E_USAGE);
}
+ if (rflg && (!Gflg)) {
+ fprintf (stderr,
+ _("%s: %s flag is only allowed with the %s flag\n"),
+ Prog, "-r", "-G");
+ usage (E_USAGE);
+ }
+
+ if (rflg && aflg) {
+ fprintf (stderr,
+ _("%s: %s and %s are mutually exclusive flags\n"),
+ Prog, "-r", "-a");
+ usage (E_USAGE);
+ }
+
if ((Lflg && (pflg || Uflg)) || (pflg && Uflg)) {
fprintf (stderr,
_("%s: the -L, -p, and -U flags are exclusive\n"),
@@ -1523,7 +1465,50 @@ static void close_files (void)
}
if (Gflg || lflg) {
- close_group_files ();
+ if (gr_close () == 0) {
+ fprintf (stderr,
+ _("%s: failure while writing changes to %s\n"),
+ Prog, gr_dbname ());
+ SYSLOG ((LOG_ERR,
+ "failure while writing changes to %s",
+ gr_dbname ()));
+ fail_exit (E_GRP_UPDATE);
+ }
+#ifdef SHADOWGRP
+ if (is_shadow_grp) {
+ if (sgr_close () == 0) {
+ fprintf (stderr,
+ _("%s: failure while writing changes to %s\n"),
+ Prog, sgr_dbname ());
+ SYSLOG ((LOG_ERR,
+ "failure while writing changes to %s",
+ sgr_dbname ()));
+ fail_exit (E_GRP_UPDATE);
+ }
+ }
+#endif
+#ifdef SHADOWGRP
+ if (is_shadow_grp) {
+ if (sgr_unlock () == 0) {
+ fprintf (stderr,
+ _("%s: failed to unlock %s\n"),
+ Prog, sgr_dbname ());
+ SYSLOG ((LOG_ERR,
+ "failed to unlock %s",
+ sgr_dbname ()));
+ /* continue */
+ }
+ }
+#endif
+ if (gr_unlock () == 0) {
+ fprintf (stderr,
+ _("%s: failed to unlock %s\n"),
+ Prog, gr_dbname ());
+ SYSLOG ((LOG_ERR,
+ "failed to unlock %s",
+ gr_dbname ()));
+ /* continue */
+ }
}
if (is_shadow_pwd) {
@@ -1593,60 +1578,6 @@ static void close_files (void)
}
/*
- * close_group_files - close all of the files that were opened
- *
- * close_group_files() closes all of the files that were opened related
- * with groups. This causes any modified entries to be written out.
- */
-static void close_group_files (void)
-{
- if (gr_close () == 0) {
- fprintf (stderr,
- _("%s: failure while writing changes to %s\n"),
- Prog, gr_dbname ());
- SYSLOG ((LOG_ERR,
- "failure while writing changes to %s",
- gr_dbname ()));
- fail_exit (E_GRP_UPDATE);
- }
-#ifdef SHADOWGRP
- if (is_shadow_grp) {
- if (sgr_close () == 0) {
- fprintf (stderr,
- _("%s: failure while writing changes to %s\n"),
- Prog, sgr_dbname ());
- SYSLOG ((LOG_ERR,
- "failure while writing changes to %s",
- sgr_dbname ()));
- fail_exit (E_GRP_UPDATE);
- }
- }
-#endif
-#ifdef SHADOWGRP
- if (is_shadow_grp) {
- if (sgr_unlock () == 0) {
- fprintf (stderr,
- _("%s: failed to unlock %s\n"),
- Prog, sgr_dbname ());
- SYSLOG ((LOG_ERR,
- "failed to unlock %s",
- sgr_dbname ()));
- /* continue */
- }
- }
-#endif
- if (gr_unlock () == 0) {
- fprintf (stderr,
- _("%s: failed to unlock %s\n"),
- Prog, gr_dbname ());
- SYSLOG ((LOG_ERR,
- "failed to unlock %s",
- gr_dbname ()));
- /* continue */
- }
-}
-
-/*
* open_files - lock and open the password files
*
* open_files() opens the two password files.
@@ -1681,7 +1612,38 @@ static void open_files (void)
}
if (Gflg || lflg) {
- open_group_files ();
+ /*
+ * Lock and open the group file. This will load all of the
+ * group entries.
+ */
+ if (gr_lock () == 0) {
+ fprintf (stderr,
+ _("%s: cannot lock %s; try again later.\n"),
+ Prog, gr_dbname ());
+ fail_exit (E_GRP_UPDATE);
+ }
+ gr_locked = true;
+ if (gr_open (O_CREAT | O_RDWR) == 0) {
+ fprintf (stderr,
+ _("%s: cannot open %s\n"),
+ Prog, gr_dbname ());
+ fail_exit (E_GRP_UPDATE);
+ }
+#ifdef SHADOWGRP
+ if (is_shadow_grp && (sgr_lock () == 0)) {
+ fprintf (stderr,
+ _("%s: cannot lock %s; try again later.\n"),
+ Prog, sgr_dbname ());
+ fail_exit (E_GRP_UPDATE);
+ }
+ sgr_locked = true;
+ if (is_shadow_grp && (sgr_open (O_CREAT | O_RDWR) == 0)) {
+ fprintf (stderr,
+ _("%s: cannot open %s\n"),
+ Prog, sgr_dbname ());
+ fail_exit (E_GRP_UPDATE);
+ }
+#endif
}
#ifdef ENABLE_SUBIDS
if (vflg || Vflg) {
@@ -1718,44 +1680,6 @@ static void open_files (void)
}
/*
- * open_group_files - lock and open the group files
- *
- * open_group_files() loads all of the group entries.
- */
-static void open_group_files (void)
-{
- if (gr_lock () == 0) {
- fprintf (stderr,
- _("%s: cannot lock %s; try again later.\n"),
- Prog, gr_dbname ());
- fail_exit (E_GRP_UPDATE);
- }
- gr_locked = true;
- if (gr_open (O_CREAT | O_RDWR) == 0) {
- fprintf (stderr,
- _("%s: cannot open %s\n"),
- Prog, gr_dbname ());
- fail_exit (E_GRP_UPDATE);
- }
-
-#ifdef SHADOWGRP
- if (is_shadow_grp && (sgr_lock () == 0)) {
- fprintf (stderr,
- _("%s: cannot lock %s; try again later.\n"),
- Prog, sgr_dbname ());
- fail_exit (E_GRP_UPDATE);
- }
- sgr_locked = true;
- if (is_shadow_grp && (sgr_open (O_CREAT | O_RDWR) == 0)) {
- fprintf (stderr,
- _("%s: cannot open %s\n"),
- Prog, sgr_dbname ());
- fail_exit (E_GRP_UPDATE);
- }
-#endif
-}
-
-/*
* usr_update - create the user entries
*
* usr_update() creates the password file entries for this user and
@@ -2208,7 +2132,8 @@ int main (int argc, char **argv)
* Get my name so that I can use it to report errors.
*/
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);
@@ -2313,7 +2238,7 @@ int main (int argc, char **argv)
if (sub_uid_remove(user_name, ptr->range.first, count) == 0) {
fprintf (stderr,
_("%s: failed to remove uid range %lu-%lu from '%s'\n"),
- Prog, ptr->range.first, ptr->range.last,
+ Prog, ptr->range.first, ptr->range.last,
sub_uid_dbname ());
fail_exit (E_SUB_UID_UPDATE);
}
@@ -2326,7 +2251,7 @@ int main (int argc, char **argv)
if (sub_uid_add(user_name, ptr->range.first, count) == 0) {
fprintf (stderr,
_("%s: failed to add uid range %lu-%lu to '%s'\n"),
- Prog, ptr->range.first, ptr->range.last,
+ Prog, ptr->range.first, ptr->range.last,
sub_uid_dbname ());
fail_exit (E_SUB_UID_UPDATE);
}
@@ -2339,7 +2264,7 @@ int main (int argc, char **argv)
if (sub_gid_remove(user_name, ptr->range.first, count) == 0) {
fprintf (stderr,
_("%s: failed to remove gid range %lu-%lu from '%s'\n"),
- Prog, ptr->range.first, ptr->range.last,
+ Prog, ptr->range.first, ptr->range.last,
sub_gid_dbname ());
fail_exit (E_SUB_GID_UPDATE);
}
@@ -2352,7 +2277,7 @@ int main (int argc, char **argv)
if (sub_gid_add(user_name, ptr->range.first, count) == 0) {
fprintf (stderr,
_("%s: failed to add gid range %lu-%lu to '%s'\n"),
- Prog, ptr->range.first, ptr->range.last,
+ Prog, ptr->range.first, ptr->range.last,
sub_gid_dbname ());
fail_exit (E_SUB_GID_UPDATE);
}
diff --git a/src/vipw.c b/src/vipw.c
index 94185c3d..8c97f4bc 100644
--- a/src/vipw.c
+++ b/src/vipw.c
@@ -1,27 +1,14 @@
/*
vipw, vigr edit the password or group file
with -s will edit shadow or gshadow file
-
- Copyright (c) 1997 , Guy Maor <maor@ece.utexas.edu>
- Copyright (c) 1999 - 2000, Marek Michałkiewicz
- Copyright (c) 2002 - 2006, Tomasz Kłoczko
- Copyright (c) 2007 - 2013, Nicolas François
- All rights reserved.
-
- 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
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA. */
+ *
+ * SPDX-FileCopyrightText: 1997 , Guy Maor <maor@ece.utexas.edu>
+ * SPDX-FileCopyrightText: 1999 - 2000, Marek Michałkiewicz
+ * SPDX-FileCopyrightText: 2002 - 2006, Tomasz Kłoczko
+ * SPDX-FileCopyrightText: 2007 - 2013, Nicolas François
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
#include <config.h>
@@ -53,6 +40,7 @@
#include <tcb.h>
#include "tcbfuncs.h"
#endif /* WITH_TCB */
+#include "shadowlog.h"
#define MSG_WARN_EDIT_OTHER_FILE _( \
"You have modified %s.\n"\
@@ -63,7 +51,6 @@
* Global variables
*/
const char *Prog;
-FILE *shadow_logfd = NULL;
static const char *filename, *fileeditname;
static bool filelocked = false;
@@ -349,6 +336,9 @@ vipwedit (const char *file, int (*file_lock) (void), int (*file_unlock) (void))
sigprocmask(SIG_BLOCK, &mask, &omask);
}
+ /* set SIGCHLD to default for waitpid */
+ signal(SIGCHLD, SIG_DFL);
+
for (;;) {
pid = waitpid (pid, &status, WUNTRACED);
if ((pid != -1) && (WIFSTOPPED (status) != 0)) {
@@ -482,7 +472,8 @@ int main (int argc, char **argv)
bool do_vipw;
Prog = Basename (argv[0]);
- shadow_logfd = stderr;
+ log_set_progname(Prog);
+ log_set_logfd(stderr);
(void) setlocale (LC_ALL, "");
(void) bindtextdomain (PACKAGE, LOCALEDIR);