Fixing: [pgpool-hackers: 2390] Problems with the relative paths in daemon mode
authorMuhammad Usama <m.usama@gmail.com>
Wed, 21 Jun 2017 12:54:04 +0000 (17:54 +0500)
committerMuhammad Usama <m.usama@gmail.com>
Wed, 21 Jun 2017 13:55:11 +0000 (18:55 +0500)
commit8991f6ea59eb9870dfeb006a4cf94b31c075cfa9
treee3390f81c63832788abcf9b2a85707983ebea284
parent7b902526d65ec872ce09347f52628a84d4b241a2
Fixing: [pgpool-hackers: 2390] Problems with the relative paths in daemon mode

Pgpool-II does all the path related calculations based on CWD
(current working directory) which only works as expected and intended
until the CWD does not change.
But in daemon mode the first thing Pgpool-II do after becoming the daemon
process is, it changes it's CWD to system root ("/") and after that all the
relative paths becomes invalid.
This means in daemon mode if the pgpool.conf file is specified as an argument
using the relative path, Pgpool-II will not be able to find the pool_passwd
or other required file whose location depends on the location of pgpool.conf
file, and will eventually fail to start, or even worst may read/write
some wrong file.

The solution to this is to convert the relative path of the pgpool.conf and
all file paths provided in the argument list to the Pgpool-II to the absolute
paths at the startup and later use those absolute paths for all path related
calculations.

Apart from using the absolute paths for pgpool.conf, pcp.conf and pool_hba.conf
files, The commit also modifies the behaviour of pid_file_name configuration
parameter, when the relative path is used for this config in pgpool.conf,
that relative path is considered with relative to the pgpool.conf path,
instead of the current working directory.
src/include/utils/pool_path.h
src/main/main.c
src/main/pgpool_main.c
src/redhat/pgpool.conf.sample.patch
src/sample/pgpool.conf.sample
src/sample/pgpool.conf.sample-master-slave
src/sample/pgpool.conf.sample-replication
src/sample/pgpool.conf.sample-stream
src/utils/pool_path.c