summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPrashanth Pai <ppai@redhat.com>2017-12-22 15:52:46 +0530
committerAmar Tumballi <amarts@redhat.com>2017-12-27 05:22:00 +0000
commit73823181dd0ffa51761c30eefbc2f43888ffe044 (patch)
treec93b567f4219c22dc29c9f8aaf711f5847adce58
parentb868d6077c14e3653fdaddcb856ab2bf6ceb9c00 (diff)
Set log path correctly when clients use UDS
When a libgapi client passes a path to Unix socket file as the "host" parameter to glfs_set_volfile_server() and doesn't explicitly specify a log file, the default log file path being generated was invalid. Example: ERROR: failed to create logfile "/var/log/glusterfs//tmp/gd2/ w1/run/glusterd2.socket-test-10368.log" (No such file or directory) With this fix, it is set to: /var/log/glusterfs/tmp-gd2-w1-run-glusterd2.socket-test-31869.log Change-Id: Ibb4b58382c72eab0d104543781e0e966ebf4c47f Signed-off-by: Prashanth Pai <ppai@redhat.com>
-rw-r--r--libglusterfs/src/common-utils.c28
1 files changed, 23 insertions, 5 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c
index 46a3084fe39..4eed92a92f9 100644
--- a/libglusterfs/src/common-utils.c
+++ b/libglusterfs/src/common-utils.c
@@ -3564,6 +3564,7 @@ gf_set_log_file_path (cmd_args_t *cmd_args, glusterfs_ctx_t *ctx)
int i = 0;
int j = 0;
int ret = 0;
+ int tmp_len = 0;
char tmp_str[1024] = {0,};
if (!cmd_args)
@@ -3617,11 +3618,28 @@ gf_set_log_file_path (cmd_args_t *cmd_args, glusterfs_ctx_t *ctx)
}
if (cmd_args->volfile_server) {
-
- ret = gf_asprintf (&cmd_args->log_file,
- DEFAULT_LOG_FILE_DIRECTORY "/%s-%s-%d.log",
- cmd_args->volfile_server,
- cmd_args->volfile_id, getpid());
+ if (strncmp (cmd_args->volfile_server_transport,
+ "unix", 4) == 0) {
+ if (cmd_args->volfile_server[0] == '/')
+ i = 1;
+ tmp_len = strlen (cmd_args->volfile_server);
+ for (j = 0; i < tmp_len; i++, j++) {
+ tmp_str[j] = cmd_args->volfile_server[i];
+ if (cmd_args->volfile_server[i] == '/')
+ tmp_str[j] = '-';
+ }
+ ret = gf_asprintf (&cmd_args->log_file,
+ "%s/%s-%s-%d.log",
+ DEFAULT_LOG_FILE_DIRECTORY,
+ tmp_str,
+ cmd_args->volfile_id, getpid());
+ } else {
+ ret = gf_asprintf (&cmd_args->log_file,
+ "%s/%s-%s-%d.log",
+ DEFAULT_LOG_FILE_DIRECTORY,
+ cmd_args->volfile_server,
+ cmd_args->volfile_id, getpid());
+ }
if (ret > 0)
ret = 0;
}