Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: user is not allowed #15187

Merged
merged 5 commits into from
Aug 8, 2019

Conversation

vitormattos
Copy link
Contributor

The created user using PostgreSQL database don't has permission to connect to database.

I changed the code to give permission

resolve #11311

The created user don't has permission to connect to database. I changed the code to give permission

Signed-off-by: Vitor Mattos <vitor@php.rio>
@vitormattos vitormattos force-pushed the bugfix-create-database-user branch from 1157db1 to 824cc0a Compare April 21, 2019 18:01
Signed-off-by: Vitor Mattos <vitor@php.rio>
@vitormattos
Copy link
Contributor Author

I believe that continuous integration is in trouble. The status is that it is still running.

Another point is that the tests that broke in my PR are not influenced by my PR.

Signed-off-by: Vitor Mattos <vitor@php.rio>
@vitormattos
Copy link
Contributor Author

@shyim done!

@kesselb kesselb added 3. to review Waiting for reviews bug labels May 5, 2019
@kesselb kesselb requested review from nickvergessen and rullzer May 5, 2019 16:05
Copy link
Member

@nickvergessen nickvergessen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine by me, but can't test

@vitormattos
Copy link
Contributor Author

Hello @nickvergessen!
The tests in the master are breaking, not because of the change I made.

@rullzer rullzer requested a review from icewind1991 May 11, 2019 14:54
@rullzer
Copy link
Member

rullzer commented May 11, 2019

@icewind1991 mind to have a look and check?

@vitormattos
Copy link
Contributor Author

Hello everybody!
This is my first PR to NC.
I want to send more but I need feedback on this PR. Do I need to do any other fixes?
@icewind1991 @rullzer @nickvergessen @shyim

@J0WI J0WI added this to the Nextcloud 16.0.2 milestone Jun 7, 2019
@J0WI
Copy link
Contributor

J0WI commented Jun 7, 2019

Can we plan this for the next release? nextcloud/docker#345 is a frequently discussed issue.

@kesselb
Copy link
Contributor

kesselb commented Jun 7, 2019

@J0WI I don't like these create database / database user code. Would it be a problem for the docker images if we remove those? Nextcloud should use the database / database user provided.

Copy link
Contributor

@kesselb kesselb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense 👍

I think you could move the logic into another method. There is already a createDatabase method. If the database already exist we drop all the permission there. You may add the grant statment to this method.

@charlag
Copy link

charlag commented Jun 7, 2019

In case it helps: I tried this little patch on my system and it finally worked.
Environment described here:
docker-library/postgres#584 (comment)

@charlag
Copy link

charlag commented Jun 7, 2019

I would also say that using credentials other than provided is super confusing and I was blaming the postgres container for that.
Thanks for the patch.

@J0WI
Copy link
Contributor

J0WI commented Jun 8, 2019

Would it be a problem for the docker images if we remove those? Nextcloud should use the database / database user provided.

That's fine for Docker. It can already be created in the database container.

@Brightside56
Copy link

Oh... I see, power of opensource 👍

@vitormattos
Copy link
Contributor Author

@rullzer have any pending for me to do in this PR?

@lukasmrtvy
Copy link

lukasmrtvy commented Aug 3, 2019

Merge?
Its really annoying , because its not possible to upgrade nextcloud ( change docker image version without persistant storage ) !
But You will hit this problem only when You are not using persistent storage ( -v nextcloud:/var/www/html),
entrypoint will always fallback to wizard, which will fail with:

Error while trying to create admin user: Failed to connect to the database: An exception occurred in driver: SQLSTATE[08006] [7] FATAL:  permission denied for database "nextcloud"
DETAIL:  User does not have CONNECT privilege.

I dont need to use volume ( of course DB is needed ) and this will not work, but it should work..

@rullzer rullzer mentioned this pull request Aug 7, 2019
2 tasks
@rullzer rullzer modified the milestones: Nextcloud 16.0.4, Nextcloud 17 Aug 8, 2019
Copy link
Member

@rullzer rullzer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine by me

@rullzer rullzer merged commit b42b26e into nextcloud:master Aug 8, 2019
@welcome
Copy link

welcome bot commented Aug 8, 2019

Thanks for your first pull request and welcome to the community! Feel free to keep them coming! If you are looking for issues to tackle then have a look at this selection: https://github.com/nextcloud/server/issues?q=is%3Aopen+is%3Aissue+label%3A%22good+first+issue%22
Most developers hang out on IRC. So join #nextcloud-dev on Freenode for a chat!

@J0WI
Copy link
Contributor

J0WI commented Aug 8, 2019

/backport to stable16

@J0WI
Copy link
Contributor

J0WI commented Aug 8, 2019

/backport to stable15

@J0WI
Copy link
Contributor

J0WI commented Aug 8, 2019

/backport to stable14

@backportbot-nextcloud
Copy link

The backport to stable16 failed. Please do this backport manually.

@backportbot-nextcloud
Copy link

The backport to stable15 failed. Please do this backport manually.

@backportbot-nextcloud
Copy link

The backport to stable14 failed. Please do this backport manually.

@@ -154,6 +154,10 @@ private function createDBUser(IDBConnection $connection) {
// create the user
$query = $connection->prepare("CREATE USER " . addslashes($this->dbUser) . " CREATEDB PASSWORD '" . addslashes($this->dbPassword) . "'");
$query->execute();
if ($this->databaseExists($connection)) {
$query = $connection->prepare('GRANT CONNECT ON DATABASE ' . addslashes($this->dbName) . ' TO '.addslashes($this->dbUser));
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that this is using ->prepare, shouldn't this be using ? and arguments instead of addslashes?
(https://www.php.net/addslashes -- "The addslashes() is sometimes incorrectly used to try to prevent SQL Injection. Instead, database-specific escaping functions and/or prepared statements should be used.")

I think this is one of the roots of what's being discussed over in docker-library/official-images#6252 (comment) (in PostgreSQL, - needs to be escaped, but addslashes won't do so, for example).

J0WI added a commit to J0WI/docker-nextcloud that referenced this pull request Jan 11, 2020
J0WI added a commit to J0WI/docker-nextcloud that referenced this pull request Jan 11, 2020
This reverts commit 4df6f79.
The upstream bug has been fixed in nextcloud/server#15187

Signed-off-by: J0WI <J0WI@users.noreply.github.com>
J0WI added a commit to nextcloud/docker that referenced this pull request Jan 13, 2020
This reverts commit 4df6f79.
The upstream bug has been fixed in nextcloud/server#15187

Signed-off-by: J0WI <J0WI@users.noreply.github.com>
pierreozoux pushed a commit to pierreozoux/docker-1 that referenced this pull request Jan 23, 2020
…cloud#961)

This reverts commit 4df6f79.
The upstream bug has been fixed in nextcloud/server#15187

Signed-off-by: J0WI <J0WI@users.noreply.github.com>
@skjnldsv
Copy link
Member

Please backport manually

@nickvergessen
Copy link
Member

Not needed anymore as it is in 17+ and 16 goes EOL soon

Craeckie pushed a commit to Craeckie/nextcloud-docker-full that referenced this pull request Mar 30, 2022
This reverts commit 4df6f79.
The upstream bug has been fixed in nextcloud/server#15187

Signed-off-by: J0WI <J0WI@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3. to review Waiting for reviews bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Installing on PostgreSQL fails if the database exists and the installer creates a new user