From nobody@FreeBSD.org  Tue Feb 22 04:13:59 2005
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 292DB16A4CE
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 22 Feb 2005 04:13:59 +0000 (GMT)
Received: from www.freebsd.org (www.freebsd.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id E062443D64
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 22 Feb 2005 04:13:58 +0000 (GMT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.13.1/8.13.1) with ESMTP id j1M4Dwta038418
	for <freebsd-gnats-submit@FreeBSD.org>; Tue, 22 Feb 2005 04:13:58 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.13.1/8.13.1/Submit) id j1M4DwcA038417;
	Tue, 22 Feb 2005 04:13:58 GMT
	(envelope-from nobody)
Message-Id: <200502220413.j1M4DwcA038417@www.freebsd.org>
Date: Tue, 22 Feb 2005 04:13:58 GMT
From: Guy Harris <guy@alum.mit.edu>
To: freebsd-gnats-submit@FreeBSD.org
Subject: NFS server should set VA_UTIMES_NULL in a v3 SETATTR if both the accessed and modified times are NFSV3SATTRTIME_TOSERVER
X-Send-Pr-Version: www-2.3

>Number:         77904
>Category:       kern
>Synopsis:       [nfs] NFS server should set VA_UTIMES_NULL in a v3 SETATTR if both the accessed and modified times are NFSV3SATTRTIME_TOSERVER
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Feb 22 04:20:13 GMT 2005
>Closed-Date:    Fri Apr 07 02:53:18 GMT 2006
>Last-Modified:  Fri Apr 07 02:53:18 GMT 2006
>Originator:     Guy Harris
>Release:        6.0-current
>Organization:
>Environment:
>Description:
A v3 SETATTR with both the access and modified times set with NFSV3SATTRTIME_TOSERVER should be treated the same as utimes(..., NULL), so that any user with write access to the file can set both times to the current time, to allow utimes(..., NULL to work over NFS).
>How-To-Repeat:
      
>Fix:
Commit 1.136.2.2 src/sys/nfsserver/nfs_srvsubs.c in RELENG_6
has addressed this, as noted by Rong-En Fan below.  This change
has also been committed to RELENG_5 and CURRENT.
>Release-Note:
>Audit-Trail:

From: Guy Harris <guy@alum.mit.edu>
To: freebsd-gnats-submit@FreeBSD.org
Cc:  
Subject: Re: kern/77904: NFS server should set VA_UTIMES_NULL in a v3 SETATTR
 if both the accessed and modified times are NFSV3SATTRTIME_TOSERVER
Date: Mon, 21 Feb 2005 21:05:55 -0800

 NetBSD's nfsm_srvsattr() does
 
                  nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
                  switch (fxdr_unsigned(int, *tl)) { \
                  case NFSV3SATTRTIME_TOCLIENT: \
                          nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
                          fxdr_nfsv3time(tl, &(a)->va_atime); \
                          break; \
                  case NFSV3SATTRTIME_TOSERVER: \
                          (a)->va_atime.tv_sec = time.tv_sec; \
                          (a)->va_atime.tv_nsec = time.tv_usec * 1000; \
                          (a)->va_vaflags |= VA_UTIMES_NULL; \
                          break; \
                  }; \
                  nfsm_dissect(tl, u_int32_t *, NFSX_UNSIGNED); \
                  switch (fxdr_unsigned(int, *tl)) { \
                  case NFSV3SATTRTIME_TOCLIENT: \
                          nfsm_dissect(tl, u_int32_t *, 2 * NFSX_UNSIGNED); \
                          fxdr_nfsv3time(tl, &(a)->va_mtime); \
                          (a)->va_vaflags &= ~VA_UTIMES_NULL; \
                          break; \
                  case NFSV3SATTRTIME_TOSERVER: \
                          (a)->va_mtime.tv_sec = time.tv_sec; \
                          (a)->va_mtime.tv_nsec = time.tv_usec * 1000; \
                          (a)->va_vaflags |= VA_UTIMES_NULL; \
                          break; \
                  }; }

From: Rong-En Fan <rafan@infor.org>
To: bug-followup@FreeBSD.org, guy@alum.mit.edu
Cc:  
Subject: =?iso-8859-1?Q?Re: kern/77904: [nfs] NFS server should set VA=5fUTIMES=5fNULL in a v3 SETATTR if both the accessed and modified times are NFSV3SATTRTIME=5fTOSERVER?=
Date: Thu, 6 Apr 2006 23:43:32 +0800 (CST)

 Hi,
 
 Followed by cvs-src mailing, I think this problem is solved by
 cel@'s commit to sys/nfsserver/nfs_srvsubs.c rev 1.136.2.2 on
 RELENG_6.
 
 I did a simple test on RELENG_6, my program is
 
 #include <stdio.h>
 #include <sys/time.h>
 #include <err.h>
 
 int
 main(int argc, char *argv[])
 {
         int error;
 
         if (argc != 2)
                 exit(1);
         error = utimes(argv[1], NULL);
         if (error != 0)
                 err(error, "failed");
         return 0;
 }
 
 Three test file on nfs:
 -rw-r--r--  1 root   wheel  0 Apr  6 10:53 /data/a
 -rw-rw----  1 root   rafan  0 Apr  6 10:53 /data/b
 -rw-r--r--  1 rafan  wheel  0 Apr  6 21:59 /data/c
 
 Before the change:
 $ id
 uid=1002(rafan) gid=1002(rafan) groups=1002(rafan)
 $ ./p /data/a
 p: failed: Operation not permitted
 $ ./p /data/b
 p: failed: Operation not permitted
 $ ./p /data/c
 $
 
 After the change:
 $ id
 uid=1002(rafan) gid=1002(rafan) groups=1002(rafan)
 $ ./p /data/a
 p: failed: Permission denied
 $ ./p /data/b
 $ ./p /data/c
 $
 
 The server is running RELENG_6 as of Apr 6. So, I think is pr
 can be closed? Also, 77902 should be also closed if this one
 is closed.
 
 Regards,
 Rong-En Fan
State-Changed-From-To: open->closed 
State-Changed-By: cel 
State-Changed-When: Fri Apr 7 02:47:54 UTC 2006 
State-Changed-Why:  
Bug was fixed by a recent commit. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=77904 
>Unformatted:
