diff --git a/daemon/mount.c b/daemon/mount.c index 47a1e5c..89b9855 100644 --- a/daemon/mount.c +++ b/daemon/mount.c @@ -72,6 +72,8 @@ static int handle_mount(nfs41_upcall *upcall) goto out; } // add a mount + root->uid = upcall->uid; + root->gid = upcall->gid; status = nfs41_root_mount_addrs(root, &addrs, 0, 0, &client); if (status) { eprintf("nfs41_root_mount() failed with %d\n", status); diff --git a/daemon/namespace.c b/daemon/namespace.c index 414cb69..d7b7f15 100644 --- a/daemon/namespace.c +++ b/daemon/namespace.c @@ -353,7 +353,8 @@ int nfs41_root_mount_addrs( goto out; /* create an rpc client */ - status = nfs41_rpc_clnt_create(addrs, root->wsize, root->rsize, !is_data, &rpc); + status = nfs41_rpc_clnt_create(addrs, root->wsize, root->rsize, !is_data, + root->uid, root->gid, &rpc); if (status) { eprintf("nfs41_rpc_clnt_create() failed %d\n", status); goto out; diff --git a/daemon/nfs41.h b/daemon/nfs41.h index 1b628b8..c62d731 100644 --- a/daemon/nfs41.h +++ b/daemon/nfs41.h @@ -182,6 +182,8 @@ typedef struct __nfs41_root { uint32_t wsize; uint32_t rsize; LONG ref_count; + uint32_t uid; + uint32_t gid; } nfs41_root; @@ -348,6 +350,8 @@ int nfs41_rpc_clnt_create( IN uint32_t wsize, IN uint32_t rsize, IN bool_t needcb, + IN uint32_t uid, + IN uint32_t gid, OUT nfs41_rpc_clnt **rpc_out); void nfs41_rpc_clnt_free( diff --git a/daemon/nfs41_rpc.c b/daemon/nfs41_rpc.c index 24ffcab..d61e6e6 100644 --- a/daemon/nfs41_rpc.c +++ b/daemon/nfs41_rpc.c @@ -101,12 +101,16 @@ int nfs41_rpc_clnt_create( IN uint32_t wsize, IN uint32_t rsize, bool_t needcb, + IN uint32_t uid, + IN uint32_t gid, OUT nfs41_rpc_clnt **rpc_out) { CLIENT *client; nfs41_rpc_clnt *rpc; uint32_t addr_index; int status; + char machname[MAXHOSTNAMELEN + 1]; + gid_t gids[1]; rpc = calloc(1, sizeof(nfs41_rpc_clnt)); if (rpc == NULL) { @@ -127,7 +131,12 @@ int nfs41_rpc_clnt_create( goto out_free_rpc_clnt; } // XXX Pick credentials in better manner - client->cl_auth = authsys_create_default(); + if (gethostname(machname, sizeof(machname)) == -1) { + eprintf("nfs41_rpc_clnt_create: gethostname failed\n"); + goto out_free_rpc_clnt; + } + machname[sizeof(machname) - 1] = '\0'; + client->cl_auth = authsys_create(machname, uid, gid, 0, gids); if (client->cl_auth == NULL) { // XXX log failure in auth creation somewhere // XXX Better error return