Skip to content

Commit cfa6ce7

Browse files
Liubov Dmitrievameta-codesync[bot]
authored andcommitted
[antlir2] fix the file permissions issues introduced in D88743755
Summary: fix the file permissions issues introduced in D88743755 The repro for the issue: https://www.internalfb.com/phabricator/paste/view/P2074123575?lines=53%2C81 Test Plan: tested permission after the fix After the change: https://www.internalfb.com/phabricator/paste/view/P2074175459?lines=88 Reviewed By: vmagro Differential Revision: D88790669 fbshipit-source-id: 27034fb551be554fc7b6504325bbf218f0d7495d
1 parent 1ad347e commit cfa6ce7

File tree

1 file changed

+9
-1
lines changed
  • antlir/antlir2/antlir2_packager/make_oci_layer/src

1 file changed

+9
-1
lines changed

antlir/antlir2/antlir2_packager/make_oci_layer/src/main.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,9 +296,17 @@ fn main() -> Result<()> {
296296
// to avoid GNU sparse headers (type 'S' = 83) which some container
297297
// runtimes (podman/skopeo) cannot handle.
298298
// Use entry.header which contains metadata from change stream
299-
// operations (Chmod, Chown, etc.) and only set the size.
299+
// operations (Chmod, Chown, etc.), but also preserve permissions
300+
// from filesystem if not already set.
300301
let mut f = File::open(args.child.join(&path))?;
301302
let f_meta = f.metadata()?;
303+
// Preserve permissions from filesystem. On Unix, mode() includes
304+
// file type bits, so mask with 0o7777 to get just permission bits.
305+
#[cfg(unix)]
306+
{
307+
use std::os::unix::fs::PermissionsExt;
308+
entry.header.set_mode(f_meta.permissions().mode() & 0o7777);
309+
}
302310
entry.header.set_size(f_meta.len());
303311
entry.header.set_entry_type(EntryType::Regular);
304312
builder.append_data(&mut entry.header, path, &mut f)?;

0 commit comments

Comments
 (0)