MFV r348971,r348977:

Sync libarchive with vendor.

Relevant vendor changes:
  - check_symlinks_fsobj() without chdir() and fchdir()
  - bsdtar.1 manpage fixes
  - patches from OpenBSD to libarchive_fe/passphrase.c
  - version bumped to 3.4.0

MFC after:	2 weeks
This commit is contained in:
Martin Matuska 2019-06-12 13:34:12 +00:00
commit fae5c36e4c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=348993
13 changed files with 223 additions and 111 deletions

View File

@ -1,3 +1,7 @@
Jun 11, 2019: libarchive 3.4.0 released
May 18, 2019: Fixes for reading Android APK and JAR archives
Apr 16, 2019: Support for non-recursive list and extract Apr 16, 2019: Support for non-recursive list and extract
Apr 14, 2019: New tar option: --exclude-vcs Apr 14, 2019: New tar option: --exclude-vcs
@ -6,7 +10,7 @@ Mar 27, 2019: Support for file and directory symlinks on Windows
Mar 12, 2019: Important fixes for storing file attributes and flags Mar 12, 2019: Important fixes for storing file attributes and flags
Jan 20, 2019: Support for xz, lzma, ppmd8 and bzip2 compression in zip archives Jan 20, 2019: Support for xz, lzma, ppmd8 and bzip2 decompression in ZIP files
Oct 06, 2018: RAR 5.0 reader Oct 06, 2018: RAR 5.0 reader

View File

@ -81,6 +81,7 @@ Currently, the library automatically detects and reads the following fomats:
* Binary cpio (big-endian or little-endian) * Binary cpio (big-endian or little-endian)
* ISO9660 CD-ROM images (with optional Rockridge or Joliet extensions) * ISO9660 CD-ROM images (with optional Rockridge or Joliet extensions)
* ZIP archives (with uncompressed or "deflate" compressed entries, including support for encrypted Zip archives) * ZIP archives (with uncompressed or "deflate" compressed entries, including support for encrypted Zip archives)
* ZIPX archives (with support for bzip2, ppmd8, lzma and xz compressed entries)
* GNU and BSD 'ar' archives * GNU and BSD 'ar' archives
* 'mtree' format * 'mtree' format
* 7-Zip archives * 7-Zip archives

View File

@ -36,7 +36,7 @@
* assert that ARCHIVE_VERSION_NUMBER >= 2012108. * assert that ARCHIVE_VERSION_NUMBER >= 2012108.
*/ */
/* Note: Compiler will complain if this does not match archive_entry.h! */ /* Note: Compiler will complain if this does not match archive_entry.h! */
#define ARCHIVE_VERSION_NUMBER 3003003 #define ARCHIVE_VERSION_NUMBER 3004000
#include <sys/stat.h> #include <sys/stat.h>
#include <stddef.h> /* for wchar_t */ #include <stddef.h> /* for wchar_t */
@ -155,7 +155,7 @@ __LA_DECL int archive_version_number(void);
/* /*
* Textual name/version of the library, useful for version displays. * Textual name/version of the library, useful for version displays.
*/ */
#define ARCHIVE_VERSION_ONLY_STRING "3.3.3" #define ARCHIVE_VERSION_ONLY_STRING "3.4.0"
#define ARCHIVE_VERSION_STRING "libarchive " ARCHIVE_VERSION_ONLY_STRING #define ARCHIVE_VERSION_STRING "libarchive " ARCHIVE_VERSION_ONLY_STRING
__LA_DECL const char * archive_version_string(void); __LA_DECL const char * archive_version_string(void);

View File

