acl_valid.c (8f45e8c07611579a6a623ef2201082816c2f39ae) acl_valid.c (a889d1fb766450bff9b27c3bccfe18fc39cd753d)
1/*-
2 * Copyright (c) 1999 Robert N. M. Watson
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 27 unchanged lines hidden (view full) ---

36#include "acl_support.h"
37
38/*
39 * acl_valid: accepts an ACL, returns 0 on valid ACL, -1 for invalid,
40 * and errno set to EINVAL.
41 *
42 * Implemented by calling the acl_check routine in acl_support, which
43 * requires ordering. We call acl_support's acl_sort to make this
1/*-
2 * Copyright (c) 1999 Robert N. M. Watson
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 27 unchanged lines hidden (view full) ---

36#include "acl_support.h"
37
38/*
39 * acl_valid: accepts an ACL, returns 0 on valid ACL, -1 for invalid,
40 * and errno set to EINVAL.
41 *
42 * Implemented by calling the acl_check routine in acl_support, which
43 * requires ordering. We call acl_support's acl_sort to make this
44 * true.
44 * true. POSIX.1e allows acl_valid() to reorder the ACL as it sees fit.
45 *
45 *
46 * POSIX.1e allows acl_valid() to reorder the ACL as it sees fit.
47 *
48 * This call is deprecated, as it doesn't ask whether the ACL is valid
46 * This call is deprecated, as it doesn't ask whether the ACL is valid
49 * for a particular target.
47 * for a particular target. However, this call is standardized, unlike
48 * the other two forms.
50 */
51int
52acl_valid(acl_t acl)
53{
54 int error;
55
56 acl_sort(acl);
57 error = acl_check(acl);
58 if (error) {
59 errno = error;
60 return (-1);
61 } else {
62 return (0);
63 }
64}
65
66
67int
49 */
50int
51acl_valid(acl_t acl)
52{
53 int error;
54
55 acl_sort(acl);
56 error = acl_check(acl);
57 if (error) {
58 errno = error;
59 return (-1);
60 } else {
61 return (0);
62 }
63}
64
65
66int
68acl_valid_file(const char *pathp, acl_type_t type, acl_t acl)
67acl_valid_file_np(const char *pathp, acl_type_t type, acl_t acl)
69{
70 int error;
71
72 if (acl_posix1e(acl, type)) {
73 error = acl_sort(acl);
74 if (error) {
75 errno = error;
76 return (-1);
77 }
78 }
79
80 return (__acl_aclcheck_file(pathp, type, acl));
81}
82
83
84int
68{
69 int error;
70
71 if (acl_posix1e(acl, type)) {
72 error = acl_sort(acl);
73 if (error) {
74 errno = error;
75 return (-1);
76 }
77 }
78
79 return (__acl_aclcheck_file(pathp, type, acl));
80}
81
82
83int
85acl_valid_fd(int fd, acl_type_t type, acl_t acl)
84acl_valid_fd_np(int fd, acl_type_t type, acl_t acl)
86{
87 int error;
88
89 if (acl_posix1e(acl, type)) {
90 error = acl_sort(acl);
91 if (error) {
92 errno = error;
93 return (-1);
94 }
95 }
96
97 return (__acl_aclcheck_fd(fd, type, acl));
98}
85{
86 int error;
87
88 if (acl_posix1e(acl, type)) {
89 error = acl_sort(acl);
90 if (error) {
91 errno = error;
92 return (-1);
93 }
94 }
95
96 return (__acl_aclcheck_fd(fd, type, acl));
97}