Repository: incubator-quickstep Updated Branches: refs/heads/quickstep-28-29 f8d696a3d -> 95a46bbe6 (forced update)
QUICKSTEP-36 fixed. Added read access check in TextScanOperator file before opening a file Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/43c7a42d Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/43c7a42d Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/43c7a42d Branch: refs/heads/quickstep-28-29 Commit: 43c7a42db736aa6e61e6f4db12721ded6e646e13 Parents: 590ba4d Author: Tarun Bansal <tarunbansal...@gmail.com> Authored: Tue Sep 6 23:40:28 2016 -0500 Committer: tarunbansal <tarunbansal...@gmail.com> Committed: Wed Sep 14 11:18:25 2016 -0500 ---------------------------------------------------------------------- relational_operators/CMakeLists.txt | 7 +++++++ .../RelationalOperatorsConfig.h.in | 20 ++++++++++++++++++++ relational_operators/TextScanOperator.cpp | 14 ++++++++++++++ 3 files changed, 41 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/43c7a42d/relational_operators/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/relational_operators/CMakeLists.txt b/relational_operators/CMakeLists.txt index cdfe309..a9645b4 100644 --- a/relational_operators/CMakeLists.txt +++ b/relational_operators/CMakeLists.txt @@ -15,6 +15,13 @@ # specific language governing permissions and limitations # under the License. +include(CheckIncludeFiles) +check_include_files("unistd.h" QUICKSTEP_HAVE_UNISTD) +configure_file ( + "${CMAKE_CURRENT_SOURCE_DIR}/RelationalOperatorsConfig.h.in" + "${CMAKE_CURRENT_BINARY_DIR}/RelationalOperatorsConfig.h" +) + QS_PROTOBUF_GENERATE_CPP(relationaloperators_SortMergeRunOperator_proto_srcs relationaloperators_SortMergeRunOperator_proto_hdrs SortMergeRunOperator.proto) http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/43c7a42d/relational_operators/RelationalOperatorsConfig.h.in ---------------------------------------------------------------------- diff --git a/relational_operators/RelationalOperatorsConfig.h.in b/relational_operators/RelationalOperatorsConfig.h.in new file mode 100644 index 0000000..879d5b3 --- /dev/null +++ b/relational_operators/RelationalOperatorsConfig.h.in @@ -0,0 +1,20 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + **/ + +#cmakedefine QUICKSTEP_HAVE_UNISTD http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/43c7a42d/relational_operators/TextScanOperator.cpp ---------------------------------------------------------------------- diff --git a/relational_operators/TextScanOperator.cpp b/relational_operators/TextScanOperator.cpp index 1a0b715..4151bac 100644 --- a/relational_operators/TextScanOperator.cpp +++ b/relational_operators/TextScanOperator.cpp @@ -19,6 +19,12 @@ #include "relational_operators/TextScanOperator.hpp" +#include "relational_operators/RelationalOperatorsConfig.h" // For QUICKSTEP_HAVE_UNISTD. + +#ifdef QUICKSTEP_HAVE_UNISTD +#include <unistd.h> +#endif // QUICKSTEP_HAVE_UNISTD + #include <algorithm> #include <cctype> #include <cstddef> @@ -91,6 +97,14 @@ bool TextScanOperator::getAllWorkOrders( if (blocking_dependencies_met_ && !work_generated_) { for (const std::string &file : files) { // Use standard C libary to retrieve the file size. + +#ifdef QUICKSTEP_HAVE_UNISTD + // Check file permissions before trying to open it. + const int access_result = access(file.c_str(), R_OK); + CHECK_EQ(0, access_result) + << "File " << file << " is not readable due to permission issues."; +#endif // QUICKSTEP_HAVE_UNISTD + FILE *fp = std::fopen(file.c_str(), "rb"); std::fseek(fp, 0, SEEK_END); const std::size_t file_size = std::ftell(fp);