[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: "ls -l": Avoid unnecessary getxattr() overhead
From: |
Pádraig Brady |
Subject: |
Re: "ls -l": Avoid unnecessary getxattr() overhead |
Date: |
Thu, 09 Feb 2012 12:02:31 +0000 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:6.0) Gecko/20110816 Thunderbird/6.0 |
On 02/09/2012 11:32 AM, Jim Meyering wrote:
> @@ -2918,10 +2935,17 @@ gobble_file (char const *name, enum filetype type,
> ino_t inode,
> {
> bool have_selinux = false;
> bool have_acl = false;
> - int attr_len = (do_deref
> - ? getfilecon (absolute_name, &f->scontext)
> - : lgetfilecon (absolute_name, &f->scontext));
> + static int prev_errno;
> + int attr_len =
> + (do_deref
> + ? getfilecon (absolute_name, &f->scontext)
> + : (( ! command_line_arg && ! first_lgetfilecon
> + && errno_unsupported (prev_errno))
> + ? (errno = ENOTSUP), -1
> + : lgetfilecon (absolute_name, &f->scontext)));
> + first_lgetfilecon = false;
> err = (attr_len < 0);
> + prev_errno = err ? errno : 0;
>
> if (err == 0)
> have_selinux = ! STREQ ("unlabeled", f->scontext);
>
So you avoid symlinks as they can point outside the device.
Unfortunately so can bind mounts, so you probably have to key on device?
Here is an example for which the above would break I think:
# touch file /dev/shm/file
# setfattr -n "user.foo" -v "bar" file /dev/shm/file
setfattr: /dev/shm/file: Operation not supported
# stat -c %D file /dev/shm/file
812
11
# mount --bind file /dev/shm/file
# stat -c %D file /dev/shm/file
812
812
# getfattr -m- -d /dev/shm/file
getfattr: Removing leading '/' from absolute path names
# file: dev/shm/file
security.selinux="unconfined_u:object_r:admin_home_t:s0"
user.foo="bar"
cheers,
Pádraig.
- "ls -l": Avoid unnecessary getxattr() overhead, Sven Breuner, 2012/02/06
- Re: "ls -l": Avoid unnecessary getxattr() overhead, Jérémy Compostella, 2012/02/06
- Re: "ls -l": Avoid unnecessary getxattr() overhead, Sven Breuner, 2012/02/06
- Re: "ls -l": Avoid unnecessary getxattr() overhead, Jérémy Compostella, 2012/02/06
- Re: "ls -l": Avoid unnecessary getxattr() overhead, Pádraig Brady, 2012/02/06
- Re: "ls -l": Avoid unnecessary getxattr() overhead, Sven Breuner, 2012/02/06
- Re: "ls -l": Avoid unnecessary getxattr() overhead, Jim Meyering, 2012/02/09
- Re: "ls -l": Avoid unnecessary getxattr() overhead,
Pádraig Brady <=
- Re: "ls -l": Avoid unnecessary getxattr() overhead, Jim Meyering, 2012/02/09
- Re: "ls -l": Avoid unnecessary getxattr() overhead, Pádraig Brady, 2012/02/09
- Re: "ls -l": Avoid unnecessary getxattr() overhead, Jim Meyering, 2012/02/09
- Re: "ls -l": Avoid unnecessary getxattr() overhead, Sven Breuner, 2012/02/09
- Re: "ls -l": Avoid unnecessary getxattr() overhead, Jim Meyering, 2012/02/10
- Re: "ls -l": Avoid unnecessary getxattr() overhead, Sven Breuner, 2012/02/09
- Re: "ls -l": Avoid unnecessary getxattr() overhead, Pádraig Brady, 2012/02/09
- Re: "ls -l": Avoid unnecessary getxattr() overhead, Jim Meyering, 2012/02/10
- Re: "ls -l": Avoid unnecessary getxattr() overhead, Sven Breuner, 2012/02/11
- Re: "ls -l": Avoid unnecessary getxattr() overhead, Jim Meyering, 2012/02/16