Remove compatibility defines for POSIX sys/stat.h macros.

Modern systems have them and we no longer support pre-POSIX systems.
This fixes potential redefinition of the macros if sys/stat.h is
included after sudo_compat.h.  Bug #968.
This commit is contained in:
Todd C. Miller
2021-03-10 12:26:11 -07:00
parent 3f11e8d9a6
commit d9d450292d
2 changed files with 6 additions and 42 deletions

View File

@@ -146,48 +146,12 @@
# endif
#endif
/*
* POSIX versions for those without...
*/
#ifndef _S_IFMT
# define _S_IFMT S_IFMT
#endif /* _S_IFMT */
#ifndef _S_IFREG
# define _S_IFREG S_IFREG
#endif /* _S_IFREG */
#ifndef _S_IFDIR
# define _S_IFDIR S_IFDIR
#endif /* _S_IFDIR */
#ifndef _S_IFLNK
# define _S_IFLNK S_IFLNK
#endif /* _S_IFLNK */
#ifndef _S_IFIFO
# define _S_IFIFO S_IFIFO
#endif /* _S_IFIFO */
#ifndef S_ISREG
# define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG)
#endif /* S_ISREG */
#ifndef S_ISDIR
# define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR)
#endif /* S_ISDIR */
#ifndef S_ISLNK
# define S_ISLNK(m) (((m) & _S_IFMT) == _S_IFLNK)
#endif /* S_ISLNK */
#ifndef S_ISFIFO
# define S_ISFIFO(m) (((m) & _S_IFMT) == _S_IFIFO)
#endif /* S_ISLNK */
#ifndef S_ISTXT
# define S_ISTXT 0001000
#endif /* S_ISTXT */
/*
* ACCESSPERMS (00777) and ALLPERMS (07777) are handy BSDisms
*/
/* ACCESSPERMS and ALLPERMS are handy BSDisms. */
#ifndef ACCESSPERMS
# define ACCESSPERMS (S_IRWXU|S_IRWXG|S_IRWXO)
# define ACCESSPERMS 00777
#endif /* ACCESSPERMS */
#ifndef ALLPERMS
# define ALLPERMS (S_ISUID|S_ISGID|S_ISTXT|S_IRWXU|S_IRWXG|S_IRWXO)
# define ALLPERMS 07777
#endif /* ALLPERMS */
/* For futimens() and utimensat() emulation. */

View File

@@ -41,7 +41,7 @@ sudo_secure_path(const char *path, unsigned int type, uid_t uid, gid_t gid, stru
debug_decl(sudo_secure_path, SUDO_DEBUG_UTIL);
if (path != NULL && stat(path, &sb) == 0) {
if ((sb.st_mode & _S_IFMT) != type) {
if ((sb.st_mode & S_IFMT) != type) {
ret = SUDO_PATH_BAD_TYPE;
} else if (uid != (uid_t)-1 && sb.st_uid != uid) {
ret = SUDO_PATH_WRONG_OWNER;
@@ -66,7 +66,7 @@ sudo_secure_path(const char *path, unsigned int type, uid_t uid, gid_t gid, stru
int
sudo_secure_file_v1(const char *path, uid_t uid, gid_t gid, struct stat *sbp)
{
return sudo_secure_path(path, _S_IFREG, uid, gid, sbp);
return sudo_secure_path(path, S_IFREG, uid, gid, sbp);
}
/*
@@ -75,5 +75,5 @@ sudo_secure_file_v1(const char *path, uid_t uid, gid_t gid, struct stat *sbp)
int
sudo_secure_dir_v1(const char *path, uid_t uid, gid_t gid, struct stat *sbp)
{
return sudo_secure_path(path, _S_IFDIR, uid, gid, sbp);
return sudo_secure_path(path, S_IFDIR, uid, gid, sbp);
}