summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2008-04-09 23:48:45 +0200
committerMichael Adam <obnox@samba.org>2008-04-10 01:29:03 +0200
commitbfc4aba3988da46addddd1b6f62462aa2b1a3d0d (patch)
tree774dc4b67b6cd69354fdcabd173061da999b783f
parent6f7fcdcda5aa4227c63cd2bd129cb0f2ca5c0009 (diff)
downloadsamba-bfc4aba3988da46addddd1b6f62462aa2b1a3d0d.tar.gz
samba-bfc4aba3988da46addddd1b6f62462aa2b1a3d0d.tar.bz2
samba-bfc4aba3988da46addddd1b6f62462aa2b1a3d0d.zip
net conf: use talloc and talloc_strdup_lower throughout all net conf functions.
Michael (This used to be commit 977cc9898970a0c07c30264e91754740c640e235)
-rw-r--r--source3/utils/net_conf.c76
1 files changed, 59 insertions, 17 deletions
diff --git a/source3/utils/net_conf.c b/source3/utils/net_conf.c
index e83a2be524..7221f3bd68 100644
--- a/source3/utils/net_conf.c
+++ b/source3/utils/net_conf.c
@@ -278,7 +278,11 @@ static int net_conf_import(struct smbconf_ctx *conf_ctx,
net_conf_import_usage(argc, argv);
goto done;
case 2:
- servicename = argv[1];
+ servicename = talloc_strdup_lower(mem_ctx, argv[1]);
+ if (servicename == NULL) {
+ d_printf("error: out of memory!\n");
+ goto done;
+ }
case 1:
filename = argv[0];
break;
@@ -434,7 +438,11 @@ static int net_conf_showshare(struct smbconf_ctx *conf_ctx,
goto done;
}
- sharename = argv[0];
+ sharename = talloc_strdup_lower(mem_ctx, argv[0]);
+ if (sharename == NULL) {
+ d_printf("error: out of memory!\n");
+ goto done;
+ }
werr = smbconf_get_share(conf_ctx, mem_ctx, sharename, &num_params,
&param_names, &param_values);
@@ -475,6 +483,7 @@ static int net_conf_addshare(struct smbconf_ctx *conf_ctx,
const char *guest_ok = "no";
const char *writeable = "no";
SMB_STRUCT_STAT sbuf;
+ TALLOC_CTX *mem_ctx = talloc_stackframe();
switch (argc) {
case 0:
@@ -522,7 +531,12 @@ static int net_conf_addshare(struct smbconf_ctx *conf_ctx,
}
case 2:
path = argv[1];
- sharename = strdup_lower(argv[0]);
+ sharename = talloc_strdup_lower(mem_ctx, argv[0]);
+ if (sharename == NULL) {
+ d_printf("error: out of memory!\n");
+ goto done;
+ }
+
break;
}
@@ -634,7 +648,7 @@ static int net_conf_addshare(struct smbconf_ctx *conf_ctx,
ret = 0;
done:
- SAFE_FREE(sharename);
+ TALLOC_FREE(mem_ctx);
return ret;
}
@@ -644,12 +658,17 @@ static int net_conf_delshare(struct smbconf_ctx *conf_ctx,
int ret = -1;
const char *sharename = NULL;
WERROR werr = WERR_OK;
+ TALLOC_CTX *mem_ctx = talloc_stackframe();
if (argc != 1) {
net_conf_delshare_usage(argc, argv);
goto done;
}
- sharename = argv[0];
+ sharename = talloc_strdup_lower(mem_ctx, argv[0]);
+ if (sharename == NULL) {
+ d_printf("error: out of memory!\n");
+ goto done;
+ }
werr = smbconf_delete_share(conf_ctx, sharename);
if (!W_ERROR_IS_OK(werr)) {
@@ -660,6 +679,7 @@ static int net_conf_delshare(struct smbconf_ctx *conf_ctx,
ret = 0;
done:
+ TALLOC_FREE(mem_ctx);
return ret;
}
@@ -671,13 +691,22 @@ static int net_conf_setparm(struct smbconf_ctx *conf_ctx,
char *service = NULL;
char *param = NULL;
const char *value_str = NULL;
+ TALLOC_CTX *mem_ctx = talloc_stackframe();
if (argc != 3) {
net_conf_setparm_usage(argc, argv);
goto done;
}
- service = strdup_lower(argv[0]);
- param = strdup_lower(argv[1]);
+ service = talloc_strdup_lower(mem_ctx, argv[0]);
+ if (service == NULL) {
+ d_printf("error: out of memory!\n");
+ goto done;
+ }
+ param = talloc_strdup_lower(mem_ctx, argv[1]);
+ if (param == NULL) {
+ d_printf("error: out of memory!\n");
+ goto done;
+ }
value_str = argv[2];
if (!smbconf_share_exists(conf_ctx, service)) {
@@ -700,8 +729,7 @@ static int net_conf_setparm(struct smbconf_ctx *conf_ctx,
ret = 0;
done:
- SAFE_FREE(service);
- SAFE_FREE(param);
+ TALLOC_FREE(mem_ctx);
return ret;
}
@@ -721,8 +749,16 @@ static int net_conf_getparm(struct smbconf_ctx *conf_ctx,
net_conf_getparm_usage(argc, argv);
goto done;
}
- service = strdup_lower(argv[0]);
- param = strdup_lower(argv[1]);
+ service = talloc_strdup_lower(mem_ctx, argv[0]);
+ if (service == NULL) {
+ d_printf("error: out of memory!\n");
+ goto done;
+ }
+ param = talloc_strdup_lower(mem_ctx, argv[1]);
+ if (param == NULL) {
+ d_printf("error: out of memory!\n");
+ goto done;
+ }
werr = smbconf_get_parameter(conf_ctx, mem_ctx, service, param, &valstr);
@@ -746,8 +782,6 @@ static int net_conf_getparm(struct smbconf_ctx *conf_ctx,
ret = 0;
done:
- SAFE_FREE(service);
- SAFE_FREE(param);
TALLOC_FREE(mem_ctx);
return ret;
}
@@ -759,13 +793,22 @@ static int net_conf_delparm(struct smbconf_ctx *conf_ctx,
WERROR werr = WERR_OK;
char *service = NULL;
char *param = NULL;
+ TALLOC_CTX *mem_ctx = talloc_stackframe();
if (argc != 2) {
net_conf_delparm_usage(argc, argv);
goto done;
}
- service = strdup_lower(argv[0]);
- param = strdup_lower(argv[1]);
+ service = talloc_strdup_lower(mem_ctx, argv[0]);
+ if (service == NULL) {
+ d_printf("error: out of memory!\n");
+ goto done;
+ }
+ param = talloc_strdup_lower(mem_ctx, argv[1]);
+ if (param == NULL) {
+ d_printf("error: out of memory!\n");
+ goto done;
+ }
werr = smbconf_delete_parameter(conf_ctx, service, param);
@@ -788,8 +831,7 @@ static int net_conf_delparm(struct smbconf_ctx *conf_ctx,
ret = 0;
done:
- SAFE_FREE(service);
- SAFE_FREE(param);
+ TALLOC_FREE(mem_ctx);
return ret;
}