repositories
/
deb_libnfs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix implicit decls of rpc_{g,s}et_error
[deb_libnfs.git]
/
lib
/
libnfs-zdr.c
diff --git
a/lib/libnfs-zdr.c
b/lib/libnfs-zdr.c
index a243d1d1a7447b5a4ffc5169d60df6128ca7beb4..90abe26d0f26e8184b452cb29703b67acd8799f0 100644
(file)
--- a/
lib/libnfs-zdr.c
+++ b/
lib/libnfs-zdr.c
@@
-20,16
+20,30
@@
* i.e. zdrmem_create() buffers.
* It aims to be compatible with normal rpcgen generated functions.
*/
* i.e. zdrmem_create() buffers.
* It aims to be compatible with normal rpcgen generated functions.
*/
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
#ifdef WIN32
#include "win32_compat.h"
#ifdef WIN32
#include "win32_compat.h"
-#else
+#endif
+
+#ifdef AROS
+#include "aros_compat.h"
+#endif
+
+#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#include <arpa/inet.h>
-#endif
/*WIN32*/
+#endif
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
+#include <unistd.h>
#include "libnfs-zdr.h"
#include "libnfs-zdr.h"
+#include "libnfs.h"
+#include "libnfs-raw.h"
+#include "libnfs-private.h"
struct opaque_auth _null_auth;
struct opaque_auth _null_auth;
@@
-122,7
+136,7
@@
bool_t libnfs_zdr_u_quad_t(ZDR *zdrs, uint64_t *u)
*u = ntohl(*(uint32_t *)&zdrs->buf[zdrs->pos]);
zdrs->pos += 4;
*u <<= 32;
*u = ntohl(*(uint32_t *)&zdrs->buf[zdrs->pos]);
zdrs->pos += 4;
*u <<= 32;
- *u |= ntohl(*(uint32_t *)&zdrs->buf[zdrs->pos]);
+ *u |=
(uint32_t)
ntohl(*(uint32_t *)&zdrs->buf[zdrs->pos]);
zdrs->pos += 4;
return TRUE;
break;
zdrs->pos += 4;
return TRUE;
break;
@@
-217,6
+231,9
@@
bool_t libnfs_zdr_opaque(ZDR *zdrs, char *objp, uint32_t size)
case ZDR_ENCODE:
memcpy(&zdrs->buf[zdrs->pos], objp, size);
zdrs->pos += size;
case ZDR_ENCODE:
memcpy(&zdrs->buf[zdrs->pos], objp, size);
zdrs->pos += size;
+ if (zdrs->pos & 3) {
+ memset(&zdrs->buf[zdrs->pos], 0x00, 4 - (zdrs->pos & 3));
+ }
zdrs->pos = (zdrs->pos + 3) & ~3;
return TRUE;
case ZDR_DECODE:
zdrs->pos = (zdrs->pos + 3) & ~3;
return TRUE;
case ZDR_DECODE:
@@
-305,29
+322,41
@@
static bool_t libnfs_opaque_auth(ZDR *zdrs, struct opaque_auth *auth)
return TRUE;
}
return TRUE;
}
-static bool_t libnfs_rpc_call_body(ZDR *zdrs, struct call_body *cmb)
+static bool_t libnfs_rpc_call_body(
struct rpc_context *rpc,
ZDR *zdrs, struct call_body *cmb)
{
if (!libnfs_zdr_u_int(zdrs, &cmb->rpcvers)) {
{
if (!libnfs_zdr_u_int(zdrs, &cmb->rpcvers)) {
+ rpc_set_error(rpc, "libnfs_rpc_call_body failed to encode "
+ "RPCVERS");
return FALSE;
}
if (!libnfs_zdr_u_int(zdrs, &cmb->prog)) {
return FALSE;
}
if (!libnfs_zdr_u_int(zdrs, &cmb->prog)) {
+ rpc_set_error(rpc, "libnfs_rpc_call_body failed to encode "
+ "PROG");
return FALSE;
}
if (!libnfs_zdr_u_int(zdrs, &cmb->vers)) {
return FALSE;
}
if (!libnfs_zdr_u_int(zdrs, &cmb->vers)) {
+ rpc_set_error(rpc, "libnfs_rpc_call_body failed to encode "
+ "VERS");
return FALSE;
}
if (!libnfs_zdr_u_int(zdrs, &cmb->proc)) {
return FALSE;
}
if (!libnfs_zdr_u_int(zdrs, &cmb->proc)) {
+ rpc_set_error(rpc, "libnfs_rpc_call_body failed to encode "
+ "PROC");
return FALSE;
}
if (!libnfs_opaque_auth(zdrs, &cmb->cred)) {
return FALSE;
}
if (!libnfs_opaque_auth(zdrs, &cmb->cred)) {
+ rpc_set_error(rpc, "libnfs_rpc_call_body failed to encode "
+ "CRED");
return FALSE;
}
if (!libnfs_opaque_auth(zdrs, &cmb->verf)) {
return FALSE;
}
if (!libnfs_opaque_auth(zdrs, &cmb->verf)) {
+ rpc_set_error(rpc, "libnfs_rpc_call_body failed to encode "
+ "VERF");
return FALSE;
}
return FALSE;
}
@@
-392,58
+421,80
@@
static bool_t libnfs_rejected_reply(ZDR *zdrs, struct rejected_reply *rr)
return FALSE;
}
return FALSE;
}
-static bool_t libnfs_rpc_reply_body(ZDR *zdrs, struct reply_body *rmb)
+static bool_t libnfs_rpc_reply_body(
struct rpc_context *rpc,
ZDR *zdrs, struct reply_body *rmb)
{
if (!libnfs_zdr_u_int(zdrs, &rmb->stat)) {
{
if (!libnfs_zdr_u_int(zdrs, &rmb->stat)) {
+ rpc_set_error(rpc, "libnfs_rpc_reply_body failed to decode "
+ "STAT");
return FALSE;
}
switch (rmb->stat) {
case MSG_ACCEPTED:
if (!libnfs_accepted_reply(zdrs, &rmb->reply.areply)) {
return FALSE;
}
switch (rmb->stat) {
case MSG_ACCEPTED:
if (!libnfs_accepted_reply(zdrs, &rmb->reply.areply)) {
+ rpc_set_error(rpc, "libnfs_rpc_reply_body failed to "
+ "decode ACCEPTED");
return FALSE;
}
return TRUE;
case MSG_DENIED:
if (!libnfs_rejected_reply(zdrs, &rmb->reply.rreply)) {
return FALSE;
}
return TRUE;
case MSG_DENIED:
if (!libnfs_rejected_reply(zdrs, &rmb->reply.rreply)) {
+ rpc_set_error(rpc, "libnfs_rpc_reply_body failed to "
+ "decode DENIED");
return FALSE;
}
return TRUE;
}
return FALSE;
}
return TRUE;
}
+ rpc_set_error(rpc, "libnfs_rpc_reply_body failed to "
+ "decode. Neither ACCEPTED nor DENIED");
return FALSE;
}
return FALSE;
}
-static bool_t libnfs_rpc_msg(ZDR *zdrs, struct rpc_msg *msg)
+static bool_t libnfs_rpc_msg(
struct rpc_context *rpc,
ZDR *zdrs, struct rpc_msg *msg)
{
{
+ int ret;
+
if (!libnfs_zdr_u_int(zdrs, &msg->xid)) {
if (!libnfs_zdr_u_int(zdrs, &msg->xid)) {
+ rpc_set_error(rpc, "libnfs_rpc_msg failed to decode XID");
return FALSE;
}
if (!libnfs_zdr_u_int(zdrs, &msg->direction)) {
return FALSE;
}
if (!libnfs_zdr_u_int(zdrs, &msg->direction)) {
+ rpc_set_error(rpc, "libnfs_rpc_msg failed to decode DIRECTION");
return FALSE;
}
switch (msg->direction) {
case CALL:
return FALSE;
}
switch (msg->direction) {
case CALL:
- return libnfs_rpc_call_body(zdrs, &msg->body.cbody);
- break;
+ ret = libnfs_rpc_call_body(rpc, zdrs, &msg->body.cbody);
+ if (!ret) {
+ rpc_set_error(rpc, "libnfs_rpc_msg failed to encode "
+ "CALL, ret=%d: %s", ret, rpc_get_error(rpc));
+ }
+ return ret;
case REPLY:
case REPLY:
- return libnfs_rpc_reply_body(zdrs, &msg->body.rbody);
- break;
+ ret = libnfs_rpc_reply_body(rpc, zdrs, &msg->body.rbody);
+ if (!ret) {
+ rpc_set_error(rpc, "libnfs_rpc_msg failed to decode "
+ "REPLY, ret=%d: %s", ret, rpc_get_error(rpc));
+ }
+ return ret;
default:
default:
+ rpc_set_error(rpc, "libnfs_rpc_msg failed to decode. "
+ "Neither CALL not REPLY");
return FALSE;
}
}
return FALSE;
}
}
-bool_t libnfs_zdr_callmsg(ZDR *zdrs, struct rpc_msg *msg)
+bool_t libnfs_zdr_callmsg(
struct rpc_context *rpc,
ZDR *zdrs, struct rpc_msg *msg)
{
{
- return libnfs_rpc_msg(zdrs, msg);
+ return libnfs_rpc_msg(
rpc,
zdrs, msg);
}
}
-bool_t libnfs_zdr_replymsg(ZDR *zdrs, struct rpc_msg *msg)
+bool_t libnfs_zdr_replymsg(
struct rpc_context *rpc,
ZDR *zdrs, struct rpc_msg *msg)
{
{
- return libnfs_rpc_msg(zdrs, msg);
+ return libnfs_rpc_msg(
rpc,
zdrs, msg);
}
struct AUTH *authnone_create(void)
}
struct AUTH *authnone_create(void)
@@
-474,10
+525,12
@@
struct AUTH *libnfs_authunix_create(char *host, uint32_t uid, uint32_t gid, uint
size = 4 + 4 + ((strlen(host) + 3) & ~3) + 4 + 4 + 4 + len * 4;
auth = malloc(sizeof(struct AUTH));
size = 4 + 4 + ((strlen(host) + 3) & ~3) + 4 + 4 + 4 + len * 4;
auth = malloc(sizeof(struct AUTH));
+ memset(auth, 0x00, sizeof(struct AUTH));
auth->ah_cred.oa_flavor = AUTH_UNIX;
auth->ah_cred.oa_length = size;
auth->ah_cred.oa_base = malloc(size);
auth->ah_cred.oa_flavor = AUTH_UNIX;
auth->ah_cred.oa_length = size;
auth->ah_cred.oa_base = malloc(size);
+ memset(auth->ah_cred.oa_base, 0x00, size);
buf = (uint32_t *)auth->ah_cred.oa_base;
idx = 0;
buf[idx++] = htonl(time(NULL));
buf = (uint32_t *)auth->ah_cred.oa_base;
idx = 0;
buf[idx++] = htonl(time(NULL));
@@
-503,7
+556,11
@@
struct AUTH *libnfs_authunix_create(char *host, uint32_t uid, uint32_t gid, uint
struct AUTH *libnfs_authunix_create_default(void)
{
struct AUTH *libnfs_authunix_create_default(void)
{
- return libnfs_authunix_create("libnfs", getuid(), -1, 0, NULL);
+#ifdef WIN32
+ return libnfs_authunix_create("libnfs", 65534, 65534, 0, NULL);
+#else
+ return libnfs_authunix_create("libnfs", getuid(), getgid(), 0, NULL);
+#endif
}
void libnfs_auth_destroy(struct AUTH *auth)
}
void libnfs_auth_destroy(struct AUTH *auth)