NetBSD Problem Report #12751

Received: (qmail 11871 invoked from network); 25 Apr 2001 17:46:57 -0000
Message-Id: <200104251747.f3PHlLR11220@mimas.fachschaften.tu-muenchen.de>
Date: Wed, 25 Apr 2001 19:47:21 +0200 (CEST)
From: mrauch@fs.tum.de
Reply-To: mrauch@fs.tum.de
To: gnats-bugs@gnats.netbsd.org
Subject: utimes not working as advertised
X-Send-Pr-Version: 3.95

>Number:         12751
>Category:       lib
>Synopsis:       utimes(2) not working when user != fileowner
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people
>State:          analyzed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Apr 25 17:47:00 +0000 2001
>Closed-Date:    
>Last-Modified:  Mon Feb 28 14:58:14 +0000 2011
>Originator:     Michael Rauch
>Release:        1.5
>Organization:
FS MPI / TUM
>Environment:
System: NetBSD mimas 1.5 NetBSD 1.5 (GENERIC) #1: Wed Nov 29 00:29:52 MET 2000 root@flambard:/usr/src/sys/arch/sparc/compile/GENERIC sparc


>Description:
The man page of utimes(2) states that calling this function with the name of 
a file that isn't owned by the user, only writeable, and a second argument
of NULL will update the timestamps on this file to the current time. 
Instead the function returns -1 and errno = 1 (EPERM). 

This bug also affects gtouch in pkgsrc/sysutils/fileutils. 
>How-To-Repeat:
gcc -o utimesbug utimesbug.c
./utimesbug <file>
(where <file> is writeable for the current user but not owned by)
utimesbug.c:
---------------snip----------------
#include <stddef.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
#include <sys/time.h>

int main(int argc, char *argv[]) {
  if (argc!=2) {
    printf("usage: %s <file> \n",argv[0]);
    exit(1);
  }
  if (utimes(argv[1],NULL) != 0) {
    printf("Error #%d \n",errno);
  } else {
    printf("ok \n");
  }
  exit(0);
}
---------------snip------------------
>Fix:

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: kleink 
State-Changed-When: Sun May 6 04:20:51 PDT 2001 
State-Changed-Why:  
I can't reproduce this on an ffs-based file system. Can you provide me with: 
* id(1) output, 
* ls -l output on the relevant files, and 
* the file system type this is happening on? 


Responsible-Changed-From-To: lib-bug-people->kleink 
Responsible-Changed-By: kleink 
Responsible-Changed-When: Sun May 6 04:20:51 PDT 2001 
Responsible-Changed-Why:  
I'm investigating this. 

From: Michael Rauch <mrauch@fs.tum.de>
To: kleink@netbsd.org
Cc: lib-bug-people@netbsd.org
Subject: Re: lib/12751
Date: Sun, 6 May 2001 14:06:14 +0200

 Hi, 

 On Sun, May 06, 2001 at 11:27:08AM -0000, kleink@netbsd.org wrote:
 > Synopsis: utimes(2) not working when user != fileowner
 > 
 > State-Changed-Why: 
 > I can't reproduce this on an ffs-based file system. Can you provide me with:
 > * id(1) output,
 > * ls -l output on the relevant files, and
 > * the file system type this is happening on?

 The file system is an NFS filesystem. I also checked on a local disk and 
 there it actually works (Sorry for forgetting to check this before 
 sending my PR.).

 Here's a transcript of a session with the relevant information:
 (/aux.old/mrauch/test is the program I sent with my PR.)

 mrauch@mimas: ~ $ touch utimes.test
 mrauch@mimas: ~ $ chmod 666 utimes.test
 mrauch@mimas: ~ $ ls -l utimes.test
 -rw-rw-rw-    1 mrauch   mrauch          0 May  6 13:50 utimes.test
 mrauch@mimas: ~ $ id
 uid=22534(mrauch) gid=22534(mrauch) 
 groups=22534(mrauch),400(semspr),511(webadmin),533(www),607(litfasmpi),
 608(ausschussmpi),609(fsmpi),610(latex),616(fbrphysik),682(komvophys),900(soft)
 mrauch@mimas: ~ $ su berichte
 Password:
 berichte@mimas: /export/home/mrauch $ /aux.old/mrauch/test utimes.test
 Error #1
 berichte@mimas: /export/home/mrauch $ id
 uid=40042(berichte) gid=40042(berichte) 
 groups=40042(berichte),533(www),607(litfasmpi),608(ausschussmpi)
 berichte@mimas: /export/home/mrauch $ ls -l utimes.test
 -rw-rw-rw-    1 mrauch   mrauch          0 May  6 13:50 utimes.test
 berichte@mimas: /export/home/mrauch $ vi utimes.test
 [insert a character and save]
 berichte@mimas: /export/home/mrauch $ ls -l utimes.test
 -rw-rw-rw-    1 mrauch   mrauch          2 May  6 13:53 utimes.test
 berichte@mimas: /export/home/mrauch $

 Maybe the following information is also relevant:
 NFS server "uname -a" - output:
 NetBSD mars 1.4.2 NetBSD 1.4.2 (GENERIC) #2: Thu Mar 16 00:08:53 PST 2000     
 toddpw@threepio.toddpw.net:/usr/src/sys/arch/sparc/compile/GENERIC sparc


 Michael

State-Changed-From-To: feedback->analyzed 
State-Changed-By: kleink 
State-Changed-When: Sun May 6 07:05:50 PDT 2001 
State-Changed-Why:  
This is a problem specific to NFS filesystems; it's not clear to me whether 
the NFS protocol make provisions for that particular case (`times' being 
NULL, VA_UTIMES_NULL). 


Responsible-Changed-From-To: kleink->fvdl 
Responsible-Changed-By: kleink 
Responsible-Changed-When: Sun May 6 07:05:50 PDT 2001 
Responsible-Changed-Why:  
I'll defer to the in-house NFS guru. 
Responsible-Changed-From-To: fvdl->lib-bug-people
Responsible-Changed-By: wiz@NetBSD.org
Responsible-Changed-When: Mon, 28 Feb 2011 14:58:14 +0000
Responsible-Changed-Why:
Reset responsible field for retired developer.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.