Compare commits

...

4 Commits

Author SHA1 Message Date
Chris Hofstaedtler 65261e28f4 New upstream version 4.17.2 2025-02-09 18:13:39 +01:00
Chris Hofstaedtler bd724b34e0 New upstream version 4.17.1 2025-01-04 12:41:43 +01:00
Chris Hofstaedtler c2a3ebed18 New upstream version 4.17.0 2024-12-28 13:12:23 +01:00
Chris Hofstaedtler f78a468368 New upstream version 4.17.0~rc1 2024-12-06 19:17:25 +01:00
864 changed files with 28509 additions and 14413 deletions
+1 -3
View File
@@ -1,7 +1,5 @@
## Process this file with automake to produce Makefile.in ## Process this file with automake to produce Makefile.in
EXTRA_DIST = NEWS README
SUBDIRS = lib SUBDIRS = lib
if ENABLE_SUBIDS if ENABLE_SUBIDS
@@ -16,7 +14,7 @@ endif
CLEANFILES = man/8.out man/po/remove-potcdate.* man/*/login.defs.d man/*/*.mo CLEANFILES = man/8.out man/po/remove-potcdate.* man/*/login.defs.d man/*/*.mo
EXTRA_DIST = tests/ EXTRA_DIST = NEWS README tests/
dist-hook: dist-hook:
chmod -R u+w $(distdir)/tests chmod -R u+w $(distdir)/tests
+1 -2
View File
@@ -243,7 +243,6 @@ EGREP = @EGREP@
ETAGS = @ETAGS@ ETAGS = @ETAGS@
EXEEXT = @EXEEXT@ EXEEXT = @EXEEXT@
FGREP = @FGREP@ FGREP = @FGREP@
FILECMD = @FILECMD@
GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
GMSGFMT = @GMSGFMT@ GMSGFMT = @GMSGFMT@
GMSGFMT_015 = @GMSGFMT_015@ GMSGFMT_015 = @GMSGFMT_015@
@@ -390,10 +389,10 @@ target_alias = @target_alias@
top_build_prefix = @top_build_prefix@ top_build_prefix = @top_build_prefix@
top_builddir = @top_builddir@ top_builddir = @top_builddir@
top_srcdir = @top_srcdir@ top_srcdir = @top_srcdir@
EXTRA_DIST = tests/
SUBDIRS = lib $(am__append_1) src po contrib doc etc tests/unit \ SUBDIRS = lib $(am__append_1) src po contrib doc etc tests/unit \
$(am__append_2) $(am__append_2)
CLEANFILES = man/8.out man/po/remove-potcdate.* man/*/login.defs.d man/*/*.mo CLEANFILES = man/8.out man/po/remove-potcdate.* man/*/login.defs.d man/*/*.mo
EXTRA_DIST = NEWS README tests/
all: config.h all: config.h
$(MAKE) $(AM_MAKEFLAGS) all-recursive $(MAKE) $(AM_MAKEFLAGS) all-recursive
Vendored
+21 -22
View File
@@ -22,15 +22,14 @@ To do so, use the procedure documented by the package, typically 'autoreconf'.])
# ltdl.m4 - Configure ltdl for the target system. -*-Autoconf-*- # ltdl.m4 - Configure ltdl for the target system. -*-Autoconf-*-
# #
# Copyright (C) 1999-2008, 2011-2019, 2021-2022 Free Software # Copyright (C) 1999-2008, 2011-2015 Free Software Foundation, Inc.
# Foundation, Inc.
# Written by Thomas Tanner, 1999 # Written by Thomas Tanner, 1999
# #
# This file is free software; the Free Software Foundation gives # This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without # unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved. # modifications, as long as this notice is preserved.
# serial 21 LTDL_INIT # serial 20 LTDL_INIT
# LT_CONFIG_LTDL_DIR(DIRECTORY, [LTDL-MODE]) # LT_CONFIG_LTDL_DIR(DIRECTORY, [LTDL-MODE])
# ------------------------------------------ # ------------------------------------------
@@ -358,7 +357,7 @@ AC_CONFIG_COMMANDS_PRE([
if test -n "$_LT_LIBOBJS"; then if test -n "$_LT_LIBOBJS"; then
# Remove the extension. # Remove the extension.
_lt_sed_drop_objext='s/\.o$//;s/\.obj$//' _lt_sed_drop_objext='s/\.o$//;s/\.obj$//'
for i in `for i in $_LT_LIBOBJS; do echo "$i"; done | $SED "$_lt_sed_drop_objext" | sort -u`; do for i in `for i in $_LT_LIBOBJS; do echo "$i"; done | sed "$_lt_sed_drop_objext" | sort -u`; do
_ltdl_libobjs="$_ltdl_libobjs $lt_libobj_prefix$i.$ac_objext" _ltdl_libobjs="$_ltdl_libobjs $lt_libobj_prefix$i.$ac_objext"
_ltdl_ltlibobjs="$_ltdl_ltlibobjs $lt_libobj_prefix$i.lo" _ltdl_ltlibobjs="$_ltdl_ltlibobjs $lt_libobj_prefix$i.lo"
done done
@@ -496,7 +495,7 @@ AC_CACHE_CHECK([whether deplibs are loaded by dlopen],
# If you are looking for one http://www.opendarwin.org/projects/dlcompat # If you are looking for one http://www.opendarwin.org/projects/dlcompat
lt_cv_sys_dlopen_deplibs=yes lt_cv_sys_dlopen_deplibs=yes
;; ;;
freebsd* | dragonfly* | midnightbsd*) freebsd* | dragonfly*)
lt_cv_sys_dlopen_deplibs=yes lt_cv_sys_dlopen_deplibs=yes
;; ;;
gnu* | linux* | k*bsd*-gnu | kopensolaris*-gnu) gnu* | linux* | k*bsd*-gnu | kopensolaris*-gnu)
@@ -931,8 +930,8 @@ AU_ALIAS([AC_LTDL_DLSYM_USCORE], [LT_FUNC_DLSYM_USCORE])
dnl aclocal-1.4 backwards compatibility: dnl aclocal-1.4 backwards compatibility:
dnl AC_DEFUN([AC_LTDL_DLSYM_USCORE], []) dnl AC_DEFUN([AC_LTDL_DLSYM_USCORE], [])
# pkg.m4 - Macros to locate and use pkg-config. -*- Autoconf -*- # pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
# serial 12 (pkg-config-0.29.2) # serial 11 (pkg-config-0.29.1)
dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>. dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com> dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
@@ -974,7 +973,7 @@ dnl
dnl See the "Since" comment for each macro you use to see what version dnl See the "Since" comment for each macro you use to see what version
dnl of the macros you require. dnl of the macros you require.
m4_defun([PKG_PREREQ], m4_defun([PKG_PREREQ],
[m4_define([PKG_MACROS_VERSION], [0.29.2]) [m4_define([PKG_MACROS_VERSION], [0.29.1])
m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1, m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
[m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])]) [m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
])dnl PKG_PREREQ ])dnl PKG_PREREQ
@@ -1019,7 +1018,7 @@ dnl Check to see whether a particular set of modules exists. Similar to
dnl PKG_CHECK_MODULES(), but does not set variables or print errors. dnl PKG_CHECK_MODULES(), but does not set variables or print errors.
dnl dnl
dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) dnl Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG])
dnl only at the first occurrence in configure.ac, so if the first place dnl only at the first occurence in configure.ac, so if the first place
dnl it's called might be skipped (such as if it is within an "if", you dnl it's called might be skipped (such as if it is within an "if", you
dnl have to call PKG_CHECK_EXISTS manually dnl have to call PKG_CHECK_EXISTS manually
AC_DEFUN([PKG_CHECK_EXISTS], AC_DEFUN([PKG_CHECK_EXISTS],
@@ -1075,7 +1074,7 @@ AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
pkg_failed=no pkg_failed=no
AC_MSG_CHECKING([for $2]) AC_MSG_CHECKING([for $1])
_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
_PKG_CONFIG([$1][_LIBS], [libs], [$2]) _PKG_CONFIG([$1][_LIBS], [libs], [$2])
@@ -1085,17 +1084,17 @@ and $1[]_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details.]) See the pkg-config man page for more details.])
if test $pkg_failed = yes; then if test $pkg_failed = yes; then
AC_MSG_RESULT([no]) AC_MSG_RESULT([no])
_PKG_SHORT_ERRORS_SUPPORTED _PKG_SHORT_ERRORS_SUPPORTED
if test $_pkg_short_errors_supported = yes; then if test $_pkg_short_errors_supported = yes; then
$1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1`
else else
$1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1`
fi fi
# Put the nasty error message in config.log where it belongs # Put the nasty error message in config.log where it belongs
echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
m4_default([$4], [AC_MSG_ERROR( m4_default([$4], [AC_MSG_ERROR(
[Package requirements ($2) were not met: [Package requirements ($2) were not met:
$$1_PKG_ERRORS $$1_PKG_ERRORS
@@ -1106,8 +1105,8 @@ installed software in a non-standard prefix.
_PKG_TEXT])[]dnl _PKG_TEXT])[]dnl
]) ])
elif test $pkg_failed = untried; then elif test $pkg_failed = untried; then
AC_MSG_RESULT([no]) AC_MSG_RESULT([no])
m4_default([$4], [AC_MSG_FAILURE( m4_default([$4], [AC_MSG_FAILURE(
[The pkg-config script could not be found or is too old. Make sure it [The pkg-config script could not be found or is too old. Make sure it
is in your PATH or set the PKG_CONFIG environment variable to the full is in your PATH or set the PKG_CONFIG environment variable to the full
path to pkg-config. path to pkg-config.
@@ -1117,10 +1116,10 @@ _PKG_TEXT
To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl
]) ])
else else
$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
$1[]_LIBS=$pkg_cv_[]$1[]_LIBS $1[]_LIBS=$pkg_cv_[]$1[]_LIBS
AC_MSG_RESULT([yes]) AC_MSG_RESULT([yes])
$3 $3
fi[]dnl fi[]dnl
])dnl PKG_CHECK_MODULES ])dnl PKG_CHECK_MODULES
-6
View File
@@ -341,12 +341,6 @@
/* Path to passwd program. */ /* Path to passwd program. */
#undef PASSWD_PROGRAM #undef PASSWD_PROGRAM
/* Define if login should support the -r flag for rlogind. */
#undef RLOGIN
/* Define to the ruserok() "success" return value (0 or 1). */
#undef RUSEROK
/* Define to support the shadow group file. */ /* Define to support the shadow group file. */
#undef SHADOWGRP #undef SHADOWGRP
Vendored
+127 -279
View File
@@ -1,6 +1,6 @@
#! /bin/sh #! /bin/sh
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.71 for shadow 4.15.3. # Generated by GNU Autoconf 2.71 for shadow 4.17.2.
# #
# Report bugs to <pkg-shadow-devel@lists.alioth.debian.org>. # Report bugs to <pkg-shadow-devel@lists.alioth.debian.org>.
# #
@@ -621,8 +621,8 @@ MAKEFLAGS=
# Identity of this package. # Identity of this package.
PACKAGE_NAME='shadow' PACKAGE_NAME='shadow'
PACKAGE_TARNAME='shadow' PACKAGE_TARNAME='shadow'
PACKAGE_VERSION='4.15.3' PACKAGE_VERSION='4.17.2'
PACKAGE_STRING='shadow 4.15.3' PACKAGE_STRING='shadow 4.17.2'
PACKAGE_BUGREPORT='pkg-shadow-devel@lists.alioth.debian.org' PACKAGE_BUGREPORT='pkg-shadow-devel@lists.alioth.debian.org'
PACKAGE_URL='https://github.com/shadow-maint/shadow' PACKAGE_URL='https://github.com/shadow-maint/shadow'
@@ -763,7 +763,6 @@ ac_ct_AR
AR AR
DLLTOOL DLLTOOL
OBJDUMP OBJDUMP
FILECMD
NM NM
ac_ct_DUMPBIN ac_ct_DUMPBIN
DUMPBIN DUMPBIN
@@ -1489,7 +1488,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing. # Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh. # This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF cat <<_ACEOF
\`configure' configures shadow 4.15.3 to adapt to many kinds of systems. \`configure' configures shadow 4.17.2 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]... Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1560,7 +1559,7 @@ fi
if test -n "$ac_init_help"; then if test -n "$ac_init_help"; then
case $ac_init_help in case $ac_init_help in
short | recursive ) echo "Configuration of shadow 4.15.3:";; short | recursive ) echo "Configuration of shadow 4.17.2:";;
esac esac
cat <<\_ACEOF cat <<\_ACEOF
@@ -1739,7 +1738,7 @@ fi
test -n "$ac_init_help" && exit $ac_status test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then if $ac_init_version; then
cat <<\_ACEOF cat <<\_ACEOF
shadow configure 4.15.3 shadow configure 4.17.2
generated by GNU Autoconf 2.71 generated by GNU Autoconf 2.71
Copyright (C) 2021 Free Software Foundation, Inc. Copyright (C) 2021 Free Software Foundation, Inc.
@@ -2339,7 +2338,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake. running configure, to aid debugging if configure makes a mistake.
It was created by shadow $as_me 4.15.3, which was It was created by shadow $as_me 4.17.2, which was
generated by GNU Autoconf 2.71. Invocation command line was generated by GNU Autoconf 2.71. Invocation command line was
$ $0$ac_configure_args_raw $ $0$ac_configure_args_raw
@@ -3612,7 +3611,7 @@ fi
# Define the identity of the package. # Define the identity of the package.
PACKAGE='shadow' PACKAGE='shadow'
VERSION='4.15.3' VERSION='4.17.2'
printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h
@@ -3846,13 +3845,13 @@ AM_BACKSLASH='\'
ac_config_headers="$ac_config_headers config.h" ac_config_headers="$ac_config_headers config.h"
LIBSUBID_ABI_MAJOR=4 LIBSUBID_ABI_MAJOR=5
LIBSUBID_ABI_MINOR=0 LIBSUBID_ABI_MINOR=0
LIBSUBID_ABI_MICRO=0 LIBSUBID_ABI_MICRO=0
LIBSUBID_ABI=4.0.0 LIBSUBID_ABI=5.0.0
test "$prefix" = "NONE" && prefix="/usr" test "$prefix" = "NONE" && prefix="/usr"
@@ -6357,8 +6356,8 @@ esac
macro_version='2.4.7' macro_version='2.4.6'
macro_revision='2.4.7' macro_revision='2.4.6'
@@ -6986,13 +6985,13 @@ else
mingw*) lt_bad_file=conftest.nm/nofile ;; mingw*) lt_bad_file=conftest.nm/nofile ;;
*) lt_bad_file=/dev/null ;; *) lt_bad_file=/dev/null ;;
esac esac
case `"$tmp_nm" -B $lt_bad_file 2>&1 | $SED '1q'` in case `"$tmp_nm" -B $lt_bad_file 2>&1 | sed '1q'` in
*$lt_bad_file* | *'Invalid file or object type'*) *$lt_bad_file* | *'Invalid file or object type'*)
lt_cv_path_NM="$tmp_nm -B" lt_cv_path_NM="$tmp_nm -B"
break 2 break 2
;; ;;
*) *)
case `"$tmp_nm" -p /dev/null 2>&1 | $SED '1q'` in case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
*/dev/null*) */dev/null*)
lt_cv_path_NM="$tmp_nm -p" lt_cv_path_NM="$tmp_nm -p"
break 2 break 2
@@ -7130,7 +7129,7 @@ esac
fi fi
fi fi
case `$DUMPBIN -symbols -headers /dev/null 2>&1 | $SED '1q'` in case `$DUMPBIN -symbols -headers /dev/null 2>&1 | sed '1q'` in
*COFF*) *COFF*)
DUMPBIN="$DUMPBIN -symbols -headers" DUMPBIN="$DUMPBIN -symbols -headers"
;; ;;
@@ -7223,7 +7222,7 @@ else $as_nop
lt_cv_sys_max_cmd_len=8192; lt_cv_sys_max_cmd_len=8192;
;; ;;
bitrig* | darwin* | dragonfly* | freebsd* | midnightbsd* | netbsd* | openbsd*) bitrig* | darwin* | dragonfly* | freebsd* | netbsd* | openbsd*)
# This has been around since 386BSD, at least. Likely further. # This has been around since 386BSD, at least. Likely further.
if test -x /sbin/sysctl; then if test -x /sbin/sysctl; then
lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax` lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
@@ -7266,7 +7265,7 @@ else $as_nop
sysv5* | sco5v6* | sysv4.2uw2*) sysv5* | sco5v6* | sysv4.2uw2*)
kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null` kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
if test -n "$kargmax"; then if test -n "$kargmax"; then
lt_cv_sys_max_cmd_len=`echo $kargmax | $SED 's/.*[ ]//'` lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[ ]//'`
else else
lt_cv_sys_max_cmd_len=32768 lt_cv_sys_max_cmd_len=32768
fi fi
@@ -7471,114 +7470,6 @@ esac
if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}file", so it can be a program name with args.
set dummy ${ac_tool_prefix}file; ac_word=$2
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
printf %s "checking for $ac_word... " >&6; }
if test ${ac_cv_prog_FILECMD+y}
then :
printf %s "(cached) " >&6
else $as_nop
if test -n "$FILECMD"; then
ac_cv_prog_FILECMD="$FILECMD" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
case $as_dir in #(((
'') as_dir=./ ;;
*/) ;;
*) as_dir=$as_dir/ ;;
esac
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
ac_cv_prog_FILECMD="${ac_tool_prefix}file"
printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
FILECMD=$ac_cv_prog_FILECMD
if test -n "$FILECMD"; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $FILECMD" >&5
printf "%s\n" "$FILECMD" >&6; }
else
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }
fi
fi
if test -z "$ac_cv_prog_FILECMD"; then
ac_ct_FILECMD=$FILECMD
# Extract the first word of "file", so it can be a program name with args.
set dummy file; ac_word=$2
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
printf %s "checking for $ac_word... " >&6; }
if test ${ac_cv_prog_ac_ct_FILECMD+y}
then :
printf %s "(cached) " >&6
else $as_nop
if test -n "$ac_ct_FILECMD"; then
ac_cv_prog_ac_ct_FILECMD="$ac_ct_FILECMD" # Let the user override the test.
else
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
case $as_dir in #(((
'') as_dir=./ ;;
*/) ;;
*) as_dir=$as_dir/ ;;
esac
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then
ac_cv_prog_ac_ct_FILECMD="file"
printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
fi
fi
ac_ct_FILECMD=$ac_cv_prog_ac_ct_FILECMD
if test -n "$ac_ct_FILECMD"; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_FILECMD" >&5
printf "%s\n" "$ac_ct_FILECMD" >&6; }
else
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }
fi
if test "x$ac_ct_FILECMD" = x; then
FILECMD=":"
else
case $cross_compiling:$ac_tool_warned in
yes:)
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
ac_tool_warned=yes ;;
esac
FILECMD=$ac_ct_FILECMD
fi
else
FILECMD="$ac_cv_prog_FILECMD"
fi
if test -n "$ac_tool_prefix"; then if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args. # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args.
set dummy ${ac_tool_prefix}objdump; ac_word=$2 set dummy ${ac_tool_prefix}objdump; ac_word=$2
@@ -7722,7 +7613,7 @@ beos*)
bsdi[45]*) bsdi[45]*)
lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)' lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'
lt_cv_file_magic_cmd='$FILECMD -L' lt_cv_file_magic_cmd='/usr/bin/file -L'
lt_cv_file_magic_test_file=/shlib/libc.so lt_cv_file_magic_test_file=/shlib/libc.so
;; ;;
@@ -7756,14 +7647,14 @@ darwin* | rhapsody*)
lt_cv_deplibs_check_method=pass_all lt_cv_deplibs_check_method=pass_all
;; ;;
freebsd* | dragonfly* | midnightbsd*) freebsd* | dragonfly*)
if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
case $host_cpu in case $host_cpu in
i*86 ) i*86 )
# Not sure whether the presence of OpenBSD here was a mistake. # Not sure whether the presence of OpenBSD here was a mistake.
# Let's accept both of them until this is cleared up. # Let's accept both of them until this is cleared up.
lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library' lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library'
lt_cv_file_magic_cmd=$FILECMD lt_cv_file_magic_cmd=/usr/bin/file
lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*` lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
;; ;;
esac esac
@@ -7777,7 +7668,7 @@ haiku*)
;; ;;
hpux10.20* | hpux11*) hpux10.20* | hpux11*)
lt_cv_file_magic_cmd=$FILECMD lt_cv_file_magic_cmd=/usr/bin/file
case $host_cpu in case $host_cpu in
ia64*) ia64*)
lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64' lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64'
@@ -7824,7 +7715,7 @@ netbsd* | netbsdelf*-gnu)
newos6*) newos6*)
lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)' lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)'
lt_cv_file_magic_cmd=$FILECMD lt_cv_file_magic_cmd=/usr/bin/file
lt_cv_file_magic_test_file=/usr/lib/libnls.so lt_cv_file_magic_test_file=/usr/lib/libnls.so
;; ;;
@@ -8197,29 +8088,13 @@ esac
fi fi
: ${AR=ar} : ${AR=ar}
: ${AR_FLAGS=cr}
# Use ARFLAGS variable as AR's operation code to sync the variable naming with
# Automake. If both AR_FLAGS and ARFLAGS are specified, AR_FLAGS should have
# higher priority because thats what people were doing historically (setting
# ARFLAGS for automake and AR_FLAGS for libtool). FIXME: Make the AR_FLAGS
# variable obsoleted/removed.
test ${AR_FLAGS+y} || AR_FLAGS=${ARFLAGS-cr}
lt_ar_flags=$AR_FLAGS
# Make AR_FLAGS overridable by 'make ARFLAGS='. Don't try to run-time override
# by AR_FLAGS because that was never working and AR_FLAGS is about to die.
@@ -8636,7 +8511,7 @@ esac
if test "$lt_cv_nm_interface" = "MS dumpbin"; then if test "$lt_cv_nm_interface" = "MS dumpbin"; then
# Gets list of data symbols to import. # Gets list of data symbols to import.
lt_cv_sys_global_symbol_to_import="$SED -n -e 's/^I .* \(.*\)$/\1/p'" lt_cv_sys_global_symbol_to_import="sed -n -e 's/^I .* \(.*\)$/\1/p'"
# Adjust the below global symbol transforms to fixup imported variables. # Adjust the below global symbol transforms to fixup imported variables.
lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'" lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'"
lt_c_name_hook=" -e 's/^I .* \(.*\)$/ {\"\1\", (void *) 0},/p'" lt_c_name_hook=" -e 's/^I .* \(.*\)$/ {\"\1\", (void *) 0},/p'"
@@ -8654,20 +8529,20 @@ fi
# Transform an extracted symbol line into a proper C declaration. # Transform an extracted symbol line into a proper C declaration.
# Some systems (esp. on ia64) link data and code symbols differently, # Some systems (esp. on ia64) link data and code symbols differently,
# so use this general approach. # so use this general approach.
lt_cv_sys_global_symbol_to_cdecl="$SED -n"\ lt_cv_sys_global_symbol_to_cdecl="sed -n"\
$lt_cdecl_hook\ $lt_cdecl_hook\
" -e 's/^T .* \(.*\)$/extern int \1();/p'"\ " -e 's/^T .* \(.*\)$/extern int \1();/p'"\
" -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'" " -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'"
# Transform an extracted symbol line into symbol name and symbol address # Transform an extracted symbol line into symbol name and symbol address
lt_cv_sys_global_symbol_to_c_name_address="$SED -n"\ lt_cv_sys_global_symbol_to_c_name_address="sed -n"\
$lt_c_name_hook\ $lt_c_name_hook\
" -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ " -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\
" -e 's/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/p'" " -e 's/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/p'"
# Transform an extracted symbol line into symbol name with lib prefix and # Transform an extracted symbol line into symbol name with lib prefix and
# symbol address. # symbol address.
lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="$SED -n"\ lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n"\
$lt_c_name_lib_hook\ $lt_c_name_lib_hook\
" -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\ " -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\
" -e 's/^$symcode$symcode* .* \(lib.*\)$/ {\"\1\", (void *) \&\1},/p'"\ " -e 's/^$symcode$symcode* .* \(lib.*\)$/ {\"\1\", (void *) \&\1},/p'"\
@@ -8691,7 +8566,7 @@ for ac_symprfx in "" "_"; do
if test "$lt_cv_nm_interface" = "MS dumpbin"; then if test "$lt_cv_nm_interface" = "MS dumpbin"; then
# Fake it for dumpbin and say T for any non-static function, # Fake it for dumpbin and say T for any non-static function,
# D for any global variable and I for any imported variable. # D for any global variable and I for any imported variable.
# Also find C++ and __fastcall symbols from MSVC++ or ICC, # Also find C++ and __fastcall symbols from MSVC++,
# which start with @ or ?. # which start with @ or ?.
lt_cv_sys_global_symbol_pipe="$AWK '"\ lt_cv_sys_global_symbol_pipe="$AWK '"\
" {last_section=section; section=\$ 3};"\ " {last_section=section; section=\$ 3};"\
@@ -8709,9 +8584,9 @@ for ac_symprfx in "" "_"; do
" s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\ " s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\
" ' prfx=^$ac_symprfx" " ' prfx=^$ac_symprfx"
else else
lt_cv_sys_global_symbol_pipe="$SED -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'" lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
fi fi
lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | $SED '/ __gnu_lto/d'" lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'"
# Check to see that the pipe works correctly. # Check to see that the pipe works correctly.
pipe_works=no pipe_works=no
@@ -8911,7 +8786,7 @@ case $with_sysroot in #(
fi fi
;; #( ;; #(
/*) /*)
lt_sysroot=`echo "$with_sysroot" | $SED -e "$sed_quote_subst"` lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"`
;; #( ;; #(
no|'') no|'')
;; #( ;; #(
@@ -9036,7 +8911,7 @@ ia64-*-hpux*)
ac_status=$? ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then test $ac_status = 0; }; then
case `$FILECMD conftest.$ac_objext` in case `/usr/bin/file conftest.$ac_objext` in
*ELF-32*) *ELF-32*)
HPUX_IA64_MODE=32 HPUX_IA64_MODE=32
;; ;;
@@ -9057,7 +8932,7 @@ ia64-*-hpux*)
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then test $ac_status = 0; }; then
if test yes = "$lt_cv_prog_gnu_ld"; then if test yes = "$lt_cv_prog_gnu_ld"; then
case `$FILECMD conftest.$ac_objext` in case `/usr/bin/file conftest.$ac_objext` in
*32-bit*) *32-bit*)
LD="${LD-ld} -melf32bsmip" LD="${LD-ld} -melf32bsmip"
;; ;;
@@ -9069,7 +8944,7 @@ ia64-*-hpux*)
;; ;;
esac esac
else else
case `$FILECMD conftest.$ac_objext` in case `/usr/bin/file conftest.$ac_objext` in
*32-bit*) *32-bit*)
LD="${LD-ld} -32" LD="${LD-ld} -32"
;; ;;
@@ -9095,7 +8970,7 @@ mips64*-*linux*)
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then test $ac_status = 0; }; then
emul=elf emul=elf
case `$FILECMD conftest.$ac_objext` in case `/usr/bin/file conftest.$ac_objext` in
*32-bit*) *32-bit*)
emul="${emul}32" emul="${emul}32"
;; ;;
@@ -9103,7 +8978,7 @@ mips64*-*linux*)
emul="${emul}64" emul="${emul}64"
;; ;;
esac esac
case `$FILECMD conftest.$ac_objext` in case `/usr/bin/file conftest.$ac_objext` in
*MSB*) *MSB*)
emul="${emul}btsmip" emul="${emul}btsmip"
;; ;;
@@ -9111,7 +8986,7 @@ mips64*-*linux*)
emul="${emul}ltsmip" emul="${emul}ltsmip"
;; ;;
esac esac
case `$FILECMD conftest.$ac_objext` in case `/usr/bin/file conftest.$ac_objext` in
*N32*) *N32*)
emul="${emul}n32" emul="${emul}n32"
;; ;;
@@ -9135,14 +9010,14 @@ s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
ac_status=$? ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then test $ac_status = 0; }; then
case `$FILECMD conftest.o` in case `/usr/bin/file conftest.o` in
*32-bit*) *32-bit*)
case $host in case $host in
x86_64-*kfreebsd*-gnu) x86_64-*kfreebsd*-gnu)
LD="${LD-ld} -m elf_i386_fbsd" LD="${LD-ld} -m elf_i386_fbsd"
;; ;;
x86_64-*linux*) x86_64-*linux*)
case `$FILECMD conftest.o` in case `/usr/bin/file conftest.o` in
*x86-64*) *x86-64*)
LD="${LD-ld} -m elf32_x86_64" LD="${LD-ld} -m elf32_x86_64"
;; ;;
@@ -9250,7 +9125,7 @@ printf "%s\n" "$lt_cv_cc_needs_belf" >&6; }
ac_status=$? ac_status=$?
printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; then test $ac_status = 0; }; then
case `$FILECMD conftest.o` in case `/usr/bin/file conftest.o` in
*64-bit*) *64-bit*)
case $lt_cv_prog_gnu_ld in case $lt_cv_prog_gnu_ld in
yes*) yes*)
@@ -10033,8 +9908,8 @@ int forced_loaded() { return 2;}
_LT_EOF _LT_EOF
echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5 echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5
$LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5 $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5
echo "$AR $AR_FLAGS libconftest.a conftest.o" >&5 echo "$AR cr libconftest.a conftest.o" >&5
$AR $AR_FLAGS libconftest.a conftest.o 2>&5 $AR cr libconftest.a conftest.o 2>&5
echo "$RANLIB libconftest.a" >&5 echo "$RANLIB libconftest.a" >&5
$RANLIB libconftest.a 2>&5 $RANLIB libconftest.a 2>&5
cat > conftest.c << _LT_EOF cat > conftest.c << _LT_EOF
@@ -10061,12 +9936,17 @@ printf "%s\n" "$lt_cv_ld_force_load" >&6; }
_lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;; _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;;
darwin1.*) darwin1.*)
_lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
darwin*) darwin*) # darwin 5.x on
case $MACOSX_DEPLOYMENT_TARGET,$host in # if running on 10.5 or later, the deployment target defaults
10.[012],*|,*powerpc*-darwin[5-8]*) # to the OS version, if on x86, and 10.4, the deployment
_lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;; # target defaults to 10.4. Don't you love it?
*) case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
_lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;; 10.0,*86*-darwin8*|10.0,*-darwin[912]*)
_lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
10.[012][,.]*)
_lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;
10.*|11.*)
_lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;
esac esac
;; ;;
esac esac
@@ -10363,8 +10243,8 @@ esac
ofile=libtool ofile=libtool
can_build_shared=yes can_build_shared=yes
# All known linkers require a '.a' archive for static linking (except MSVC and # All known linkers require a '.a' archive for static linking (except MSVC,
# ICC, which need '.lib'). # which needs '.lib').
libext=a libext=a
with_gnu_ld=$lt_cv_prog_gnu_ld with_gnu_ld=$lt_cv_prog_gnu_ld
@@ -10882,7 +10762,7 @@ lt_prog_compiler_static=
lt_prog_compiler_static='-qstaticlink' lt_prog_compiler_static='-qstaticlink'
;; ;;
*) *)
case `$CC -V 2>&1 | $SED 5q` in case `$CC -V 2>&1 | sed 5q` in
*Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*) *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*)
# Sun Fortran 8.3 passes all unrecognized flags to the linker # Sun Fortran 8.3 passes all unrecognized flags to the linker
lt_prog_compiler_pic='-KPIC' lt_prog_compiler_pic='-KPIC'
@@ -11305,15 +11185,15 @@ printf %s "checking whether the $compiler linker ($LD) supports shared libraries
case $host_os in case $host_os in
cygwin* | mingw* | pw32* | cegcc*) cygwin* | mingw* | pw32* | cegcc*)
# FIXME: the MSVC++ and ICC port hasn't been tested in a loooong time # FIXME: the MSVC++ port hasn't been tested in a loooong time
# When not using gcc, we currently assume that we are using # When not using gcc, we currently assume that we are using
# Microsoft Visual C++ or Intel C++ Compiler. # Microsoft Visual C++.
if test yes != "$GCC"; then if test yes != "$GCC"; then
with_gnu_ld=no with_gnu_ld=no
fi fi
;; ;;
interix*) interix*)
# we just hope/assume this is gcc and not c89 (= MSVC++ or ICC) # we just hope/assume this is gcc and not c89 (= MSVC++)
with_gnu_ld=yes with_gnu_ld=yes
;; ;;
openbsd* | bitrig*) openbsd* | bitrig*)
@@ -11368,7 +11248,7 @@ printf %s "checking whether the $compiler linker ($LD) supports shared libraries
whole_archive_flag_spec= whole_archive_flag_spec=
fi fi
supports_anon_versioning=no supports_anon_versioning=no
case `$LD -v | $SED -e 's/([^)]\+)\s\+//' 2>&1` in case `$LD -v | $SED -e 's/(^)\+)\s\+//' 2>&1` in
*GNU\ gold*) supports_anon_versioning=yes ;; *GNU\ gold*) supports_anon_versioning=yes ;;
*\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11 *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
*\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ... *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
@@ -11480,7 +11360,6 @@ _LT_EOF
emximp -o $lib $output_objdir/$libname.def' emximp -o $lib $output_objdir/$libname.def'
old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
enable_shared_with_static_runtimes=yes enable_shared_with_static_runtimes=yes
file_list_spec='@'
;; ;;
interix[3-9]*) interix[3-9]*)
@@ -11495,7 +11374,7 @@ _LT_EOF
# 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
# time. Moving up from 0x10000000 also allows more sbrk(2) space. # time. Moving up from 0x10000000 also allows more sbrk(2) space.
archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
archive_expsym_cmds='$SED "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib' archive_expsym_cmds='sed "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
;; ;;
gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu) gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
@@ -11538,7 +11417,7 @@ _LT_EOF
compiler_needs_object=yes compiler_needs_object=yes
;; ;;
esac esac
case `$CC -V 2>&1 | $SED 5q` in case `$CC -V 2>&1 | sed 5q` in
*Sun\ C*) # Sun C 5.9 *Sun\ C*) # Sun C 5.9
whole_archive_flag_spec='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive' whole_archive_flag_spec='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'
compiler_needs_object=yes compiler_needs_object=yes
@@ -11550,14 +11429,13 @@ _LT_EOF
if test yes = "$supports_anon_versioning"; then if test yes = "$supports_anon_versioning"; then
archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
echo "local: *; };" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~
$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib' $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib'
fi fi
case $cc_basename in case $cc_basename in
tcc*) tcc*)
hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
export_dynamic_flag_spec='-rdynamic' export_dynamic_flag_spec='-rdynamic'
;; ;;
xlf* | bgf* | bgxlf* | mpixlf*) xlf* | bgf* | bgxlf* | mpixlf*)
@@ -11567,7 +11445,7 @@ _LT_EOF
archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib' archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib'
if test yes = "$supports_anon_versioning"; then if test yes = "$supports_anon_versioning"; then
archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~ archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~ cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
echo "local: *; };" >> $output_objdir/$libname.ver~ echo "local: *; };" >> $output_objdir/$libname.ver~
$LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib' $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
fi fi
@@ -11699,7 +11577,7 @@ _LT_EOF
if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols' export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols'
else else
export_symbols_cmds='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "L") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols' export_symbols_cmds='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols'
fi fi
aix_use_runtimelinking=no aix_use_runtimelinking=no
@@ -11970,12 +11848,12 @@ fi
cygwin* | mingw* | pw32* | cegcc*) cygwin* | mingw* | pw32* | cegcc*)
# When not using gcc, we currently assume that we are using # When not using gcc, we currently assume that we are using
# Microsoft Visual C++ or Intel C++ Compiler. # Microsoft Visual C++.
# hardcode_libdir_flag_spec is actually meaningless, as there is # hardcode_libdir_flag_spec is actually meaningless, as there is
# no search path for DLLs. # no search path for DLLs.
case $cc_basename in case $cc_basename in
cl* | icl*) cl*)
# Native MSVC or ICC # Native MSVC
hardcode_libdir_flag_spec=' ' hardcode_libdir_flag_spec=' '
allow_undefined_flag=unsupported allow_undefined_flag=unsupported
always_export_symbols=yes always_export_symbols=yes
@@ -12016,7 +11894,7 @@ fi
fi' fi'
;; ;;
*) *)
# Assume MSVC and ICC wrapper # Assume MSVC wrapper
hardcode_libdir_flag_spec=' ' hardcode_libdir_flag_spec=' '
allow_undefined_flag=unsupported allow_undefined_flag=unsupported
# Tell ltmain to make .lib files, not .a files. # Tell ltmain to make .lib files, not .a files.
@@ -12057,8 +11935,8 @@ fi
output_verbose_link_cmd=func_echo_all output_verbose_link_cmd=func_echo_all
archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil" archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil"
module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil" module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil"
archive_expsym_cmds="$SED 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil" archive_expsym_cmds="sed 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil"
module_expsym_cmds="$SED -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil" module_expsym_cmds="sed -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil"
else else
ld_shlibs=no ld_shlibs=no
@@ -12092,7 +11970,7 @@ fi
;; ;;
# FreeBSD 3 and greater uses gcc -shared to do shared libraries. # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
freebsd* | dragonfly* | midnightbsd*) freebsd* | dragonfly*)
archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
hardcode_libdir_flag_spec='-R$libdir' hardcode_libdir_flag_spec='-R$libdir'
hardcode_direct=yes hardcode_direct=yes
@@ -12273,7 +12151,6 @@ printf "%s\n" "$lt_cv_irix_exported_symbol" >&6; }
# Fabrice Bellard et al's Tiny C Compiler # Fabrice Bellard et al's Tiny C Compiler
ld_shlibs=yes ld_shlibs=yes
archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags' archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'
;; ;;
esac esac
;; ;;
@@ -12345,7 +12222,6 @@ printf "%s\n" "$lt_cv_irix_exported_symbol" >&6; }
emximp -o $lib $output_objdir/$libname.def' emximp -o $lib $output_objdir/$libname.def'
old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def' old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'
enable_shared_with_static_runtimes=yes enable_shared_with_static_runtimes=yes
file_list_spec='@'
;; ;;
osf3*) osf3*)
@@ -13038,7 +12914,7 @@ cygwin* | mingw* | pw32* | cegcc*)
case $host_os in case $host_os in
cygwin*) cygwin*)
# Cygwin DLLs use 'cyg' prefix rather than 'lib' # Cygwin DLLs use 'cyg' prefix rather than 'lib'
soname_spec='`echo $libname | $SED -e 's/^lib/cyg/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' soname_spec='`echo $libname | sed -e 's/^lib/cyg/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api" sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"
;; ;;
@@ -13048,14 +12924,14 @@ cygwin* | mingw* | pw32* | cegcc*)
;; ;;
pw32*) pw32*)
# pw32 DLLs use 'pw' prefix rather than 'lib' # pw32 DLLs use 'pw' prefix rather than 'lib'
library_names_spec='`echo $libname | $SED -e 's/^lib/pw/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' library_names_spec='`echo $libname | sed -e 's/^lib/pw/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
;; ;;
esac esac
dynamic_linker='Win32 ld.exe' dynamic_linker='Win32 ld.exe'
;; ;;
*,cl* | *,icl*) *,cl*)
# Native MSVC or ICC # Native MSVC
libname_spec='$name' libname_spec='$name'
soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext' soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'
library_names_spec='$libname.dll.lib' library_names_spec='$libname.dll.lib'
@@ -13074,7 +12950,7 @@ cygwin* | mingw* | pw32* | cegcc*)
done done
IFS=$lt_save_ifs IFS=$lt_save_ifs
# Convert to MSYS style. # Convert to MSYS style.
sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'` sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'`
;; ;;
cygwin*) cygwin*)
# Convert to unix form, then to dos form, then back to unix form # Convert to unix form, then to dos form, then back to unix form
@@ -13111,7 +12987,7 @@ cygwin* | mingw* | pw32* | cegcc*)
;; ;;
*) *)
# Assume MSVC and ICC wrapper # Assume MSVC wrapper
library_names_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext $libname.lib' library_names_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext $libname.lib'
dynamic_linker='Win32 ld.exe' dynamic_linker='Win32 ld.exe'
;; ;;
@@ -13144,7 +13020,7 @@ dgux*)
shlibpath_var=LD_LIBRARY_PATH shlibpath_var=LD_LIBRARY_PATH
;; ;;
freebsd* | dragonfly* | midnightbsd*) freebsd* | dragonfly*)
# DragonFly does not have aout. When/if they implement a new # DragonFly does not have aout. When/if they implement a new
# versioning mechanism, adjust this. # versioning mechanism, adjust this.
if test -x /usr/bin/objformat; then if test -x /usr/bin/objformat; then
@@ -14309,41 +14185,30 @@ striplib=
old_striplib= old_striplib=
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5
printf %s "checking whether stripping libraries is possible... " >&6; } printf %s "checking whether stripping libraries is possible... " >&6; }
if test -z "$STRIP"; then if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
printf "%s\n" "no" >&6; } test -z "$striplib" && striplib="$STRIP --strip-unneeded"
else { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
if $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
old_striplib="$STRIP --strip-debug"
striplib="$STRIP --strip-unneeded"
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
printf "%s\n" "yes" >&6; } printf "%s\n" "yes" >&6; }
else else
case $host_os in # FIXME - insert some real tests, host_os isn't really good enough
darwin*) case $host_os in
# FIXME - insert some real tests, host_os isn't really good enough darwin*)
if test -n "$STRIP"; then
striplib="$STRIP -x" striplib="$STRIP -x"
old_striplib="$STRIP -S" old_striplib="$STRIP -S"
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
printf "%s\n" "yes" >&6; } printf "%s\n" "yes" >&6; }
;; else
freebsd*)
if $STRIP -V 2>&1 | $GREP "elftoolchain" >/dev/null; then
old_striplib="$STRIP --strip-debug"
striplib="$STRIP --strip-unneeded"
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
printf "%s\n" "yes" >&6; }
else
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }
fi
;;
*)
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; } printf "%s\n" "no" >&6; }
;; fi
esac ;;
fi *)
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }
;;
esac
fi fi
@@ -15848,15 +15713,6 @@ printf "%s\n" "$shadow_cv_passwd_dir" >&6; }
printf "%s\n" "#define PASSWD_PROGRAM \"$shadow_cv_passwd_dir/passwd\"" >>confdefs.h printf "%s\n" "#define PASSWD_PROGRAM \"$shadow_cv_passwd_dir/passwd\"" >>confdefs.h
if test "$ac_cv_func_ruserok" = "yes"; then
printf "%s\n" "#define RLOGIN 1" >>confdefs.h
printf "%s\n" "#define RUSEROK 0" >>confdefs.h
fi
# Check whether --enable-shadowgrp was given. # Check whether --enable-shadowgrp was given.
if test ${enable_shadowgrp+y} if test ${enable_shadowgrp+y}
then : then :
@@ -16359,8 +16215,8 @@ printf "%s\n" "no" >&6; }
fi fi
pkg_failed=no pkg_failed=no
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for cmocka" >&5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for CMOCKA" >&5
printf %s "checking for cmocka... " >&6; } printf %s "checking for CMOCKA... " >&6; }
if test -n "$CMOCKA_CFLAGS"; then if test -n "$CMOCKA_CFLAGS"; then
pkg_cv_CMOCKA_CFLAGS="$CMOCKA_CFLAGS" pkg_cv_CMOCKA_CFLAGS="$CMOCKA_CFLAGS"
@@ -16400,7 +16256,7 @@ fi
if test $pkg_failed = yes; then if test $pkg_failed = yes; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; } printf "%s\n" "no" >&6; }
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
@@ -16409,26 +16265,26 @@ else
_pkg_short_errors_supported=no _pkg_short_errors_supported=no
fi fi
if test $_pkg_short_errors_supported = yes; then if test $_pkg_short_errors_supported = yes; then
CMOCKA_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "cmocka" 2>&1` CMOCKA_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "cmocka" 2>&1`
else else
CMOCKA_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "cmocka" 2>&1` CMOCKA_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "cmocka" 2>&1`
fi fi
# Put the nasty error message in config.log where it belongs # Put the nasty error message in config.log where it belongs
echo "$CMOCKA_PKG_ERRORS" >&5 echo "$CMOCKA_PKG_ERRORS" >&5
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: libcmocka not found, cmocka tests will not be built" >&5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: libcmocka not found, cmocka tests will not be built" >&5
printf "%s\n" "$as_me: WARNING: libcmocka not found, cmocka tests will not be built" >&2;} printf "%s\n" "$as_me: WARNING: libcmocka not found, cmocka tests will not be built" >&2;}
elif test $pkg_failed = untried; then elif test $pkg_failed = untried; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; } printf "%s\n" "no" >&6; }
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: libcmocka not found, cmocka tests will not be built" >&5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: libcmocka not found, cmocka tests will not be built" >&5
printf "%s\n" "$as_me: WARNING: libcmocka not found, cmocka tests will not be built" >&2;} printf "%s\n" "$as_me: WARNING: libcmocka not found, cmocka tests will not be built" >&2;}
else else
CMOCKA_CFLAGS=$pkg_cv_CMOCKA_CFLAGS CMOCKA_CFLAGS=$pkg_cv_CMOCKA_CFLAGS
CMOCKA_LIBS=$pkg_cv_CMOCKA_LIBS CMOCKA_LIBS=$pkg_cv_CMOCKA_LIBS
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
printf "%s\n" "yes" >&6; } printf "%s\n" "yes" >&6; }
have_cmocka="yes" have_cmocka="yes"
fi fi
if test x$have_cmocka = xyes; then if test x$have_cmocka = xyes; then
HAVE_CMOCKA_TRUE= HAVE_CMOCKA_TRUE=
@@ -17062,8 +16918,8 @@ then :
pkg_failed=no pkg_failed=no
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for libbsd-overlay" >&5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for LIBBSD" >&5
printf %s "checking for libbsd-overlay... " >&6; } printf %s "checking for LIBBSD... " >&6; }
if test -n "$LIBBSD_CFLAGS"; then if test -n "$LIBBSD_CFLAGS"; then
pkg_cv_LIBBSD_CFLAGS="$LIBBSD_CFLAGS" pkg_cv_LIBBSD_CFLAGS="$LIBBSD_CFLAGS"
@@ -17103,7 +16959,7 @@ fi
if test $pkg_failed = yes; then if test $pkg_failed = yes; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; } printf "%s\n" "no" >&6; }
if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
@@ -17112,14 +16968,14 @@ else
_pkg_short_errors_supported=no _pkg_short_errors_supported=no
fi fi
if test $_pkg_short_errors_supported = yes; then if test $_pkg_short_errors_supported = yes; then
LIBBSD_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libbsd-overlay" 2>&1` LIBBSD_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "libbsd-overlay" 2>&1`
else else
LIBBSD_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libbsd-overlay" 2>&1` LIBBSD_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "libbsd-overlay" 2>&1`
fi fi
# Put the nasty error message in config.log where it belongs # Put the nasty error message in config.log where it belongs
echo "$LIBBSD_PKG_ERRORS" >&5 echo "$LIBBSD_PKG_ERRORS" >&5
as_fn_error $? "Package requirements (libbsd-overlay) were not met: as_fn_error $? "Package requirements (libbsd-overlay) were not met:
$LIBBSD_PKG_ERRORS $LIBBSD_PKG_ERRORS
@@ -17130,9 +16986,9 @@ Alternatively, you may set the environment variables LIBBSD_CFLAGS
and LIBBSD_LIBS to avoid the need to call pkg-config. and LIBBSD_LIBS to avoid the need to call pkg-config.
See the pkg-config man page for more details." "$LINENO" 5 See the pkg-config man page for more details." "$LINENO" 5
elif test $pkg_failed = untried; then elif test $pkg_failed = untried; then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; } printf "%s\n" "no" >&6; }
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;} printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it as_fn_error $? "The pkg-config script could not be found or is too old. Make sure it
is in your PATH or set the PKG_CONFIG environment variable to the full is in your PATH or set the PKG_CONFIG environment variable to the full
@@ -17145,8 +17001,8 @@ See the pkg-config man page for more details.
To get pkg-config, see <http://pkg-config.freedesktop.org/>. To get pkg-config, see <http://pkg-config.freedesktop.org/>.
See \`config.log' for more details" "$LINENO" 5; } See \`config.log' for more details" "$LINENO" 5; }
else else
LIBBSD_CFLAGS=$pkg_cv_LIBBSD_CFLAGS LIBBSD_CFLAGS=$pkg_cv_LIBBSD_CFLAGS
LIBBSD_LIBS=$pkg_cv_LIBBSD_LIBS LIBBSD_LIBS=$pkg_cv_LIBBSD_LIBS
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5 { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
printf "%s\n" "yes" >&6; } printf "%s\n" "yes" >&6; }
@@ -18230,7 +18086,7 @@ if test "x$ac_cv_lib_skey_skeychallenge" = xyes
then : then :
LIBSKEY=-lskey LIBSKEY=-lskey
else $as_nop else $as_nop
as_fn_error $? "liskey missing. You can download S/Key source code from http://rsync1.it.gentoo.org/gentoo/distfiles/skey-1.1.5.tar.bz2" "$LINENO" 5 as_fn_error $? "libskey missing. You can download S/Key source code from http://rsync1.it.gentoo.org/gentoo/distfiles/skey-1.1.5.tar.bz2" "$LINENO" 5
fi fi
@@ -20990,7 +20846,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their # report actual input values of CONFIG_FILES etc. instead of their
# values after options handling. # values after options handling.
ac_log=" ac_log="
This file was extended by shadow $as_me 4.15.3, which was This file was extended by shadow $as_me 4.17.2, which was
generated by GNU Autoconf 2.71. Invocation command line was generated by GNU Autoconf 2.71. Invocation command line was
CONFIG_FILES = $CONFIG_FILES CONFIG_FILES = $CONFIG_FILES
@@ -21059,7 +20915,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config='$ac_cs_config_escaped' ac_cs_config='$ac_cs_config_escaped'
ac_cs_version="\\ ac_cs_version="\\
shadow config.status 4.15.3 shadow config.status 4.17.2
configured by $0, generated by GNU Autoconf 2.71, configured by $0, generated by GNU Autoconf 2.71,
with options \\"\$ac_cs_config\\" with options \\"\$ac_cs_config\\"
@@ -21222,7 +21078,6 @@ lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_q
lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`' lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`'
reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`' reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`'
reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`' reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`'
FILECMD='`$ECHO "$FILECMD" | $SED "$delay_single_quote_subst"`'
OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`' OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`'
deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`' deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`'
file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`' file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`'
@@ -21231,7 +21086,6 @@ want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`'
DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`' DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`'
sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`' sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`'
AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`' AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`'
lt_ar_flags='`$ECHO "$lt_ar_flags" | $SED "$delay_single_quote_subst"`'
AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`' AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`'
archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`' archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`'
STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`' STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`'
@@ -21352,7 +21206,6 @@ LN_S \
lt_SP2NL \ lt_SP2NL \
lt_NL2SP \ lt_NL2SP \
reload_flag \ reload_flag \
FILECMD \
OBJDUMP \ OBJDUMP \
deplibs_check_method \ deplibs_check_method \
file_magic_cmd \ file_magic_cmd \
@@ -21361,6 +21214,7 @@ want_nocaseglob \
DLLTOOL \ DLLTOOL \
sharedlib_from_linklib_cmd \ sharedlib_from_linklib_cmd \
AR \ AR \
AR_FLAGS \
archiver_list_spec \ archiver_list_spec \
STRIP \ STRIP \
RANLIB \ RANLIB \
@@ -22343,9 +22197,6 @@ to_host_file_cmd=$lt_cv_to_host_file_cmd
# convert \$build files to toolchain format. # convert \$build files to toolchain format.
to_tool_file_cmd=$lt_cv_to_tool_file_cmd to_tool_file_cmd=$lt_cv_to_tool_file_cmd
# A file(cmd) program that detects file types.
FILECMD=$lt_FILECMD
# An object symbol dumper. # An object symbol dumper.
OBJDUMP=$lt_OBJDUMP OBJDUMP=$lt_OBJDUMP
@@ -22370,11 +22221,8 @@ sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd
# The archiver. # The archiver.
AR=$lt_AR AR=$lt_AR
# Flags to create an archive (by configure).
lt_ar_flags=$lt_ar_flags
# Flags to create an archive. # Flags to create an archive.
AR_FLAGS=\${ARFLAGS-"\$lt_ar_flags"} AR_FLAGS=$lt_AR_FLAGS
# How to feed a file listing to the archiver. # How to feed a file listing to the archiver.
archiver_list_spec=$lt_archiver_list_spec archiver_list_spec=$lt_archiver_list_spec
@@ -22750,7 +22598,7 @@ ltmain=$ac_aux_dir/ltmain.sh
# if finds mixed CR/LF and LF-only lines. Since sed operates in # if finds mixed CR/LF and LF-only lines. Since sed operates in
# text mode, it properly converts lines to CR/LF. This bash problem # text mode, it properly converts lines to CR/LF. This bash problem
# is reportedly fixed, but why not run on old versions too? # is reportedly fixed, but why not run on old versions too?
$SED '$q' "$ltmain" >> "$cfgfile" \ sed '$q' "$ltmain" >> "$cfgfile" \
|| (rm -f "$cfgfile"; exit 1) || (rm -f "$cfgfile"; exit 1)
mv -f "$cfgfile" "$ofile" || mv -f "$cfgfile" "$ofile" ||
+3 -10
View File
@@ -1,10 +1,10 @@
dnl Process this file with autoconf to produce a configure script. dnl Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69]) AC_PREREQ([2.69])
m4_define([libsubid_abi_major], 4) m4_define([libsubid_abi_major], 5)
m4_define([libsubid_abi_minor], 0) m4_define([libsubid_abi_minor], 0)
m4_define([libsubid_abi_micro], 0) m4_define([libsubid_abi_micro], 0)
m4_define([libsubid_abi], [libsubid_abi_major.libsubid_abi_minor.libsubid_abi_micro]) m4_define([libsubid_abi], [libsubid_abi_major.libsubid_abi_minor.libsubid_abi_micro])
AC_INIT([shadow], [4.15.3], [pkg-shadow-devel@lists.alioth.debian.org], [], AC_INIT([shadow], [4.17.2], [pkg-shadow-devel@lists.alioth.debian.org], [],
[https://github.com/shadow-maint/shadow]) [https://github.com/shadow-maint/shadow])
AM_INIT_AUTOMAKE([1.11 foreign dist-xz subdir-objects tar-pax]) AM_INIT_AUTOMAKE([1.11 foreign dist-xz subdir-objects tar-pax])
AC_CONFIG_MACRO_DIRS([m4]) AC_CONFIG_MACRO_DIRS([m4])
@@ -159,13 +159,6 @@ fi])
AC_DEFINE_UNQUOTED(PASSWD_PROGRAM, "$shadow_cv_passwd_dir/passwd", AC_DEFINE_UNQUOTED(PASSWD_PROGRAM, "$shadow_cv_passwd_dir/passwd",
[Path to passwd program.]) [Path to passwd program.])
dnl XXX - quick hack, should disappear before anyone notices :).
dnl XXX - I just read the above message :).
if test "$ac_cv_func_ruserok" = "yes"; then
AC_DEFINE(RLOGIN, 1, [Define if login should support the -r flag for rlogind.])
AC_DEFINE(RUSEROK, 0, [Define to the ruserok() "success" return value (0 or 1).])
fi
AC_ARG_ENABLE(shadowgrp, AC_ARG_ENABLE(shadowgrp,
[AS_HELP_STRING([--enable-shadowgrp], [enable shadow group support @<:@default=yes@:>@])], [AS_HELP_STRING([--enable-shadowgrp], [enable shadow group support @<:@default=yes@:>@])],
[case "${enableval}" in [case "${enableval}" in
@@ -696,7 +689,7 @@ AC_SUBST(LIBMD)
if test "$with_skey" = "yes"; then if test "$with_skey" = "yes"; then
AC_CHECK_LIB(md, MD5Init, [LIBMD=-lmd]) AC_CHECK_LIB(md, MD5Init, [LIBMD=-lmd])
AC_CHECK_LIB(skey, skeychallenge, [LIBSKEY=-lskey], AC_CHECK_LIB(skey, skeychallenge, [LIBSKEY=-lskey],
[AC_MSG_ERROR([liskey missing. You can download S/Key source code from http://rsync1.it.gentoo.org/gentoo/distfiles/skey-1.1.5.tar.bz2])]) [AC_MSG_ERROR([libskey missing. You can download S/Key source code from http://rsync1.it.gentoo.org/gentoo/distfiles/skey-1.1.5.tar.bz2])])
AC_DEFINE(SKEY, 1, [Define to support S/Key logins.]) AC_DEFINE(SKEY, 1, [Define to support S/Key logins.])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#include <stdio.h> #include <stdio.h>
-1
View File
@@ -161,7 +161,6 @@ EGREP = @EGREP@
ETAGS = @ETAGS@ ETAGS = @ETAGS@
EXEEXT = @EXEEXT@ EXEEXT = @EXEEXT@
FGREP = @FGREP@ FGREP = @FGREP@
FILECMD = @FILECMD@
GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
GMSGFMT = @GMSGFMT@ GMSGFMT = @GMSGFMT@
GMSGFMT_015 = @GMSGFMT_015@ GMSGFMT_015 = @GMSGFMT_015@
+11 -10
View File
@@ -118,6 +118,9 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <syslog.h> #include <syslog.h>
#include "string/strcmp/streq.h"
#define IMMEDIATE_CHANGE /* Expire newly created password, must be changed #define IMMEDIATE_CHANGE /* Expire newly created password, must be changed
* immediately upon next login */ * immediately upon next login */
#define HAVE_QUOTAS /* Obvious */ #define HAVE_QUOTAS /* Obvious */
@@ -291,12 +294,10 @@ main (void)
printf ("Home Directory [%s/%s]: ", DEFAULT_HOME, usrname); printf ("Home Directory [%s/%s]: ", DEFAULT_HOME, usrname);
fflush (stdout); fflush (stdout);
safeget (dir, sizeof (dir)); safeget (dir, sizeof (dir));
if (!strlen (dir)) if (!strlen(dir)) /* hit return */
{ /* hit return */ sprintf(dir, "%s/%s", DEFAULT_HOME, usrname);
sprintf (dir, "%s/%s", DEFAULT_HOME, usrname);
}
else if (dir[strlen (dir) - 1] == '/') else if (dir[strlen (dir) - 1] == '/')
sprintf (dir+strlen(dir), "%s", usrname); strcat(dir, usrname);
} }
else else
{ {
@@ -308,7 +309,7 @@ main (void)
fflush (stdout); fflush (stdout);
safeget (shell, sizeof (shell)); safeget (shell, sizeof (shell));
if (!strlen (shell)) if (!strlen (shell))
sprintf (shell, "%s", DEFAULT_SHELL); strcpy(shell, DEFAULT_SHELL);
else else
{ {
char *sh; char *sh;
@@ -316,7 +317,7 @@ main (void)
#ifdef HAVE_GETUSERSHELL #ifdef HAVE_GETUSERSHELL
setusershell (); setusershell ();
while ((sh = getusershell ()) != NULL) while ((sh = getusershell ()) != NULL)
if (!strcmp (shell, sh)) if (streq(shell, sh))
ok = 1; ok = 1;
endusershell (); endusershell ();
#endif #endif
@@ -327,7 +328,7 @@ main (void)
else else
{ {
printf ("Shell NOT in /etc/shells, DEFAULT used\n"); printf ("Shell NOT in /etc/shells, DEFAULT used\n");
sprintf (shell, "%s", DEFAULT_SHELL); strcpy(shell, DEFAULT_SHELL);
} }
} }
} }
@@ -491,12 +492,12 @@ safeget (char *buf, int maxlen)
bad = (!isalnum (c) && (c != '_') && (c != ' ')); bad = (!isalnum (c) && (c != '_') && (c != ' '));
*(buf++) = c; *(buf++) = c;
} }
*buf = '\0'; stpcpy(buf, "");
if (bad) if (bad)
{ {
printf ("\nString contained banned character. Please stick to alphanumerics.\n"); printf ("\nString contained banned character. Please stick to alphanumerics.\n");
*bstart = '\0'; stpcpy(bstart, "");
} }
} }
+3 -7
View File
@@ -471,12 +471,12 @@
The Shadow Suite contains replacement programs for: The Shadow Suite contains replacement programs for:
su, login, passwd, newgrp, chfn, chsh, and id su, login, passwd, newgrp, chfn, chsh
The package also contains the new programs: The package also contains the new programs:
chage, newusers, dpasswd, gpasswd, useradd, userdel, usermod, chage, newusers, dpasswd, gpasswd, useradd, userdel, usermod,
groupadd, groupdel, groupmod, groups, pwck, grpck, lastlog, pwconv, groupadd, groupdel, groupmod, pwck, grpck, lastlog, pwconv,
and pwunconv and pwunconv
Additionally, the library: libshadow.a is included for writing and/or Additionally, the library: libshadow.a is included for writing and/or
@@ -586,8 +586,6 @@
· /usr/bin/chsh · /usr/bin/chsh
· /usr/bin/id
The BETA package has a save target in the Makefile, but it's commented The BETA package has a save target in the Makefile, but it's commented
out because different distributions place the programs in different out because different distributions place the programs in different
places. places.
@@ -637,8 +635,6 @@
· /usr/man/man1/chsh.1.gz · /usr/man/man1/chsh.1.gz
· /usr/man/man1/id.1.gz
· /usr/man/man1/login.1.gz · /usr/man/man1/login.1.gz
· /usr/man/man1/passwd.1.gz · /usr/man/man1/passwd.1.gz
@@ -1377,7 +1373,7 @@
users or changing the group password, the /etc/gshadow file will be users or changing the group password, the /etc/gshadow file will be
changed. changed.
The programs groups, groupadd, groupmod, and groupdel are provided as The programs groupadd, groupmod, and groupdel are provided as
part of the Shadow Suite to modify groups. part of the Shadow Suite to modify groups.
The format of the /etc/group file is as follows: The format of the /etc/group file is as follows:
-1
View File
@@ -161,7 +161,6 @@ EGREP = @EGREP@
ETAGS = @ETAGS@ ETAGS = @ETAGS@
EXEEXT = @EXEEXT@ EXEEXT = @EXEEXT@
FGREP = @FGREP@ FGREP = @FGREP@
FILECMD = @FILECMD@
GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
GMSGFMT = @GMSGFMT@ GMSGFMT = @GMSGFMT@
GMSGFMT_015 = @GMSGFMT_015@ GMSGFMT_015 = @GMSGFMT_015@
-1
View File
@@ -250,7 +250,6 @@ EGREP = @EGREP@
ETAGS = @ETAGS@ ETAGS = @ETAGS@
EXEEXT = @EXEEXT@ EXEEXT = @EXEEXT@
FGREP = @FGREP@ FGREP = @FGREP@
FILECMD = @FILECMD@
GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
GMSGFMT = @GMSGFMT@ GMSGFMT = @GMSGFMT@
GMSGFMT_015 = @GMSGFMT_015@ GMSGFMT_015 = @GMSGFMT_015@
-1
View File
@@ -193,7 +193,6 @@ EGREP = @EGREP@
ETAGS = @ETAGS@ ETAGS = @ETAGS@
EXEEXT = @EXEEXT@ EXEEXT = @EXEEXT@
FGREP = @FGREP@ FGREP = @FGREP@
FILECMD = @FILECMD@
GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
GMSGFMT = @GMSGFMT@ GMSGFMT = @GMSGFMT@
GMSGFMT_015 = @GMSGFMT_015@ GMSGFMT_015 = @GMSGFMT_015@
-1
View File
@@ -158,7 +158,6 @@ EGREP = @EGREP@
ETAGS = @ETAGS@ ETAGS = @ETAGS@
EXEEXT = @EXEEXT@ EXEEXT = @EXEEXT@
FGREP = @FGREP@ FGREP = @FGREP@
FILECMD = @FILECMD@
GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@ GETTEXT_MACRO_VERSION = @GETTEXT_MACRO_VERSION@
GMSGFMT = @GMSGFMT@ GMSGFMT = @GMSGFMT@
GMSGFMT_015 = @GMSGFMT_015@ GMSGFMT_015 = @GMSGFMT_015@
+81 -25
View File
@@ -29,16 +29,48 @@ libshadow_la_SOURCES = \
age.c \ age.c \
agetpass.c \ agetpass.c \
agetpass.h \ agetpass.h \
alloc.c \ alloc/calloc.c \
alloc.h \ alloc/calloc.h \
atoi/a2i.c \ alloc/malloc.c \
atoi/a2i.h \ alloc/malloc.h \
atoi/str2i.c \ alloc/realloc.c \
atoi/str2i.h \ alloc/realloc.h \
atoi/strtoi.c \ alloc/reallocf.c \
atoi/strtoi.h \ alloc/reallocf.h \
atoi/strtou_noneg.c \ alloc/x/xcalloc.c \
atoi/strtou_noneg.h \ alloc/x/xcalloc.h \
alloc/x/xmalloc.c \
alloc/x/xmalloc.h \
alloc/x/xrealloc.c \
alloc/x/xrealloc.h \
atoi/a2i/a2i.c \
atoi/a2i/a2i.h \
atoi/a2i/a2s.c \
atoi/a2i/a2s.h \
atoi/a2i/a2s_c.c \
atoi/a2i/a2s_c.h \
atoi/a2i/a2s_nc.c \
atoi/a2i/a2s_nc.h \
atoi/a2i/a2u.c \
atoi/a2i/a2u.h \
atoi/a2i/a2u_c.c \
atoi/a2i/a2u_c.h \
atoi/a2i/a2u_nc.c \
atoi/a2i/a2u_nc.h \
atoi/getnum.c \
atoi/getnum.h \
atoi/str2i/str2i.c \
atoi/str2i/str2i.h \
atoi/str2i/str2s.c \
atoi/str2i/str2s.h \
atoi/str2i/str2u.c \
atoi/str2i/str2u.h \
atoi/strtoi/strtoi.c \
atoi/strtoi/strtoi.h \
atoi/strtoi/strtou.c \
atoi/strtoi/strtou.h \
atoi/strtoi/strtou_noneg.c \
atoi/strtoi/strtou_noneg.h \
attr.h \ attr.h \
audit_help.c \ audit_help.c \
basename.c \ basename.c \
@@ -71,9 +103,11 @@ libshadow_la_SOURCES = \
find_new_sub_gids.c \ find_new_sub_gids.c \
find_new_sub_uids.c \ find_new_sub_uids.c \
fputsx.c \ fputsx.c \
get_gid.c \ fs/readlink/areadlink.c \
fs/readlink/areadlink.h \
fs/readlink/readlinknul.c \
fs/readlink/readlinknul.h \
get_pid.c \ get_pid.c \
get_uid.c \
getdate.h \ getdate.h \
getdate.y \ getdate.y \
getdef.c \ getdef.c \
@@ -94,8 +128,6 @@ libshadow_la_SOURCES = \
lockpw.c \ lockpw.c \
loginprompt.c \ loginprompt.c \
mail.c \ mail.c \
memzero.c \
memzero.h \
motd.c \ motd.c \
must_be.h \ must_be.h \
myname.c \ myname.c \
@@ -119,7 +151,6 @@ libshadow_la_SOURCES = \
pwdcheck.c \ pwdcheck.c \
pwmem.c \ pwmem.c \
remove_tree.c \ remove_tree.c \
rlogin.c \
root_flag.c \ root_flag.c \
run_part.h \ run_part.h \
run_part.c \ run_part.c \
@@ -145,18 +176,42 @@ libshadow_la_SOURCES = \
spawn.c \ spawn.c \
sssd.c \ sssd.c \
sssd.h \ sssd.h \
string/sprintf.c \ string/memset/memzero.c \
string/sprintf.h \ string/memset/memzero.h \
string/stpecpy.c \ string/sprintf/snprintf.c \
string/stpecpy.h \ string/sprintf/snprintf.h \
string/stpeprintf.c \ string/sprintf/stpeprintf.c \
string/stpeprintf.h \ string/sprintf/stpeprintf.h \
string/sprintf/xasprintf.c \
string/sprintf/xasprintf.h \
string/strchr/strchrcnt.c \
string/strchr/strchrcnt.h \
string/strchr/stpspn.c \
string/strchr/stpspn.h \
string/strchr/strnul.c \
string/strchr/strnul.h \
string/strchr/strrspn.c \
string/strchr/strrspn.h \
string/strcmp/streq.c \
string/strcmp/streq.h \
string/strcpy/stpecpy.c \
string/strcpy/stpecpy.h \
string/strcpy/strncat.c \
string/strcpy/strncat.h \
string/strcpy/strncpy.c \
string/strcpy/strncpy.h \
string/strcpy/strtcpy.c \
string/strcpy/strtcpy.h \
string/strdup/strndupa.c \
string/strdup/strndupa.h \
string/strdup/xstrdup.c \
string/strdup/xstrdup.h \
string/strdup/xstrndup.c \
string/strdup/xstrndup.h \
string/strftime.c \ string/strftime.c \
string/strftime.h \ string/strftime.h \
string/strncpy.h \ string/strtok/stpsep.c \
string/strtcpy.c \ string/strtok/stpsep.h \
string/strtcpy.h \
string/zustr2stp.h \
strtoday.c \ strtoday.c \
sub.c \ sub.c \
subordinateio.h \ subordinateio.h \
@@ -165,6 +220,7 @@ libshadow_la_SOURCES = \
time/day_to_str.c \ time/day_to_str.c \
time/day_to_str.h \ time/day_to_str.h \
ttytype.c \ ttytype.c \
typetraits.h \
tz.c \ tz.c \
ulimit.c \ ulimit.c \
user_busy.c \ user_busy.c \
+814 -230
View File
File diff suppressed because it is too large Load Diff
+13 -11
View File
@@ -14,28 +14,30 @@
#include "prototypes.h" #include "prototypes.h"
#include "defines.h" #include "defines.h"
#include <stdio.h>
#include <grp.h>
#include <errno.h> #include <errno.h>
#include <grp.h>
#include <stdio.h>
#include <string.h>
#include "alloc.h" #include "alloc/malloc.h"
#include "alloc/reallocf.h"
#include "shadowlog.h" #include "shadowlog.h"
#ident "$Id$" #ident "$Id$"
#define SEP ",:"
/* /*
* Add groups with names from LIST (separated by commas or colons) * Add groups with names from LIST (separated by commas or colons)
* to the supplementary group set. Silently ignore groups which are * to the supplementary group set. Silently ignore groups which are
* already there. Warning: uses strtok(). * already there.
*/ */
int add_groups (const char *list) int
add_groups(const char *list)
{ {
GETGROUPS_T *grouplist; GETGROUPS_T *grouplist;
size_t i; size_t i;
int ngroups; int ngroups;
bool added; bool added;
char *token; char *g, *p;
char buf[1024]; char buf[1024];
int ret; int ret;
FILE *shadow_logfd = log_get_logfd(); FILE *shadow_logfd = log_get_logfd();
@@ -70,13 +72,13 @@ int add_groups (const char *list)
} }
added = false; added = false;
for (token = strtok (buf, SEP); NULL != token; token = strtok (NULL, SEP)) { p = buf;
while (NULL != (g = strsep(&p, ",:"))) {
struct group *grp; struct group *grp;
grp = getgrnam (token); /* local, no need for xgetgrnam */ grp = getgrnam(g); /* local, no need for xgetgrnam */
if (NULL == grp) { if (NULL == grp) {
fprintf (shadow_logfd, _("Warning: unknown group %s\n"), fprintf(shadow_logfd, _("Warning: unknown group %s\n"), g);
token);
continue; continue;
} }
+1 -1
View File
@@ -16,7 +16,7 @@
#ident "$Id$" #ident "$Id$"
#include "alloc.h" #include "alloc/malloc.h"
#if WITH_LIBBSD == 0 #if WITH_LIBBSD == 0
#include "freezero.h" #include "freezero.h"
-73
View File
@@ -1,73 +0,0 @@
/*
* SPDX-FileCopyrightText: 1990 - 1994, Julianne Frances Haugh
* SPDX-FileCopyrightText: 1996 - 1998, Marek Michałkiewicz
* SPDX-FileCopyrightText: 2003 - 2006, Tomasz Kłoczko
* SPDX-FileCopyrightText: 2008 , Nicolas François
* SPDX-FileCopyrightText: 2023 , Alejandro Colomar <alx@kernel.org>
*
* SPDX-License-Identifier: BSD-3-Clause
*/
/* Replacements for malloc and strdup with error checking. Too trivial
to be worth copyrighting :-). I did that because a lot of code used
malloc and strdup without checking for NULL pointer, and I like some
message better than a core dump... --marekm
Yeh, but. Remember that bailing out might leave the system in some
bizarre state. You really want to put in error checking, then add
some back-out failure recovery code. -- jfh */
#include <config.h>
#ident "$Id$"
#include "alloc.h"
#include <errno.h>
#include <stddef.h>
#include <stdio.h>
#include "defines.h"
#include "prototypes.h"
#include "shadowlog.h"
extern inline void *xmalloc(size_t size);
extern inline void *xmallocarray(size_t nmemb, size_t size);
extern inline void *mallocarray(size_t nmemb, size_t size);
extern inline void *reallocarrayf(void *p, size_t nmemb, size_t size);
extern inline char *xstrdup(const char *str);
void *
xcalloc(size_t nmemb, size_t size)
{
void *p;
p = calloc(nmemb, size);
if (p == NULL)
goto x;
return p;
x:
fprintf(log_get_logfd(), _("%s: %s\n"),
log_get_progname(), strerror(errno));
exit(13);
}
void *
xreallocarray(void *p, size_t nmemb, size_t size)
{
p = reallocarrayf(p, nmemb, size);
if (p == NULL)
goto x;
return p;
x:
fprintf(log_get_logfd(), _("%s: %s\n"),
log_get_progname(), strerror(errno));
exit(13);
}
-101
View File
@@ -1,101 +0,0 @@
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#ifndef SHADOW_INCLUDE_LIB_MALLOC_H_
#define SHADOW_INCLUDE_LIB_MALLOC_H_
#include <config.h>
#include <assert.h>
#include <errno.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include "attr.h"
#include "defines.h"
#define CALLOC(n, type) ((type *) calloc(n, sizeof(type)))
#define XCALLOC(n, type) ((type *) xcalloc(n, sizeof(type)))
#define MALLOC(n, type) ((type *) mallocarray(n, sizeof(type)))
#define XMALLOC(n, type) ((type *) xmallocarray(n, sizeof(type)))
#define REALLOC(ptr, n, type) \
( \
_Generic(ptr, type *: (type *) reallocarray(ptr, n, sizeof(type))) \
)
#define REALLOCF(ptr, n, type) \
( \
_Generic(ptr, type *: (type *) reallocarrayf(ptr, n, sizeof(type))) \
)
#define XREALLOC(ptr, n, type) \
( \
_Generic(ptr, type *: (type *) xreallocarray(ptr, n, sizeof(type))) \
)
ATTR_MALLOC(free)
inline void *xmalloc(size_t size);
ATTR_MALLOC(free)
inline void *xmallocarray(size_t nmemb, size_t size);
ATTR_MALLOC(free)
inline void *mallocarray(size_t nmemb, size_t size);
ATTR_MALLOC(free)
inline void *reallocarrayf(void *p, size_t nmemb, size_t size);
ATTR_MALLOC(free)
inline char *xstrdup(const char *str);
ATTR_MALLOC(free)
void *xcalloc(size_t nmemb, size_t size);
ATTR_MALLOC(free)
void *xreallocarray(void *p, size_t nmemb, size_t size);
inline void *
xmalloc(size_t size)
{
return xmallocarray(1, size);
}
inline void *
xmallocarray(size_t nmemb, size_t size)
{
return xreallocarray(NULL, nmemb, size);
}
inline void *
mallocarray(size_t nmemb, size_t size)
{
return reallocarray(NULL, nmemb, size);
}
inline void *
reallocarrayf(void *p, size_t nmemb, size_t size)
{
void *q;
q = reallocarray(p, nmemb, size);
/* realloc(p, 0) is equivalent to free(p); avoid double free. */
if (q == NULL && nmemb != 0 && size != 0)
free(p);
return q;
}
inline char *
xstrdup(const char *str)
{
return strcpy(XMALLOC(strlen(str) + 1, char), str);
}
#endif // include guard
+11
View File
@@ -0,0 +1,11 @@
// SPDX-FileCopyrightText: 1990-1994, Julianne Frances Haugh
// SPDX-FileCopyrightText: 1996-1998, Marek Michałkiewicz
// SPDX-FileCopyrightText: 2003-2006, Tomasz Kłoczko
// SPDX-FileCopyrightText: 2008 , Nicolas François
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#include <config.h>
#include "alloc/calloc.h"
+20
View File
@@ -0,0 +1,20 @@
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#ifndef SHADOW_INCLUDE_LIB_ALLOC_CALLOC_H_
#define SHADOW_INCLUDE_LIB_ALLOC_CALLOC_H_
#include <config.h>
#include <stdlib.h>
#define CALLOC(n, type) \
( \
(type *) calloc(n, sizeof(type)) \
)
#endif // include guard
+16
View File
@@ -0,0 +1,16 @@
// SPDX-FileCopyrightText: 1990-1994, Julianne Frances Haugh
// SPDX-FileCopyrightText: 1996-1998, Marek Michałkiewicz
// SPDX-FileCopyrightText: 2003-2006, Tomasz Kłoczko
// SPDX-FileCopyrightText: 2008 , Nicolas François
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#include <config.h>
#include "alloc/malloc.h"
#include <stddef.h>
extern inline void *mallocarray(size_t nmemb, size_t size);
+34
View File
@@ -0,0 +1,34 @@
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#ifndef SHADOW_INCLUDE_LIB_ALLOC_MALLOC_H_
#define SHADOW_INCLUDE_LIB_ALLOC_MALLOC_H_
#include <config.h>
#include <stdlib.h>
#include "attr.h"
#define MALLOC(n, type) \
( \
(type *) mallocarray(n, sizeof(type)) \
)
ATTR_ALLOC_SIZE(1, 2)
ATTR_MALLOC(free)
inline void *mallocarray(size_t nmemb, size_t size);
inline void *
mallocarray(size_t nmemb, size_t size)
{
return reallocarray(NULL, nmemb, size);
}
#endif // include guard
+11
View File
@@ -0,0 +1,11 @@
// SPDX-FileCopyrightText: 1990-1994, Julianne Frances Haugh
// SPDX-FileCopyrightText: 1996-1998, Marek Michałkiewicz
// SPDX-FileCopyrightText: 2003-2006, Tomasz Kłoczko
// SPDX-FileCopyrightText: 2008 , Nicolas François
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#include <config.h>
#include "alloc/realloc.h"
+20
View File
@@ -0,0 +1,20 @@
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#ifndef SHADOW_INCLUDE_LIB_ALLOC_REALLOC_H_
#define SHADOW_INCLUDE_LIB_ALLOC_REALLOC_H_
#include <config.h>
#include <stdlib.h>
#define REALLOC(p, n, type) \
( \
_Generic(p, type *: (type *) reallocarray(p, (n) ?: 1, sizeof(type))) \
)
#endif // include guard
+16
View File
@@ -0,0 +1,16 @@
// SPDX-FileCopyrightText: 1990-1994, Julianne Frances Haugh
// SPDX-FileCopyrightText: 1996-1998, Marek Michałkiewicz
// SPDX-FileCopyrightText: 2003-2006, Tomasz Kłoczko
// SPDX-FileCopyrightText: 2008 , Nicolas François
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#include <config.h>
#include "alloc/reallocf.h"
#include <stddef.h>
extern inline void *reallocarrayf(void *p, size_t nmemb, size_t size);
+41
View File
@@ -0,0 +1,41 @@
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#ifndef SHADOW_INCLUDE_LIB_ALLOC_REALLOCF_H_
#define SHADOW_INCLUDE_LIB_ALLOC_REALLOCF_H_
#include <config.h>
#include <stddef.h>
#include <stdlib.h>
#include "attr.h"
#define REALLOCF(p, n, type) \
( \
_Generic(p, type *: (type *) reallocarrayf(p, (n) ?: 1, sizeof(type)))\
)
ATTR_ALLOC_SIZE(2, 3)
ATTR_MALLOC(free)
inline void *reallocarrayf(void *p, size_t nmemb, size_t size);
inline void *
reallocarrayf(void *p, size_t nmemb, size_t size)
{
void *q;
q = reallocarray(p, nmemb ?: 1, size ?: 1);
if (q == NULL)
free(p);
return q;
}
#endif // include guard
+36
View File
@@ -0,0 +1,36 @@
// SPDX-FileCopyrightText: 1990-1994, Julianne Frances Haugh
// SPDX-FileCopyrightText: 1996-1998, Marek Michałkiewicz
// SPDX-FileCopyrightText: 2003-2006, Tomasz Kłoczko
// SPDX-FileCopyrightText: 2008 , Nicolas François
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#include <config.h>
#include "alloc/x/xcalloc.h"
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include "defines.h"
#include "shadowlog.h"
void *
xcalloc(size_t nmemb, size_t size)
{
void *p;
p = calloc(nmemb, size);
if (p == NULL)
goto x;
return p;
x:
fprintf(log_get_logfd(), _("%s: %s\n"),
log_get_progname(), strerror(errno));
exit(13);
}
+28
View File
@@ -0,0 +1,28 @@
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#ifndef SHADOW_INCLUDE_LIB_ALLOC_X_XCALLOC_H_
#define SHADOW_INCLUDE_LIB_ALLOC_X_XCALLOC_H_
#include <config.h>
#include <stddef.h>
#include <stdlib.h>
#include "attr.h"
#define XCALLOC(n, type) \
( \
(type *) xcalloc(n, sizeof(type)) \
)
ATTR_ALLOC_SIZE(1, 2)
ATTR_MALLOC(free)
void *xcalloc(size_t nmemb, size_t size);
#endif // include guard
+16
View File
@@ -0,0 +1,16 @@
// SPDX-FileCopyrightText: 1990-1994, Julianne Frances Haugh
// SPDX-FileCopyrightText: 1996-1998, Marek Michałkiewicz
// SPDX-FileCopyrightText: 2003-2006, Tomasz Kłoczko
// SPDX-FileCopyrightText: 2008 , Nicolas François
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#include <config.h>
#include "alloc/x/xmalloc.h"
#include <stddef.h>
extern inline void *xmallocarray(size_t nmemb, size_t size);
+35
View File
@@ -0,0 +1,35 @@
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#ifndef SHADOW_INCLUDE_LIB_ALLOC_X_XMALLOC_H_
#define SHADOW_INCLUDE_LIB_ALLOC_X_XMALLOC_H_
#include <config.h>
#include <stddef.h>
#include "alloc/x/xrealloc.h"
#include "attr.h"
#define XMALLOC(n, type) \
( \
(type *) xmallocarray(n, sizeof(type)) \
)
ATTR_ALLOC_SIZE(1, 2)
ATTR_MALLOC(free)
inline void *xmallocarray(size_t nmemb, size_t size);
inline void *
xmallocarray(size_t nmemb, size_t size)
{
return xreallocarray(NULL, nmemb, size);
}
#endif // include guard
+35
View File
@@ -0,0 +1,35 @@
// SPDX-FileCopyrightText: 1990-1994, Julianne Frances Haugh
// SPDX-FileCopyrightText: 1996-1998, Marek Michałkiewicz
// SPDX-FileCopyrightText: 2003-2006, Tomasz Kłoczko
// SPDX-FileCopyrightText: 2008 , Nicolas François
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#include <config.h>
#include "alloc/x/xrealloc.h"
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include "alloc/reallocf.h"
#include "defines.h"
#include "shadowlog.h"
void *
xreallocarray(void *p, size_t nmemb, size_t size)
{
p = reallocarrayf(p, nmemb, size);
if (p == NULL)
goto x;
return p;
x:
fprintf(log_get_logfd(), _("%s: %s\n"),
log_get_progname(), strerror(errno));
exit(13);
}
+31
View File
@@ -0,0 +1,31 @@
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#ifndef SHADOW_INCLUDE_LIB_MALLOC_H_
#define SHADOW_INCLUDE_LIB_MALLOC_H_
#include <config.h>
#include <assert.h>
#include <errno.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include "attr.h"
#define XREALLOC(ptr, n, type) \
( \
_Generic(ptr, type *: (type *) xreallocarray(ptr, n, sizeof(type))) \
)
ATTR_ALLOC_SIZE(2, 3)
ATTR_MALLOC(free)
void *xreallocarray(void *p, size_t nmemb, size_t size);
#endif // include guard
-46
View File
@@ -1,46 +0,0 @@
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#include <config.h>
#include "atoi/a2i.h"
extern inline int a2sh_c(short *restrict n, const char *s,
const char **restrict endp, int base, short min, short max);
extern inline int a2si_c(int *restrict n, const char *s,
const char **restrict endp, int base, int min, int max);
extern inline int a2sl_c(long *restrict n, const char *s,
const char **restrict endp, int base, long min, long max);
extern inline int a2sll_c(long long *restrict n, const char *s,
const char **restrict endp, int base, long long min, long long max);
extern inline int a2uh_c(unsigned short *restrict n, const char *s,
const char **restrict endp, int base, unsigned short min,
unsigned short max);
extern inline int a2ui_c(unsigned int *restrict n, const char *s,
const char **restrict endp, int base, unsigned int min, unsigned int max);
extern inline int a2ul_c(unsigned long *restrict n, const char *s,
const char **restrict endp, int base, unsigned long min, unsigned long max);
extern inline int a2ull_c(unsigned long long *restrict n, const char *s,
const char **restrict endp, int base, unsigned long long min,
unsigned long long max);
extern inline int a2sh_nc(short *restrict n, char *s,
char **restrict endp, int base, short min, short max);
extern inline int a2si_nc(int *restrict n, char *s,
char **restrict endp, int base, int min, int max);
extern inline int a2sl_nc(long *restrict n, char *s,
char **restrict endp, int base, long min, long max);
extern inline int a2sll_nc(long long *restrict n, char *s,
char **restrict endp, int base, long long min, long long max);
extern inline int a2uh_nc(unsigned short *restrict n, char *s,
char **restrict endp, int base, unsigned short min, unsigned short max);
extern inline int a2ui_nc(unsigned int *restrict n, char *s,
char **restrict endp, int base, unsigned int min, unsigned int max);
extern inline int a2ul_nc(unsigned long *restrict n, char *s,
char **restrict endp, int base, unsigned long min, unsigned long max);
extern inline int a2ull_nc(unsigned long long *restrict n, char *s,
char **restrict endp, int base, unsigned long long min,
unsigned long long max);
-386
View File
@@ -1,386 +0,0 @@
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#ifndef SHADOW_INCLUDE_LIB_ATOI_A2I_H_
#define SHADOW_INCLUDE_LIB_ATOI_A2I_H_
#include <config.h>
#include <errno.h>
#include "atoi/strtoi.h"
#include "atoi/strtou_noneg.h"
#include "attr.h"
/*
* See the manual of these macros in liba2i's documentation:
* <http://www.alejandro-colomar.es/share/dist/liba2i/git/HEAD/liba2i-HEAD.pdf>
*/
#define a2i(TYPE, n, s, ...) \
( \
_Generic((void (*)(TYPE, typeof(s))) 0, \
void (*)(short, const char *): a2sh_c, \
void (*)(short, const void *): a2sh_c, \
void (*)(short, char *): a2sh_nc, \
void (*)(short, void *): a2sh_nc, \
void (*)(int, const char *): a2si_c, \
void (*)(int, const void *): a2si_c, \
void (*)(int, char *): a2si_nc, \
void (*)(int, void *): a2si_nc, \
void (*)(long, const char *): a2sl_c, \
void (*)(long, const void *): a2sl_c, \
void (*)(long, char *): a2sl_nc, \
void (*)(long, void *): a2sl_nc, \
void (*)(long long, const char *): a2sll_c, \
void (*)(long long, const void *): a2sll_c, \
void (*)(long long, char *): a2sll_nc, \
void (*)(long long, void *): a2sll_nc, \
void (*)(unsigned short, const char *): a2uh_c, \
void (*)(unsigned short, const void *): a2uh_c, \
void (*)(unsigned short, char *): a2uh_nc, \
void (*)(unsigned short, void *): a2uh_nc, \
void (*)(unsigned int, const char *): a2ui_c, \
void (*)(unsigned int, const void *): a2ui_c, \
void (*)(unsigned int, char *): a2ui_nc, \
void (*)(unsigned int, void *): a2ui_nc, \
void (*)(unsigned long, const char *): a2ul_c, \
void (*)(unsigned long, const void *): a2ul_c, \
void (*)(unsigned long, char *): a2ul_nc, \
void (*)(unsigned long, void *): a2ul_nc, \
void (*)(unsigned long long, const char *): a2ull_c, \
void (*)(unsigned long long, const void *): a2ull_c, \
void (*)(unsigned long long, char *): a2ull_nc, \
void (*)(unsigned long long, void *): a2ull_nc \
)(n, s, __VA_ARGS__) \
)
#define a2sh(n, s, ...) \
( \
_Generic(s, \
const char *: a2sh_c, \
const void *: a2sh_c, \
char *: a2sh_nc, \
void *: a2sh_nc \
)(n, s, __VA_ARGS__) \
)
#define a2si(n, s, ...) \
( \
_Generic(s, \
const char *: a2si_c, \
const void *: a2si_c, \
char *: a2si_nc, \
void *: a2si_nc \
)(n, s, __VA_ARGS__) \
)
#define a2sl(n, s, ...) \
( \
_Generic(s, \
const char *: a2sl_c, \
const void *: a2sl_c, \
char *: a2sl_nc, \
void *: a2sl_nc \
)(n, s, __VA_ARGS__) \
)
#define a2sll(n, s, ...) \
( \
_Generic(s, \
const char *: a2sll_c, \
const void *: a2sll_c, \
char *: a2sll_nc, \
void *: a2sll_nc \
)(n, s, __VA_ARGS__) \
)
#define a2uh(n, s, ...) \
( \
_Generic(s, \
const char *: a2uh_c, \
const void *: a2uh_c, \
char *: a2uh_nc, \
void *: a2uh_nc \
)(n, s, __VA_ARGS__) \
)
#define a2ui(n, s, ...) \
( \
_Generic(s, \
const char *: a2ui_c, \
const void *: a2ui_c, \
char *: a2ui_nc, \
void *: a2ui_nc \
)(n, s, __VA_ARGS__) \
)
#define a2ul(n, s, ...) \
( \
_Generic(s, \
const char *: a2ul_c, \
const void *: a2ul_c, \
char *: a2ul_nc, \
void *: a2ul_nc \
)(n, s, __VA_ARGS__) \
)
#define a2ull(n, s, ...) \
( \
_Generic(s, \
const char *: a2ull_c, \
const void *: a2ull_c, \
char *: a2ull_nc, \
void *: a2ull_nc \
)(n, s, __VA_ARGS__) \
)
ATTR_STRING(2) ATTR_ACCESS(write_only, 1) ATTR_ACCESS(write_only, 3)
inline int a2sh_c(short *restrict n, const char *s,
const char **restrict endp, int base, short min, short max);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1) ATTR_ACCESS(write_only, 3)
inline int a2si_c(int *restrict n, const char *s,
const char **restrict endp, int base, int min, int max);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1) ATTR_ACCESS(write_only, 3)
inline int a2sl_c(long *restrict n, const char *s,
const char **restrict endp, int base, long min, long max);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1) ATTR_ACCESS(write_only, 3)
inline int a2sll_c(long long *restrict n, const char *s,
const char **restrict endp, int base, long long min, long long max);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1) ATTR_ACCESS(write_only, 3)
inline int a2uh_c(unsigned short *restrict n, const char *s,
const char **restrict endp, int base, unsigned short min,
unsigned short max);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1) ATTR_ACCESS(write_only, 3)
inline int a2ui_c(unsigned int *restrict n, const char *s,
const char **restrict endp, int base, unsigned int min, unsigned int max);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1) ATTR_ACCESS(write_only, 3)
inline int a2ul_c(unsigned long *restrict n, const char *s,
const char **restrict endp, int base, unsigned long min, unsigned long max);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1) ATTR_ACCESS(write_only, 3)
inline int a2ull_c(unsigned long long *restrict n, const char *s,
const char **restrict endp, int base, unsigned long long min,
unsigned long long max);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1) ATTR_ACCESS(write_only, 3)
inline int a2sh_nc(short *restrict n, char *s,
char **restrict endp, int base, short min, short max);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1) ATTR_ACCESS(write_only, 3)
inline int a2si_nc(int *restrict n, char *s,
char **restrict endp, int base, int min, int max);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1) ATTR_ACCESS(write_only, 3)
inline int a2sl_nc(long *restrict n, char *s,
char **restrict endp, int base, long min, long max);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1) ATTR_ACCESS(write_only, 3)
inline int a2sll_nc(long long *restrict n, char *s,
char **restrict endp, int base, long long min, long long max);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1) ATTR_ACCESS(write_only, 3)
inline int a2uh_nc(unsigned short *restrict n, char *s,
char **restrict endp, int base, unsigned short min, unsigned short max);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1) ATTR_ACCESS(write_only, 3)
inline int a2ui_nc(unsigned int *restrict n, char *s,
char **restrict endp, int base, unsigned int min, unsigned int max);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1) ATTR_ACCESS(write_only, 3)
inline int a2ul_nc(unsigned long *restrict n, char *s,
char **restrict endp, int base, unsigned long min, unsigned long max);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1) ATTR_ACCESS(write_only, 3)
inline int a2ull_nc(unsigned long long *restrict n, char *s,
char **restrict endp, int base, unsigned long long min,
unsigned long long max);
inline int
a2sh_c(short *restrict n, const char *s,
const char **restrict endp, int base, short min, short max)
{
return a2sh(n, (char *) s, (char **) endp, base, min, max);
}
inline int
a2si_c(int *restrict n, const char *s,
const char **restrict endp, int base, int min, int max)
{
return a2si(n, (char *) s, (char **) endp, base, min, max);
}
inline int
a2sl_c(long *restrict n, const char *s,
const char **restrict endp, int base, long min, long max)
{
return a2sl(n, (char *) s, (char **) endp, base, min, max);
}
inline int
a2sll_c(long long *restrict n, const char *s,
const char **restrict endp, int base, long long min, long long max)
{
return a2sll(n, (char *) s, (char **) endp, base, min, max);
}
inline int
a2uh_c(unsigned short *restrict n, const char *s,
const char **restrict endp, int base, unsigned short min,
unsigned short max)
{
return a2uh(n, (char *) s, (char **) endp, base, min, max);
}
inline int
a2ui_c(unsigned int *restrict n, const char *s,
const char **restrict endp, int base, unsigned int min, unsigned int max)
{
return a2ui(n, (char *) s, (char **) endp, base, min, max);
}
inline int
a2ul_c(unsigned long *restrict n, const char *s,
const char **restrict endp, int base, unsigned long min, unsigned long max)
{
return a2ul(n, (char *) s, (char **) endp, base, min, max);
}
inline int
a2ull_c(unsigned long long *restrict n, const char *s,
const char **restrict endp, int base, unsigned long long min,
unsigned long long max)
{
return a2ull(n, (char *) s, (char **) endp, base, min, max);
}
inline int
a2sh_nc(short *restrict n, char *s,
char **restrict endp, int base, short min, short max)
{
int status;
*n = strtoi_(s, endp, base, min, max, &status);
if (status != 0) {
errno = status;
return -1;
}
return 0;
}
inline int
a2si_nc(int *restrict n, char *s,
char **restrict endp, int base, int min, int max)
{
int status;
*n = strtoi_(s, endp, base, min, max, &status);
if (status != 0) {
errno = status;
return -1;
}
return 0;
}
inline int
a2sl_nc(long *restrict n, char *s,
char **restrict endp, int base, long min, long max)
{
int status;
*n = strtoi_(s, endp, base, min, max, &status);
if (status != 0) {
errno = status;
return -1;
}
return 0;
}
inline int
a2sll_nc(long long *restrict n, char *s,
char **restrict endp, int base, long long min, long long max)
{
int status;
*n = strtoi_(s, endp, base, min, max, &status);
if (status != 0) {
errno = status;
return -1;
}
return 0;
}
inline int
a2uh_nc(unsigned short *restrict n, char *s,
char **restrict endp, int base, unsigned short min,
unsigned short max)
{
int status;
*n = strtou_noneg(s, endp, base, min, max, &status);
if (status != 0) {
errno = status;
return -1;
}
return 0;
}
inline int
a2ui_nc(unsigned int *restrict n, char *s,
char **restrict endp, int base, unsigned int min, unsigned int max)
{
int status;
*n = strtou_noneg(s, endp, base, min, max, &status);
if (status != 0) {
errno = status;
return -1;
}
return 0;
}
inline int
a2ul_nc(unsigned long *restrict n, char *s,
char **restrict endp, int base, unsigned long min, unsigned long max)
{
int status;
*n = strtou_noneg(s, endp, base, min, max, &status);
if (status != 0) {
errno = status;
return -1;
}
return 0;
}
inline int
a2ull_nc(unsigned long long *restrict n, char *s,
char **restrict endp, int base, unsigned long long min,
unsigned long long max)
{
int status;
*n = strtou_noneg(s, endp, base, min, max, &status);
if (status != 0) {
errno = status;
return -1;
}
return 0;
}
#endif // include guard
+7
View File
@@ -0,0 +1,7 @@
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#include <config.h>
#include "atoi/a2i/a2i.h"
+62
View File
@@ -0,0 +1,62 @@
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#ifndef SHADOW_INCLUDE_LIB_ATOI_A2I_A2I_H_
#define SHADOW_INCLUDE_LIB_ATOI_A2I_A2I_H_
#include <config.h>
#include "atoi/a2i/a2s_c.h"
#include "atoi/a2i/a2s_nc.h"
#include "atoi/a2i/a2u_c.h"
#include "atoi/a2i/a2u_nc.h"
/*
* See the manual of these macros in liba2i's documentation:
* <http://www.alejandro-colomar.es/share/dist/liba2i/git/HEAD/liba2i-HEAD.pdf>
*/
#define a2i(TYPE, n, s, ...) \
( \
_Generic((void (*)(TYPE, typeof(s))) 0, \
void (*)(short, const char *): a2sh_c, \
void (*)(short, const void *): a2sh_c, \
void (*)(short, char *): a2sh_nc, \
void (*)(short, void *): a2sh_nc, \
void (*)(int, const char *): a2si_c, \
void (*)(int, const void *): a2si_c, \
void (*)(int, char *): a2si_nc, \
void (*)(int, void *): a2si_nc, \
void (*)(long, const char *): a2sl_c, \
void (*)(long, const void *): a2sl_c, \
void (*)(long, char *): a2sl_nc, \
void (*)(long, void *): a2sl_nc, \
void (*)(long long, const char *): a2sll_c, \
void (*)(long long, const void *): a2sll_c, \
void (*)(long long, char *): a2sll_nc, \
void (*)(long long, void *): a2sll_nc, \
void (*)(unsigned short, const char *): a2uh_c, \
void (*)(unsigned short, const void *): a2uh_c, \
void (*)(unsigned short, char *): a2uh_nc, \
void (*)(unsigned short, void *): a2uh_nc, \
void (*)(unsigned int, const char *): a2ui_c, \
void (*)(unsigned int, const void *): a2ui_c, \
void (*)(unsigned int, char *): a2ui_nc, \
void (*)(unsigned int, void *): a2ui_nc, \
void (*)(unsigned long, const char *): a2ul_c, \
void (*)(unsigned long, const void *): a2ul_c, \
void (*)(unsigned long, char *): a2ul_nc, \
void (*)(unsigned long, void *): a2ul_nc, \
void (*)(unsigned long long, const char *): a2ull_c, \
void (*)(unsigned long long, const void *): a2ull_c, \
void (*)(unsigned long long, char *): a2ull_nc, \
void (*)(unsigned long long, void *): a2ull_nc \
)(n, s, __VA_ARGS__) \
)
#endif // include guard
+7
View File
@@ -0,0 +1,7 @@
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#include <config.h>
#include "atoi/a2i/a2s.h"
+56
View File
@@ -0,0 +1,56 @@
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#ifndef SHADOW_INCLUDE_LIB_ATOI_A2I_A2S_H_
#define SHADOW_INCLUDE_LIB_ATOI_A2I_A2S_H_
#include <config.h>
#include "atoi/a2i/a2s_c.h"
#include "atoi/a2i/a2s_nc.h"
#define a2sh(n, s, ...) \
( \
_Generic(s, \
const char *: a2sh_c, \
const void *: a2sh_c, \
char *: a2sh_nc, \
void *: a2sh_nc \
)(n, s, __VA_ARGS__) \
)
#define a2si(n, s, ...) \
( \
_Generic(s, \
const char *: a2si_c, \
const void *: a2si_c, \
char *: a2si_nc, \
void *: a2si_nc \
)(n, s, __VA_ARGS__) \
)
#define a2sl(n, s, ...) \
( \
_Generic(s, \
const char *: a2sl_c, \
const void *: a2sl_c, \
char *: a2sl_nc, \
void *: a2sl_nc \
)(n, s, __VA_ARGS__) \
)
#define a2sll(n, s, ...) \
( \
_Generic(s, \
const char *: a2sll_c, \
const void *: a2sll_c, \
char *: a2sll_nc, \
void *: a2sll_nc \
)(n, s, __VA_ARGS__) \
)
#endif // include guard
+17
View File
@@ -0,0 +1,17 @@
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#include <config.h>
#include "atoi/a2i/a2s_c.h"
extern inline int a2sh_c(short *restrict n, const char *s,
const char **restrict endp, int base, short min, short max);
extern inline int a2si_c(int *restrict n, const char *s,
const char **restrict endp, int base, int min, int max);
extern inline int a2sl_c(long *restrict n, const char *s,
const char **restrict endp, int base, long min, long max);
extern inline int a2sll_c(long long *restrict n, const char *s,
const char **restrict endp, int base, long long min, long long max);
+64
View File
@@ -0,0 +1,64 @@
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#ifndef SHADOW_INCLUDE_LIB_ATOI_A2I_A2S_C_H_
#define SHADOW_INCLUDE_LIB_ATOI_A2I_A2S_C_H_
#include <config.h>
#include <errno.h>
#include <inttypes.h>
#include "atoi/a2i/a2s_nc.h"
#include "attr.h"
ATTR_STRING(2) ATTR_ACCESS(write_only, 1) ATTR_ACCESS(write_only, 3)
inline int a2sh_c(short *restrict n, const char *s,
const char **restrict endp, int base, short min, short max);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1) ATTR_ACCESS(write_only, 3)
inline int a2si_c(int *restrict n, const char *s,
const char **restrict endp, int base, int min, int max);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1) ATTR_ACCESS(write_only, 3)
inline int a2sl_c(long *restrict n, const char *s,
const char **restrict endp, int base, long min, long max);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1) ATTR_ACCESS(write_only, 3)
inline int a2sll_c(long long *restrict n, const char *s,
const char **restrict endp, int base, long long min, long long max);
inline int
a2sh_c(short *restrict n, const char *s,
const char **restrict endp, int base, short min, short max)
{
return a2sh_nc(n, (char *) s, (char **) endp, base, min, max);
}
inline int
a2si_c(int *restrict n, const char *s,
const char **restrict endp, int base, int min, int max)
{
return a2si_nc(n, (char *) s, (char **) endp, base, min, max);
}
inline int
a2sl_c(long *restrict n, const char *s,
const char **restrict endp, int base, long min, long max)
{
return a2sl_nc(n, (char *) s, (char **) endp, base, min, max);
}
inline int
a2sll_c(long long *restrict n, const char *s,
const char **restrict endp, int base, long long min, long long max)
{
return a2sll_nc(n, (char *) s, (char **) endp, base, min, max);
}
#endif // include guard
+17
View File
@@ -0,0 +1,17 @@
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#include <config.h>
#include "atoi/a2i/a2s_nc.h"
extern inline int a2sh_nc(short *restrict n, char *s,
char **restrict endp, int base, short min, short max);
extern inline int a2si_nc(int *restrict n, char *s,
char **restrict endp, int base, int min, int max);
extern inline int a2sl_nc(long *restrict n, char *s,
char **restrict endp, int base, long min, long max);
extern inline int a2sll_nc(long long *restrict n, char *s,
char **restrict endp, int base, long long min, long long max);
+91
View File
@@ -0,0 +1,91 @@
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#ifndef SHADOW_INCLUDE_LIB_ATOI_A2I_A2S_NC_H_
#define SHADOW_INCLUDE_LIB_ATOI_A2I_A2S_NC_H_
#include <config.h>
#include <errno.h>
#include "atoi/strtoi/strtoi.h"
#include "attr.h"
ATTR_STRING(2) ATTR_ACCESS(write_only, 1) ATTR_ACCESS(write_only, 3)
inline int a2sh_nc(short *restrict n, char *s,
char **restrict endp, int base, short min, short max);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1) ATTR_ACCESS(write_only, 3)
inline int a2si_nc(int *restrict n, char *s,
char **restrict endp, int base, int min, int max);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1) ATTR_ACCESS(write_only, 3)
inline int a2sl_nc(long *restrict n, char *s,
char **restrict endp, int base, long min, long max);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1) ATTR_ACCESS(write_only, 3)
inline int a2sll_nc(long long *restrict n, char *s,
char **restrict endp, int base, long long min, long long max);
inline int
a2sh_nc(short *restrict n, char *s,
char **restrict endp, int base, short min, short max)
{
int status;
*n = strtoi_(s, endp, base, min, max, &status);
if (status != 0) {
errno = status;
return -1;
}
return 0;
}
inline int
a2si_nc(int *restrict n, char *s,
char **restrict endp, int base, int min, int max)
{
int status;
*n = strtoi_(s, endp, base, min, max, &status);
if (status != 0) {
errno = status;
return -1;
}
return 0;
}
inline int
a2sl_nc(long *restrict n, char *s,
char **restrict endp, int base, long min, long max)
{
int status;
*n = strtoi_(s, endp, base, min, max, &status);
if (status != 0) {
errno = status;
return -1;
}
return 0;
}
inline int
a2sll_nc(long long *restrict n, char *s,
char **restrict endp, int base, long long min, long long max)
{
int status;
*n = strtoi_(s, endp, base, min, max, &status);
if (status != 0) {
errno = status;
return -1;
}
return 0;
}
#endif // include guard
+7
View File
@@ -0,0 +1,7 @@
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#include <config.h>
#include "atoi/a2i/a2u.h"
+56
View File
@@ -0,0 +1,56 @@
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#ifndef SHADOW_INCLUDE_LIB_ATOI_A2I_A2U_H_
#define SHADOW_INCLUDE_LIB_ATOI_A2I_A2U_H_
#include <config.h>
#include "atoi/a2i/a2u_c.h"
#include "atoi/a2i/a2u_nc.h"
#define a2uh(n, s, ...) \
( \
_Generic(s, \
const char *: a2uh_c, \
const void *: a2uh_c, \
char *: a2uh_nc, \
void *: a2uh_nc \
)(n, s, __VA_ARGS__) \
)
#define a2ui(n, s, ...) \
( \
_Generic(s, \
const char *: a2ui_c, \
const void *: a2ui_c, \
char *: a2ui_nc, \
void *: a2ui_nc \
)(n, s, __VA_ARGS__) \
)
#define a2ul(n, s, ...) \
( \
_Generic(s, \
const char *: a2ul_c, \
const void *: a2ul_c, \
char *: a2ul_nc, \
void *: a2ul_nc \
)(n, s, __VA_ARGS__) \
)
#define a2ull(n, s, ...) \
( \
_Generic(s, \
const char *: a2ull_c, \
const void *: a2ull_c, \
char *: a2ull_nc, \
void *: a2ull_nc \
)(n, s, __VA_ARGS__) \
)
#endif // include guard
+19
View File
@@ -0,0 +1,19 @@
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#include <config.h>
#include "atoi/a2i/a2u_c.h"
extern inline int a2uh_c(unsigned short *restrict n, const char *s,
const char **restrict endp, int base, unsigned short min,
unsigned short max);
extern inline int a2ui_c(unsigned int *restrict n, const char *s,
const char **restrict endp, int base, unsigned int min, unsigned int max);
extern inline int a2ul_c(unsigned long *restrict n, const char *s,
const char **restrict endp, int base, unsigned long min, unsigned long max);
extern inline int a2ull_c(unsigned long long *restrict n, const char *s,
const char **restrict endp, int base, unsigned long long min,
unsigned long long max);
+65
View File
@@ -0,0 +1,65 @@
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#ifndef SHADOW_INCLUDE_LIB_ATOI_A2I_A2U_C_H_
#define SHADOW_INCLUDE_LIB_ATOI_A2I_A2U_C_H_
#include <config.h>
#include "atoi/a2i/a2u_nc.h"
#include "attr.h"
ATTR_STRING(2) ATTR_ACCESS(write_only, 1) ATTR_ACCESS(write_only, 3)
inline int a2uh_c(unsigned short *restrict n, const char *s,
const char **restrict endp, int base, unsigned short min,
unsigned short max);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1) ATTR_ACCESS(write_only, 3)
inline int a2ui_c(unsigned int *restrict n, const char *s,
const char **restrict endp, int base, unsigned int min, unsigned int max);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1) ATTR_ACCESS(write_only, 3)
inline int a2ul_c(unsigned long *restrict n, const char *s,
const char **restrict endp, int base, unsigned long min, unsigned long max);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1) ATTR_ACCESS(write_only, 3)
inline int a2ull_c(unsigned long long *restrict n, const char *s,
const char **restrict endp, int base, unsigned long long min,
unsigned long long max);
inline int
a2uh_c(unsigned short *restrict n, const char *s,
const char **restrict endp, int base, unsigned short min,
unsigned short max)
{
return a2uh_nc(n, (char *) s, (char **) endp, base, min, max);
}
inline int
a2ui_c(unsigned int *restrict n, const char *s,
const char **restrict endp, int base, unsigned int min, unsigned int max)
{
return a2ui_nc(n, (char *) s, (char **) endp, base, min, max);
}
inline int
a2ul_c(unsigned long *restrict n, const char *s,
const char **restrict endp, int base, unsigned long min, unsigned long max)
{
return a2ul_nc(n, (char *) s, (char **) endp, base, min, max);
}
inline int
a2ull_c(unsigned long long *restrict n, const char *s,
const char **restrict endp, int base, unsigned long long min,
unsigned long long max)
{
return a2ull_nc(n, (char *) s, (char **) endp, base, min, max);
}
#endif // include guard
+18
View File
@@ -0,0 +1,18 @@
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#include <config.h>
#include "atoi/a2i/a2u_nc.h"
extern inline int a2uh_nc(unsigned short *restrict n, char *s,
char **restrict endp, int base, unsigned short min, unsigned short max);
extern inline int a2ui_nc(unsigned int *restrict n, char *s,
char **restrict endp, int base, unsigned int min, unsigned int max);
extern inline int a2ul_nc(unsigned long *restrict n, char *s,
char **restrict endp, int base, unsigned long min, unsigned long max);
extern inline int a2ull_nc(unsigned long long *restrict n, char *s,
char **restrict endp, int base, unsigned long long min,
unsigned long long max);
+94
View File
@@ -0,0 +1,94 @@
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#ifndef SHADOW_INCLUDE_LIB_ATOI_A2I_A2U_NC_H_
#define SHADOW_INCLUDE_LIB_ATOI_A2I_A2U_NC_H_
#include <config.h>
#include <errno.h>
#include "atoi/strtoi/strtou_noneg.h"
#include "attr.h"
ATTR_STRING(2) ATTR_ACCESS(write_only, 1) ATTR_ACCESS(write_only, 3)
inline int a2uh_nc(unsigned short *restrict n, char *s,
char **restrict endp, int base, unsigned short min, unsigned short max);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1) ATTR_ACCESS(write_only, 3)
inline int a2ui_nc(unsigned int *restrict n, char *s,
char **restrict endp, int base, unsigned int min, unsigned int max);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1) ATTR_ACCESS(write_only, 3)
inline int a2ul_nc(unsigned long *restrict n, char *s,
char **restrict endp, int base, unsigned long min, unsigned long max);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1) ATTR_ACCESS(write_only, 3)
inline int a2ull_nc(unsigned long long *restrict n, char *s,
char **restrict endp, int base, unsigned long long min,
unsigned long long max);
inline int
a2uh_nc(unsigned short *restrict n, char *s,
char **restrict endp, int base, unsigned short min,
unsigned short max)
{
int status;
*n = strtou_noneg(s, endp, base, min, max, &status);
if (status != 0) {
errno = status;
return -1;
}
return 0;
}
inline int
a2ui_nc(unsigned int *restrict n, char *s,
char **restrict endp, int base, unsigned int min, unsigned int max)
{
int status;
*n = strtou_noneg(s, endp, base, min, max, &status);
if (status != 0) {
errno = status;
return -1;
}
return 0;
}
inline int
a2ul_nc(unsigned long *restrict n, char *s,
char **restrict endp, int base, unsigned long min, unsigned long max)
{
int status;
*n = strtou_noneg(s, endp, base, min, max, &status);
if (status != 0) {
errno = status;
return -1;
}
return 0;
}
inline int
a2ull_nc(unsigned long long *restrict n, char *s,
char **restrict endp, int base, unsigned long long min,
unsigned long long max)
{
int status;
*n = strtou_noneg(s, endp, base, min, max, &status);
if (status != 0) {
errno = status;
return -1;
}
return 0;
}
#endif // include guard
+16
View File
@@ -0,0 +1,16 @@
// SPDX-FileCopyrightText: 2009, Nicolas François
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#include <config.h>
#include <sys/types.h>
#include "atoi/getnum.h"
extern inline int get_fd(const char *restrict fdstr, int *restrict fd);
extern inline int get_gid(const char *restrict gidstr, gid_t *restrict gid);
extern inline int get_pid(const char *restrict pidstr, pid_t *restrict pid);
extern inline int get_uid(const char *restrict uidstr, uid_t *restrict uid);
+60
View File
@@ -0,0 +1,60 @@
// SPDX-FileCopyrightText: 2009, Nicolas François
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#ifndef SHADOW_INCLUDE_LIB_ATOI_GETNUM_H_
#define SHADOW_INCLUDE_LIB_ATOI_GETNUM_H_
#include <config.h>
#include <limits.h>
#include <stddef.h>
#include <sys/types.h>
#include "atoi/a2i/a2i.h"
#include "atoi/a2i/a2s.h"
#include "attr.h"
#include "typetraits.h"
ATTR_STRING(1) ATTR_ACCESS(write_only, 2)
inline int get_fd(const char *restrict fdstr, int *restrict fd);
ATTR_STRING(1) ATTR_ACCESS(write_only, 2)
inline int get_gid(const char *restrict gidstr, gid_t *restrict gid);
ATTR_STRING(1) ATTR_ACCESS(write_only, 2)
inline int get_pid(const char *restrict pidstr, pid_t *restrict pid);
ATTR_STRING(1) ATTR_ACCESS(write_only, 2)
inline int get_uid(const char *restrict uidstr, uid_t *restrict uid);
inline int
get_fd(const char *restrict fdstr, int *restrict fd)
{
return a2si(fd, fdstr, NULL, 10, 0, INT_MAX);
}
inline int
get_gid(const char *restrict gidstr, gid_t *restrict gid)
{
return a2i(gid_t, gid, gidstr, NULL, 10, type_min(gid_t), type_max(gid_t));
}
inline int
get_pid(const char *restrict pidstr, pid_t *restrict pid)
{
return a2i(pid_t, pid, pidstr, NULL, 10, 1, type_max(pid_t));
}
inline int
get_uid(const char *restrict uidstr, uid_t *restrict uid)
{
return a2i(uid_t, uid, uidstr, NULL, 10, type_min(uid_t), type_max(uid_t));
}
#endif // include guard
-108
View File
@@ -1,108 +0,0 @@
// SPDX-FileCopyrightText: 2007-2009, Nicolas François
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#ifndef SHADOW_INCLUDE_LIB_ATOI_STR2I_H_
#define SHADOW_INCLUDE_LIB_ATOI_STR2I_H_
#include <config.h>
#include <limits.h>
#include <stddef.h>
#include "atoi/a2i.h"
#include "attr.h"
#define str2i(TYPE, ...) \
( \
_Generic((TYPE) 0, \
short: str2sh, \
int: str2si, \
long: str2sl, \
long long: str2sll, \
unsigned short: str2uh, \
unsigned int: str2ui, \
unsigned long: str2ul, \
unsigned long long: str2ull \
)(__VA_ARGS__) \
)
ATTR_STRING(2) ATTR_ACCESS(write_only, 1)
inline int str2sh(short *restrict n, const char *restrict s);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1)
inline int str2si(int *restrict n, const char *restrict s);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1)
inline int str2sl(long *restrict n, const char *restrict s);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1)
inline int str2sll(long long *restrict n, const char *restrict s);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1)
inline int str2uh(unsigned short *restrict n, const char *restrict s);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1)
inline int str2ui(unsigned int *restrict n, const char *restrict s);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1)
inline int str2ul(unsigned long *restrict n, const char *restrict s);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1)
inline int str2ull(unsigned long long *restrict n, const char *restrict s);
inline int
str2sh(short *restrict n, const char *restrict s)
{
return a2sh(n, s, NULL, 0, SHRT_MIN, SHRT_MAX);
}
inline int
str2si(int *restrict n, const char *restrict s)
{
return a2si(n, s, NULL, 0, INT_MIN, INT_MAX);
}
inline int
str2sl(long *restrict n, const char *restrict s)
{
return a2sl(n, s, NULL, 0, LONG_MIN, LONG_MAX);
}
inline int
str2sll(long long *restrict n, const char *restrict s)
{
return a2sll(n, s, NULL, 0, LLONG_MIN, LLONG_MAX);
}
inline int
str2uh(unsigned short *restrict n, const char *restrict s)
{
return a2uh(n, s, NULL, 0, 0, USHRT_MAX);
}
inline int
str2ui(unsigned int *restrict n, const char *restrict s)
{
return a2ui(n, s, NULL, 0, 0, UINT_MAX);
}
inline int
str2ul(unsigned long *restrict n, const char *restrict s)
{
return a2ul(n, s, NULL, 0, 0, ULONG_MAX);
}
inline int
str2ull(unsigned long long *restrict n, const char *restrict s)
{
return a2ull(n, s, NULL, 0, 0, ULLONG_MAX);
}
#endif // include guard
+8
View File
@@ -0,0 +1,8 @@
// SPDX-FileCopyrightText: 2007-2009, Nicolas François
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#include <config.h>
#include "atoi/str2i/str2i.h"
+31
View File
@@ -0,0 +1,31 @@
// SPDX-FileCopyrightText: 2007-2009, Nicolas François
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#ifndef SHADOW_INCLUDE_LIB_ATOI_STR2I_STR2I_H_
#define SHADOW_INCLUDE_LIB_ATOI_STR2I_STR2I_H_
#include <config.h>
#include "atoi/str2i/str2s.h"
#include "atoi/str2i/str2u.h"
#define str2i(TYPE, ...) \
( \
_Generic((TYPE) 0, \
short: str2sh, \
int: str2si, \
long: str2sl, \
long long: str2sll, \
unsigned short: str2uh, \
unsigned int: str2ui, \
unsigned long: str2ul, \
unsigned long long: str2ull \
)(__VA_ARGS__) \
)
#endif // include guard
+14
View File
@@ -0,0 +1,14 @@
// SPDX-FileCopyrightText: 2007-2009, Nicolas François
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#include <config.h>
#include "atoi/str2i/str2s.h"
extern inline int str2sh(short *restrict n, const char *restrict s);
extern inline int str2si(int *restrict n, const char *restrict s);
extern inline int str2sl(long *restrict n, const char *restrict s);
extern inline int str2sll(long long *restrict n, const char *restrict s);
+57
View File
@@ -0,0 +1,57 @@
// SPDX-FileCopyrightText: 2007-2009, Nicolas François
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#ifndef SHADOW_INCLUDE_LIB_ATOI_STR2I_STR2S_H_
#define SHADOW_INCLUDE_LIB_ATOI_STR2I_STR2S_H_
#include <config.h>
#include <limits.h>
#include <stddef.h>
#include "atoi/a2i/a2s.h"
#include "attr.h"
ATTR_STRING(2) ATTR_ACCESS(write_only, 1)
inline int str2sh(short *restrict n, const char *restrict s);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1)
inline int str2si(int *restrict n, const char *restrict s);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1)
inline int str2sl(long *restrict n, const char *restrict s);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1)
inline int str2sll(long long *restrict n, const char *restrict s);
inline int
str2sh(short *restrict n, const char *restrict s)
{
return a2sh(n, s, NULL, 0, SHRT_MIN, SHRT_MAX);
}
inline int
str2si(int *restrict n, const char *restrict s)
{
return a2si(n, s, NULL, 0, INT_MIN, INT_MAX);
}
inline int
str2sl(long *restrict n, const char *restrict s)
{
return a2sl(n, s, NULL, 0, LONG_MIN, LONG_MAX);
}
inline int
str2sll(long long *restrict n, const char *restrict s)
{
return a2sll(n, s, NULL, 0, LLONG_MIN, LLONG_MAX);
}
#endif // include guard
+1 -5
View File
@@ -5,13 +5,9 @@
#include <config.h> #include <config.h>
#include "atoi/str2i.h" #include "atoi/str2i/str2u.h"
extern inline int str2sh(short *restrict n, const char *restrict s);
extern inline int str2si(int *restrict n, const char *restrict s);
extern inline int str2sl(long *restrict n, const char *restrict s);
extern inline int str2sll(long long *restrict n, const char *restrict s);
extern inline int str2uh(unsigned short *restrict n, const char *restrict s); extern inline int str2uh(unsigned short *restrict n, const char *restrict s);
extern inline int str2ui(unsigned int *restrict n, const char *restrict s); extern inline int str2ui(unsigned int *restrict n, const char *restrict s);
extern inline int str2ul(unsigned long *restrict n, const char *restrict s); extern inline int str2ul(unsigned long *restrict n, const char *restrict s);
+57
View File
@@ -0,0 +1,57 @@
// SPDX-FileCopyrightText: 2007-2009, Nicolas François
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#ifndef SHADOW_INCLUDE_LIB_ATOI_STR2I_STR2U_H_
#define SHADOW_INCLUDE_LIB_ATOI_STR2I_STR2U_H_
#include <config.h>
#include <limits.h>
#include <stddef.h>
#include "atoi/a2i/a2u.h"
#include "attr.h"
ATTR_STRING(2) ATTR_ACCESS(write_only, 1)
inline int str2uh(unsigned short *restrict n, const char *restrict s);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1)
inline int str2ui(unsigned int *restrict n, const char *restrict s);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1)
inline int str2ul(unsigned long *restrict n, const char *restrict s);
ATTR_STRING(2) ATTR_ACCESS(write_only, 1)
inline int str2ull(unsigned long long *restrict n, const char *restrict s);
inline int
str2uh(unsigned short *restrict n, const char *restrict s)
{
return a2uh(n, s, NULL, 0, 0, USHRT_MAX);
}
inline int
str2ui(unsigned int *restrict n, const char *restrict s)
{
return a2ui(n, s, NULL, 0, 0, UINT_MAX);
}
inline int
str2ul(unsigned long *restrict n, const char *restrict s)
{
return a2ul(n, s, NULL, 0, 0, ULONG_MAX);
}
inline int
str2ull(unsigned long long *restrict n, const char *restrict s)
{
return a2ull(n, s, NULL, 0, 0, ULLONG_MAX);
}
#endif // include guard
-15
View File
@@ -1,15 +0,0 @@
// SPDX-FileCopyrightText: 2023, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#include <config.h>
#include "atoi/strtoi.h"
#include <stdint.h>
extern inline intmax_t strtoi_(const char *s, char **restrict endp, int base,
intmax_t min, intmax_t max, int *restrict status);
extern inline uintmax_t strtou_(const char *s, char **restrict endp, int base,
uintmax_t min, uintmax_t max, int *restrict status);
-96
View File
@@ -1,96 +0,0 @@
// SPDX-FileCopyrightText: 2023, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#ifndef SHADOW_INCLUDE_LIB_ATOI_STRTOI_H_
#define SHADOW_INCLUDE_LIB_ATOI_STRTOI_H_
#include <config.h>
#include <errno.h>
#include <inttypes.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/param.h>
#include "attr.h"
#define strtoNmax(TYPE, ...) \
( \
_Generic((TYPE) 0, \
intmax_t: strtoimax, \
uintmax_t: strtoumax \
)(__VA_ARGS__) \
)
#define strtoN(s, endp, base, min, max, status, TYPE) \
({ \
const char *s_ = s; \
char **endp_ = endp; \
int base_ = base; \
TYPE min_ = min; \
TYPE max_ = max; \
int *status_ = status; \
\
int e_, st_; \
char *end_; \
TYPE n_; \
\
if (endp_ == NULL) \
endp_ = &end_; \
if (status_ == NULL) \
status_ = &st_; \
\
if (base_ != 0 && (base_ < 0 || base_ > 36)) { \
*status_ = EINVAL; \
n_ = 0; \
\
} else { \
e_ = errno; \
errno = 0; \
n_ = strtoNmax(TYPE, s_, endp_, base_); \
\
if (*endp_ == s_) \
*status_ = ECANCELED; \
else if (errno == ERANGE || n_ < min_ || n_ > max_) \
*status_ = ERANGE; \
else if (**endp_ != '\0') \
*status_ = ENOTSUP; \
else \
*status_ = 0; \
\
errno = e_; \
} \
MAX(min_, MIN(max_, n_)); \
})
ATTR_STRING(1) ATTR_ACCESS(write_only, 2) ATTR_ACCESS(write_only, 6)
inline intmax_t strtoi_(const char *s, char **restrict endp, int base,
intmax_t min, intmax_t max, int *restrict status);
ATTR_STRING(1) ATTR_ACCESS(write_only, 2) ATTR_ACCESS(write_only, 6)
inline uintmax_t strtou_(const char *s, char **restrict endp, int base,
uintmax_t min, uintmax_t max, int *restrict status);
inline intmax_t
strtoi_(const char *s, char **restrict endp, int base,
intmax_t min, intmax_t max, int *restrict status)
{
return strtoN(s, endp, base, min, max, status, intmax_t);
}
inline uintmax_t
strtou_(const char *s, char **restrict endp, int base,
uintmax_t min, uintmax_t max, int *restrict status)
{
return strtoN(s, endp, base, min, max, status, uintmax_t);
}
#endif // include guard
+13
View File
@@ -0,0 +1,13 @@
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#include <config.h>
#include "atoi/strtoi/strtoi.h"
#include <stdint.h>
extern inline intmax_t strtoi_(const char *s, char **restrict endp, int base,
intmax_t min, intmax_t max, int *restrict status);
+64
View File
@@ -0,0 +1,64 @@
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#ifndef SHADOW_INCLUDE_LIB_ATOI_STRTOI_STRTOI_H_
#define SHADOW_INCLUDE_LIB_ATOI_STRTOI_STRTOI_H_
#include <config.h>
#include <errno.h>
#include <inttypes.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/param.h>
#include "attr.h"
ATTR_STRING(1) ATTR_ACCESS(write_only, 2) ATTR_ACCESS(write_only, 6)
inline intmax_t strtoi_(const char *s, char **restrict endp, int base,
intmax_t min, intmax_t max, int *restrict status);
inline intmax_t
strtoi_(const char *s, char **restrict endp, int base,
intmax_t min, intmax_t max, int *restrict status)
{
int e, st;
char *end;
intmax_t n;
if (endp == NULL)
endp = &end;
if (status == NULL)
status = &st;
if (base != 0 && (base < 2 || base > 36)) {
*status = EINVAL;
return MAX(min, MIN(max, 0));
}
e = errno;
errno = 0;
n = strtoimax(s, endp, base);
if (*endp == s)
*status = ECANCELED;
else if (errno == ERANGE || n < min || n > max)
*status = ERANGE;
else if (**endp != '\0')
*status = ENOTSUP;
else
*status = 0;
errno = e;
return MAX(min, MIN(max, n));
}
#endif // include guard
+13
View File
@@ -0,0 +1,13 @@
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#include <config.h>
#include "atoi/strtoi/strtou.h"
#include <stdint.h>
extern inline uintmax_t strtou_(const char *s, char **restrict endp, int base,
uintmax_t min, uintmax_t max, int *restrict status);
+64
View File
@@ -0,0 +1,64 @@
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#ifndef SHADOW_INCLUDE_LIB_ATOI_STRTOI_STRTOU_H_
#define SHADOW_INCLUDE_LIB_ATOI_STRTOI_STRTOU_H_
#include <config.h>
#include <errno.h>
#include <inttypes.h>
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
#include <sys/param.h>
#include "attr.h"
ATTR_STRING(1) ATTR_ACCESS(write_only, 2) ATTR_ACCESS(write_only, 6)
inline uintmax_t strtou_(const char *s, char **restrict endp, int base,
uintmax_t min, uintmax_t max, int *restrict status);
inline uintmax_t
strtou_(const char *s, char **restrict endp, int base,
uintmax_t min, uintmax_t max, int *restrict status)
{
int e, st;
char *end;
uintmax_t n;
if (endp == NULL)
endp = &end;
if (status == NULL)
status = &st;
if (base != 0 && (base < 2 || base > 36)) {
*status = EINVAL;
return MAX(min, 0);
}
e = errno;
errno = 0;
n = strtoumax(s, endp, base);
if (*endp == s)
*status = ECANCELED;
else if (errno == ERANGE || n < min || n > max)
*status = ERANGE;
else if (**endp != '\0')
*status = ENOTSUP;
else
*status = 0;
errno = e;
return MAX(min, MIN(max, n));
}
#endif // include guard
@@ -1,10 +1,10 @@
// SPDX-FileCopyrightText: 2023, Alejandro Colomar <alx@kernel.org> // SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause // SPDX-License-Identifier: BSD-3-Clause
#include <config.h> #include <config.h>
#include "atoi/strtou_noneg.h" #include "atoi/strtoi/strtou_noneg.h"
#include <stdint.h> #include <stdint.h>
@@ -1,9 +1,9 @@
// SPDX-FileCopyrightText: 2023, Alejandro Colomar <alx@kernel.org> // SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause // SPDX-License-Identifier: BSD-3-Clause
#ifndef SHADOW_INCLUDE_LIB_ATOI_STRTOU_NONEG_H_ #ifndef SHADOW_INCLUDE_LIB_ATOI_STRTOI_STRTOU_NONEG_H_
#define SHADOW_INCLUDE_LIB_ATOI_STRTOU_NONEG_H_ #define SHADOW_INCLUDE_LIB_ATOI_STRTOI_STRTOU_NONEG_H_
#include <config.h> #include <config.h>
@@ -12,7 +12,8 @@
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include "atoi/strtoi.h" #include "atoi/strtoi/strtoi.h"
#include "atoi/strtoi/strtou.h"
#include "attr.h" #include "attr.h"
+9 -7
View File
@@ -5,16 +5,18 @@
#include "config.h" #include "config.h"
#if defined(__GNUC__) #if (__GNUC__ >= 10)
# define MAYBE_UNUSED __attribute__((unused)) # define MAYBE_UNUSED [[gnu::unused]]
# define NORETURN __attribute__((__noreturn__)) # define NORETURN [[gnu::__noreturn__]]
# define format_attr(type, fmt, va) __attribute__((format(type, fmt, va))) # define format_attr(type, fmt, va) [[gnu::format(type, fmt, va)]]
# define ATTR_ACCESS(...) __attribute__((access(__VA_ARGS__))) # define ATTR_ACCESS(...) [[gnu::access(__VA_ARGS__)]]
# define ATTR_ALLOC_SIZE(...) [[gnu::alloc_size(__VA_ARGS__)]]
#else #else
# define MAYBE_UNUSED # define MAYBE_UNUSED
# define NORETURN # define NORETURN
# define format_attr(type, fmt, va) # define format_attr(type, fmt, va)
# define ATTR_ACCESS(...) # define ATTR_ACCESS(...)
# define ATTR_ALLOC_SIZE(...)
#endif #endif
#if (__GNUC__ >= 11) && !defined(__clang__) #if (__GNUC__ >= 11) && !defined(__clang__)
@@ -24,9 +26,9 @@
#endif #endif
#if (__GNUC__ >= 14) #if (__GNUC__ >= 14)
# define ATTR_STRING(...) [[gnu::null_terminated_string_arg(__VA_ARGS__)]] # define ATTR_STRING(i) [[gnu::null_terminated_string_arg(i)]]
#else #else
# define ATTR_STRING(...) # define ATTR_STRING(i)
#endif #endif
+34 -11
View File
@@ -2,7 +2,7 @@
// SPDX-FileCopyrightText: 1996-2000, Marek Michałkiewicz // SPDX-FileCopyrightText: 1996-2000, Marek Michałkiewicz
// SPDX-FileCopyrightText: 2001-2005, Tomasz Kłoczko // SPDX-FileCopyrightText: 2001-2005, Tomasz Kłoczko
// SPDX-FileCopyrightText: 2005-2008, Nicolas François // SPDX-FileCopyrightText: 2005-2008, Nicolas François
// SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org> // SPDX-FileCopyrightText: 2023-2025, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause // SPDX-License-Identifier: BSD-3-Clause
@@ -12,6 +12,9 @@
* return values: * return values:
* true - OK * true - OK
* false - bad name * false - bad name
* errors:
* EINVAL Invalid name characters or sequences
* EOVERFLOW Name longer than maximum size
*/ */
@@ -28,6 +31,12 @@
#include "defines.h" #include "defines.h"
#include "chkname.h" #include "chkname.h"
#include "string/strcmp/streq.h"
#ifndef LOGIN_NAME_MAX
# define LOGIN_NAME_MAX 256
#endif
int allow_bad_names = false; int allow_bad_names = false;
@@ -38,16 +47,16 @@ login_name_max_size(void)
{ {
long conf; long conf;
errno = 0;
conf = sysconf(_SC_LOGIN_NAME_MAX); conf = sysconf(_SC_LOGIN_NAME_MAX);
if (conf == -1 && errno != 0) if (conf == -1)
return LOGIN_NAME_MAX; return LOGIN_NAME_MAX;
return conf; return conf;
} }
static bool is_valid_name (const char *name) static bool
is_valid_name(const char *name)
{ {
if (allow_bad_names) { if (allow_bad_names) {
return true; return true;
@@ -71,13 +80,15 @@ static bool is_valid_name (const char *name)
(*name >= 'A' && *name <= 'Z') || (*name >= 'A' && *name <= 'Z') ||
(*name >= '0' && *name <= '9') || (*name >= '0' && *name <= '9') ||
*name == '_' || *name == '_' ||
*name == '.')) { *name == '.'))
{
errno = EINVAL;
return false; return false;
} }
numeric = isdigit(*name); numeric = isdigit(*name);
while ('\0' != *++name) { while (!streq(++name, "")) {
if (!((*name >= 'a' && *name <= 'z') || if (!((*name >= 'a' && *name <= 'z') ||
(*name >= 'A' && *name <= 'Z') || (*name >= 'A' && *name <= 'Z') ||
(*name >= '0' && *name <= '9') || (*name >= '0' && *name <= '9') ||
@@ -85,34 +96,46 @@ static bool is_valid_name (const char *name)
*name == '.' || *name == '.' ||
*name == '-' || *name == '-' ||
(*name == '$' && name[1] == '\0') (*name == '$' && name[1] == '\0')
)) { ))
{
errno = EINVAL;
return false; return false;
} }
numeric &= isdigit(*name); numeric &= isdigit(*name);
} }
return !numeric; if (numeric) {
errno = EINVAL;
return false;
}
return true;
} }
bool bool
is_valid_user_name(const char *name) is_valid_user_name(const char *name)
{ {
if (strlen(name) >= login_name_max_size()) if (strlen(name) >= login_name_max_size()) {
errno = EOVERFLOW;
return false; return false;
}
return is_valid_name(name); return is_valid_name(name);
} }
bool is_valid_group_name (const char *name) bool
is_valid_group_name(const char *name)
{ {
/* /*
* Arbitrary limit for group names. * Arbitrary limit for group names.
* HP-UX 10 limits to 16 characters * HP-UX 10 limits to 16 characters
*/ */
if ( (GROUP_NAME_MAX_LENGTH > 0) if ( (GROUP_NAME_MAX_LENGTH > 0)
&& (strlen (name) > GROUP_NAME_MAX_LENGTH)) { && (strlen (name) > GROUP_NAME_MAX_LENGTH))
{
errno = EOVERFLOW;
return false; return false;
} }
+7 -4
View File
@@ -13,12 +13,15 @@
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
#include "prototypes.h"
#include "defines.h"
#include <fcntl.h> #include <fcntl.h>
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include "defines.h"
#include "prototypes.h"
#include "string/strcmp/streq.h"
static int chown_tree_at (int at_fd, static int chown_tree_at (int at_fd,
const char *path, const char *path,
uid_t old_uid, uid_t old_uid,
@@ -56,8 +59,8 @@ static int chown_tree_at (int at_fd,
/* /*
* Skip the "." and ".." entries * Skip the "." and ".." entries
*/ */
if ( (strcmp (ent->d_name, ".") == 0) if ( streq(ent->d_name, ".")
|| (strcmp (ent->d_name, "..") == 0)) { || streq(ent->d_name, "..")) {
continue; continue;
} }
+1 -1
View File
@@ -44,7 +44,7 @@ void do_cleanups (void)
{ {
unsigned int i; unsigned int i;
/* Make sure there were no overflow */ /* Make sure there were no overflows */
assert (NULL == cleanup_functions[CLEANUP_FUNCTIONS-1]); assert (NULL == cleanup_functions[CLEANUP_FUNCTIONS-1]);
if (getpid () != cleanup_pid) { if (getpid () != cleanup_pid) {
+29 -32
View File
@@ -11,28 +11,33 @@
#ident "$Id$" #ident "$Id$"
#include "defines.h"
#include <assert.h> #include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <signal.h>
#include <stdio.h>
#include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <stdlib.h> #include <stdlib.h>
#include <limits.h>
#include <utime.h> #include <utime.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h>
#include <signal.h>
#include "alloc.h" #include "alloc/malloc.h"
#include "memzero.h" #include "alloc/reallocf.h"
#include "atoi/getnum.h"
#include "commonio.h"
#include "defines.h"
#include "nscd.h" #include "nscd.h"
#include "sssd.h"
#ifdef WITH_TCB #ifdef WITH_TCB
#include <tcb.h> #include <tcb.h>
#endif /* WITH_TCB */ #endif /* WITH_TCB */
#include "prototypes.h" #include "prototypes.h"
#include "commonio.h"
#include "shadowlog_internal.h" #include "shadowlog_internal.h"
#include "string/sprintf.h" #include "sssd.h"
#include "string/memset/memzero.h"
#include "string/sprintf/snprintf.h"
#include "string/strcmp/streq.h"
#include "string/strtok/stpsep.h"
/* local function prototypes */ /* local function prototypes */
@@ -194,7 +199,7 @@ static int do_lock_file (const char *file, const char *lock, bool log)
errno = EINVAL; errno = EINVAL;
return 0; return 0;
} }
buf[len] = '\0'; stpcpy(&buf[len], "");
if (get_pid(buf, &pid) == -1) { if (get_pid(buf, &pid) == -1) {
if (log) { if (log) {
(void) fprintf (shadow_logfd, (void) fprintf (shadow_logfd,
@@ -573,9 +578,7 @@ static void add_one_entry_nis (struct commonio_db *db,
int commonio_open (struct commonio_db *db, int mode) int commonio_open (struct commonio_db *db, int mode)
{ {
char *buf; char *buf;
char *cp;
char *line; char *line;
struct commonio_entry *p;
void *eptr = NULL; void *eptr = NULL;
int flags = mode; int flags = mode;
size_t buflen; size_t buflen;
@@ -636,21 +639,21 @@ int commonio_open (struct commonio_db *db, int mode)
buflen = BUFLEN; buflen = BUFLEN;
buf = MALLOC(buflen, char); buf = MALLOC(buflen, char);
if (NULL == buf) { if (NULL == buf)
goto cleanup_ENOMEM; goto cleanup_errno;
}
while (db->ops->fgets (buf, buflen, db->fp) == buf) { while (db->ops->fgets (buf, buflen, db->fp) == buf) {
struct commonio_entry *p;
while ( (strrchr (buf, '\n') == NULL) while ( (strrchr (buf, '\n') == NULL)
&& (feof (db->fp) == 0)) { && (feof (db->fp) == 0)) {
size_t len; size_t len;
buflen += BUFLEN; buflen += BUFLEN;
cp = REALLOC(buf, buflen, char); buf = REALLOCF(buf, buflen, char);
if (NULL == cp) { if (NULL == buf)
goto cleanup_buf; goto cleanup_errno;
}
buf = cp;
len = strlen (buf); len = strlen (buf);
if (db->ops->fgets (buf + len, if (db->ops->fgets (buf + len,
(int) (buflen - len), (int) (buflen - len),
@@ -658,10 +661,7 @@ int commonio_open (struct commonio_db *db, int mode)
goto cleanup_buf; goto cleanup_buf;
} }
} }
cp = strrchr (buf, '\n'); stpsep(buf, "\n");
if (NULL != cp) {
*cp = '\0';
}
line = strdup (buf); line = strdup (buf);
if (NULL == line) { if (NULL == line) {
@@ -713,7 +713,6 @@ int commonio_open (struct commonio_db *db, int mode)
free (line); free (line);
cleanup_buf: cleanup_buf:
free (buf); free (buf);
cleanup_ENOMEM:
errno = ENOMEM; errno = ENOMEM;
cleanup_errno: cleanup_errno:
saved_errno = errno; saved_errno = errno;
@@ -832,10 +831,8 @@ int commonio_sort_wrt (struct commonio_db *shadow,
if (NULL == spw_ptr->eptr) { if (NULL == spw_ptr->eptr) {
continue; continue;
} }
if (strcmp (name, shadow->ops->getname (spw_ptr->eptr)) if (streq(name, shadow->ops->getname(spw_ptr->eptr)))
== 0) {
break; break;
}
} }
if (NULL == spw_ptr) { if (NULL == spw_ptr) {
continue; continue;
@@ -1036,7 +1033,7 @@ static /*@dependent@*/ /*@null@*/struct commonio_entry *next_entry_by_name (
for (p = pos; NULL != p; p = p->next) { for (p = pos; NULL != p; p = p->next) {
ep = p->eptr; ep = p->eptr;
if ( (NULL != ep) if ( (NULL != ep)
&& (strcmp (db->ops->getname (ep), name) == 0)) { && streq(db->ops->getname(ep), name)) {
break; break;
} }
} }
@@ -1242,7 +1239,7 @@ int commonio_rewind (struct commonio_db *db)
if (!db->isopen) { if (!db->isopen) {
errno = EINVAL; errno = EINVAL;
return 0; return NULL;
} }
if (NULL == db->cursor) { if (NULL == db->cursor) {
db->cursor = db->head; db->cursor = db->head;
+15 -12
View File
@@ -9,20 +9,25 @@
*/ */
#include <config.h> #include <config.h>
#include "defines.h"
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include "defines.h"
#include "getdef.h" #include "getdef.h"
#include "prototypes.h" #include "prototypes.h"
#include "string/strtcpy.h" #include "string/strcmp/streq.h"
#include "string/strcpy/strtcpy.h"
#include "string/strtok/stpsep.h"
#ident "$Id$"
/* /*
* This is now rather generic function which decides if "tty" is listed * This is now rather generic function which decides if "tty" is listed
* under "cfgin" in config (directly or indirectly). Fallback to default if * under "cfgin" in config (directly or indirectly). Fallback to default if
* something is bad. * something is bad.
*/ */
static bool is_listed (const char *cfgin, const char *tty, bool def) static bool
is_listed(const char *cfgin, const char *tty, bool def)
{ {
FILE *fp; FILE *fp;
char buf[1024], *s; char buf[1024], *s;
@@ -45,14 +50,13 @@ static bool is_listed (const char *cfgin, const char *tty, bool def)
if (*cons != '/') { if (*cons != '/') {
char *pbuf; char *pbuf;
STRTCPY(buf, cons); STRTCPY(buf, cons);
pbuf = &buf[0]; pbuf = buf;
while ((s = strtok (pbuf, ":")) != NULL) { while (NULL != (s = strsep(&pbuf, ":"))) {
if (strcmp (s, tty) == 0) { if (streq(s, tty)) {
return true; return true;
} }
pbuf = NULL;
} }
return false; return false;
} }
@@ -72,9 +76,8 @@ static bool is_listed (const char *cfgin, const char *tty, bool def)
*/ */
while (fgets (buf, sizeof (buf), fp) != NULL) { while (fgets (buf, sizeof (buf), fp) != NULL) {
/* Remove optional trailing '\n'. */ stpsep(buf, "\n");
buf[strcspn (buf, "\n")] = '\0'; if (streq(buf, tty)) {
if (strcmp (buf, tty) == 0) {
(void) fclose (fp); (void) fclose (fp);
return true; return true;
} }
+9 -44
View File
@@ -17,9 +17,11 @@
#include <sys/time.h> #include <sys/time.h>
#include <fcntl.h> #include <fcntl.h>
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include "alloc.h" #include "alloc/x/xmalloc.h"
#include "attr.h" #include "attr.h"
#include "fs/readlink/areadlink.h"
#include "prototypes.h" #include "prototypes.h"
#include "defines.h" #include "defines.h"
#ifdef WITH_SELINUX #ifdef WITH_SELINUX
@@ -36,7 +38,8 @@
#include <attr/libattr.h> #include <attr/libattr.h>
#endif /* WITH_ATTR */ #endif /* WITH_ATTR */
#include "shadowlog.h" #include "shadowlog.h"
#include "string/sprintf.h" #include "string/sprintf/xasprintf.h"
#include "string/strcmp/streq.h"
static /*@null@*/const char *src_orig; static /*@null@*/const char *src_orig;
@@ -66,7 +69,6 @@ static int copy_dir (const struct path_info *src, const struct path_info *dst,
const struct stat *statp, const struct timespec mt[], const struct stat *statp, const struct timespec mt[],
uid_t old_uid, uid_t new_uid, uid_t old_uid, uid_t new_uid,
gid_t old_gid, gid_t new_gid); gid_t old_gid, gid_t new_gid);
static /*@null@*/char *readlink_malloc (const char *filename);
static int copy_symlink (const struct path_info *src, const struct path_info *dst, static int copy_symlink (const struct path_info *src, const struct path_info *dst,
MAYBE_UNUSED bool reset_selinux, MAYBE_UNUSED bool reset_selinux,
const struct stat *statp, const struct timespec mt[], const struct stat *statp, const struct timespec mt[],
@@ -313,8 +315,8 @@ static int copy_tree_impl (const struct path_info *src, const struct path_info *
/* /*
* Skip the "." and ".." entries * Skip the "." and ".." entries
*/ */
if (strcmp(ent->d_name, ".") == 0 || if (streq(ent->d_name, ".") ||
strcmp(ent->d_name, "..") == 0) streq(ent->d_name, ".."))
{ {
continue; continue;
} }
@@ -536,42 +538,6 @@ static int copy_dir (const struct path_info *src, const struct path_info *dst,
return err; return err;
} }
/*
* readlink_malloc - wrapper for readlink
*
* return NULL on error.
* The return string shall be freed by the caller.
*/
static /*@null@*/char *readlink_malloc (const char *filename)
{
size_t size = 1024;
while (true) {
ssize_t nchars;
char *buffer = MALLOC(size, char);
if (NULL == buffer) {
return NULL;
}
nchars = readlink (filename, buffer, size);
if (nchars < 0) {
free(buffer);
return NULL;
}
if ((size_t) nchars < size) { /* The buffer was large enough */
/* readlink does not nul-terminate */
buffer[nchars] = '\0';
return buffer;
}
/* Try again with a bigger buffer */
free (buffer);
size *= 2;
}
}
/* /*
* copy_symlink - copy a symlink * copy_symlink - copy a symlink
* *
@@ -602,10 +568,9 @@ static int copy_symlink (const struct path_info *src, const struct path_info *ds
* destination directory name. * destination directory name.
*/ */
oldlink = readlink_malloc (src->full_path); oldlink = areadlink(src->full_path);
if (NULL == oldlink) { if (NULL == oldlink)
return -1; return -1;
}
/* If src was a link to an entry of the src_orig directory itself, /* If src was a link to an entry of the src_orig directory itself,
* create a link to the corresponding entry in the dst_orig * create a link to the corresponding entry in the dst_orig
+12 -15
View File
@@ -1,21 +1,19 @@
/* // SPDX-FileCopyrightText: 2022-2024, Alejandro Colomar <alx@kernel.org>
* SPDX-FileCopyrightText: Alejandro Colomar <alx@kernel.org> // SPDX-License-Identifier: BSD-3-Clause
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <config.h> #include <config.h>
#ident "$Id$" #ident "$Id$"
#include <fcntl.h>
#include <limits.h> #include <limits.h>
#include <stdint.h> #include <stdint.h>
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#if HAVE_SYS_RANDOM_H #if HAVE_SYS_RANDOM_H
#include <sys/random.h> #include <sys/random.h>
#endif #endif
#include "bit.h" #include "bit.h"
#include "defines.h" #include "defines.h"
#include "prototypes.h" #include "prototypes.h"
@@ -34,7 +32,7 @@ static unsigned long csrand_uniform_slow(unsigned long n);
unsigned long unsigned long
csrand(void) csrand(void)
{ {
FILE *fp; int fd;
unsigned long r; unsigned long r;
#ifdef HAVE_GETENTROPY #ifdef HAVE_GETENTROPY
@@ -56,17 +54,16 @@ csrand(void)
#endif #endif
/* Use /dev/urandom as a last resort. */ /* Use /dev/urandom as a last resort. */
fp = fopen("/dev/urandom", "r"); fd = open("/dev/urandom", O_RDONLY);
if (NULL == fp) { if (fd == -1)
goto fail;
if (read(fd, &r, sizeof(r)) != sizeof(r)) {
close(fd);
goto fail; goto fail;
} }
if (fread(&r, sizeof(r), 1, fp) != 1) { close(fd);
fclose(fp);
goto fail;
}
fclose(fp);
return r; return r;
fail: fail:
+5 -2
View File
@@ -16,11 +16,14 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "alloc.h" #include "alloc/x/xmalloc.h"
#include "alloc/x/xrealloc.h"
#include "prototypes.h" #include "prototypes.h"
#include "defines.h" #include "defines.h"
#include "shadowlog.h" #include "shadowlog.h"
#include "string/sprintf.h" #include "string/sprintf/snprintf.h"
#include "string/sprintf/xasprintf.h"
#include "string/strdup/xstrdup.h"
/* /*
+4 -6
View File
@@ -18,10 +18,10 @@
#include "defines.h" #include "defines.h"
#include "faillog.h" #include "faillog.h"
#include "failure.h" #include "failure.h"
#include "memzero.h"
#include "prototypes.h" #include "prototypes.h"
#include "string/memset/memzero.h"
#include "string/strftime.h" #include "string/strftime.h"
#include "string/strtcpy.h" #include "string/strcpy/strtcpy.h"
#define YEAR (365L*DAY) #define YEAR (365L*DAY)
@@ -82,7 +82,7 @@ void failure (uid_t uid, const char *tty, struct faillog *fl)
} }
STRTCPY(fl->fail_line, tty); STRTCPY(fl->fail_line, tty);
(void) time (&fl->fail_time); fl->fail_time = time(NULL);
/* /*
* Seek back to the correct position in the file and write the * Seek back to the correct position in the file and write the
@@ -126,7 +126,7 @@ static bool too_many_failures (const struct faillog *fl)
return true; /* locked until reset manually */ return true; /* locked until reset manually */
} }
(void) time (&now); now = time(NULL);
if ((fl->fail_time + fl->fail_locktime) < now) { if ((fl->fail_time + fl->fail_locktime) < now) {
return false; /* enough time since last failure */ return false; /* enough time since last failure */
} }
@@ -242,14 +242,12 @@ void failprint (const struct faillog *fail)
struct tm *tp; struct tm *tp;
char lasttimeb[256]; char lasttimeb[256];
char *lasttime = lasttimeb; char *lasttime = lasttimeb;
time_t NOW;
if (0 == fail->fail_cnt) { if (0 == fail->fail_cnt) {
return; return;
} }
tp = localtime (&(fail->fail_time)); tp = localtime (&(fail->fail_time));
(void) time (&NOW);
/* /*
* Print all information we have. * Print all information we have.
+13 -18
View File
@@ -14,7 +14,13 @@
#include <ctype.h> #include <ctype.h>
#include <string.h> #include <string.h>
#include <stdio.h> #include <stdio.h>
#include "prototypes.h" #include "prototypes.h"
#include "string/strchr/stpspn.h"
#include "string/strchr/strrspn.h"
#include "string/strcmp/streq.h"
#include "string/strtok/stpsep.h"
/* /*
* valid_field - insure that a field contains all legal characters * valid_field - insure that a field contains all legal characters
@@ -42,7 +48,7 @@ int valid_field (const char *field, const char *illegal)
} }
/* Search if there are non-printable or control characters */ /* Search if there are non-printable or control characters */
for (cp = field; '\0' != *cp; cp++) { for (cp = field; !streq(cp, ""); cp++) {
unsigned char c = *cp; unsigned char c = *cp;
if (!isprint (c)) { if (!isprint (c)) {
err = 1; err = 1;
@@ -62,7 +68,8 @@ int valid_field (const char *field, const char *illegal)
* prompt the user with the name of the field being changed and the * prompt the user with the name of the field being changed and the
* current value. * current value.
*/ */
void change_field (char *buf, size_t maxsize, const char *prompt) void
change_field(char *buf, size_t maxsize, const char *prompt)
{ {
char newf[200]; char newf[200];
char *cp; char *cp;
@@ -77,29 +84,17 @@ void change_field (char *buf, size_t maxsize, const char *prompt)
return; return;
} }
cp = strchr (newf, '\n'); if (stpsep(newf, "\n") == NULL)
if (NULL == cp) {
return; return;
}
*cp = '\0';
if ('\0' != newf[0]) { if (!streq(newf, "")) {
/* /*
* Remove leading and trailing whitespace. This also * Remove leading and trailing whitespace. This also
* makes it possible to change the field to empty, by * makes it possible to change the field to empty, by
* entering a space. --marekm * entering a space. --marekm
*/ */
stpcpy(strrspn(newf, " \t"), "");
while (newf < cp && isspace (cp[-1])) { cp = stpspn(newf, " \t");
cp--;
}
*cp = '\0';
cp = newf;
while (isspace (*cp)) {
cp++;
}
strcpy (buf, cp); strcpy (buf, cp);
} }
} }
+2 -1
View File
@@ -9,10 +9,11 @@
#include <config.h> #include <config.h>
#include <assert.h> #include <assert.h>
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <errno.h> #include <errno.h>
#include "alloc.h" #include "alloc/calloc.h"
#include "prototypes.h" #include "prototypes.h"
#include "groupio.h" #include "groupio.h"
#include "getdef.h" #include "getdef.h"
+6 -5
View File
@@ -9,10 +9,11 @@
#include <config.h> #include <config.h>
#include <assert.h> #include <assert.h>
#include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <errno.h> #include <errno.h>
#include "alloc.h" #include "alloc/calloc.h"
#include "prototypes.h" #include "prototypes.h"
#include "pwio.h" #include "pwio.h"
#include "getdef.h" #include "getdef.h"
@@ -304,7 +305,7 @@ int find_new_uid(bool sys_user,
return 0; return 0;
} else if (result == EEXIST || result == EINVAL) { } else if (result == EEXIST || result == EINVAL) {
/* /*
* This GID is in use or unusable, we'll * This UID is in use or unusable, we'll
* continue to the next. * continue to the next.
*/ */
} else { } else {
@@ -350,7 +351,7 @@ int find_new_uid(bool sys_user,
return 0; return 0;
} else if (result == EEXIST || result == EINVAL) { } else if (result == EEXIST || result == EINVAL) {
/* /*
* This GID is in use or unusable, we'll * This UID is in use or unusable, we'll
* continue to the next. * continue to the next.
*/ */
} else { } else {
@@ -413,7 +414,7 @@ int find_new_uid(bool sys_user,
return 0; return 0;
} else if (result == EEXIST || result == EINVAL) { } else if (result == EEXIST || result == EINVAL) {
/* /*
* This GID is in use or unusable, we'll * This UID is in use or unusable, we'll
* continue to the next. * continue to the next.
*/ */
} else { } else {
@@ -459,7 +460,7 @@ int find_new_uid(bool sys_user,
return 0; return 0;
} else if (result == EEXIST || result == EINVAL) { } else if (result == EEXIST || result == EINVAL) {
/* /*
* This GID is in use or unusable, we'll * This UID is in use or unusable, we'll
* continue to the next. * continue to the next.
*/ */
} else { } else {
+7 -8
View File
@@ -10,10 +10,11 @@
#include <config.h> #include <config.h>
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include "defines.h" #include "defines.h"
#include "prototypes.h" #include "prototypes.h"
#include "string/strcmp/streq.h"
#ident "$Id$"
/*@null@*/char * /*@null@*/char *
@@ -25,7 +26,7 @@ fgetsx(/*@returned@*/char *restrict buf, int cnt, FILE *restrict f)
while (cnt > 0) { while (cnt > 0) {
if (fgets (cp, cnt, f) != cp) { if (fgets (cp, cnt, f) != cp) {
if (cp == buf) { if (cp == buf) {
return 0; return NULL;
} else { } else {
break; break;
} }
@@ -33,10 +34,8 @@ fgetsx(/*@returned@*/char *restrict buf, int cnt, FILE *restrict f)
ep = strrchr (cp, '\\'); ep = strrchr (cp, '\\');
if ((NULL != ep) && (*(ep + 1) == '\n')) { if ((NULL != ep) && (*(ep + 1) == '\n')) {
cnt -= ep - cp; cnt -= ep - cp;
if (cnt > 0) { if (cnt > 0)
cp = ep; cp = stpcpy(ep, "");
*cp = '\0';
}
} else { } else {
break; break;
} }
@@ -48,7 +47,7 @@ int fputsx (const char *s, FILE * stream)
{ {
int i; int i;
for (i = 0; '\0' != *s; i++, s++) { for (i = 0; !streq(s, ""); i++, s++) {
if (putc (*s, stream) == EOF) { if (putc (*s, stream) == EOF) {
return EOF; return EOF;
} }
+10
View File
@@ -0,0 +1,10 @@
// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#include <config.h>
#include "fs/readlink/areadlink.h"
extern inline char *areadlink(const char *link);
+53
View File
@@ -0,0 +1,53 @@
// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#ifndef SHADOW_INCLUDE_LIB_FS_READLINK_AREADLINK_H_
#define SHADOW_INCLUDE_LIB_FS_READLINK_AREADLINK_H_
#include <config.h>
#include <errno.h>
#include <limits.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdlib.h>
#include "alloc/malloc.h"
#include "attr.h"
#include "fs/readlink/readlinknul.h"
ATTR_STRING(1)
inline char *areadlink(const char *link);
// Similar to readlink(2), but allocate and terminate the string.
inline char *
areadlink(const char *link)
{
size_t size = PATH_MAX;
while (true) {
int len;
char *buf;
buf = MALLOC(size, char);
if (NULL == buf)
return NULL;
len = readlinknul(link, buf, size);
if (len != -1)
return buf;
free(buf);
if (errno != E2BIG)
return NULL;
size *= 2;
}
}
#endif // include guard
+14
View File
@@ -0,0 +1,14 @@
// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#include <config.h>
#include "fs/readlink/readlinknul.h"
#include <stddef.h>
#include <sys/types.h>
extern inline ssize_t readlinknul(const char *restrict link, char *restrict buf,
size_t size);
+53
View File
@@ -0,0 +1,53 @@
// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
// SPDX-License-Identifier: BSD-3-Clause
#ifndef SHADOW_INCLUDE_LIB_FS_READLINK_READLINKNUL_H_
#define SHADOW_INCLUDE_LIB_FS_READLINK_READLINKNUL_H_
#include <config.h>
#include <errno.h>
#include <stddef.h>
#include <string.h>
#include <sys/types.h>
#include <unistd.h>
#include "attr.h"
#include "sizeof.h"
#define READLINKNUL(link, buf) readlinknul(link, buf, NITEMS(buf))
ATTR_STRING(1)
inline ssize_t readlinknul(const char *restrict link, char *restrict buf,
size_t size);
// Similar to readlink(2), but terminate the string.
inline ssize_t
readlinknul(const char *restrict link, char *restrict buf, size_t size)
{
size_t ulen;
ssize_t slen;
slen = readlink(link, buf, size);
if (slen == -1)
return -1;
ulen = slen;
if (ulen == size) {
stpcpy(&buf[size-1], "");
errno = E2BIG;
return -1;
}
stpcpy(&buf[ulen], "");
return slen;
}
#endif // include guard
-34
View File
@@ -1,34 +0,0 @@
/*
* SPDX-FileCopyrightText: 2009 , Nicolas François
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <config.h>
#ident "$Id$"
#include "prototypes.h"
#include "defines.h"
int
get_gid(const char *gidstr, gid_t *gid)
{
char *end;
long long val;
errno = 0;
val = strtoll(gidstr, &end, 10);
if ( ('\0' == *gidstr)
|| ('\0' != *end)
|| (0 != errno)
|| (/*@+longintegral@*/val != (gid_t)val)/*@=longintegral@*/) {
return -1;
}
*gid = val;
return 0;
}
+10 -38
View File
@@ -1,8 +1,7 @@
/* // SPDX-FileCopyrightText: 2009, Nicolas François
* SPDX-FileCopyrightText: 2009 , Nicolas François // SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
* // SPDX-License-Identifier: BSD-3-Clause
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <config.h> #include <config.h>
@@ -14,29 +13,10 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include "string/sprintf.h" #include "atoi/getnum.h"
#include "string/sprintf/snprintf.h"
int
get_pid(const char *pidstr, pid_t *pid)
{
char *end;
long long val;
errno = 0;
val = strtoll(pidstr, &end, 10);
if ( ('\0' == *pidstr)
|| ('\0' != *end)
|| (0 != errno)
|| (val < 1)
|| (/*@+longintegral@*/val != (pid_t)val)/*@=longintegral@*/) {
return -1;
}
*pid = val;
return 0;
}
/* /*
* If use passed in fd:4 as an argument, then return the * If use passed in fd:4 as an argument, then return the
* value '4', the fd to use. * value '4', the fd to use.
@@ -44,20 +24,12 @@ get_pid(const char *pidstr, pid_t *pid)
*/ */
int get_pidfd_from_fd(const char *pidfdstr) int get_pidfd_from_fd(const char *pidfdstr)
{ {
char *end; int pidfd;
long long val;
struct stat st; struct stat st;
dev_t proc_st_dev, proc_st_rdev; dev_t proc_st_dev, proc_st_rdev;
errno = 0; if (get_fd(pidfdstr, &pidfd) == -1)
val = strtoll(pidfdstr, &end, 10);
if ( ('\0' == *pidfdstr)
|| ('\0' != *end)
|| (0 != errno)
|| (val < 0)
|| (/*@+longintegral@*/val != (int)val)/*@=longintegral@*/) {
return -1; return -1;
}
if (stat("/proc/self/uid_map", &st) < 0) { if (stat("/proc/self/uid_map", &st) < 0) {
return -1; return -1;
@@ -66,7 +38,7 @@ int get_pidfd_from_fd(const char *pidfdstr)
proc_st_dev = st.st_dev; proc_st_dev = st.st_dev;
proc_st_rdev = st.st_rdev; proc_st_rdev = st.st_rdev;
if (fstat(val, &st) < 0) { if (fstat(pidfd, &st) < 0) {
return -1; return -1;
} }
@@ -74,7 +46,7 @@ int get_pidfd_from_fd(const char *pidfdstr)
return -1; return -1;
} }
return (int)val; return pidfd;
} }
int open_pidfd(const char *pidstr) int open_pidfd(const char *pidstr)
-34
View File
@@ -1,34 +0,0 @@
/*
* SPDX-FileCopyrightText: 2009 , Nicolas François
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <config.h>
#ident "$Id$"
#include "prototypes.h"
#include "defines.h"
int
get_uid(const char *uidstr, uid_t *uid)
{
char *end;
long long val;
errno = 0;
val = strtoll(uidstr, &end, 10);
if ( ('\0' == *uidstr)
|| ('\0' != *end)
|| (0 != errno)
|| (/*@+longintegral@*/val != (uid_t)val)/*@=longintegral@*/) {
return -1;
}
*uid = val;
return 0;
}
+126 -125
View File
@@ -94,14 +94,16 @@
# undef static # undef static
#endif #endif
#include <stdio.h>
#include <ctype.h> #include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <time.h> #include <time.h>
#include "attr.h" #include "attr.h"
#include "getdate.h" #include "getdate.h"
#include "string/strchr/stpspn.h"
#include "string/strcmp/streq.h"
#include <string.h>
/* Some old versions of bison generate parsers that use bcopy. /* Some old versions of bison generate parsers that use bcopy.
That loses on systems that don't provide the function, so we have That loses on systems that don't provide the function, so we have
@@ -213,7 +215,7 @@ static int yyRelSeconds;
static int yyRelYear; static int yyRelYear;
#line 217 "getdate.c" #line 219 "getdate.c"
# ifndef YY_CAST # ifndef YY_CAST
# ifdef __cplusplus # ifdef __cplusplus
@@ -299,12 +301,12 @@ extern int yydebug;
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
union YYSTYPE union YYSTYPE
{ {
#line 147 "getdate.y" #line 149 "getdate.y"
int Number; int Number;
enum _MERIDIAN Meridian; enum _MERIDIAN Meridian;
#line 308 "getdate.c" #line 310 "getdate.c"
}; };
typedef union YYSTYPE YYSTYPE; typedef union YYSTYPE YYSTYPE;
@@ -744,12 +746,12 @@ static const yytype_int8 yytranslate[] =
/* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
static const yytype_int16 yyrline[] = static const yytype_int16 yyrline[] =
{ {
0, 163, 163, 164, 167, 170, 173, 176, 179, 182, 0, 165, 165, 166, 169, 172, 175, 178, 181, 184,
185, 191, 197, 206, 212, 224, 227, 231, 236, 240, 187, 193, 199, 208, 214, 226, 229, 233, 238, 242,
244, 250, 254, 272, 278, 284, 288, 293, 297, 304, 246, 252, 256, 274, 280, 286, 290, 295, 299, 306,
312, 315, 318, 321, 324, 327, 330, 333, 336, 339, 314, 317, 320, 323, 326, 329, 332, 335, 338, 341,
342, 345, 348, 351, 354, 357, 360, 363, 366, 371, 344, 347, 350, 353, 356, 359, 362, 365, 368, 373,
405, 408 407, 410
}; };
#endif #endif
@@ -1350,69 +1352,69 @@ yyreduce:
switch (yyn) switch (yyn)
{ {
case 4: /* item: time */ case 4: /* item: time */
#line 167 "getdate.y" #line 169 "getdate.y"
{ {
yyHaveTime++; yyHaveTime++;
} }
#line 1358 "getdate.c" #line 1360 "getdate.c"
break; break;
case 5: /* item: zone */ case 5: /* item: zone */
#line 170 "getdate.y" #line 172 "getdate.y"
{ {
yyHaveZone++; yyHaveZone++;
} }
#line 1366 "getdate.c" #line 1368 "getdate.c"
break; break;
case 6: /* item: date */ case 6: /* item: date */
#line 173 "getdate.y" #line 175 "getdate.y"
{ {
yyHaveDate++; yyHaveDate++;
} }
#line 1374 "getdate.c" #line 1376 "getdate.c"
break; break;
case 7: /* item: day */ case 7: /* item: day */
#line 176 "getdate.y" #line 178 "getdate.y"
{ {
yyHaveDay++; yyHaveDay++;
} }
#line 1382 "getdate.c" #line 1384 "getdate.c"
break; break;
case 8: /* item: rel */ case 8: /* item: rel */
#line 179 "getdate.y" #line 181 "getdate.y"
{ {
yyHaveRel++; yyHaveRel++;
} }
#line 1390 "getdate.c" #line 1392 "getdate.c"
break; break;
case 10: /* time: tUNUMBER tMERIDIAN */ case 10: /* time: tUNUMBER tMERIDIAN */
#line 185 "getdate.y" #line 187 "getdate.y"
{ {
yyHour = (yyvsp[-1].Number); yyHour = (yyvsp[-1].Number);
yyMinutes = 0; yyMinutes = 0;
yySeconds = 0; yySeconds = 0;
yyMeridian = (yyvsp[0].Meridian); yyMeridian = (yyvsp[0].Meridian);
} }
#line 1401 "getdate.c" #line 1403 "getdate.c"
break; break;
case 11: /* time: tUNUMBER ':' tUNUMBER o_merid */ case 11: /* time: tUNUMBER ':' tUNUMBER o_merid */
#line 191 "getdate.y" #line 193 "getdate.y"
{ {
yyHour = (yyvsp[-3].Number); yyHour = (yyvsp[-3].Number);
yyMinutes = (yyvsp[-1].Number); yyMinutes = (yyvsp[-1].Number);
yySeconds = 0; yySeconds = 0;
yyMeridian = (yyvsp[0].Meridian); yyMeridian = (yyvsp[0].Meridian);
} }
#line 1412 "getdate.c" #line 1414 "getdate.c"
break; break;
case 12: /* time: tUNUMBER ':' tUNUMBER tSNUMBER */ case 12: /* time: tUNUMBER ':' tUNUMBER tSNUMBER */
#line 197 "getdate.y" #line 199 "getdate.y"
{ {
yyHour = (yyvsp[-3].Number); yyHour = (yyvsp[-3].Number);
yyMinutes = (yyvsp[-1].Number); yyMinutes = (yyvsp[-1].Number);
@@ -1422,22 +1424,22 @@ yyreduce:
? -(yyvsp[0].Number) % 100 + (-(yyvsp[0].Number) / 100) * 60 ? -(yyvsp[0].Number) % 100 + (-(yyvsp[0].Number) / 100) * 60
: - ((yyvsp[0].Number) % 100 + ((yyvsp[0].Number) / 100) * 60)); : - ((yyvsp[0].Number) % 100 + ((yyvsp[0].Number) / 100) * 60));
} }
#line 1426 "getdate.c" #line 1428 "getdate.c"
break; break;
case 13: /* time: tUNUMBER ':' tUNUMBER ':' tUNUMBER o_merid */ case 13: /* time: tUNUMBER ':' tUNUMBER ':' tUNUMBER o_merid */
#line 206 "getdate.y" #line 208 "getdate.y"
{ {
yyHour = (yyvsp[-5].Number); yyHour = (yyvsp[-5].Number);
yyMinutes = (yyvsp[-3].Number); yyMinutes = (yyvsp[-3].Number);
yySeconds = (yyvsp[-1].Number); yySeconds = (yyvsp[-1].Number);
yyMeridian = (yyvsp[0].Meridian); yyMeridian = (yyvsp[0].Meridian);
} }
#line 1437 "getdate.c" #line 1439 "getdate.c"
break; break;
case 14: /* time: tUNUMBER ':' tUNUMBER ':' tUNUMBER tSNUMBER */ case 14: /* time: tUNUMBER ':' tUNUMBER ':' tUNUMBER tSNUMBER */
#line 212 "getdate.y" #line 214 "getdate.y"
{ {
yyHour = (yyvsp[-5].Number); yyHour = (yyvsp[-5].Number);
yyMinutes = (yyvsp[-3].Number); yyMinutes = (yyvsp[-3].Number);
@@ -1448,71 +1450,71 @@ yyreduce:
? -(yyvsp[0].Number) % 100 + (-(yyvsp[0].Number) / 100) * 60 ? -(yyvsp[0].Number) % 100 + (-(yyvsp[0].Number) / 100) * 60
: - ((yyvsp[0].Number) % 100 + ((yyvsp[0].Number) / 100) * 60)); : - ((yyvsp[0].Number) % 100 + ((yyvsp[0].Number) / 100) * 60));
} }
#line 1452 "getdate.c" #line 1454 "getdate.c"
break; break;
case 15: /* zone: tZONE */ case 15: /* zone: tZONE */
#line 224 "getdate.y" #line 226 "getdate.y"
{ {
yyTimezone = (yyvsp[0].Number); yyTimezone = (yyvsp[0].Number);
} }
#line 1460 "getdate.c" #line 1462 "getdate.c"
break; break;
case 16: /* zone: tDAYZONE */ case 16: /* zone: tDAYZONE */
#line 227 "getdate.y" #line 229 "getdate.y"
{ {
yyTimezone = (yyvsp[0].Number) - 60; yyTimezone = (yyvsp[0].Number) - 60;
} }
#line 1468 "getdate.c" #line 1470 "getdate.c"
break; break;
case 17: /* zone: tZONE tDST */ case 17: /* zone: tZONE tDST */
#line 231 "getdate.y" #line 233 "getdate.y"
{ {
yyTimezone = (yyvsp[-1].Number) - 60; yyTimezone = (yyvsp[-1].Number) - 60;
} }
#line 1476 "getdate.c" #line 1478 "getdate.c"
break; break;
case 18: /* day: tDAY */ case 18: /* day: tDAY */
#line 236 "getdate.y" #line 238 "getdate.y"
{ {
yyDayOrdinal = 1; yyDayOrdinal = 1;
yyDayNumber = (yyvsp[0].Number); yyDayNumber = (yyvsp[0].Number);
} }
#line 1485 "getdate.c" #line 1487 "getdate.c"
break; break;
case 19: /* day: tDAY ',' */ case 19: /* day: tDAY ',' */
#line 240 "getdate.y" #line 242 "getdate.y"
{ {
yyDayOrdinal = 1; yyDayOrdinal = 1;
yyDayNumber = (yyvsp[-1].Number); yyDayNumber = (yyvsp[-1].Number);
} }
#line 1494 "getdate.c" #line 1496 "getdate.c"
break; break;
case 20: /* day: tUNUMBER tDAY */ case 20: /* day: tUNUMBER tDAY */
#line 244 "getdate.y" #line 246 "getdate.y"
{ {
yyDayOrdinal = (yyvsp[-1].Number); yyDayOrdinal = (yyvsp[-1].Number);
yyDayNumber = (yyvsp[0].Number); yyDayNumber = (yyvsp[0].Number);
} }
#line 1503 "getdate.c" #line 1505 "getdate.c"
break; break;
case 21: /* date: tUNUMBER '/' tUNUMBER */ case 21: /* date: tUNUMBER '/' tUNUMBER */
#line 250 "getdate.y" #line 252 "getdate.y"
{ {
yyMonth = (yyvsp[-2].Number); yyMonth = (yyvsp[-2].Number);
yyDay = (yyvsp[0].Number); yyDay = (yyvsp[0].Number);
} }
#line 1512 "getdate.c" #line 1514 "getdate.c"
break; break;
case 22: /* date: tUNUMBER '/' tUNUMBER '/' tUNUMBER */ case 22: /* date: tUNUMBER '/' tUNUMBER '/' tUNUMBER */
#line 254 "getdate.y" #line 256 "getdate.y"
{ {
/* Interpret as YYYY/MM/DD if $1 >= 1000, otherwise as MM/DD/YY. /* Interpret as YYYY/MM/DD if $1 >= 1000, otherwise as MM/DD/YY.
The goal in recognizing YYYY/MM/DD is solely to support legacy The goal in recognizing YYYY/MM/DD is solely to support legacy
@@ -1531,71 +1533,71 @@ yyreduce:
yyYear = (yyvsp[0].Number); yyYear = (yyvsp[0].Number);
} }
} }
#line 1535 "getdate.c" #line 1537 "getdate.c"
break; break;
case 23: /* date: tUNUMBER tSNUMBER tSNUMBER */ case 23: /* date: tUNUMBER tSNUMBER tSNUMBER */
#line 272 "getdate.y" #line 274 "getdate.y"
{ {
/* ISO 8601 format. yyyy-mm-dd. */ /* ISO 8601 format. yyyy-mm-dd. */
yyYear = (yyvsp[-2].Number); yyYear = (yyvsp[-2].Number);
yyMonth = -(yyvsp[-1].Number); yyMonth = -(yyvsp[-1].Number);
yyDay = -(yyvsp[0].Number); yyDay = -(yyvsp[0].Number);
} }
#line 1546 "getdate.c" #line 1548 "getdate.c"
break; break;
case 24: /* date: tUNUMBER tMONTH tSNUMBER */ case 24: /* date: tUNUMBER tMONTH tSNUMBER */
#line 278 "getdate.y" #line 280 "getdate.y"
{ {
/* e.g. 17-JUN-1992. */ /* e.g. 17-JUN-1992. */
yyDay = (yyvsp[-2].Number); yyDay = (yyvsp[-2].Number);
yyMonth = (yyvsp[-1].Number); yyMonth = (yyvsp[-1].Number);
yyYear = -(yyvsp[0].Number); yyYear = -(yyvsp[0].Number);
} }
#line 1557 "getdate.c" #line 1559 "getdate.c"
break; break;
case 25: /* date: tMONTH tUNUMBER */ case 25: /* date: tMONTH tUNUMBER */
#line 284 "getdate.y" #line 286 "getdate.y"
{ {
yyMonth = (yyvsp[-1].Number); yyMonth = (yyvsp[-1].Number);
yyDay = (yyvsp[0].Number); yyDay = (yyvsp[0].Number);
} }
#line 1566 "getdate.c" #line 1568 "getdate.c"
break; break;
case 26: /* date: tMONTH tUNUMBER ',' tUNUMBER */ case 26: /* date: tMONTH tUNUMBER ',' tUNUMBER */
#line 288 "getdate.y" #line 290 "getdate.y"
{ {
yyMonth = (yyvsp[-3].Number); yyMonth = (yyvsp[-3].Number);
yyDay = (yyvsp[-2].Number); yyDay = (yyvsp[-2].Number);
yyYear = (yyvsp[0].Number); yyYear = (yyvsp[0].Number);
} }
#line 1576 "getdate.c" #line 1578 "getdate.c"
break; break;
case 27: /* date: tUNUMBER tMONTH */ case 27: /* date: tUNUMBER tMONTH */
#line 293 "getdate.y" #line 295 "getdate.y"
{ {
yyMonth = (yyvsp[0].Number); yyMonth = (yyvsp[0].Number);
yyDay = (yyvsp[-1].Number); yyDay = (yyvsp[-1].Number);
} }
#line 1585 "getdate.c" #line 1587 "getdate.c"
break; break;
case 28: /* date: tUNUMBER tMONTH tUNUMBER */ case 28: /* date: tUNUMBER tMONTH tUNUMBER */
#line 297 "getdate.y" #line 299 "getdate.y"
{ {
yyMonth = (yyvsp[-1].Number); yyMonth = (yyvsp[-1].Number);
yyDay = (yyvsp[-2].Number); yyDay = (yyvsp[-2].Number);
yyYear = (yyvsp[0].Number); yyYear = (yyvsp[0].Number);
} }
#line 1595 "getdate.c" #line 1597 "getdate.c"
break; break;
case 29: /* rel: relunit tAGO */ case 29: /* rel: relunit tAGO */
#line 304 "getdate.y" #line 306 "getdate.y"
{ {
yyRelSeconds = -yyRelSeconds; yyRelSeconds = -yyRelSeconds;
yyRelMinutes = -yyRelMinutes; yyRelMinutes = -yyRelMinutes;
@@ -1604,155 +1606,155 @@ yyreduce:
yyRelMonth = -yyRelMonth; yyRelMonth = -yyRelMonth;
yyRelYear = -yyRelYear; yyRelYear = -yyRelYear;
} }
#line 1608 "getdate.c" #line 1610 "getdate.c"
break; break;
case 31: /* relunit: tUNUMBER tYEAR_UNIT */ case 31: /* relunit: tUNUMBER tYEAR_UNIT */
#line 315 "getdate.y" #line 317 "getdate.y"
{ {
yyRelYear += (yyvsp[-1].Number) * (yyvsp[0].Number); yyRelYear += (yyvsp[-1].Number) * (yyvsp[0].Number);
} }
#line 1616 "getdate.c" #line 1618 "getdate.c"
break; break;
case 32: /* relunit: tSNUMBER tYEAR_UNIT */ case 32: /* relunit: tSNUMBER tYEAR_UNIT */
#line 318 "getdate.y" #line 320 "getdate.y"
{ {
yyRelYear += (yyvsp[-1].Number) * (yyvsp[0].Number); yyRelYear += (yyvsp[-1].Number) * (yyvsp[0].Number);
} }
#line 1624 "getdate.c" #line 1626 "getdate.c"
break; break;
case 33: /* relunit: tYEAR_UNIT */ case 33: /* relunit: tYEAR_UNIT */
#line 321 "getdate.y" #line 323 "getdate.y"
{ {
yyRelYear += (yyvsp[0].Number); yyRelYear += (yyvsp[0].Number);
} }
#line 1632 "getdate.c" #line 1634 "getdate.c"
break; break;
case 34: /* relunit: tUNUMBER tMONTH_UNIT */ case 34: /* relunit: tUNUMBER tMONTH_UNIT */
#line 324 "getdate.y" #line 326 "getdate.y"
{ {
yyRelMonth += (yyvsp[-1].Number) * (yyvsp[0].Number); yyRelMonth += (yyvsp[-1].Number) * (yyvsp[0].Number);
} }
#line 1640 "getdate.c" #line 1642 "getdate.c"
break; break;
case 35: /* relunit: tSNUMBER tMONTH_UNIT */ case 35: /* relunit: tSNUMBER tMONTH_UNIT */
#line 327 "getdate.y" #line 329 "getdate.y"
{ {
yyRelMonth += (yyvsp[-1].Number) * (yyvsp[0].Number); yyRelMonth += (yyvsp[-1].Number) * (yyvsp[0].Number);
} }
#line 1648 "getdate.c" #line 1650 "getdate.c"
break; break;
case 36: /* relunit: tMONTH_UNIT */ case 36: /* relunit: tMONTH_UNIT */
#line 330 "getdate.y" #line 332 "getdate.y"
{ {
yyRelMonth += (yyvsp[0].Number); yyRelMonth += (yyvsp[0].Number);
} }
#line 1656 "getdate.c" #line 1658 "getdate.c"
break; break;
case 37: /* relunit: tUNUMBER tDAY_UNIT */ case 37: /* relunit: tUNUMBER tDAY_UNIT */
#line 333 "getdate.y" #line 335 "getdate.y"
{ {
yyRelDay += (yyvsp[-1].Number) * (yyvsp[0].Number); yyRelDay += (yyvsp[-1].Number) * (yyvsp[0].Number);
} }
#line 1664 "getdate.c" #line 1666 "getdate.c"
break; break;
case 38: /* relunit: tSNUMBER tDAY_UNIT */ case 38: /* relunit: tSNUMBER tDAY_UNIT */
#line 336 "getdate.y" #line 338 "getdate.y"
{ {
yyRelDay += (yyvsp[-1].Number) * (yyvsp[0].Number); yyRelDay += (yyvsp[-1].Number) * (yyvsp[0].Number);
} }
#line 1672 "getdate.c" #line 1674 "getdate.c"
break; break;
case 39: /* relunit: tDAY_UNIT */ case 39: /* relunit: tDAY_UNIT */
#line 339 "getdate.y" #line 341 "getdate.y"
{ {
yyRelDay += (yyvsp[0].Number); yyRelDay += (yyvsp[0].Number);
} }
#line 1680 "getdate.c" #line 1682 "getdate.c"
break; break;
case 40: /* relunit: tUNUMBER tHOUR_UNIT */ case 40: /* relunit: tUNUMBER tHOUR_UNIT */
#line 342 "getdate.y" #line 344 "getdate.y"
{ {
yyRelHour += (yyvsp[-1].Number) * (yyvsp[0].Number); yyRelHour += (yyvsp[-1].Number) * (yyvsp[0].Number);
} }
#line 1688 "getdate.c" #line 1690 "getdate.c"
break; break;
case 41: /* relunit: tSNUMBER tHOUR_UNIT */ case 41: /* relunit: tSNUMBER tHOUR_UNIT */
#line 345 "getdate.y" #line 347 "getdate.y"
{ {
yyRelHour += (yyvsp[-1].Number) * (yyvsp[0].Number); yyRelHour += (yyvsp[-1].Number) * (yyvsp[0].Number);
} }
#line 1696 "getdate.c" #line 1698 "getdate.c"
break; break;
case 42: /* relunit: tHOUR_UNIT */ case 42: /* relunit: tHOUR_UNIT */
#line 348 "getdate.y" #line 350 "getdate.y"
{ {
yyRelHour += (yyvsp[0].Number); yyRelHour += (yyvsp[0].Number);
} }
#line 1704 "getdate.c" #line 1706 "getdate.c"
break; break;
case 43: /* relunit: tUNUMBER tMINUTE_UNIT */ case 43: /* relunit: tUNUMBER tMINUTE_UNIT */
#line 351 "getdate.y" #line 353 "getdate.y"
{ {
yyRelMinutes += (yyvsp[-1].Number) * (yyvsp[0].Number); yyRelMinutes += (yyvsp[-1].Number) * (yyvsp[0].Number);
} }
#line 1712 "getdate.c" #line 1714 "getdate.c"
break; break;
case 44: /* relunit: tSNUMBER tMINUTE_UNIT */ case 44: /* relunit: tSNUMBER tMINUTE_UNIT */
#line 354 "getdate.y" #line 356 "getdate.y"
{ {
yyRelMinutes += (yyvsp[-1].Number) * (yyvsp[0].Number); yyRelMinutes += (yyvsp[-1].Number) * (yyvsp[0].Number);
} }
#line 1720 "getdate.c" #line 1722 "getdate.c"
break; break;
case 45: /* relunit: tMINUTE_UNIT */ case 45: /* relunit: tMINUTE_UNIT */
#line 357 "getdate.y" #line 359 "getdate.y"
{ {
yyRelMinutes += (yyvsp[0].Number); yyRelMinutes += (yyvsp[0].Number);
} }
#line 1728 "getdate.c" #line 1730 "getdate.c"
break; break;
case 46: /* relunit: tUNUMBER tSEC_UNIT */ case 46: /* relunit: tUNUMBER tSEC_UNIT */
#line 360 "getdate.y" #line 362 "getdate.y"
{ {
yyRelSeconds += (yyvsp[-1].Number) * (yyvsp[0].Number); yyRelSeconds += (yyvsp[-1].Number) * (yyvsp[0].Number);
} }
#line 1736 "getdate.c" #line 1738 "getdate.c"
break; break;
case 47: /* relunit: tSNUMBER tSEC_UNIT */ case 47: /* relunit: tSNUMBER tSEC_UNIT */
#line 363 "getdate.y" #line 365 "getdate.y"
{ {
yyRelSeconds += (yyvsp[-1].Number) * (yyvsp[0].Number); yyRelSeconds += (yyvsp[-1].Number) * (yyvsp[0].Number);
} }
#line 1744 "getdate.c" #line 1746 "getdate.c"
break; break;
case 48: /* relunit: tSEC_UNIT */ case 48: /* relunit: tSEC_UNIT */
#line 366 "getdate.y" #line 368 "getdate.y"
{ {
yyRelSeconds += (yyvsp[0].Number); yyRelSeconds += (yyvsp[0].Number);
} }
#line 1752 "getdate.c" #line 1754 "getdate.c"
break; break;
case 49: /* number: tUNUMBER */ case 49: /* number: tUNUMBER */
#line 372 "getdate.y" #line 374 "getdate.y"
{ {
if ((yyHaveTime != 0) && (yyHaveDate != 0) && (yyHaveRel == 0)) if ((yyHaveTime != 0) && (yyHaveDate != 0) && (yyHaveRel == 0))
yyYear = (yyvsp[0].Number); yyYear = (yyvsp[0].Number);
@@ -1783,27 +1785,27 @@ yyreduce:
} }
} }
} }
#line 1787 "getdate.c" #line 1789 "getdate.c"
break; break;
case 50: /* o_merid: %empty */ case 50: /* o_merid: %empty */
#line 405 "getdate.y" #line 407 "getdate.y"
{ {
(yyval.Meridian) = MER24; (yyval.Meridian) = MER24;
} }
#line 1795 "getdate.c" #line 1797 "getdate.c"
break; break;
case 51: /* o_merid: tMERIDIAN */ case 51: /* o_merid: tMERIDIAN */
#line 409 "getdate.y" #line 411 "getdate.y"
{ {
(yyval.Meridian) = (yyvsp[0].Meridian); (yyval.Meridian) = (yyvsp[0].Meridian);
} }
#line 1803 "getdate.c" #line 1805 "getdate.c"
break; break;
#line 1807 "getdate.c" #line 1809 "getdate.c"
default: break; default: break;
} }
@@ -1996,7 +1998,7 @@ yyreturnlab:
return yyresult; return yyresult;
} }
#line 414 "getdate.y" #line 416 "getdate.y"
/* Month and day table. */ /* Month and day table. */
@@ -2211,16 +2213,16 @@ static int LookupWord (char *buff)
bool abbrev; bool abbrev;
/* Make it lowercase. */ /* Make it lowercase. */
for (p = buff; '\0' != *p; p++) for (p = buff; !streq(p, ""); p++)
if (isupper (*p)) if (isupper (*p))
*p = tolower (*p); *p = tolower (*p);
if (strcmp (buff, "am") == 0 || strcmp (buff, "a.m.") == 0) if (streq(buff, "am") || streq(buff, "a.m."))
{ {
yylval.Meridian = MERam; yylval.Meridian = MERam;
return tMERIDIAN; return tMERIDIAN;
} }
if (strcmp (buff, "pm") == 0 || strcmp (buff, "p.m.") == 0) if (streq(buff, "pm") || streq(buff, "p.m."))
{ {
yylval.Meridian = MERpm; yylval.Meridian = MERpm;
return tMERIDIAN; return tMERIDIAN;
@@ -2232,7 +2234,7 @@ static int LookupWord (char *buff)
else if (strlen (buff) == 4 && buff[3] == '.') else if (strlen (buff) == 4 && buff[3] == '.')
{ {
abbrev = true; abbrev = true;
buff[3] = '\0'; stpcpy(&buff[3], "");
} }
else else
abbrev = false; abbrev = false;
@@ -2247,7 +2249,7 @@ static int LookupWord (char *buff)
return tp->type; return tp->type;
} }
} }
else if (strcmp (buff, tp->name) == 0) else if (streq(buff, tp->name))
{ {
yylval.Number = tp->value; yylval.Number = tp->value;
return tp->type; return tp->type;
@@ -2255,17 +2257,17 @@ static int LookupWord (char *buff)
} }
for (tp = TimezoneTable; tp->name; tp++) for (tp = TimezoneTable; tp->name; tp++)
if (strcmp (buff, tp->name) == 0) if (streq(buff, tp->name))
{ {
yylval.Number = tp->value; yylval.Number = tp->value;
return tp->type; return tp->type;
} }
if (strcmp (buff, "dst") == 0) if (streq(buff, "dst"))
return tDST; return tDST;
for (tp = UnitsTable; tp->name; tp++) for (tp = UnitsTable; tp->name; tp++)
if (strcmp (buff, tp->name) == 0) if (streq(buff, tp->name))
{ {
yylval.Number = tp->value; yylval.Number = tp->value;
return tp->type; return tp->type;
@@ -2275,9 +2277,9 @@ static int LookupWord (char *buff)
i = strlen (buff) - 1; i = strlen (buff) - 1;
if (buff[i] == 's') if (buff[i] == 's')
{ {
buff[i] = '\0'; stpcpy(&buff[i], "");
for (tp = UnitsTable; tp->name; tp++) for (tp = UnitsTable; tp->name; tp++)
if (strcmp (buff, tp->name) == 0) if (streq(buff, tp->name))
{ {
yylval.Number = tp->value; yylval.Number = tp->value;
return tp->type; return tp->type;
@@ -2286,7 +2288,7 @@ static int LookupWord (char *buff)
} }
for (tp = OtherTable; tp->name; tp++) for (tp = OtherTable; tp->name; tp++)
if (strcmp (buff, tp->name) == 0) if (streq(buff, tp->name))
{ {
yylval.Number = tp->value; yylval.Number = tp->value;
return tp->type; return tp->type;
@@ -2296,7 +2298,7 @@ static int LookupWord (char *buff)
if (buff[1] == '\0' && isalpha (*buff)) if (buff[1] == '\0' && isalpha (*buff))
{ {
for (tp = MilitaryTable; tp->name; tp++) for (tp = MilitaryTable; tp->name; tp++)
if (strcmp (buff, tp->name) == 0) if (streq(buff, tp->name))
{ {
yylval.Number = tp->value; yylval.Number = tp->value;
return tp->type; return tp->type;
@@ -2304,15 +2306,15 @@ static int LookupWord (char *buff)
} }
/* Drop out any periods and try the timezone table again. */ /* Drop out any periods and try the timezone table again. */
for (i = 0, p = q = buff; '\0' != *q; q++) for (i = 0, p = q = buff; !streq(q, ""); q++)
if (*q != '.') if (*q != '.')
*p++ = *q; *p++ = *q;
else else
i++; i++;
*p = '\0'; stpcpy(p, "");
if (0 != i) if (0 != i)
for (tp = TimezoneTable; NULL != tp->name; tp++) for (tp = TimezoneTable; NULL != tp->name; tp++)
if (strcmp (buff, tp->name) == 0) if (streq(buff, tp->name))
{ {
yylval.Number = tp->value; yylval.Number = tp->value;
return tp->type; return tp->type;
@@ -2332,8 +2334,7 @@ yylex (void)
for (;;) for (;;)
{ {
while (isspace (*yyInput)) yyInput = stpspn(yyInput, " \t");
yyInput++;
if (isdigit (c = *yyInput) || c == '-' || c == '+') if (isdigit (c = *yyInput) || c == '-' || c == '+')
{ {
@@ -2358,7 +2359,7 @@ yylex (void)
for (p = buff; (c = *yyInput++, isalpha (c)) || c == '.';) for (p = buff; (c = *yyInput++, isalpha (c)) || c == '.';)
if (p < &buff[sizeof buff - 1]) if (p < &buff[sizeof buff - 1])
*p++ = c; *p++ = c;
*p = '\0'; stpcpy(p, "");
yyInput--; yyInput--;
return LookupWord (buff); return LookupWord (buff);
} }
@@ -2407,7 +2408,7 @@ time_t get_date (const char *p, const time_t *now)
time_t Start; time_t Start;
yyInput = p; yyInput = p;
Start = now ? *now : time ((time_t *) NULL); Start = now ? *now : time(NULL);
tmp = localtime (&Start); tmp = localtime (&Start);
yyYear = tmp->tm_year + TM_YEAR_ORIGIN; yyYear = tmp->tm_year + TM_YEAR_ORIGIN;
yyMonth = tmp->tm_mon + 1; yyMonth = tmp->tm_mon + 1;
@@ -2521,7 +2522,7 @@ main(void)
buff[MAX_BUFF_LEN] = 0; buff[MAX_BUFF_LEN] = 0;
while (fgets (buff, MAX_BUFF_LEN, stdin) && buff[0]) while (fgets (buff, MAX_BUFF_LEN, stdin) && buff[0])
{ {
d = get_date (buff, (time_t *) NULL); d = get_date(buff, NULL);
if (d == -1) if (d == -1)
(void) printf ("Bad format - couldn't convert.\n"); (void) printf ("Bad format - couldn't convert.\n");
else else
+23 -22
View File
@@ -24,14 +24,16 @@
# undef static # undef static
#endif #endif
#include <stdio.h>
#include <ctype.h> #include <ctype.h>
#include <stdio.h>
#include <string.h>
#include <time.h> #include <time.h>
#include "attr.h" #include "attr.h"
#include "getdate.h" #include "getdate.h"
#include "string/strchr/stpspn.h"
#include "string/strcmp/streq.h"
#include <string.h>
/* Some old versions of bison generate parsers that use bcopy. /* Some old versions of bison generate parsers that use bcopy.
That loses on systems that don't provide the function, so we have That loses on systems that don't provide the function, so we have
@@ -625,16 +627,16 @@ static int LookupWord (char *buff)
bool abbrev; bool abbrev;
/* Make it lowercase. */ /* Make it lowercase. */
for (p = buff; '\0' != *p; p++) for (p = buff; !streq(p, ""); p++)
if (isupper (*p)) if (isupper (*p))
*p = tolower (*p); *p = tolower (*p);
if (strcmp (buff, "am") == 0 || strcmp (buff, "a.m.") == 0) if (streq(buff, "am") || streq(buff, "a.m."))
{ {
yylval.Meridian = MERam; yylval.Meridian = MERam;
return tMERIDIAN; return tMERIDIAN;
} }
if (strcmp (buff, "pm") == 0 || strcmp (buff, "p.m.") == 0) if (streq(buff, "pm") || streq(buff, "p.m."))
{ {
yylval.Meridian = MERpm; yylval.Meridian = MERpm;
return tMERIDIAN; return tMERIDIAN;
@@ -646,7 +648,7 @@ static int LookupWord (char *buff)
else if (strlen (buff) == 4 && buff[3] == '.') else if (strlen (buff) == 4 && buff[3] == '.')
{ {
abbrev = true; abbrev = true;
buff[3] = '\0'; stpcpy(&buff[3], "");
} }
else else
abbrev = false; abbrev = false;
@@ -661,7 +663,7 @@ static int LookupWord (char *buff)
return tp->type; return tp->type;
} }
} }
else if (strcmp (buff, tp->name) == 0) else if (streq(buff, tp->name))
{ {
yylval.Number = tp->value; yylval.Number = tp->value;
return tp->type; return tp->type;
@@ -669,17 +671,17 @@ static int LookupWord (char *buff)
} }
for (tp = TimezoneTable; tp->name; tp++) for (tp = TimezoneTable; tp->name; tp++)
if (strcmp (buff, tp->name) == 0) if (streq(buff, tp->name))
{ {
yylval.Number = tp->value; yylval.Number = tp->value;
return tp->type; return tp->type;
} }
if (strcmp (buff, "dst") == 0) if (streq(buff, "dst"))
return tDST; return tDST;
for (tp = UnitsTable; tp->name; tp++) for (tp = UnitsTable; tp->name; tp++)
if (strcmp (buff, tp->name) == 0) if (streq(buff, tp->name))
{ {
yylval.Number = tp->value; yylval.Number = tp->value;
return tp->type; return tp->type;
@@ -689,9 +691,9 @@ static int LookupWord (char *buff)
i = strlen (buff) - 1; i = strlen (buff) - 1;
if (buff[i] == 's') if (buff[i] == 's')
{ {
buff[i] = '\0'; stpcpy(&buff[i], "");
for (tp = UnitsTable; tp->name; tp++) for (tp = UnitsTable; tp->name; tp++)
if (strcmp (buff, tp->name) == 0) if (streq(buff, tp->name))
{ {
yylval.Number = tp->value; yylval.Number = tp->value;
return tp->type; return tp->type;
@@ -700,7 +702,7 @@ static int LookupWord (char *buff)
} }
for (tp = OtherTable; tp->name; tp++) for (tp = OtherTable; tp->name; tp++)
if (strcmp (buff, tp->name) == 0) if (streq(buff, tp->name))
{ {
yylval.Number = tp->value; yylval.Number = tp->value;
return tp->type; return tp->type;
@@ -710,7 +712,7 @@ static int LookupWord (char *buff)
if (buff[1] == '\0' && isalpha (*buff)) if (buff[1] == '\0' && isalpha (*buff))
{ {
for (tp = MilitaryTable; tp->name; tp++) for (tp = MilitaryTable; tp->name; tp++)
if (strcmp (buff, tp->name) == 0) if (streq(buff, tp->name))
{ {
yylval.Number = tp->value; yylval.Number = tp->value;
return tp->type; return tp->type;
@@ -718,15 +720,15 @@ static int LookupWord (char *buff)
} }
/* Drop out any periods and try the timezone table again. */ /* Drop out any periods and try the timezone table again. */
for (i = 0, p = q = buff; '\0' != *q; q++) for (i = 0, p = q = buff; !streq(q, ""); q++)
if (*q != '.') if (*q != '.')
*p++ = *q; *p++ = *q;
else else
i++; i++;
*p = '\0'; stpcpy(p, "");
if (0 != i) if (0 != i)
for (tp = TimezoneTable; NULL != tp->name; tp++) for (tp = TimezoneTable; NULL != tp->name; tp++)
if (strcmp (buff, tp->name) == 0) if (streq(buff, tp->name))
{ {
yylval.Number = tp->value; yylval.Number = tp->value;
return tp->type; return tp->type;
@@ -746,8 +748,7 @@ yylex (void)
for (;;) for (;;)
{ {
while (isspace (*yyInput)) yyInput = stpspn(yyInput, " \t");
yyInput++;
if (isdigit (c = *yyInput) || c == '-' || c == '+') if (isdigit (c = *yyInput) || c == '-' || c == '+')
{ {
@@ -772,7 +773,7 @@ yylex (void)
for (p = buff; (c = *yyInput++, isalpha (c)) || c == '.';) for (p = buff; (c = *yyInput++, isalpha (c)) || c == '.';)
if (p < &buff[sizeof buff - 1]) if (p < &buff[sizeof buff - 1])
*p++ = c; *p++ = c;
*p = '\0'; stpcpy(p, "");
yyInput--; yyInput--;
return LookupWord (buff); return LookupWord (buff);
} }
@@ -821,7 +822,7 @@ time_t get_date (const char *p, const time_t *now)
time_t Start; time_t Start;
yyInput = p; yyInput = p;
Start = now ? *now : time ((time_t *) NULL); Start = now ? *now : time(NULL);
tmp = localtime (&Start); tmp = localtime (&Start);
yyYear = tmp->tm_year + TM_YEAR_ORIGIN; yyYear = tmp->tm_year + TM_YEAR_ORIGIN;
yyMonth = tmp->tm_mon + 1; yyMonth = tmp->tm_mon + 1;
@@ -935,7 +936,7 @@ main(void)
buff[MAX_BUFF_LEN] = 0; buff[MAX_BUFF_LEN] = 0;
while (fgets (buff, MAX_BUFF_LEN, stdin) && buff[0]) while (fgets (buff, MAX_BUFF_LEN, stdin) && buff[0])
{ {
d = get_date (buff, (time_t *) NULL); d = get_date(buff, NULL);
if (d == -1) if (d == -1)
(void) printf ("Bad format - couldn't convert.\n"); (void) printf ("Bad format - couldn't convert.\n");
else else
+34 -38
View File
@@ -11,22 +11,29 @@
#ident "$Id$" #ident "$Id$"
#include "prototypes.h" #include <ctype.h>
#include "defines.h" #include <errno.h>
#include <stddef.h> #include <stddef.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <ctype.h> #include <string.h>
#include <errno.h>
#ifdef USE_ECONF #ifdef USE_ECONF
#include <libeconf.h> #include <libeconf.h>
#endif #endif
#include "alloc.h" #include "atoi/a2i/a2s.h"
#include "atoi/str2i.h" #include "atoi/a2i/a2u.h"
#include "atoi/str2i/str2u.h"
#include "defines.h"
#include "getdef.h" #include "getdef.h"
#include "prototypes.h"
#include "shadowlog_internal.h" #include "shadowlog_internal.h"
#include "string/sprintf.h" #include "string/sprintf/xasprintf.h"
#include "string/strchr/stpspn.h"
#include "string/strchr/strrspn.h"
#include "string/strcmp/streq.h"
#include "string/strtok/stpsep.h"
/* /*
@@ -151,7 +158,6 @@ static struct itemdef def_table[] = {
{NULL, NULL} {NULL, NULL}
}; };
#define NUMKNOWNDEFS (sizeof(knowndef_table)/sizeof(knowndef_table[0]))
static struct itemdef knowndef_table[] = { static struct itemdef knowndef_table[] = {
#ifdef USE_PAM #ifdef USE_PAM
PAMDEFS PAMDEFS
@@ -232,10 +238,11 @@ bool getdef_bool (const char *item)
* values are handled. * values are handled.
*/ */
int getdef_num (const char *item, int dflt) int
getdef_num(const char *item, int dflt)
{ {
struct itemdef *d; int val;
long val; struct itemdef *d;
if (!def_loaded) { if (!def_loaded) {
def_load (); def_load ();
@@ -246,9 +253,7 @@ int getdef_num (const char *item, int dflt)
return dflt; return dflt;
} }
if ( (str2sl(&val, d->value) == -1) if (a2si(&val, d->value, NULL, 0, -1, INT_MAX) == -1) {
|| (val > INT_MAX)
|| (val < -1)) {
fprintf (shadow_logfd, fprintf (shadow_logfd,
_("configuration error - cannot parse %s value: '%s'"), _("configuration error - cannot parse %s value: '%s'"),
item, d->value); item, d->value);
@@ -267,10 +272,11 @@ int getdef_num (const char *item, int dflt)
* values are handled. * values are handled.
*/ */
unsigned int getdef_unum (const char *item, unsigned int dflt) unsigned int
getdef_unum(const char *item, unsigned int dflt)
{ {
struct itemdef *d; unsigned int val;
long val; struct itemdef *d;
if (!def_loaded) { if (!def_loaded) {
def_load (); def_load ();
@@ -281,9 +287,7 @@ unsigned int getdef_unum (const char *item, unsigned int dflt)
return dflt; return dflt;
} }
if ( (str2sl(&val, d->value) == -1) if (a2ui(&val, d->value, NULL, 0, 0, UINT_MAX) == -1) {
|| (val < 0)
|| (val > INT_MAX)) {
fprintf (shadow_logfd, fprintf (shadow_logfd,
_("configuration error - cannot parse %s value: '%s'"), _("configuration error - cannot parse %s value: '%s'"),
item, d->value); item, d->value);
@@ -316,7 +320,7 @@ long getdef_long (const char *item, long dflt)
return dflt; return dflt;
} }
if (str2sl(&val, d->value) == -1 || val < -1) { if (a2sl(&val, d->value, NULL, 0, -1, LONG_MAX) == -1) {
fprintf (shadow_logfd, fprintf (shadow_logfd,
_("configuration error - cannot parse %s value: '%s'"), _("configuration error - cannot parse %s value: '%s'"),
item, d->value); item, d->value);
@@ -416,7 +420,7 @@ static /*@observer@*/ /*@null@*/struct itemdef *def_find (const char *name, cons
*/ */
for (ptr = def_table; NULL != ptr->name; ptr++) { for (ptr = def_table; NULL != ptr->name; ptr++) {
if (strcmp (ptr->name, name) == 0) { if (streq(ptr->name, name)) {
return ptr; return ptr;
} }
} }
@@ -426,7 +430,7 @@ static /*@observer@*/ /*@null@*/struct itemdef *def_find (const char *name, cons
*/ */
for (ptr = knowndef_table; NULL != ptr->name; ptr++) { for (ptr = knowndef_table; NULL != ptr->name; ptr++) {
if (strcmp (ptr->name, name) == 0) { if (streq(ptr->name, name)) {
goto out; goto out;
} }
} }
@@ -526,7 +530,6 @@ static void def_load (void)
#else /* USE_ECONF */ #else /* USE_ECONF */
static void def_load (void) static void def_load (void)
{ {
int i;
FILE *fp; FILE *fp;
char buf[1024], *name, *value, *s; char buf[1024], *name, *value, *s;
@@ -558,28 +561,21 @@ static void def_load (void)
/* /*
* Trim trailing whitespace. * Trim trailing whitespace.
*/ */
for (i = (ptrdiff_t) strlen (buf) - 1; i >= 0; --i) { stpcpy(strrspn(buf, " \t\n"), "");
if (!isspace (buf[i])) {
break;
}
}
i++;
buf[i] = '\0';
/* /*
* Break the line into two fields. * Break the line into two fields.
*/ */
name = buf + strspn (buf, " \t"); /* first nonwhite */ name = stpspn(buf, " \t"); /* first nonwhite */
if (*name == '\0' || *name == '#') if (streq(name, "") || *name == '#')
continue; /* comment or empty */ continue; /* comment or empty */
s = name + strcspn (name, " \t"); /* end of field */ s = stpsep(name, " \t"); /* next field */
if (*s == '\0') if (s == NULL)
continue; /* only 1 field?? */ continue; /* only 1 field?? */
*s++ = '\0'; value = stpspn(s, " \"\t"); /* next nonwhite */
value = s + strspn (s, " \"\t"); /* next nonwhite */ stpsep(value, "\"");
*(value + strcspn (value, "\"")) = '\0';
/* /*
* Store the value in def_table. * Store the value in def_table.
+18 -22
View File
@@ -1,11 +1,10 @@
/* // SPDX-FileCopyrightText: 1991-1994, Julianne Frances Haugh
* SPDX-FileCopyrightText: 1991 - 1994, Julianne Frances Haugh // SPDX-FileCopyrightText: 1996-2000, Marek Michałkiewicz
* SPDX-FileCopyrightText: 1996 - 2000, Marek Michałkiewicz // SPDX-FileCopyrightText: 2000-2006, Tomasz Kłoczko
* SPDX-FileCopyrightText: 2000 - 2006, Tomasz Kłoczko // SPDX-FileCopyrightText: 2007-2009, Nicolas François
* SPDX-FileCopyrightText: 2007 - 2009, Nicolas François // SPDX-FileCopyrightText: 2023-2024, Alejandro Colomar <alx@kernel.org>
* // SPDX-License-Identifier: BSD-3-Clause
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <config.h> #include <config.h>
@@ -14,30 +13,27 @@
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#include <grp.h> #include <grp.h>
#include <sys/types.h>
#include "atoi/getnum.h"
#include "prototypes.h" #include "prototypes.h"
/* /*
* getgr_nam_gid - Return a pointer to the group specified by a string. * getgr_nam_gid - Return a pointer to the group specified by a string.
* The string may be a valid GID or a valid groupname. * The string may be a valid GID or a valid groupname.
* If the group does not exist on the system, NULL is returned. * If the group does not exist on the system, NULL is returned.
*/ */
extern /*@only@*//*@null@*/struct group *getgr_nam_gid (/*@null@*/const char *grname) extern /*@only@*//*@null@*/struct group *
getgr_nam_gid(/*@null@*/const char *grname)
{ {
char *end; gid_t gid;
long long gid;
if (NULL == grname) { if (NULL == grname)
return NULL; return NULL;
}
errno = 0; if (get_gid(grname, &gid) == 0)
gid = strtoll(grname, &end, 10); return xgetgrgid(gid);
if ( ('\0' != *grname) return xgetgrnam(grname);
&& ('\0' == *end)
&& (0 == errno)
&& (/*@+longintegral@*/gid == (gid_t)gid)/*@=longintegral@*/) {
return xgetgrgid (gid);
}
return xgetgrnam (grname);
} }
+3 -2
View File
@@ -10,9 +10,10 @@
#include <ctype.h> #include <ctype.h>
#include <stdlib.h> #include <stdlib.h>
#include "atoi/a2i.h" #include "atoi/a2i/a2u.h"
#include "defines.h" #include "defines.h"
#include "prototypes.h" #include "prototypes.h"
#include "string/strcmp/streq.h"
/* /*
@@ -53,7 +54,7 @@ getrange(const char *range,
return 0; /* <long> */ return 0; /* <long> */
case '-': case '-':
if ('\0' == *end) if (streq(end, ""))
return 0; /* <long>- */ return 0; /* <long>- */
parse_max: parse_max:
if (!isdigit((unsigned char) *end)) if (!isdigit((unsigned char) *end))
+1 -1
View File
@@ -11,7 +11,7 @@
#include <limits.h> #include <limits.h>
#include <stdio.h> #include <stdio.h>
#include "atoi/a2i.h" #include "atoi/a2i/a2i.h"
#include "defines.h" #include "defines.h"
#include "prototypes.h" #include "prototypes.h"
#include "shadowlog.h" #include "shadowlog.h"
+9 -7
View File
@@ -15,12 +15,14 @@
#include <assert.h> #include <assert.h>
#include <stdio.h> #include <stdio.h>
#include "alloc.h" #include "alloc/calloc.h"
#include "prototypes.h" #include "alloc/malloc.h"
#include "defines.h"
#include "commonio.h" #include "commonio.h"
#include "defines.h"
#include "getdef.h" #include "getdef.h"
#include "groupio.h" #include "groupio.h"
#include "prototypes.h"
#include "string/strcmp/streq.h"
static /*@null@*/struct commonio_entry *merge_group_entries ( static /*@null@*/struct commonio_entry *merge_group_entries (
@@ -262,8 +264,8 @@ static int group_open_hook (void)
struct group *g2 = gr2->eptr; struct group *g2 = gr2->eptr;
if (NULL != g1 && if (NULL != g1 &&
NULL != g2 && NULL != g2 &&
0 == strcmp (g1->gr_name, g2->gr_name) && streq(g1->gr_name, g2->gr_name) &&
0 == strcmp (g1->gr_passwd, g2->gr_passwd) && streq(g1->gr_passwd, g2->gr_passwd) &&
g1->gr_gid == g2->gr_gid) { g1->gr_gid == g2->gr_gid) {
/* Both group entries refer to the same /* Both group entries refer to the same
* group. It is a split group. Merge the * group. It is a split group. Merge the
@@ -331,7 +333,7 @@ static /*@null@*/struct commonio_entry *merge_group_entries (
for (i=0; NULL != gptr2->gr_mem[i]; i++) { for (i=0; NULL != gptr2->gr_mem[i]; i++) {
char **pmember = gptr1->gr_mem; char **pmember = gptr1->gr_mem;
while (NULL != *pmember) { while (NULL != *pmember) {
if (0 == strcmp(*pmember, gptr2->gr_mem[i])) { if (streq(*pmember, gptr2->gr_mem[i])) {
break; break;
} }
pmember++; pmember++;
@@ -354,7 +356,7 @@ static /*@null@*/struct commonio_entry *merge_group_entries (
for (i=0; NULL != gptr2->gr_mem[i]; i++) { for (i=0; NULL != gptr2->gr_mem[i]; i++) {
char **pmember = new_members; char **pmember = new_members;
while (NULL != *pmember) { while (NULL != *pmember) {
if (0 == strcmp(*pmember, gptr2->gr_mem[i])) { if (streq(*pmember, gptr2->gr_mem[i])) {
break; break;
} }
pmember++; pmember++;
+7 -6
View File
@@ -12,11 +12,13 @@
#ident "$Id$" #ident "$Id$"
#include "alloc.h" #include "alloc/calloc.h"
#include "memzero.h" #include "alloc/malloc.h"
#include "prototypes.h" #include "prototypes.h"
#include "defines.h" #include "defines.h"
#include "groupio.h" #include "groupio.h"
#include "string/memset/memzero.h"
/*@null@*/ /*@only@*/struct group *__gr_dup (const struct group *grent) /*@null@*/ /*@only@*/struct group *__gr_dup (const struct group *grent)
{ {
@@ -81,10 +83,9 @@ void
gr_free(/*@only@*/struct group *grent) gr_free(/*@only@*/struct group *grent)
{ {
free (grent->gr_name); free (grent->gr_name);
if (NULL != grent->gr_passwd) { if (NULL != grent->gr_passwd)
strzero (grent->gr_passwd); free(strzero(grent->gr_passwd));
free (grent->gr_passwd);
}
gr_free_members(grent); gr_free_members(grent);
free (grent); free (grent);
} }
+64 -98
View File
@@ -14,45 +14,40 @@
#ident "$Id$" #ident "$Id$"
#include <stddef.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "alloc.h" #include "alloc/malloc.h"
#include "prototypes.h" #include "alloc/realloc.h"
#include "alloc/x/xmalloc.h"
#include "defines.h" #include "defines.h"
#include "prototypes.h"
#include "string/strchr/strchrcnt.h"
#include "string/strcmp/streq.h"
#include "string/strtok/stpsep.h"
static /*@null@*/FILE *shadow; static /*@null@*/FILE *shadow;
static /*@null@*//*@only@*/char **members = NULL; static struct sgrp sgroup = {};
static size_t nmembers = 0;
static /*@null@*//*@only@*/char **admins = NULL;
static size_t nadmins = 0;
static struct sgrp sgroup;
#define FIELDS 4 #define FIELDS 4
static /*@null@*/char **build_list (char *s, char **list[], size_t * nlist) static /*@null@*/char **
build_list(char *s)
{ {
char **ptr = *list; char **l;
size_t nelem = *nlist, size; size_t i;
while (s != NULL && *s != '\0') { l = XMALLOC(strchrcnt(s, ',') + 2, char *);
size = (nelem + 1) * sizeof (ptr);
ptr = REALLOC(*list, size, char *); for (i = 0; s != NULL && !streq(s, ""); i++)
if (NULL != ptr) { l[i] = strsep(&s, ",");
ptr[nelem] = strsep(&s, ",");
nelem++; l[i] = NULL;
*list = ptr;
*nlist = nelem; return l;
}
}
size = (nelem + 1) * sizeof (ptr);
ptr = REALLOC(*list, size, char *);
if (NULL != ptr) {
ptr[nelem] = NULL;
*list = ptr;
}
return ptr;
} }
void setsgent (void) void setsgent (void)
@@ -60,7 +55,7 @@ void setsgent (void)
if (NULL != shadow) { if (NULL != shadow) {
rewind (shadow); rewind (shadow);
} else { } else {
shadow = fopen (SGROUP_FILE, "r"); shadow = fopen (SGROUP_FILE, "re");
} }
} }
@@ -73,7 +68,8 @@ void endsgent (void)
shadow = NULL; shadow = NULL;
} }
/*@observer@*//*@null@*/struct sgrp *sgetsgent (const char *string) /*@observer@*//*@null@*/struct sgrp *
sgetsgent(const char *string)
{ {
static char *sgrbuf = NULL; static char *sgrbuf = NULL;
static size_t sgrbuflen = 0; static size_t sgrbuflen = 0;
@@ -85,19 +81,15 @@ void endsgent (void)
if (len > sgrbuflen) { if (len > sgrbuflen) {
char *buf = REALLOC(sgrbuf, len, char); char *buf = REALLOC(sgrbuf, len, char);
if (NULL == buf) { if (NULL == buf)
return NULL; return NULL;
}
sgrbuf = buf; sgrbuf = buf;
sgrbuflen = len; sgrbuflen = len;
} }
strcpy (sgrbuf, string); strcpy (sgrbuf, string);
stpsep(sgrbuf, "\n");
cp = strrchr (sgrbuf, '\n');
if (NULL != cp) {
*cp = '\0';
}
/* /*
* There should be exactly 4 colon separated fields. Find * There should be exactly 4 colon separated fields. Find
@@ -113,22 +105,16 @@ void endsgent (void)
*/ */
if (NULL != cp || i != FIELDS) if (NULL != cp || i != FIELDS)
return 0; return NULL;
sgroup.sg_name = fields[0]; sgroup.sg_name = fields[0];
sgroup.sg_passwd = fields[1]; sgroup.sg_passwd = fields[1];
if (0 != nadmins) {
nadmins = 0; free(sgroup.sg_adm);
free (admins); free(sgroup.sg_mem);
admins = NULL;
} sgroup.sg_adm = build_list(fields[2]);
if (0 != nmembers) { sgroup.sg_mem = build_list(fields[3]);
nmembers = 0;
free (members);
members = NULL;
}
sgroup.sg_adm = build_list (fields[2], &admins, &nadmins);
sgroup.sg_mem = build_list (fields[3], &members, &nmembers);
return &sgroup; return &sgroup;
} }
@@ -159,32 +145,29 @@ void endsgent (void)
return NULL; return NULL;
} }
if (fgetsx(buf, buflen, fp) == buf) { if (fgetsx(buf, buflen, fp) == NULL)
while ( ((cp = strrchr (buf, '\n')) == NULL) return NULL;
&& (feof (fp) == 0)) {
size_t len;
cp = REALLOC(buf, buflen * 2, char); while ( (strrchr(buf, '\n') == NULL)
if (NULL == cp) { && (feof (fp) == 0)) {
return NULL; size_t len;
}
buf = cp;
buflen *= 2;
len = strlen (buf); cp = REALLOC(buf, buflen * 2, char);
if (fgetsx (&buf[len], if (NULL == cp) {
(int) (buflen - len), return NULL;
fp) != &buf[len]) {
return NULL;
}
} }
cp = strrchr (buf, '\n'); buf = cp;
if (NULL != cp) { buflen *= 2;
*cp = '\0';
len = strlen (buf);
if (fgetsx (&buf[len],
(int) (buflen - len),
fp) != &buf[len]) {
return NULL;
} }
return (sgetsgent (buf));
} }
return NULL; stpsep(buf, "\n");
return (sgetsgent (buf));
} }
/* /*
@@ -210,7 +193,7 @@ void endsgent (void)
setsgent (); setsgent ();
while ((sgrp = getsgent ()) != NULL) { while ((sgrp = getsgent ()) != NULL) {
if (strcmp (name, sgrp->sg_name) == 0) { if (streq(name, sgrp->sg_name)) {
break; break;
} }
} }
@@ -253,53 +236,36 @@ int putsgent (const struct sgrp *sgrp, FILE * fp)
/* /*
* Copy the group name and passwd. * Copy the group name and passwd.
*/ */
cp = stpcpy(stpcpy(cp, sgrp->sg_name), ":");
strcpy (cp, sgrp->sg_name); cp = stpcpy(stpcpy(cp, sgrp->sg_passwd), ":");
cp += strlen (cp);
*cp++ = ':';
strcpy (cp, sgrp->sg_passwd);
cp += strlen (cp);
*cp++ = ':';
/* /*
* Copy the administrators, separating each from the other * Copy the administrators, separating each from the other
* with a ",". * with a ",".
*/ */
for (i = 0; NULL != sgrp->sg_adm[i]; i++) { for (i = 0; NULL != sgrp->sg_adm[i]; i++) {
if (i > 0) { if (i > 0)
*cp++ = ','; cp = stpcpy(cp, ",");
}
strcpy (cp, sgrp->sg_adm[i]); cp = stpcpy(cp, sgrp->sg_adm[i]);
cp += strlen (cp);
} }
*cp = ':'; cp = stpcpy(cp, ":");
cp++;
/* /*
* Now do likewise with the group members. * Now do likewise with the group members.
*/ */
for (i = 0; NULL != sgrp->sg_mem[i]; i++) { for (i = 0; NULL != sgrp->sg_mem[i]; i++) {
if (i > 0) { if (i > 0)
*cp = ','; cp = stpcpy(cp, ",");
cp++;
}
strcpy (cp, sgrp->sg_mem[i]); cp = stpcpy(cp, sgrp->sg_mem[i]);
cp += strlen (cp);
} }
*cp = '\n'; stpcpy(cp, "\n");
cp++;
*cp = '\0';
/* /*
* Output using the function which understands the line * Output using the function which understands the line
* continuation conventions. * continuation conventions.
*/ */
if (fputsx (buf, fp) == EOF) { if (fputsx (buf, fp) == EOF) {
free (buf); free (buf);
return -1; return -1;
-10
View File
@@ -30,7 +30,6 @@ struct sgrp {
#include <stdio.h> /* for FILE */ #include <stdio.h> /* for FILE */
#if __STDC__
/*@observer@*//*@null@*/struct sgrp *getsgent (void); /*@observer@*//*@null@*/struct sgrp *getsgent (void);
/*@observer@*//*@null@*/struct sgrp *getsgnam (const char *); /*@observer@*//*@null@*/struct sgrp *getsgnam (const char *);
/*@observer@*//*@null@*/struct sgrp *sgetsgent (const char *); /*@observer@*//*@null@*/struct sgrp *sgetsgent (const char *);
@@ -38,15 +37,6 @@ struct sgrp {
void setsgent (void); void setsgent (void);
void endsgent (void); void endsgent (void);
int putsgent (const struct sgrp *, FILE *); int putsgent (const struct sgrp *, FILE *);
#else
/*@observer@*//*@null@*/struct sgrp *getsgent ();
/*@observer@*//*@null@*/struct sgrp *getsgnam ();
/*@observer@*//*@null@*/struct sgrp *sgetsgent ();
/*@observer@*//*@null@*/struct sgrp *fgetsgent ();
void setsgent ();
void endsgent ();
int putsgent ();
#endif
#define GSHADOW "/etc/gshadow" #define GSHADOW "/etc/gshadow"
#endif /* ifndef _H_GSHADOW */ #endif /* ifndef _H_GSHADOW */
+11 -7
View File
@@ -12,13 +12,17 @@
#ident "$Id$" #ident "$Id$"
#include <sys/types.h>
#include <stdio.h>
#include <pwd.h> #include <pwd.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include "defines.h" #include "defines.h"
#include "prototypes.h"
#include "getdef.h" #include "getdef.h"
#include "string/sprintf.h" #include "prototypes.h"
#include "string/sprintf/snprintf.h"
#include "string/strcmp/streq.h"
#include "string/strtok/stpsep.h"
/* /*
@@ -70,9 +74,9 @@ bool hushed (const char *username)
return false; return false;
} }
for (found = false; !found && (fgets (buf, sizeof buf, fp) == buf);) { for (found = false; !found && (fgets (buf, sizeof buf, fp) == buf);) {
buf[strcspn (buf, "\n")] = '\0'; stpsep(buf, "\n");
found = (strcmp (buf, pw->pw_shell) == 0) || found = streq(buf, pw->pw_shell) ||
(strcmp (buf, pw->pw_name) == 0); streq(buf, pw->pw_name);
} }
(void) fclose (fp); (void) fclose (fp);
return found; return found;
+26 -39
View File
@@ -12,24 +12,26 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <strings.h> #include <strings.h>
#include "alloc.h"
#include "atoi/str2i.h"
#include "prototypes.h"
#include "string/stpeprintf.h"
#include "idmapping.h"
#if HAVE_SYS_CAPABILITY_H #if HAVE_SYS_CAPABILITY_H
#include <sys/prctl.h> #include <sys/prctl.h>
#include <sys/capability.h> #include <sys/capability.h>
#endif #endif
#include "alloc/calloc.h"
#include "alloc/x/xmalloc.h"
#include "atoi/a2i/a2u.h"
#include "idmapping.h"
#include "prototypes.h"
#include "shadowlog.h" #include "shadowlog.h"
#include "sizeof.h" #include "sizeof.h"
#include "string/sprintf/stpeprintf.h"
#include "string/strcmp/streq.h"
struct map_range *get_map_ranges(int ranges, int argc, char **argv) struct map_range *
get_map_ranges(int ranges, int argc, char **argv)
{ {
struct map_range *mappings, *mapping; struct map_range *mappings, *m;
int idx, argidx;
if (ranges < 0 || argc < 0) { if (ranges < 0 || argc < 0) {
fprintf(log_get_logfd(), "%s: error calculating number of arguments\n", log_get_progname()); fprintf(log_get_logfd(), "%s: error calculating number of arguments\n", log_get_progname());
@@ -45,45 +47,30 @@ struct map_range *get_map_ranges(int ranges, int argc, char **argv)
if (!mappings) { if (!mappings) {
fprintf(log_get_logfd(), _( "%s: Memory allocation failure\n"), fprintf(log_get_logfd(), _( "%s: Memory allocation failure\n"),
log_get_progname()); log_get_progname());
exit(EXIT_FAILURE); return NULL;
} }
/* Gather up the ranges from the command line */ /* Gather up the ranges from the command line */
mapping = mappings; m = mappings;
for (idx = 0, argidx = 0; idx < ranges; idx++, argidx += 3, mapping++) { for (int i = 0; i < ranges * 3; i+=3, m++) {
if (str2ul(&mapping->upper, argv[argidx + 0]) == -1) { if (a2ul(&m->upper, argv[i + 0], NULL, 0, 0, UINT_MAX - 1) == -1) {
if (errno == ERANGE)
fprintf(log_get_logfd(), _( "%s: subuid overflow detected.\n"), log_get_progname());
free(mappings); free(mappings);
return NULL; return NULL;
} }
if (str2ul(&mapping->lower, argv[argidx + 1]) == -1) { if (a2ul(&m->lower, argv[i + 1], NULL, 0, 0, UINT_MAX - 1) == -1) {
if (errno == ERANGE)
fprintf(log_get_logfd(), _( "%s: subuid overflow detected.\n"), log_get_progname());
free(mappings); free(mappings);
return NULL; return NULL;
} }
if (str2ul(&mapping->count, argv[argidx + 2]) == -1) { if (a2ul(&m->count, argv[i + 2], NULL, 0, 1, UINT_MAX - MAX(m->lower, m->upper)) == -1) {
if (errno == ERANGE)
fprintf(log_get_logfd(), _( "%s: subuid overflow detected.\n"), log_get_progname());
free(mappings); free(mappings);
return NULL; return NULL;
} }
if (ULONG_MAX - mapping->upper <= mapping->count || ULONG_MAX - mapping->lower <= mapping->count) {
fprintf(log_get_logfd(), _( "%s: subuid overflow detected.\n"), log_get_progname());
exit(EXIT_FAILURE);
}
if (mapping->upper > UINT_MAX ||
mapping->lower > UINT_MAX ||
mapping->count > UINT_MAX) {
fprintf(log_get_logfd(), _( "%s: subuid overflow detected.\n"), log_get_progname());
exit(EXIT_FAILURE);
}
if (mapping->lower + mapping->count > UINT_MAX ||
mapping->upper + mapping->count > UINT_MAX) {
fprintf(log_get_logfd(), _( "%s: subuid overflow detected.\n"), log_get_progname());
exit(EXIT_FAILURE);
}
if (mapping->lower + mapping->count < mapping->lower ||
mapping->upper + mapping->count < mapping->upper) {
/* this one really shouldn't be possible given previous checks */
fprintf(log_get_logfd(), _( "%s: subuid overflow detected.\n"), log_get_progname());
exit(EXIT_FAILURE);
}
} }
return mappings; return mappings;
} }
@@ -147,9 +134,9 @@ void write_mapping(int proc_dir_fd, int ranges, const struct map_range *mappings
struct __user_cap_header_struct hdr = {_LINUX_CAPABILITY_VERSION_3, 0}; struct __user_cap_header_struct hdr = {_LINUX_CAPABILITY_VERSION_3, 0};
struct __user_cap_data_struct data[2] = {{0}}; struct __user_cap_data_struct data[2] = {{0}};
if (strcmp(map_file, "uid_map") == 0) { if (streq(map_file, "uid_map")) {
cap = CAP_SETUID; cap = CAP_SETUID;
} else if (strcmp(map_file, "gid_map") == 0) { } else if (streq(map_file, "gid_map")) {
cap = CAP_SETGID; cap = CAP_SETGID;
} else { } else {
fprintf(log_get_logfd(), _("%s: Invalid map file %s specified\n"), log_get_progname(), map_file); fprintf(log_get_logfd(), _("%s: Invalid map file %s specified\n"), log_get_progname(), map_file);
@@ -158,7 +145,7 @@ void write_mapping(int proc_dir_fd, int ranges, const struct map_range *mappings
/* Align setuid- and fscaps-based new{g,u}idmap behavior. */ /* Align setuid- and fscaps-based new{g,u}idmap behavior. */
if (geteuid() == 0 && geteuid() != ruid) { if (geteuid() == 0 && geteuid() != ruid) {
if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0) < 0) { if (prctl(PR_SET_KEEPCAPS, 1L) == -1) {
fprintf(log_get_logfd(), _("%s: Could not prctl(PR_SET_KEEPCAPS)\n"), log_get_progname()); fprintf(log_get_logfd(), _("%s: Could not prctl(PR_SET_KEEPCAPS)\n"), log_get_progname());
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
+2 -1
View File
@@ -21,6 +21,7 @@
#include "adds.h" #include "adds.h"
#include "defines.h" #include "defines.h"
#include "prototypes.h" #include "prototypes.h"
#include "string/strcmp/streq.h"
#ident "$Id$" #ident "$Id$"
@@ -67,7 +68,7 @@ int isexpired (const struct passwd *pw, /*@null@*/const struct spwd *sp)
* returns sp_lstchg==0 (must change password) instead of -1! * returns sp_lstchg==0 (must change password) instead of -1!
*/ */
if ( (0 == sp->sp_lstchg) if ( (0 == sp->sp_lstchg)
&& (strcmp (pw->pw_passwd, SHADOW_PASSWD_STRING) == 0)) { && streq(pw->pw_passwd, SHADOW_PASSWD_STRING)) {
return 1; return 1;
} }

Some files were not shown because too many files have changed in this diff Show More