From 6c3ea4f47ea280811a7fe53a22f7832e4533c9ec Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 26 Jun 2024 18:18:36 +0200 Subject: Adding upstream version 1:4.15.2. Signed-off-by: Daniel Baumann --- lib/defines.h | 183 ++++++++++------------------------------------------------ 1 file changed, 30 insertions(+), 153 deletions(-) (limited to 'lib/defines.h') diff --git a/lib/defines.h b/lib/defines.h index d01f691..8c55ddd 100644 --- a/lib/defines.h +++ b/lib/defines.h @@ -6,41 +6,8 @@ #include "config.h" -#if HAVE_STDBOOL_H -# include -#else -# if ! HAVE__BOOL -# ifdef __cplusplus -typedef bool _Bool; -# else -typedef unsigned char _Bool; -# endif -# endif -# define bool _Bool -# define false (0) -# define true (1) -# define __bool_true_false_are_defined 1 -#endif - -/* Take care of NLS matters. */ -#ifdef S_SPLINT_S -extern char *setlocale(int categories, const char *locale); -# define LC_ALL (6) -extern char * bindtextdomain (const char * domainname, const char * dirname); -extern char * textdomain (const char * domainname); -# define _(Text) Text -# define ngettext(Msgid1, Msgid2, N) \ - ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) -#else -#ifdef HAVE_LOCALE_H -# include -#else -# undef setlocale -# define setlocale(category, locale) (NULL) -# ifndef LC_ALL -# define LC_ALL 6 -# endif -#endif +#include +#include #define gettext_noop(String) (String) /* #define gettext_def(String) "#define String" */ @@ -57,22 +24,18 @@ extern char * textdomain (const char * domainname); # define ngettext(Msgid1, Msgid2, N) \ ((N) == 1 ? (const char *) (Msgid1) : (const char *) (Msgid2)) #endif -#endif +#include #include #include -#if HAVE_ERRNO_H -# include -#endif +#include #include #include #include -#if HAVE_UNISTD_H -# include -#endif +#include /* * crypt(3), crypt_gensalt(3), and their @@ -85,22 +48,6 @@ extern char * textdomain (const char * domainname); #include #include -#ifdef HAVE_MEMSET_S -# define memzero(ptr, size) memset_s((ptr), 0, (size)) -#elif defined HAVE_EXPLICIT_BZERO /* !HAVE_MEMSET_S */ -# define memzero(ptr, size) explicit_bzero((ptr), (size)) -#else /* !HAVE_MEMSET_S && HAVE_EXPLICIT_BZERO */ -static inline void memzero(void *ptr, size_t size) -{ - volatile unsigned char * volatile p = ptr; - while (size--) { - *p++ = '\0'; - } -} -#endif /* !HAVE_MEMSET_S && !HAVE_EXPLICIT_BZERO */ - -#define strzero(s) memzero(s, strlen(s)) /* warning: evaluates twice */ - #include /* @@ -123,7 +70,6 @@ static inline void memzero(void *ptr, size_t size) #endif #endif -#ifdef USE_SYSLOG #include #ifndef LOG_WARN @@ -170,14 +116,6 @@ static inline void memzero(void *ptr, size_t size) #define SYSLOG(x) syslog x #endif /* !ENABLE_NLS */ -#else /* !USE_SYSLOG */ - -#define SYSLOG(x) /* empty */ -#define openlog(a,b,c) /* empty */ -#define closelog() /* empty */ - -#endif /* !USE_SYSLOG */ - /* The default syslog settings can now be changed here, in just one place. */ @@ -192,63 +130,25 @@ static inline void memzero(void *ptr, size_t size) #define OPENLOG(progname) openlog(progname, SYSLOG_OPTIONS, SYSLOG_FACILITY) -#ifndef F_OK -# define F_OK 0 -# define X_OK 1 -# define W_OK 2 -# define R_OK 4 -#endif - -#ifndef SEEK_SET -# define SEEK_SET 0 -# define SEEK_CUR 1 -# define SEEK_END 2 -#endif - -#if HAVE_TERMIOS_H -# include -# define STTY(fd, termio) tcsetattr(fd, TCSANOW, termio) -# define GTTY(fd, termio) tcgetattr(fd, termio) -# define TERMIO struct termios -# define USE_TERMIOS -#else /* assumed HAVE_TERMIO_H */ -# include -# include -# define STTY(fd, termio) ioctl(fd, TCSETA, termio) -# define GTTY(fd, termio) ioctl(fd, TCGETA, termio) -# define TEMRIO struct termio -# define USE_TERMIO -#endif +#include +#define STTY(fd, termio) tcsetattr(fd, TCSANOW, termio) +#define GTTY(fd, termio) tcgetattr(fd, termio) +#define TERMIO struct termios /* * Password aging constants * * DAY - seconds / day * WEEK - seconds / week - * SCALE - seconds / aging unit */ /* Solaris defines this in shadow.h */ #ifndef DAY -#define DAY (24L*3600L) +#define DAY ((time_t) 24 * 3600) #endif #define WEEK (7*DAY) -#ifdef ITI_AGING -#define SCALE 1 -#else -#define SCALE DAY -#endif - -/* Copy string pointed by B to array A with size checking. It was originally - in lmain.c but is _very_ useful elsewhere. Some setuid root programs with - very sloppy coding used to assume that BUFSIZ will always be enough... */ - - /* danger - side effects */ -#define STRFCPY(A,B) \ - (strncpy((A), (B), sizeof(A) - 1), (A)[sizeof(A) - 1] = '\0') - #ifndef PASSWD_FILE #define PASSWD_FILE "/etc/passwd" #endif @@ -261,22 +161,18 @@ static inline void memzero(void *ptr, size_t size) #define SHADOW_FILE "/etc/shadow" #endif -#ifdef SHADOWGRP -#ifndef SGROUP_FILE -#define SGROUP_FILE "/etc/gshadow" -#endif +#ifndef SUBUID_FILE +#define SUBUID_FILE "/etc/subuid" #endif -#ifndef NULL -#define NULL ((void *) 0) +#ifndef SUBGID_FILE +#define SUBGID_FILE "/etc/subgid" #endif -#ifdef sun /* hacks for compiling on SunOS */ -# ifndef SOLARIS -extern int fputs (); -extern char *strdup (); -extern char *strerror (); -# endif +#ifdef SHADOWGRP +#ifndef SGROUP_FILE +#define SGROUP_FILE "/etc/gshadow" +#endif #endif /* @@ -288,45 +184,16 @@ extern char *strerror (); #define SHADOW_PASSWD_STRING "x" #endif -#define SHADOW_SP_FLAG_UNSET ((unsigned long int)-1) +#define SHADOW_SP_FLAG_UNSET ((unsigned long)-1) #ifdef WITH_AUDIT -#ifdef __u8 /* in case we use pam < 0.80 */ +/* in case we use pam < 0.80 */ #undef __u8 -#endif -#ifdef __u32 #undef __u32 -#endif #include #endif -/* To be used for verified unused parameters */ -#if defined(__GNUC__) && !defined(__STRICT_ANSI__) -# define unused __attribute__((unused)) -# define format_attr(type, index, check) __attribute__((format (type, index, check))) -#else -# define unused -# define format_attr(type, index, check) -#endif - -/* Maximum length of usernames */ -#ifdef HAVE_UTMPX_H -# include -# define USER_NAME_MAX_LENGTH (sizeof (((struct utmpx *)NULL)->ut_user)) -#else -# include -# ifdef HAVE_STRUCT_UTMP_UT_USER -# define USER_NAME_MAX_LENGTH (sizeof (((struct utmp *)NULL)->ut_user)) -# else -# ifdef HAVE_STRUCT_UTMP_UT_NAME -# define USER_NAME_MAX_LENGTH (sizeof (((struct utmp *)NULL)->ut_name)) -# else -# define USER_NAME_MAX_LENGTH 32 -# endif -# endif -#endif - /* Maximum length of passwd entry */ #define PASSWD_ENTRY_MAX_LENGTH 32768 @@ -336,4 +203,14 @@ extern char *strerror (); # define shadow_getenv(name) getenv(name) #endif +/* + * Maximum password length + * + * Consider that there is also limit in PAM (PAM_MAX_RESP_SIZE) + * currently set to 512. + */ +#if !defined(PASS_MAX) +#define PASS_MAX BUFSIZ - 1 +#endif + #endif /* _DEFINES_H_ */ -- cgit v1.2.3