4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
11 Problem: Backup file may get wrong permissions.
12 Solution: Use permissions of original file for backup file in more places.
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
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);
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);
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))
43 * A forced write will try to create a new file if the old one is
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)
51 * A forced write will try to create a new file if the old one is
54 if ((fd = mch_open((char *)backup, O_RDONLY | O_EXTRA, 0)) >= 0)
56 if ((write_info.bw_fd = mch_open((char *)fname,
57 ! O_WRONLY | O_CREAT | O_TRUNC | O_EXTRA, 0666)) >= 0)
60 write_info.bw_buf = smallbuf;
62 if ((fd = mch_open((char *)backup, O_RDONLY | O_EXTRA, 0)) >= 0)
64 if ((write_info.bw_fd = mch_open((char *)fname,
65 ! O_WRONLY | O_CREAT | O_TRUNC | O_EXTRA,
69 write_info.bw_buf = smallbuf;
74 || (empty_fd = mch_open(org, O_CREAT | O_EXTRA | O_EXCL,
76 EMSG(_("E206: patchmode: can't touch empty original file"));
82 || (empty_fd = mch_open(org, O_CREAT | O_EXTRA | O_EXCL,
84 EMSG(_("E206: patchmode: can't touch empty original file"));
95 + vim_acl_T acl; /* ACL from original file */
99 * When the names are identical, there is nothing to do.
103 * Rename() failed, try copying the file.
105 fd_in = mch_open((char *)from, O_RDONLY|O_EXTRA, 0);
108 ! fd_out = mch_open((char *)to, O_CREAT|O_EXCL|O_WRONLY|O_EXTRA, 0666);
114 * Rename() failed, try copying the file.
116 + perm = mch_getperm(from);
118 + /* For systems that support ACL: get the ACL from the original file. */
119 + acl = mch_get_acl(from);
121 fd_in = mch_open((char *)from, O_RDONLY|O_EXTRA, 0);
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);
133 errmsg = _("E210: Error reading \"%s\"");
136 + mch_setperm(to, perm);
138 + mch_set_acl(to, acl);
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
148 { /* Add new patch number below this line */
154 Why is "abbreviation" such a long word?
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 ///