/[packages]/cauldron/zip/current/SOURCES/zip-2.3-noninteractivepassword+testencrypedfile.patch
ViewVC logotype

Contents of /cauldron/zip/current/SOURCES/zip-2.3-noninteractivepassword+testencrypedfile.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2230 - (show annotations) (download)
Sun Jan 9 11:38:37 2011 UTC (13 years, 3 months ago) by blino
File size: 3832 byte(s)
imported package zip
1 --- zipcloak.c 2008-05-08 04:17:00.000000000 +0200
2 +++ zipcloak.c.oden 2008-08-18 12:22:07.000000000 +0200
3 @@ -220,6 +220,8 @@ static ZCONST char *help_info[] = {
4 " -b --temp-path use \"path\" for the temporary zip file",
5 #endif
6 " -O --output-file write output to new zip file",
7 +" -3 feed password in through FD 3",
8 +" -t test if the archive is already encrypted",
9 " -q --quiet quiet operation, suppress some informational messages",
10 " -h --help show this help",
11 " -v --version show version info",
12 @@ -312,6 +314,7 @@ int main(argc, argv)
13 int attr; /* attributes of zip file */
14 zoff_t start_offset; /* start of central directory */
15 int decrypt; /* decryption flag */
16 + int checkifencrypted; /* check if encrypted flag */
17 int temp_path; /* 1 if next argument is path for temp files */
18 char passwd[IZ_PWLEN+1]; /* password for encryption or decryption */
19 char verify[IZ_PWLEN+1]; /* password for encryption or decryption */
20 @@ -390,6 +393,7 @@ int main(argc, argv)
21
22 /* Go through args */
23 zipfile = tempzip = NULL;
24 + *passwd = (char)0;
25 tempzf = NULL;
26 #ifdef SIGINT
27 signal(SIGINT, handler);
28 @@ -412,7 +416,7 @@ int main(argc, argv)
29 #ifdef SIGSEGV
30 signal(SIGSEGV, handler);
31 #endif
32 - temp_path = decrypt = 0;
33 + temp_path = decrypt = 0; checkifencrypted = 0;
34 #if 0
35 /* old command line */
36 for (r = 1; r < argc; r++) {
37 @@ -428,6 +432,8 @@ int main(argc, argv)
38 break;
39 case 'd':
40 decrypt = 1; break;
41 + case 't':
42 + checkifencrypted = 1; break;
43 case 'h': /* Show help */
44 help();
45 EXIT(ZE_OK);
46 @@ -439,6 +445,18 @@ int main(argc, argv)
47 case 'v': /* Show version info */
48 version_info();
49 EXIT(ZE_OK);
50 + case '3': /* get passwd from fd 3 */
51 + passwd[read(3, passwd, PWLEN)]=(char)0;
52 + if(*passwd) {
53 + char *s;
54 + if( (s=strchr(passwd, '\n')) ||
55 + (s=strchr(passwd, '\r')) )
56 + *s=(char)0;
57 + } else {
58 + ziperr(ZE_PARMS, "-3 requires input in fd 3");
59 + EXIT(1);
60 + }
61 + break;
62 default:
63 ziperr(ZE_PARMS, "unknown option");
64 } /* switch */
65 @@ -569,7 +587,17 @@ int main(argc, argv)
66
67 /* Check for something to do */
68 for (z = zfiles; z != NULL; z = z->nxt) {
69 - if (decrypt ? z->flg & 1 : !(z->flg & 1)) break;
70 + if ((decrypt | checkifencrypted) ? z->flg & 1 : !(z->flg & 1)) break;
71 + }
72 + if (checkifencrypted) {
73 + if (z == NULL) {
74 + printf ("The specified file is NOT encrypted.\n");
75 + EXIT(1);
76 + } else
77 + {
78 + printf ("The specified file is encrypted.\n");
79 + EXIT(0);
80 + }
81 }
82 if (z == NULL) {
83 ziperr(ZE_NONE, decrypt ? "no encrypted files"
84 @@ -628,6 +656,8 @@ int main(argc, argv)
85 #endif
86
87 /* Get password */
88 + if (*passwd) /* got it with -3 */
89 + goto GOT_PASSWD;
90 if (getp("Enter password: ", passwd, IZ_PWLEN+1) == NULL)
91 ziperr(ZE_PARMS,
92 "stderr is not a tty (you may never see this message!)");
93 @@ -644,6 +674,7 @@ int main(argc, argv)
94 ziperr(ZE_PARMS, "zero length password not allowed");
95 }
96
97 + GOT_PASSWD:
98 /* Open input zip file again, copy preamble if any */
99 if ((in_file = fopen(zipfile, FOPR)) == NULL) ziperr(ZE_NAME, zipfile);
100

  ViewVC Help
Powered by ViewVC 1.1.30