[comp.unix.questions] Symbolic link

quang@CSUFRES.CSUFRESNO.EDU (Quang Ngo) (05/20/91)

I have a simple question:

If someone were to make a symbolic link to my account (if I accidentally
left it opened), then how do I know?  How would I remove it?  

Thanks,

-Quang (quang@csufres.CSUFresno.EDU)

gwyn@smoke.brl.mil (Doug Gwyn) (05/21/91)

In article <9105200532.AA27396@csufres.CSUFresno.EDU> quang@CSUFRES.CSUFRESNO.EDU (Quang Ngo) writes:
>If someone were to make a symbolic link to my account (if I accidentally
>left it opened), then how do I know?  How would I remove it?  

The question makes no sense.  You do not "leave an account opened" on UNIX.
A symbolic link can name any target, whether or not it exists or is
protected against access.  The target of a symbolic link, if it exists, is
not modified in any way.  To find symbolic links to a designated path, you
would have to search the entire hierarchical file system, and to do a
thorough job of that you'd need superuser privileges.  You can remove any
entry from any directory for which you have write permission, using the
"rm" utility.

Do any of these facts help answer whatever your question REALLY was?

mouse@thunder.mcrcim.mcgill.edu (der Mouse) (05/24/91)

In article <9105200532.AA27396@csufres.CSUFresno.EDU>, quang@CSUFRES.CSUFRESNO.EDU (Quang Ngo) writes:

> I have a simple question:

> If someone were to make a symbolic link to my account (if I
> accidentally left it opened), then how do I know?  How would I remove
> it?

The question doesn't really make much sense.  By "to [your] account",
you presumably mean to one of your directories.  I'm not sure what you
mean by leaving it "open[ed]", but I assume this means with some of the
world access bits turned on.

The only permissions involved when creating a symbolic link are those
on the directory in which the link resides.  The place the link points
to does not need to have any permission bits turned on; in fact, it
need not even exist.  So anyone can create a symbolic link pointing to
any of your directories at any time, regardless of how you have your
permission bits set.

So, why isn't this a huge security hole?  Because the permissions are
checked when the link is used, of course.

How would you know?  You wouldn't.  You'd have to search the entire
filesystem, and to do a thorough job of it you'd have to be super-user.
But it doesn't really matter because if you turn off the permission
bits your stuff is inaccessible even if the link does exist.

How would you remove it?  Again, you generally wouldn't.  You'd need to
be able to remove stuff from the directory the link is in, which you
presumably wouldn't have.  But again, it really doesn't much matter.

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu

heinz@cc.univie.ac.at (05/24/91)

In <16213@smoke.brl.mil> gwyn@smoke.brl.mil (Doug Gwyn) writes:

>In article <9105200532.AA27396@csufres.CSUFresno.EDU> quang@CSUFRES.CSUFRESNO.EDU (Quang Ngo) writes:
>>If someone were to make a symbolic link to my account (if I accidentally
>>left it opened), then how do I know?  How would I remove it?

[Stuff deleted]

>thorough job of that you'd need superuser privileges.  You can remove any
>entry from any directory for which you have write permission, using the
>"rm" utility.

The question, as I understand it, was how to remove the symbolic link, motivated
by the following:

One of the major problems with hard links is that if you create a hard link to
another user's file and the owner removes the 'file' (he really removes his
directory entry for the file, which is in fact another hard link itself - the
directory entry, not the file), the file still exists and the user now
may be accounted for a file he doesn't know of any longer (if the
deletion of the file on disk is accompanied by a deletion of the file in
the user's memory :-). This is why the use of hard links should be highly
discouraged, although they can be detected via the link count.

With symbolic links, this problem does not exist, since
a symbolic link only contains the path name of the file (to be exact: it
contains the path name of a hard link to the file), and if this hard link
(= directory entry) is deleted, the symbolic link becomes a dangling pointer and
cannot be used any longer.

So there's no need to find and remove any symbolic links to your directory.
Simply remove the files you want to remove, and the link to them won't be
of use any longer.

I hope this answers your question.

Greetings,
HH
--
--------------------------------------------------------------------------------
---/     Heinz M. Herbeck                    /    Trust me, I know    /       /-
--/     heinz@sophie.pri.univie.ac.at       /    what I'm doing !    /       /--
-/     Vienna University, Austria          /    (Sledge Hammer)     /       /---
--------------------------------------------------------------------------------