diff options
Diffstat (limited to 'xlators/nfs/server/src/mount3.c')
| -rw-r--r-- | xlators/nfs/server/src/mount3.c | 72 |
1 files changed, 46 insertions, 26 deletions
diff --git a/xlators/nfs/server/src/mount3.c b/xlators/nfs/server/src/mount3.c index 726dc293af6..a34d9104c17 100644 --- a/xlators/nfs/server/src/mount3.c +++ b/xlators/nfs/server/src/mount3.c @@ -920,14 +920,11 @@ mnt3svc_volume_mount(rpcsvc_request_t *req, struct mount3_state *ms, { inode_t *exportinode = NULL; int ret = -EFAULT; - uuid_t rootgfid = { - 0, - }; + static uuid_t rootgfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; if ((!req) || (!exp) || (!ms)) return ret; - rootgfid[15] = 1; exportinode = inode_find(exp->vol->itable, rootgfid); if (!exportinode) { gf_msg(GF_MNT, GF_LOG_ERROR, ENOENT, NFS_MSG_GET_ROOT_INODE_FAIL, @@ -1372,9 +1369,7 @@ __mnt3_resolve_subdir(mnt3_resolve_t *mres) nfs_user_t nfu = { 0, }; - uuid_t rootgfid = { - 0, - }; + static uuid_t rootgfid = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; if (!mres) return ret; @@ -1385,7 +1380,6 @@ __mnt3_resolve_subdir(mnt3_resolve_t *mres) if (!firstcomp) goto err; - rootgfid[15] = 1; ret = nfs_entry_loc_fill(mres->mstate->nfsx, mres->exp->vol->itable, rootgfid, firstcomp, &mres->resolveloc, NFS_RESOLVE_CREATE, NULL); @@ -2337,7 +2331,7 @@ __build_mountlist(struct mount3_state *ms, int *count) goto free_list; } - strcat(mlist->ml_hostname, me->hostname); + strcpy(mlist->ml_hostname, me->hostname); gf_msg_debug(GF_MNT, 0, "mount entry: dir: %s, host: %s", mlist->ml_directory, mlist->ml_hostname); @@ -3205,6 +3199,12 @@ mnt3_export_parse_auth_param(struct mnt3_export *exp, char *exportpath) struct host_auth_spec *host = NULL; int ret = 0; + if (exportpath == NULL) { + gf_msg(GF_MNT, GF_LOG_ERROR, EINVAL, NFS_MSG_PARSE_HOSTSPEC_FAIL, + "Export path is NULL"); + return -1; + } + /* Using exportpath directly in strtok_r because we want * to strip off AUTH parameter from exportpath. */ token = strtok_r(exportpath, "(", &savPtr); @@ -3656,20 +3656,26 @@ out: return ret; } -rpcsvc_actor_t mnt3svc_actors[MOUNT3_PROC_COUNT] = { - {"NULL", MOUNT3_NULL, mnt3svc_null, NULL, 0, DRC_NA}, - {"MNT", MOUNT3_MNT, mnt3svc_mnt, NULL, 0, DRC_NA}, - {"DUMP", MOUNT3_DUMP, mnt3svc_dump, NULL, 0, DRC_NA}, - {"UMNT", MOUNT3_UMNT, mnt3svc_umnt, NULL, 0, DRC_NA}, - {"UMNTALL", MOUNT3_UMNTALL, mnt3svc_umntall, NULL, 0, DRC_NA}, - {"EXPORT", MOUNT3_EXPORT, mnt3svc_export, NULL, 0, DRC_NA}}; +static rpcsvc_actor_t mnt3svc_actors[MOUNT3_PROC_COUNT] = { + { + "NULL", + mnt3svc_null, + NULL, + MOUNT3_NULL, + DRC_NA, + }, + {"MNT", mnt3svc_mnt, NULL, MOUNT3_MNT, DRC_NA, 0}, + {"DUMP", mnt3svc_dump, NULL, MOUNT3_DUMP, DRC_NA, 0}, + {"UMNT", mnt3svc_umnt, NULL, MOUNT3_UMNT, DRC_NA, 0}, + {"UMNTALL", mnt3svc_umntall, NULL, MOUNT3_UMNTALL, DRC_NA, 0}, + {"EXPORT", mnt3svc_export, NULL, MOUNT3_EXPORT, DRC_NA, 0}}; /* Static init parts are assigned here, dynamic ones are done in * mnt3svc_init and mnt3_init_state. * Making MOUNT3 a synctask so that the blocking DNS calls during rpc auth * gets offloaded to syncenv, keeping the main/poll thread unblocked */ -rpcsvc_program_t mnt3prog = { +static rpcsvc_program_t mnt3prog = { .progname = "MOUNT3", .prognum = MOUNT_PROGRAM, .progver = MOUNT_V3, @@ -4056,6 +4062,11 @@ mnt3svc_init(xlator_t *nfsx) mnt3prog.private = mstate; options = dict_new(); + if (options == NULL) { + gf_msg(GF_NFS, GF_LOG_ERROR, ENOMEM, NFS_MSG_GFID_DICT_CREATE_FAIL, + "dict allocation failed"); + goto err; + } ret = gf_asprintf(&portstr, "%d", GF_MOUNTV3_PORT); if (ret == -1) @@ -4091,7 +4102,6 @@ mnt3svc_init(xlator_t *nfsx) if (ret == -1) { gf_msg(GF_NFS, GF_LOG_ERROR, errno, NFS_MSG_LISTENERS_CREATE_FAIL, "Unable to create listeners"); - dict_unref(options); goto err; } @@ -4102,20 +4112,25 @@ mnt3svc_init(xlator_t *nfsx) gf_msg_debug(GF_MNT, GF_LOG_DEBUG, "Thread creation failed"); } } + if (options) + dict_unref(options); + return &mnt3prog; err: + if (options) + dict_unref(options); return NULL; } -rpcsvc_actor_t mnt1svc_actors[MOUNT1_PROC_COUNT] = { - {"NULL", MOUNT1_NULL, mnt3svc_null, NULL, 0, DRC_NA}, - {"MNT", MOUNT1_MNT, NULL, NULL, 0, DRC_NA}, - {"DUMP", MOUNT1_DUMP, mnt3svc_dump, NULL, 0, DRC_NA}, - {"UMNT", MOUNT1_UMNT, mnt3svc_umnt, NULL, 0, DRC_NA}, - {"UMNTALL", MOUNT1_UMNTALL, NULL, NULL, 0, DRC_NA}, - {"EXPORT", MOUNT1_EXPORT, mnt3svc_export, NULL, 0, DRC_NA}}; +static rpcsvc_actor_t mnt1svc_actors[MOUNT1_PROC_COUNT] = { + {"NULL", mnt3svc_null, NULL, MOUNT1_NULL, DRC_NA, 0}, + {"MNT", NULL, NULL, MOUNT1_MNT, DRC_NA, 0}, + {"DUMP", mnt3svc_dump, NULL, MOUNT1_DUMP, DRC_NA, 0}, + {"UMNT", mnt3svc_umnt, NULL, MOUNT1_UMNT, DRC_NA, 0}, + {"UMNTALL", NULL, NULL, MOUNT1_UMNTALL, DRC_NA, 0}, + {"EXPORT", mnt3svc_export, NULL, MOUNT1_EXPORT, DRC_NA, 0}}; -rpcsvc_program_t mnt1prog = { +static rpcsvc_program_t mnt1prog = { .progname = "MOUNT1", .prognum = MOUNT_PROGRAM, .progver = MOUNT_V1, @@ -4151,6 +4166,11 @@ mnt1svc_init(xlator_t *nfsx) mnt1prog.private = mstate; options = dict_new(); + if (options == NULL) { + gf_msg(GF_NFS, GF_LOG_ERROR, ENOMEM, NFS_MSG_GFID_DICT_CREATE_FAIL, + "dict allocation failed"); + goto err; + } ret = gf_asprintf(&portstr, "%d", GF_MOUNTV1_PORT); if (ret == -1) |
