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
This commit is contained in:
parent
659e382f5b
commit
3a2a859dd4
@ -568,6 +568,20 @@ archive_entry_copy_hardlink_w(struct archive_entry *entry, const wchar_t *target
|
||||
aes_copy_wcs(&entry->ae_hardlink, target);
|
||||
}
|
||||
|
||||
void
|
||||
archive_entry_set_atime(struct archive_entry *entry, time_t t, long ns)
|
||||
{
|
||||
entry->ae_stat.st_atime = t;
|
||||
ARCHIVE_STAT_SET_ATIME_NANOS(&entry->ae_stat, ns);
|
||||
}
|
||||
|
||||
void
|
||||
archive_entry_set_ctime(struct archive_entry *entry, time_t t, long ns)
|
||||
{
|
||||
entry->ae_stat.st_ctime = t;
|
||||
ARCHIVE_STAT_SET_CTIME_NANOS(&entry->ae_stat, ns);
|
||||
}
|
||||
|
||||
/* Set symlink if symlink is already set, else set hardlink. */
|
||||
void
|
||||
archive_entry_set_link(struct archive_entry *entry, const char *target)
|
||||
|
@ -96,6 +96,8 @@ const char *archive_entry_uname(struct archive_entry *);
|
||||
*/
|
||||
|
||||
void archive_entry_copy_stat(struct archive_entry *, const struct stat *);
|
||||
void archive_entry_set_atime(struct archive_entry *, time_t, long);
|
||||
void archive_entry_set_ctime(struct archive_entry *, time_t, long);
|
||||
void archive_entry_set_fflags(struct archive_entry *,
|
||||
unsigned long set, unsigned long clear);
|
||||
/* Returns pointer to start of first invalid token, or NULL if none. */
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user