Assume all modern systems support fstat(2).

This commit is contained in:
Todd C. Miller
2011-08-31 11:19:10 -04:00
parent 47af0fc2b8
commit f730cb7873
5 changed files with 3 additions and 31 deletions

View File

@@ -129,9 +129,6 @@
/* Define to 1 if you have the `freeifaddrs' function. */ /* Define to 1 if you have the `freeifaddrs' function. */
#undef HAVE_FREEIFADDRS #undef HAVE_FREEIFADDRS
/* Define to 1 if you have the `fstat' function. */
#undef HAVE_FSTAT
/* Define to 1 if you have the `futime' function. */ /* Define to 1 if you have the `futime' function. */
#undef HAVE_FUTIME #undef HAVE_FUTIME

2
configure vendored
View File

@@ -16267,7 +16267,7 @@ $as_echo "#define HAVE_GETGROUPS 1" >>confdefs.h
fi fi
LIBS=$ac_save_LIBS LIBS=$ac_save_LIBS
for ac_func in strrchr sysconf tzset strftime fstat \ for ac_func in strrchr sysconf tzset strftime \
regcomp setlocale nl_langinfo getaddrinfo mbr_check_membership \ regcomp setlocale nl_langinfo getaddrinfo mbr_check_membership \
setrlimit64 sysctl setrlimit64 sysctl
do : do :

View File

@@ -2087,7 +2087,7 @@ dnl
dnl Function checks dnl Function checks
dnl dnl
AC_FUNC_GETGROUPS AC_FUNC_GETGROUPS
AC_CHECK_FUNCS(strrchr sysconf tzset strftime fstat \ AC_CHECK_FUNCS(strrchr sysconf tzset strftime \
regcomp setlocale nl_langinfo getaddrinfo mbr_check_membership \ regcomp setlocale nl_langinfo getaddrinfo mbr_check_membership \
setrlimit64 sysctl) setrlimit64 sysctl)
AC_REPLACE_FUNCS(getgrouplist) AC_REPLACE_FUNCS(getgrouplist)

View File

@@ -300,11 +300,7 @@ edit_sudoers(struct sudoersfile *sp, char *editor, char *args, int lineno)
ssize_t nread; /* number of bytes read */ ssize_t nread; /* number of bytes read */
struct stat sb; /* stat buffer */ struct stat sb; /* stat buffer */
#ifdef HAVE_FSTAT
if (fstat(sp->fd, &sb) == -1) if (fstat(sp->fd, &sb) == -1)
#else
if (stat(sp->path, &sb) == -1)
#endif
error(1, _("unable to stat %s"), sp->path); error(1, _("unable to stat %s"), sp->path);
orig_size = sb.st_size; orig_size = sb.st_size;
mtim_get(&sb, &orig_mtim); mtim_get(&sb, &orig_mtim);
@@ -544,11 +540,7 @@ install_sudoers(struct sudoersfile *sp, int oldperms)
*/ */
if (oldperms) { if (oldperms) {
/* Use perms of the existing file. */ /* Use perms of the existing file. */
#ifdef HAVE_FSTAT
if (fstat(sp->fd, &sb) == -1) if (fstat(sp->fd, &sb) == -1)
#else
if (stat(sp->path, &sb) == -1)
#endif
error(1, _("unable to stat %s"), sp->path); error(1, _("unable to stat %s"), sp->path);
if (chown(sp->tpath, sb.st_uid, sb.st_gid) != 0) { if (chown(sp->tpath, sb.st_uid, sb.st_gid) != 0) {
warning(_("unable to set (uid, gid) of %s to (%u, %u)"), warning(_("unable to set (uid, gid) of %s to (%u, %u)"),
@@ -776,12 +768,7 @@ check_syntax(char *sudoers_path, int quiet, int strict)
} }
} }
/* Check mode and owner in strict mode. */ /* Check mode and owner in strict mode. */
#ifdef HAVE_FSTAT if (strict && yyin != stdin && fstat(fileno(yyin), &sb) == 0) {
if (strict && yyin != stdin && fstat(fileno(yyin), &sb) == 0)
#else
if (strict && yyin != stdin && stat(sudoers_path, &sb) == 0)
#endif
{
if (sb.st_uid != SUDOERS_UID || sb.st_gid != SUDOERS_GID) { if (sb.st_uid != SUDOERS_UID || sb.st_gid != SUDOERS_GID) {
error = TRUE; error = TRUE;
if (!quiet) { if (!quiet) {

View File

@@ -156,11 +156,7 @@ sudo_edit(struct command_details *command_details)
zero_bytes(&sb, sizeof(sb)); /* new file */ zero_bytes(&sb, sizeof(sb)); /* new file */
rc = 0; rc = 0;
} else { } else {
#ifdef HAVE_FSTAT
rc = fstat(ofd, &sb); rc = fstat(ofd, &sb);
#else
rc = stat(tf[j].ofile, &sb);
#endif
} }
} }
switch_user(ROOT_UID, user_details.egid, switch_user(ROOT_UID, user_details.egid,
@@ -217,11 +213,7 @@ sudo_edit(struct command_details *command_details)
* to determine whether or not a file has been modified. * to determine whether or not a file has been modified.
*/ */
(void) touch(tfd, NULL, &tf[j].omtim); (void) touch(tfd, NULL, &tf[j].omtim);
#ifdef HAVE_FSTAT
rc = fstat(tfd, &sb); rc = fstat(tfd, &sb);
#else
rc = stat(tf[j].tfile, &sb);
#endif
if (!rc) if (!rc)
mtim_get(&sb, &tf[j].omtim); mtim_get(&sb, &tf[j].omtim);
close(tfd); close(tfd);
@@ -265,11 +257,7 @@ sudo_edit(struct command_details *command_details)
if (seteuid(user_details.uid) != 0) if (seteuid(user_details.uid) != 0)
error(1, "seteuid(%d)", (int)user_details.uid); error(1, "seteuid(%d)", (int)user_details.uid);
if ((tfd = open(tf[i].tfile, O_RDONLY, 0644)) != -1) { if ((tfd = open(tf[i].tfile, O_RDONLY, 0644)) != -1) {
#ifdef HAVE_FSTAT
rc = fstat(tfd, &sb); rc = fstat(tfd, &sb);
#else
rc = stat(tf[i].tfile, &sb);
#endif
} }
if (seteuid(ROOT_UID) != 0) if (seteuid(ROOT_UID) != 0)
error(1, "seteuid(ROOT_UID)"); error(1, "seteuid(ROOT_UID)");