pkgsrc - initial commit
[pkgsrc.git] / archivers / unzip / patches / patch-ac
1 $NetBSD: patch-ac,v 1.1 2005/08/04 14:20:35 tron Exp $
2
3 --- unix/unix.c.orig    2005-02-26 19:43:42.000000000 +0000
4 +++ unix/unix.c 2005-08-04 15:15:17.000000000 +0100
5 @@ -1042,8 +1042,6 @@
6      ush z_uidgid[2];
7      int have_uidgid_flg;
8  
9 -    fclose(G.outfile);
10 -
11  /*---------------------------------------------------------------------------
12      If symbolic links are supported, allocate storage for a symlink control
13      structure, put the uncompressed "data" and other required info in it, and
14 @@ -1059,6 +1057,8 @@
15                                  strlen(G.filename);
16          slinkentry *slnk_entry;
17  
18 +        fclose(G.outfile);
19 +
20          if ((unsigned)slnk_entrysize < ucsize) {
21              Info(slide, 0x201, ((char *)slide,
22                "warning:  symbolic link (%s) failed: mem alloc overflow\n",
23 @@ -1107,6 +1107,11 @@
24      }
25  #endif /* SYMLINKS */
26  
27 +#ifndef NO_CHMOD
28 +    if (fchmod(fileno(G.outfile), filtattr(__G__ G.pInfo->file_attr)))
29 +        perror("chmod (file attributes) error");
30 +#endif
31 +
32  #ifdef QLZIP
33      if (G.extra_field) {
34          static void qlfix OF((__GPRO__ uch *ef_ptr, unsigned ef_len));
35 @@ -1120,7 +1125,7 @@
36      /* if -X option was specified and we have UID/GID info, restore it */
37      if (have_uidgid_flg) {
38          TTrace((stderr, "close_outfile:  restoring Unix UID/GID info\n"));
39 -        if (chown(G.filename, (uid_t)z_uidgid[0], (gid_t)z_uidgid[1]))
40 +        if (fchown(fileno(G.outfile), (uid_t)z_uidgid[0], (gid_t)z_uidgid[1]))
41          {
42              if (uO.qflag)
43                  Info(slide, 0x201, ((char *)slide,
44 @@ -1133,6 +1138,8 @@
45          }
46      }
47  
48 +    fclose(G.outfile);
49 +
50      /* set the file's access and modification times */
51      if (utime(G.filename, &(zt.t2))) {
52  #ifdef AOS_VS
53 @@ -1156,11 +1163,6 @@
54      zipfile.
55    ---------------------------------------------------------------------------*/
56  
57 -#ifndef NO_CHMOD
58 -    if (chmod(G.filename, filtattr(__G__ G.pInfo->file_attr)))
59 -        perror("chmod (file attributes) error");
60 -#endif
61 -
62  } /* end function close_outfile() */
63  
64  #endif /* !MTS */