Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc update and stop setting MAGIC_PRESERVE_ATIME #2335

Merged
merged 2 commits into from
Aug 23, 2023

Conversation

pqarmitage
Copy link
Collaborator

No description provided.

On RedHat systems setting MAGIC_PRESERVE_ATIME caused SELinux errors.

RedHat bugzilla identified in BZ
   https://bugzilla.redhat.com/show_bug.cgi?id=1997148
that this was caused by a call to utimensat().

Issue acassen#2333 identified that setting MAGIC_PRESERVE_ATIME triggers the
call of utimensat(). Inspecting src/magic.c in the "file" utility source
code shows that the call of utimensat() was made due to utimes() being
called. glibc maps this to a call of utimensat().

Although setting the flag, and hence preserving atime when ascertaining
the file type is not unreasonable, the atime will be modified anyway
when the file is subsequently executed. Also it is clear from the
"file" code in src/magic.c, that not only is the atime not properly
restored when MAGIC_PRESERVE_ATIME is set, but that mtime is also
modified, even though the file has not been modified. This is due to
close_and_restore() in src/magic.c only restoring the seconds field,
and not the microseconds that utimes() can specify, and that
utime()/utimes() update both the atime and mtime fields. Consequently
the fractions of a second of atime and mtime are both set to 0.

Further, there is a comment in src/magic.c:
    /*
     * Try to restore access, modification times if read it.
     * This is really *bad* because it will modify the status
     * time of the file... And of course this will affect
     * backup programs
     */

We don't want to be doing *bad* things in keepalived, so that reinforces
removing MAGIC_PRESERVE_ATIME.

Signed-off-by: Quentin Armitage <[email protected]>
@pqarmitage pqarmitage merged commit b6d1db2 into acassen:master Aug 23, 2023
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant