void acl_null_cb(struct rpc_context *rpc _U_, int status, void *data, void *private_data)
{
struct client *client = private_data;
+ GETACL3args args;
printf("Got NFSACL/NULL reply\n");
printf("Get ACL for root handle\n");
- if (rpc_nfsacl_getacl_async(rpc, acl_getacl_cb, &client->rootfh, NFSACL_MASK_ACL_ENTRY|NFSACL_MASK_ACL_COUNT|NFSACL_MASK_ACL_DEFAULT_ENTRY|NFSACL_MASK_ACL_DEFAULT_COUNT, client) != 0) {
+ args.dir = client->rootfh;
+ args.mask = NFSACL_MASK_ACL_ENTRY|NFSACL_MASK_ACL_COUNT|NFSACL_MASK_ACL_DEFAULT_ENTRY|NFSACL_MASK_ACL_DEFAULT_COUNT;
+ if (rpc_nfsacl_getacl_async(rpc, acl_getacl_cb, &args, client) != 0) {
printf("Failed to send getacl request\n");
exit(10);
}
void rpc_set_error(struct rpc_context *rpc, char *error_string, ...);
void nfs_set_error(struct nfs_context *nfs, char *error_string, ...);
-struct rpc_context *nfs_get_rpc_context(struct nfs_context *nfs);
const char *nfs_get_server(struct nfs_context *nfs);
const char *nfs_get_export(struct nfs_context *nfs);
char *rpc_get_error(struct rpc_context *rpc);
int rpc_queue_length(struct rpc_context *rpc);
+/* Utility function to get an RPC context from a NFS context. Useful for doing low level NFSACL
+ * calls on a NFS context.
+ */
+struct rpc_context *nfs_get_rpc_context(struct nfs_context *nfs);
+
+/* This function returns the nfs_fh3 structure from a nfsfh structure.
+ This allows to use a file onened with nfs_open() together with low-level
+ rpc functions that thake a nfs filehandle
+*/
+struct nfs_fh3 *nfs_get_fh(struct nfsfh *nfsfh);
#define RPC_STATUS_SUCCESS 0
#define RPC_STATUS_ERROR 1
* <0 : An error occured when trying to set up the call. The callback will not be invoked.
*
* When the callback is invoked, status indicates the result:
- * RPC_STATUS_SUCCESS : We got a successful response from the rquota daemon.
+ * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
* data is a GETACL3res pointer
- * RPC_STATUS_ERROR : An error occured when trying to contact the rquota daemon.
+ * RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
* data is the error string.
* RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
* data is NULL.
*/
-int rpc_nfsacl_getacl_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, uint32_t mask, void *private_data);
+struct GETACL3args;
+int rpc_nfsacl_getacl_async(struct rpc_context *rpc, rpc_cb cb, struct GETACL3args *args, void *private_data);
+
+
+/*
+ * Call NFSACL/SETACL
+ *
+ * Function returns
+ * 0 : The call was initiated. The callback will be invoked when the call completes.
+ * <0 : An error occured when trying to set up the call. The callback will not be invoked.
+ *
+ * When the callback is invoked, status indicates the result:
+ * RPC_STATUS_SUCCESS : We got a successful response from the nfs daemon.
+ * data is a SETACL3res pointer
+ * RPC_STATUS_ERROR : An error occured when trying to contact the nfs daemon.
+ * data is the error string.
+ * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
+ * data is NULL.
+ */
+struct SETACL3args;
+int rpc_nfsacl_setacl_async(struct rpc_context *rpc, rpc_cb cb, struct SETACL3args *args, void *private_data);
const struct nfs_fh3 *nfs_get_rootfh(struct nfs_context *nfs) {
return &nfs->rootfh;
}
+
+struct nfs_fh3 *nfs_get_fh(struct nfsfh *nfsfh) {
+ return &nfsfh->fh;
+}
void;
};
+struct SETACL3args {
+ nfs_fh3 dir;
+ uint32_t mask;
+ uint32_t ace_count;
+ struct nfsacl_ace ace<>;
+ uint32_t default_ace_count;
+ struct nfsacl_ace default_ace<>;
+};
+
+struct SETACL3resok {
+ post_op_attr attr;
+};
+
+union SETACL3res switch (nfsstat3 status) {
+case NFS3_OK:
+ SETACL3resok resok;
+default:
+ void;
+};
+
program NFSACL_PROGRAM {
version NFSACL_V3 {
void
GETACL3res
NFSACL3_GETACL(GETACL3args) = 1;
+
+ SETACL3res
+ NFSACL3_SETACL(SETACL3args) = 2;
} = 3;
} = 100227;
}
-int rpc_nfsacl_getacl_async(struct rpc_context *rpc, rpc_cb cb, struct nfs_fh3 *fh, uint32_t mask, void *private_data)
+int rpc_nfsacl_getacl_async(struct rpc_context *rpc, rpc_cb cb, struct GETACL3args *args, void *private_data)
{
struct rpc_pdu *pdu;
- GETACL3args args;
pdu = rpc_allocate_pdu(rpc, NFSACL_PROGRAM, NFSACL_V3, NFSACL3_GETACL, cb, private_data, (xdrproc_t)xdr_GETACL3res, sizeof(GETACL3res));
if (pdu == NULL) {
return -1;
}
- args.dir.data.data_len = fh->data.data_len;
- args.dir.data.data_val = fh->data.data_val;
- args.mask = mask;
-
- if (xdr_GETACL3args(&pdu->xdr, &args) == 0) {
+ if (xdr_GETACL3args(&pdu->xdr, args) == 0) {
rpc_set_error(rpc, "XDR error: Failed to encode GETACL3args");
rpc_free_pdu(rpc, pdu);
return -2;
return 0;
}
+
+int rpc_nfsacl_setacl_async(struct rpc_context *rpc, rpc_cb cb, struct SETACL3args *args, void *private_data)
+{
+ struct rpc_pdu *pdu;
+
+ pdu = rpc_allocate_pdu(rpc, NFSACL_PROGRAM, NFSACL_V3, NFSACL3_SETACL, cb, private_data, (xdrproc_t)xdr_SETACL3res, sizeof(SETACL3res));
+ if (pdu == NULL) {
+ rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nfsacl/setacl call");
+ return -1;
+ }
+
+ if (xdr_SETACL3args(&pdu->xdr, args) == 0) {
+ rpc_set_error(rpc, "XDR error: Failed to encode SETACL3args");
+ rpc_free_pdu(rpc, pdu);
+ return -2;
+ }
+
+ if (rpc_queue_pdu(rpc, pdu) != 0) {
+ rpc_set_error(rpc, "Out of memory. Failed to queue pdu for nfsacl/setacl call");
+ rpc_free_pdu(rpc, pdu);
+ return -2;
+ }
+
+ return 0;
+}