- use $PATH before _PATH_DEFPATH, from Tim van der Molen
- plug leak, noticed by oga feedback and ok oga@
This commit is contained in:
parent
3bf9d124cf
commit
33d3a7edf1
@ -15,7 +15,7 @@
|
|||||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
*
|
*
|
||||||
* $Id: kbfunc.c,v 1.16 2008/03/23 15:09:21 simon Exp $
|
* $Id: kbfunc.c,v 1.17 2008/04/05 21:09:19 okan Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <paths.h>
|
#include <paths.h>
|
||||||
@ -264,7 +264,7 @@ void
|
|||||||
kbfunc_exec(struct client_ctx *scratch, void *arg)
|
kbfunc_exec(struct client_ctx *scratch, void *arg)
|
||||||
{
|
{
|
||||||
#define NPATHS 256
|
#define NPATHS 256
|
||||||
char **ap, *paths[NPATHS], *path, tpath[MAXPATHLEN];
|
char **ap, *paths[NPATHS], *path, *pathcpy, tpath[MAXPATHLEN];
|
||||||
int l, i, j, ngroups;
|
int l, i, j, ngroups;
|
||||||
gid_t mygroups[NGROUPS_MAX];
|
gid_t mygroups[NGROUPS_MAX];
|
||||||
uid_t ruid, euid, suid;
|
uid_t ruid, euid, suid;
|
||||||
@ -294,14 +294,18 @@ kbfunc_exec(struct client_ctx *scratch, void *arg)
|
|||||||
err(1, "getresuid failure");
|
err(1, "getresuid failure");
|
||||||
|
|
||||||
TAILQ_INIT(&menuq);
|
TAILQ_INIT(&menuq);
|
||||||
/* just use default path until we have config to set this */
|
|
||||||
path = xstrdup(_PATH_DEFPATH);
|
if ((path = getenv("PATH")) == NULL)
|
||||||
|
path = _PATH_DEFPATH;
|
||||||
|
pathcpy = path = xstrdup(path);
|
||||||
|
|
||||||
for (ap = paths; ap < &paths[NPATHS - 1] &&
|
for (ap = paths; ap < &paths[NPATHS - 1] &&
|
||||||
(*ap = strsep(&path, ":")) != NULL;) {
|
(*ap = strsep(&pathcpy, ":")) != NULL;) {
|
||||||
if (**ap != '\0')
|
if (**ap != '\0')
|
||||||
ap++;
|
ap++;
|
||||||
}
|
}
|
||||||
*ap = NULL;
|
*ap = NULL;
|
||||||
|
xfree(path);
|
||||||
for (i = 0; i < NPATHS && paths[i] != NULL; i++) {
|
for (i = 0; i < NPATHS && paths[i] != NULL; i++) {
|
||||||
if ((dirp = opendir(paths[i])) == NULL)
|
if ((dirp = opendir(paths[i])) == NULL)
|
||||||
continue;
|
continue;
|
||||||
@ -367,7 +371,6 @@ kbfunc_exec(struct client_ctx *scratch, void *arg)
|
|||||||
TAILQ_REMOVE(&menuq, mi, entry);
|
TAILQ_REMOVE(&menuq, mi, entry);
|
||||||
xfree(mi);
|
xfree(mi);
|
||||||
}
|
}
|
||||||
xfree(path);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
Loading…
Reference in New Issue
Block a user