Re: how to get fullname from inode_symlink() ?

From: Serge E. Hallyn (serue@private)
Date: Fri Dec 16 2005 - 07:05:57 PST


Quoting NAHieu (nahieu@private):
> Hello,
> 
> I have a problem when trying to hook inode_symlink(). According to
> security.h, this hook and its args like below:
> 
> --
> int (*inode_symlink) (struct inode *dir, struct dentry *dentry, const
> char *old_name);
> 
>  * @inode_symlink:
>  *      Check the permission to create a symbolic link to a file.
>  *      @dir contains the inode structure of parent directory of the
> symbolic link.
>  *      @dentry contains the dentry structure of the symbolic link.
>  *      @old_name contains the pathname of file.
>  *      Return 0 if permission is granted.
> ---
> 
> Of 3 args, the last one old_name should give us the full-name of the
> "original" file (which has a new file points to), but that is not the

Wrong.  Nowhere does it say "full-name".  Both paths are relative to
@dir.

Admittedly it could probably stand to be spelled out in the description,
at least whether it is relative to @dir or to current->cwd.  But both
looking at more code (i.e. fs/ext2/namei.c:ext2_symlink) and simple
experimentation (cd /home/$USER; strace ln -s ../../etc/fstab
work/fstab; ls -ld work/fstab) would give you the answer.

-serge



This archive was generated by hypermail 2.1.3 : Fri Dec 16 2005 - 07:07:00 PST