]> git.pld-linux.org Git - packages/vim.git/blob - 6.3.066
- up to 6.4.001 (but some todo issues left)
[packages/vim.git] / 6.3.066
1 To: vim-dev@vim.org
2 Subject: Patch 6.3.066
3 Fcc: outbox
4 From: Bram Moolenaar <Bram@moolenaar.net>
5 Mime-Version: 1.0
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
8 ------------
9
10 Patch 6.3.066
11 Problem:    Backup file may get wrong permissions.
12 Solution:   Use permissions of original file for backup file in more places.
13 Files:      src/fileio.c
14
15
16 *** ../vim-6.3.029/src/fileio.c Sat Sep 18 21:13:25 2004
17 --- src/fileio.c        Fri Mar 18 12:56:41 2005
18 ***************
19 *** 3314,3320 ****
20                     /* Open with O_EXCL to avoid the file being created while
21                      * we were sleeping (symlink hacker attack?) */
22                     bfd = mch_open((char *)backup,
23 !                                      O_WRONLY|O_CREAT|O_EXTRA|O_EXCL, 0666);
24                     if (bfd < 0)
25                     {
26                         vim_free(backup);
27 --- 3314,3320 ----
28                     /* Open with O_EXCL to avoid the file being created while
29                      * we were sleeping (symlink hacker attack?) */
30                     bfd = mch_open((char *)backup,
31 !                               O_WRONLY|O_CREAT|O_EXTRA|O_EXCL, perm & 0777);
32                     if (bfd < 0)
33                     {
34                         vim_free(backup);
35 ***************
36 *** 3698,3704 ****
37       while ((fd = mch_open((char *)wfname, O_WRONLY | O_EXTRA | (append
38                         ? (forceit ? (O_APPEND | O_CREAT) : O_APPEND)
39                         : (O_CREAT | O_TRUNC))
40 !                       , 0666)) < 0)
41       {
42         /*
43          * A forced write will try to create a new file if the old one is
44 --- 3698,3704 ----
45       while ((fd = mch_open((char *)wfname, O_WRONLY | O_EXTRA | (append
46                         ? (forceit ? (O_APPEND | O_CREAT) : O_APPEND)
47                         : (O_CREAT | O_TRUNC))
48 !                       , perm & 0777)) < 0)
49       {
50         /*
51          * A forced write will try to create a new file if the old one is
52 ***************
53 *** 4104,4110 ****
54                 if ((fd = mch_open((char *)backup, O_RDONLY | O_EXTRA, 0)) >= 0)
55                 {
56                     if ((write_info.bw_fd = mch_open((char *)fname,
57 !                         O_WRONLY | O_CREAT | O_TRUNC | O_EXTRA, 0666)) >= 0)
58                     {
59                         /* copy the file. */
60                         write_info.bw_buf = smallbuf;
61 --- 4104,4111 ----
62                 if ((fd = mch_open((char *)backup, O_RDONLY | O_EXTRA, 0)) >= 0)
63                 {
64                     if ((write_info.bw_fd = mch_open((char *)fname,
65 !                                   O_WRONLY | O_CREAT | O_TRUNC | O_EXTRA,
66 !                                                          perm & 0777)) >= 0)
67                     {
68                         /* copy the file. */
69                         write_info.bw_buf = smallbuf;
70 ***************
71 *** 4261,4267 ****
72   
73             if (org == NULL
74                     || (empty_fd = mch_open(org, O_CREAT | O_EXTRA | O_EXCL,
75 !                                                                  0666)) < 0)
76               EMSG(_("E206: patchmode: can't touch empty original file"));
77             else
78               close(empty_fd);
79 --- 4262,4268 ----
80   
81             if (org == NULL
82                     || (empty_fd = mch_open(org, O_CREAT | O_EXTRA | O_EXCL,
83 !                                                           perm & 0777)) < 0)
84               EMSG(_("E206: patchmode: can't touch empty original file"));
85             else
86               close(empty_fd);
87 ***************
88 *** 5693,5698 ****
89 --- 5694,5703 ----
90       BPTR      flock;
91   #endif
92       struct stat       st;
93 +     long      perm;
94 + #ifdef HAVE_ACL
95 +     vim_acl_T acl;            /* ACL from original file */
96 + #endif
97   
98       /*
99        * When the names are identical, there is nothing to do.
100 ***************
101 *** 5743,5752 ****
102       /*
103        * Rename() failed, try copying the file.
104        */
105       fd_in = mch_open((char *)from, O_RDONLY|O_EXTRA, 0);
106       if (fd_in == -1)
107         return -1;
108 !     fd_out = mch_open((char *)to, O_CREAT|O_EXCL|O_WRONLY|O_EXTRA, 0666);
109       if (fd_out == -1)
110       {
111         close(fd_in);
112 --- 5748,5764 ----
113       /*
114        * Rename() failed, try copying the file.
115        */
116 +     perm = mch_getperm(from);
117 + #ifdef HAVE_ACL
118 +     /* For systems that support ACL: get the ACL from the original file. */
119 +     acl = mch_get_acl(from);
120 + #endif
121       fd_in = mch_open((char *)from, O_RDONLY|O_EXTRA, 0);
122       if (fd_in == -1)
123         return -1;
124
125 !     /* Create the new file with same permissions as the original. */
126 !     fd_out = mch_open((char *)to, O_CREAT|O_EXCL|O_WRONLY|O_EXTRA, (int)perm);
127       if (fd_out == -1)
128       {
129         close(fd_in);
130 ***************
131 *** 5777,5782 ****
132 --- 5789,5798 ----
133         errmsg = _("E210: Error reading \"%s\"");
134         to = from;
135       }
136 +     mch_setperm(to, perm);
137 + #ifdef HAVE_ACL
138 +     mch_set_acl(to, acl);
139 + #endif
140       if (errmsg != NULL)
141       {
142         EMSG2(errmsg, to);
143 *** ../vim-6.3.029/src/version.c        Fri Mar 18 10:56:48 2005
144 --- src/version.c       Fri Mar 18 13:36:18 2005
145 ***************
146 *** 643,644 ****
147 --- 643,646 ----
148   {   /* Add new patch number below this line */
149 + /**/
150 +     66,
151   /**/
152
153 -- 
154 Why is "abbreviation" such a long word?
155
156  /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net   \\\
157 ///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
158 \\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
159  \\\     Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html   ///
This page took 0.033573 seconds and 3 git commands to generate.