summaryrefslogtreecommitdiffstats
path: root/source/lib/replace.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/lib/replace.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/lib/replace.c')
-rw-r--r--source/lib/replace.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/source/lib/replace.c b/source/lib/replace.c
index 6a492f977c3..8d91c2d785c 100644
--- a/source/lib/replace.c
+++ b/source/lib/replace.c
@@ -163,15 +163,21 @@ Corrections by richard.kettlewell@kewill.com
/* yikes! no SETGROUPS or INITGROUPS? how can this work? */
return(0);
#else /* HAVE_SETGROUPS */
- gid_t grouplst[NGROUPS_MAX];
+ gid_t *grouplst = NULL;
+ int max_gr = groups_max();
+ int ret;
int i,j;
struct group *g;
char *gr;
+ if((grouplst = (gid_t *)malloc(sizeof(gid_t) * max_gr)) == NULL) {
+ DEBUG(0,("initgroups: malloc fail !\n");
+ return -1;
+ }
+
grouplst[0] = id;
i = 1;
- while (i < NGROUPS_MAX &&
- ((g = (struct group *)getgrent()) != (struct group *)NULL)) {
+ while (i < max_gr && ((g = (struct group *)getgrent()) != (struct group *)NULL)) {
if (g->gr_gid == id)
continue;
j = 0;
@@ -187,7 +193,9 @@ Corrections by richard.kettlewell@kewill.com
}
}
endgrent();
- return(sys_setgroups(i,grouplst));
+ ret = sys_setgroups(i,grouplst);
+ free((char *)grouplst);
+ return ret;
#endif /* HAVE_SETGROUPS */
}
#endif /* HAVE_INITGROUPS */