Use fseeko() for legacy utmp handling if available.
This commit is contained in:
@@ -149,6 +149,9 @@
|
|||||||
/* 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 `fseeko' function. */
|
||||||
|
#undef HAVE_FSEEKO
|
||||||
|
|
||||||
/* Define to 1 if you have the `futime' function. */
|
/* Define to 1 if you have the `futime' function. */
|
||||||
#undef HAVE_FUTIME
|
#undef HAVE_FUTIME
|
||||||
|
|
||||||
|
11
configure
vendored
11
configure
vendored
@@ -16710,6 +16710,17 @@ if eval test \"x\$"$as_ac_var"\" = x"yes"; then :
|
|||||||
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
|
#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
|
||||||
_ACEOF
|
_ACEOF
|
||||||
break
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
for ac_func in fseeko
|
||||||
|
do :
|
||||||
|
ac_fn_c_check_func "$LINENO" "fseeko" "ac_cv_func_fseeko"
|
||||||
|
if test "x$ac_cv_func_fseeko" = xyes; then :
|
||||||
|
cat >>confdefs.h <<_ACEOF
|
||||||
|
#define HAVE_FSEEKO 1
|
||||||
|
_ACEOF
|
||||||
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@@ -2213,6 +2213,7 @@ utmp_style=LEGACY
|
|||||||
AC_CHECK_FUNCS(getutxid getutid, [utmp_style=POSIX; break])
|
AC_CHECK_FUNCS(getutxid getutid, [utmp_style=POSIX; break])
|
||||||
if test "$utmp_style" = "LEGACY"; then
|
if test "$utmp_style" = "LEGACY"; then
|
||||||
AC_CHECK_FUNCS(getttyent ttyslot, [break])
|
AC_CHECK_FUNCS(getttyent ttyslot, [break])
|
||||||
|
AC_CHECK_FUNCS(fseeko)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
AC_CHECK_FUNCS(sysctl, [AC_CHECK_MEMBERS([struct kinfo_proc.ki_tdev], [],
|
AC_CHECK_FUNCS(sysctl, [AC_CHECK_MEMBERS([struct kinfo_proc.ki_tdev], [],
|
||||||
|
@@ -328,7 +328,11 @@ utmp_login(const char *from_line, const char *to_line, int ttyfd,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
utmp_fill(to_line, user, ut_old, &utbuf);
|
utmp_fill(to_line, user, ut_old, &utbuf);
|
||||||
|
#ifdef HAVE_FSEEKO
|
||||||
|
if (fseeko(fp, slot * (off_t)sizeof(utbuf), SEEK_SET) == 0) {
|
||||||
|
#else
|
||||||
if (fseek(fp, slot * (long)sizeof(utbuf), SEEK_SET) == 0) {
|
if (fseek(fp, slot * (long)sizeof(utbuf), SEEK_SET) == 0) {
|
||||||
|
#endif
|
||||||
if (fwrite(&utbuf, sizeof(utbuf), 1, fp) == 1)
|
if (fwrite(&utbuf, sizeof(utbuf), 1, fp) == 1)
|
||||||
rval = true;
|
rval = true;
|
||||||
}
|
}
|
||||||
@@ -361,7 +365,11 @@ utmp_logout(const char *line, int status)
|
|||||||
# endif
|
# endif
|
||||||
utmp_settime(&utbuf);
|
utmp_settime(&utbuf);
|
||||||
/* Back up and overwrite record. */
|
/* Back up and overwrite record. */
|
||||||
|
#ifdef HAVE_FSEEKO
|
||||||
|
if (fseeko(fp, (off_t)0 - (off_t)sizeof(utbuf), SEEK_CUR) == 0) {
|
||||||
|
#else
|
||||||
if (fseek(fp, 0L - (long)sizeof(utbuf), SEEK_CUR) == 0) {
|
if (fseek(fp, 0L - (long)sizeof(utbuf), SEEK_CUR) == 0) {
|
||||||
|
#endif
|
||||||
if (fwrite(&utbuf, sizeof(utbuf), 1, fp) == 1)
|
if (fwrite(&utbuf, sizeof(utbuf), 1, fp) == 1)
|
||||||
rval = true;
|
rval = true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user