[aklug] Re: Strange hard linking

From: Christopher Howard <cmhoward@frigidcode.com>
Date: Fri Nov 26 2010 - 15:26:11 AKST

On Fri, Nov 26, 2010 at 02:57:29PM -0900, Kevin Miller wrote:
> On 11/26/2010 02:24 PM, Christopher Howard wrote:
> > So, I was messing around the other day, and found this rather wierd
> > behavior in Linux:
> >
> > First, I go root, and cd to some public directory. I create a file
> > with some text in it (we'll call it file0) with the new file of
> > course being own by root.
> >
> > Next, I switch back to a regular user account. I cd to my /tmp
> > directory, and use the ln command to create a new file (file1) in the
> > /tmp directory that is a hard link to file0. The new file1, strangely
> > enough, is not own by me, but is owned by root, although it does have
> > "everyone" read permissions.
> >
> > Then, I go root again, and I delete file0. I switch back to my
> > regular user, and discover that file1 still exists, and is still
> > owned by root. I cannot delete it with my regular user account.
> >
> > So, in summary, as a non-root user, I have the ability to "create"
> > (preserve?) files that I do not own and that I cannot delete.
>
> I believe that's because what is really owned is the inode entry. When
> you create the first file, root "owns" the inode. When you create the
> hard link, it's really just a pointer to the inode (If I understand
> arightly). So when you delete the first file, the entry is deleted for
> the public directory but the file still exists as created.
>
> I'm sure my explanation is rather limited - others here can/will
> probably clarify more fully.
>
> What were the world permissions on the original file?
>

Original file was 644, owned by root:root. New file also was 644, owned by root:root.

Hmm... So if I can't remove the inode (owned by root) how to I remove the pointer to the inode? There seems to be an "unlink" program on my box, but it doesn't do the job either.

-- 
Christopher Howard
frigidcode.com
theologia.indicium.us
---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Fri Nov 26 15:31:59 2010

This archive was generated by hypermail 2.1.8 : Fri Nov 26 2010 - 15:31:59 AKST