summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/spawn.cc
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2016-07-07 06:51:05 -0700
committerKaz Kylheku <kaz@kylheku.com>2017-11-16 19:34:52 -0800
commit515616d259089315f440ce5d80f201da4819ee1d (patch)
tree9adcb3aca2493b36d568dd2c063c94324a2d35eb /winsup/cygwin/spawn.cc
parentd7256ca37afb78f351d3c2a944b4ed2f3a3b4cdf (diff)
downloadcygnal-515616d259089315f440ce5d80f201da4819ee1d.tar.gz
cygnal-515616d259089315f440ce5d80f201da4819ee1d.tar.bz2
cygnal-515616d259089315f440ce5d80f201da4819ee1d.zip
Use COMSPEC env var, not hard-coded CMD.EXE path.
It is with some reluctance I make this change, due to the security implications of relying on environment variables. But we can't have a hard-coded path. * winsup/cygwin/include/paths.h (_PATH_CMDEXE): Macro removed. * winsup/cygwin/spawn.cc (av::setup): Use COMSPEC environment variable instead of hard-coded path. If missing, bail with errno set to EOPNOTSUPP. * winsup/cygwin/syscalls.cc (system): Use COMSPEC environment variable. If missing, return -1. (getusershell): Eliminate static array of shell names. If shell_index is zero, return value of COMSPEC env var, if it exists, and increment shell_index to 1. (popen): Use COMSPEC and if that is missing, set errno to EOPNOTSUPP and return NULL.
Diffstat (limited to 'winsup/cygwin/spawn.cc')
-rw-r--r--winsup/cygwin/spawn.cc5
1 files changed, 4 insertions, 1 deletions
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
index 758447e9d..7ea2fca1c 100644
--- a/winsup/cygwin/spawn.cc
+++ b/winsup/cygwin/spawn.cc
@@ -1166,7 +1166,10 @@ av::setup (const char *prog_arg, path_conv& real_path, const char *ext,
}
if (ascii_strcasematch (ext, ".com"))
break;
- pgm = (char *) _PATH_CMDEXE;
+ if ((pgm = getenv("COMSPEC")) == NULL) {
+ set_errno (EOPNOTSUPP);
+ return -1;
+ }
arg1 = NULL;
}