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. */
#undef HAVE_FREEIFADDRS
/* Define to 1 if you have the `fstat' function. */
#undef HAVE_FSTAT
/* Define to 1 if you have the `futime' function. */
#undef HAVE_FUTIME

2
configure vendored
View File

@@ -16267,7 +16267,7 @@ $as_echo "#define HAVE_GETGROUPS 1" >>confdefs.h
fi
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 \
setrlimit64 sysctl
do :

View File

@@ -2087,7 +2087,7 @@ dnl
dnl Function checks
dnl
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 \
setrlimit64 sysctl)
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 */
struct stat sb; /* stat buffer */
#ifdef HAVE_FSTAT
if (fstat(sp->fd, &sb) == -1)
#else
if (stat(sp->path, &sb) == -1)
#endif
error(1, _("unable to stat %s"), sp->path);
orig_size = sb.st_size;
mtim_get(&sb, &orig_mtim);
@@ -544,11 +540,7 @@ install_sudoers(struct sudoersfile *sp, int oldperms)
*/
if (oldperms) {
/* Use perms of the existing file. */
#ifdef HAVE_FSTAT
if (fstat(sp->fd, &sb) == -1)
#else
if (stat(sp->path, &sb) == -1)
#endif
error(1, _("unable to stat %s"), sp->path);
if (chown(sp->tpath, sb.st_uid, sb.st_gid) != 0) {
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. */
#ifdef HAVE_FSTAT
if (strict && yyin != stdin && fstat(fileno(yyin), &sb) == 0)
#else
if (strict && yyin != stdin && stat(sudoers_path, &sb) == 0)
#endif
{
if (strict && yyin != stdin && fstat(fileno(yyin), &sb) == 0) {
if (sb.st_uid != SUDOERS_UID || sb.st_gid != SUDOERS_GID) {
error = TRUE;
if (!quiet) {

View File

@@ -156,11 +156,7 @@ sudo_edit(struct command_details *command_details)
zero_bytes(&sb, sizeof(sb)); /* new file */
rc = 0;
} else {
#ifdef HAVE_FSTAT
rc = fstat(ofd, &sb);
#else
rc = stat(tf[j].ofile, &sb);
#endif
}
}
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.
*/
(void) touch(tfd, NULL, &tf[j].omtim);
#ifdef HAVE_FSTAT
rc = fstat(tfd, &sb);
#else
rc = stat(tf[j].tfile, &sb);
#endif
if (!rc)
mtim_get(&sb, &tf[j].omtim);
close(tfd);
@@ -265,11 +257,7 @@ sudo_edit(struct command_details *command_details)
if (seteuid(user_details.uid) != 0)
error(1, "seteuid(%d)", (int)user_details.uid);
if ((tfd = open(tf[i].tfile, O_RDONLY, 0644)) != -1) {
#ifdef HAVE_FSTAT
rc = fstat(tfd, &sb);
#else
rc = stat(tf[i].tfile, &sb);
#endif
}
if (seteuid(ROOT_UID) != 0)
error(1, "seteuid(ROOT_UID)");