bin/104702: [patch] Make fetch(1) preserve permissions when overwriting a file

Kevin Day toasty at dragondata.com
Mon Oct 23 00:30:13 PDT 2006


>Number:         104702
>Category:       bin
>Synopsis:       [patch] Make fetch(1) preserve permissions when overwriting a file
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Mon Oct 23 07:30:11 GMT 2006
>Closed-Date:
>Last-Modified:
>Originator:     Kevin Day
>Release:        FreeBSD 6.1-RELEASE amd64
>Organization:
Your.Org, Inc.
>Environment:
System: FreeBSD server28 6.1-RELEASE FreeBSD 6.1-RELEASE #1: Sat Jul 29 06:31:24 UTC 2006 toasty at server28:/usr/src/sys/amd64/compile/SERVER amd64


>Description:

In FreeBSD 4.x, fetch(1) would preserve file permissions when overwriting a file.

Starting in 5.x, fetch applies inconsistent permissions when creating or overwriting an existing file.

New files are given 0644, but overwritten files are given  0600. Not only is this inconsistent, but I believe fetch should preserve permissions when overwriting a file.

>How-To-Repeat:

server29# uname -r
6.1-RELEASE
server29# fetch -o testfile http://www.freebsd.org
testfile                                      100% of   18 kB  128 kBps
server29# ls -l testfile
-rw-r--r--  1 root  wheel  19135 Oct 19 14:37 testfile
server29# chmod 664 testfile
server29# ls -l testfile
-rw-rw-r--  1 root  wheel  19135 Oct 19 14:37 testfile
server29# fetch -o testfile http://www.freebsd.org
testfile                                      100% of   18 kB  128 kBps
server29# ls -l testfile
-rw-------  1 root  wheel  19135 Oct 19 14:37 testfile

>Fix:

--- fetch.c~       Mon Oct 23 02:13:44 2006
+++ fetch.c     Fri Jul 28 23:40:48 2006
@@ -569,6 +569,8 @@
                        if (tmppath != NULL) {
                                mkstemps(tmppath, strlen(slash) + 1);
                                of = fopen(tmppath, "w");
+                               chown(tmppath, sb.st_uid, sb.st_gid);
+                               chmod(tmppath, sb.st_mode & 07777);
                        }
                }
                if (of == NULL)

>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list