FreeBSD Bugzilla – Attachment 211753 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 (v3)
0002-Add-passphrase-support-v3.patch (text/plain), 3.39 KB, created by
Mingye Wang
on 2020-02-19 03:50:13 UTC
(
hide
)
Description:
Add passphrase support (v3)
Filename:
MIME Type:
Creator:
Mingye Wang
Created:
2020-02-19 03:50:13 UTC
Size:
3.39 KB
patch
obsolete
>From a1088ebe7f4449939df3df754b4e67a76f2f2720 Mon Sep 17 00:00:00 2001 >From: Mingye Wang <arthur200126@gmail.com> >Date: Mon, 17 Feb 2020 00:44:41 +0800 >Subject: [PATCH 2/3] Add passphrase support (v3) > >This commit adds support for passphrase (interactive query) and the -P >option. > >v2: Add internal flag to tell whether P_arg is malloc'ed. If so, free at >the end. >v3: move free to unzip() where it makes more sense >--- > unzip.1 | 3 +++ > unzip.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-- > 2 files changed, 51 insertions(+), 2 deletions(-) > >diff --git a/unzip.1 b/unzip.1 >index b7c2d85..37ec0e3 100644 >--- a/unzip.1 >+++ b/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 >diff --git a/unzip.c b/unzip.c >index 1828b8b..a4c0880 100644 >--- a/unzip.c >+++ b/unzip.c >@@ -55,6 +55,8 @@ > > #include <archive.h> > #include <archive_entry.h> >+#include <readpassphrase.h> >+ > > /* command-line options */ > static int a_opt; /* convert EOL */ >@@ -68,6 +70,7 @@ static int n_opt; /* never overwrite */ > 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 */ >@@ -851,6 +854,36 @@ test(struct archive *a, struct archive_entry *e) > return error_count; > } > >+/* >+ * Callback function for reading one 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 = (char **)_client_data; >+ char *p; >+ >+ if (*passphrase_buf == NULL) { >+ *passphrase_buf = malloc(PPBUFF_SIZE); >+ P_arg_malloc = 1; >+ if (*passphrase_buf == NULL) { >+ errno = ENOMEM; >+ error("malloc()"); >+ } >+ } >+ >+ p = readpassphrase("Enter 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. >@@ -881,6 +914,12 @@ unzip(const char *fn) > } > } > >+ if (P_arg) { >+ archive_read_add_passphrase(a, P_arg); >+ } else { >+ archive_read_set_passphrase_callback(a, &P_arg, &passphrase_callback); >+ } >+ > total_size = 0; > file_count = 0; > error_count = 0; >@@ -932,6 +971,11 @@ unzip(const char *fn) > fn); > } > } >+ >+ if (P_arg_malloc) { >+ free(P_arg); >+ P_arg = NULL; >+ } > } > > static void >@@ -953,7 +997,7 @@ getopts(int argc, char *argv[]) > #else > optreset = optind = 1; > #endif >- 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; >@@ -993,6 +1037,9 @@ getopts(int argc, char *argv[]) > case 'p': > p_opt = 1; > break; >+ case 'P': >+ P_arg = optarg; >+ break; > case 'q': > q_opt = 1; > break; >@@ -1069,6 +1116,5 @@ main(int argc, char *argv[]) > errorx("-n, -o and -u are contradictory"); > > unzip(zipfile); >- > exit(0); > } >-- >2.24.0.windows.2 >
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