Should the set/get/listxattr() callbacks follow symlinks?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Should the set/get/listxattr() callbacks follow symlinks?

Goswin von Brederlow-2
Hi,

I've got a little problem with unionfs_fuse. When I run "ls
/etc/ssmtp" I get:

ls: /etc/ssmtp: Too many levels of symbolic links
/etc/ssmpt -> /etc/qlustar/common/ssmpt

The reason for this is that the getxattr() callback is called for the
symlink and since there is no lgetxattrat() syscall I have to use:

        int fd = openat(base_fd, path, O_RDONLY | O_NOFOLLOW);
        if (fd == -1) {
          perror("openat (lgetxattr):");
          return -1;
        }
        res = fgetxattr(fd, name, value, size);
        close(fd);
        return res;

The problem here is that openat() fails with ELOOP because of the
O_NOFOLLOW causing the above error.

Should the getxattr() callback follow the symlink or should it return
something else?

MfG
        Goswin

------------------------------------------------------------------------------
The best possible search technologies are now affordable for all companies.
Download your FREE open source Enterprise Search Engine today!
Our experts will assist you in its installation for $59/mo, no commitment.
Test it for FREE on our Cloud platform anytime!
http://pubads.g.doubleclick.net/gampad/clk?id=145328191&iu=/4140/ostg.clktrk
_______________________________________________
fuse-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/fuse-devel
Reply | Threaded
Open this post in threaded view
|

Re: Should the set/get/listxattr() callbacks follow symlinks?

Jean-Pierre André
Hi,

Goswin von Brederlow wrote:

> Hi,
>
> I've got a little problem with unionfs_fuse. When I run "ls
> /etc/ssmtp" I get:
>
> ls: /etc/ssmtp: Too many levels of symbolic links
> /etc/ssmpt -> /etc/qlustar/common/ssmpt
>
> The reason for this is that the getxattr() callback is called for the
> symlink and since there is no lgetxattrat() syscall I have to use:
>
> int fd = openat(base_fd, path, O_RDONLY | O_NOFOLLOW);
> if (fd == -1) {
>  perror("openat (lgetxattr):");
>  return -1;
> }
> res = fgetxattr(fd, name, value, size);
> close(fd);
> return res;
>
> The problem here is that openat() fails with ELOOP because of the
> O_NOFOLLOW causing the above error.
>
> Should the getxattr() callback follow the symlink or should it return
> something else?
>
> MfG
> Goswin

the fuse method getxattr() should not follow the symlinks, but
getxattr(2) follows them. Use lgetxattr(2) to not follow
the symlinks.

getfattr(1) has an option -h to not follow the symlinks.

AFAIR only some kind of xattrs is allowed on symlinks
(either the user ones, or the system ones).

Jean-Pierre


------------------------------------------------------------------------------
The best possible search technologies are now affordable for all companies.
Download your FREE open source Enterprise Search Engine today!
Our experts will assist you in its installation for $59/mo, no commitment.
Test it for FREE on our Cloud platform anytime!
http://pubads.g.doubleclick.net/gampad/clk?id=145328191&iu=/4140/ostg.clktrk
_______________________________________________
fuse-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/fuse-devel
Reply | Threaded
Open this post in threaded view
|

Re: Should the set/get/listxattr() callbacks follow symlinks?

Goswin von Brederlow-2
On Tue, May 27, 2014 at 10:40:52AM +0200, Jean-Pierre André wrote:

> Hi,
>
> Goswin von Brederlow wrote:
> > Hi,
> >
> > I've got a little problem with unionfs_fuse. When I run "ls
> > /etc/ssmtp" I get:
> >
> > ls: /etc/ssmtp: Too many levels of symbolic links
> > /etc/ssmpt -> /etc/qlustar/common/ssmpt
> >
> > The reason for this is that the getxattr() callback is called for the
> > symlink and since there is no lgetxattrat() syscall I have to use:
> >
> > int fd = openat(base_fd, path, O_RDONLY | O_NOFOLLOW);
> > if (fd == -1) {
> >  perror("openat (lgetxattr):");
> >  return -1;
> > }
> > res = fgetxattr(fd, name, value, size);
> > close(fd);
> > return res;
> >
> > The problem here is that openat() fails with ELOOP because of the
> > O_NOFOLLOW causing the above error.
> >
> > Should the getxattr() callback follow the symlink or should it return
> > something else?
> >
> > MfG
> > Goswin
>
> the fuse method getxattr() should not follow the symlinks, but
> getxattr(2) follows them. Use lgetxattr(2) to not follow
> the symlinks.
>
> getfattr(1) has an option -h to not follow the symlinks.
>
> AFAIR only some kind of xattrs is allowed on symlinks
> (either the user ones, or the system ones).
>
> Jean-Pierre

As said there is no lgetxattrat() syscall so I have to use openat()
and fgetxattr(). Using lgetxattr() is not an option.

What should be returned that 1) signals an error when trying to use
xattr on symlinks and 2) does not cause programs like ls to output
irelevant error messages?

MfG
        Goswin

------------------------------------------------------------------------------
The best possible search technologies are now affordable for all companies.
Download your FREE open source Enterprise Search Engine today!
Our experts will assist you in its installation for $59/mo, no commitment.
Test it for FREE on our Cloud platform anytime!
http://pubads.g.doubleclick.net/gampad/clk?id=145328191&iu=/4140/ostg.clktrk
_______________________________________________
fuse-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/fuse-devel
Reply | Threaded
Open this post in threaded view
|

Re: Should the set/get/listxattr() callbacks follow symlinks?

Bernd Schubert-2
Hello Goswin,

On 05/27/2014 12:28 PM, Goswin von Brederlow wrote:

> On Tue, May 27, 2014 at 10:40:52AM +0200, Jean-Pierre André wrote:
>> Hi,
>>
>> Goswin von Brederlow wrote:
>>> Hi,
>>>
>>> I've got a little problem with unionfs_fuse. When I run "ls
>>> /etc/ssmtp" I get:
>>>
>>> ls: /etc/ssmtp: Too many levels of symbolic links
>>> /etc/ssmpt -> /etc/qlustar/common/ssmpt
>>>
>>> The reason for this is that the getxattr() callback is called for the
>>> symlink and since there is no lgetxattrat() syscall I have to use:
>>>
>>> int fd = openat(base_fd, path, O_RDONLY | O_NOFOLLOW);

In principle O_PATH would be the right flag - if xattr wouldn't be
excluded. I guess the reasoning is that xattrs are not neccessarily an
inode operation only.

>>> if (fd == -1) {
>>>  perror("openat (lgetxattr):");
>>>  return -1;
>>> }
>>> res = fgetxattr(fd, name, value, size);
>>> close(fd);
>>> return res;
>>>
>>> The problem here is that openat() fails with ELOOP because of the
>>> O_NOFOLLOW causing the above error.
>>>
>>> Should the getxattr() callback follow the symlink or should it return
>>> something else?

man 2 getxattr

>        If extended attributes are not supported by the filesystem, or are disabled, errno is set to ENOTSUP.


We should probably try to speed up fsetxattrat support:
https://lkml.org/lkml/2014/1/21/192


Cheers,
Bernd


------------------------------------------------------------------------------
Time is money. Stop wasting it! Get your web API in 5 minutes.
www.restlet.com/download
http://p.sf.net/sfu/restlet
_______________________________________________
fuse-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/fuse-devel