diff options
author | Jeremy Allison <jra@samba.org> | 2000-02-15 19:36:47 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2000-02-15 19:36:47 +0000 |
commit | 3cf31a194f5721b67b1255e3f168d4bc87d433fc (patch) | |
tree | f9e3ef842e2bad4d7fb0142f685962e125176b23 /source3/smbd | |
parent | 8688933c7feb87179c178a30e4fc42970fe1da8f (diff) | |
download | samba-3cf31a194f5721b67b1255e3f168d4bc87d433fc.tar.gz samba-3cf31a194f5721b67b1255e3f168d4bc87d433fc.tar.bz2 samba-3cf31a194f5721b67b1255e3f168d4bc87d433fc.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.
(This used to be commit b52e92b09d4ca3b66e534f520468dee27065d048)
Diffstat (limited to 'source3/smbd')
-rw-r--r-- | source3/smbd/dfree.c | 10 | ||||
-rw-r--r-- | source3/smbd/nttrans.c | 6 | ||||
-rw-r--r-- | source3/smbd/password.c | 6 |
3 files changed, 8 insertions, 14 deletions
diff --git a/source3/smbd/dfree.c b/source3/smbd/dfree.c index 7838080461..7866d60277 100644 --- a/source3/smbd/dfree.c +++ b/source3/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)) { diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c index d9ad16e7d3..e94e603661 100644 --- a/source3/smbd/nttrans.c +++ b/source3/smbd/nttrans.c @@ -843,15 +843,13 @@ int reply_ntcreate_and_X(connection_struct *conn, } if(fsp->is_directory) { - if(fsp->conn->vfs_ops.stat(dos_to_unix(fsp->fsp_name, False), - &sbuf) != 0) { + if(conn->vfs_ops.stat(dos_to_unix(fsp->fsp_name, False), &sbuf) != 0) { close_file(fsp,True); restore_case_semantics(file_attributes); return(ERROR(ERRDOS,ERRnoaccess)); } } else { - if (fsp->conn->vfs_ops.fstat(fsp->fd_ptr->fd,&sbuf) - != 0) { + if (conn->vfs_ops.fstat(fsp->fd_ptr->fd,&sbuf) != 0) { close_file(fsp,False); restore_case_semantics(file_attributes); return(ERROR(ERRDOS,ERRnoaccess)); diff --git a/source3/smbd/password.c b/source3/smbd/password.c index 44fbdfa8ec..19e7d36443 100644 --- a/source3/smbd/password.c +++ b/source3/smbd/password.c @@ -175,14 +175,10 @@ int setup_groups(char *user, uid_t uid, gid_t gid, int *p_ngroups, gid_t **p_gro ngroups = sys_getgroups(0,&grp); if (ngroups <= 0) { - ngroups = 32; + ngroups = groups_max(); } -#ifdef NGROUPS_MAX - if((groups = (gid_t *)malloc(sizeof(gid_t)*NGROUPS_MAX)) == NULL) -#else /* NGROUPS_MAX */ if((groups = (gid_t *)malloc(sizeof(gid_t)*ngroups)) == NULL) -#endif /* NGROUPS_MAX */ { DEBUG(0,("setup_groups malloc fail !\n")); return -1; |