Skip to content

Commit c2bd8a4

Browse files
committed
see the comments for the details.
1 parent 2f6a8c0 commit c2bd8a4

File tree

3 files changed

+22
-14
lines changed

3 files changed

+22
-14
lines changed

build.conf.template

-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ elif [ $MIRROR == "baidu" ]; then
6161
GPERFTOOLS_URL=http://gitlab.baidu.com/baidups/third/raw/master/gperftools-${GPERFTOOLS_VERSION}.tar.gz
6262
INS_URL=http://gitlab.baidu.com/baidups/third/raw/master/ins-${INS_VERSION}.tar.gz
6363
NOSE_URL=http://gitlab.baidu.com/baidups/third/raw/master/nose-${NOSE_VERSION}.tar.gz
64-
READLINE_URL=http://git.savannah.gnu.org/cgit/readline.git/snapshot/readline-${READLINE_VERSION}.tar.gz
6564
else
6665
return 1
6766
fi

src/common/file/file_path.cc

+15-11
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,26 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
#include "common/file/file_path.h"
6+
57
#include <dirent.h>
68
#include <grp.h>
9+
#include <libgen.h>
10+
#include <linux/limits.h>
711
#include <pwd.h>
12+
#include <sys/stat.h>
13+
#include <sys/types.h>
14+
#include <unistd.h>
15+
816
#include <stdint.h>
917
#include <stdio.h>
1018
#include <stdlib.h>
1119
#include <string.h>
12-
#include <sys/stat.h>
13-
#include <sys/types.h>
14-
#include <unistd.h>
15-
#include <libgen.h>
1620

1721
#include <gflags/gflags.h>
1822

1923
#include "common/base/string_ext.h"
20-
#include "common/file/file_path.h"
24+
2125

2226
DECLARE_int32(file_op_retry_times);
2327

@@ -106,17 +110,17 @@ bool CreateDirWithRetry(const std::string& dir_path) {
106110
}
107111
return is_success;
108112
}
109-
std::string GetCWD(){
110-
char buf[1024];
111-
if(getcwd(buf, 1024) == NULL){
113+
std::string GetCWD() {
114+
char buf[PATH_MAX];
115+
if(getcwd(buf, PATH_MAX) == NULL){
112116
return "";
113117
}
114118
return buf;
115119
}
116120

117-
std::string GetProcessDir(){
118-
char buf[1024];
119-
ssize_t count = readlink("/proc/self/exe", buf, 1024);
121+
std::string GetProcessDir() {
122+
char buf[PATH_MAX];
123+
ssize_t count = readlink("/proc/self/exe", buf, PATH_MAX);
120124
if(count == 0) {
121125
return "";
122126
} else{

src/sdk/client_impl.cc

+7-2
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,7 @@ static int SpecifiedFlagfileCount(const std::string& confpath) {
11891189

11901190
static int InitFlags(const std::string& confpath, const std::string& log_prefix) {
11911191
// search conf file, priority:
1192-
// user-specified > ./tera.flag > ../conf/tera.flag
1192+
// user-specified > ./tera.flag > ../conf/tera.flag > exeDir/tera.flag > exeDir/../tera.flag
11931193
std::string flagfile;
11941194
if (SpecifiedFlagfileCount(confpath) > 1) {
11951195
LOG(ERROR) << "should specify no more than one config file";
@@ -1220,10 +1220,15 @@ static int InitFlags(const std::string& confpath, const std::string& log_prefix)
12201220
} else {
12211221
LOG(ERROR) << "hasn't specify the flagfile, but default config file not found";
12221222
return -1;
1223-
}
1223+
}
12241224

12251225
utils::LoadFlagFile(flagfile);
12261226

1227+
if(!IsDir(FLAGS_log_dir)) {
1228+
LOG(ERROR) << "wrong log directory: "<<FLAGS_log_dir;
1229+
return -1;
1230+
}
1231+
12271232
if (!g_is_glog_init) {
12281233
::google::InitGoogleLogging(log_prefix.c_str());
12291234
utils::SetupLog(log_prefix);

0 commit comments

Comments
 (0)