summaryrefslogtreecommitdiffstats
path: root/source/smbd/dfree.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2000-02-15 19:36:47 +0000
committerJeremy Allison <jra@samba.org>2000-02-15 19:36:47 +0000
commitb52e92b09d4ca3b66e534f520468dee27065d048 (patch)
treedddaeb11e700299abbf352077681b78d38430f0b /source/smbd/dfree.c
parent3d6d3863751787b08d40268c83221add1487a5c9 (diff)
downloadsamba-b52e92b09d4ca3b66e534f520468dee27065d048.tar.gz
samba-b52e92b09d4ca3b66e534f520468dee27065d048.tar.xz
samba-b52e92b09d4ca3b66e534f520468dee27065d048.zip
Added replacement functions sys_popen and sys_pclose. These are based
on the glibc source code and are safer than the traditional popen as they don't use a shell to exec the requested command. Now we have these functions they can be tightened up (environment etc.) as required to make a safe popen. It should now be safe to add the environement variable loading code to loadparm.c Jeremy.
Diffstat (limited to 'source/smbd/dfree.c')
-rw-r--r--source/smbd/dfree.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/source/smbd/dfree.c b/source/smbd/dfree.c
index 78380804615..7866d60277d 100644
--- a/source/smbd/dfree.c
+++ b/source/smbd/dfree.c
@@ -208,7 +208,6 @@ static SMB_BIG_UINT disk_free(char *path, BOOL small_query,
* If external disk calculation specified, use it.
*/
-#ifdef HAVE_POPEN
dfree_command = lp_dfree_command();
if (dfree_command && *dfree_command) {
pstring line;
@@ -216,7 +215,9 @@ static SMB_BIG_UINT disk_free(char *path, BOOL small_query,
FILE *pp;
slprintf (line, sizeof(pstring) - 1, "%s %s", dfree_command, path);
- pp = popen(line, "r");
+ DEBUG (3, ("disk_free: Running command %s\n", line));
+
+ pp = sys_popen(line, "r");
if (pp) {
fgets(line, sizeof(pstring), pp);
line[sizeof(pstring)-1] = '\0';
@@ -236,7 +237,7 @@ static SMB_BIG_UINT disk_free(char *path, BOOL small_query,
*bsize = (SMB_BIG_UINT)strtoul(p, NULL, 10);
else
*bsize = 1024;
- pclose (pp);
+ sys_pclose (pp);
DEBUG (3, ("Parsed output of dfree, dsize=%u, dfree=%u, bsize=%u\n",
(unsigned int)*dsize, (unsigned int)*dfree, (unsigned int)*bsize));
@@ -245,12 +246,11 @@ static SMB_BIG_UINT disk_free(char *path, BOOL small_query,
if (!*dfree)
*dfree = 1024;
} else {
- DEBUG (0, ("disk_free: popen() failed for command %s. Error was : %s\n",
+ DEBUG (0, ("disk_free: sys_popen() failed for command %s. Error was : %s\n",
line, strerror(errno) ));
fsusage(path, dfree, dsize);
}
} else
-#endif /* HAVE_POPEN */
fsusage(path, dfree, dsize);
if (disk_quotas(path, &bsize_q, &dfree_q, &dsize_q)) {