From 28121c52ac4c22fa1d8539c179f2f4e34f7b35df Mon Sep 17 00:00:00 2001 From: trasz Date: Thu, 25 Jun 2009 13:08:02 +0000 Subject: Fix c194955 - somehow I managed all the new files, tripling their contents. --- lib/libc/posix1e/acl_add_flag_np.3 | 196 ---------- lib/libc/posix1e/acl_branding.c | 332 ---------------- lib/libc/posix1e/acl_clear_flags_np.3 | 158 -------- lib/libc/posix1e/acl_delete_flag_np.3 | 168 --------- lib/libc/posix1e/acl_flag.c | 310 --------------- lib/libc/posix1e/acl_from_text_nfs4.c | 624 ------------------------------- lib/libc/posix1e/acl_get_brand_np.3 | 172 --------- lib/libc/posix1e/acl_get_entry_type_np.3 | 160 -------- lib/libc/posix1e/acl_get_flag_np.3 | 188 ---------- lib/libc/posix1e/acl_get_flagset_np.3 | 166 -------- lib/libc/posix1e/acl_is_trivial_np.3 | 168 --------- lib/libc/posix1e/acl_set_entry_type_np.3 | 190 ---------- lib/libc/posix1e/acl_set_flagset_np.3 | 170 --------- lib/libc/posix1e/acl_strip.c | 400 -------------------- lib/libc/posix1e/acl_strip_np.3 | 218 ----------- lib/libc/posix1e/acl_support_nfs4.c | 512 ------------------------- lib/libc/posix1e/acl_to_text_nfs4.c | 532 -------------------------- 17 files changed, 4664 deletions(-) (limited to 'lib') diff --git a/lib/libc/posix1e/acl_add_flag_np.3 b/lib/libc/posix1e/acl_add_flag_np.3 index 87d5fbd..18222b6 100644 --- a/lib/libc/posix1e/acl_add_flag_np.3 +++ b/lib/libc/posix1e/acl_add_flag_np.3 @@ -96,199 +96,3 @@ The .Fn acl_add_flag_np function was written by .An Edward Tomasz Napierala Aq trasz@FreeBSD.org . -.\"- -.\" Copyright (c) 2008, 2009 Edward Tomasz Napierala -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR THE VOICES IN HIS HEAD BE -.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.\" -.Dd March 10, 2001 -.Dt ACL_ADD_FLAG_NP 3 -.Os -.Sh NAME -.Nm acl_add_flag_np -.Nd add flags to a flagset -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/types.h -.In sys/acl.h -.Ft int -.Fn acl_add_flag_np "acl_flagset_t flagset_d" "acl_flag_t flag" -.Sh DESCRIPTION -The -.Fn acl_add_flag_np -function -is a non-portable call that adds the flags contained in -.Fa flags -to the flagset -.Fa flagset_d . -.Pp -Note: it is not considered an error to attempt to add flags -that already exist in the flagset. -.Pp -Valid values are: -.Pp -.Bl -column -offset 3n "ACL_ENTRY_NO_PROPAGATE_INHERIT" -.It ACL_ENTRY_FILE_INHERIT Will be inherited by files. -.It ACL_ENTRY_DIRECTORY_INHERIT Will be inherited by directories. -.It ACL_ENTRY_NO_PROPAGATE_INHERIT Will not propagate. -.It ACL_ENTRY_INHERIT_ONLY Inherit-only. -.El -.Sh RETURN VALUES -.Rv -std acl_add_flag_np -.Sh ERRORS -The -.Fn acl_add_flag_np -function fails if: -.Bl -tag -width Er -.It Bq Er EINVAL -Argument -.Fa flagset_d -is not a valid descriptor for a flagset within an ACL entry. -Argument -.Fa flag -does not contain a valid -.Vt acl_flag_t -value. -.El -.Sh SEE ALSO -.Xr acl 3 , -.Xr acl_clear_flags_np 3 , -.Xr acl_delete_flag_np 3 , -.Xr acl_get_flagset_np 3 , -.Xr acl_set_flagset_np 3 , -.Xr posix1e 3 -.Sh STANDARDS -POSIX.1e is described in IEEE POSIX.1e draft 17. -.Sh HISTORY -POSIX.1e support was introduced in -.Fx 4.0 . -The -.Fn acl_add_flag_np -function was added in -.Fx 8.0 . -.Sh AUTHORS -The -.Fn acl_add_flag_np -function was written by -.An Edward Tomasz Napierala Aq trasz@FreeBSD.org . -.\"- -.\" Copyright (c) 2008, 2009 Edward Tomasz Napierala -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR THE VOICES IN HIS HEAD BE -.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.\" -.Dd March 10, 2001 -.Dt ACL_ADD_FLAG_NP 3 -.Os -.Sh NAME -.Nm acl_add_flag_np -.Nd add flags to a flagset -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/types.h -.In sys/acl.h -.Ft int -.Fn acl_add_flag_np "acl_flagset_t flagset_d" "acl_flag_t flag" -.Sh DESCRIPTION -The -.Fn acl_add_flag_np -function -is a non-portable call that adds the flags contained in -.Fa flags -to the flagset -.Fa flagset_d . -.Pp -Note: it is not considered an error to attempt to add flags -that already exist in the flagset. -.Pp -Valid values are: -.Pp -.Bl -column -offset 3n "ACL_ENTRY_NO_PROPAGATE_INHERIT" -.It ACL_ENTRY_FILE_INHERIT Will be inherited by files. -.It ACL_ENTRY_DIRECTORY_INHERIT Will be inherited by directories. -.It ACL_ENTRY_NO_PROPAGATE_INHERIT Will not propagate. -.It ACL_ENTRY_INHERIT_ONLY Inherit-only. -.El -.Sh RETURN VALUES -.Rv -std acl_add_flag_np -.Sh ERRORS -The -.Fn acl_add_flag_np -function fails if: -.Bl -tag -width Er -.It Bq Er EINVAL -Argument -.Fa flagset_d -is not a valid descriptor for a flagset within an ACL entry. -Argument -.Fa flag -does not contain a valid -.Vt acl_flag_t -value. -.El -.Sh SEE ALSO -.Xr acl 3 , -.Xr acl_clear_flags_np 3 , -.Xr acl_delete_flag_np 3 , -.Xr acl_get_flagset_np 3 , -.Xr acl_set_flagset_np 3 , -.Xr posix1e 3 -.Sh STANDARDS -POSIX.1e is described in IEEE POSIX.1e draft 17. -.Sh HISTORY -POSIX.1e support was introduced in -.Fx 4.0 . -The -.Fn acl_add_flag_np -function was added in -.Fx 8.0 . -.Sh AUTHORS -The -.Fn acl_add_flag_np -function was written by -.An Edward Tomasz Napierala Aq trasz@FreeBSD.org . diff --git a/lib/libc/posix1e/acl_branding.c b/lib/libc/posix1e/acl_branding.c index cd0f8fc..9839477 100644 --- a/lib/libc/posix1e/acl_branding.c +++ b/lib/libc/posix1e/acl_branding.c @@ -164,335 +164,3 @@ acl_get_brand_np(acl_t acl, int *brand_p) return (0); } -/*- - * Copyright (c) 2008, 2009 Edward Tomasz Napierała - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include - -#include "acl_support.h" - -/* - * An ugly detail of the implementation - fortunately not visible - * to the API users - is the "branding": libc needs to keep track - * of what "brand" ACL is: NFSv4, POSIX.1e or unknown. It happens - * automatically - for example, during acl_get_file(3) ACL gets - * branded according to the "type" argument; during acl_set_permset - * ACL, if its brand is unknown it gets branded as NFSv4 if any of the - * NFSv4 permissions that are not valid for POSIX.1e ACL are set etc. - * Branding information is used for printing out the ACL (acl_to_text(3)), - * veryfying acl_set_whatever arguments (checking against setting - * bits that are valid only for NFSv4 in ACL branded as POSIX.1e) etc. - */ - -static acl_t -entry2acl(acl_entry_t entry) -{ - acl_t aclp; - - aclp = (acl_t)(((long)entry >> _ACL_T_ALIGNMENT_BITS) << _ACL_T_ALIGNMENT_BITS); - - return (aclp); -} - -/* - * Return brand of an ACL. - */ -int -_acl_brand(const acl_t acl) -{ - - return (acl->ats_brand); -} - -int -_entry_brand(const acl_entry_t entry) -{ - - return (_acl_brand(entry2acl(entry))); -} - -/* - * Return 1, iff branding ACL as "brand" is ok. - */ -int -_acl_brand_may_be(const acl_t acl, int brand) -{ - - if (_acl_brand(acl) == ACL_BRAND_UNKNOWN) - return (1); - - if (_acl_brand(acl) == brand) - return (1); - - return (0); -} - -int -_entry_brand_may_be(const acl_entry_t entry, int brand) -{ - - return (_acl_brand_may_be(entry2acl(entry), brand)); -} - -/* - * Brand ACL as "brand". - */ -void -_acl_brand_as(acl_t acl, int brand) -{ - - assert(_acl_brand_may_be(acl, brand)); - - acl->ats_brand = brand; -} - -void -_entry_brand_as(const acl_entry_t entry, int brand) -{ - - _acl_brand_as(entry2acl(entry), brand); -} - -int -_acl_type_not_valid_for_acl(const acl_t acl, acl_type_t type) -{ - - switch (_acl_brand(acl)) { - case ACL_BRAND_NFS4: - if (type == ACL_TYPE_NFS4) - return (0); - break; - - case ACL_BRAND_POSIX: - if (type == ACL_TYPE_ACCESS || type == ACL_TYPE_DEFAULT) - return (0); - break; - } - - return (-1); -} - -void -_acl_brand_from_type(acl_t acl, acl_type_t type) -{ - - switch (type) { - case ACL_TYPE_NFS4: - _acl_brand_as(acl, ACL_BRAND_NFS4); - break; - case ACL_TYPE_ACCESS: - case ACL_TYPE_DEFAULT: - _acl_brand_as(acl, ACL_BRAND_POSIX); - break; - default: - /* XXX: What to do here? */ - break; - } -} - -int -acl_get_brand_np(acl_t acl, int *brand_p) -{ - - if (acl == NULL || brand_p == NULL) { - errno = EINVAL; - return (-1); - } - *brand_p = _acl_brand(acl); - - return (0); -} -/*- - * Copyright (c) 2008, 2009 Edward Tomasz Napierała - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include - -#include "acl_support.h" - -/* - * An ugly detail of the implementation - fortunately not visible - * to the API users - is the "branding": libc needs to keep track - * of what "brand" ACL is: NFSv4, POSIX.1e or unknown. It happens - * automatically - for example, during acl_get_file(3) ACL gets - * branded according to the "type" argument; during acl_set_permset - * ACL, if its brand is unknown it gets branded as NFSv4 if any of the - * NFSv4 permissions that are not valid for POSIX.1e ACL are set etc. - * Branding information is used for printing out the ACL (acl_to_text(3)), - * veryfying acl_set_whatever arguments (checking against setting - * bits that are valid only for NFSv4 in ACL branded as POSIX.1e) etc. - */ - -static acl_t -entry2acl(acl_entry_t entry) -{ - acl_t aclp; - - aclp = (acl_t)(((long)entry >> _ACL_T_ALIGNMENT_BITS) << _ACL_T_ALIGNMENT_BITS); - - return (aclp); -} - -/* - * Return brand of an ACL. - */ -int -_acl_brand(const acl_t acl) -{ - - return (acl->ats_brand); -} - -int -_entry_brand(const acl_entry_t entry) -{ - - return (_acl_brand(entry2acl(entry))); -} - -/* - * Return 1, iff branding ACL as "brand" is ok. - */ -int -_acl_brand_may_be(const acl_t acl, int brand) -{ - - if (_acl_brand(acl) == ACL_BRAND_UNKNOWN) - return (1); - - if (_acl_brand(acl) == brand) - return (1); - - return (0); -} - -int -_entry_brand_may_be(const acl_entry_t entry, int brand) -{ - - return (_acl_brand_may_be(entry2acl(entry), brand)); -} - -/* - * Brand ACL as "brand". - */ -void -_acl_brand_as(acl_t acl, int brand) -{ - - assert(_acl_brand_may_be(acl, brand)); - - acl->ats_brand = brand; -} - -void -_entry_brand_as(const acl_entry_t entry, int brand) -{ - - _acl_brand_as(entry2acl(entry), brand); -} - -int -_acl_type_not_valid_for_acl(const acl_t acl, acl_type_t type) -{ - - switch (_acl_brand(acl)) { - case ACL_BRAND_NFS4: - if (type == ACL_TYPE_NFS4) - return (0); - break; - - case ACL_BRAND_POSIX: - if (type == ACL_TYPE_ACCESS || type == ACL_TYPE_DEFAULT) - return (0); - break; - } - - return (-1); -} - -void -_acl_brand_from_type(acl_t acl, acl_type_t type) -{ - - switch (type) { - case ACL_TYPE_NFS4: - _acl_brand_as(acl, ACL_BRAND_NFS4); - break; - case ACL_TYPE_ACCESS: - case ACL_TYPE_DEFAULT: - _acl_brand_as(acl, ACL_BRAND_POSIX); - break; - default: - /* XXX: What to do here? */ - break; - } -} - -int -acl_get_brand_np(acl_t acl, int *brand_p) -{ - - if (acl == NULL || brand_p == NULL) { - errno = EINVAL; - return (-1); - } - *brand_p = _acl_brand(acl); - - return (0); -} diff --git a/lib/libc/posix1e/acl_clear_flags_np.3 b/lib/libc/posix1e/acl_clear_flags_np.3 index ec91b3f..b2586e1 100644 --- a/lib/libc/posix1e/acl_clear_flags_np.3 +++ b/lib/libc/posix1e/acl_clear_flags_np.3 @@ -77,161 +77,3 @@ The .Fn acl_clear_flags_np function was written by .An Edward Tomasz Napierala Aq trasz@FreeBSD.org . -.\"- -.\" Copyright (c) 2008, 2009 Edward Tomasz Napierala -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR THE VOICES IN HIS HEAD BE -.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.\" -.Dd March 10, 2001 -.Dt ACL_CLEAR_FLAGS_NP 3 -.Os -.Sh NAME -.Nm acl_clear_flags_np -.Nd clear flags from a flagset -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/types.h -.In sys/acl.h -.Ft int -.Fn acl_clear_flags_np "acl_flagset_t flagset_d" -.Sh DESCRIPTION -The -.Fn acl_clear_flags_np -function -is a non-portable call that clears all flags from flagset -.Fa flagset_d . -.Sh RETURN VALUES -.Rv -std acl_clear_flags_np -.Sh ERRORS -The -.Fn acl_clear_flags_np -function fails if: -.Bl -tag -width Er -.It Bq Er EINVAL -Argument -.Fa flagset_d -is not a valid descriptor for a flagset. -.El -.Sh SEE ALSO -.Xr acl 3 , -.Xr acl_add_flag_np 3 , -.Xr acl_delete_flag_np 3 , -.Xr acl_get_flagset_np 3 , -.Xr acl_set_flagset_np 3 , -.Xr posix1e 3 -.Sh STANDARDS -POSIX.1e is described in IEEE POSIX.1e draft 17. -.Sh HISTORY -POSIX.1e support was introduced in -.Fx 4.0 . -The -.Fn acl_clear_flags_np -function was added in -.Fx 5.0 . -.Sh AUTHORS -The -.Fn acl_clear_flags_np -function was written by -.An Edward Tomasz Napierala Aq trasz@FreeBSD.org . -.\"- -.\" Copyright (c) 2008, 2009 Edward Tomasz Napierala -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR THE VOICES IN HIS HEAD BE -.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.\" -.Dd March 10, 2001 -.Dt ACL_CLEAR_FLAGS_NP 3 -.Os -.Sh NAME -.Nm acl_clear_flags_np -.Nd clear flags from a flagset -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/types.h -.In sys/acl.h -.Ft int -.Fn acl_clear_flags_np "acl_flagset_t flagset_d" -.Sh DESCRIPTION -The -.Fn acl_clear_flags_np -function -is a non-portable call that clears all flags from flagset -.Fa flagset_d . -.Sh RETURN VALUES -.Rv -std acl_clear_flags_np -.Sh ERRORS -The -.Fn acl_clear_flags_np -function fails if: -.Bl -tag -width Er -.It Bq Er EINVAL -Argument -.Fa flagset_d -is not a valid descriptor for a flagset. -.El -.Sh SEE ALSO -.Xr acl 3 , -.Xr acl_add_flag_np 3 , -.Xr acl_delete_flag_np 3 , -.Xr acl_get_flagset_np 3 , -.Xr acl_set_flagset_np 3 , -.Xr posix1e 3 -.Sh STANDARDS -POSIX.1e is described in IEEE POSIX.1e draft 17. -.Sh HISTORY -POSIX.1e support was introduced in -.Fx 4.0 . -The -.Fn acl_clear_flags_np -function was added in -.Fx 5.0 . -.Sh AUTHORS -The -.Fn acl_clear_flags_np -function was written by -.An Edward Tomasz Napierala Aq trasz@FreeBSD.org . diff --git a/lib/libc/posix1e/acl_delete_flag_np.3 b/lib/libc/posix1e/acl_delete_flag_np.3 index 2e947e9..211a97a 100644 --- a/lib/libc/posix1e/acl_delete_flag_np.3 +++ b/lib/libc/posix1e/acl_delete_flag_np.3 @@ -82,171 +82,3 @@ The .Fn acl_delete_flag_np function was written by .An Edward Tomasz Napierala Aq trasz@FreeBSD.org . -.\"- -.\" Copyright (c) 2008, 2009 Edward Tomasz Napierala -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR THE VOICES IN HIS HEAD BE -.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.\" -.Dd March 10, 2001 -.Dt ACL_DELETE_FLAG_NP 3 -.Os -.Sh NAME -.Nm acl_delete_flag_np -.Nd delete flags from a flagset -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/types.h -.In sys/acl.h -.Ft int -.Fn acl_delete_flag_np "acl_flagset_t flagset_d" "acl_flag_t flag" -.Sh DESCRIPTION -The -.Fn acl_delete_flag_np -function -is a non-portable call that removes specific flags from flagset -.Fa flags . -.Sh RETURN VALUES -.Rv -std acl_delete_flag_np -.Sh ERRORS -The -.Fn acl_delete_flag_np -function fails if: -.Bl -tag -width Er -.It Bq Er EINVAL -Argument -.Fa flagset_d -is not a valid descriptor for a flagset. -Argument -.Fa flag -does not contain a valid -.Vt acl_flag_t -value. -.El -.Sh SEE ALSO -.Xr acl 3 , -.Xr acl_add_flag_np 3 , -.Xr acl_clear_flag_nps 3 , -.Xr acl_get_flagset_np 3 , -.Xr acl_set_flagset_np 3 , -.Xr posix1e 3 -.Sh STANDARDS -POSIX.1e is described in IEEE POSIX.1e draft 17. -.Sh HISTORY -POSIX.1e support was introduced in -.Fx 4.0 . -The -.Fn acl_delete_flag_np -function was added in -.Fx 8.0 . -.Sh AUTHORS -The -.Fn acl_delete_flag_np -function was written by -.An Edward Tomasz Napierala Aq trasz@FreeBSD.org . -.\"- -.\" Copyright (c) 2008, 2009 Edward Tomasz Napierala -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR THE VOICES IN HIS HEAD BE -.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.\" -.Dd March 10, 2001 -.Dt ACL_DELETE_FLAG_NP 3 -.Os -.Sh NAME -.Nm acl_delete_flag_np -.Nd delete flags from a flagset -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/types.h -.In sys/acl.h -.Ft int -.Fn acl_delete_flag_np "acl_flagset_t flagset_d" "acl_flag_t flag" -.Sh DESCRIPTION -The -.Fn acl_delete_flag_np -function -is a non-portable call that removes specific flags from flagset -.Fa flags . -.Sh RETURN VALUES -.Rv -std acl_delete_flag_np -.Sh ERRORS -The -.Fn acl_delete_flag_np -function fails if: -.Bl -tag -width Er -.It Bq Er EINVAL -Argument -.Fa flagset_d -is not a valid descriptor for a flagset. -Argument -.Fa flag -does not contain a valid -.Vt acl_flag_t -value. -.El -.Sh SEE ALSO -.Xr acl 3 , -.Xr acl_add_flag_np 3 , -.Xr acl_clear_flag_nps 3 , -.Xr acl_get_flagset_np 3 , -.Xr acl_set_flagset_np 3 , -.Xr posix1e 3 -.Sh STANDARDS -POSIX.1e is described in IEEE POSIX.1e draft 17. -.Sh HISTORY -POSIX.1e support was introduced in -.Fx 4.0 . -The -.Fn acl_delete_flag_np -function was added in -.Fx 8.0 . -.Sh AUTHORS -The -.Fn acl_delete_flag_np -function was written by -.An Edward Tomasz Napierala Aq trasz@FreeBSD.org . diff --git a/lib/libc/posix1e/acl_flag.c b/lib/libc/posix1e/acl_flag.c index c4c52b3..39e258d 100644 --- a/lib/libc/posix1e/acl_flag.c +++ b/lib/libc/posix1e/acl_flag.c @@ -153,313 +153,3 @@ acl_set_flagset_np(acl_entry_t entry_d, acl_flagset_t flagset_d) return (0); } -/*- - * Copyright (c) 2008, 2009 Edward Tomasz Napierała - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include - -#include "acl_support.h" - -static int -_flag_is_invalid(acl_flag_t flag) -{ - - if ((flag & ACL_FLAGS_BITS) == flag) - return (0); - - errno = EINVAL; - - return (1); -} - -int -acl_add_flag_np(acl_flagset_t flagset_d, acl_flag_t flag) -{ - - if (flagset_d == NULL) { - errno = EINVAL; - return (-1); - } - - if (_flag_is_invalid(flag)) - return (-1); - - *flagset_d |= flag; - - return (0); -} - -int -acl_clear_flags_np(acl_flagset_t flagset_d) -{ - - if (flagset_d == NULL) { - errno = EINVAL; - return (-1); - } - - *flagset_d |= 0; - - return (0); -} - -int -acl_delete_flag_np(acl_flagset_t flagset_d, acl_flag_t flag) -{ - - if (flagset_d == NULL) { - errno = EINVAL; - return (-1); - } - - if (_flag_is_invalid(flag)) - return (-1); - - *flagset_d &= ~flag; - - return (0); -} - -int -acl_get_flag_np(acl_flagset_t flagset_d, acl_flag_t flag) -{ - - if (flagset_d == NULL) { - errno = EINVAL; - return (-1); - } - - if (_flag_is_invalid(flag)) - return (-1); - - if (*flagset_d & flag) - return (1); - - return (0); -} - -int -acl_get_flagset_np(acl_entry_t entry_d, acl_flagset_t *flagset_p) -{ - - if (entry_d == NULL || flagset_p == NULL) { - errno = EINVAL; - return (-1); - } - - if (!_entry_brand_may_be(entry_d, ACL_BRAND_NFS4)) { - errno = EINVAL; - return (-1); - } - - *flagset_p = &entry_d->ae_flags; - - return (0); -} - -int -acl_set_flagset_np(acl_entry_t entry_d, acl_flagset_t flagset_d) -{ - - if (entry_d == NULL) { - errno = EINVAL; - return (-1); - } - - if (!_entry_brand_may_be(entry_d, ACL_BRAND_NFS4)) { - errno = EINVAL; - return (-1); - } - - _entry_brand_as(entry_d, ACL_BRAND_NFS4); - - if (_flag_is_invalid(*flagset_d)) - return (-1); - - entry_d->ae_flags = *flagset_d; - - return (0); -} -/*- - * Copyright (c) 2008, 2009 Edward Tomasz Napierała - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include - -#include "acl_support.h" - -static int -_flag_is_invalid(acl_flag_t flag) -{ - - if ((flag & ACL_FLAGS_BITS) == flag) - return (0); - - errno = EINVAL; - - return (1); -} - -int -acl_add_flag_np(acl_flagset_t flagset_d, acl_flag_t flag) -{ - - if (flagset_d == NULL) { - errno = EINVAL; - return (-1); - } - - if (_flag_is_invalid(flag)) - return (-1); - - *flagset_d |= flag; - - return (0); -} - -int -acl_clear_flags_np(acl_flagset_t flagset_d) -{ - - if (flagset_d == NULL) { - errno = EINVAL; - return (-1); - } - - *flagset_d |= 0; - - return (0); -} - -int -acl_delete_flag_np(acl_flagset_t flagset_d, acl_flag_t flag) -{ - - if (flagset_d == NULL) { - errno = EINVAL; - return (-1); - } - - if (_flag_is_invalid(flag)) - return (-1); - - *flagset_d &= ~flag; - - return (0); -} - -int -acl_get_flag_np(acl_flagset_t flagset_d, acl_flag_t flag) -{ - - if (flagset_d == NULL) { - errno = EINVAL; - return (-1); - } - - if (_flag_is_invalid(flag)) - return (-1); - - if (*flagset_d & flag) - return (1); - - return (0); -} - -int -acl_get_flagset_np(acl_entry_t entry_d, acl_flagset_t *flagset_p) -{ - - if (entry_d == NULL || flagset_p == NULL) { - errno = EINVAL; - return (-1); - } - - if (!_entry_brand_may_be(entry_d, ACL_BRAND_NFS4)) { - errno = EINVAL; - return (-1); - } - - *flagset_p = &entry_d->ae_flags; - - return (0); -} - -int -acl_set_flagset_np(acl_entry_t entry_d, acl_flagset_t flagset_d) -{ - - if (entry_d == NULL) { - errno = EINVAL; - return (-1); - } - - if (!_entry_brand_may_be(entry_d, ACL_BRAND_NFS4)) { - errno = EINVAL; - return (-1); - } - - _entry_brand_as(entry_d, ACL_BRAND_NFS4); - - if (_flag_is_invalid(*flagset_d)) - return (-1); - - entry_d->ae_flags = *flagset_d; - - return (0); -} diff --git a/lib/libc/posix1e/acl_from_text_nfs4.c b/lib/libc/posix1e/acl_from_text_nfs4.c index d9a3184..12bfb4e 100644 --- a/lib/libc/posix1e/acl_from_text_nfs4.c +++ b/lib/libc/posix1e/acl_from_text_nfs4.c @@ -310,627 +310,3 @@ malformed_field: errno = EINVAL; return (-1); } -/*- - * Copyright (c) 2008, 2009 Edward Tomasz Napierała - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "acl_support.h" - -#define MAX_ENTRY_LENGTH 512 - -/* - * Parse the tag field of ACL entry passed as "str". If qualifier - * needs to follow, then the variable referenced by "need_qualifier" - * is set to 1, otherwise it's set to 0. - */ -static int -parse_tag(const char *str, acl_entry_t entry, int *need_qualifier) -{ - - assert(need_qualifier != NULL); - *need_qualifier = 0; - - if (strcmp(str, "owner@") == 0) - return (acl_set_tag_type(entry, ACL_USER_OBJ)); - if (strcmp(str, "group@") == 0) - return (acl_set_tag_type(entry, ACL_GROUP_OBJ)); - if (strcmp(str, "everyone@") == 0) - return (acl_set_tag_type(entry, ACL_EVERYONE)); - - *need_qualifier = 1; - - if (strcmp(str, "user") == 0 || strcmp(str, "u") == 0) - return (acl_set_tag_type(entry, ACL_USER)); - if (strcmp(str, "group") == 0 || strcmp(str, "g") == 0) - return (acl_set_tag_type(entry, ACL_GROUP)); - - warnx("malformed ACL: invalid \"tag\" field"); - - return (-1); -} - -/* - * Parse the qualifier field of ACL entry passed as "str". - * If user or group name cannot be resolved, then the variable - * referenced by "need_qualifier" is set to 1. - */ -static int -parse_qualifier(char *str, acl_entry_t entry, int *need_qualifier) -{ - int qualifier_length, error; - id_t id; - char *end; - struct passwd *pwd; - struct group *grp; - acl_tag_t tag; - - assert(need_qualifier != NULL); - *need_qualifier = 0; - - qualifier_length = strlen(str); - - if (qualifier_length == 0) { - warnx("malformed ACL: empty \"qualifier\" field"); - return (-1); - } - - /* XXX: Can we assume that valid username never begins with a digit? */ - if (isdigit(str[0])) { - id = strtod(str, &end); - - if (end - str != qualifier_length) { - warnx("malformed ACL: trailing characters " - "after numerical id"); - return (-1); - } - - return (acl_set_qualifier(entry, &id)); - } - - error = acl_get_tag_type(entry, &tag); - if (error) - return (error); - - assert(tag == ACL_USER || tag == ACL_GROUP); - - if (tag == ACL_USER) { - /* XXX: Thread-unsafe. */ - pwd = getpwnam(str); - if (pwd == NULL) { - *need_qualifier = 1; - return (0); - } - - return (acl_set_qualifier(entry, &(pwd->pw_uid))); - } - - /* XXX: Thread-unsafe. */ - grp = getgrnam(str); - if (grp == NULL) { - *need_qualifier = 1; - return (0); - } - - return (acl_set_qualifier(entry, &(grp->gr_gid))); -} - -static int -parse_access_mask(char *str, acl_entry_t entry) -{ - int error; - acl_perm_t perm; - - error = _nfs4_parse_access_mask(str, &perm); - if (error) - return (error); - - error = acl_set_permset(entry, &perm); - - return (error); -} - -static int -parse_flags(char *str, acl_entry_t entry) -{ - int error; - acl_flag_t flags; - - error = _nfs4_parse_flags(str, &flags); - if (error) - return (error); - - error = acl_set_flagset_np(entry, &flags); - - return (error); -} - -static int -parse_entry_type(const char *str, acl_entry_t entry) -{ - - if (strcmp(str, "allow") == 0) - return (acl_set_entry_type_np(entry, ACL_ENTRY_TYPE_ALLOW)); - if (strcmp(str, "deny") == 0) - return (acl_set_entry_type_np(entry, ACL_ENTRY_TYPE_DENY)); - if (strcmp(str, "audit") == 0) - return (acl_set_entry_type_np(entry, ACL_ENTRY_TYPE_AUDIT)); - if (strcmp(str, "alarm") == 0) - return (acl_set_entry_type_np(entry, ACL_ENTRY_TYPE_ALARM)); - - warnx("malformed ACL: invalid \"type\" field"); - - return (-1); -} - -static int -parse_appended_id(char *str, acl_entry_t entry) -{ - int qualifier_length; - char *end; - id_t id; - - qualifier_length = strlen(str); - if (qualifier_length == 0) { - warnx("malformed ACL: \"appended id\" field present, " - "but empty"); - return (-1); - } - - id = strtod(str, &end); - if (end - str != qualifier_length) { - warnx("malformed ACL: appended id is not a number"); - return (-1); - } - - return (acl_set_qualifier(entry, &id)); -} - -static int -number_of_colons(const char *str) -{ - int count = 0; - - while (*str != '\0') { - if (*str == ':') - count++; - - str++; - } - - return (count); -} - -int -_nfs4_acl_entry_from_text(acl_t aclp, char *str) -{ - int error, need_qualifier; - acl_entry_t entry; - char *field, *qualifier_field; - - error = acl_create_entry(&aclp, &entry); - if (error) - return (error); - - assert(_entry_brand(entry) == ACL_BRAND_NFS4); - - if (str == NULL) - goto truncated_entry; - field = strsep(&str, ":"); - - field = string_skip_whitespace(field); - if ((*field == '\0') && (!str)) { - /* - * Is an entirely comment line, skip to next - * comma. - */ - return (0); - } - - error = parse_tag(field, entry, &need_qualifier); - if (error) - goto malformed_field; - - if (need_qualifier) { - if (str == NULL) - goto truncated_entry; - qualifier_field = field = strsep(&str, ":"); - error = parse_qualifier(field, entry, &need_qualifier); - if (error) - goto malformed_field; - } - - if (str == NULL) - goto truncated_entry; - field = strsep(&str, ":"); - error = parse_access_mask(field, entry); - if (error) - goto malformed_field; - - if (str == NULL) - goto truncated_entry; - /* Do we have "flags" field? */ - if (number_of_colons(str) > 0) { - field = strsep(&str, ":"); - error = parse_flags(field, entry); - if (error) - goto malformed_field; - } - - if (str == NULL) - goto truncated_entry; - field = strsep(&str, ":"); - error = parse_entry_type(field, entry); - if (error) - goto malformed_field; - - if (need_qualifier) { - if (str == NULL) { - warnx("malformed ACL: unknown user or group name " - "\"%s\"", qualifier_field); - goto truncated_entry; - } - - error = parse_appended_id(str, entry); - if (error) - goto malformed_field; - } - - return (0); - -truncated_entry: -malformed_field: - acl_delete_entry(aclp, entry); - errno = EINVAL; - return (-1); -} -/*- - * Copyright (c) 2008, 2009 Edward Tomasz Napierała - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "acl_support.h" - -#define MAX_ENTRY_LENGTH 512 - -/* - * Parse the tag field of ACL entry passed as "str". If qualifier - * needs to follow, then the variable referenced by "need_qualifier" - * is set to 1, otherwise it's set to 0. - */ -static int -parse_tag(const char *str, acl_entry_t entry, int *need_qualifier) -{ - - assert(need_qualifier != NULL); - *need_qualifier = 0; - - if (strcmp(str, "owner@") == 0) - return (acl_set_tag_type(entry, ACL_USER_OBJ)); - if (strcmp(str, "group@") == 0) - return (acl_set_tag_type(entry, ACL_GROUP_OBJ)); - if (strcmp(str, "everyone@") == 0) - return (acl_set_tag_type(entry, ACL_EVERYONE)); - - *need_qualifier = 1; - - if (strcmp(str, "user") == 0 || strcmp(str, "u") == 0) - return (acl_set_tag_type(entry, ACL_USER)); - if (strcmp(str, "group") == 0 || strcmp(str, "g") == 0) - return (acl_set_tag_type(entry, ACL_GROUP)); - - warnx("malformed ACL: invalid \"tag\" field"); - - return (-1); -} - -/* - * Parse the qualifier field of ACL entry passed as "str". - * If user or group name cannot be resolved, then the variable - * referenced by "need_qualifier" is set to 1. - */ -static int -parse_qualifier(char *str, acl_entry_t entry, int *need_qualifier) -{ - int qualifier_length, error; - id_t id; - char *end; - struct passwd *pwd; - struct group *grp; - acl_tag_t tag; - - assert(need_qualifier != NULL); - *need_qualifier = 0; - - qualifier_length = strlen(str); - - if (qualifier_length == 0) { - warnx("malformed ACL: empty \"qualifier\" field"); - return (-1); - } - - /* XXX: Can we assume that valid username never begins with a digit? */ - if (isdigit(str[0])) { - id = strtod(str, &end); - - if (end - str != qualifier_length) { - warnx("malformed ACL: trailing characters " - "after numerical id"); - return (-1); - } - - return (acl_set_qualifier(entry, &id)); - } - - error = acl_get_tag_type(entry, &tag); - if (error) - return (error); - - assert(tag == ACL_USER || tag == ACL_GROUP); - - if (tag == ACL_USER) { - /* XXX: Thread-unsafe. */ - pwd = getpwnam(str); - if (pwd == NULL) { - *need_qualifier = 1; - return (0); - } - - return (acl_set_qualifier(entry, &(pwd->pw_uid))); - } - - /* XXX: Thread-unsafe. */ - grp = getgrnam(str); - if (grp == NULL) { - *need_qualifier = 1; - return (0); - } - - return (acl_set_qualifier(entry, &(grp->gr_gid))); -} - -static int -parse_access_mask(char *str, acl_entry_t entry) -{ - int error; - acl_perm_t perm; - - error = _nfs4_parse_access_mask(str, &perm); - if (error) - return (error); - - error = acl_set_permset(entry, &perm); - - return (error); -} - -static int -parse_flags(char *str, acl_entry_t entry) -{ - int error; - acl_flag_t flags; - - error = _nfs4_parse_flags(str, &flags); - if (error) - return (error); - - error = acl_set_flagset_np(entry, &flags); - - return (error); -} - -static int -parse_entry_type(const char *str, acl_entry_t entry) -{ - - if (strcmp(str, "allow") == 0) - return (acl_set_entry_type_np(entry, ACL_ENTRY_TYPE_ALLOW)); - if (strcmp(str, "deny") == 0) - return (acl_set_entry_type_np(entry, ACL_ENTRY_TYPE_DENY)); - if (strcmp(str, "audit") == 0) - return (acl_set_entry_type_np(entry, ACL_ENTRY_TYPE_AUDIT)); - if (strcmp(str, "alarm") == 0) - return (acl_set_entry_type_np(entry, ACL_ENTRY_TYPE_ALARM)); - - warnx("malformed ACL: invalid \"type\" field"); - - return (-1); -} - -static int -parse_appended_id(char *str, acl_entry_t entry) -{ - int qualifier_length; - char *end; - id_t id; - - qualifier_length = strlen(str); - if (qualifier_length == 0) { - warnx("malformed ACL: \"appended id\" field present, " - "but empty"); - return (-1); - } - - id = strtod(str, &end); - if (end - str != qualifier_length) { - warnx("malformed ACL: appended id is not a number"); - return (-1); - } - - return (acl_set_qualifier(entry, &id)); -} - -static int -number_of_colons(const char *str) -{ - int count = 0; - - while (*str != '\0') { - if (*str == ':') - count++; - - str++; - } - - return (count); -} - -int -_nfs4_acl_entry_from_text(acl_t aclp, char *str) -{ - int error, need_qualifier; - acl_entry_t entry; - char *field, *qualifier_field; - - error = acl_create_entry(&aclp, &entry); - if (error) - return (error); - - assert(_entry_brand(entry) == ACL_BRAND_NFS4); - - if (str == NULL) - goto truncated_entry; - field = strsep(&str, ":"); - - field = string_skip_whitespace(field); - if ((*field == '\0') && (!str)) { - /* - * Is an entirely comment line, skip to next - * comma. - */ - return (0); - } - - error = parse_tag(field, entry, &need_qualifier); - if (error) - goto malformed_field; - - if (need_qualifier) { - if (str == NULL) - goto truncated_entry; - qualifier_field = field = strsep(&str, ":"); - error = parse_qualifier(field, entry, &need_qualifier); - if (error) - goto malformed_field; - } - - if (str == NULL) - goto truncated_entry; - field = strsep(&str, ":"); - error = parse_access_mask(field, entry); - if (error) - goto malformed_field; - - if (str == NULL) - goto truncated_entry; - /* Do we have "flags" field? */ - if (number_of_colons(str) > 0) { - field = strsep(&str, ":"); - error = parse_flags(field, entry); - if (error) - goto malformed_field; - } - - if (str == NULL) - goto truncated_entry; - field = strsep(&str, ":"); - error = parse_entry_type(field, entry); - if (error) - goto malformed_field; - - if (need_qualifier) { - if (str == NULL) { - warnx("malformed ACL: unknown user or group name " - "\"%s\"", qualifier_field); - goto truncated_entry; - } - - error = parse_appended_id(str, entry); - if (error) - goto malformed_field; - } - - return (0); - -truncated_entry: -malformed_field: - acl_delete_entry(aclp, entry); - errno = EINVAL; - return (-1); -} diff --git a/lib/libc/posix1e/acl_get_brand_np.3 b/lib/libc/posix1e/acl_get_brand_np.3 index 7ddbba3..20f45dd 100644 --- a/lib/libc/posix1e/acl_get_brand_np.3 +++ b/lib/libc/posix1e/acl_get_brand_np.3 @@ -84,175 +84,3 @@ The .Fn acl_get_brand_np function was written by .An Edward Tomasz Napierala Aq trasz@FreeBSD.org . -.\"- -.\" Copyright (c) 2008, 2009 Edward Tomasz Napierala -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR THE VOICES IN HIS HEAD BE -.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.\" -.Dd March 10, 2001 -.Dt ACL_GET_BRAND_NP 3 -.Os -.Sh NAME -.Nm acl_get_brand_np -.Nd retrieve the ACL brand from an ACL entry -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/types.h -.In sys/acl.h -.Ft int -.Fn acl_get_brand_np "acl_t acl" "int *brand_p" -.Sh DESCRIPTION -The -.Fn acl_get_brand_np -function -is a non-portable call that returns the ACL brand for the ACL -.Fa acl . -Upon successful completion, the location referred to by the argument -.Fa brand_p -will be set to the ACL brand of the ACL -.Fa acl . -.Pp -Branding is an internal mechanism intended to prevent mixing POSIX.1e -and NFSv4 entries by mistake. -It's also used by the libc to determine how to print out the ACL. -The first call to function that is specific for one particular brand - POSIX.1e -or NFSv4 - "brands" the ACL. -After that, calling function specific to another brand will result in error. -.Sh RETURN VALUES -.Rv -std acl_get_brand_np -.Sh ERRORS -The -.Fn acl_get_brand_np -function fails if: -.Bl -tag -width Er -.It Bq Er EINVAL -Argument -.Fa acl -does not point to a valid ACL. -.El -.Sh SEE ALSO -.Xr acl 3 , -.Xr posix1e 3 -.Sh STANDARDS -POSIX.1e is described in IEEE POSIX.1e draft 17. -.Sh HISTORY -POSIX.1e support was introduced in -.Fx 4.0 . -The -.Fn acl_get_brand_np -function was added in -.Fx 8.0 . -.Sh AUTHORS -The -.Fn acl_get_brand_np -function was written by -.An Edward Tomasz Napierala Aq trasz@FreeBSD.org . -.\"- -.\" Copyright (c) 2008, 2009 Edward Tomasz Napierala -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR THE VOICES IN HIS HEAD BE -.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.\" -.Dd March 10, 2001 -.Dt ACL_GET_BRAND_NP 3 -.Os -.Sh NAME -.Nm acl_get_brand_np -.Nd retrieve the ACL brand from an ACL entry -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/types.h -.In sys/acl.h -.Ft int -.Fn acl_get_brand_np "acl_t acl" "int *brand_p" -.Sh DESCRIPTION -The -.Fn acl_get_brand_np -function -is a non-portable call that returns the ACL brand for the ACL -.Fa acl . -Upon successful completion, the location referred to by the argument -.Fa brand_p -will be set to the ACL brand of the ACL -.Fa acl . -.Pp -Branding is an internal mechanism intended to prevent mixing POSIX.1e -and NFSv4 entries by mistake. -It's also used by the libc to determine how to print out the ACL. -The first call to function that is specific for one particular brand - POSIX.1e -or NFSv4 - "brands" the ACL. -After that, calling function specific to another brand will result in error. -.Sh RETURN VALUES -.Rv -std acl_get_brand_np -.Sh ERRORS -The -.Fn acl_get_brand_np -function fails if: -.Bl -tag -width Er -.It Bq Er EINVAL -Argument -.Fa acl -does not point to a valid ACL. -.El -.Sh SEE ALSO -.Xr acl 3 , -.Xr posix1e 3 -.Sh STANDARDS -POSIX.1e is described in IEEE POSIX.1e draft 17. -.Sh HISTORY -POSIX.1e support was introduced in -.Fx 4.0 . -The -.Fn acl_get_brand_np -function was added in -.Fx 8.0 . -.Sh AUTHORS -The -.Fn acl_get_brand_np -function was written by -.An Edward Tomasz Napierala Aq trasz@FreeBSD.org . diff --git a/lib/libc/posix1e/acl_get_entry_type_np.3 b/lib/libc/posix1e/acl_get_entry_type_np.3 index b473eb0..34d93be 100644 --- a/lib/libc/posix1e/acl_get_entry_type_np.3 +++ b/lib/libc/posix1e/acl_get_entry_type_np.3 @@ -78,163 +78,3 @@ The .Fn acl_get_entry_type_np function was written by .An Edward Tomasz Napierala Aq trasz@FreeBSD.org . -.\"- -.\" Copyright (c) 2008, 2009 Edward Tomasz Napierala -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR THE VOICES IN HIS HEAD BE -.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.\" -.Dd March 10, 2001 -.Dt ACL_GET_ENTRY_TYPE_NP 3 -.Os -.Sh NAME -.Nm acl_get_entry_type_np -.Nd retrieve the ACL type from an NFSv4 ACL entry -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/types.h -.In sys/acl.h -.Ft int -.Fn acl_get_entry_type_np "acl_entry_t entry_d" "acl_entry_type_t *entry_type_p" -.Sh DESCRIPTION -The -.Fn acl_get_entry_type_np -function -is a non-portable call that returns the ACL type for the NFSv4 ACL entry -.Fa entry_d . -Upon successful completion, the location referred to by the argument -.Fa entry_type_p -will be set to the ACL type of the ACL entry -.Fa entry_d . -.Sh RETURN VALUES -.Rv -std acl_get_entry_type_np -.Sh ERRORS -The -.Fn acl_get_entry_type_np -function fails if: -.Bl -tag -width Er -.It Bq Er EINVAL -Argument -.Fa entry_d -is not a valid descriptor for an NFSv4 ACL entry; -.El -.Sh SEE ALSO -.Xr acl 3 , -.Xr acl_set_entry_type_np 3 , -.Xr posix1e 3 -.Sh STANDARDS -POSIX.1e is described in IEEE POSIX.1e draft 17. -.Sh HISTORY -POSIX.1e support was introduced in -.Fx 4.0 . -The -.Fn acl_get_entry_type_np -function was added in -.Fx 8.0 . -.Sh AUTHORS -The -.Fn acl_get_entry_type_np -function was written by -.An Edward Tomasz Napierala Aq trasz@FreeBSD.org . -.\"- -.\" Copyright (c) 2008, 2009 Edward Tomasz Napierala -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR THE VOICES IN HIS HEAD BE -.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.\" -.Dd March 10, 2001 -.Dt ACL_GET_ENTRY_TYPE_NP 3 -.Os -.Sh NAME -.Nm acl_get_entry_type_np -.Nd retrieve the ACL type from an NFSv4 ACL entry -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/types.h -.In sys/acl.h -.Ft int -.Fn acl_get_entry_type_np "acl_entry_t entry_d" "acl_entry_type_t *entry_type_p" -.Sh DESCRIPTION -The -.Fn acl_get_entry_type_np -function -is a non-portable call that returns the ACL type for the NFSv4 ACL entry -.Fa entry_d . -Upon successful completion, the location referred to by the argument -.Fa entry_type_p -will be set to the ACL type of the ACL entry -.Fa entry_d . -.Sh RETURN VALUES -.Rv -std acl_get_entry_type_np -.Sh ERRORS -The -.Fn acl_get_entry_type_np -function fails if: -.Bl -tag -width Er -.It Bq Er EINVAL -Argument -.Fa entry_d -is not a valid descriptor for an NFSv4 ACL entry; -.El -.Sh SEE ALSO -.Xr acl 3 , -.Xr acl_set_entry_type_np 3 , -.Xr posix1e 3 -.Sh STANDARDS -POSIX.1e is described in IEEE POSIX.1e draft 17. -.Sh HISTORY -POSIX.1e support was introduced in -.Fx 4.0 . -The -.Fn acl_get_entry_type_np -function was added in -.Fx 8.0 . -.Sh AUTHORS -The -.Fn acl_get_entry_type_np -function was written by -.An Edward Tomasz Napierala Aq trasz@FreeBSD.org . diff --git a/lib/libc/posix1e/acl_get_flag_np.3 b/lib/libc/posix1e/acl_get_flag_np.3 index 9101ea8..295ee3e 100644 --- a/lib/libc/posix1e/acl_get_flag_np.3 +++ b/lib/libc/posix1e/acl_get_flag_np.3 @@ -92,191 +92,3 @@ The .Fn acl_get_flag_np function was written by .An Edward Tomasz Napierala Aq trasz@FreeBSD.org . -.\"- -.\" Copyright (c) 2008, 2009 Edward Tomasz Napierala -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR THE VOICES IN HIS HEAD BE -.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.\" -.Dd April 10, 2001 -.Dt ACL_GET_FLAG_NP 3 -.Os -.Sh NAME -.Nm acl_get_flag_np -.Nd check if a flag is set in a flagset -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/types.h -.In sys/acl.h -.Ft int -.Fn acl_get_flag_np "acl_flagset_t flagset_d" "acl_flag_t flag" -.Sh DESCRIPTION -The -.Fn acl_get_flag_np -function -is a non-portable function that checks if a flag is set in -a flagset. -.Sh RETURN VALUES -If the flag in -.Fa flag -is set in the flagset -.Fa flagset_d , -a value of -1 -is returned, otherwise a value of -0 -is returned. -.Sh ERRORS -If any of the following conditions occur, the -.Fn acl_get_flag_np -function will return a value of -\-1 -and set global variable -.Va errno -to the corresponding value: -.Bl -tag -width Er -.It Bq Er EINVAL -Argument -.Fa flag -does not contain a valid ACL flag or argument -.Fa flagset_d -is not a valid ACL flagset. -.El -.Sh SEE ALSO -.Xr acl 3 , -.Xr acl_add_flag_np 3 , -.Xr acl_clear_flags_np 3 , -.Xr acl_delete_flag_np 3 , -.Xr acl_get_flagset_np 3 , -.Xr acl_set_flagset_np 3 , -.Xr posix1e 3 -.Sh STANDARDS -POSIX.1e is described in IEEE POSIX.1e draft 17. -.Sh HISTORY -POSIX.1e support was introduced in -.Fx 4.0 . -The -.Fn acl_get_flag_np -function was added in -.Fx 8.0 . -.Sh AUTHORS -The -.Fn acl_get_flag_np -function was written by -.An Edward Tomasz Napierala Aq trasz@FreeBSD.org . -.\"- -.\" Copyright (c) 2008, 2009 Edward Tomasz Napierala -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR THE VOICES IN HIS HEAD BE -.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.\" -.Dd April 10, 2001 -.Dt ACL_GET_FLAG_NP 3 -.Os -.Sh NAME -.Nm acl_get_flag_np -.Nd check if a flag is set in a flagset -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/types.h -.In sys/acl.h -.Ft int -.Fn acl_get_flag_np "acl_flagset_t flagset_d" "acl_flag_t flag" -.Sh DESCRIPTION -The -.Fn acl_get_flag_np -function -is a non-portable function that checks if a flag is set in -a flagset. -.Sh RETURN VALUES -If the flag in -.Fa flag -is set in the flagset -.Fa flagset_d , -a value of -1 -is returned, otherwise a value of -0 -is returned. -.Sh ERRORS -If any of the following conditions occur, the -.Fn acl_get_flag_np -function will return a value of -\-1 -and set global variable -.Va errno -to the corresponding value: -.Bl -tag -width Er -.It Bq Er EINVAL -Argument -.Fa flag -does not contain a valid ACL flag or argument -.Fa flagset_d -is not a valid ACL flagset. -.El -.Sh SEE ALSO -.Xr acl 3 , -.Xr acl_add_flag_np 3 , -.Xr acl_clear_flags_np 3 , -.Xr acl_delete_flag_np 3 , -.Xr acl_get_flagset_np 3 , -.Xr acl_set_flagset_np 3 , -.Xr posix1e 3 -.Sh STANDARDS -POSIX.1e is described in IEEE POSIX.1e draft 17. -.Sh HISTORY -POSIX.1e support was introduced in -.Fx 4.0 . -The -.Fn acl_get_flag_np -function was added in -.Fx 8.0 . -.Sh AUTHORS -The -.Fn acl_get_flag_np -function was written by -.An Edward Tomasz Napierala Aq trasz@FreeBSD.org . diff --git a/lib/libc/posix1e/acl_get_flagset_np.3 b/lib/libc/posix1e/acl_get_flagset_np.3 index d2e812b..7e72340 100644 --- a/lib/libc/posix1e/acl_get_flagset_np.3 +++ b/lib/libc/posix1e/acl_get_flagset_np.3 @@ -81,169 +81,3 @@ The .Fn acl_get_flagset_np function was written by .An Edward Tomasz Napierala Aq trasz@FreeBSD.org . -.\"- -.\" Copyright (c) 2008, 2009 Edward Tomasz Napierala -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR THE VOICES IN HIS HEAD BE -.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.\" -.Dd March 10, 2001 -.Dt ACL_GET_FLAGSET_NP 3 -.Os -.Sh NAME -.Nm acl_get_flagset_np -.Nd retrieve flagset from an NFSv4 ACL entry -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/types.h -.In sys/acl.h -.Ft int -.Fn acl_get_flagset_np "acl_entry_t entry_d" "acl_flagset_t *flagset_p" -.Sh DESCRIPTION -The -.Fn acl_get_flagset_np -function -is a non-portable call that returns via -.Fa flagset_np_p -a descriptor to the flagset in the ACL entry -.Fa entry_d . -Subsequent operations using the returned flagset operate -on the flagset within the ACL entry. -.Sh RETURN VALUES -.Rv -std acl_get_flagset_np -.Sh ERRORS -The -.Fn acl_get_flagset_np -function fails if: -.Bl -tag -width Er -.It Bq Er EINVAL -Argument -.Fa entry_d -is not a valid descriptor for an ACL entry. -.El -.Sh SEE ALSO -.Xr acl 3 , -.Xr acl_add_flag_np 3 , -.Xr acl_clear_flags_np 3 , -.Xr acl_delete_flag_np 3 , -.Xr acl_set_flagset_np 3 , -.Xr posix1e 3 -.Sh STANDARDS -POSIX.1e is described in IEEE POSIX.1e draft 17. -.Sh HISTORY -POSIX.1e support was introduced in -.Fx 4.0 . -The -.Fn acl_get_flagset_np -function was added in -.Fx 8.0 . -.Sh AUTHORS -The -.Fn acl_get_flagset_np -function was written by -.An Edward Tomasz Napierala Aq trasz@FreeBSD.org . -.\"- -.\" Copyright (c) 2008, 2009 Edward Tomasz Napierala -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR THE VOICES IN HIS HEAD BE -.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.\" -.Dd March 10, 2001 -.Dt ACL_GET_FLAGSET_NP 3 -.Os -.Sh NAME -.Nm acl_get_flagset_np -.Nd retrieve flagset from an NFSv4 ACL entry -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/types.h -.In sys/acl.h -.Ft int -.Fn acl_get_flagset_np "acl_entry_t entry_d" "acl_flagset_t *flagset_p" -.Sh DESCRIPTION -The -.Fn acl_get_flagset_np -function -is a non-portable call that returns via -.Fa flagset_np_p -a descriptor to the flagset in the ACL entry -.Fa entry_d . -Subsequent operations using the returned flagset operate -on the flagset within the ACL entry. -.Sh RETURN VALUES -.Rv -std acl_get_flagset_np -.Sh ERRORS -The -.Fn acl_get_flagset_np -function fails if: -.Bl -tag -width Er -.It Bq Er EINVAL -Argument -.Fa entry_d -is not a valid descriptor for an ACL entry. -.El -.Sh SEE ALSO -.Xr acl 3 , -.Xr acl_add_flag_np 3 , -.Xr acl_clear_flags_np 3 , -.Xr acl_delete_flag_np 3 , -.Xr acl_set_flagset_np 3 , -.Xr posix1e 3 -.Sh STANDARDS -POSIX.1e is described in IEEE POSIX.1e draft 17. -.Sh HISTORY -POSIX.1e support was introduced in -.Fx 4.0 . -The -.Fn acl_get_flagset_np -function was added in -.Fx 8.0 . -.Sh AUTHORS -The -.Fn acl_get_flagset_np -function was written by -.An Edward Tomasz Napierala Aq trasz@FreeBSD.org . diff --git a/lib/libc/posix1e/acl_is_trivial_np.3 b/lib/libc/posix1e/acl_is_trivial_np.3 index 9ea6511..787e3f9 100644 --- a/lib/libc/posix1e/acl_is_trivial_np.3 +++ b/lib/libc/posix1e/acl_is_trivial_np.3 @@ -82,171 +82,3 @@ function was added in .Fx 8.0 . .Sh AUTHORS .An Edward Tomasz Napierala Aq trasz@FreeBSD.org . -.\"- -.\" Copyright (c) 2008, 2009 Edward Tomasz Napierala -.\" All rights reserved. -.\" -.\" This software was developed by Robert Watson for the TrustedBSD Project. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.\" -.Dd January 28, 2000 -.Dt ACL_STRIP_NP 3 -.Os -.Sh NAME -.Nm acl_is_trivial_np -.Nd determine whether ACL is trivial -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/types.h -.In sys/acl.h -.Ft int -.Fn acl_is_trivial_np "const acl_t aclp" "int *trivialp" -.Sh DESCRIPTION -The -.Fn acl_is_trivial -function determines whether the ACL pointed to by the argument -.Va acl -is trivial. -Upon successful completion, the location referred to by the argument -.Fa trivialp -will be set to 1, if the ACL -.Fa aclp -points to is trivial, or 0 if it's not. -.Pp -ACL is trivial if it can be fully expressed as a file mode without loosing -any access rules. -For POSIX.1e ACLs, ACL is trivial if it has the three required entries, -one for owner, one for owning group, and one for other. -For NFSv4 ACLs, ACL is trivial if it has the "canonical six" entries. -Files that have non-trivial ACL have a plus sign appended after mode bits -in "ls -l" output. -.Sh RETURN VALUES -.Rv -std acl_get_tag_type -.Sh SEE ALSO -.Xr acl 3 , -.Xr posix1e 3 -.Sh STANDARDS -POSIX.1e is described in IEEE POSIX.1e draft 17. -Discussion -of the draft continues on the cross-platform POSIX.1e implementation -mailing list. -To join this list, see the -.Fx -POSIX.1e implementation -page for more information. -.Sh HISTORY -POSIX.1e support was introduced in -.Fx 4.0 . -The -.Fn acl_is_trivial_np -function was added in -.Fx 8.0 . -.Sh AUTHORS -.An Edward Tomasz Napierala Aq trasz@FreeBSD.org . -.\"- -.\" Copyright (c) 2008, 2009 Edward Tomasz Napierala -.\" All rights reserved. -.\" -.\" This software was developed by Robert Watson for the TrustedBSD Project. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.\" -.Dd January 28, 2000 -.Dt ACL_STRIP_NP 3 -.Os -.Sh NAME -.Nm acl_is_trivial_np -.Nd determine whether ACL is trivial -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/types.h -.In sys/acl.h -.Ft int -.Fn acl_is_trivial_np "const acl_t aclp" "int *trivialp" -.Sh DESCRIPTION -The -.Fn acl_is_trivial -function determines whether the ACL pointed to by the argument -.Va acl -is trivial. -Upon successful completion, the location referred to by the argument -.Fa trivialp -will be set to 1, if the ACL -.Fa aclp -points to is trivial, or 0 if it's not. -.Pp -ACL is trivial if it can be fully expressed as a file mode without loosing -any access rules. -For POSIX.1e ACLs, ACL is trivial if it has the three required entries, -one for owner, one for owning group, and one for other. -For NFSv4 ACLs, ACL is trivial if it has the "canonical six" entries. -Files that have non-trivial ACL have a plus sign appended after mode bits -in "ls -l" output. -.Sh RETURN VALUES -.Rv -std acl_get_tag_type -.Sh SEE ALSO -.Xr acl 3 , -.Xr posix1e 3 -.Sh STANDARDS -POSIX.1e is described in IEEE POSIX.1e draft 17. -Discussion -of the draft continues on the cross-platform POSIX.1e implementation -mailing list. -To join this list, see the -.Fx -POSIX.1e implementation -page for more information. -.Sh HISTORY -POSIX.1e support was introduced in -.Fx 4.0 . -The -.Fn acl_is_trivial_np -function was added in -.Fx 8.0 . -.Sh AUTHORS -.An Edward Tomasz Napierala Aq trasz@FreeBSD.org . diff --git a/lib/libc/posix1e/acl_set_entry_type_np.3 b/lib/libc/posix1e/acl_set_entry_type_np.3 index 922123a..acfa2f5 100644 --- a/lib/libc/posix1e/acl_set_entry_type_np.3 +++ b/lib/libc/posix1e/acl_set_entry_type_np.3 @@ -93,193 +93,3 @@ The .Fn acl_get_entry_type_np function was written by .An Edward Tomasz Napierala Aq trasz@FreeBSD.org . -.\"- -.\" Copyright (c) 2008, 2009 Edward Tomasz Napierala -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR THE VOICES IN HIS HEAD BE -.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.\" -.Dd March 10, 2001 -.Dt ACL_SET_ENTRY_TYPE_NP 3 -.Os -.Sh NAME -.Nm acl_set_entry_type_np -.Nd set NFSv4 ACL entry type -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/types.h -.In sys/acl.h -.Ft int -.Fn acl_set_entry_type_np "acl_entry_t entry_d" "acl_entry_type_t entry_type" -.Sh DESCRIPTION -The -.Fn acl_set_entry_type_np -function -is a non-portable call that sets the type of the ACL entry -.Fa entry_d -to the value referred to by -.Fa entry_type . -.Pp -Valid values are: -.Pp -.Bl -column -offset 3n "ACL_ENTRY_TYPE_ALLOW" -.It ACL_ENTRY_TYPE_ALLOW "allow" type entry -.It ACL_ENTRY_TYPE_DENY "deny" type entry -.El -.Pp -This call brands the ACL as NFSv4. -.Sh RETURN VALUES -.Rv -std acl_set_entry_type_np -.Sh ERRORS -The -.Fn acl_set_entry_type_np -function fails if: -.Bl -tag -width Er -.It Bq Er EINVAL -Argument -.Fa entry_d -is not a valid descriptor for an ACL entry. -The value pointed to by -.Fa entry_type -is not valid. -ACL is already branded as POSIX.1e. -.It Bq Er ENOMEM -The value to be returned requires more memory than is allowed -by the hardware or system-imposed memory management constraints. -.El -.Sh SEE ALSO -.Xr acl 3 , -.Xr acl_get_brand_np 3 , -.Xr acl_get_entry_type_np 3 , -.Xr posix1e 3 -.Sh STANDARDS -POSIX.1e is described in IEEE POSIX.1e draft 17. -.Sh HISTORY -POSIX.1e support was introduced in -.Fx 4.0 . -The -.Fn acl_get_entry_type_np -function was added in -.Fx 8.0 . -.Sh AUTHORS -The -.Fn acl_get_entry_type_np -function was written by -.An Edward Tomasz Napierala Aq trasz@FreeBSD.org . -.\"- -.\" Copyright (c) 2008, 2009 Edward Tomasz Napierala -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR THE VOICES IN HIS HEAD BE -.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.\" -.Dd March 10, 2001 -.Dt ACL_SET_ENTRY_TYPE_NP 3 -.Os -.Sh NAME -.Nm acl_set_entry_type_np -.Nd set NFSv4 ACL entry type -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/types.h -.In sys/acl.h -.Ft int -.Fn acl_set_entry_type_np "acl_entry_t entry_d" "acl_entry_type_t entry_type" -.Sh DESCRIPTION -The -.Fn acl_set_entry_type_np -function -is a non-portable call that sets the type of the ACL entry -.Fa entry_d -to the value referred to by -.Fa entry_type . -.Pp -Valid values are: -.Pp -.Bl -column -offset 3n "ACL_ENTRY_TYPE_ALLOW" -.It ACL_ENTRY_TYPE_ALLOW "allow" type entry -.It ACL_ENTRY_TYPE_DENY "deny" type entry -.El -.Pp -This call brands the ACL as NFSv4. -.Sh RETURN VALUES -.Rv -std acl_set_entry_type_np -.Sh ERRORS -The -.Fn acl_set_entry_type_np -function fails if: -.Bl -tag -width Er -.It Bq Er EINVAL -Argument -.Fa entry_d -is not a valid descriptor for an ACL entry. -The value pointed to by -.Fa entry_type -is not valid. -ACL is already branded as POSIX.1e. -.It Bq Er ENOMEM -The value to be returned requires more memory than is allowed -by the hardware or system-imposed memory management constraints. -.El -.Sh SEE ALSO -.Xr acl 3 , -.Xr acl_get_brand_np 3 , -.Xr acl_get_entry_type_np 3 , -.Xr posix1e 3 -.Sh STANDARDS -POSIX.1e is described in IEEE POSIX.1e draft 17. -.Sh HISTORY -POSIX.1e support was introduced in -.Fx 4.0 . -The -.Fn acl_get_entry_type_np -function was added in -.Fx 8.0 . -.Sh AUTHORS -The -.Fn acl_get_entry_type_np -function was written by -.An Edward Tomasz Napierala Aq trasz@FreeBSD.org . diff --git a/lib/libc/posix1e/acl_set_flagset_np.3 b/lib/libc/posix1e/acl_set_flagset_np.3 index dabf389..d8dd622 100644 --- a/lib/libc/posix1e/acl_set_flagset_np.3 +++ b/lib/libc/posix1e/acl_set_flagset_np.3 @@ -83,173 +83,3 @@ The .Fn acl_set_flagset_np function was written by .An Edward Tomasz Napierala Aq trasz@FreeBSD.org . -.\"- -.\" Copyright (c) 2008, 2009 Edward Tomasz Napierala -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR THE VOICES IN HIS HEAD BE -.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.\" -.Dd March 10, 2001 -.Dt ACL_SET_FLAGSET_NP 3 -.Os -.Sh NAME -.Nm acl_set_flagset_np -.Nd set the flags of an NFSv4 ACL entry -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/types.h -.In sys/acl.h -.Ft int -.Fn acl_set_flagset_np "acl_entry_t entry_d" "acl_flagset_t flagset_d" -.Sh DESCRIPTION -The -.Fn acl_set_flagset_np -function -is a non-portable call that sets the flags of ACL entry -.Fa entry_d -with the flags contained in -.Fa flagset_d . -.Pp -This call brands the ACL as NFSv4. -.Sh RETURN VALUES -.Rv -std acl_set_flagset_np -.Sh ERRORS -The -.Fn acl_set_flagset_np -function fails if: -.Bl -tag -width Er -.It Bq Er EINVAL -Argument -.Fa entry_d -is not a valid descriptor for an ACL entry. -ACL is already branded as POSIX.1e. -.El -.Sh SEE ALSO -.Xr acl 3 , -.Xr acl_add_flag_np 3 , -.Xr acl_get_brand_np 3 , -.Xr acl_clear_flags_np 3 , -.Xr acl_delete_flag_np 3 , -.Xr acl_get_flagset_np 3 , -.Xr posix1e 3 -.Sh STANDARDS -POSIX.1e is described in IEEE POSIX.1e draft 17. -.Sh HISTORY -POSIX.1e support was introduced in -.Fx 4.0 . -The -.Fn acl_set_flagset_np -function was added in -.Fx 8.0 . -.Sh AUTHORS -The -.Fn acl_set_flagset_np -function was written by -.An Edward Tomasz Napierala Aq trasz@FreeBSD.org . -.\"- -.\" Copyright (c) 2008, 2009 Edward Tomasz Napierala -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR THE VOICES IN HIS HEAD BE -.\" LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.\" -.Dd March 10, 2001 -.Dt ACL_SET_FLAGSET_NP 3 -.Os -.Sh NAME -.Nm acl_set_flagset_np -.Nd set the flags of an NFSv4 ACL entry -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/types.h -.In sys/acl.h -.Ft int -.Fn acl_set_flagset_np "acl_entry_t entry_d" "acl_flagset_t flagset_d" -.Sh DESCRIPTION -The -.Fn acl_set_flagset_np -function -is a non-portable call that sets the flags of ACL entry -.Fa entry_d -with the flags contained in -.Fa flagset_d . -.Pp -This call brands the ACL as NFSv4. -.Sh RETURN VALUES -.Rv -std acl_set_flagset_np -.Sh ERRORS -The -.Fn acl_set_flagset_np -function fails if: -.Bl -tag -width Er -.It Bq Er EINVAL -Argument -.Fa entry_d -is not a valid descriptor for an ACL entry. -ACL is already branded as POSIX.1e. -.El -.Sh SEE ALSO -.Xr acl 3 , -.Xr acl_add_flag_np 3 , -.Xr acl_get_brand_np 3 , -.Xr acl_clear_flags_np 3 , -.Xr acl_delete_flag_np 3 , -.Xr acl_get_flagset_np 3 , -.Xr posix1e 3 -.Sh STANDARDS -POSIX.1e is described in IEEE POSIX.1e draft 17. -.Sh HISTORY -POSIX.1e support was introduced in -.Fx 4.0 . -The -.Fn acl_set_flagset_np -function was added in -.Fx 8.0 . -.Sh AUTHORS -The -.Fn acl_set_flagset_np -function was written by -.An Edward Tomasz Napierala Aq trasz@FreeBSD.org . diff --git a/lib/libc/posix1e/acl_strip.c b/lib/libc/posix1e/acl_strip.c index 0cb68e2..1dcdfcd 100644 --- a/lib/libc/posix1e/acl_strip.c +++ b/lib/libc/posix1e/acl_strip.c @@ -198,403 +198,3 @@ acl_is_trivial_np(const acl_t aclp, int *trivialp) return (-1); } } -/*- - * Copyright (c) 2001 Chris D. Faulhaber - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR THE VOICES IN HIS HEAD BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include - -#include "acl_support.h" - -/* - * These two routines from sys/kern/subr_acl_nfs4.c are used by both kernel - * and libc. - */ -void acl_nfs4_sync_acl_from_mode(struct acl *aclp, mode_t mode, - int file_owner_id); -void acl_nfs4_sync_mode_from_acl(mode_t *_mode, const struct acl *aclp); - -static acl_t -_nfs4_acl_strip_np(const acl_t aclp, int recalculate_mask) -{ - acl_t newacl; - mode_t mode; - - newacl = acl_init(ACL_MAX_ENTRIES); - if (newacl == NULL) { - errno = ENOMEM; - return (NULL); - } - - _acl_brand_as(newacl, ACL_BRAND_NFS4); - - acl_nfs4_sync_mode_from_acl(&mode, &(aclp->ats_acl)); - acl_nfs4_sync_acl_from_mode(&(newacl->ats_acl), mode, -1); - - return (newacl); -} - -static acl_t -_posix1e_acl_strip_np(const acl_t aclp, int recalculate_mask) -{ - acl_t acl_new, acl_old; - acl_entry_t entry, entry_new; - acl_permset_t perm; - acl_tag_t tag; - int entry_id, have_mask_entry; - - assert(_acl_brand(aclp) == ACL_BRAND_POSIX); - - acl_old = acl_dup(aclp); - if (acl_old == NULL) - return (NULL); - - assert(_acl_brand(acl_old) == ACL_BRAND_POSIX); - - have_mask_entry = 0; - acl_new = acl_init(ACL_MAX_ENTRIES); - if (acl_new == NULL) - return (NULL); - tag = ACL_UNDEFINED_TAG; - - /* only save the default user/group/other entries */ - entry_id = ACL_FIRST_ENTRY; - while (acl_get_entry(acl_old, entry_id, &entry) == 1) { - entry_id = ACL_NEXT_ENTRY; - - assert(_entry_brand(entry) == ACL_BRAND_POSIX); - - if (acl_get_tag_type(entry, &tag) == -1) - return (NULL); - - switch(tag) { - case ACL_USER_OBJ: - case ACL_GROUP_OBJ: - case ACL_OTHER: - if (acl_get_tag_type(entry, &tag) == -1) - return (NULL); - if (acl_get_permset(entry, &perm) == -1) - return (NULL); - if (acl_create_entry(&acl_new, &entry_new) == -1) - return (NULL); - if (acl_set_tag_type(entry_new, tag) == -1) - return (NULL); - if (acl_set_permset(entry_new, perm) == -1) - return (NULL); - if (acl_copy_entry(entry_new, entry) == -1) - return (NULL); - assert(_entry_brand(entry_new) == ACL_BRAND_POSIX); - break; - case ACL_MASK: - have_mask_entry = 1; - break; - default: - break; - } - } - - assert(_acl_brand(acl_new) == ACL_BRAND_POSIX); - - if (have_mask_entry && recalculate_mask) { - if (acl_calc_mask(&acl_new) == -1) - return (NULL); - } - - return (acl_new); -} - -acl_t -acl_strip_np(const acl_t aclp, int recalculate_mask) -{ - switch (_acl_brand(aclp)) { - case ACL_BRAND_NFS4: - return (_nfs4_acl_strip_np(aclp, recalculate_mask)); - - case ACL_BRAND_POSIX: - return (_posix1e_acl_strip_np(aclp, recalculate_mask)); - - default: - errno = EINVAL; - return (NULL); - } -} - -/* - * Return 1, if ACL is trivial, 0 otherwise. - * - * ACL is trivial, iff its meaning could be fully expressed using just file - * mode. In other words, ACL is trivial iff it doesn't have "+" to the right - * of the mode bits in "ls -l" output ;-) - */ -int -acl_is_trivial_np(const acl_t aclp, int *trivialp) -{ - acl_t tmpacl; - int differs; - - if (aclp == NULL || trivialp == NULL) { - errno = EINVAL; - return (-1); - } - - switch (_acl_brand(aclp)) { - case ACL_BRAND_POSIX: - if (aclp->ats_acl.acl_cnt == 3) - *trivialp = 1; - else - *trivialp = 0; - - return (0); - - case ACL_BRAND_NFS4: - /* - * Calculate trivial ACL - using acl_strip_np - and compare - * with the original. - */ - tmpacl = acl_strip_np(aclp, 0); - if (tmpacl == NULL) - return (-1); - - differs = _acl_differs(aclp, tmpacl); - acl_free(tmpacl); - - if (differs) - *trivialp = 0; - else - *trivialp = 1; - - return (0); - - default: - errno = EINVAL; - return (-1); - } -} -/*- - * Copyright (c) 2001 Chris D. Faulhaber - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR THE VOICES IN HIS HEAD BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include - -#include "acl_support.h" - -/* - * These two routines from sys/kern/subr_acl_nfs4.c are used by both kernel - * and libc. - */ -void acl_nfs4_sync_acl_from_mode(struct acl *aclp, mode_t mode, - int file_owner_id); -void acl_nfs4_sync_mode_from_acl(mode_t *_mode, const struct acl *aclp); - -static acl_t -_nfs4_acl_strip_np(const acl_t aclp, int recalculate_mask) -{ - acl_t newacl; - mode_t mode; - - newacl = acl_init(ACL_MAX_ENTRIES); - if (newacl == NULL) { - errno = ENOMEM; - return (NULL); - } - - _acl_brand_as(newacl, ACL_BRAND_NFS4); - - acl_nfs4_sync_mode_from_acl(&mode, &(aclp->ats_acl)); - acl_nfs4_sync_acl_from_mode(&(newacl->ats_acl), mode, -1); - - return (newacl); -} - -static acl_t -_posix1e_acl_strip_np(const acl_t aclp, int recalculate_mask) -{ - acl_t acl_new, acl_old; - acl_entry_t entry, entry_new; - acl_permset_t perm; - acl_tag_t tag; - int entry_id, have_mask_entry; - - assert(_acl_brand(aclp) == ACL_BRAND_POSIX); - - acl_old = acl_dup(aclp); - if (acl_old == NULL) - return (NULL); - - assert(_acl_brand(acl_old) == ACL_BRAND_POSIX); - - have_mask_entry = 0; - acl_new = acl_init(ACL_MAX_ENTRIES); - if (acl_new == NULL) - return (NULL); - tag = ACL_UNDEFINED_TAG; - - /* only save the default user/group/other entries */ - entry_id = ACL_FIRST_ENTRY; - while (acl_get_entry(acl_old, entry_id, &entry) == 1) { - entry_id = ACL_NEXT_ENTRY; - - assert(_entry_brand(entry) == ACL_BRAND_POSIX); - - if (acl_get_tag_type(entry, &tag) == -1) - return (NULL); - - switch(tag) { - case ACL_USER_OBJ: - case ACL_GROUP_OBJ: - case ACL_OTHER: - if (acl_get_tag_type(entry, &tag) == -1) - return (NULL); - if (acl_get_permset(entry, &perm) == -1) - return (NULL); - if (acl_create_entry(&acl_new, &entry_new) == -1) - return (NULL); - if (acl_set_tag_type(entry_new, tag) == -1) - return (NULL); - if (acl_set_permset(entry_new, perm) == -1) - return (NULL); - if (acl_copy_entry(entry_new, entry) == -1) - return (NULL); - assert(_entry_brand(entry_new) == ACL_BRAND_POSIX); - break; - case ACL_MASK: - have_mask_entry = 1; - break; - default: - break; - } - } - - assert(_acl_brand(acl_new) == ACL_BRAND_POSIX); - - if (have_mask_entry && recalculate_mask) { - if (acl_calc_mask(&acl_new) == -1) - return (NULL); - } - - return (acl_new); -} - -acl_t -acl_strip_np(const acl_t aclp, int recalculate_mask) -{ - switch (_acl_brand(aclp)) { - case ACL_BRAND_NFS4: - return (_nfs4_acl_strip_np(aclp, recalculate_mask)); - - case ACL_BRAND_POSIX: - return (_posix1e_acl_strip_np(aclp, recalculate_mask)); - - default: - errno = EINVAL; - return (NULL); - } -} - -/* - * Return 1, if ACL is trivial, 0 otherwise. - * - * ACL is trivial, iff its meaning could be fully expressed using just file - * mode. In other words, ACL is trivial iff it doesn't have "+" to the right - * of the mode bits in "ls -l" output ;-) - */ -int -acl_is_trivial_np(const acl_t aclp, int *trivialp) -{ - acl_t tmpacl; - int differs; - - if (aclp == NULL || trivialp == NULL) { - errno = EINVAL; - return (-1); - } - - switch (_acl_brand(aclp)) { - case ACL_BRAND_POSIX: - if (aclp->ats_acl.acl_cnt == 3) - *trivialp = 1; - else - *trivialp = 0; - - return (0); - - case ACL_BRAND_NFS4: - /* - * Calculate trivial ACL - using acl_strip_np - and compare - * with the original. - */ - tmpacl = acl_strip_np(aclp, 0); - if (tmpacl == NULL) - return (-1); - - differs = _acl_differs(aclp, tmpacl); - acl_free(tmpacl); - - if (differs) - *trivialp = 0; - else - *trivialp = 1; - - return (0); - - default: - errno = EINVAL; - return (-1); - } -} diff --git a/lib/libc/posix1e/acl_strip_np.3 b/lib/libc/posix1e/acl_strip_np.3 index 9896f99..7b3537d 100644 --- a/lib/libc/posix1e/acl_strip_np.3 +++ b/lib/libc/posix1e/acl_strip_np.3 @@ -107,221 +107,3 @@ function was added in .Fx 8.0 . .Sh AUTHORS .An Edward Tomasz Napierala Aq trasz@FreeBSD.org . -.\"- -.\" Copyright (c) 2008, 2009 Edward Tomasz Napierala -.\" All rights reserved. -.\" -.\" This software was developed by Robert Watson for the TrustedBSD Project. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.\" -.Dd January 28, 2000 -.Dt ACL_STRIP_NP 3 -.Os -.Sh NAME -.Nm acl_strip_np -.Nd strip exteneded entries from an ACL -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/types.h -.In sys/acl.h -.Ft acl_t -.Fn acl_strip_np "const acl_t acl" "int recalculate_mask" -.Sh DESCRIPTION -The -.Fn acl_strip_np -function returns a pointer to a trivial ACL computed from the ACL pointed -to by the argument -.Va acl . -.Pp -This function may cause memory to be allocated. -The caller should free any -releasable memory, when the new ACL is no longer required, by calling -.Xr acl_free 3 -with the -.Va (void*)acl_t -as an argument. -.Pp -Any existing ACL pointers that refer to the ACL referred to by -.Va acl -shall continue to refer to the ACL. -.Sh RETURN VALUES -Upon successful completion, this function shall return a pointer to the -newly allocated ACL. -Otherwise, a value of -.Va (acl_t)NULL -shall be returned, and -.Va errno -shall be set to indicate the error. -.Sh ERRORS -If any of the following conditions occur, the -.Fn acl_init -function shall return a value of -.Va (acl_t)NULL -and set -.Va errno -to the corresponding value: -.Bl -tag -width Er -.It Bq Er EINVAL -Argument -.Va acl -does not point to a valid ACL. -.It Bq Er ENOMEM -The -.Va acl_t -to be returned requires more memory than is allowed by the hardware or -system-imposed memory management constraints. -.El -.Sh SEE ALSO -.Xr acl 3 , -.Xr acl_is_trivial_np 3 , -.Xr posix1e 3 -.Sh STANDARDS -POSIX.1e is described in IEEE POSIX.1e draft 17. -Discussion -of the draft continues on the cross-platform POSIX.1e implementation -mailing list. -To join this list, see the -.Fx -POSIX.1e implementation -page for more information. -.Sh HISTORY -POSIX.1e support was introduced in -.Fx 4.0 . -The -.Fn acl_strip_np -function was added in -.Fx 8.0 . -.Sh AUTHORS -.An Edward Tomasz Napierala Aq trasz@FreeBSD.org . -.\"- -.\" Copyright (c) 2008, 2009 Edward Tomasz Napierala -.\" All rights reserved. -.\" -.\" This software was developed by Robert Watson for the TrustedBSD Project. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" $FreeBSD$ -.\" -.Dd January 28, 2000 -.Dt ACL_STRIP_NP 3 -.Os -.Sh NAME -.Nm acl_strip_np -.Nd strip exteneded entries from an ACL -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/types.h -.In sys/acl.h -.Ft acl_t -.Fn acl_strip_np "const acl_t acl" "int recalculate_mask" -.Sh DESCRIPTION -The -.Fn acl_strip_np -function returns a pointer to a trivial ACL computed from the ACL pointed -to by the argument -.Va acl . -.Pp -This function may cause memory to be allocated. -The caller should free any -releasable memory, when the new ACL is no longer required, by calling -.Xr acl_free 3 -with the -.Va (void*)acl_t -as an argument. -.Pp -Any existing ACL pointers that refer to the ACL referred to by -.Va acl -shall continue to refer to the ACL. -.Sh RETURN VALUES -Upon successful completion, this function shall return a pointer to the -newly allocated ACL. -Otherwise, a value of -.Va (acl_t)NULL -shall be returned, and -.Va errno -shall be set to indicate the error. -.Sh ERRORS -If any of the following conditions occur, the -.Fn acl_init -function shall return a value of -.Va (acl_t)NULL -and set -.Va errno -to the corresponding value: -.Bl -tag -width Er -.It Bq Er EINVAL -Argument -.Va acl -does not point to a valid ACL. -.It Bq Er ENOMEM -The -.Va acl_t -to be returned requires more memory than is allowed by the hardware or -system-imposed memory management constraints. -.El -.Sh SEE ALSO -.Xr acl 3 , -.Xr acl_is_trivial_np 3 , -.Xr posix1e 3 -.Sh STANDARDS -POSIX.1e is described in IEEE POSIX.1e draft 17. -Discussion -of the draft continues on the cross-platform POSIX.1e implementation -mailing list. -To join this list, see the -.Fx -POSIX.1e implementation -page for more information. -.Sh HISTORY -POSIX.1e support was introduced in -.Fx 4.0 . -The -.Fn acl_strip_np -function was added in -.Fx 8.0 . -.Sh AUTHORS -.An Edward Tomasz Napierala Aq trasz@FreeBSD.org . diff --git a/lib/libc/posix1e/acl_support_nfs4.c b/lib/libc/posix1e/acl_support_nfs4.c index 0a840b3..c5be3d1 100644 --- a/lib/libc/posix1e/acl_support_nfs4.c +++ b/lib/libc/posix1e/acl_support_nfs4.c @@ -254,515 +254,3 @@ _nfs4_parse_access_mask(const char *str, acl_perm_t *perms) return (error); } -/*- - * Copyright (c) 2008, 2009 Edward Tomasz Napierała - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include "acl_support.h" - -struct flagnames_struct { - uint32_t flag; - const char *name; - char letter; -}; - -struct flagnames_struct a_flags[] = - {{ ACL_ENTRY_FILE_INHERIT, "file_inherit", 'f'}, - { ACL_ENTRY_DIRECTORY_INHERIT, "dir_inherit", 'd'}, - { ACL_ENTRY_INHERIT_ONLY, "inherit_only", 'i'}, - { ACL_ENTRY_NO_PROPAGATE_INHERIT, "no_propagate", 'n'}, - { ACL_ENTRY_SUCCESSFUL_ACCESS, "successfull_access", 'S'}, - { ACL_ENTRY_FAILED_ACCESS, "failed_access", 'F'}, - /* - * There is no ACE_IDENTIFIER_GROUP here - SunOS does not show it - * in the "flags" field. There is no ACE_OWNER, ACE_GROUP or - * ACE_EVERYONE either, for obvious reasons. - */ - { 0, 0, 0}}; - -struct flagnames_struct a_access_masks[] = - {{ ACL_READ_DATA, "read_data", 'r'}, - { ACL_WRITE_DATA, "write_data", 'w'}, - { ACL_EXECUTE, "execute", 'x'}, - { ACL_APPEND_DATA, "append_data", 'p'}, - { ACL_DELETE_CHILD, "delete_child", 'D'}, - { ACL_DELETE, "delete", 'd'}, - { ACL_READ_ATTRIBUTES, "read_attributes", 'a'}, - { ACL_WRITE_ATTRIBUTES, "write_attributes", 'A'}, - { ACL_READ_NAMED_ATTRS, "read_xattr", 'R'}, - { ACL_WRITE_NAMED_ATTRS, "write_xattr", 'W'}, - { ACL_READ_ACL, "read_acl", 'c'}, - { ACL_WRITE_ACL, "write_acl", 'C'}, - { ACL_WRITE_OWNER, "write_owner", 'o'}, - { ACL_SYNCHRONIZE, "synchronize", 's'}, - { 0, 0, 0}}; - -static const char * -format_flag(uint32_t *var, const struct flagnames_struct *flags) -{ - - for (; flags->name != 0; flags++) { - if ((flags->flag & *var) == 0) - continue; - - *var &= ~flags->flag; - return (flags->name); - } - - return (NULL); -} - -static int -format_flags_verbose(char *str, size_t size, uint32_t var, - const struct flagnames_struct *flags) -{ - size_t off = 0; - const char *tmp; - - while ((tmp = format_flag(&var, flags)) != NULL) { - off += snprintf(str + off, size - off, "%s/", tmp); - assert (off < size); - } - - /* If there were any flags added... */ - if (off > 0) { - off--; - /* ... then remove the last slash. */ - assert(str[off] == '/'); - } - - str[off] = '\0'; - - return (0); -} - -static int -format_flags_compact(char *str, size_t size, uint32_t var, - const struct flagnames_struct *flags) -{ - size_t i; - - for (i = 0; flags[i].name != NULL; i++) { - assert(i < size); - if ((flags[i].flag & var) == 0) - str[i] = '-'; - else - str[i] = flags[i].letter; - } - - str[i] = '\0'; - - return (0); -} - -static int -parse_flags_verbose(const char *strp, uint32_t *var, - const struct flagnames_struct *flags, const char *flags_name, - int *try_compact) -{ - int i, found, ever_found = 0; - char *str, *flag; - - str = strdup(strp); - *try_compact = 0; - *var = 0; - - while (str != NULL) { - flag = strsep(&str, "/:"); - - found = 0; - for (i = 0; flags[i].name != NULL; i++) { - if (strcmp(flags[i].name, flag) == 0) { - *var |= flags[i].flag; - found = 1; - ever_found = 1; - } - } - - if (!found) { - if (ever_found) - warnx("malformed ACL: \"%s\" field contains " - "invalid flag \"%s\"", flags_name, flag); - else - *try_compact = 1; - free(str); - return (-1); - } - } - - free(str); - return (0); -} - -static int -parse_flags_compact(const char *str, uint32_t *var, - const struct flagnames_struct *flags, const char *flags_name) -{ - int i, j, found; - - *var = 0; - - for (i = 0;; i++) { - if (str[i] == '\0') - return (0); - - /* Ignore minus signs. */ - if (str[i] == '-') - continue; - - found = 0; - - for (j = 0; flags[j].name != NULL; j++) { - if (flags[j].letter == str[i]) { - *var |= flags[j].flag; - found = 1; - break; - } - } - - if (!found) { - warnx("malformed ACL: \"%s\" field contains " - "invalid flag \"%c\"", flags_name, str[i]); - return (-1); - } - } -} - -int -_nfs4_format_flags(char *str, size_t size, acl_flag_t var, int verbose) -{ - - if (verbose) - return (format_flags_verbose(str, size, var, a_flags)); - - return (format_flags_compact(str, size, var, a_flags)); -} - -int -_nfs4_format_access_mask(char *str, size_t size, acl_perm_t var, int verbose) -{ - - if (verbose) - return (format_flags_verbose(str, size, var, a_access_masks)); - - return (format_flags_compact(str, size, var, a_access_masks)); -} - -int -_nfs4_parse_flags(const char *str, acl_flag_t *flags) -{ - int error, try_compact; - int tmpflags; - - error = parse_flags_verbose(str, &tmpflags, a_flags, "flags", &try_compact); - if (error && try_compact) - error = parse_flags_compact(str, &tmpflags, a_flags, "flags"); - - *flags = tmpflags; - - return (error); -} - -int -_nfs4_parse_access_mask(const char *str, acl_perm_t *perms) -{ - int error, try_compact; - int tmpperms; - - error = parse_flags_verbose(str, &tmpperms, a_access_masks, - "access permissions", &try_compact); - if (error && try_compact) - error = parse_flags_compact(str, &tmpperms, - a_access_masks, "access permissions"); - - *perms = tmpperms; - - return (error); -} -/*- - * Copyright (c) 2008, 2009 Edward Tomasz Napierała - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include "acl_support.h" - -struct flagnames_struct { - uint32_t flag; - const char *name; - char letter; -}; - -struct flagnames_struct a_flags[] = - {{ ACL_ENTRY_FILE_INHERIT, "file_inherit", 'f'}, - { ACL_ENTRY_DIRECTORY_INHERIT, "dir_inherit", 'd'}, - { ACL_ENTRY_INHERIT_ONLY, "inherit_only", 'i'}, - { ACL_ENTRY_NO_PROPAGATE_INHERIT, "no_propagate", 'n'}, - { ACL_ENTRY_SUCCESSFUL_ACCESS, "successfull_access", 'S'}, - { ACL_ENTRY_FAILED_ACCESS, "failed_access", 'F'}, - /* - * There is no ACE_IDENTIFIER_GROUP here - SunOS does not show it - * in the "flags" field. There is no ACE_OWNER, ACE_GROUP or - * ACE_EVERYONE either, for obvious reasons. - */ - { 0, 0, 0}}; - -struct flagnames_struct a_access_masks[] = - {{ ACL_READ_DATA, "read_data", 'r'}, - { ACL_WRITE_DATA, "write_data", 'w'}, - { ACL_EXECUTE, "execute", 'x'}, - { ACL_APPEND_DATA, "append_data", 'p'}, - { ACL_DELETE_CHILD, "delete_child", 'D'}, - { ACL_DELETE, "delete", 'd'}, - { ACL_READ_ATTRIBUTES, "read_attributes", 'a'}, - { ACL_WRITE_ATTRIBUTES, "write_attributes", 'A'}, - { ACL_READ_NAMED_ATTRS, "read_xattr", 'R'}, - { ACL_WRITE_NAMED_ATTRS, "write_xattr", 'W'}, - { ACL_READ_ACL, "read_acl", 'c'}, - { ACL_WRITE_ACL, "write_acl", 'C'}, - { ACL_WRITE_OWNER, "write_owner", 'o'}, - { ACL_SYNCHRONIZE, "synchronize", 's'}, - { 0, 0, 0}}; - -static const char * -format_flag(uint32_t *var, const struct flagnames_struct *flags) -{ - - for (; flags->name != 0; flags++) { - if ((flags->flag & *var) == 0) - continue; - - *var &= ~flags->flag; - return (flags->name); - } - - return (NULL); -} - -static int -format_flags_verbose(char *str, size_t size, uint32_t var, - const struct flagnames_struct *flags) -{ - size_t off = 0; - const char *tmp; - - while ((tmp = format_flag(&var, flags)) != NULL) { - off += snprintf(str + off, size - off, "%s/", tmp); - assert (off < size); - } - - /* If there were any flags added... */ - if (off > 0) { - off--; - /* ... then remove the last slash. */ - assert(str[off] == '/'); - } - - str[off] = '\0'; - - return (0); -} - -static int -format_flags_compact(char *str, size_t size, uint32_t var, - const struct flagnames_struct *flags) -{ - size_t i; - - for (i = 0; flags[i].name != NULL; i++) { - assert(i < size); - if ((flags[i].flag & var) == 0) - str[i] = '-'; - else - str[i] = flags[i].letter; - } - - str[i] = '\0'; - - return (0); -} - -static int -parse_flags_verbose(const char *strp, uint32_t *var, - const struct flagnames_struct *flags, const char *flags_name, - int *try_compact) -{ - int i, found, ever_found = 0; - char *str, *flag; - - str = strdup(strp); - *try_compact = 0; - *var = 0; - - while (str != NULL) { - flag = strsep(&str, "/:"); - - found = 0; - for (i = 0; flags[i].name != NULL; i++) { - if (strcmp(flags[i].name, flag) == 0) { - *var |= flags[i].flag; - found = 1; - ever_found = 1; - } - } - - if (!found) { - if (ever_found) - warnx("malformed ACL: \"%s\" field contains " - "invalid flag \"%s\"", flags_name, flag); - else - *try_compact = 1; - free(str); - return (-1); - } - } - - free(str); - return (0); -} - -static int -parse_flags_compact(const char *str, uint32_t *var, - const struct flagnames_struct *flags, const char *flags_name) -{ - int i, j, found; - - *var = 0; - - for (i = 0;; i++) { - if (str[i] == '\0') - return (0); - - /* Ignore minus signs. */ - if (str[i] == '-') - continue; - - found = 0; - - for (j = 0; flags[j].name != NULL; j++) { - if (flags[j].letter == str[i]) { - *var |= flags[j].flag; - found = 1; - break; - } - } - - if (!found) { - warnx("malformed ACL: \"%s\" field contains " - "invalid flag \"%c\"", flags_name, str[i]); - return (-1); - } - } -} - -int -_nfs4_format_flags(char *str, size_t size, acl_flag_t var, int verbose) -{ - - if (verbose) - return (format_flags_verbose(str, size, var, a_flags)); - - return (format_flags_compact(str, size, var, a_flags)); -} - -int -_nfs4_format_access_mask(char *str, size_t size, acl_perm_t var, int verbose) -{ - - if (verbose) - return (format_flags_verbose(str, size, var, a_access_masks)); - - return (format_flags_compact(str, size, var, a_access_masks)); -} - -int -_nfs4_parse_flags(const char *str, acl_flag_t *flags) -{ - int error, try_compact; - int tmpflags; - - error = parse_flags_verbose(str, &tmpflags, a_flags, "flags", &try_compact); - if (error && try_compact) - error = parse_flags_compact(str, &tmpflags, a_flags, "flags"); - - *flags = tmpflags; - - return (error); -} - -int -_nfs4_parse_access_mask(const char *str, acl_perm_t *perms) -{ - int error, try_compact; - int tmpperms; - - error = parse_flags_verbose(str, &tmpperms, a_access_masks, - "access permissions", &try_compact); - if (error && try_compact) - error = parse_flags_compact(str, &tmpperms, - a_access_masks, "access permissions"); - - *perms = tmpperms; - - return (error); -} diff --git a/lib/libc/posix1e/acl_to_text_nfs4.c b/lib/libc/posix1e/acl_to_text_nfs4.c index dc622a1..3adbfb4 100644 --- a/lib/libc/posix1e/acl_to_text_nfs4.c +++ b/lib/libc/posix1e/acl_to_text_nfs4.c @@ -264,535 +264,3 @@ _nfs4_acl_to_text_np(const acl_t aclp, ssize_t *len_p, int flags) return (str); } -/*- - * Copyright (c) 2008, 2009 Edward Tomasz Napierała - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "acl_support.h" - -#define MAX_ENTRY_LENGTH 512 - -static int -format_who(char *str, size_t size, const acl_entry_t entry, int numeric) -{ - int error; - acl_tag_t tag; - struct passwd *pwd; - struct group *grp; - id_t *id; - - error = acl_get_tag_type(entry, &tag); - if (error) - return (error); - - switch (tag) { - case ACL_USER_OBJ: - snprintf(str, size, "owner@"); - break; - - case ACL_USER: - id = (id_t *)acl_get_qualifier(entry); - if (id == NULL) - return (-1); - /* XXX: Thread-unsafe. */ - if (!numeric) - pwd = getpwuid(*id); - else - pwd = NULL; - if (pwd == NULL) - snprintf(str, size, "user:%d", (unsigned int)*id); - else - snprintf(str, size, "user:%s", pwd->pw_name); - break; - - case ACL_GROUP_OBJ: - snprintf(str, size, "group@"); - break; - - case ACL_GROUP: - id = (id_t *)acl_get_qualifier(entry); - if (id == NULL) - return (-1); - /* XXX: Thread-unsafe. */ - if (!numeric) - grp = getgrgid(*id); - else - grp = NULL; - if (grp == NULL) - snprintf(str, size, "group:%d", (unsigned int)*id); - else - snprintf(str, size, "group:%s", grp->gr_name); - break; - - case ACL_EVERYONE: - snprintf(str, size, "everyone@"); - break; - - default: - return (-1); - } - - return (0); -} - -static int -format_entry_type(char *str, size_t size, const acl_entry_t entry) -{ - int error; - acl_entry_type_t entry_type; - - error = acl_get_entry_type_np(entry, &entry_type); - if (error) - return (error); - - switch (entry_type) { - case ACL_ENTRY_TYPE_ALLOW: - snprintf(str, size, "allow"); - break; - case ACL_ENTRY_TYPE_DENY: - snprintf(str, size, "deny"); - break; - case ACL_ENTRY_TYPE_AUDIT: - snprintf(str, size, "audit"); - break; - case ACL_ENTRY_TYPE_ALARM: - snprintf(str, size, "alarm"); - break; - default: - return (-1); - } - - return (0); -} - -static int -format_additional_id(char *str, size_t size, const acl_entry_t entry) -{ - int error; - acl_tag_t tag; - id_t *id; - - error = acl_get_tag_type(entry, &tag); - if (error) - return (error); - - switch (tag) { - case ACL_USER_OBJ: - case ACL_GROUP_OBJ: - case ACL_EVERYONE: - str[0] = '\0'; - break; - - default: - id = (id_t *)acl_get_qualifier(entry); - if (id == NULL) - return (-1); - snprintf(str, size, ":%d", (unsigned int)*id); - } - - return (0); -} - -static int -format_entry(char *str, size_t size, const acl_entry_t entry, int flags) -{ - size_t off = 0, padding_length, maximum_who_field_length = 18; - acl_permset_t permset; - acl_flagset_t flagset; - int error, len; - char buf[MAX_ENTRY_LENGTH + 1]; - - assert(_entry_brand(entry) == ACL_BRAND_NFS4); - - error = acl_get_flagset_np(entry, &flagset); - if (error) - return (error); - - error = acl_get_permset(entry, &permset); - if (error) - return (error); - - error = format_who(buf, sizeof(buf), entry, - flags & ACL_TEXT_NUMERIC_IDS); - if (error) - return (error); - len = strlen(buf); - padding_length = maximum_who_field_length - len; - if (padding_length > 0) { - memset(str, ' ', padding_length); - off += padding_length; - } - off += snprintf(str + off, size - off, "%s:", buf); - - error = _nfs4_format_access_mask(buf, sizeof(buf), *permset, - flags & ACL_TEXT_VERBOSE); - if (error) - return (error); - off += snprintf(str + off, size - off, "%s:", buf); - - error = _nfs4_format_flags(buf, sizeof(buf), *flagset, - flags & ACL_TEXT_VERBOSE); - if (error) - return (error); - off += snprintf(str + off, size - off, "%s:", buf); - - error = format_entry_type(buf, sizeof(buf), entry); - if (error) - return (error); - off += snprintf(str + off, size - off, "%s", buf); - - if (flags & ACL_TEXT_APPEND_ID) { - error = format_additional_id(buf, sizeof(buf), entry); - if (error) - return (error); - off += snprintf(str + off, size - off, "%s", buf); - } - - off += snprintf(str + off, size - off, "\n"); - - /* Make sure we didn't truncate anything. */ - assert (off < size); - - return (0); -} - -char * -_nfs4_acl_to_text_np(const acl_t aclp, ssize_t *len_p, int flags) -{ - int error, off = 0, size, entry_id = ACL_FIRST_ENTRY; - char *str; - acl_entry_t entry; - - if (aclp->ats_acl.acl_cnt == 0) - return strdup(""); - - size = aclp->ats_acl.acl_cnt * MAX_ENTRY_LENGTH; - str = malloc(size); - if (str == NULL) - return (NULL); - - while (acl_get_entry(aclp, entry_id, &entry) == 1) { - entry_id = ACL_NEXT_ENTRY; - - assert(off < size); - - error = format_entry(str + off, size - off, entry, flags); - if (error) { - errno = EINVAL; - return (NULL); - } - - off = strlen(str); - } - - assert(off < size); - str[off] = '\0'; - - if (len_p != NULL) - *len_p = off; - - return (str); -} -/*- - * Copyright (c) 2008, 2009 Edward Tomasz Napierała - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -__FBSDID("$FreeBSD$"); - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "acl_support.h" - -#define MAX_ENTRY_LENGTH 512 - -static int -format_who(char *str, size_t size, const acl_entry_t entry, int numeric) -{ - int error; - acl_tag_t tag; - struct passwd *pwd; - struct group *grp; - id_t *id; - - error = acl_get_tag_type(entry, &tag); - if (error) - return (error); - - switch (tag) { - case ACL_USER_OBJ: - snprintf(str, size, "owner@"); - break; - - case ACL_USER: - id = (id_t *)acl_get_qualifier(entry); - if (id == NULL) - return (-1); - /* XXX: Thread-unsafe. */ - if (!numeric) - pwd = getpwuid(*id); - else - pwd = NULL; - if (pwd == NULL) - snprintf(str, size, "user:%d", (unsigned int)*id); - else - snprintf(str, size, "user:%s", pwd->pw_name); - break; - - case ACL_GROUP_OBJ: - snprintf(str, size, "group@"); - break; - - case ACL_GROUP: - id = (id_t *)acl_get_qualifier(entry); - if (id == NULL) - return (-1); - /* XXX: Thread-unsafe. */ - if (!numeric) - grp = getgrgid(*id); - else - grp = NULL; - if (grp == NULL) - snprintf(str, size, "group:%d", (unsigned int)*id); - else - snprintf(str, size, "group:%s", grp->gr_name); - break; - - case ACL_EVERYONE: - snprintf(str, size, "everyone@"); - break; - - default: - return (-1); - } - - return (0); -} - -static int -format_entry_type(char *str, size_t size, const acl_entry_t entry) -{ - int error; - acl_entry_type_t entry_type; - - error = acl_get_entry_type_np(entry, &entry_type); - if (error) - return (error); - - switch (entry_type) { - case ACL_ENTRY_TYPE_ALLOW: - snprintf(str, size, "allow"); - break; - case ACL_ENTRY_TYPE_DENY: - snprintf(str, size, "deny"); - break; - case ACL_ENTRY_TYPE_AUDIT: - snprintf(str, size, "audit"); - break; - case ACL_ENTRY_TYPE_ALARM: - snprintf(str, size, "alarm"); - break; - default: - return (-1); - } - - return (0); -} - -static int -format_additional_id(char *str, size_t size, const acl_entry_t entry) -{ - int error; - acl_tag_t tag; - id_t *id; - - error = acl_get_tag_type(entry, &tag); - if (error) - return (error); - - switch (tag) { - case ACL_USER_OBJ: - case ACL_GROUP_OBJ: - case ACL_EVERYONE: - str[0] = '\0'; - break; - - default: - id = (id_t *)acl_get_qualifier(entry); - if (id == NULL) - return (-1); - snprintf(str, size, ":%d", (unsigned int)*id); - } - - return (0); -} - -static int -format_entry(char *str, size_t size, const acl_entry_t entry, int flags) -{ - size_t off = 0, padding_length, maximum_who_field_length = 18; - acl_permset_t permset; - acl_flagset_t flagset; - int error, len; - char buf[MAX_ENTRY_LENGTH + 1]; - - assert(_entry_brand(entry) == ACL_BRAND_NFS4); - - error = acl_get_flagset_np(entry, &flagset); - if (error) - return (error); - - error = acl_get_permset(entry, &permset); - if (error) - return (error); - - error = format_who(buf, sizeof(buf), entry, - flags & ACL_TEXT_NUMERIC_IDS); - if (error) - return (error); - len = strlen(buf); - padding_length = maximum_who_field_length - len; - if (padding_length > 0) { - memset(str, ' ', padding_length); - off += padding_length; - } - off += snprintf(str + off, size - off, "%s:", buf); - - error = _nfs4_format_access_mask(buf, sizeof(buf), *permset, - flags & ACL_TEXT_VERBOSE); - if (error) - return (error); - off += snprintf(str + off, size - off, "%s:", buf); - - error = _nfs4_format_flags(buf, sizeof(buf), *flagset, - flags & ACL_TEXT_VERBOSE); - if (error) - return (error); - off += snprintf(str + off, size - off, "%s:", buf); - - error = format_entry_type(buf, sizeof(buf), entry); - if (error) - return (error); - off += snprintf(str + off, size - off, "%s", buf); - - if (flags & ACL_TEXT_APPEND_ID) { - error = format_additional_id(buf, sizeof(buf), entry); - if (error) - return (error); - off += snprintf(str + off, size - off, "%s", buf); - } - - off += snprintf(str + off, size - off, "\n"); - - /* Make sure we didn't truncate anything. */ - assert (off < size); - - return (0); -} - -char * -_nfs4_acl_to_text_np(const acl_t aclp, ssize_t *len_p, int flags) -{ - int error, off = 0, size, entry_id = ACL_FIRST_ENTRY; - char *str; - acl_entry_t entry; - - if (aclp->ats_acl.acl_cnt == 0) - return strdup(""); - - size = aclp->ats_acl.acl_cnt * MAX_ENTRY_LENGTH; - str = malloc(size); - if (str == NULL) - return (NULL); - - while (acl_get_entry(aclp, entry_id, &entry) == 1) { - entry_id = ACL_NEXT_ENTRY; - - assert(off < size); - - error = format_entry(str + off, size - off, entry, flags); - if (error) { - errno = EINVAL; - return (NULL); - } - - off = strlen(str); - } - - assert(off < size); - str[off] = '\0'; - - if (len_p != NULL) - *len_p = off; - - return (str); -} -- cgit v1.1