2 * Copyright (c) 2001-2002 International Business Machines Corp.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
9 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
10 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
11 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
12 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
13 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
14 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
15 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
16 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
17 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
18 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
19 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22 #include <afs/param.h>
26 #include "org_openafs_jafs_ACL.h"
29 #include <sys/ioctl.h>
31 #include <afs/venus.h>
32 #include <afs/afs_args.h>
35 #include <afs/afs_osi.h>
38 /* just for debugging */
43 #define MAXINSIZE 1300 /* pioctl complains if data is larger than this */
44 #define VMSGSIZE 128 /* size of msg buf in volume hdr */
46 static char space[MAXSIZE];
57 * Returns a formatted string representing the ACL for the specified path.
59 * path the directory path
60 * returns NULL if an exception is encountered.
65 struct ViceIoctl params;
73 buffer = (char *)malloc(ACL_LEN);
76 fprintf(stderr, "ERROR: ACL::getACL -> could not allocate buffer\n");
81 params.out_size = ACL_LEN;
83 if (call_syscall(AFSCALL_PIOCTL, path, VIOCGETAL, ¶ms, 1, 0)) {
84 fprintf(stderr, "ERROR: ACL::getACL -> VIOCGETAL failed: %d\n",
94 * Sets the ACL for the specified path using the provided string
97 * path the directory path
98 * aclString string representation of ACL to be set
99 * returns TRUE if the operation succeeds; otherwise FALSE;
102 setACL(char *path, char *aclString)
104 struct ViceIoctl params;
105 char *redirect, *parentURI, *cptr;
107 params.in = aclString;
108 params.in_size = strlen(aclString) + 1;
112 if (call_syscall(AFSCALL_PIOCTL, path, VIOCGETAL, ¶ms, 1)) {
113 fprintf(stderr, "ERROR: ACL::setACL -> VIOCSETAL failed: %d\n",
122 * Returns a formatted string representing the ACL for the specified path.
124 * The string format is in the form of a ViceIoctl and is as follows:
125 * printf("%d\n%d\n", positiveEntriesCount, negativeEntriesCount);
126 * printf("%s\t%d\n", userOrGroupName, rightsMask);
128 * path the directory path
129 * returns NULL if an exception is encountered.
131 JNIEXPORT jstring JNICALL
132 Java_org_openafs_jafs_ACL_getACLString(JNIEnv * env, jobject obj,
136 jstring answer = NULL;
138 path = getNativeString(env, pathUTF);
140 fprintf(stderr, "ERROR: ACL::getACLString ->");
141 fprintf(stderr, "path = NULL\n");
142 throwAFSException(env, JAFSNULLPATH);
150 answer = (*env)->NewStringUTF(env, acl);
153 throwAFSException(env, errno);
160 * Sets the ACL for the specified path using the provided string
163 * The string format is in the form of a ViceIoctl and is as follows:
164 * printf("%d\n%d\n", positiveEntriesCount, negativeEntriesCount);
165 * printf("%s\t%d\n", userOrGroupName, rightsMask);
167 * path the directory path
168 * aclString string representation of ACL to be set
169 * throws an afsAdminExceptionName if an internal exception is encountered.
171 JNIEXPORT void JNICALL
172 Java_org_openafs_jafs_ACL_setACLString(JNIEnv * env, jobject obj,
173 jstring pathUTF, jstring aclStringUTF)
175 char *path, *aclString;
177 if (pathUTF == NULL) {
178 fprintf(stderr, "ERROR: ACL::setACLString -> pathUTF == NULL\n");
179 throwAFSException(env, JAFSNULLPATH);
183 if (aclStringUTF == NULL) {
184 fprintf(stderr, "ERROR: ACL::setACLString -> aclStringUTF == NULL\n");
185 throwAFSException(env, JAFSNULLACL);
189 /* path = (char*) (*env)->GetStringUTFChars(env, pathUTF, 0); */
190 path = getNativeString(env, pathUTF);
192 fprintf(stderr, "ERROR: ACL::setACLString -> failed to get path\n");
193 throwMessageException(env, "Failed to get path.");
197 /* aclString = (char*) (*env)->GetStringUTFChars(env, aclStringUTF, 0); */
198 aclString = getNativeString(env, aclStringUTF);
199 if (aclString == NULL) {
202 "ERROR: ACL::setACLString -> failed to get aclString\n");
203 throwMessageException(env, "Failed to get ACL string.");
207 if (!setACL(path, aclString)) {
208 throwAFSException(env, errno);
216 * (*env)->ReleaseStringUTFChars(env, pathUTF, path);
217 * (*env)->ReleaseStringUTFChars(env, aclStringUTF, aclString);