diff options
author | Jeremy Allison <jra@samba.org> | 2007-11-15 14:19:52 -0800 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2007-11-15 14:19:52 -0800 |
commit | 68be9a820059ee96dd26c527efd7c14e679d3f2c (patch) | |
tree | c3c853a01013fc7977ab02a31e673fe17b4135e6 /source3/lib/sysquotas.c | |
parent | 8e1b0f81c27dc332560f19de27fb86ac96c59775 (diff) | |
download | samba-68be9a820059ee96dd26c527efd7c14e679d3f2c.tar.gz samba-68be9a820059ee96dd26c527efd7c14e679d3f2c.tar.xz samba-68be9a820059ee96dd26c527efd7c14e679d3f2c.zip |
More pstring removal. This one was tricky. I had to add
one horror (pstring_clean_name()) which will have to
remain until I've removed all pstrings from the client code.
Jeremy.
(This used to be commit 1ea3ac80146b83c2522b69e7747c823366a2b47d)
Diffstat (limited to 'source3/lib/sysquotas.c')
-rw-r--r-- | source3/lib/sysquotas.c | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/source3/lib/sysquotas.c b/source3/lib/sysquotas.c index 094422ac9bc..4a2d88abdf5 100644 --- a/source3/lib/sysquotas.c +++ b/source3/lib/sysquotas.c @@ -177,19 +177,19 @@ static struct { #ifdef HAVE_XFS_QUOTAS {"xfs", sys_get_xfs_quota, sys_set_xfs_quota}, #endif /* HAVE_XFS_QUOTAS */ - {NULL, NULL, NULL} + {NULL, NULL, NULL} }; static int command_get_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp) { const char *get_quota_command; char **lines = NULL; - + get_quota_command = lp_get_quota_command(); if (get_quota_command && *get_quota_command) { const char *p; char *p2; - pstring syscmd; + char *syscmd = NULL; int _id = -1; switch(qtype) { @@ -206,13 +206,16 @@ static int command_get_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t return -1; } - slprintf(syscmd, sizeof(syscmd)-1, - "%s \"%s\" %d %d", - get_quota_command, path, qtype, _id); + if (asprintf(&syscmd, "%s \"%s\" %d %d", + get_quota_command, path, qtype, _id) < 0) { + return -1; + } DEBUG (3, ("get_quota: Running command %s\n", syscmd)); lines = file_lines_pload(syscmd, NULL); + SAFE_FREE(syscmd); + if (lines) { char *line = lines[0]; @@ -325,7 +328,7 @@ static int command_get_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t errno = ENOSYS; return -1; - + invalid_param: file_lines_free(lines); @@ -336,11 +339,11 @@ invalid_param: static int command_set_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t id, SMB_DISK_QUOTA *dp) { const char *set_quota_command; - + set_quota_command = lp_set_quota_command(); if (set_quota_command && *set_quota_command) { - char **lines; - pstring syscmd; + char **lines = NULL; + char *syscmd = NULL; int _id = -1; switch(qtype) { @@ -357,37 +360,40 @@ static int command_set_quota(const char *path, enum SMB_QUOTA_TYPE qtype, unid_t } #ifdef LARGE_SMB_OFF_T - slprintf(syscmd, sizeof(syscmd)-1, + if (asprintf(&syscmd, "%s \"%s\" %d %d " "%u %llu %llu " - "%llu %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); + (long long unsigned)dp->bsize) < 0) { + return -1; + } #else /* LARGE_SMB_OFF_T */ - slprintf(syscmd, sizeof(syscmd)-1, + if (asprintf(&syscmd, "%s \"%s\" %d %d " "%u %lu %lu " - "%lu %lu %lu ", + "%lu %lu %lu ", set_quota_command, path, qtype, _id, dp->qflags, (long unsigned)dp->softlimit,(long unsigned)dp->hardlimit, (long unsigned)dp->isoftlimit,(long unsigned)dp->ihardlimit, - (long unsigned)dp->bsize); + (long unsigned)dp->bsize) < 0) { + return -1; + } #endif /* LARGE_SMB_OFF_T */ - - DEBUG (3, ("get_quota: Running command %s\n", syscmd)); lines = file_lines_pload(syscmd, NULL); + SAFE_FREE(syscmd); if (lines) { char *line = lines[0]; DEBUG (3, ("Read output from set_quota, \"%s\"\n", line)); file_lines_free(lines); - + return 0; } DEBUG (0, ("set_quota_command failed!\n")); |