coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Cmd mv: Owner/group copy


From: Filip Kocina
Subject: Re: Cmd mv: Owner/group copy
Date: Mon, 11 Feb 2013 09:59:39 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.12) Gecko/20130108 Thunderbird/10.0.12

Bob Proulx wrote:
> Moving a file on the same filesystem does not copy the file.  Moving a
> file from one directory to another on the same filesystem simply
> creates a new inode pointer in the new directory and deletes the inode
> pointer from the old.  The data in the file itself is unchanged.
> Effectively the file did not move at all but only the directory
> entries pointing to it.  It is only the directory that changes.
> 
>   dir1 --> file1     dir2
>   dir1     file1 <-- dir2
> 
> Moving a file from one filesystem to another does necessarily mean
> copying the file.  In that case it is similar to a cp then rm.  The
> permissions and ownership depend upon the priviledge of the user
> process doing the copy and remove.  Root is the superuser and has full
> permission and the file will be as similar as possible to the previous
> move on the same filesystem.  But non-root will be left with owning
> the file.

Thank you for refreshing - I'm familiar with this.

> Also think about the case where a file has many hardlinks to it.
> There is exactly one file and one inode and the perm:owner:group is
> stored in the inode.  Moving a file on the same filesystem does not
> change this but just creates a new hardlink and deletes the old.

I hadn't been aware of that, that's exactly the explanation I needed.

> You did not explain the problem with a "not very smooth-tongued name,
> the user who owns this file could be compromised" and therefore I do
> not understand the problem you are worried about.  As you might
> imagine this policy has been around for many decades and if there were
> a security problem with it then it would have been fixed years ago.
> Therefore it probably doesn't have a problem.

I meant some bad name, e.g. containing an obscene word, but as I noted
above thanks to you I now understand, the behavior is surely correct.

> With great power comes great responsibility.  The root superuser must
> be careful.  Root does have the power to create problems.  It needs
> this in order to solve problems.
> 
> There is no such problem for a non-root normal user.

Yes, I mentioned that in previous e-mail (not to move file into a
directory of another user).


Thank you very much for your comprehensive answer.

-- 
Filip Kocina
E-mail: address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]