2 * Copyright (c) 1995 - 2001 Kungliga Tekniska Högskolan
3 * (Royal Institute of Technology, Stockholm, Sweden).
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the Institute nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 skipline(char **curptr
)
41 while(**curptr
!='\n') (*curptr
)++;
46 afs_getacl(char *path
)
49 struct ViceIoctl a_params
;
50 struct AclEntry
*pos
=NULL
;
51 struct AclEntry
*neg
=NULL
;
53 char tmpname
[MAXNAME
];
57 oldacl
=(struct Acl
*) malloc(sizeof(struct Acl
));
59 printf("fs: Out of memory\n");
64 a_params
.out_size
=MAXSIZE
;
66 a_params
.out
=malloc(MAXSIZE
);
68 if(a_params
.out
== NULL
) {
69 printf ("fs: Out of memory\n");
74 if(k_pioctl(path
,ARLA_VIOCGETAL
,&a_params
,1)==-1) {
75 fserr(PROGNAME
, errno
, path
);
83 /* Number of pos/neg entries parsing */
84 sscanf(curptr
, "%d\n%d\n", &oldacl
->NumPositiveEntries
,
85 &oldacl
->NumNegativeEntries
);
89 if(oldacl
->NumPositiveEntries
)
90 for(i
=0; i
<oldacl
->NumPositiveEntries
; i
++) {
91 sscanf(curptr
, "%99s %d", tmpname
, &tmprights
);
94 pos
=malloc(sizeof(struct AclEntry
));
98 pos
->next
=malloc(sizeof(struct AclEntry
));
101 pos
->RightsMask
=tmprights
;
102 strlcpy(pos
->name
, tmpname
, sizeof(pos
->name
));
106 if(oldacl
->NumNegativeEntries
)
107 for(i
=0; i
<oldacl
->NumNegativeEntries
; i
++) {
108 sscanf(curptr
, "%99s %d", tmpname
, &tmprights
);
111 neg
=malloc(sizeof(struct AclEntry
));
115 neg
->next
=malloc(sizeof(struct AclEntry
));
118 neg
->RightsMask
=tmprights
;
119 strlcpy(neg
->name
, tmpname
, sizeof(neg
->name
));
128 afs_listacl(char *path
)
131 struct AclEntry
*position
;
134 acl
= afs_getacl(path
);
142 printf("Access list for %s is\n", path
);
143 if(acl
->NumPositiveEntries
) {
144 printf("Normal rights:\n");
147 for(i
=0;i
<acl
->NumPositiveEntries
;i
++) {
148 printf(" %s ", position
->name
);
149 if(position
->RightsMask
&PRSFS_READ
)
151 if(position
->RightsMask
&PRSFS_LOOKUP
)
153 if(position
->RightsMask
&PRSFS_INSERT
)
155 if(position
->RightsMask
&PRSFS_DELETE
)
157 if(position
->RightsMask
&PRSFS_WRITE
)
159 if(position
->RightsMask
&PRSFS_LOCK
)
161 if(position
->RightsMask
&PRSFS_ADMINISTER
)
164 position
=position
->next
;
167 if(acl
->NumNegativeEntries
) {
168 printf("Negative rights:\n");
171 for(i
=0;i
<acl
->NumNegativeEntries
;i
++) {
172 printf(" %s ", position
->name
);
173 if(position
->RightsMask
&PRSFS_READ
)
175 if(position
->RightsMask
&PRSFS_LOOKUP
)
177 if(position
->RightsMask
&PRSFS_INSERT
)
179 if(position
->RightsMask
&PRSFS_DELETE
)
181 if(position
->RightsMask
&PRSFS_WRITE
)
183 if(position
->RightsMask
&PRSFS_LOCK
)
185 if(position
->RightsMask
&PRSFS_ADMINISTER
)
188 position
=position
->next
;
194 listacl_cmd (int argc
, char **argv
)
204 for(i
=0;i
<argc
;i
++) {
207 afs_listacl(argv
[i
]);