View | Details | Raw Unified | Return to bug 244181 | Differences between
and this patch

Collapse All | Expand All

(-)b/unzip.1 (+3 lines)
Lines 81-86 When extracting files from the zipfile, they are written to stdout. Link Here
81
The normal output is suppressed as if
81
The normal output is suppressed as if
82
.Fl q
82
.Fl q
83
was specified.
83
was specified.
84
.It Fl P Ar passphrase
85
Extract encrypted files using a passphrase. Putting a passphrase in
86
plaintext using this option is a bad idea.
84
.It Fl q
87
.It Fl q
85
Quiet: print less information while extracting.
88
Quiet: print less information while extracting.
86
.It Fl t
89
.It Fl t
(-)b/unzip.c (-2 / +42 lines)
Lines 55-60 Link Here
55
55
56
#include <archive.h>
56
#include <archive.h>
57
#include <archive_entry.h>
57
#include <archive_entry.h>
58
#include <readpassphrase.h>
59
58
60
59
/* command-line options */
61
/* command-line options */
60
static int		 a_opt;		/* convert EOL */
62
static int		 a_opt;		/* convert EOL */
Lines 68-73 static int n_opt; /* never overwrite */ Link Here
68
static int		 o_opt;		/* always overwrite */
70
static int		 o_opt;		/* always overwrite */
69
static int		 p_opt;		/* extract to stdout, quiet */
71
static int		 p_opt;		/* extract to stdout, quiet */
70
static int		 q_opt;		/* quiet */
72
static int		 q_opt;		/* quiet */
73
static char	*P_arg;		/* passphrase */
71
static int		 t_opt;		/* test */
74
static int		 t_opt;		/* test */
72
static int		 u_opt;		/* update */
75
static int		 u_opt;		/* update */
73
static int		 v_opt;		/* verbose/list */
76
static int		 v_opt;		/* verbose/list */
Lines 851-856 test(struct archive *a, struct archive_entry *e) Link Here
851
	return error_count;
854
	return error_count;
852
}
855
}
853
856
857
/*
858
 * Callback function for reading one passphrase.
859
 * Originally from cpio.c and passphrase.c, libarchive.
860
 */
861
#define PPBUFF_SIZE 1024
862
static const char *
863
passphrase_callback(struct archive *a, void *_client_data)
864
{
865
	char **passphrase_buf = (char **)_client_data;
866
	char *p;
867
868
	if (*passphrase_buf == NULL) {
869
		*passphrase_buf = malloc(PPBUFF_SIZE);
870
		if (*passphrase_buf == NULL) {
871
			errno = ENOMEM;
872
			error("malloc()");
873
		}
874
	}
875
876
	p = readpassphrase("Enter passphrase:", *passphrase_buf,
877
		PPBUFF_SIZE, RPP_ECHO_OFF);
878
	
879
	if (p == NULL && errno != EINTR) {
880
		error("readpassphrase()");
881
	}
882
883
	return p;
884
}
885
854
/*
886
/*
855
 * Main loop: open the zipfile, iterate over its contents and decide what
887
 * Main loop: open the zipfile, iterate over its contents and decide what
856
 * to do with each entry.
888
 * to do with each entry.
Lines 881-886 unzip(const char *fn) Link Here
881
		}
913
		}
882
	}
914
	}
883
915
916
	if (P_arg) {
917
		archive_read_add_passphrase(a, P_arg);
918
	} else {
919
		archive_read_set_passphrase_callback(a, &P_arg, &passphrase_callback);
920
	}
921
884
	total_size = 0;
922
	total_size = 0;
885
	file_count = 0;
923
	file_count = 0;
886
	error_count = 0;
924
	error_count = 0;
Lines 953-959 getopts(int argc, char *argv[]) Link Here
953
#else
991
#else
954
	optreset = optind = 1;
992
	optreset = optind = 1;
955
#endif
993
#endif
956
	while ((opt = getopt(argc, argv, "aCcd:fjLlnopqtuvx:yZ1")) != -1)
994
	while ((opt = getopt(argc, argv, "aCcd:fjLlnopP:qtuvx:yZ1")) != -1)
957
		switch (opt) {
995
		switch (opt) {
958
		case '1':
996
		case '1':
959
			Z1_opt = 1;
997
			Z1_opt = 1;
Lines 993-998 getopts(int argc, char *argv[]) Link Here
993
		case 'p':
1031
		case 'p':
994
			p_opt = 1;
1032
			p_opt = 1;
995
			break;
1033
			break;
1034
		case 'P':
1035
			P_arg = optarg;
1036
			break;
996
		case 'q':
1037
		case 'q':
997
			q_opt = 1;
1038
			q_opt = 1;
998
			break;
1039
			break;
999
- 

Return to bug 244181