You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by dr...@apache.org on 2017/08/16 15:53:10 UTC
[trafficserver] branch master updated: Add check on Environment
input to validate it exists
This is an automated email from the ASF dual-hosted git repository.
dragon pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new ee9477d Add check on Environment input to validate it exists
ee9477d is described below
commit ee9477d13f659e27ca6525ebdd084d91d50a00a1
Author: Jason Kenny <dr...@live.com>
AuthorDate: Tue Aug 15 17:14:22 2017 -0500
Add check on Environment input to validate it exists
---
lib/ts/runroot.cc | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/lib/ts/runroot.cc b/lib/ts/runroot.cc
index c6261c4..ef49ce0 100644
--- a/lib/ts/runroot.cc
+++ b/lib/ts/runroot.cc
@@ -70,6 +70,15 @@ check_parent_path(const std::string &path, bool json = false)
return {};
}
+// until I get a <filesystem> impl in
+bool
+is_directory(const char *directory)
+{
+ struct stat buffer;
+ int result = stat(directory, &buffer);
+ return (!result && (S_IFDIR & buffer.st_mode)) ? true : false;
+}
+
// handler for ts runroot
void
runroot_handler(const char **argv, bool json = false)
@@ -112,8 +121,9 @@ runroot_handler(const char **argv, bool json = false)
}
}
// 2. argv provided invalid/no yaml file, then check env variable
- if (getenv("TS_RUNROOT") != nullptr) {
- setenv("USING_RUNROOT", getenv("TS_RUNROOT"), true);
+ char *env_val = getenv("TS_RUNROOT");
+ if ((env_val != nullptr) && is_directory(env_val)) {
+ setenv("USING_RUNROOT", env_val, true);
if (!json)
ink_notice("using the environment variable TS_RUNROOT");
return;
--
To stop receiving notification emails like this one, please contact
['"commits@trafficserver.apache.org" <co...@trafficserver.apache.org>'].