You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2018/01/12 16:03:48 UTC
[trafficserver] 07/09: Add check on Environment input to validate
it exists
This is an automated email from the ASF dual-hosted git repository.
zwoop pushed a commit to branch 7.1.x
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
commit 4ba94efa85689ac86c19e3659c939bb93a2b2305
Author: Jason Kenny <dr...@live.com>
AuthorDate: Tue Aug 15 17:14:22 2017 -0500
Add check on Environment input to validate it exists
(cherry picked from commit ee9477d13f659e27ca6525ebdd084d91d50a00a1)
---
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>.