@ -30,7 +30,7 @@
#define ARCHIVE_ENTRY_H_INCLUDED #define ARCHIVE_ENTRY_H_INCLUDED
/* Note: Compiler will complain if this does not match archive.h! */ /* Note: Compiler will complain if this does not match archive.h! */
#define ARCHIVE_VERSION_NUMBER 3003003 #define ARCHIVE_VERSION_NUMBER 3004000
/* /*
* Note: archive_entry.h is for use outside of libarchive; the * Note: archive_entry.h is for use outside of libarchive; the

View File

@ -60,7 +60,7 @@ static int archive_filter_b64encode_write(struct archive_write_filter *,
const void *, size_t); const void *, size_t);
static int archive_filter_b64encode_close(struct archive_write_filter *); static int archive_filter_b64encode_close(struct archive_write_filter *);
static int archive_filter_b64encode_free(struct archive_write_filter *); static int archive_filter_b64encode_free(struct archive_write_filter *);
static void b64_encode(struct archive_string *, const unsigned char *, size_t); static void la_b64_encode(struct archive_string *, const unsigned char *, size_t);
static int64_t atol8(const char *, size_t); static int64_t atol8(const char *, size_t);
static const char base64[] = { static const char base64[] = {
@ -180,7 +180,7 @@ archive_filter_b64encode_open(struct archive_write_filter *f)
} }
static void static void
b64_encode(struct archive_string *as, const unsigned char *p, size_t len) la_b64_encode(struct archive_string *as, const unsigned char *p, size_t len)
{ {
int c; int c;
@ -234,12 +234,12 @@ archive_filter_b64encode_write(struct archive_write_filter *f, const void *buff,
} }
if (state->hold_len < LBYTES) if (state->hold_len < LBYTES)
return (ret); return (ret);
b64_encode(&state->encoded_buff, state->hold, LBYTES); la_b64_encode(&state->encoded_buff, state->hold, LBYTES);
state->hold_len = 0; state->hold_len = 0;
} }
for (; length >= LBYTES; length -= LBYTES, p += LBYTES) for (; length >= LBYTES; length -= LBYTES, p += LBYTES)
b64_encode(&state->encoded_buff, p, LBYTES); la_b64_encode(&state->encoded_buff, p, LBYTES);
/* Save remaining bytes. */ /* Save remaining bytes. */
if (length > 0) { if (length > 0) {
@ -270,7 +270,7 @@ archive_filter_b64encode_close(struct archive_write_filter *f)
/* Flush remaining bytes. */ /* Flush remaining bytes. */
if (state->hold_len != 0) if (state->hold_len != 0)
b64_encode(&state->encoded_buff, state->hold, state->hold_len); la_b64_encode(&state->encoded_buff, state->hold, state->hold_len);
archive_string_sprintf(&state->encoded_buff, "====\n"); archive_string_sprintf(&state->encoded_buff, "====\n");
/* Write the last block */ /* Write the last block */
archive_write_set_bytes_in_last_block(f->archive, 1); archive_write_set_bytes_in_last_block(f->archive, 1);

View File

@ -165,6 +165,10 @@ __FBSDID("$FreeBSD$");
#define O_NOFOLLOW 0 #define O_NOFOLLOW 0
#endif #endif
#ifndef AT_FDCWD
#define AT_FDCWD -100
#endif
struct fixup_entry { struct fixup_entry {
struct fixup_entry *next; struct fixup_entry *next;
struct archive_acl acl; struct archive_acl acl;
@ -348,6 +352,8 @@ struct archive_write_disk {
#define HFS_BLOCKS(s) ((s) >> 12) #define HFS_BLOCKS(s) ((s) >> 12)
static int la_opendirat(int, const char *);
static void fsobj_error(int *, struct archive_string *, int, const char *, static void fsobj_error(int *, struct archive_string *, int, const char *,
const char *); const char *);
static int check_symlinks_fsobj(char *, int *, struct archive_string *, static int check_symlinks_fsobj(char *, int *, struct archive_string *,
@ -400,6 +406,37 @@ static ssize_t _archive_write_disk_data(struct archive *, const void *,
static ssize_t _archive_write_disk_data_block(struct archive *, const void *, static ssize_t _archive_write_disk_data_block(struct archive *, const void *,
size_t, int64_t); size_t, int64_t);
static int
la_opendirat(int fd, const char *path) {
const int flags = O_CLOEXEC
#if defined(O_BINARY)
| O_BINARY
#endif
#if defined(O_DIRECTORY)
| O_DIRECTORY
#endif
#if defined(O_PATH)
| O_PATH
#elif defined(O_SEARCH)
| O_SEARCH
#elif defined(O_EXEC)
| O_EXEC
#else
| O_RDONLY
#endif
;
#if !defined(HAVE_OPENAT)
if (fd != AT_FDCWD) {
errno = ENOTSUP;
return (-1);
} else
return (open(fd, path, flags));
#else
return (openat(fd, path, flags));
#endif
}
static int static int
lazy_stat(struct archive_write_disk *a) lazy_stat(struct archive_write_disk *a)
{ {
@ -1909,7 +1946,7 @@ edit_deep_directories(struct archive_write_disk *a)
return; return;
/* Try to record our starting dir. */ /* Try to record our starting dir. */
a->restore_pwd = open(".", O_RDONLY | O_BINARY | O_CLOEXEC); a->restore_pwd = la_opendirat(AT_FDCWD, ".");
__archive_ensure_cloexec_flag(a->restore_pwd); __archive_ensure_cloexec_flag(a->restore_pwd);
if (a->restore_pwd < 0) if (a->restore_pwd < 0)
return; return;
@ -2342,7 +2379,7 @@ _archive_write_disk_close(struct archive *_a)
{ {
struct archive_write_disk *a = (struct archive_write_disk *)_a; struct archive_write_disk *a = (struct archive_write_disk *)_a;
struct fixup_entry *next, *p; struct fixup_entry *next, *p;
int ret; int fd, ret;
archive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC, archive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC,
ARCHIVE_STATE_HEADER | ARCHIVE_STATE_DATA, ARCHIVE_STATE_HEADER | ARCHIVE_STATE_DATA,
@ -2353,21 +2390,33 @@ _archive_write_disk_close(struct archive *_a)
p = sort_dir_list(a->fixup_list); p = sort_dir_list(a->fixup_list);
while (p != NULL) { while (p != NULL) {
fd = -1;
a->pst = NULL; /* Mark stat cache as out-of-date. */ a->pst = NULL; /* Mark stat cache as out-of-date. */
if (p->fixup &
(TODO_TIMES | TODO_MODE_BASE | TODO_ACLS | TODO_FFLAGS)) {
fd = open(p->name,
O_WRONLY | O_BINARY | O_NOFOLLOW | O_CLOEXEC);
}
if (p->fixup & TODO_TIMES) { if (p->fixup & TODO_TIMES) {
set_times(a, -1, p->mode, p->name, set_times(a, fd, p->mode, p->name,
p->atime, p->atime_nanos, p->atime, p->atime_nanos,
p->birthtime, p->birthtime_nanos, p->birthtime, p->birthtime_nanos,
p->mtime, p->mtime_nanos, p->mtime, p->mtime_nanos,
p->ctime, p->ctime_nanos); p->ctime, p->ctime_nanos);
} }
if (p->fixup & TODO_MODE_BASE) if (p->fixup & TODO_MODE_BASE) {
#ifdef HAVE_FCHMOD
if (fd >= 0)
fchmod(fd, p->mode);
else
#endif
chmod(p->name, p->mode); chmod(p->name, p->mode);
}
if (p->fixup & TODO_ACLS) if (p->fixup & TODO_ACLS)
archive_write_disk_set_acls(&a->archive, -1, p->name, archive_write_disk_set_acls(&a->archive, fd,
&p->acl, p->mode); p->name, &p->acl, p->mode);
if (p->fixup & TODO_FFLAGS) if (p->fixup & TODO_FFLAGS)
set_fflags_platform(a, -1, p->name, set_fflags_platform(a, fd, p->name,
p->mode, p->fflags_set, 0); p->mode, p->fflags_set, 0);
if (p->fixup & TODO_MAC_METADATA) if (p->fixup & TODO_MAC_METADATA)
set_mac_metadata(a, p->name, p->mac_metadata, set_mac_metadata(a, p->name, p->mac_metadata,
@ -2376,6 +2425,8 @@ _archive_write_disk_close(struct archive *_a)
archive_acl_clear(&p->acl); archive_acl_clear(&p->acl);
free(p->mac_metadata); free(p->mac_metadata);
free(p->name); free(p->name);
if (fd >= 0)
close(fd);
free(p); free(p);
p = next; p = next;
} }
@ -2540,8 +2591,6 @@ fsobj_error(int *a_eno, struct archive_string *a_estr,
* scan the path and both can be optimized by comparing against other * scan the path and both can be optimized by comparing against other
* recent paths. * recent paths.
*/ */
/* TODO: Extend this to support symlinks on Windows Vista and later. */
/* /*
* Checks the given path to see if any elements along it are symlinks. Returns * Checks the given path to see if any elements along it are symlinks. Returns
* ARCHIVE_OK if there are none, otherwise puts an error in errmsg. * ARCHIVE_OK if there are none, otherwise puts an error in errmsg.
@ -2550,7 +2599,8 @@ static int
check_symlinks_fsobj(char *path, int *a_eno, struct archive_string *a_estr, check_symlinks_fsobj(char *path, int *a_eno, struct archive_string *a_estr,
int flags) int flags)
{ {
#if !defined(HAVE_LSTAT) #if !defined(HAVE_LSTAT) && \
!(defined(HAVE_OPENAT) && defined(HAVE_FSTATAT) && defined(HAVE_UNLINKAT))
/* Platform doesn't have lstat, so we can't look for symlinks. */ /* Platform doesn't have lstat, so we can't look for symlinks. */
(void)path; /* UNUSED */ (void)path; /* UNUSED */
(void)error_number; /* UNUSED */ (void)error_number; /* UNUSED */
@ -2565,7 +2615,10 @@ check_symlinks_fsobj(char *path, int *a_eno, struct archive_string *a_estr,
char c; char c;
int r; int r;
struct stat st; struct stat st;
int restore_pwd; int chdir_fd;
#if defined(HAVE_OPENAT) && defined(HAVE_FSTATAT) && defined(HAVE_UNLINKAT)
int fd;
#endif
/* Nothing to do here if name is empty */ /* Nothing to do here if name is empty */
if(path[0] == '\0') if(path[0] == '\0')
@ -2586,9 +2639,9 @@ check_symlinks_fsobj(char *path, int *a_eno, struct archive_string *a_estr,
* c holds what used to be in *tail * c holds what used to be in *tail
* last is 1 if this is the last tail * last is 1 if this is the last tail
*/ */
restore_pwd = open(".", O_RDONLY | O_BINARY | O_CLOEXEC); chdir_fd = la_opendirat(AT_FDCWD, ".");
__archive_ensure_cloexec_flag(restore_pwd); __archive_ensure_cloexec_flag(chdir_fd);
if (restore_pwd < 0) { if (chdir_fd < 0) {
fsobj_error(a_eno, a_estr, errno, fsobj_error(a_eno, a_estr, errno,
"Could not open ", path); "Could not open ", path);
return (ARCHIVE_FATAL); return (ARCHIVE_FATAL);
@ -2621,7 +2674,11 @@ check_symlinks_fsobj(char *path, int *a_eno, struct archive_string *a_estr,
c = tail[0]; c = tail[0];
tail[0] = '\0'; tail[0] = '\0';
/* Check that we haven't hit a symlink. */ /* Check that we haven't hit a symlink. */
#if defined(HAVE_OPENAT) && defined(HAVE_FSTATAT) && defined(HAVE_UNLINKAT)
r = fstatat(chdir_fd, head, &st, AT_SYMLINK_NOFOLLOW);
#else
r = lstat(head, &st); r = lstat(head, &st);
#endif
if (r != 0) { if (r != 0) {
tail[0] = c; tail[0] = c;
/* We've hit a dir that doesn't exist; stop now. */ /* We've hit a dir that doesn't exist; stop now. */
@ -2647,7 +2704,19 @@ check_symlinks_fsobj(char *path, int *a_eno, struct archive_string *a_estr,
} }
} else if (S_ISDIR(st.st_mode)) { } else if (S_ISDIR(st.st_mode)) {
if (!last) { if (!last) {
if (chdir(head) != 0) { #if defined(HAVE_OPENAT) && defined(HAVE_FSTATAT) && defined(HAVE_UNLINKAT)
fd = la_opendirat(chdir_fd, head);
if (fd < 0)
r = -1;
else {
r = 0;
close(chdir_fd);
chdir_fd = fd;
}
#else
r = chdir(head);
#endif
if (r != 0) {
tail[0] = c; tail[0] = c;
fsobj_error(a_eno, a_estr, errno, fsobj_error(a_eno, a_estr, errno,
"Could not chdir ", path); "Could not chdir ", path);
@ -2664,7 +2733,12 @@ check_symlinks_fsobj(char *path, int *a_eno, struct archive_string *a_estr,
* so we can overwrite it with the * so we can overwrite it with the
* item being extracted. * item being extracted.
*/ */
if (unlink(head)) { #if defined(HAVE_OPENAT) && defined(HAVE_FSTATAT) && defined(HAVE_UNLINKAT)
r = unlinkat(chdir_fd, head, 0);
#else
r = unlink(head);
#endif
if (r != 0) {
tail[0] = c; tail[0] = c;
fsobj_error(a_eno, a_estr, errno, fsobj_error(a_eno, a_estr, errno,
"Could not remove symlink ", "Could not remove symlink ",
@ -2694,7 +2768,12 @@ check_symlinks_fsobj(char *path, int *a_eno, struct archive_string *a_estr,
break; break;
} else if (flags & ARCHIVE_EXTRACT_UNLINK) { } else if (flags & ARCHIVE_EXTRACT_UNLINK) {
/* User asked us to remove problems. */ /* User asked us to remove problems. */
if (unlink(head) != 0) { #if defined(HAVE_OPENAT) && defined(HAVE_FSTATAT) && defined(HAVE_UNLINKAT)
r = unlinkat(chdir_fd, head, 0);
#else
r = unlink(head);
#endif
if (r != 0) {
tail[0] = c; tail[0] = c;
fsobj_error(a_eno, a_estr, 0, fsobj_error(a_eno, a_estr, 0,
"Cannot remove intervening " "Cannot remove intervening "
@ -2712,7 +2791,11 @@ check_symlinks_fsobj(char *path, int *a_eno, struct archive_string *a_estr,
* This is needed to extract hardlinks over * This is needed to extract hardlinks over
* symlinks. * symlinks.
*/ */
#if defined(HAVE_OPENAT) && defined(HAVE_FSTATAT) && defined(HAVE_UNLINKAT)
r = fstatat(chdir_fd, head, &st, 0);
#else
r = la_stat(head, &st); r = la_stat(head, &st);
#endif
if (r != 0) { if (r != 0) {
tail[0] = c; tail[0] = c;
if (errno == ENOENT) { if (errno == ENOENT) {
@ -2725,7 +2808,19 @@ check_symlinks_fsobj(char *path, int *a_eno, struct archive_string *a_estr,
break; break;
} }
} else if (S_ISDIR(st.st_mode)) { } else if (S_ISDIR(st.st_mode)) {
if (chdir(head) != 0) { #if defined(HAVE_OPENAT) && defined(HAVE_FSTATAT) && defined(HAVE_UNLINKAT)
fd = la_opendirat(chdir_fd, head);
if (fd < 0)
r = -1;
else {
r = 0;
close(chdir_fd);
chdir_fd = fd;
}
#else
r = chdir(head);
#endif
if (r != 0) {
tail[0] = c; tail[0] = c;
fsobj_error(a_eno, a_estr, fsobj_error(a_eno, a_estr,
errno, errno,
@ -2761,16 +2856,21 @@ check_symlinks_fsobj(char *path, int *a_eno, struct archive_string *a_estr,
} }
/* Catches loop exits via break */ /* Catches loop exits via break */
tail[0] = c; tail[0] = c;
#ifdef HAVE_FCHDIR #if defined(HAVE_OPENAT) && defined(HAVE_FSTATAT) && defined(HAVE_UNLINKAT)
/* If we operate with openat(), fstatat() and unlinkat() there was
* no chdir(), so just close the fd */
if (chdir_fd >= 0)
close(chdir_fd);
#elif HAVE_FCHDIR
/* If we changed directory above, restore it here. */ /* If we changed directory above, restore it here. */
if (restore_pwd >= 0) { if (chdir_fd >= 0) {
r = fchdir(restore_pwd); r = fchdir(chdir_fd);
if (r != 0) { if (r != 0) {
fsobj_error(a_eno, a_estr, errno, fsobj_error(a_eno, a_estr, errno,
"chdir() failure", ""); "chdir() failure", "");
} }
close(restore_pwd); close(chdir_fd);
restore_pwd = -1; chdir_fd = -1;
if (r != 0) { if (r != 0) {
res = (ARCHIVE_FATAL); res = (ARCHIVE_FATAL);
} }
@ -3387,6 +3487,7 @@ static int
set_mode(struct archive_write_disk *a, int mode) set_mode(struct archive_write_disk *a, int mode)
{ {
int r = ARCHIVE_OK; int r = ARCHIVE_OK;
int r2;
mode &= 07777; /* Strip off file type bits. */ mode &= 07777; /* Strip off file type bits. */
if (a->todo & TODO_SGID_CHECK) { if (a->todo & TODO_SGID_CHECK) {
@ -3480,17 +3581,15 @@ set_mode(struct archive_write_disk *a, int mode)
* post-extract fixup, which is handled elsewhere. * post-extract fixup, which is handled elsewhere.
*/ */
#ifdef HAVE_FCHMOD #ifdef HAVE_FCHMOD
if (a->fd >= 0) { if (a->fd >= 0)
if (fchmod(a->fd, mode) != 0) { r2 = fchmod(a->fd, mode);
archive_set_error(&a->archive, errno, else
"Can't set permissions to 0%o", (int)mode);
r = ARCHIVE_WARN;
}
} else
#endif #endif
/* If this platform lacks fchmod(), then /* If this platform lacks fchmod(), then
* we'll just use chmod(). */ * we'll just use chmod(). */
if (chmod(a->name, mode) != 0) { r2 = chmod(a->name, mode);
if (r2 != 0) {
archive_set_error(&a->archive, errno, archive_set_error(&a->archive, errno,
"Can't set permissions to 0%o", (int)mode); "Can't set permissions to 0%o", (int)mode);
r = ARCHIVE_WARN; r = ARCHIVE_WARN;

View File

@ -49,11 +49,10 @@ __FBSDID("$FreeBSD$");
*/ */
struct lafe_line_reader { struct lafe_line_reader {
FILE *f; FILE *f;
char *buff, *buff_end, *line_start, *line_end, *p; char *buff, *buff_end, *line_start, *line_end;
char *pathname; char *pathname;
size_t buff_length; size_t buff_length;
int nullSeparator; /* Lines separated by null, not CR/CRLF/etc. */ int nullSeparator; /* Lines separated by null, not CR/CRLF/etc. */
int ret;
}; };
struct lafe_line_reader * struct lafe_line_reader *

View File

@ -23,9 +23,11 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
/* $OpenBSD: readpassphrase.c,v 1.22 2010/01/13 10:20:54 dtucker Exp $ */ /* $OpenBSD: readpassphrase.c,v 1.27 2019/01/25 00:19:25 millert Exp $ */
/* /*
* Copyright (c) 2000-2002, 2007 Todd C. Miller <Todd.Miller@courtesan.com> * Copyright (c) 2000-2002, 2007, 2010
* Todd C. Miller <millert@openbsd.org>
* *
* Permission to use, copy, modify, and distribute this software for any * Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above * purpose with or without fee is hereby granted, provided that the above
@ -198,6 +200,27 @@ readpassphrase(const char *prompt, char *buf, size_t bufsiz, int flags)
output = STDERR_FILENO; output = STDERR_FILENO;
} }
/*
* Turn off echo if possible.
* If we are using a tty but are not the foreground pgrp this will
* generate SIGTTOU, so do it *before* installing the signal handlers.
*/
if (input != STDIN_FILENO && tcgetattr(input, &oterm) == 0) {
memcpy(&term, &oterm, sizeof(term));
if (!(flags & RPP_ECHO_ON))
term.c_lflag &= ~(ECHO | ECHONL);
#ifdef VSTATUS
if (term.c_cc[VSTATUS] != _POSIX_VDISABLE)
term.c_cc[VSTATUS] = _POSIX_VDISABLE;
#endif
(void)tcsetattr(input, _T_FLUSH, &term);
} else {
memset(&term, 0, sizeof(term));
term.c_lflag |= ECHO;
memset(&oterm, 0, sizeof(oterm));
oterm.c_lflag |= ECHO;
}
/* /*
* Catch signals that would otherwise cause the user to end * Catch signals that would otherwise cause the user to end
* up with echo turned off in the shell. Don't worry about * up with echo turned off in the shell. Don't worry about
@ -217,25 +240,6 @@ readpassphrase(const char *prompt, char *buf, size_t bufsiz, int flags)
(void)sigaction(SIGTTIN, &sa, &savettin); (void)sigaction(SIGTTIN, &sa, &savettin);
(void)sigaction(SIGTTOU, &sa, &savettou); (void)sigaction(SIGTTOU, &sa, &savettou);
/* Turn off echo if possible. */
if (input != STDIN_FILENO && tcgetattr(input, &oterm) == 0) {
memcpy(&term, &oterm, sizeof(term));
if (!(flags & RPP_ECHO_ON))
term.c_lflag &= ~(ECHO | ECHONL);
#ifdef VSTATUS
if (term.c_cc[VSTATUS] != _POSIX_VDISABLE)
term.c_cc[VSTATUS] = _POSIX_VDISABLE;
#endif
(void)tcsetattr(input, _T_FLUSH, &term);
} else {
memset(&term, 0, sizeof(term));
term.c_lflag |= ECHO;
memset(&oterm, 0, sizeof(oterm));
oterm.c_lflag |= ECHO;
}
/* No I/O if we are already backgrounded. */
if (signo[SIGTTOU] != 1 && signo[SIGTTIN] != 1) {
if (!(flags & RPP_STDIN)) { if (!(flags & RPP_STDIN)) {
int r = write(output, prompt, strlen(prompt)); int r = write(output, prompt, strlen(prompt));
(void)r; (void)r;
@ -261,13 +265,16 @@ readpassphrase(const char *prompt, char *buf, size_t bufsiz, int flags)
int r = write(output, "\n", 1); int r = write(output, "\n", 1);
(void)r; (void)r;
} }
}
/* Restore old terminal settings and signals. */ /* Restore old terminal settings and signals. */
if (memcmp(&term, &oterm, sizeof(term)) != 0) { if (memcmp(&term, &oterm, sizeof(term)) != 0) {
const int sigttou = signo[SIGTTOU];
/* Ignore SIGTTOU generated when we are not the fg pgrp. */
while (tcsetattr(input, _T_FLUSH, &oterm) == -1 && while (tcsetattr(input, _T_FLUSH, &oterm) == -1 &&
errno == EINTR) errno == EINTR && !signo[SIGTTOU])
continue; continue;
signo[SIGTTOU] = sigttou;
} }
(void)sigaction(SIGALRM, &savealrm, NULL); (void)sigaction(SIGALRM, &savealrm, NULL);
(void)sigaction(SIGHUP, &savehup, NULL); (void)sigaction(SIGHUP, &savehup, NULL);

View File

@ -25,7 +25,7 @@
.\" .\"
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd October 1, 2017 .Dd June 3, 2019
.Dt TAR 1 .Dt TAR 1
.Os .Os
.Sh NAME .Sh NAME
@ -198,7 +198,7 @@ options and before extracting any files.
.It Fl Fl clear-nochange-fflags .It Fl Fl clear-nochange-fflags
(x mode only) (x mode only)
Before removing file system objects to replace them, clear platform-specific Before removing file system objects to replace them, clear platform-specific
file flags that might prevent removal. file attributes or file flags that might prevent removal.
.It Fl Fl exclude Ar pattern .It Fl Fl exclude Ar pattern
Do not process files or directories that match the Do not process files or directories that match the
specified pattern. specified pattern.
@ -218,7 +218,8 @@ and
.Sq Darcs . .Sq Darcs .
.It Fl Fl fflags .It Fl Fl fflags
(c, r, u, x modes only) (c, r, u, x modes only)
Archive or extract file flags. This is the reverse of Archive or extract platform-specific file attributes or file flags.
This is the reverse of
.Fl Fl no-fflags .Fl Fl no-fflags
and the default behavior in c, r, and u modes or if and the default behavior in c, r, and u modes or if
.Nm .Nm
@ -389,8 +390,8 @@ Do not extract modification time.
By default, the modification time is set to the time stored in the archive. By default, the modification time is set to the time stored in the archive.
.It Fl Fl mac-metadata .It Fl Fl mac-metadata
(c, r, u and x mode only) (c, r, u and x mode only)
Mac OS X specific. Archive or extract extended ACLs and extended attributes Mac OS X specific. Archive or extract extended ACLs and extended file
using attributes using
.Xr copyfile 3 .Xr copyfile 3
in AppleDouble format. This is the reverse of in AppleDouble format. This is the reverse of
.Fl Fl no-mac-metadata . .Fl Fl no-mac-metadata .
@ -445,21 +446,21 @@ and the default behavior if
is run as non-root in x mode (on Mac OS X as any user in c, r, u and x modes). is run as non-root in x mode (on Mac OS X as any user in c, r, u and x modes).
.It Fl Fl no-fflags .It Fl Fl no-fflags
(c, r, u, x modes only) (c, r, u, x modes only)
Do not archive or extract file flags. This is the reverse of Do not archive or extract file attributes or file flags. This is the reverse of
.Fl Fl fflags .Fl Fl fflags
and the default behavior if and the default behavior if
.Nm .Nm
is run as non-root in x mode. is run as non-root in x mode.
.It Fl Fl no-mac-metadata .It Fl Fl no-mac-metadata
(x mode only) (x mode only)
Mac OS X specific. Do not archive or extract ACLs and extended attributes using Mac OS X specific. Do not archive or extract ACLs and extended file attributes
using
.Xr copyfile 3 .Xr copyfile 3
in AppleDouble format. This is the reverse of in AppleDouble format. This is the reverse of
.Fl Fl mac-metadata . .Fl Fl mac-metadata .
and the default behavior if and the default behavior if
.Nm .Nm
is run as non-root in x mode. is run as non-root in x mode.
.It Fl n , Fl Fl norecurse , Fl Fl no-recursion
.It Fl Fl no-same-owner .It Fl Fl no-same-owner
(x mode only) (x mode only)
Do not extract owner and group IDs. Do not extract owner and group IDs.
@ -470,8 +471,8 @@ and the default behavior if
is run as non-root. is run as non-root.
.It Fl Fl no-same-permissions .It Fl Fl no-same-permissions
(x mode only) (x mode only)
Do not extract full permissions (SGID, SUID, sticky bit, ACLs, Do not extract full permissions (SGID, SUID, sticky bit,
extended attributes or extended file flags). file attributes or file flags, extended file attributes and ACLs).
This is the reverse of This is the reverse of
.Fl p .Fl p
and the default behavior if and the default behavior if
@ -479,7 +480,7 @@ and the default behavior if
is run as non-root. is run as non-root.
.It Fl Fl no-xattrs .It Fl Fl no-xattrs
(c, r, u, x modes only) (c, r, u, x modes only)
Do not archive or extract extended attributes. This is the reverse of Do not archive or extract extended file attributes. This is the reverse of
.Fl Fl xattrs .Fl Fl xattrs
and the default behavior if and the default behavior if
.Nm .Nm
@ -667,13 +668,13 @@ This option suppresses these behaviors.
.It Fl p , Fl Fl insecure , Fl Fl preserve-permissions .It Fl p , Fl Fl insecure , Fl Fl preserve-permissions
(x mode only) (x mode only)
Preserve file permissions. Preserve file permissions.
Attempt to restore the full permissions, including owner, file modes, ACLs, Attempt to restore the full permissions, including file modes, file attributes
extended attributes and extended file flags, if available, for each item or file flags, extended file attributes and ACLs, if available, for each item
extracted from the archive. This is te reverse of extracted from the archive. This is the reverse of
.Fl Fl no-same-permissions .Fl Fl no-same-permissions
and the default if and the default if
.Nm .Nm
is being run by root and can be partially overridden by also specifying is being run as root. It can be partially overridden by also specifying
.Fl Fl no-acls , .Fl Fl no-acls ,
.Fl Fl no-fflags , .Fl Fl no-fflags ,
.Fl Fl no-mac-metadata .Fl Fl no-mac-metadata
@ -844,7 +845,7 @@ See
for more information about the handling of exclusions. for more information about the handling of exclusions.
.It Fl Fl xattrs .It Fl Fl xattrs
(c, r, u, x modes only) (c, r, u, x modes only)
Archive or extract extended attributes. This is the reverse of Archive or extract extended file attributes. This is the reverse of
.Fl Fl no-xattrs .Fl Fl no-xattrs
and the default behavior in c, r, and u modes or if and the default behavior in c, r, and u modes or if
.Nm .Nm

View File

@ -209,6 +209,7 @@
#define HAVE_TZSET 1 #define HAVE_TZSET 1
#define HAVE_UINTMAX_T 1 #define HAVE_UINTMAX_T 1
#define HAVE_UNISTD_H 1 #define HAVE_UNISTD_H 1
#define HAVE_UNLINKAT 1
#define HAVE_UNSETENV 1 #define HAVE_UNSETENV 1
#define HAVE_UNSIGNED_LONG_LONG 1 #define HAVE_UNSIGNED_LONG_LONG 1
#define HAVE_UNSIGNED_LONG_LONG_INT 1 #define HAVE_UNSIGNED_LONG_LONG_INT 1

View File

@ -6,7 +6,7 @@ _LIBARCHIVEDIR= ${SRCTOP}/contrib/libarchive
_LIBARCHIVECONFDIR= ${SRCTOP}/lib/libarchive _LIBARCHIVECONFDIR= ${SRCTOP}/lib/libarchive
PROG= bsdcat PROG= bsdcat
BSDCAT_VERSION_STRING= 3.3.3 BSDCAT_VERSION_STRING= 3.4.0
.PATH: ${_LIBARCHIVEDIR}/cat .PATH: ${_LIBARCHIVEDIR}/cat
SRCS= bsdcat.c cmdline.c SRCS= bsdcat.c cmdline.c

View File

@ -6,7 +6,7 @@ _LIBARCHIVEDIR= ${SRCTOP}/contrib/libarchive
_LIBARCHIVECONFDIR= ${SRCTOP}/lib/libarchive _LIBARCHIVECONFDIR= ${SRCTOP}/lib/libarchive
PROG= bsdcpio PROG= bsdcpio
BSDCPIO_VERSION_STRING= 3.3.3 BSDCPIO_VERSION_STRING= 3.4.0
.PATH: ${_LIBARCHIVEDIR}/cpio .PATH: ${_LIBARCHIVEDIR}/cpio
SRCS= cpio.c cmdline.c SRCS= cpio.c cmdline.c

View File

@ -4,7 +4,7 @@
_LIBARCHIVEDIR= ${SRCTOP}/contrib/libarchive _LIBARCHIVEDIR= ${SRCTOP}/contrib/libarchive
PROG= bsdtar PROG= bsdtar
BSDTAR_VERSION_STRING= 3.3.3 BSDTAR_VERSION_STRING= 3.4.0
.PATH: ${_LIBARCHIVEDIR}/tar .PATH: ${_LIBARCHIVEDIR}/tar
SRCS= bsdtar.c \ SRCS= bsdtar.c \