Subject: lib/12751: utimes not working as advertised
To: None <gnats-bugs@gnats.netbsd.org>
From: None <mrauch@fs.tum.de>
List: netbsd-bugs
Date: 04/25/2001 19:47:21
>Number:         12751
>Category:       lib
>Synopsis:       utimes(2) not working when user != fileowner
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Wed Apr 25 10:47:00 PDT 2001
>Closed-Date:
>Last-Modified:
>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:
>Unformatted: