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:
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];
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:
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];