/* parameters passable via URL */
int tcp_syncnt;
+ int uid;
+ int gid;
};
struct rpc_pdu {
void rpc_unset_autoreconnect(struct rpc_context *rpc);
void rpc_set_tcp_syncnt(struct rpc_context *rpc, int v);
+void rpc_set_uid(struct rpc_context *rpc, int uid);
+void rpc_set_gid(struct rpc_context *rpc, int gid);
int rpc_add_fragment(struct rpc_context *rpc, char *data, uint64_t size);
void rpc_free_all_fragments(struct rpc_context *rpc);
struct AUTH;
EXTERN void nfs_set_auth(struct nfs_context *nfs, struct AUTH *auth);
-
/*
* When an operation failed, this function can extract a detailed error string.
*/
salt += 0x01000000;
rpc->fd = -1;
rpc->tcp_syncnt = RPC_PARAM_UNDEFINED;
+#ifdef WIN32
+ rpc->uid = 65534;
+ rpc->gid = 65534;
+#else
+ rpc->uid = getuid();
+ rpc->gid = getgid();
+#endif
return rpc;
}
rpc->auth = auth;
}
+static void rpc_set_uid_gid(struct rpc_context *rpc, int uid, int gid) {
+ if (uid != rpc->uid || gid != rpc->gid) {
+ struct AUTH *auth = libnfs_authunix_create("libnfs", uid, gid, 0, NULL);
+ if (auth != NULL) {
+ rpc_set_auth(rpc, auth);
+ rpc->uid = uid;
+ rpc->gid = gid;
+ }
+ }
+}
+
+void rpc_set_uid(struct rpc_context *rpc, int uid) {
+ rpc_set_uid_gid(rpc, uid, rpc->gid);
+}
+
+void rpc_set_gid(struct rpc_context *rpc, int gid) {
+ rpc_set_uid_gid(rpc, rpc->uid, gid);
+}
void rpc_set_error(struct rpc_context *rpc, char *error_string, ...)
{
strp2++;
if (!strncmp(strp, "tcp-syncnt", 10)) {
rpc_set_tcp_syncnt(nfs->rpc, atoi(strp2));
+ } else if (!strncmp(strp, "uid", 3)) {
+ rpc_set_uid(nfs->rpc, atoi(strp2));
+ } else if (!strncmp(strp, "gid", 3)) {
+ rpc_set_gid(nfs->rpc, atoi(strp2));
}
}
}