summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2019-05-18 11:08:15 -0700
committerJeremy Allison <jra@samba.org>2019-05-24 19:00:05 +0000
commit4a63e3b9659c8715d436c66dee8bf420e2ea89fb (patch)
tree481b49d7ea68d7cc92e67cb9e5704b3309fced61 /source3/lib
parentf9ccf1cc3df13138a1a4b645c8190238ce011f04 (diff)
downloadsamba-4a63e3b9659c8715d436c66dee8bf420e2ea89fb.tar.gz
s3: smbd: Convert sysquotas.c code to use file_lines_ploadv().
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13964 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/sysquotas.c126
1 files changed, 107 insertions, 19 deletions
diff --git a/source3/lib/sysquotas.c b/source3/lib/sysquotas.c
index 43a451da596..864d9dd5c56 100644
--- a/source3/lib/sysquotas.c
+++ b/source3/lib/sysquotas.c
@@ -251,9 +251,9 @@ static int command_get_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t
if (get_quota_command && *get_quota_command) {
const char *p;
char *p2;
- char *syscmd = NULL;
int _id = -1;
int error = 0;
+ char **argl = NULL;
switch(qtype) {
case SMB_USER_QUOTA_TYPE:
@@ -269,15 +269,40 @@ static int command_get_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t
return -1;
}
- if (asprintf(&syscmd, "%s %s %d %d",
- get_quota_command, path, qtype, _id) < 0) {
+ argl = talloc_zero_array(talloc_tos(), char *, 5);
+ if (argl == NULL) {
return -1;
}
+ argl[0] = talloc_strdup(argl, get_quota_command);
+ if (argl[0] == NULL) {
+ TALLOC_FREE(argl);
+ return -1;
+ }
+ argl[1] = talloc_strdup(argl, path);
+ if (argl[1] == NULL) {
+ TALLOC_FREE(argl);
+ return -1;
+ }
+ argl[2] = talloc_asprintf(argl, "%d", qtype);
+ if (argl[2] == NULL) {
+ TALLOC_FREE(argl);
+ return -1;
+ }
+ argl[3] = talloc_asprintf(argl, "%d", _id);
+ if (argl[3] == NULL) {
+ TALLOC_FREE(argl);
+ return -1;
+ }
+ argl[4] = NULL;
- DEBUG (3, ("get_quota: Running command %s\n", syscmd));
+ DBG_NOTICE("Running command %s %s %d %d\n",
+ get_quota_command,
+ path,
+ qtype,
+ _id);
- lines = file_lines_pload(talloc_tos(), syscmd, NULL);
- SAFE_FREE(syscmd);
+ lines = file_lines_ploadv(talloc_tos(), argl, NULL);
+ TALLOC_FREE(argl);
if (lines) {
char *line = lines[0];
@@ -399,8 +424,8 @@ static int command_set_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t
set_quota_command = lp_set_quota_command(talloc_tos());
if (set_quota_command && *set_quota_command) {
char **lines = NULL;
- char *syscmd = NULL;
int _id = -1;
+ char **argl = NULL;
switch(qtype) {
case SMB_USER_QUOTA_TYPE:
@@ -415,21 +440,84 @@ static int command_set_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t
return -1;
}
- if (asprintf(&syscmd,
- "%s %s %d %d "
- "%u %llu %llu "
- "%llu %llu %llu ",
- set_quota_command, path, qtype, _id, dp->qflags,
- (long long unsigned)dp->softlimit,(long long unsigned)dp->hardlimit,
- (long long unsigned)dp->isoftlimit,(long long unsigned)dp->ihardlimit,
- (long long unsigned)dp->bsize) < 0) {
+ argl = talloc_zero_array(talloc_tos(), char *, 11);
+ if (argl == NULL) {
return -1;
}
+ argl[0] = talloc_strdup(argl, set_quota_command);
+ if (argl[0] == NULL) {
+ TALLOC_FREE(argl);
+ return -1;
+ }
+ argl[1] = talloc_strdup(argl, path);
+ if (argl[1] == NULL) {
+ TALLOC_FREE(argl);
+ return -1;
+ }
+ argl[2] = talloc_asprintf(argl, "%d", qtype);
+ if (argl[2] == NULL) {
+ TALLOC_FREE(argl);
+ return -1;
+ }
+ argl[3] = talloc_asprintf(argl, "%d", _id);
+ if (argl[3] == NULL) {
+ TALLOC_FREE(argl);
+ return -1;
+ }
+ argl[4] = talloc_asprintf(argl, "%u", dp->qflags);
+ if (argl[4] == NULL) {
+ TALLOC_FREE(argl);
+ return -1;
+ }
+ argl[5] = talloc_asprintf(argl, "%llu",
+ (long long unsigned)dp->softlimit);
+ if (argl[5] == NULL) {
+ TALLOC_FREE(argl);
+ return -1;
+ }
+ argl[6] = talloc_asprintf(argl, "%llu",
+ (long long unsigned)dp->hardlimit);
+ if (argl[6] == NULL) {
+ TALLOC_FREE(argl);
+ return -1;
+ }
+ argl[7] = talloc_asprintf(argl, "%llu",
+ (long long unsigned)dp->isoftlimit);
+ if (argl[7] == NULL) {
+ TALLOC_FREE(argl);
+ return -1;
+ }
+ argl[8] = talloc_asprintf(argl, "%llu",
+ (long long unsigned)dp->ihardlimit);
+ if (argl[8] == NULL) {
+ TALLOC_FREE(argl);
+ return -1;
+ }
+ argl[9] = talloc_asprintf(argl, "%llu",
+ (long long unsigned)dp->bsize);
+ if (argl[9] == NULL) {
+ TALLOC_FREE(argl);
+ return -1;
+ }
+ argl[10] = NULL;
- DBG_NOTICE("set_quota: Running command %s\n", syscmd);
-
- lines = file_lines_pload(talloc_tos(), syscmd, NULL);
- SAFE_FREE(syscmd);
+ DBG_NOTICE("Running command "
+ "%s %s %d %d "
+ "%u %llu %llu "
+ "%llu %llu %llu ",
+ set_quota_command,
+ path,
+ qtype,
+ _id,
+ dp->qflags,
+ (long long unsigned)dp->softlimit,
+ (long long unsigned)dp->hardlimit,
+ (long long unsigned)dp->isoftlimit,
+ (long long unsigned)dp->ihardlimit,
+ (long long unsigned)dp->bsize);
+
+ lines = file_lines_ploadv(talloc_tos(), argl, NULL);
+ TALLOC_FREE(argl);
if (lines) {
char *line = lines[0];