/* * Copyright (C) 2006 James Antill * * This library 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 of the License, or (at your option) any later version. * * This library 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 * * email: james@and.org */ /* Filters for an Xattr list */ #include "xattr_filter.h" #include void xattr_filter(Xattrs *xattrs, int (*filter)(const Xattr_node *)) { size_t scan = 0; while (scan < xattrs->num) { if ((*filter)(xattrs->ents + scan)) { xattr_del(xattrs, scan + 1); continue; } ++scan; } } int xattr_sc_filter_user(const Xattr_node *node) { if (strncmp(node->key, "user.", strlen("user."))) return (1); return (0); } int xattr_sc_filter2_user(const Xattr_node *node) { return !xattr_sc_filter_user(node); } int xattr_sc_filter_trusted(const Xattr_node *node) { if (strncmp(node->key, "trusted.", strlen("trusted."))) return (1); return (0); } int xattr_sc_filter2_trusted(const Xattr_node *node) { return !xattr_sc_filter_trusted(node); } int xattr_sc_filter_generic(const Xattr_node *node) { return (xattr_sc_filter_user(node) || xattr_sc_filter_trusted(node)); } int xattr_sc_filter2_generic(const Xattr_node *node) { return !xattr_sc_filter_generic(node); } int xattr_sc_filter_acls(const Xattr_node *node) { /* filter both system.posix_acl_access and system.posix_acl_default */ if (strncmp(node->key, "system.posix_acl_", strlen("system.posix_acl_"))) return (1); return (0); } int xattr_sc_filter2_acls(const Xattr_node *node) { return !xattr_sc_filter_acls(node); } int xattr_sc_filter_selinux(const Xattr_node *node) { if (strncmp(node->key, "security.selinux", strlen("security.selinux"))) return (1); return (0); } int xattr_sc_filter2_selinux(const Xattr_node *node) { return !xattr_sc_filter_selinux(node); }