From f730cb78736644a50fb05610f7a0b764ce26fdcb Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Wed, 31 Aug 2011 11:19:10 -0400 Subject: [PATCH] Assume all modern systems support fstat(2). --- config.h.in | 3 --- configure | 2 +- configure.in | 2 +- plugins/sudoers/visudo.c | 15 +-------------- src/sudo_edit.c | 12 ------------ 5 files changed, 3 insertions(+), 31 deletions(-) diff --git a/config.h.in b/config.h.in index d0945540a..c49bb5e3e 100644 --- a/config.h.in +++ b/config.h.in @@ -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 diff --git a/configure b/configure index d58a8df98..fe6365f93 100755 --- a/configure +++ b/configure @@ -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 : diff --git a/configure.in b/configure.in index d0ce291b5..762057852 100644 --- a/configure.in +++ b/configure.in @@ -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) diff --git a/plugins/sudoers/visudo.c b/plugins/sudoers/visudo.c index 5bdb2fc59..e37f6d50f 100644 --- a/plugins/sudoers/visudo.c +++ b/plugins/sudoers/visudo.c @@ -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) { diff --git a/src/sudo_edit.c b/src/sudo_edit.c index 0a4d511f8..af7f07192 100644 --- a/src/sudo_edit.c +++ b/src/sudo_edit.c @@ -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)"); -- 2.40.0