diff options
author | kientzle <kientzle@FreeBSD.org> | 2005-06-01 15:44:23 +0000 |
---|---|---|
committer | kientzle <kientzle@FreeBSD.org> | 2005-06-01 15:44:23 +0000 |
commit | 326eb5aaed484df8a3d09646b1ee713a644b2fef (patch) | |
tree | a0265f8757a9cdf69f87dcceeb15a519dc097d2c /lib/libarchive/archive_write_set_format_pax.c | |
parent | 3d55e66334d67292b77fe5eb6f5bc74e4eca2021 (diff) | |
download | FreeBSD-src-326eb5aaed484df8a3d09646b1ee713a644b2fef.zip FreeBSD-src-326eb5aaed484df8a3d09646b1ee713a644b2fef.tar.gz |
A minor refinement to "pax" output: Remove suid/sgid/sticky bits
from mode before using mode for extended attributes entry, copy
mtime/atime/ctime to extended attributes entry so it's a little more
clear that it corresponds to the like-named regular entry.
MFC after: 14 days
Diffstat (limited to 'lib/libarchive/archive_write_set_format_pax.c')
-rw-r--r-- | lib/libarchive/archive_write_set_format_pax.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lib/libarchive/archive_write_set_format_pax.c b/lib/libarchive/archive_write_set_format_pax.c index 2309909..479cca6 100644 --- a/lib/libarchive/archive_write_set_format_pax.c +++ b/lib/libarchive/archive_write_set_format_pax.c @@ -643,19 +643,41 @@ archive_write_pax_header(struct archive *a, archive_entry_set_pathname(pax_attr_entry, build_pax_attribute_name(pax_entry_name, p)); st.st_size = archive_strlen(&(pax->pax_header)); + /* Copy uid/gid (but clip to ustar limits). */ st.st_uid = st_main->st_uid; if (st.st_uid >= 1 << 18) st.st_uid = (1 << 18) - 1; st.st_gid = st_main->st_gid; if (st.st_gid >= 1 << 18) st.st_gid = (1 << 18) - 1; + /* Copy mode over (but not setuid/setgid bits) */ st.st_mode = st_main->st_mode; +#ifdef S_ISUID + st.st_mode &= ~S_ISUID; +#endif +#ifdef S_ISGID + st.st_mode &= ~S_ISGID; +#endif +#ifdef S_ISVTX + st.st_mode &= ~S_ISVTX; +#endif archive_entry_copy_stat(pax_attr_entry, &st); + /* Copy uname/gname. */ archive_entry_set_uname(pax_attr_entry, archive_entry_uname(entry_main)); archive_entry_set_gname(pax_attr_entry, archive_entry_gname(entry_main)); + /* Copy timestamps. */ + archive_entry_set_mtime(pax_attr_entry, + archive_entry_mtime(entry_main), + archive_entry_mtime_nsec(entry_main)); + archive_entry_set_atime(pax_attr_entry, + archive_entry_atime(entry_main), + archive_entry_atime_nsec(entry_main)); + archive_entry_set_ctime(pax_attr_entry, + archive_entry_ctime(entry_main), + archive_entry_ctime_nsec(entry_main)); ret = __archive_write_format_header_ustar(a, paxbuff, pax_attr_entry, 'x', 1); |