[pgpool-hackers: 2392] Re: Problems with the relative paths in daemon mode
Tatsuo Ishii
ishii at sraoss.co.jp
Wed Jun 14 07:27:35 JST 2017
Good catch! Please go ahead.
Best regards,
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese:http://www.sraoss.co.jp
> Hi
>
> Pgpool-II does not properly handle the relative paths especially when the
> pgpool.conf file is explicitly specified using the command line (-f switch)
> while its patch is given relative to the current directory.
>
> For example:
>
> Suppose we invoke pgpool-II from "/home/work/installed/pgpool/bin" directory
>
> $ pwd
> /home/work//installed/pgpool/bin
> $ ./pgpool -f simple_conf/pgpool.conf
>
> Now we are expecting here is that the Pgpool-II will look for pgpool.conf
> file in the
> /home/work/installed/pgpool/bin/simple_conf/ directory, which it does
> correctly :-), and also latter in the startup phase when it will require
> the pool_passwd file it will look in the same (
> /home/work/installed/pgpool/bin/simple_conf/)directory.
> So in the code what Pgpool-II does is, it take out the directory portion
> from the command line option provided to it for specifying the pgpool.conf
> file and look for the pool_passwd file in that directory. which in this
> case is just simple_conf/
>
> Now the problem here is since the pgpool.conf path used in the command line
> option was a relative path, so it will only be able to go to the correct
> directory location if the current directory of Pgpool-II remains the same
> from where it was invoked from.
>
> And since we do not change the current directory when Pgpool-II is started
> with "-n" switch ( non daemon mode) so everything works as expected in that
> mode.
> But when the Pgpool-II is started in the daemon mode the daemonize()
> function changes the current directory to "/"
>
> main.c:380 if(chdir("/"))
>
> and after that all relative path becomes invalid and Pgpool-II will start
> looking for files in invalid or non-existent location. which as per our
> example in daemon mode it will try to find the pool_passwd file in
>
> /simple_conf/pool_passed
>
> instead of
>
> /home/work//installed/pgpool/bin/simple_conf/pool_passwd
> The solution to this is to convert the relative path of the pgpool.conf to
> the absolute path at the startup and later use that absolute path for all
> other path calculations.
>
> If you do not have any reservation, than I will start working on the fix.
>
> Thanks
> Best Regards
> Muhammad Usama
More information about the pgpool-hackers
mailing list