Deleted Added
full compact
acl_set.c (195004) acl_set.c (208785)
1/*-
2 * Copyright (c) 1999, 2000, 2001, 2002 Robert N. M. Watson
3 * All rights reserved.
4 *
5 * This software was developed by Robert Watson for the TrustedBSD Project.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

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

25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28/*
29 * acl_set_file -- set a file/directory ACL by name
30 */
31
32#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1999, 2000, 2001, 2002 Robert N. M. Watson
3 * All rights reserved.
4 *
5 * This software was developed by Robert Watson for the TrustedBSD Project.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions

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

25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28/*
29 * acl_set_file -- set a file/directory ACL by name
30 */
31
32#include <sys/cdefs.h>
33__FBSDID("$FreeBSD: head/lib/libc/posix1e/acl_set.c 195004 2009-06-25 20:57:53Z trasz $");
33__FBSDID("$FreeBSD: head/lib/libc/posix1e/acl_set.c 208785 2010-06-03 14:29:17Z trasz $");
34
35#include <sys/types.h>
36#include "namespace.h"
37#include <sys/acl.h>
38#include "un-namespace.h"
39
40#include <errno.h>
41#include <stdlib.h>

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

48 * For POSIX.1e-semantic ACLs, do a presort so the kernel doesn't have to
49 * (the POSIX.1e semantic code will reject unsorted ACL submission). If it's
50 * not a semantic that the library knows about, just submit it flat and
51 * assume the caller knows what they're up to.
52 */
53int
54acl_set_file(const char *path_p, acl_type_t type, acl_t acl)
55{
34
35#include <sys/types.h>
36#include "namespace.h"
37#include <sys/acl.h>
38#include "un-namespace.h"
39
40#include <errno.h>
41#include <stdlib.h>

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

48 * For POSIX.1e-semantic ACLs, do a presort so the kernel doesn't have to
49 * (the POSIX.1e semantic code will reject unsorted ACL submission). If it's
50 * not a semantic that the library knows about, just submit it flat and
51 * assume the caller knows what they're up to.
52 */
53int
54acl_set_file(const char *path_p, acl_type_t type, acl_t acl)
55{
56 int error;
57
58 if (acl == NULL || path_p == NULL) {
59 errno = EINVAL;
60 return (-1);
61 }
62 type = _acl_type_unold(type);
63 if (_acl_type_not_valid_for_acl(acl, type)) {
64 errno = EINVAL;
65 return (-1);
66 }
56
57 if (acl == NULL || path_p == NULL) {
58 errno = EINVAL;
59 return (-1);
60 }
61 type = _acl_type_unold(type);
62 if (_acl_type_not_valid_for_acl(acl, type)) {
63 errno = EINVAL;
64 return (-1);
65 }
67 if (_posix1e_acl(acl, type)) {
68 error = _posix1e_acl_sort(acl);
69 if (error) {
70 errno = error;
71 return (-1);
72 }
73 }
66 if (_posix1e_acl(acl, type))
67 _posix1e_acl_sort(acl);
74
75 acl->ats_cur_entry = 0;
76
77 return (__acl_set_file(path_p, type, &acl->ats_acl));
78}
79
80int
81acl_set_link_np(const char *path_p, acl_type_t type, acl_t acl)
82{
68
69 acl->ats_cur_entry = 0;
70
71 return (__acl_set_file(path_p, type, &acl->ats_acl));
72}
73
74int
75acl_set_link_np(const char *path_p, acl_type_t type, acl_t acl)
76{
83 int error;
84
85 if (acl == NULL || path_p == NULL) {
86 errno = EINVAL;
87 return (-1);
88 }
89 type = _acl_type_unold(type);
90 if (_acl_type_not_valid_for_acl(acl, type)) {
91 errno = EINVAL;
92 return (-1);
93 }
77
78 if (acl == NULL || path_p == NULL) {
79 errno = EINVAL;
80 return (-1);
81 }
82 type = _acl_type_unold(type);
83 if (_acl_type_not_valid_for_acl(acl, type)) {
84 errno = EINVAL;
85 return (-1);
86 }
94 if (_posix1e_acl(acl, type)) {
95 error = _posix1e_acl_sort(acl);
96 if (error) {
97 errno = error;
98 return (-1);
99 }
100 }
87 if (_posix1e_acl(acl, type))
88 _posix1e_acl_sort(acl);
101
102 acl->ats_cur_entry = 0;
103
104 return (__acl_set_link(path_p, type, &acl->ats_acl));
105}
106
107int
108acl_set_fd(int fd, acl_t acl)
109{
110
111 if (fpathconf(fd, _PC_ACL_NFS4) == 1)
112 return (acl_set_fd_np(fd, acl, ACL_TYPE_NFS4));
113
114 return (acl_set_fd_np(fd, acl, ACL_TYPE_ACCESS));
115}
116
117int
118acl_set_fd_np(int fd, acl_t acl, acl_type_t type)
119{
89
90 acl->ats_cur_entry = 0;
91
92 return (__acl_set_link(path_p, type, &acl->ats_acl));
93}
94
95int
96acl_set_fd(int fd, acl_t acl)
97{
98
99 if (fpathconf(fd, _PC_ACL_NFS4) == 1)
100 return (acl_set_fd_np(fd, acl, ACL_TYPE_NFS4));
101
102 return (acl_set_fd_np(fd, acl, ACL_TYPE_ACCESS));
103}
104
105int
106acl_set_fd_np(int fd, acl_t acl, acl_type_t type)
107{
120 int error;
121
122 if (acl == NULL) {
123 errno = EINVAL;
124 return (-1);
125 }
126 type = _acl_type_unold(type);
127 if (_acl_type_not_valid_for_acl(acl, type)) {
128 errno = EINVAL;
129 return (-1);
130 }
108
109 if (acl == NULL) {
110 errno = EINVAL;
111 return (-1);
112 }
113 type = _acl_type_unold(type);
114 if (_acl_type_not_valid_for_acl(acl, type)) {
115 errno = EINVAL;
116 return (-1);
117 }
131 if (_posix1e_acl(acl, type)) {
132 error = _posix1e_acl_sort(acl);
133 if (error) {
134 errno = error;
135 return (-1);
136 }
137 }
118 if (_posix1e_acl(acl, type))
119 _posix1e_acl_sort(acl);
138
139 acl->ats_cur_entry = 0;
140
141 return (___acl_set_fd(fd, type, &acl->ats_acl));
142}
143
144/*
145 * acl_set_permset() (23.4.23): sets the permissions of ACL entry entry_d

--- 126 unchanged lines hidden ---
120
121 acl->ats_cur_entry = 0;
122
123 return (___acl_set_fd(fd, type, &acl->ats_acl));
124}
125
126/*
127 * acl_set_permset() (23.4.23): sets the permissions of ACL entry entry_d

--- 126 unchanged lines hidden ---