FreeBSD Bugzilla – Attachment 212674 Details for
Bug 244181
unzip: Add passphrase and GLIBC build support
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Add passphrase support
patch.txt (text/plain), 2.97 KB, created by
Alex Kozlov
on 2020-03-24 09:30:50 UTC
(
hide
)
Description:
Add passphrase support
Filename:
MIME Type:
Creator:
Alex Kozlov
Created:
2020-03-24 09:30:50 UTC
Size:
2.97 KB
patch
obsolete
>Index: unzip.1 >@@ -81,6 +81,9 @@ When extracting files from the zipfile, they are written to stdout. > The normal output is suppressed as if > .Fl q > was specified. >+.It Fl P Ar passphrase >+Extract encrypted files using a passphrase. Putting a passphrase in >+plaintext using this option is a bad idea. > .It Fl q > Quiet: print less information while extracting. > .It Fl t >Index: unzip.c >@@ -51,6 +51,7 @@ > > #include <archive.h> > #include <archive_entry.h> >+#include <readpassphrase.h> > > /* command-line options */ > static int a_opt; /* convert EOL */ >@@ -64,6 +65,7 @@ > static int o_opt; /* always overwrite */ > static int p_opt; /* extract to stdout, quiet */ > static int q_opt; /* quiet */ >+static char *P_arg; /* passphrase */ > static int t_opt; /* test */ > static int u_opt; /* update */ > static int v_opt; /* verbose/list */ >@@ -95,6 +97,9 @@ > */ > static int noeol; > >+/* for an interactive passphrase input */ >+static char *passphrase_buf; >+ > /* fatal error message + errno */ > static void > error(const char *fmt, ...) >@@ -848,6 +853,36 @@ > } > > /* >+ * Callback function for reading passphrase. >+ * Originally from cpio.c and passphrase.c, libarchive. >+ */ >+#define PPBUFF_SIZE 1024 >+static const char * >+passphrase_callback(struct archive *a, void *_client_data) >+{ >+ char *passphrase_buf = _client_data; >+ char *p; >+ >+ (void)a; /* UNUSED */ >+ >+ if (passphrase_buf == NULL) { >+ passphrase_buf = malloc(PPBUFF_SIZE); >+ if (passphrase_buf == NULL) { >+ errno = ENOMEM; >+ error("malloc()"); >+ } >+ } >+ >+ p = readpassphrase("\nEnter passphrase:", passphrase_buf, >+ PPBUFF_SIZE, RPP_ECHO_OFF); >+ >+ if (p == NULL && errno != EINTR) >+ error("readpassphrase()"); >+ >+ return p; >+} >+ >+/* > * Main loop: open the zipfile, iterate over its contents and decide what > * to do with each entry. > */ >@@ -863,6 +898,12 @@ > error("archive_read_new failed"); > > ac(archive_read_support_format_zip(a)); >+ >+ if (P_arg) >+ archive_read_add_passphrase(a, P_arg); >+ else >+ archive_read_set_passphrase_callback(a, passphrase_buf, &passphrase_callback); >+ > ac(archive_read_open_filename(a, fn, 8192)); > > if (!zipinfo_mode) { >@@ -919,6 +960,11 @@ > ac(archive_read_close(a)); > (void)archive_read_free(a); > >+ if (passphrase_buf != NULL) { >+ memset(passphrase_buf, 0, PPBUFF_SIZE); >+ free(passphrase_buf); >+ } >+ > if (t_opt) { > if (error_count > 0) { > errorx("%ju checksum error(s) found.", error_count); >@@ -934,7 +980,7 @@ > usage(void) > { > >- fprintf(stderr, "Usage: unzip [-aCcfjLlnopqtuvyZ1] [-d dir] [-x pattern] " >+ fprintf(stderr, "Usage: unzip [-aCcfjLlnopPqtuvyZ1] [-d dir] [-x pattern] " > "zipfile\n"); > exit(1); > } >@@ -945,7 +991,7 @@ > int opt; > > optreset = optind = 1; >- while ((opt = getopt(argc, argv, "aCcd:fjLlnopqtuvx:yZ1")) != -1) >+ while ((opt = getopt(argc, argv, "aCcd:fjLlnopP:qtuvx:yZ1")) != -1) > switch (opt) { > case '1': > Z1_opt = 1; >@@ -984,6 +1030,9 @@ > break; > case 'p': > p_opt = 1; >+ break; >+ case 'P': >+ P_arg = optarg; > break; > case 'q': > q_opt = 1;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 244181
:
211703
|
211704
|
211705
|
211738
|
211753
| 212674