Bug 215215 - www/nextcloud: PostgreSQL: setup failure, pg_hba.conf: nextcloud db user wants access to "postgres"
Summary: www/nextcloud: PostgreSQL: setup failure, pg_hba.conf: nextcloud db user want...
Status: Closed Not A Bug
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: freebsd-ports-bugs (Nobody)
URL:
Keywords: needs-qa
Depends on:
Blocks:
 
Reported: 2016-12-11 15:30 UTC by O. Hartmann
Modified: 2018-01-16 09:58 UTC (History)
3 users (show)

See Also:
vlad-fbsd: maintainer-feedback? (loic.blot)
vlad-fbsd: merge-quarterly?


Attachments
Fix a syntax error in PostgreSQL ALTER ROLE stetment and issues with PG db creation (361 bytes, patch)
2016-12-11 18:08 UTC, O. Hartmann
vlad-fbsd: maintainer-approval-
Details | Diff
Patch for www/nextcloud (6.63 KB, patch)
2016-12-11 18:21 UTC, O. Hartmann
vlad-fbsd: maintainer-approval? (loic.blot)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description O. Hartmann 2016-12-11 15:30:03 UTC
Problem: www/nextcloud can not be setup using the webinterface by connecting and setting up the proper tables via its webinterface. Even if installed properly according to the installation howto (manually setting up the databse on a PostgreSQL server), www/nextcloud tries to access PostgrSQL's 'postgres' database - which is wrong!

Scenario:
Using databases/postgresql9[5|6]-server and client accordingly with the most recent ports tree (r428351) and the proper www/nextcloud from this revision.

According to nextcloud's howto, a database named 'nextcloud' has been created. The owner is a user 'nextcloudadm' with the priviledge of creating databases, and login.

This specific user also has the priviledge to access locally and remotely reflected by proper entries in pg_hba.conf.

The access with that specific user to the specific database on the host containing the postgresql database is checked and verified by accessing via "psql" client.

When it comes to the setup of the tables, one might want to access the nextcloud instance via web. We already placed as recommended in the HowTo a config/config.php in the correct path to proceed for the proper setup of the tables. This fails!

The error shown is that nextcloud's setup script tries to access database 'postgres' - which is wrong!

The installation of www/nextcloud never worked for PostgreSQL and should be fixed.
Comment 1 VK 2016-12-11 15:57:08 UTC
Thanks for the report. Why did you change the maintainer-feedback flag?
Comment 2 VK 2016-12-11 16:00:07 UTC
BTW, as of PostgreSQL 9.6 port, the default PostgreSQL user is proper "postgres". postgresql92 - 95 it is "pgsql". So I'm guessing that nextcloud could be patched for that.
Comment 3 O. Hartmann 2016-12-11 17:46:56 UTC
The problem is not databases/postgresql96 nor databases/portgresql95. It doesn't work with either.

After some investigations, I stepped over this thread, describing the exact same situation:

https://github.com/nextcloud/server/pull/497

The solution/patch referenced herein

https://github.com/nextcloud/server/pull/497/files?w=1

works for me.

There is another issue (also serious), because there is a PG syntax error in the PostgrsqlSetup.php script. I accidentally deleted the patch I'm using for weeks now and I thought I had already filed a PR about that issue, but I obviously didn't, not for NC.

I'll send the patch in within the next couple of minutes (or hours, I'm not focussed on the moment).

oh
Comment 4 O. Hartmann 2016-12-11 18:08:56 UTC
Created attachment 177885 [details]
Fix a syntax error in PostgreSQL ALTER ROLE stetment and issues with PG db creation

The patch assigned targets a PG syntax error in ALTER ROLE statement in lib/private/Setup/PostgreSQL.php, see here:

https://help.nextcloud.com/t/nextcloud-10-0-1-bug-in-postgresql-setup-fixed/4748

and issues in setting up PostgreSQL in general as the database, referenced by this issue:

https://github.com/nextcloud/server/pull/497
Comment 5 VK 2016-12-11 18:13:05 UTC
Comment on attachment 177885 [details]
Fix a syntax error in PostgreSQL ALTER ROLE stetment and issues with PG db creation

This patch only bumps revision, did you miss something?

Also are you the maintainer of this port? If so, please sync up your Bugzilla e-mail address with the one listed for the port MAINTAINER. We have no other way to confirm maintainer approvals and feedback.
Comment 6 O. Hartmann 2016-12-11 18:21:35 UTC
Created attachment 177886 [details]
Patch for www/nextcloud

This should be the correct patch. Used svn diff, but starting from /usr/ports, it doesn't catch it.

Sorry.
Comment 7 O. Hartmann 2016-12-11 18:21:51 UTC
No, I am not the maintainer.
Comment 8 VK 2016-12-11 18:34:00 UTC
Thanks for the correct patch. Please confirm this passes the build test with Poudriere.

Also please add a comment to the top of the patch itself about what it does and which commit it comes from, so it's easier to handle the patch later when the port is updated and the fix is in upstream src.

You can reuse the comment from the upstream commit:

https://github.com/nextcloud/server/commit/5365c1a32f396e1e699dea597d7656138f649573.patch

I asked if you were the maintainer because you flagged the PR with maintainer-feedback previously, and now you set maintainer-approval on the patch. You shouldn't do that if you're not the maintainer.

Perhaps you wanted to REQUEST maintainer approval on your attachment? You do so by setting maintainer-approval(?) flag (note the ?) with the maintainer e-mail address, which I'll do that for you so you can see how it looks.
Comment 9 O. Hartmann 2016-12-11 19:50:59 UTC
I build with poudriere, but the metrik is: it builds with "make" from ports for me.

I haven't checked it semantics with a new installation - I use the syntax correction since I use NC 10 - it has been introduced there. The other issue seem to went away after I patched the two files, too.

I have no time to do another full and clean installation as I would do bevor I give 100% assured.

By the way, 10.0.0.2 is out.

Kind regards,

oh
Comment 10 loic.blot 2016-12-12 21:09:23 UTC
I'm very security aware and grant super admin rights to a PHP application is not very good, i prefer adding a notice for PG users in the pkg-message to help them bootstrap the first database (without tables) and the first pg user.
Comment 11 O. Hartmann 2016-12-19 10:13:29 UTC
(In reply to loic.blot from comment #10)

+1

But the patch applied contains only a serious syntax fix and the correct schema/database even for a non-superuser owner of the database, which is necessary to maintain the initial setup of the database.

I looked also for a complete manual way, but lack in finding the pgsql schemata for the initial setup.
Comment 12 Walter Schwarzenfeld 2018-01-16 09:31:08 UTC
Is this still relevant?
Comment 13 loic.blot 2018-01-16 09:43:32 UTC
I don't think it's relevant as-is and as i said, adding a pkg-message notice for rights is better