bugfix: must check and create data path
parent
ecca01766a
commit
6b1f5e0cca
4
HISTORY
4
HISTORY
|
|
@ -1,7 +1,9 @@
|
||||||
|
|
||||||
Version 6.01 2019-10-23
|
Version 6.01 2019-10-25
|
||||||
* compress and uncompress binlog file by gzip when need,
|
* compress and uncompress binlog file by gzip when need,
|
||||||
config items in storage.conf: compress_binlog and compress_binlog_time
|
config items in storage.conf: compress_binlog and compress_binlog_time
|
||||||
|
* bugfix: must check and create data path before write_to_pid_file
|
||||||
|
in fdfs_storaged.c
|
||||||
|
|
||||||
Version 6.00 2019-10-16
|
Version 6.00 2019-10-16
|
||||||
* tracker and storage server support dual IPs
|
* tracker and storage server support dual IPs
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,11 @@ int main(int argc, char *argv[])
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((result=storage_check_and_make_data_path()) != 0)
|
||||||
|
{
|
||||||
|
log_destroy();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
snprintf(pidFilename, sizeof(pidFilename),
|
snprintf(pidFilename, sizeof(pidFilename),
|
||||||
"%s/data/fdfs_storaged.pid", g_fdfs_base_path);
|
"%s/data/fdfs_storaged.pid", g_fdfs_base_path);
|
||||||
if ((result=process_action(pidFilename, argv[2], &stop)) != 0)
|
if ((result=process_action(pidFilename, argv[2], &stop)) != 0)
|
||||||
|
|
|
||||||
|
|
@ -684,6 +684,29 @@ int storage_write_to_sync_ini_file()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int storage_check_and_make_data_path()
|
||||||
|
{
|
||||||
|
char data_path[MAX_PATH_SIZE];
|
||||||
|
snprintf(data_path, sizeof(data_path), "%s/data",
|
||||||
|
g_fdfs_base_path);
|
||||||
|
if (!fileExists(data_path))
|
||||||
|
{
|
||||||
|
if (mkdir(data_path, 0755) != 0)
|
||||||
|
{
|
||||||
|
logError("file: "__FILE__", line: %d, "
|
||||||
|
"mkdir \"%s\" fail, "
|
||||||
|
"errno: %d, error info: %s",
|
||||||
|
__LINE__, data_path,
|
||||||
|
errno, STRERROR(errno));
|
||||||
|
return errno != 0 ? errno : EPERM;
|
||||||
|
}
|
||||||
|
|
||||||
|
STORAGE_CHOWN(data_path, geteuid(), getegid())
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int storage_check_and_make_data_dirs()
|
static int storage_check_and_make_data_dirs()
|
||||||
{
|
{
|
||||||
int result;
|
int result;
|
||||||
|
|
@ -820,21 +843,10 @@ static int storage_check_and_make_data_dirs()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!fileExists(data_path))
|
if ((result=storage_check_and_make_data_path()) != 0)
|
||||||
{
|
{
|
||||||
if (mkdir(data_path, 0755) != 0)
|
return result;
|
||||||
{
|
|
||||||
logError("file: "__FILE__", line: %d, " \
|
|
||||||
"mkdir \"%s\" fail, " \
|
|
||||||
"errno: %d, error info: %s", \
|
|
||||||
__LINE__, data_path, \
|
|
||||||
errno, STRERROR(errno));
|
|
||||||
return errno != 0 ? errno : EPERM;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
STORAGE_CHOWN(data_path, geteuid(), getegid())
|
|
||||||
}
|
|
||||||
|
|
||||||
g_last_server_port = g_server_port;
|
g_last_server_port = g_server_port;
|
||||||
g_last_http_port = g_http_port;
|
g_last_http_port = g_http_port;
|
||||||
g_storage_join_time = g_current_time;
|
g_storage_join_time = g_current_time;
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,8 @@ bool storage_id_is_myself(const char *storage_id);
|
||||||
int storage_set_tracker_client_ips(ConnectionInfo *conn,
|
int storage_set_tracker_client_ips(ConnectionInfo *conn,
|
||||||
const int tracker_index);
|
const int tracker_index);
|
||||||
|
|
||||||
|
int storage_check_and_make_data_path();
|
||||||
|
|
||||||
#define STORAGE_CHOWN(path, current_uid, current_gid) \
|
#define STORAGE_CHOWN(path, current_uid, current_gid) \
|
||||||
if (!(g_run_by_gid == current_gid && g_run_by_uid == current_uid)) \
|
if (!(g_run_by_gid == current_gid && g_run_by_uid == current_uid)) \
|
||||||
{ \
|
{ \
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue