<div dir="ltr"><div><div><div><div><div><div><div>Hi Christoph,<br><br></div>Thanks for looking into this. I've managed to bash the original container into installing the cluster, so it can't be used to properly debug this. I've just setup a new one, as described in the original bug report, so I can show you my findings. <br><br>In the clean install, "apt-get install postgresql" exhibits the error described in the bug.<br><br></div>From here:<br>root@debian-db:~# su - postgres<br>postgres@debian-db:~$ /bin/sh<br></div><div>$ exit<br>postgres@debian-db:~$ cat /etc/postgresql/9.4/main/postgresql.conf<br>cat: /etc/postgresql/9.4/main/postgresql.conf: Permission denied<br>postgres@debian-db:~$ ls -lah /etc/ | grep postgresql<br>drwxr-x---+ 3 root root 4.0K Aug 17 08:49 postgresql<br>drwxr-xr-x+ 3 root root 4.0K Aug 17 08:47 postgresql-common<br>postgres@debian-db:~$ exit<br><br></div><div>So, postgres seems able to execute /bin/sh just fine, but can't read the postgresql.conf file, in line with the file permissions.<br></div><div><br>root@debian-db:~# pg_dropcluster 9.4 main<br></div>root@debian-db:~# chown postgres /etc/postgresql<br>root@debian-db:~# cd /tmp && pg_createcluster 9.4 main<br>Creating new cluster 9.4/main ...<br> config /etc/postgresql/9.4/main<br> data /var/lib/postgresql/9.4/main<br> locale en_US.UTF-8<br>Flags of /var/lib/postgresql/9.4/main set as -------------e-C<br>Warning: The socket directory for owners other than 'postgres'<br>defaults to /tmp. You might want to change the unix_socket_directories parameter<br>in postgresql.conf to a more secure directory.<br>Error: could not open /etc/postgresql/9.4/main/postgresql.conf for reading at /usr/share/perl5/PgCommon.pm line 194.<br>Can't exec "/bin/sh": Permission denied at /usr/bin/pg_createcluster line 590.<br><br></div>Same error. Strangely, now:<br><br>root@debian-db:/tmp# su - postgres<br>postgres@debian-db:~$ cat /etc/postgresql/9.4/main/postgresql.conf <br></div>[postgresql.conf content here]<br><br></div>So, the only option is a wrong error message.<br></div><div><br>If I edit the relevant section in /usr/bin/pg_createcluster, I can get it to work. On line 417, there's this content:<br><br>set_cluster_socketdir $version, $cluster, $socketdir if $socketdir;<br>$> = $orig_euid;<br>$) = $orig_egid;<br></div><br>Change it to:<br><div><div><br>$> = $orig_euid;<br>$) = $orig_egid;<br>set_cluster_socketdir $version, $cluster, $socketdir if $socketdir;<br><br></div><div>(i.e. Run the config change as root, not as postgres, which is consistent with the rest of the script). I think the error reported by PgCommon.pm is wrong. It can't *write* the conf file, not *read*.<br><br></div><div>After the change, "pg_createcluster 9.4 main" runs just fine.<br></div><div><br></div><div>Now, for the cherry on top. The cluster won't start:<br><br>root@debian-db:/tmp# systemctl start postgresql@9.4-main.service<br>Job for postgresql@9.4-main.service failed because the control process exited with error code. See "systemctl status postgresql@9.4-main.service" and "journalctl -xe" for details.<br><br></div><div>systemctl status doesn't give any interesting info:<br>root@debian-db:/tmp# systemctl status postgresql@9.4-main.service<br>● postgresql@9.4-main.service - PostgreSQL Cluster 9.4-main<br> Loaded: loaded (/lib/systemd/system/postgresql@.service; disabled; vendor preset: enabled)<br> Active: failed (Result: exit-code) since Mon 2015-08-17 09:09:28 UTC; 35s ago<br> Process: 3198 ExecStart=postgresql@%i %i start (code=exited, status=1/FAILURE)<br><br>Aug 17 09:08:57 debian-db systemd[1]: Starting PostgreSQL Cluster 9.4-main...<br>Aug 17 09:09:28 debian-db postgresql@9.4-main[3198]: The PostgreSQL server failed to start. Please check the log output.<br>Aug 17 09:09:28 debian-db systemd[1]: postgresql@9.4-main.service: Control process exited, code=exited status=1<br>Aug 17 09:09:28 debian-db systemd[1]: Failed to start PostgreSQL Cluster 9.4-main.<br>Aug 17 09:09:28 debian-db systemd[1]: postgresql@9.4-main.service: Unit entered failed state.<br>Aug 17 09:09:28 debian-db systemd[1]: postgresql@9.4-main.service: Failed with result 'exit-code'.<br><br></div><div>But it is again a question of permissions. /var/log/postgresql is owned by root:postgres with permissions rwxrwxr-t. Within, postgresql-9.4-main.log is owned by postgres:adm with permissions rw-r-----. It should work, but postgresql complains it can't write to its log. I suppose the temporary flag in the log directory may cause strange behaviour when the log file is accessed by a different user/group pair (postgres:postgres vs postgres:adm). <br><br>root@debian-db:/tmp# rm -Rf /var/log/postgresql/; mkdir /var/log/postgresql/; chown postgres:postgres /var/log/postgresql/<br>root@debian-db:/tmp# systemctl start postgresql@9.4-main.service<br>root@debian-db:/tmp# echo $?<br>0<br><br></div><div>Sorry for the long mail. It was inevitable. It seems pg_createcluster is actually wrong, the configuration change should be done as root (from what I infer from the rest of the script). However, something in debian triggered this, as it didn't use to happen (I last did this operation over a year ago, so my the bisection is not much use, really).<br><br></div><div>If you need to play around with this install, I can try and get this container online and accessible to you. Tell me if you need me to.<br><br></div><div>Cheers,<br>--<br></div><div>Sérgio Carvalho<br></div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Fri, Aug 14, 2015 at 6:34 PM, Christoph Berg <span dir="ltr"><<a href="mailto:myon@debian.org" target="_blank">myon@debian.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Control: tags -1 moreinfo<br>
<br>
Re: Sergio Carvalho 2015-08-13 <20150813184358.3021.68521.reportbug@profissional-db><br>
> The installer produces this output:<br>
><br>
> Setting up postgresql-9.4 (9.4.4-1) ...<br>
> Creating new cluster 9.4/main ...<br>
> config /etc/postgresql/9.4/main<br>
> data /var/lib/postgresql/9.4/main<br>
> locale en_US.UTF-8<br>
> Flags of /var/lib/postgresql/9.4/main set as -------------e-C<br>
> Warning: The socket directory for owners other than 'postgres'<br>
> defaults to /tmp. You might want to change the unix_socket_directories parameter<br>
> in postgresql.conf to a more secure directory.<br>
> Error: could not open /etc/postgresql/9.4/main/postgresql.conf for reading at /usr/share/perl5/PgCommon.pm line 194.<br>
> Can't exec "/bin/sh": Permission denied at /usr/bin/pg_createcluster line 590.<br>
<br>
Hi Sergio,<br>
<br>
to me it seems the /bin/sh error is the root of the problem. Could you<br>
check what's up with that? If that's broken it's no wonder the<br>
utilities fail in some way.<br>
<span class="HOEnZb"><font color="#888888"><br>
Christoph<br>
--<br>
<a href="mailto:cb@df7cb.de">cb@df7cb.de</a> | <a href="http://www.df7cb.de/" rel="noreferrer" target="_blank">http://www.df7cb.de/</a><br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature">Sérgio Carvalho</div>
</div>