diff options
author | Kamil Dudka <kdudka@redhat.com> | 2011-04-04 12:43:39 +0200 |
---|---|---|
committer | Andreas Gruenbacher <agruen@linbit.com> | 2011-04-04 18:40:55 +0200 |
commit | 6bf5e24d48077db58b389e90558100fc121b8134 (patch) | |
tree | fc760711729113152560c1aae6b9e800d935d80f /libacl | |
parent | cd31bafa745bb0603a26a39ad8d7e4abd2756c10 (diff) | |
download | acl-6bf5e24d48077db58b389e90558100fc121b8134.tar.gz |
libacl: Add acl_extended_file_nofollow()
This function calls lgetxattr() instead of getxattr(), which helps ls(1)
to prevent unnecessary automatic mounts, which acl_extended_file()
triggers. See the following bug report for more details:
https://bugzilla.redhat.com/692982
Diffstat (limited to 'libacl')
-rw-r--r-- | libacl/Makefile | 3 | ||||
-rw-r--r-- | libacl/__acl_extended_file.c | 49 | ||||
-rw-r--r-- | libacl/__acl_extended_file.h | 4 | ||||
-rw-r--r-- | libacl/acl_extended_file.c | 20 | ||||
-rw-r--r-- | libacl/acl_extended_file_nofollow.c | 34 |
5 files changed, 92 insertions, 18 deletions
diff --git a/libacl/Makefile b/libacl/Makefile index 1224b65..cfe3d3a 100644 --- a/libacl/Makefile +++ b/libacl/Makefile @@ -47,7 +47,8 @@ POSIX_CFILES = \ LIBACL_CFILES = \ acl_to_any_text.c acl_entries.c acl_check.c acl_error.c acl_cmp.c \ - acl_extended_fd.c acl_extended_file.c acl_equiv_mode.c acl_from_mode.c + acl_extended_fd.c acl_extended_file.c acl_equiv_mode.c acl_from_mode.c \ + acl_extended_file_nofollow.c __acl_extended_file.c INTERNAL_CFILES = \ __acl_to_any_text.c __acl_to_xattr.c __acl_from_xattr.c \ diff --git a/libacl/__acl_extended_file.c b/libacl/__acl_extended_file.c new file mode 100644 index 0000000..629afe9 --- /dev/null +++ b/libacl/__acl_extended_file.c @@ -0,0 +1,49 @@ +/* + File: acl_extended_file.c + + Copyright (C) 2000, 2011 + Andreas Gruenbacher, <a.gruenbacher@bestbits.at> + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include <unistd.h> +#include <attr/xattr.h> +#include "libacl.h" + +#include "byteorder.h" +#include "acl_ea.h" +#include "__acl_extended_file.h" + + +int +__acl_extended_file(const char *path_p, getxattr_t fun) +{ + int base_size = sizeof(acl_ea_header) + 3 * sizeof(acl_ea_entry); + int retval; + + retval = fun(path_p, ACL_EA_ACCESS, NULL, 0); + if (retval < 0 && errno != ENOATTR && errno != ENODATA) + return -1; + if (retval > base_size) + return 1; + retval = fun(path_p, ACL_EA_DEFAULT, NULL, 0); + if (retval < 0 && errno != ENOATTR && errno != ENODATA) + return -1; + if (retval >= base_size) + return 1; + return 0; +} + diff --git a/libacl/__acl_extended_file.h b/libacl/__acl_extended_file.h new file mode 100644 index 0000000..f8881a1 --- /dev/null +++ b/libacl/__acl_extended_file.h @@ -0,0 +1,4 @@ +typedef ssize_t (*getxattr_t)(const char *, const char *, void *value, + size_t size); + +int __acl_extended_file(const char *path_p, getxattr_t fun); diff --git a/libacl/acl_extended_file.c b/libacl/acl_extended_file.c index d1cb85d..f417784 100644 --- a/libacl/acl_extended_file.c +++ b/libacl/acl_extended_file.c @@ -1,7 +1,7 @@ /* File: acl_extended_file.c - Copyright (C) 2000 + Copyright (C) 2011 Andreas Gruenbacher, <a.gruenbacher@bestbits.at> This program is free software; you can redistribute it and/or @@ -23,26 +23,12 @@ #include <attr/xattr.h> #include "libacl.h" -#include "byteorder.h" -#include "acl_ea.h" +#include "__acl_extended_file.h" int acl_extended_file(const char *path_p) { - int base_size = sizeof(acl_ea_header) + 3 * sizeof(acl_ea_entry); - int retval; - - retval = getxattr(path_p, ACL_EA_ACCESS, NULL, 0); - if (retval < 0 && errno != ENOATTR && errno != ENODATA) - return -1; - if (retval > base_size) - return 1; - retval = getxattr(path_p, ACL_EA_DEFAULT, NULL, 0); - if (retval < 0 && errno != ENOATTR && errno != ENODATA) - return -1; - if (retval >= base_size) - return 1; - return 0; + return __acl_extended_file(path_p, getxattr); } diff --git a/libacl/acl_extended_file_nofollow.c b/libacl/acl_extended_file_nofollow.c new file mode 100644 index 0000000..8f4711f --- /dev/null +++ b/libacl/acl_extended_file_nofollow.c @@ -0,0 +1,34 @@ +/* + File: acl_extended_file.c + + Copyright (C) 2011 + Andreas Gruenbacher, <a.gruenbacher@bestbits.at> + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +#include <unistd.h> +#include <attr/xattr.h> +#include "libacl.h" + +#include "__acl_extended_file.h" + + +int +acl_extended_file_nofollow(const char *path_p) +{ + return __acl_extended_file(path_p, lgetxattr); +} + |