diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2023-01-13 10:57:03 +0200 |
---|---|---|
committer | Michal Domonkos <mdomonko@redhat.com> | 2023-03-13 15:32:25 +0100 |
commit | 6792666f1be55abe487648f564fb0855d4cb8c15 (patch) | |
tree | 6c3783f8598c49282d156b405dd250d7caa208cb | |
parent | f72c7800ae1e02ed6dfe3a240c4dc756883cc2ac (diff) | |
download | rpm-6792666f1be55abe487648f564fb0855d4cb8c15.tar.gz |
Explicitly specify O_RDONLY when opening files for setmeta
On Linux, this is a no-op as O_RDONLY is 0 but this may not be so on
other platforms. Another 4.18 regression.
(cherry picked from commit 3a7c8bc401a97f0ebf57bef3987a337129e4371f)
-rw-r--r-- | lib/fsm.c | 6 |
1 files changed, 4 insertions, 2 deletions
@@ -1018,9 +1018,11 @@ setmeta: /* Special files require path-based ops */ int mayopen = S_ISREG(fp->sb.st_mode) || S_ISDIR(fp->sb.st_mode); if (!rc && fd == -1 && mayopen) { + int flags = O_RDONLY; /* Only follow safe symlinks, and never on temporary files */ - fd = fsmOpenat(di.dirfd, fp->fpath, - fp->suffix ? AT_SYMLINK_NOFOLLOW : 0, 0); + if (fp->suffix) + flags |= AT_SYMLINK_NOFOLLOW; + fd = fsmOpenat(di.dirfd, fp->fpath, flags, 0); if (fd < 0) rc = RPMERR_OPEN_FAILED; } |