touch question
am 07.01.2008 16:50:57 von Robert Latest
Hello,
is it correct or a bug that only the owner of a file can use "touch" to set
the modification time of a file to some arbitrary time? For testing
purposes, I've got a file with mode 666 in a mode 777 directory, owned by
another user, but I can't "touch" it. Why?
robert
Re: touch question
am 07.01.2008 18:26:06 von Icarus Sparry
On Mon, 07 Jan 2008 15:50:57 +0000, Robert Latest wrote:
> Hello,
>
> is it correct or a bug that only the owner of a file can use "touch" to
> set the modification time of a file to some arbitrary time? For testing
> purposes, I've got a file with mode 666 in a mode 777 directory, owned
> by another user, but I can't "touch" it. Why?
>
> robert
From the man page for utimes
NAME utime, utimes - change access and/or modification times of an
inode
SYNOPSIS #include #include
int utime(const char *filename, const struct utimbuf *buf);
#include
int utimes(const char *filename, const struct timeval times[2]);
DESCRIPTION utime() changes the access and modification times of the
inode specified by filename to the actime and modtime fields of buf
respectively.
If buf is NULL, then the access and modification times of the
file are set to the current time.
Changing time stamps is permitted when: either the process has
appropriate privileges (Linux: has the CAP_FOWNER capability), or the
effective user ID equals the user ID of the file, or buf is NULL and
the process has write per- mission to the file.
So the behaviour is correct. You have to have an EUID equal to the owner
of the file to set an arbitary time. You can set it to the current time
just by having write permission.
Re: touch question
am 08.01.2008 04:41:33 von Barry Margolin
In article <478260ae$0$84195$742ec2ed@news.sonic.net>,
Icarus Sparry wrote:
> So the behaviour is correct. You have to have an EUID equal to the owner
> of the file to set an arbitary time. You can set it to the current time
> just by having write permission.
I presume the intent is that the owner might want to know when people
have written to his file. They shouldn't be able to write to the file
and then hide it by reverting the modification time.
--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
Re: touch question
am 08.01.2008 09:58:45 von Robert Latest
Barry Margolin wrote:
> I presume the intent is that the owner might want to know when people
> have written to his file. They shouldn't be able to write to the file
> and then hide it by reverting the modification time.
Yeah, makes sense.
robert