From 9b65811fc4a05254132297e403d2ba220fed983a Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Tue, 6 May 2003 21:52:26 +0000 Subject: Now that rcmdsh(3) can deal with an rsh command w/ args, deal with -P path elements that have spaces. --- usr.bin/rdist/common.c | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) (limited to 'usr.bin/rdist/common.c') 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); } /* -- cgit v1.2.3