summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>2003-05-06 21:52:25 +0000
committermillert <millert@openbsd.org>2003-05-06 21:52:25 +0000
commit1e2fc716d340f88461969e96c5fe46019638ac67 (patch)
tree8ee6c07d8fb0290ac8438c8f48c258dc961dd7d5
parentstring cleaning; tedu ok (diff)
downloadwireguard-openbsd-1e2fc716d340f88461969e96c5fe46019638ac67.tar.xz
wireguard-openbsd-1e2fc716d340f88461969e96c5fe46019638ac67.zip
Now that rcmdsh(3) can deal with an rsh command w/ args, deal with
-P path elements that have spaces.
-rw-r--r--usr.bin/rdist/common.c29
1 files changed, 11 insertions, 18 deletions
diff --git a/usr.bin/rdist/common.c b/usr.bin/rdist/common.c
index 6f963698e6e..f29b246d458 100644
--- a/usr.bin/rdist/common.c
+++ b/usr.bin/rdist/common.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: common.c,v 1.18 2003/04/19 17:22:29 millert Exp $ */
+/* $OpenBSD: common.c,v 1.19 2003/05/06 21:52:25 millert Exp $ */
/*
* Copyright (c) 1983 Regents of the University of California.
@@ -39,7 +39,7 @@ static char RCSid[] =
"$From: common.c,v 6.82 1998/03/23 23:27:33 michaelc Exp $";
#else
static char RCSid[] =
-"$OpenBSD: common.c,v 1.18 2003/04/19 17:22:29 millert Exp $";
+"$OpenBSD: common.c,v 1.19 2003/05/06 21:52:25 millert Exp $";
#endif
static char sccsid[] = "@(#)common.c";
@@ -985,26 +985,19 @@ extern char *xbasename(path)
extern char *searchpath(path)
char *path;
{
- char *cp;
char *file;
+ char *space;
+ int found;
struct stat statbuf;
- for (; ;) {
- if (!path)
- return(NULL);
- file = path;
- cp = strchr(path, ':');
- if (cp) {
- path = cp + 1;
- *cp = CNULL;
- } else
- path = NULL;
- if (stat(file, &statbuf) == 0)
- return(file);
- /* Put back what we zapped */
- if (path)
- *cp = ':';
+ for (found = 0; !found && (file = strsep(&path, ":")) != NULL; ) {
+ if ((space = strchr(file, ' ')) != NULL)
+ *space = CNULL;
+ found = stat(file, &statbuf) == 0;
+ if (space)
+ *space = ' '; /* Put back what we zapped */
}
+ return (file);
}
/*