Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| a9c3448878 | |||
| a475f464e0 | |||
| 65261e28f4 | |||
| bd724b34e0 | |||
| c2a3ebed18 | |||
| f78a468368 |
+1
-3
@@ -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
@@ -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
@@ -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
|
||||||
|
|
||||||
|
|||||||
-61
@@ -20,10 +20,6 @@
|
|||||||
/* Path for faillog file. */
|
/* Path for faillog file. */
|
||||||
#undef FAILLOG_FILE
|
#undef FAILLOG_FILE
|
||||||
|
|
||||||
/* Define to the type of elements in the array set by `getgroups'. Usually
|
|
||||||
this is either `int' or `gid_t'. */
|
|
||||||
#undef GETGROUPS_T
|
|
||||||
|
|
||||||
/* max group name length */
|
/* max group name length */
|
||||||
#undef GROUP_NAME_MAX_LENGTH
|
#undef GROUP_NAME_MAX_LENGTH
|
||||||
|
|
||||||
@@ -53,9 +49,6 @@
|
|||||||
the CoreFoundation framework. */
|
the CoreFoundation framework. */
|
||||||
#undef HAVE_CFPREFERENCESCOPYAPPVALUE
|
#undef HAVE_CFPREFERENCESCOPYAPPVALUE
|
||||||
|
|
||||||
/* Define to 1 if you have the <crypt.h> header file. */
|
|
||||||
#undef HAVE_CRYPT_H
|
|
||||||
|
|
||||||
/* Define if the GNU dcgettext() function is already present or preinstalled.
|
/* Define if the GNU dcgettext() function is already present or preinstalled.
|
||||||
*/
|
*/
|
||||||
#undef HAVE_DCGETTEXT
|
#undef HAVE_DCGETTEXT
|
||||||
@@ -119,24 +112,15 @@
|
|||||||
/* Define to 1 if you have the `getusershell' function. */
|
/* Define to 1 if you have the `getusershell' function. */
|
||||||
#undef HAVE_GETUSERSHELL
|
#undef HAVE_GETUSERSHELL
|
||||||
|
|
||||||
/* Define to 1 if you have the <gshadow.h> header file. */
|
|
||||||
#undef HAVE_GSHADOW_H
|
|
||||||
|
|
||||||
/* Define if you have the iconv() function and it works. */
|
/* Define if you have the iconv() function and it works. */
|
||||||
#undef HAVE_ICONV
|
#undef HAVE_ICONV
|
||||||
|
|
||||||
/* Define to 1 if you have the `initgroups' function. */
|
|
||||||
#undef HAVE_INITGROUPS
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `innetgr' function. */
|
/* Define to 1 if you have the `innetgr' function. */
|
||||||
#undef HAVE_INNETGR
|
#undef HAVE_INNETGR
|
||||||
|
|
||||||
/* Define to 1 if you have the <inttypes.h> header file. */
|
/* Define to 1 if you have the <inttypes.h> header file. */
|
||||||
#undef HAVE_INTTYPES_H
|
#undef HAVE_INTTYPES_H
|
||||||
|
|
||||||
/* Define to 1 if you have the <lastlog.h> header file. */
|
|
||||||
#undef HAVE_LASTLOG_H
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `lckpwdf' function. */
|
/* Define to 1 if you have the `lckpwdf' function. */
|
||||||
#undef HAVE_LCKPWDF
|
#undef HAVE_LCKPWDF
|
||||||
|
|
||||||
@@ -164,9 +148,6 @@
|
|||||||
/* Define to 1 if you have the <minix/config.h> header file. */
|
/* Define to 1 if you have the <minix/config.h> header file. */
|
||||||
#undef HAVE_MINIX_CONFIG_H
|
#undef HAVE_MINIX_CONFIG_H
|
||||||
|
|
||||||
/* Define to 1 if you have the <paths.h> header file. */
|
|
||||||
#undef HAVE_PATHS_H
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `putgrent' function. */
|
/* Define to 1 if you have the `putgrent' function. */
|
||||||
#undef HAVE_PUTGRENT
|
#undef HAVE_PUTGRENT
|
||||||
|
|
||||||
@@ -179,9 +160,6 @@
|
|||||||
/* Define to 1 if you have the <readpassphrase.h> header file. */
|
/* Define to 1 if you have the <readpassphrase.h> header file. */
|
||||||
#undef HAVE_READPASSPHRASE_H
|
#undef HAVE_READPASSPHRASE_H
|
||||||
|
|
||||||
/* Define to 1 if you have the <rpc/key_prot.h> header file. */
|
|
||||||
#undef HAVE_RPC_KEY_PROT_H
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `rpmatch' function. */
|
/* Define to 1 if you have the `rpmatch' function. */
|
||||||
#undef HAVE_RPMATCH
|
#undef HAVE_RPMATCH
|
||||||
|
|
||||||
@@ -197,9 +175,6 @@
|
|||||||
/* Define to 1 if you have the <semanage/semanage.h> header file. */
|
/* Define to 1 if you have the <semanage/semanage.h> header file. */
|
||||||
#undef HAVE_SEMANAGE_SEMANAGE_H
|
#undef HAVE_SEMANAGE_SEMANAGE_H
|
||||||
|
|
||||||
/* Define to 1 if you have the `setgroups' function. */
|
|
||||||
#undef HAVE_SETGROUPS
|
|
||||||
|
|
||||||
/* Define to 1 if you have the `sgetgrent' function. */
|
/* Define to 1 if you have the `sgetgrent' function. */
|
||||||
#undef HAVE_SGETGRENT
|
#undef HAVE_SGETGRENT
|
||||||
|
|
||||||
@@ -209,12 +184,6 @@
|
|||||||
/* Define to 1 if you have the `sgetspent' function. */
|
/* Define to 1 if you have the `sgetspent' function. */
|
||||||
#undef HAVE_SGETSPENT
|
#undef HAVE_SGETSPENT
|
||||||
|
|
||||||
/* Define to 1 if you have the <sgtty.h> header file. */
|
|
||||||
#undef HAVE_SGTTY_H
|
|
||||||
|
|
||||||
/* Have working shadow group support in libc */
|
|
||||||
#undef HAVE_SHADOWGRP
|
|
||||||
|
|
||||||
/* Define if you have the shl_load function. */
|
/* Define if you have the shl_load function. */
|
||||||
#undef HAVE_SHL_LOAD
|
#undef HAVE_SHL_LOAD
|
||||||
|
|
||||||
@@ -260,15 +229,6 @@
|
|||||||
/* Define to 1 if `ut_xtime' is a member of `struct utmpx'. */
|
/* Define to 1 if `ut_xtime' is a member of `struct utmpx'. */
|
||||||
#undef HAVE_STRUCT_UTMPX_UT_XTIME
|
#undef HAVE_STRUCT_UTMPX_UT_XTIME
|
||||||
|
|
||||||
/* Define to 1 if you have the <sys/capability.h> header file. */
|
|
||||||
#undef HAVE_SYS_CAPABILITY_H
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <sys/ioctl.h> header file. */
|
|
||||||
#undef HAVE_SYS_IOCTL_H
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <sys/random.h> header file. */
|
|
||||||
#undef HAVE_SYS_RANDOM_H
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <sys/statfs.h> header file. */
|
/* Define to 1 if you have the <sys/statfs.h> header file. */
|
||||||
#undef HAVE_SYS_STATFS_H
|
#undef HAVE_SYS_STATFS_H
|
||||||
|
|
||||||
@@ -281,9 +241,6 @@
|
|||||||
/* Define to 1 if you have the <tcb.h> header file. */
|
/* Define to 1 if you have the <tcb.h> header file. */
|
||||||
#undef HAVE_TCB_H
|
#undef HAVE_TCB_H
|
||||||
|
|
||||||
/* Define to 1 if you have the <termio.h> header file. */
|
|
||||||
#undef HAVE_TERMIO_H
|
|
||||||
|
|
||||||
/* Define to 1 if you have the <unistd.h> header file. */
|
/* Define to 1 if you have the <unistd.h> header file. */
|
||||||
#undef HAVE_UNISTD_H
|
#undef HAVE_UNISTD_H
|
||||||
|
|
||||||
@@ -296,9 +253,6 @@
|
|||||||
/* Define to 1 if `utime(file, NULL)' sets file's timestamp to the present. */
|
/* Define to 1 if `utime(file, NULL)' sets file's timestamp to the present. */
|
||||||
#undef HAVE_UTIME_NULL
|
#undef HAVE_UTIME_NULL
|
||||||
|
|
||||||
/* Define to 1 if you have the <utmp.h> header file. */
|
|
||||||
#undef HAVE_UTMP_H
|
|
||||||
|
|
||||||
/* Define to support vendor settings. */
|
/* Define to support vendor settings. */
|
||||||
#undef HAVE_VENDORDIR
|
#undef HAVE_VENDORDIR
|
||||||
|
|
||||||
@@ -341,12 +295,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
|
||||||
|
|
||||||
@@ -518,14 +466,5 @@
|
|||||||
/* Define for large files, on AIX-style hosts. */
|
/* Define for large files, on AIX-style hosts. */
|
||||||
#undef _LARGE_FILES
|
#undef _LARGE_FILES
|
||||||
|
|
||||||
/* Path for utmp file. */
|
|
||||||
#undef _UTMP_FILE
|
|
||||||
|
|
||||||
/* Path for wtmp file. */
|
/* Path for wtmp file. */
|
||||||
#undef _WTMP_FILE
|
#undef _WTMP_FILE
|
||||||
|
|
||||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
|
||||||
#undef gid_t
|
|
||||||
|
|
||||||
/* Define to `int' if <sys/types.h> doesn't define. */
|
|
||||||
#undef uid_t
|
|
||||||
|
|||||||
+6
-66
@@ -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.4], [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])
|
||||||
@@ -36,20 +36,13 @@ LT_LIB_DLLOAD
|
|||||||
|
|
||||||
dnl Checks for libraries.
|
dnl Checks for libraries.
|
||||||
|
|
||||||
dnl Checks for header files.
|
|
||||||
AC_CHECK_HEADERS(crypt.h utmp.h \
|
|
||||||
termio.h sgtty.h sys/ioctl.h paths.h \
|
|
||||||
sys/capability.h sys/random.h \
|
|
||||||
gshadow.h lastlog.h rpc/key_prot.h acl/libacl.h \
|
|
||||||
attr/libattr.h attr/error_context.h)
|
|
||||||
|
|
||||||
dnl shadow now uses the libc's shadow implementation
|
dnl shadow now uses the libc's shadow implementation
|
||||||
AC_CHECK_HEADER([shadow.h],,[AC_MSG_ERROR([You need a libc with shadow.h])])
|
AC_CHECK_HEADER([shadow.h],,[AC_MSG_ERROR([You need a libc with shadow.h])])
|
||||||
|
|
||||||
AC_CHECK_FUNCS(arc4random_buf futimes \
|
AC_CHECK_FUNCS(arc4random_buf futimes \
|
||||||
getentropy getrandom getspnam getusershell \
|
getentropy getrandom getspnam getusershell \
|
||||||
initgroups lckpwdf lutimes \
|
lckpwdf lutimes \
|
||||||
setgroups updwtmpx innetgr \
|
updwtmpx innetgr \
|
||||||
getspnam_r \
|
getspnam_r \
|
||||||
rpmatch \
|
rpmatch \
|
||||||
memset_explicit explicit_bzero stpecpy stpeprintf)
|
memset_explicit explicit_bzero stpecpy stpeprintf)
|
||||||
@@ -66,7 +59,6 @@ AC_CHECK_MEMBERS([struct utmpx.ut_name,
|
|||||||
struct utmpx.ut_xtime],,,[[#include <utmpx.h>]])
|
struct utmpx.ut_xtime],,,[[#include <utmpx.h>]])
|
||||||
|
|
||||||
dnl Checks for library functions.
|
dnl Checks for library functions.
|
||||||
AC_TYPE_GETGROUPS
|
|
||||||
AC_FUNC_UTIME_NULL
|
AC_FUNC_UTIME_NULL
|
||||||
AC_REPLACE_FUNCS(putgrent putpwent putspent)
|
AC_REPLACE_FUNCS(putgrent putpwent putspent)
|
||||||
AC_REPLACE_FUNCS(sgetgrent sgetpwent sgetspent)
|
AC_REPLACE_FUNCS(sgetgrent sgetpwent sgetspent)
|
||||||
@@ -76,33 +68,6 @@ AC_CHECK_FUNC(secure_getenv, [AC_DEFINE(HAS_SECURE_GETENV,
|
|||||||
1,
|
1,
|
||||||
[Defined to 1 if you have the declaration of 'secure_getenv'])])
|
[Defined to 1 if you have the declaration of 'secure_getenv'])])
|
||||||
|
|
||||||
if test "$ac_cv_header_shadow_h" = "yes"; then
|
|
||||||
AC_CACHE_CHECK(for working shadow group support,
|
|
||||||
ac_cv_libc_shadowgrp,
|
|
||||||
AC_RUN_IFELSE([AC_LANG_SOURCE([
|
|
||||||
#include <shadow.h>
|
|
||||||
#ifdef HAVE_GSHADOW_H
|
|
||||||
#include <gshadow.h>
|
|
||||||
#endif
|
|
||||||
int
|
|
||||||
main()
|
|
||||||
{
|
|
||||||
struct sgrp *sg = sgetsgent("test:x::");
|
|
||||||
/* NYS libc on Red Hat 3.0.3 has broken shadow group support */
|
|
||||||
return !sg || !sg->sg_adm || !sg->sg_mem;
|
|
||||||
}]
|
|
||||||
)],
|
|
||||||
[ac_cv_libc_shadowgrp=yes],
|
|
||||||
[ac_cv_libc_shadowgrp=no],
|
|
||||||
[ac_cv_libc_shadowgrp=no]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
if test "$ac_cv_libc_shadowgrp" = "yes"; then
|
|
||||||
AC_DEFINE(HAVE_SHADOWGRP, 1, [Have working shadow group support in libc])
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
AC_CACHE_CHECK([location of shared mail directory], shadow_cv_maildir,
|
AC_CACHE_CHECK([location of shared mail directory], shadow_cv_maildir,
|
||||||
[for shadow_cv_maildir in /var/mail /var/spool/mail /usr/spool/mail /usr/mail none; do
|
[for shadow_cv_maildir in /var/mail /var/spool/mail /usr/spool/mail /usr/mail none; do
|
||||||
if test -d $shadow_cv_maildir; then
|
if test -d $shadow_cv_maildir; then
|
||||||
@@ -125,18 +90,6 @@ if test $shadow_cv_mailfile != none; then
|
|||||||
[Name of user's mail spool file if stored in user's home directory.])
|
[Name of user's mail spool file if stored in user's home directory.])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
AC_CACHE_CHECK([location of utmp], shadow_cv_utmpdir,
|
|
||||||
[for shadow_cv_utmpdir in /var/run /var/adm /usr/adm /etc none; do
|
|
||||||
if test -f $shadow_cv_utmpdir/utmp; then
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done])
|
|
||||||
if test "$shadow_cv_utmpdir" = "none"; then
|
|
||||||
AC_MSG_WARN(utmp file not found)
|
|
||||||
fi
|
|
||||||
AC_DEFINE_UNQUOTED(_UTMP_FILE, "$shadow_cv_utmpdir/utmp",
|
|
||||||
[Path for utmp file.])
|
|
||||||
|
|
||||||
AC_CACHE_CHECK([location of faillog/lastlog/wtmp], shadow_cv_logdir,
|
AC_CACHE_CHECK([location of faillog/lastlog/wtmp], shadow_cv_logdir,
|
||||||
[for shadow_cv_logdir in /var/log /var/adm /usr/adm /etc; do
|
[for shadow_cv_logdir in /var/log /var/adm /usr/adm /etc; do
|
||||||
if test -d $shadow_cv_logdir; then
|
if test -d $shadow_cv_logdir; then
|
||||||
@@ -150,22 +103,9 @@ AC_DEFINE_UNQUOTED(LASTLOG_FILE, "$shadow_cv_logdir/lastlog",
|
|||||||
AC_DEFINE_UNQUOTED(FAILLOG_FILE, "$shadow_cv_logdir/faillog",
|
AC_DEFINE_UNQUOTED(FAILLOG_FILE, "$shadow_cv_logdir/faillog",
|
||||||
[Path for faillog file.])
|
[Path for faillog file.])
|
||||||
|
|
||||||
AC_CACHE_CHECK([location of the passwd program], shadow_cv_passwd_dir,
|
AC_DEFINE_UNQUOTED(PASSWD_PROGRAM, "$exec_prefix/bin/passwd",
|
||||||
[if test -f /usr/bin/passwd; then
|
|
||||||
shadow_cv_passwd_dir=/usr/bin
|
|
||||||
else
|
|
||||||
shadow_cv_passwd_dir=/bin
|
|
||||||
fi])
|
|
||||||
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 +636,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>
|
||||||
|
|||||||
@@ -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
@@ -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, "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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:
|
||||||
@@ -1755,7 +1751,7 @@
|
|||||||
}
|
}
|
||||||
#ifdef HAS_SHADOW
|
#ifdef HAS_SHADOW
|
||||||
if ((pw->pw_passwd && pw->pw_passwd[0] == '@'
|
if ((pw->pw_passwd && pw->pw_passwd[0] == '@'
|
||||||
&& pw_auth (pw->pw_passwd+1, pw->pw_name, PW_LOGIN, NULL))
|
&& pw_auth(pw->pw_passwd+1, pw->pw_name))
|
||||||
|| !valid (passwd, pw)) {
|
|| !valid (passwd, pw)) {
|
||||||
return (UPAP_AUTHNAK);
|
return (UPAP_AUTHNAK);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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@
|
||||||
|
|||||||
@@ -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@
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ pamd_files = \
|
|||||||
passwd
|
passwd
|
||||||
|
|
||||||
pamd_acct_tools_files = \
|
pamd_acct_tools_files = \
|
||||||
chage \
|
|
||||||
chgpasswd \
|
chgpasswd \
|
||||||
groupadd \
|
groupadd \
|
||||||
groupdel \
|
groupdel \
|
||||||
|
|||||||
@@ -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@
|
||||||
@@ -343,7 +342,6 @@ top_srcdir = @top_srcdir@
|
|||||||
pamd_files = chpasswd chfn chsh groupmems login newusers passwd \
|
pamd_files = chpasswd chfn chsh groupmems login newusers passwd \
|
||||||
$(am__append_2)
|
$(am__append_2)
|
||||||
pamd_acct_tools_files = \
|
pamd_acct_tools_files = \
|
||||||
chage \
|
|
||||||
chgpasswd \
|
chgpasswd \
|
||||||
groupadd \
|
groupadd \
|
||||||
groupdel \
|
groupdel \
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
#%PAM-1.0
|
|
||||||
auth sufficient pam_rootok.so
|
|
||||||
account required pam_permit.so
|
|
||||||
password include system-auth
|
|
||||||
@@ -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@
|
||||||
|
|||||||
+103
-25
@@ -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,11 +151,18 @@ 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 \
|
||||||
salt.c \
|
salt.c \
|
||||||
|
search/cmp/cmp.c \
|
||||||
|
search/cmp/cmp.h \
|
||||||
|
search/l/lfind.c \
|
||||||
|
search/l/lfind.h \
|
||||||
|
search/l/lsearch.c \
|
||||||
|
search/l/lsearch.h \
|
||||||
|
search/sort/qsort.c \
|
||||||
|
search/sort/qsort.h \
|
||||||
selinux.c \
|
selinux.c \
|
||||||
semanage.c \
|
semanage.c \
|
||||||
setugid.c \
|
setugid.c \
|
||||||
@@ -134,6 +173,8 @@ libshadow_la_SOURCES = \
|
|||||||
sgroupio.c \
|
sgroupio.c \
|
||||||
sgroupio.h\
|
sgroupio.h\
|
||||||
shadow.c \
|
shadow.c \
|
||||||
|
shadow/grp/agetgroups.c \
|
||||||
|
shadow/grp/agetgroups.h \
|
||||||
shadowio.c \
|
shadowio.c \
|
||||||
shadowio.h \
|
shadowio.h \
|
||||||
shadowlog.c \
|
shadowlog.c \
|
||||||
@@ -145,18 +186,54 @@ libshadow_la_SOURCES = \
|
|||||||
spawn.c \
|
spawn.c \
|
||||||
sssd.c \
|
sssd.c \
|
||||||
sssd.h \
|
sssd.h \
|
||||||
string/sprintf.c \
|
string/ctype/strisascii/strisdigit.c \
|
||||||
string/sprintf.h \
|
string/ctype/strisascii/strisdigit.h \
|
||||||
string/stpecpy.c \
|
string/memset/memzero.c \
|
||||||
string/stpecpy.h \
|
string/memset/memzero.h \
|
||||||
string/stpeprintf.c \
|
string/sprintf/snprintf.c \
|
||||||
string/stpeprintf.h \
|
string/sprintf/snprintf.h \
|
||||||
|
string/sprintf/stpeprintf.c \
|
||||||
|
string/sprintf/stpeprintf.h \
|
||||||
|
string/sprintf/xasprintf.c \
|
||||||
|
string/sprintf/xasprintf.h \
|
||||||
|
string/strchr/strchrcnt.c \
|
||||||
|
string/strchr/strchrcnt.h \
|
||||||
|
string/strchr/strchrscnt.c \
|
||||||
|
string/strchr/strchrscnt.h \
|
||||||
|
string/strchr/strnul.c \
|
||||||
|
string/strchr/strnul.h \
|
||||||
|
string/strcmp/strcaseeq.c \
|
||||||
|
string/strcmp/strcaseeq.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/strspn/stpspn.c \
|
||||||
string/strtcpy.c \
|
string/strspn/stpspn.h \
|
||||||
string/strtcpy.h \
|
string/strspn/stprcspn.c \
|
||||||
string/zustr2stp.h \
|
string/strspn/stprcspn.h \
|
||||||
|
string/strspn/stprspn.c \
|
||||||
|
string/strspn/stprspn.h \
|
||||||
|
string/strspn/strrcspn.c \
|
||||||
|
string/strspn/strrcspn.h \
|
||||||
|
string/strspn/strrspn.c \
|
||||||
|
string/strspn/strrspn.h \
|
||||||
|
string/strtok/stpsep.c \
|
||||||
|
string/strtok/stpsep.h \
|
||||||
strtoday.c \
|
strtoday.c \
|
||||||
sub.c \
|
sub.c \
|
||||||
subordinateio.h \
|
subordinateio.h \
|
||||||
@@ -165,6 +242,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 \
|
||||||
|
|||||||
+1058
-232
File diff suppressed because it is too large
Load Diff
+48
-81
@@ -1,114 +1,81 @@
|
|||||||
/*
|
// SPDX-FileCopyrightText: 1989-1994, Julianne Frances Haugh
|
||||||
* SPDX-FileCopyrightText: 1989 - 1994, Julianne Frances Haugh
|
// SPDX-FileCopyrightText: 1996-1998, Marek Michałkiewicz
|
||||||
* SPDX-FileCopyrightText: 1996 - 1998, Marek Michałkiewicz
|
// SPDX-FileCopyrightText: 2001-2006, Tomasz Kłoczko
|
||||||
* SPDX-FileCopyrightText: 2001 - 2006, Tomasz Kłoczko
|
// SPDX-FileCopyrightText: 2007-2009, Nicolas François
|
||||||
* SPDX-FileCopyrightText: 2007 - 2009, Nicolas François
|
// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
|
||||||
*
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#if defined (HAVE_SETGROUPS) && ! defined (USE_PAM)
|
#if !defined(USE_PAM)
|
||||||
|
|
||||||
#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 <sys/types.h>
|
||||||
|
|
||||||
#include "alloc.h"
|
#include "alloc/reallocf.h"
|
||||||
|
#include "search/l/lsearch.h"
|
||||||
|
#include "shadow/grp/agetgroups.h"
|
||||||
#include "shadowlog.h"
|
#include "shadowlog.h"
|
||||||
|
#include "string/strchr/strchrscnt.h"
|
||||||
|
|
||||||
#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;
|
char *g, *p, *dup;
|
||||||
size_t i;
|
|
||||||
int ngroups;
|
|
||||||
bool added;
|
|
||||||
char *token;
|
|
||||||
char buf[1024];
|
|
||||||
int ret;
|
|
||||||
FILE *shadow_logfd = log_get_logfd();
|
FILE *shadow_logfd = log_get_logfd();
|
||||||
|
gid_t *gids;
|
||||||
|
size_t n;
|
||||||
|
|
||||||
if (strlen (list) >= sizeof (buf)) {
|
gids = agetgroups(&n);
|
||||||
errno = EINVAL;
|
if (gids == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
strcpy (buf, list);
|
|
||||||
|
|
||||||
i = 16;
|
gids = REALLOCF(gids, n + strchrscnt(list, ",:") + 1, gid_t);
|
||||||
for (;;) {
|
if (gids == NULL)
|
||||||
grouplist = MALLOC(i, GETGROUPS_T);
|
|
||||||
if (NULL == grouplist) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
ngroups = getgroups (i, grouplist);
|
|
||||||
if ( ( (-1 == ngroups)
|
|
||||||
&& (EINVAL != errno))
|
|
||||||
|| (i > (size_t)ngroups)) {
|
|
||||||
/* Unexpected failure of getgroups or successful
|
|
||||||
* reception of the groups */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
/* not enough room, so try allocating a larger buffer */
|
|
||||||
free (grouplist);
|
|
||||||
i *= 2;
|
|
||||||
}
|
|
||||||
if (ngroups < 0) {
|
|
||||||
free (grouplist);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
|
||||||
|
|
||||||
added = false;
|
p = dup = strdup(list);
|
||||||
for (token = strtok (buf, SEP); NULL != token; token = strtok (NULL, SEP)) {
|
if (dup == NULL)
|
||||||
struct group *grp;
|
goto free_gids;
|
||||||
|
|
||||||
grp = getgrnam (token); /* local, no need for xgetgrnam */
|
while (NULL != (g = strsep(&p, ",:"))) {
|
||||||
|
struct group *grp;
|
||||||
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < (size_t)ngroups && grouplist[i] != grp->gr_gid; i++);
|
LSEARCH(&grp->gr_gid, gids, &n);
|
||||||
|
}
|
||||||
|
free(dup);
|
||||||
|
|
||||||
if (i < (size_t)ngroups) {
|
if (setgroups(n, gids) == -1) {
|
||||||
continue;
|
fprintf(shadow_logfd, "setgroups: %s\n", strerror(errno));
|
||||||
}
|
goto free_gids;
|
||||||
|
|
||||||
if (ngroups >= sysconf (_SC_NGROUPS_MAX)) {
|
|
||||||
fputs (_("Warning: too many groups\n"), shadow_logfd);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
grouplist = REALLOCF(grouplist, (size_t) ngroups + 1, GETGROUPS_T);
|
|
||||||
if (grouplist == NULL) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
grouplist[ngroups] = grp->gr_gid;
|
|
||||||
ngroups++;
|
|
||||||
added = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (added) {
|
free(gids);
|
||||||
ret = setgroups (ngroups, grouplist);
|
|
||||||
free (grouplist);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
free (grouplist);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
|
||||||
#else /* HAVE_SETGROUPS && !USE_PAM */
|
|
||||||
extern int ISO_C_forbids_an_empty_translation_unit;
|
|
||||||
#endif /* HAVE_SETGROUPS && !USE_PAM */
|
|
||||||
|
|
||||||
|
free_gids:
|
||||||
|
free(gids);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
#else /* !USE_PAM */
|
||||||
|
extern int ISO_C_forbids_an_empty_translation_unit;
|
||||||
|
#endif /* !USE_PAM */
|
||||||
|
|||||||
@@ -11,5 +11,3 @@
|
|||||||
|
|
||||||
extern inline long addsl2(long a, long b);
|
extern inline long addsl2(long a, long b);
|
||||||
extern inline long addslN(size_t n, long addend[n]);
|
extern inline long addslN(size_t n, long addend[n]);
|
||||||
|
|
||||||
extern inline int cmpl(const void *p1, const void *p2);
|
|
||||||
|
|||||||
+3
-19
@@ -1,4 +1,4 @@
|
|||||||
// 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
|
||||||
|
|
||||||
|
|
||||||
@@ -11,8 +11,8 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
|
#include "search/sort/qsort.h"
|
||||||
#include "sizeof.h"
|
#include "sizeof.h"
|
||||||
|
|
||||||
|
|
||||||
@@ -27,8 +27,6 @@
|
|||||||
inline long addsl2(long a, long b);
|
inline long addsl2(long a, long b);
|
||||||
inline long addslN(size_t n, long addend[n]);
|
inline long addslN(size_t n, long addend[n]);
|
||||||
|
|
||||||
inline int cmpl(const void *p1, const void *p2);
|
|
||||||
|
|
||||||
|
|
||||||
inline long
|
inline long
|
||||||
addsl2(long a, long b)
|
addsl2(long a, long b)
|
||||||
@@ -57,7 +55,7 @@ addslN(size_t n, long addend[n])
|
|||||||
|
|
||||||
e = errno;
|
e = errno;
|
||||||
while (n > 1) {
|
while (n > 1) {
|
||||||
qsort(addend, n, sizeof(addend[0]), cmpl);
|
QSORT(addend, n);
|
||||||
|
|
||||||
errno = 0;
|
errno = 0;
|
||||||
addend[0] = addsl2(addend[0], addend[--n]);
|
addend[0] = addsl2(addend[0], addend[--n]);
|
||||||
@@ -69,18 +67,4 @@ addslN(size_t n, long addend[n])
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline int
|
|
||||||
cmpl(const void *p1, const void *p2)
|
|
||||||
{
|
|
||||||
const long *l1 = p1;
|
|
||||||
const long *l2 = p2;
|
|
||||||
|
|
||||||
if (*l1 < *l2)
|
|
||||||
return -1;
|
|
||||||
if (*l1 > *l2)
|
|
||||||
return +1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#endif // include guard
|
#endif // include guard
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ int expire (const struct passwd *pw, /*@null@*/const struct spwd *sp)
|
|||||||
* passwd to work just like it would had they executed
|
* passwd to work just like it would had they executed
|
||||||
* it from the command line while logged in.
|
* it from the command line while logged in.
|
||||||
*/
|
*/
|
||||||
#if defined(HAVE_INITGROUPS) && ! defined(USE_PAM)
|
#if !defined(USE_PAM)
|
||||||
if (setup_uid_gid (pw, false) != 0)
|
if (setup_uid_gid (pw, false) != 0)
|
||||||
#else
|
#else
|
||||||
if (setup_uid_gid (pw) != 0)
|
if (setup_uid_gid (pw) != 0)
|
||||||
|
|||||||
+1
-1
@@ -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
@@ -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
@@ -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
|
|
||||||
@@ -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"
|
||||||
@@ -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
|
||||||
@@ -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);
|
||||||
@@ -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
|
||||||
@@ -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"
|
||||||
@@ -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
|
||||||
@@ -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);
|
||||||
@@ -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
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
@@ -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
|
||||||
@@ -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);
|
||||||
@@ -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
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
@@ -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
|
||||||
@@ -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
@@ -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
|
|
||||||
@@ -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"
|
||||||
@@ -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
|
||||||
@@ -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"
|
||||||
@@ -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
|
||||||
@@ -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);
|
||||||
@@ -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
|
||||||
@@ -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);
|
||||||
@@ -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
|
||||||
@@ -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"
|
||||||
@@ -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
|
||||||
@@ -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);
|
||||||
@@ -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
|
||||||
@@ -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);
|
||||||
@@ -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
|
||||||
@@ -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);
|
||||||
@@ -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
|
||||||
@@ -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
|
|
||||||
@@ -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"
|
||||||
@@ -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
|
||||||
@@ -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);
|
||||||
@@ -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
|
||||||
@@ -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);
|
||||||
@@ -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
|
||||||
@@ -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);
|
|
||||||
@@ -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
|
|
||||||
@@ -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);
|
||||||
@@ -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
|
||||||
@@ -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);
|
||||||
@@ -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
@@ -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
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+50
-3
@@ -25,6 +25,8 @@
|
|||||||
#include "attr.h"
|
#include "attr.h"
|
||||||
#include "prototypes.h"
|
#include "prototypes.h"
|
||||||
#include "shadowlog.h"
|
#include "shadowlog.h"
|
||||||
|
#include "string/sprintf/snprintf.h"
|
||||||
|
|
||||||
int audit_fd;
|
int audit_fd;
|
||||||
|
|
||||||
void audit_help_open (void)
|
void audit_help_open (void)
|
||||||
@@ -46,10 +48,14 @@ void audit_help_open (void)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* This function will log a message to the audit system using a predefined
|
* This function will log a message to the audit system using a predefined
|
||||||
* message format. Parameter usage is as follows:
|
* message format. For additional information on the user account lifecycle
|
||||||
|
* events check
|
||||||
|
* <https://github.com/linux-audit/audit-documentation/wiki/SPEC-User-Account-Lifecycle-Events>
|
||||||
*
|
*
|
||||||
* type - type of message: AUDIT_USER_CHAUTHTOK for changing any account
|
* Parameter usage is as follows:
|
||||||
* attributes.
|
*
|
||||||
|
* type - type of message. A list of possible values is available in
|
||||||
|
* "audit-records.h" file.
|
||||||
* pgname - program's name
|
* pgname - program's name
|
||||||
* op - operation. "adding user", "changing finger info", "deleting group"
|
* op - operation. "adding user", "changing finger info", "deleting group"
|
||||||
* name - user's account or group name. If not available use NULL.
|
* name - user's account or group name. If not available use NULL.
|
||||||
@@ -68,6 +74,47 @@ void audit_logger (int type, MAYBE_UNUSED const char *pgname, const char *op,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This function will log a message to the audit system using a predefined
|
||||||
|
* message format. For additional information on the group account lifecycle
|
||||||
|
* events check
|
||||||
|
* <https://github.com/linux-audit/audit-documentation/wiki/SPEC-User-Account-Lifecycle-Events>
|
||||||
|
*
|
||||||
|
* Parameter usage is as follows:
|
||||||
|
*
|
||||||
|
* type - type of message. A list of possible values is available in
|
||||||
|
* "audit-records.h" file.
|
||||||
|
* op - operation. "adding-user", "modify-group", "deleting-user-from-group"
|
||||||
|
* name - user's account or group name. If not available use NULL.
|
||||||
|
* id - uid or gid that the operation is being performed on. This is used
|
||||||
|
* only when user is NULL.
|
||||||
|
* grp_type - type of group: "grp" or "new_group"
|
||||||
|
* grp - group name associated with event
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
audit_logger_with_group(int type, const char *op, const char *name,
|
||||||
|
id_t id, const char *grp_type, const char *grp,
|
||||||
|
shadow_audit_result result)
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
char enc_group[GROUP_NAME_MAX_LENGTH * 2 + 1];
|
||||||
|
char buf[NITEMS(enc_group) + 100];
|
||||||
|
|
||||||
|
if (audit_fd < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
len = strnlen(grp, sizeof(enc_group)/2);
|
||||||
|
if (audit_value_needs_encoding(grp, len)) {
|
||||||
|
SNPRINTF(buf, "%s %s=%s", op, grp_type,
|
||||||
|
audit_encode_value(enc_group, grp, len));
|
||||||
|
} else {
|
||||||
|
SNPRINTF(buf, "%s %s=\"%s\"", op, grp_type, grp);
|
||||||
|
}
|
||||||
|
|
||||||
|
audit_log_acct_message(audit_fd, type, NULL, buf, name, id,
|
||||||
|
NULL, NULL, NULL, result);
|
||||||
|
}
|
||||||
|
|
||||||
void audit_logger_message (const char *message, shadow_audit_result result)
|
void audit_logger_message (const char *message, shadow_audit_result result)
|
||||||
{
|
{
|
||||||
if (audit_fd < 0) {
|
if (audit_fd < 0) {
|
||||||
|
|||||||
+13
-13
@@ -1,10 +1,8 @@
|
|||||||
/*
|
// SPDX-FileCopyrightText: 1990-1994, Julianne Frances Haugh
|
||||||
* SPDX-FileCopyrightText: 1990 - 1994, Julianne Frances Haugh
|
// SPDX-FileCopyrightText: 1996-1997, Marek Michałkiewicz
|
||||||
* SPDX-FileCopyrightText: 1996 - 1997, Marek Michałkiewicz
|
// SPDX-FileCopyrightText: 2003-2005, Tomasz Kłoczko
|
||||||
* SPDX-FileCopyrightText: 2003 - 2005, Tomasz Kłoczko
|
// SPDX-FileCopyrightText: 2024, Alejandro Colomar <alx@kernel.org>
|
||||||
*
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* basename.c - not worth copyrighting :-). Some versions of Linux libc
|
* basename.c - not worth copyrighting :-). Some versions of Linux libc
|
||||||
@@ -15,17 +13,19 @@
|
|||||||
|
|
||||||
#include <config.h>
|
#include <config.h>
|
||||||
|
|
||||||
#ident "$Id$"
|
#include <stddef.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "defines.h"
|
|
||||||
#include "prototypes.h"
|
#include "prototypes.h"
|
||||||
/*@observer@*/const char *Basename (const char *str)
|
#include "string/strspn/stprcspn.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*@observer@*/const char *
|
||||||
|
Basename(const char *str)
|
||||||
{
|
{
|
||||||
if (str == NULL) {
|
if (str == NULL) {
|
||||||
abort ();
|
abort ();
|
||||||
}
|
}
|
||||||
|
|
||||||
char *cp = strrchr (str, '/');
|
return stprcspn(str, "/");
|
||||||
|
|
||||||
return (NULL != cp) ? cp + 1 : str;
|
|
||||||
}
|
}
|
||||||
|
|||||||
+39
-19
@@ -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,13 @@
|
|||||||
|
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
#include "chkname.h"
|
#include "chkname.h"
|
||||||
|
#include "string/ctype/strisascii/strisdigit.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 +48,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;
|
||||||
@@ -62,57 +72,67 @@ static bool is_valid_name (const char *name)
|
|||||||
*
|
*
|
||||||
* Also do not allow fully numeric names or just "." or "..".
|
* Also do not allow fully numeric names or just "." or "..".
|
||||||
*/
|
*/
|
||||||
int numeric;
|
|
||||||
|
|
||||||
if ('\0' == *name ||
|
if (strisdigit(name)) {
|
||||||
('.' == *name && (('.' == name[1] && '\0' == name[2]) ||
|
errno = EINVAL;
|
||||||
'\0' == name[1])) ||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (streq(name, "") ||
|
||||||
|
streq(name, ".") ||
|
||||||
|
streq(name, "..") ||
|
||||||
!((*name >= 'a' && *name <= 'z') ||
|
!((*name >= 'a' && *name <= 'z') ||
|
||||||
(*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);
|
while (!streq(++name, "")) {
|
||||||
|
|
||||||
while ('\0' != *++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') ||
|
||||||
*name == '_' ||
|
*name == '_' ||
|
||||||
*name == '.' ||
|
*name == '.' ||
|
||||||
*name == '-' ||
|
*name == '-' ||
|
||||||
(*name == '$' && name[1] == '\0')
|
streq(name, "$")
|
||||||
)) {
|
))
|
||||||
|
{
|
||||||
|
errno = EINVAL;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
numeric &= isdigit(*name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return !numeric;
|
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
@@ -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
@@ -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) {
|
||||||
|
|||||||
+11
-11
@@ -62,7 +62,7 @@ void cleanup_report_mod_group (void *cleanup_info)
|
|||||||
gr_dbname (),
|
gr_dbname (),
|
||||||
info->action));
|
info->action));
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_USER_ACCT, log_get_progname(),
|
audit_logger (AUDIT_GRP_MGMT, log_get_progname(),
|
||||||
info->audit_msg,
|
info->audit_msg,
|
||||||
info->name, AUDIT_NO_ID,
|
info->name, AUDIT_NO_ID,
|
||||||
SHADOW_AUDIT_FAILURE);
|
SHADOW_AUDIT_FAILURE);
|
||||||
@@ -80,7 +80,7 @@ void cleanup_report_mod_gshadow (void *cleanup_info)
|
|||||||
sgr_dbname (),
|
sgr_dbname (),
|
||||||
info->action));
|
info->action));
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_USER_ACCT, log_get_progname(),
|
audit_logger (AUDIT_GRP_MGMT, log_get_progname(),
|
||||||
info->audit_msg,
|
info->audit_msg,
|
||||||
info->name, AUDIT_NO_ID,
|
info->name, AUDIT_NO_ID,
|
||||||
SHADOW_AUDIT_FAILURE);
|
SHADOW_AUDIT_FAILURE);
|
||||||
@@ -101,7 +101,7 @@ void cleanup_report_add_group_group (void *group_name)
|
|||||||
SYSLOG ((LOG_ERR, "failed to add group %s to %s", name, gr_dbname ()));
|
SYSLOG ((LOG_ERR, "failed to add group %s to %s", name, gr_dbname ()));
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_ADD_GROUP, log_get_progname(),
|
audit_logger (AUDIT_ADD_GROUP, log_get_progname(),
|
||||||
"adding group to /etc/group",
|
"adding-group",
|
||||||
name, AUDIT_NO_ID,
|
name, AUDIT_NO_ID,
|
||||||
SHADOW_AUDIT_FAILURE);
|
SHADOW_AUDIT_FAILURE);
|
||||||
#endif
|
#endif
|
||||||
@@ -120,8 +120,8 @@ void cleanup_report_add_group_gshadow (void *group_name)
|
|||||||
|
|
||||||
SYSLOG ((LOG_ERR, "failed to add group %s to %s", name, sgr_dbname ()));
|
SYSLOG ((LOG_ERR, "failed to add group %s to %s", name, sgr_dbname ()));
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_ADD_GROUP, log_get_progname(),
|
audit_logger (AUDIT_GRP_MGMT, log_get_progname(),
|
||||||
"adding group to /etc/gshadow",
|
"adding-shadow-group",
|
||||||
name, AUDIT_NO_ID,
|
name, AUDIT_NO_ID,
|
||||||
SHADOW_AUDIT_FAILURE);
|
SHADOW_AUDIT_FAILURE);
|
||||||
#endif
|
#endif
|
||||||
@@ -143,8 +143,8 @@ void cleanup_report_del_group_group (void *group_name)
|
|||||||
"failed to remove group %s from %s",
|
"failed to remove group %s from %s",
|
||||||
name, gr_dbname ()));
|
name, gr_dbname ()));
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_ADD_GROUP, log_get_progname(),
|
audit_logger (AUDIT_DEL_GROUP, log_get_progname(),
|
||||||
"removing group from /etc/group",
|
"removing-group",
|
||||||
name, AUDIT_NO_ID,
|
name, AUDIT_NO_ID,
|
||||||
SHADOW_AUDIT_FAILURE);
|
SHADOW_AUDIT_FAILURE);
|
||||||
#endif
|
#endif
|
||||||
@@ -166,8 +166,8 @@ void cleanup_report_del_group_gshadow (void *group_name)
|
|||||||
"failed to remove group %s from %s",
|
"failed to remove group %s from %s",
|
||||||
name, sgr_dbname ()));
|
name, sgr_dbname ()));
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_ADD_GROUP, log_get_progname(),
|
audit_logger (AUDIT_GRP_MGMT, log_get_progname(),
|
||||||
"removing group from /etc/gshadow",
|
"removing-shadow-group",
|
||||||
name, AUDIT_NO_ID,
|
name, AUDIT_NO_ID,
|
||||||
SHADOW_AUDIT_FAILURE);
|
SHADOW_AUDIT_FAILURE);
|
||||||
#endif
|
#endif
|
||||||
@@ -187,7 +187,7 @@ void cleanup_unlock_group (MAYBE_UNUSED void *arg)
|
|||||||
log_get_progname(), gr_dbname ());
|
log_get_progname(), gr_dbname ());
|
||||||
SYSLOG ((LOG_ERR, "failed to unlock %s", gr_dbname ()));
|
SYSLOG ((LOG_ERR, "failed to unlock %s", gr_dbname ()));
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger_message ("unlocking group file",
|
audit_logger_message ("unlocking-group",
|
||||||
SHADOW_AUDIT_FAILURE);
|
SHADOW_AUDIT_FAILURE);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -207,7 +207,7 @@ void cleanup_unlock_gshadow (MAYBE_UNUSED void *arg)
|
|||||||
log_get_progname(), sgr_dbname ());
|
log_get_progname(), sgr_dbname ());
|
||||||
SYSLOG ((LOG_ERR, "failed to unlock %s", sgr_dbname ()));
|
SYSLOG ((LOG_ERR, "failed to unlock %s", sgr_dbname ()));
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger_message ("unlocking gshadow file",
|
audit_logger_message ("unlocking-gshadow",
|
||||||
SHADOW_AUDIT_FAILURE);
|
SHADOW_AUDIT_FAILURE);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-6
@@ -44,7 +44,7 @@ void cleanup_report_mod_passwd (void *cleanup_info)
|
|||||||
pw_dbname (),
|
pw_dbname (),
|
||||||
info->action));
|
info->action));
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_USER_ACCT, log_get_progname(),
|
audit_logger (AUDIT_USER_MGMT, log_get_progname(),
|
||||||
info->audit_msg,
|
info->audit_msg,
|
||||||
info->name, AUDIT_NO_ID,
|
info->name, AUDIT_NO_ID,
|
||||||
SHADOW_AUDIT_FAILURE);
|
SHADOW_AUDIT_FAILURE);
|
||||||
@@ -65,7 +65,7 @@ void cleanup_report_add_user_passwd (void *user_name)
|
|||||||
SYSLOG ((LOG_ERR, "failed to add user %s to %s", name, pw_dbname ()));
|
SYSLOG ((LOG_ERR, "failed to add user %s to %s", name, pw_dbname ()));
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_ADD_USER, log_get_progname(),
|
audit_logger (AUDIT_ADD_USER, log_get_progname(),
|
||||||
"adding user to /etc/passwd",
|
"adding-user",
|
||||||
name, AUDIT_NO_ID,
|
name, AUDIT_NO_ID,
|
||||||
SHADOW_AUDIT_FAILURE);
|
SHADOW_AUDIT_FAILURE);
|
||||||
#endif
|
#endif
|
||||||
@@ -84,8 +84,8 @@ void cleanup_report_add_user_shadow (void *user_name)
|
|||||||
|
|
||||||
SYSLOG ((LOG_ERR, "failed to add user %s to %s", name, spw_dbname ()));
|
SYSLOG ((LOG_ERR, "failed to add user %s to %s", name, spw_dbname ()));
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger (AUDIT_ADD_USER, log_get_progname(),
|
audit_logger (AUDIT_USER_MGMT, log_get_progname(),
|
||||||
"adding user to /etc/shadow",
|
"adding-shadow-user",
|
||||||
name, AUDIT_NO_ID,
|
name, AUDIT_NO_ID,
|
||||||
SHADOW_AUDIT_FAILURE);
|
SHADOW_AUDIT_FAILURE);
|
||||||
#endif
|
#endif
|
||||||
@@ -104,7 +104,7 @@ void cleanup_unlock_passwd (MAYBE_UNUSED void *arg)
|
|||||||
log_get_progname(), pw_dbname ());
|
log_get_progname(), pw_dbname ());
|
||||||
SYSLOG ((LOG_ERR, "failed to unlock %s", pw_dbname ()));
|
SYSLOG ((LOG_ERR, "failed to unlock %s", pw_dbname ()));
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger_message ("unlocking passwd file",
|
audit_logger_message ("unlocking-passwd",
|
||||||
SHADOW_AUDIT_FAILURE);
|
SHADOW_AUDIT_FAILURE);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -123,7 +123,7 @@ void cleanup_unlock_shadow (MAYBE_UNUSED void *arg)
|
|||||||
log_get_progname(), spw_dbname ());
|
log_get_progname(), spw_dbname ());
|
||||||
SYSLOG ((LOG_ERR, "failed to unlock %s", spw_dbname ()));
|
SYSLOG ((LOG_ERR, "failed to unlock %s", spw_dbname ()));
|
||||||
#ifdef WITH_AUDIT
|
#ifdef WITH_AUDIT
|
||||||
audit_logger_message ("unlocking shadow file",
|
audit_logger_message ("unlocking-shadow",
|
||||||
SHADOW_AUDIT_FAILURE);
|
SHADOW_AUDIT_FAILURE);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|||||||
+44
-56
@@ -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 */
|
||||||
@@ -69,17 +74,10 @@ int lrename (const char *old, const char *new)
|
|||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
char *r = NULL;
|
char *r = NULL;
|
||||||
|
|
||||||
#ifndef __GLIBC__
|
|
||||||
char resolved_path[PATH_MAX];
|
|
||||||
#endif /* !__GLIBC__ */
|
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
|
|
||||||
if (lstat (new, &sb) == 0 && S_ISLNK (sb.st_mode)) {
|
if (lstat (new, &sb) == 0 && S_ISLNK (sb.st_mode)) {
|
||||||
#ifdef __GLIBC__ /* now a POSIX.1-2008 feature */
|
|
||||||
r = realpath (new, NULL);
|
r = realpath (new, NULL);
|
||||||
#else /* !__GLIBC__ */
|
|
||||||
r = realpath (new, resolved_path);
|
|
||||||
#endif /* !__GLIBC__ */
|
|
||||||
if (NULL == r) {
|
if (NULL == r) {
|
||||||
perror ("realpath in lrename()");
|
perror ("realpath in lrename()");
|
||||||
} else {
|
} else {
|
||||||
@@ -89,9 +87,7 @@ int lrename (const char *old, const char *new)
|
|||||||
|
|
||||||
res = rename (old, new);
|
res = rename (old, new);
|
||||||
|
|
||||||
#ifdef __GLIBC__
|
|
||||||
free (r);
|
free (r);
|
||||||
#endif /* __GLIBC__ */
|
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
@@ -194,7 +190,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 +569,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 +630,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 +652,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 +704,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 +822,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;
|
||||||
@@ -894,7 +882,7 @@ static int write_all (const struct commonio_db *db)
|
|||||||
|
|
||||||
int commonio_close (struct commonio_db *db)
|
int commonio_close (struct commonio_db *db)
|
||||||
{
|
{
|
||||||
int errors = 0;
|
bool errors = false;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
|
|
||||||
@@ -935,25 +923,25 @@ int commonio_close (struct commonio_db *db)
|
|||||||
|
|
||||||
#ifdef WITH_SELINUX
|
#ifdef WITH_SELINUX
|
||||||
if (set_selinux_file_context (db->filename, S_IFREG) != 0) {
|
if (set_selinux_file_context (db->filename, S_IFREG) != 0) {
|
||||||
errors++;
|
errors = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (create_backup (buf, db->fp) != 0) {
|
if (create_backup (buf, db->fp) != 0) {
|
||||||
errors++;
|
errors = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fclose (db->fp) != 0) {
|
if (fclose (db->fp) != 0) {
|
||||||
errors++;
|
errors = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
db->fp = NULL;
|
db->fp = NULL;
|
||||||
|
|
||||||
#ifdef WITH_SELINUX
|
#ifdef WITH_SELINUX
|
||||||
if (reset_selinux_file_context () != 0) {
|
if (reset_selinux_file_context () != 0) {
|
||||||
errors++;
|
errors = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (errors != 0)
|
if (errors)
|
||||||
goto fail;
|
goto fail;
|
||||||
} else {
|
} else {
|
||||||
/*
|
/*
|
||||||
@@ -969,7 +957,7 @@ int commonio_close (struct commonio_db *db)
|
|||||||
|
|
||||||
#ifdef WITH_SELINUX
|
#ifdef WITH_SELINUX
|
||||||
if (set_selinux_file_context (db->filename, S_IFREG) != 0) {
|
if (set_selinux_file_context (db->filename, S_IFREG) != 0) {
|
||||||
errors++;
|
errors = true;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -979,24 +967,24 @@ int commonio_close (struct commonio_db *db)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (write_all (db) != 0) {
|
if (write_all (db) != 0) {
|
||||||
errors++;
|
errors = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fflush (db->fp) != 0) {
|
if (fflush (db->fp) != 0) {
|
||||||
errors++;
|
errors = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fsync (fileno (db->fp)) != 0) {
|
if (fsync (fileno (db->fp)) != 0) {
|
||||||
errors++;
|
errors = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fclose (db->fp) != 0) {
|
if (fclose (db->fp) != 0) {
|
||||||
errors++;
|
errors = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
db->fp = NULL;
|
db->fp = NULL;
|
||||||
|
|
||||||
if (errors != 0) {
|
if (errors) {
|
||||||
unlink (buf);
|
unlink (buf);
|
||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
@@ -1014,11 +1002,11 @@ int commonio_close (struct commonio_db *db)
|
|||||||
nscd_need_reload = true;
|
nscd_need_reload = true;
|
||||||
goto success;
|
goto success;
|
||||||
fail:
|
fail:
|
||||||
errors++;
|
errors = true;
|
||||||
success:
|
success:
|
||||||
|
|
||||||
free_linked_list (db);
|
free_linked_list (db);
|
||||||
return errors == 0;
|
return !errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
static /*@dependent@*/ /*@null@*/struct commonio_entry *next_entry_by_name (
|
static /*@dependent@*/ /*@null@*/struct commonio_entry *next_entry_by_name (
|
||||||
@@ -1036,7 +1024,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 +1230,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
@@ -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
@@ -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
|
||||||
|
|||||||
+14
-17
@@ -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 __has_include(<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:
|
||||||
|
|||||||
+2
-7
@@ -41,7 +41,7 @@
|
|||||||
* crypt(3), crypt_gensalt(3), and their
|
* crypt(3), crypt_gensalt(3), and their
|
||||||
* feature test macros may be defined in here.
|
* feature test macros may be defined in here.
|
||||||
*/
|
*/
|
||||||
#if HAVE_CRYPT_H
|
#if __has_include(<crypt.h>)
|
||||||
# include <crypt.h>
|
# include <crypt.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -50,13 +50,8 @@
|
|||||||
|
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
|
||||||
/*
|
|
||||||
* Possible cases:
|
|
||||||
* - /usr/include/shadow.h exists and includes the shadow group stuff.
|
|
||||||
* - /usr/include/shadow.h exists, but we use our own gshadow.h.
|
|
||||||
*/
|
|
||||||
#include <shadow.h>
|
#include <shadow.h>
|
||||||
#if defined(SHADOWGRP) && !defined(GSHADOW)
|
#if defined(SHADOWGRP)
|
||||||
#include "gshadow_.h"
|
#include "gshadow_.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -65,7 +65,8 @@
|
|||||||
(void) fprintf (shadow_logfd,
|
(void) fprintf (shadow_logfd,
|
||||||
_("crypt method not supported by libcrypt? (%s)\n"),
|
_("crypt method not supported by libcrypt? (%s)\n"),
|
||||||
method);
|
method);
|
||||||
exit (EXIT_FAILURE);
|
errno = EINVAL;
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (strlen (cp) != 13) {
|
if (strlen (cp) != 13) {
|
||||||
|
|||||||
@@ -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
@@ -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
@@ -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/strcmp/streq.h"
|
||||||
|
#include "string/strspn/stpspn.h"
|
||||||
|
#include "string/strspn/stprspn.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(stprspn(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
@@ -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
@@ -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
@@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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);
|
||||||
@@ -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
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
// SPDX-FileCopyrightText: 2024-2025, Alejandro Colomar <alx@kernel.org>
|
||||||
|
// SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
|
|
||||||
|
#include <config.h>
|
||||||
|
|
||||||
|
#include "fs/readlink/readlinknul.h"
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
|
||||||
|
extern inline ssize_t readlinknul(const char *restrict link, char *restrict buf,
|
||||||
|
ssize_t size);
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
// SPDX-FileCopyrightText: 2024-2025, 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 <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,
|
||||||
|
ssize_t size);
|
||||||
|
|
||||||
|
|
||||||
|
// Similar to readlink(2), but terminate the string.
|
||||||
|
inline ssize_t
|
||||||
|
readlinknul(const char *restrict link, char *restrict buf, ssize_t size)
|
||||||
|
{
|
||||||
|
ssize_t len;
|
||||||
|
|
||||||
|
len = readlink(link, buf, size);
|
||||||
|
if (len == -1)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
if (len == size) {
|
||||||
|
stpcpy(&buf[size-1], "");
|
||||||
|
errno = E2BIG;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
stpcpy(&buf[len], "");
|
||||||
|
|
||||||
|
return len;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif // include guard
|
||||||
@@ -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
@@ -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)
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
+262
-504
File diff suppressed because it is too large
Load Diff
+29
-233
@@ -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/strcmp/streq.h"
|
||||||
|
#include "string/strspn/stpspn.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
|
||||||
@@ -90,8 +92,6 @@
|
|||||||
static int yylex (void);
|
static int yylex (void);
|
||||||
static int yyerror (const char *s);
|
static int yyerror (const char *s);
|
||||||
|
|
||||||
#define EPOCH 1970
|
|
||||||
#define HOUR(x) ((x) * 60)
|
|
||||||
|
|
||||||
#define MAX_BUFF_LEN 128 /* size of buffer to read the date into */
|
#define MAX_BUFF_LEN 128 /* size of buffer to read the date into */
|
||||||
|
|
||||||
@@ -126,8 +126,6 @@ static int yyHaveDate;
|
|||||||
static int yyHaveDay;
|
static int yyHaveDay;
|
||||||
static int yyHaveRel;
|
static int yyHaveRel;
|
||||||
static int yyHaveTime;
|
static int yyHaveTime;
|
||||||
static int yyHaveZone;
|
|
||||||
static int yyTimezone;
|
|
||||||
static int yyDay;
|
static int yyDay;
|
||||||
static int yyHour;
|
static int yyHour;
|
||||||
static int yyMinutes;
|
static int yyMinutes;
|
||||||
@@ -149,13 +147,13 @@ static int yyRelYear;
|
|||||||
enum _MERIDIAN Meridian;
|
enum _MERIDIAN Meridian;
|
||||||
}
|
}
|
||||||
|
|
||||||
%token tAGO tDAY tDAY_UNIT tDAYZONE tDST tHOUR_UNIT tID
|
%token tAGO tDAY tDAY_UNIT tHOUR_UNIT tID
|
||||||
%token tMERIDIAN tMINUTE_UNIT tMONTH tMONTH_UNIT
|
%token tMERIDIAN tMINUTE_UNIT tMONTH tMONTH_UNIT
|
||||||
%token tSEC_UNIT tSNUMBER tUNUMBER tYEAR_UNIT tZONE
|
%token tSEC_UNIT tSNUMBER tUNUMBER tYEAR_UNIT
|
||||||
|
|
||||||
%type <Number> tDAY tDAY_UNIT tDAYZONE tHOUR_UNIT tMINUTE_UNIT
|
%type <Number> tDAY tDAY_UNIT tHOUR_UNIT tMINUTE_UNIT
|
||||||
%type <Number> tMONTH tMONTH_UNIT
|
%type <Number> tMONTH tMONTH_UNIT
|
||||||
%type <Number> tSEC_UNIT tSNUMBER tUNUMBER tYEAR_UNIT tZONE
|
%type <Number> tSEC_UNIT tSNUMBER tUNUMBER tYEAR_UNIT
|
||||||
%type <Meridian> tMERIDIAN o_merid
|
%type <Meridian> tMERIDIAN o_merid
|
||||||
|
|
||||||
%%
|
%%
|
||||||
@@ -167,9 +165,6 @@ spec : /* NULL */
|
|||||||
item : time {
|
item : time {
|
||||||
yyHaveTime++;
|
yyHaveTime++;
|
||||||
}
|
}
|
||||||
| zone {
|
|
||||||
yyHaveZone++;
|
|
||||||
}
|
|
||||||
| date {
|
| date {
|
||||||
yyHaveDate++;
|
yyHaveDate++;
|
||||||
}
|
}
|
||||||
@@ -194,14 +189,10 @@ time : tUNUMBER tMERIDIAN {
|
|||||||
yySeconds = 0;
|
yySeconds = 0;
|
||||||
yyMeridian = $4;
|
yyMeridian = $4;
|
||||||
}
|
}
|
||||||
| tUNUMBER ':' tUNUMBER tSNUMBER {
|
| tUNUMBER ':' tUNUMBER {
|
||||||
yyHour = $1;
|
yyHour = $1;
|
||||||
yyMinutes = $3;
|
yyMinutes = $3;
|
||||||
yyMeridian = MER24;
|
yyMeridian = MER24;
|
||||||
yyHaveZone++;
|
|
||||||
yyTimezone = ($4 < 0
|
|
||||||
? -$4 % 100 + (-$4 / 100) * 60
|
|
||||||
: - ($4 % 100 + ($4 / 100) * 60));
|
|
||||||
}
|
}
|
||||||
| tUNUMBER ':' tUNUMBER ':' tUNUMBER o_merid {
|
| tUNUMBER ':' tUNUMBER ':' tUNUMBER o_merid {
|
||||||
yyHour = $1;
|
yyHour = $1;
|
||||||
@@ -209,27 +200,11 @@ time : tUNUMBER tMERIDIAN {
|
|||||||
yySeconds = $5;
|
yySeconds = $5;
|
||||||
yyMeridian = $6;
|
yyMeridian = $6;
|
||||||
}
|
}
|
||||||
| tUNUMBER ':' tUNUMBER ':' tUNUMBER tSNUMBER {
|
| tUNUMBER ':' tUNUMBER ':' tUNUMBER {
|
||||||
yyHour = $1;
|
yyHour = $1;
|
||||||
yyMinutes = $3;
|
yyMinutes = $3;
|
||||||
yySeconds = $5;
|
yySeconds = $5;
|
||||||
yyMeridian = MER24;
|
yyMeridian = MER24;
|
||||||
yyHaveZone++;
|
|
||||||
yyTimezone = ($6 < 0
|
|
||||||
? -$6 % 100 + (-$6 / 100) * 60
|
|
||||||
: - ($6 % 100 + ($6 / 100) * 60));
|
|
||||||
}
|
|
||||||
;
|
|
||||||
|
|
||||||
zone : tZONE {
|
|
||||||
yyTimezone = $1;
|
|
||||||
}
|
|
||||||
| tDAYZONE {
|
|
||||||
yyTimezone = $1 - 60;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
tZONE tDST {
|
|
||||||
yyTimezone = $1 - 60;
|
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@@ -482,91 +457,6 @@ static TABLE const OtherTable[] = {
|
|||||||
{ NULL, 0, 0 }
|
{ NULL, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
/* The timezone table. */
|
|
||||||
static TABLE const TimezoneTable[] = {
|
|
||||||
{ "gmt", tZONE, HOUR ( 0) }, /* Greenwich Mean */
|
|
||||||
{ "ut", tZONE, HOUR ( 0) }, /* Universal (Coordinated) */
|
|
||||||
{ "utc", tZONE, HOUR ( 0) },
|
|
||||||
{ "wet", tZONE, HOUR ( 0) }, /* Western European */
|
|
||||||
{ "bst", tDAYZONE, HOUR ( 0) }, /* British Summer */
|
|
||||||
{ "wat", tZONE, HOUR ( 1) }, /* West Africa */
|
|
||||||
{ "at", tZONE, HOUR ( 2) }, /* Azores */
|
|
||||||
{ "ast", tZONE, HOUR ( 4) }, /* Atlantic Standard */
|
|
||||||
{ "adt", tDAYZONE, HOUR ( 4) }, /* Atlantic Daylight */
|
|
||||||
{ "est", tZONE, HOUR ( 5) }, /* Eastern Standard */
|
|
||||||
{ "edt", tDAYZONE, HOUR ( 5) }, /* Eastern Daylight */
|
|
||||||
{ "cst", tZONE, HOUR ( 6) }, /* Central Standard */
|
|
||||||
{ "cdt", tDAYZONE, HOUR ( 6) }, /* Central Daylight */
|
|
||||||
{ "mst", tZONE, HOUR ( 7) }, /* Mountain Standard */
|
|
||||||
{ "mdt", tDAYZONE, HOUR ( 7) }, /* Mountain Daylight */
|
|
||||||
{ "pst", tZONE, HOUR ( 8) }, /* Pacific Standard */
|
|
||||||
{ "pdt", tDAYZONE, HOUR ( 8) }, /* Pacific Daylight */
|
|
||||||
{ "yst", tZONE, HOUR ( 9) }, /* Yukon Standard */
|
|
||||||
{ "ydt", tDAYZONE, HOUR ( 9) }, /* Yukon Daylight */
|
|
||||||
{ "hst", tZONE, HOUR (10) }, /* Hawaii Standard */
|
|
||||||
{ "hdt", tDAYZONE, HOUR (10) }, /* Hawaii Daylight */
|
|
||||||
{ "cat", tZONE, HOUR (10) }, /* Central Alaska */
|
|
||||||
{ "ahst", tZONE, HOUR (10) }, /* Alaska-Hawaii Standard */
|
|
||||||
{ "nt", tZONE, HOUR (11) }, /* Nome */
|
|
||||||
{ "idlw", tZONE, HOUR (12) }, /* International Date Line West */
|
|
||||||
{ "cet", tZONE, -HOUR (1) }, /* Central European */
|
|
||||||
{ "met", tZONE, -HOUR (1) }, /* Middle European */
|
|
||||||
{ "mewt", tZONE, -HOUR (1) }, /* Middle European Winter */
|
|
||||||
{ "mest", tDAYZONE, -HOUR (1) }, /* Middle European Summer */
|
|
||||||
{ "mesz", tDAYZONE, -HOUR (1) }, /* Middle European Summer */
|
|
||||||
{ "swt", tZONE, -HOUR (1) }, /* Swedish Winter */
|
|
||||||
{ "sst", tDAYZONE, -HOUR (1) }, /* Swedish Summer */
|
|
||||||
{ "fwt", tZONE, -HOUR (1) }, /* French Winter */
|
|
||||||
{ "fst", tDAYZONE, -HOUR (1) }, /* French Summer */
|
|
||||||
{ "eet", tZONE, -HOUR (2) }, /* Eastern Europe, USSR Zone 1 */
|
|
||||||
{ "bt", tZONE, -HOUR (3) }, /* Baghdad, USSR Zone 2 */
|
|
||||||
{ "zp4", tZONE, -HOUR (4) }, /* USSR Zone 3 */
|
|
||||||
{ "zp5", tZONE, -HOUR (5) }, /* USSR Zone 4 */
|
|
||||||
{ "zp6", tZONE, -HOUR (6) }, /* USSR Zone 5 */
|
|
||||||
{ "wast", tZONE, -HOUR (7) }, /* West Australian Standard */
|
|
||||||
{ "wadt", tDAYZONE, -HOUR (7) }, /* West Australian Daylight */
|
|
||||||
{ "cct", tZONE, -HOUR (8) }, /* China Coast, USSR Zone 7 */
|
|
||||||
{ "jst", tZONE, -HOUR (9) }, /* Japan Standard, USSR Zone 8 */
|
|
||||||
{ "east", tZONE, -HOUR (10) }, /* Eastern Australian Standard */
|
|
||||||
{ "eadt", tDAYZONE, -HOUR (10) }, /* Eastern Australian Daylight */
|
|
||||||
{ "gst", tZONE, -HOUR (10) }, /* Guam Standard, USSR Zone 9 */
|
|
||||||
{ "nzt", tZONE, -HOUR (12) }, /* New Zealand */
|
|
||||||
{ "nzst", tZONE, -HOUR (12) }, /* New Zealand Standard */
|
|
||||||
{ "nzdt", tDAYZONE, -HOUR (12) }, /* New Zealand Daylight */
|
|
||||||
{ "idle", tZONE, -HOUR (12) }, /* International Date Line East */
|
|
||||||
{ NULL, 0, 0 }
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Military timezone table. */
|
|
||||||
static TABLE const MilitaryTable[] = {
|
|
||||||
{ "a", tZONE, HOUR ( 1) },
|
|
||||||
{ "b", tZONE, HOUR ( 2) },
|
|
||||||
{ "c", tZONE, HOUR ( 3) },
|
|
||||||
{ "d", tZONE, HOUR ( 4) },
|
|
||||||
{ "e", tZONE, HOUR ( 5) },
|
|
||||||
{ "f", tZONE, HOUR ( 6) },
|
|
||||||
{ "g", tZONE, HOUR ( 7) },
|
|
||||||
{ "h", tZONE, HOUR ( 8) },
|
|
||||||
{ "i", tZONE, HOUR ( 9) },
|
|
||||||
{ "k", tZONE, HOUR ( 10) },
|
|
||||||
{ "l", tZONE, HOUR ( 11) },
|
|
||||||
{ "m", tZONE, HOUR ( 12) },
|
|
||||||
{ "n", tZONE, HOUR (- 1) },
|
|
||||||
{ "o", tZONE, HOUR (- 2) },
|
|
||||||
{ "p", tZONE, HOUR (- 3) },
|
|
||||||
{ "q", tZONE, HOUR (- 4) },
|
|
||||||
{ "r", tZONE, HOUR (- 5) },
|
|
||||||
{ "s", tZONE, HOUR (- 6) },
|
|
||||||
{ "t", tZONE, HOUR (- 7) },
|
|
||||||
{ "u", tZONE, HOUR (- 8) },
|
|
||||||
{ "v", tZONE, HOUR (- 9) },
|
|
||||||
{ "w", tZONE, HOUR (-10) },
|
|
||||||
{ "x", tZONE, HOUR (-11) },
|
|
||||||
{ "y", tZONE, HOUR (-12) },
|
|
||||||
{ "z", tZONE, HOUR ( 0) },
|
|
||||||
{ NULL, 0, 0 }
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -619,22 +509,21 @@ static int ToYear (int Year)
|
|||||||
static int LookupWord (char *buff)
|
static int LookupWord (char *buff)
|
||||||
{
|
{
|
||||||
register char *p;
|
register char *p;
|
||||||
register char *q;
|
|
||||||
register const TABLE *tp;
|
register const TABLE *tp;
|
||||||
int i;
|
int i;
|
||||||
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 +535,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,25 +550,15 @@ 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (tp = TimezoneTable; tp->name; tp++)
|
|
||||||
if (strcmp (buff, tp->name) == 0)
|
|
||||||
{
|
|
||||||
yylval.Number = tp->value;
|
|
||||||
return tp->type;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (strcmp (buff, "dst") == 0)
|
|
||||||
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 +568,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,38 +579,12 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Military timezones. */
|
|
||||||
if (buff[1] == '\0' && isalpha (*buff))
|
|
||||||
{
|
|
||||||
for (tp = MilitaryTable; tp->name; tp++)
|
|
||||||
if (strcmp (buff, tp->name) == 0)
|
|
||||||
{
|
|
||||||
yylval.Number = tp->value;
|
|
||||||
return tp->type;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Drop out any periods and try the timezone table again. */
|
|
||||||
for (i = 0, p = q = buff; '\0' != *q; q++)
|
|
||||||
if (*q != '.')
|
|
||||||
*p++ = *q;
|
|
||||||
else
|
|
||||||
i++;
|
|
||||||
*p = '\0';
|
|
||||||
if (0 != i)
|
|
||||||
for (tp = TimezoneTable; NULL != tp->name; tp++)
|
|
||||||
if (strcmp (buff, tp->name) == 0)
|
|
||||||
{
|
|
||||||
yylval.Number = tp->value;
|
|
||||||
return tp->type;
|
|
||||||
}
|
|
||||||
|
|
||||||
return tID;
|
return tID;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -746,8 +599,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 +624,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);
|
||||||
}
|
}
|
||||||
@@ -795,34 +647,14 @@ yylex (void)
|
|||||||
|
|
||||||
#define TM_YEAR_ORIGIN 1900
|
#define TM_YEAR_ORIGIN 1900
|
||||||
|
|
||||||
/* Yield A - B, measured in seconds. */
|
|
||||||
static long difftm (struct tm *a, struct tm *b)
|
|
||||||
{
|
|
||||||
int ay = a->tm_year + (TM_YEAR_ORIGIN - 1);
|
|
||||||
int by = b->tm_year + (TM_YEAR_ORIGIN - 1);
|
|
||||||
long days = (
|
|
||||||
/* difference in day of year */
|
|
||||||
a->tm_yday - b->tm_yday
|
|
||||||
/* + intervening leap days */
|
|
||||||
+ ((ay >> 2) - (by >> 2))
|
|
||||||
- (ay / 100 - by / 100)
|
|
||||||
+ ((ay / 100 >> 2) - (by / 100 >> 2))
|
|
||||||
/* + difference in years * 365 */
|
|
||||||
+ (long) (ay - by) * 365
|
|
||||||
);
|
|
||||||
return (60 * (60 * (24 * days + (a->tm_hour - b->tm_hour))
|
|
||||||
+ (a->tm_min - b->tm_min))
|
|
||||||
+ (a->tm_sec - b->tm_sec));
|
|
||||||
}
|
|
||||||
|
|
||||||
time_t get_date (const char *p, const time_t *now)
|
time_t get_date (const char *p, const time_t *now)
|
||||||
{
|
{
|
||||||
struct tm tm, tm0, *tmp;
|
struct tm tm, *tmp;
|
||||||
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 = gmtime(&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;
|
||||||
yyDay = tmp->tm_mday;
|
yyDay = tmp->tm_mday;
|
||||||
@@ -840,10 +672,9 @@ time_t get_date (const char *p, const time_t *now)
|
|||||||
yyHaveDay = 0;
|
yyHaveDay = 0;
|
||||||
yyHaveRel = 0;
|
yyHaveRel = 0;
|
||||||
yyHaveTime = 0;
|
yyHaveTime = 0;
|
||||||
yyHaveZone = 0;
|
|
||||||
|
|
||||||
if (yyparse ()
|
if (yyparse ()
|
||||||
|| yyHaveTime > 1 || yyHaveZone > 1 || yyHaveDate > 1 || yyHaveDay > 1)
|
|| yyHaveTime > 1 || yyHaveDate > 1 || yyHaveDay > 1)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
tm.tm_year = ToYear (yyYear) - TM_YEAR_ORIGIN + yyRelYear;
|
tm.tm_year = ToYear (yyYear) - TM_YEAR_ORIGIN + yyRelYear;
|
||||||
@@ -865,39 +696,12 @@ time_t get_date (const char *p, const time_t *now)
|
|||||||
tm.tm_hour += yyRelHour;
|
tm.tm_hour += yyRelHour;
|
||||||
tm.tm_min += yyRelMinutes;
|
tm.tm_min += yyRelMinutes;
|
||||||
tm.tm_sec += yyRelSeconds;
|
tm.tm_sec += yyRelSeconds;
|
||||||
tm.tm_isdst = -1;
|
tm.tm_isdst = 0;
|
||||||
tm0 = tm;
|
|
||||||
|
|
||||||
Start = mktime (&tm);
|
Start = timegm(&tm);
|
||||||
|
|
||||||
if (Start == (time_t) -1)
|
if (Start == (time_t) -1)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* Guard against falsely reporting errors near the time_t boundaries
|
|
||||||
when parsing times in other time zones. For example, if the min
|
|
||||||
time_t value is 1970-01-01 00:00:00 UTC and we are 8 hours ahead
|
|
||||||
of UTC, then the min localtime value is 1970-01-01 08:00:00; if
|
|
||||||
we apply mktime to 1970-01-01 00:00:00 we will get an error, so
|
|
||||||
we apply mktime to 1970-01-02 08:00:00 instead and adjust the time
|
|
||||||
zone by 24 hours to compensate. This algorithm assumes that
|
|
||||||
there is no DST transition within a day of the time_t boundaries. */
|
|
||||||
if (yyHaveZone)
|
|
||||||
{
|
|
||||||
tm = tm0;
|
|
||||||
if (tm.tm_year <= EPOCH - TM_YEAR_ORIGIN)
|
|
||||||
{
|
|
||||||
tm.tm_mday++;
|
|
||||||
yyTimezone -= 24 * 60;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tm.tm_mday--;
|
|
||||||
yyTimezone += 24 * 60;
|
|
||||||
}
|
|
||||||
Start = mktime (&tm);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Start == (time_t) -1)
|
|
||||||
return Start;
|
return Start;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -905,19 +709,11 @@ time_t get_date (const char *p, const time_t *now)
|
|||||||
{
|
{
|
||||||
tm.tm_mday += ((yyDayNumber - tm.tm_wday + 7) % 7
|
tm.tm_mday += ((yyDayNumber - tm.tm_wday + 7) % 7
|
||||||
+ 7 * (yyDayOrdinal - (0 < yyDayOrdinal)));
|
+ 7 * (yyDayOrdinal - (0 < yyDayOrdinal)));
|
||||||
Start = mktime (&tm);
|
Start = timegm(&tm);
|
||||||
if (Start == (time_t) -1)
|
if (Start == (time_t) -1)
|
||||||
return Start;
|
return Start;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (yyHaveZone)
|
|
||||||
{
|
|
||||||
long delta = yyTimezone * 60L + difftm (&tm, gmtime (&Start));
|
|
||||||
if ((Start + delta < Start) != (delta < 0))
|
|
||||||
return -1; /* time_t overflow */
|
|
||||||
Start += delta;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Start;
|
return Start;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -935,7 +731,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
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user