summaryrefslogtreecommitdiff
path: root/usr/src/lib/libshare
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/lib/libshare')
-rw-r--r--usr/src/lib/libshare/common/libshare.c14
-rw-r--r--usr/src/lib/libshare/common/libshare_zfs.c1
-rw-r--r--usr/src/lib/libshare/common/libsharecore.c11
-rw-r--r--usr/src/lib/libshare/common/scfutil.c25
-rw-r--r--usr/src/lib/libshare/nfs/libshare_nfs.c6
-rw-r--r--usr/src/lib/libshare/smb/libshare_smb.c10
6 files changed, 48 insertions, 19 deletions
diff --git a/usr/src/lib/libshare/common/libshare.c b/usr/src/lib/libshare/common/libshare.c
index 6af47e38c6..d8989a70ce 100644
--- a/usr/src/lib/libshare/common/libshare.c
+++ b/usr/src/lib/libshare/common/libshare.c
@@ -727,11 +727,13 @@ sa_optionset_name(sa_optionset_t optionset, char *oname, size_t len, char *id)
} else {
char *index;
index = get_node_attr((void *)parent, "id");
- if (index != NULL)
+ if (index != NULL) {
len = snprintf(oname, len, "%s_%s_%s", id,
proto ? proto : "default", index);
- else
+ sa_free_attr_string(index);
+ } else {
len = 0;
+ }
}
if (proto != NULL)
@@ -1387,7 +1389,6 @@ mark_excluded_protos(sa_group_t group, xmlNodePtr share, uint64_t flags)
if (value == NULL)
continue;
features = sa_proto_get_featureset(value);
- sa_free_attr_string(value);
if (!(features & flags)) {
(void) strlcat(exclude_list, sep,
sizeof (exclude_list));
@@ -1395,6 +1396,7 @@ mark_excluded_protos(sa_group_t group, xmlNodePtr share, uint64_t flags)
sizeof (exclude_list));
sep = ",";
}
+ sa_free_attr_string(value);
}
if (exclude_list[0] != '\0')
(void) xmlSetProp(share, (xmlChar *)"exclude",
@@ -2043,7 +2045,7 @@ get_node_attr(void *nodehdl, char *tag)
}
/*
- * get_node_attr(node, tag)
+ * set_node_attr(node, tag)
*
* Set the specified tag(attribute) to the specified value This is
* used internally by a number of attribute oriented functions. It
@@ -2897,6 +2899,8 @@ sa_create_security(sa_group_t group, char *sectype, char *proto)
}
}
}
+ if (id != NULL)
+ sa_free_attr_string(id);
if (groupname != NULL)
sa_free_attr_string(groupname);
return (security);
@@ -3109,6 +3113,8 @@ sa_set_prop_by_prop(sa_optionset_t optionset, sa_group_t group,
(void) sa_security_name(optionset,
oname, sizeof (oname), id);
ret = sa_start_transaction(scf_handle, oname);
+ if (id != NULL)
+ sa_free_attr_string(id);
}
if (ret == SA_OK) {
switch (type) {
diff --git a/usr/src/lib/libshare/common/libshare_zfs.c b/usr/src/lib/libshare/common/libshare_zfs.c
index 7e461ba3b7..5adef70b4c 100644
--- a/usr/src/lib/libshare/common/libshare_zfs.c
+++ b/usr/src/lib/libshare/common/libshare_zfs.c
@@ -990,6 +990,7 @@ add_resources(sa_share_t share, char *opt)
newopt = calloc(1, size);
if (newopt != NULL)
(void) snprintf(newopt, size, "%s,name=%s", opt, name);
+ sa_free_attr_string(name);
free(opt);
opt = newopt;
propstr = sa_proto_legacy_format("smb", resource, 0);
diff --git a/usr/src/lib/libshare/common/libsharecore.c b/usr/src/lib/libshare/common/libsharecore.c
index 72d3420e1c..18e5f3c793 100644
--- a/usr/src/lib/libshare/common/libsharecore.c
+++ b/usr/src/lib/libshare/common/libsharecore.c
@@ -410,7 +410,7 @@ adddfsentry(xfs_sharelist_t *list, sa_share_t share, char *proto)
if (item != NULL) {
parent = sa_get_parent_group(share);
groupname = sa_get_group_attr(parent, "name");
- if (strcmp(groupname, "default") == 0) {
+ if (groupname != NULL && strcmp(groupname, "default") == 0) {
sa_free_attr_string(groupname);
groupname = NULL;
}
@@ -691,11 +691,15 @@ sa_update_legacy(sa_share_t share, char *proto)
* set or the type is not "transient".
*/
if (persist == NULL || strcmp(persist, "transient") != 0) {
+ path = sa_get_share_attr(share, "path");
+ if (path == NULL) {
+ ret = SA_NO_MEMORY;
+ goto out;
+ }
dfstab = open_dfstab(SA_LEGACY_DFSTAB);
if (dfstab != NULL) {
(void) setvbuf(dfstab, NULL, _IOLBF, BUFSIZ * 8);
sablocksigs(&old);
- path = sa_get_share_attr(share, "path");
(void) lockf(fileno(dfstab), F_LOCK, 0);
list = getdfstab(dfstab);
rewind(dfstab);
@@ -708,7 +712,6 @@ sa_update_legacy(sa_share_t share, char *proto)
(void) fsync(fileno(dfstab));
saunblocksigs(&old);
(void) fclose(dfstab);
- sa_free_attr_string(path);
if (list != NULL)
dfs_free_list(list);
} else {
@@ -717,7 +720,9 @@ sa_update_legacy(sa_share_t share, char *proto)
else
ret = SA_CONFIG_ERR;
}
+ sa_free_attr_string(path);
}
+out:
if (persist != NULL)
sa_free_attr_string(persist);
return (ret);
diff --git a/usr/src/lib/libshare/common/scfutil.c b/usr/src/lib/libshare/common/scfutil.c
index f5fabad540..21395d0731 100644
--- a/usr/src/lib/libshare/common/scfutil.c
+++ b/usr/src/lib/libshare/common/scfutil.c
@@ -20,12 +20,10 @@
*/
/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/* helper functions for using libscf with sharemgr */
#include <libscf.h>
@@ -1585,7 +1583,7 @@ sa_set_resource_property(scfutilhandle_t *handle, sa_share_t share)
valstr ? valstr : "");
else
(void) snprintf(propstr, strsize, "%s:%s:%s",
- idstr ? idstr : "", valstr ? valstr : "",
+ idstr, valstr ? valstr : "",
description ? description : "");
if (scf_value_set_astring(value, propstr) != 0) {
ret = SA_SYSTEM_ERR;
@@ -1604,16 +1602,29 @@ sa_set_resource_property(scfutilhandle_t *handle, sa_share_t share)
free(propstr);
}
err:
- if (valstr != NULL)
+ if (valstr != NULL) {
sa_free_attr_string(valstr);
- if (idstr != NULL)
+ valstr = NULL;
+ }
+ if (idstr != NULL) {
sa_free_attr_string(idstr);
- if (description != NULL)
+ idstr = NULL;
+ }
+ if (description != NULL) {
sa_free_share_description(description);
+ description = NULL;
+ }
}
/* the entry is in the transaction */
entry = NULL;
+ if (valstr != NULL)
+ sa_free_attr_string(valstr);
+ if (idstr != NULL)
+ sa_free_attr_string(idstr);
+ if (description != NULL)
+ sa_free_share_description(description);
+
if (ret == SA_SYSTEM_ERR) {
switch (scf_error()) {
case SCF_ERROR_PERMISSION_DENIED:
diff --git a/usr/src/lib/libshare/nfs/libshare_nfs.c b/usr/src/lib/libshare/nfs/libshare_nfs.c
index b71df49804..8007ab2466 100644
--- a/usr/src/lib/libshare/nfs/libshare_nfs.c
+++ b/usr/src/lib/libshare/nfs/libshare_nfs.c
@@ -1014,7 +1014,8 @@ fill_export_from_optionset(struct exportdata *export, sa_optionset_t optionset)
/* have a syntactic error */
(void) printf(dgettext(TEXT_DOMAIN,
"NFS: unrecognized option %s=%s\n"),
- name, value != NULL ? value : "");
+ name != NULL ? name : "",
+ value != NULL ? value : "");
break;
}
if (name != NULL)
@@ -1841,7 +1842,7 @@ nfs_enable_share(sa_share_t share)
prop != NULL && i < num_secinfo;
prop = sa_get_next_property(prop), i++) {
char *sectype;
- sectype = sa_get_property_attr(prop, "type");
+ sectype = sa_get_property_attr(prop, "type");
/*
* if sectype is NULL, we probably
* have a memory problem and can't get
@@ -3023,6 +3024,7 @@ nfs_minmax_check(int index, int value)
OPT_CMP_GE) {
ret = value >= val ? B_TRUE : B_FALSE;
}
+ sa_free_attr_string(pval);
}
}
}
diff --git a/usr/src/lib/libshare/smb/libshare_smb.c b/usr/src/lib/libshare/smb/libshare_smb.c
index 2b72fe919a..b6c5417c19 100644
--- a/usr/src/lib/libshare/smb/libshare_smb.c
+++ b/usr/src/lib/libshare/smb/libshare_smb.c
@@ -563,7 +563,8 @@ smb_disable_resource(sa_resource_t resource)
if (smb_isonline()) {
res = smb_share_delete(rname);
- if (res != NERR_Success) {
+ if (res != NERR_Success &&
+ res != NERR_NetNameNotFound) {
sa_free_attr_string(rname);
return (SA_CONFIG_ERR);
}
@@ -1775,8 +1776,9 @@ smb_parse_optstring(sa_group_t group, char *options)
"prefix", prefix);
}
}
- name = fix_resource_name((sa_share_t)group,
- value, prefix);
+ if (prefix != NULL)
+ name = fix_resource_name(
+ (sa_share_t)group, value, prefix);
if (name != NULL) {
resource = sa_add_resource(
(sa_share_t)group, name,
@@ -1981,6 +1983,8 @@ smb_rename_resource(sa_handle_t handle, sa_resource_t resource, char *newname)
err = smb_share_rename(oldname, newname);
+ sa_free_attr_string(oldname);
+
/* improve error values somewhat */
switch (err) {
case NERR_Success: