2 * Copyright (c) 2001 Silicon Graphics, Inc. All Rights Reserved.
4 * This prog is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
8 * This prog is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this prog with
17 * other software, or any other product whatsoever.
19 * You should have received a copy of the GNU General Public License along
20 * with this prog; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
34 * Test our various libacl functions.
35 * Use IRIX semantics or Linux semantics if pertinent.
44 int irixsemantics = 0;
48 fprintf(stderr, "usage: %s\n"
49 " -i - use irix semantics\n"
57 printf("%s: %s: %s\n", prog, msg, strerror(errno));
61 dump_ace(acl_entry_t ace)
63 printf("<tag:%d,id:%d,perm:%u>",
64 ace->ae_tag, ace->ae_id, ace->ae_perm);
71 printf("ACL[n=%d]: ", acl->acl_cnt);
72 for (i=0;i<acl->acl_cnt;i++) {
73 acl_entry_t ace = &acl->acl_entry[i];
83 dump_acl_by_entry(acl_t acl)
88 printf("Get 1st entry on filled ACL\n");
89 sts = acl_get_entry(acl, ACL_FIRST_ENTRY, &ace);
90 printf("acl_get_entry -> %d\n", sts);
92 printf("1: "); dump_ace(ace); printf("\n");
95 for(i=2;i<=acl->acl_cnt+2;i++) {
96 printf("Get %dth entry on filled ACL\n", i);
97 sts = acl_get_entry(acl, ACL_NEXT_ENTRY, &ace);
98 printf("acl_get_entry -> %d\n", sts);
100 printf("%d: ",i); dump_ace(ace); printf("\n");
106 * create a full acl with entries with known bogus values
109 create_filled_acl(void)
114 acl = acl_init(ACL_MAX_ENTRIES);
116 for(i=0;i<ACL_MAX_ENTRIES;i++) {
117 acl_entry_t ace = &acl->acl_entry[i];
127 main(int argc, char **argv)
130 acl_t acl1, acl2, acl3;
133 prog = basename(argv[0]);
135 while ((c = getopt(argc, argv, "i")) != -1) {
147 acl_set_compat(ACL_COMPAT_IRIXGET);
150 /* ---------------------------------------------- */
151 printf("*** test out creating an ACL ***\n");
153 printf("Test acl_init(ACL_MAX_ENTRIES+1)\n");
154 acl1 = acl_init(ACL_MAX_ENTRIES+1);
156 print_err("acl_init(max+1)");
158 printf("Test acl_init(-1)\n");
161 print_err("acl_init(-1)");
163 printf("Test acl_init(0)\n");
166 print_err("acl_init(0)");
169 printf("Test acl_create_entry(NULL, ...)\n");
170 if (acl_create_entry(NULL, &ace1) == -1) {
171 print_err("acl_create_entry(NULL,ace1)");
173 printf("Test acl_create_entry(..., NULL)\n");
174 if (acl_create_entry(&acl1, NULL) == -1) {
175 print_err("acl_create_entry(NULL,ace1)");
177 printf("Test acl_create_entry(acl1, ace1)\n");
179 if (acl_create_entry(&acl1, &ace1) == -1) {
180 print_err("acl_create_entry(*null,ace1)");
185 for (i=0;i<=ACL_MAX_ENTRIES+1;i++) {
186 printf("%d: creating ace\n", i);
187 if (acl_create_entry(&acl1, &ace1) == -1) {
188 print_err("acl_create_entry");
193 /* ---------------------------------------------- */
194 printf("*** test out getting ACEs ***\n");
196 dump_acl_by_entry(acl1);
198 printf("dump empty ACL\n");
201 print_err("acl_init(0)");
203 dump_acl_by_entry(acl2);
205 printf("fill an ACL with known bogus values\n");
206 acl3 = create_filled_acl();
207 dump_acl_by_entry(acl3);
209 /* ---------------------------------------------- */