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

When postgres is used, the setup fails if username contains a dash #13318

Closed
KopfKrieg opened this issue Jan 2, 2019 · 6 comments
Closed

When postgres is used, the setup fails if username contains a dash #13318

KopfKrieg opened this issue Jan 2, 2019 · 6 comments
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap 25-feedback bug feature: install and update

Comments

@KopfKrieg
Copy link

Steps to reproduce

  1. Setup Postgres (10.5, 10.6, 11.1 - doesn't matter)
  2. Setup Nextcloud 15.0.0
  3. Point your browser to your domain (cloud.example.com), which shows the setup dialogue.
  4. As username for Nextcloud enter something with a dash (e.g. "Kopf-IT"). Chose PostgreSQL as database type, use postgres as user (the default superuser!) and its password. Fill out everything else as usual

Expected behaviour

Nextcloud should then use the postgres superuser to create a Nextcloud only user, insert the data into the config.php, and continue to setup the Nextcloud instance.

Actual behaviour

Nextcloud tries to create the oc_kopf-it user, but fails. The error I get is:
Error while trying to create admin user: Failed to connect to the database: An exception occured in driver: SQLSTATE[08006] [7[ FATAL: password authentication failed for uer "oc_kopf-it"

Using KopfIT or any other name not containing a dash circumvents the problem. I know this sounds like a Postgres problem (or a problem Postgres should solve, not Nextcloud), but after searching for similar error message on The Internet™ I came to the conclusion it might be an error in the Nextcloud postgres driver. It seems the username postgres tries to create is not escaped in the right way.

Server configuration

Operating system: Ubuntu 18.04.1 LTS

Web server: Caddy

Database: Postgres

PHP version: 7.2.13

Nextcloud version: 15.0.0

Updated from an older Nextcloud/ownCloud or fresh install: Fresh install, using the docker image

Where did you install Nextcloud from: Docker Hub

@KopfKrieg KopfKrieg added 0. Needs triage Pending check for reproducibility or if it fits our roadmap bug labels Jan 2, 2019
@skjnldsv skjnldsv linked a pull request Sep 9, 2020 that will close this issue
@skjnldsv skjnldsv added 3. to review Waiting for reviews and removed 0. Needs triage Pending check for reproducibility or if it fits our roadmap labels Sep 9, 2020
@szaimen
Copy link
Contributor

szaimen commented Jan 9, 2023

Hi, please update to 24.0.8 or better 25.0.2 and report back if it fixes the issue. Thank you!

@szaimen szaimen added needs info 0. Needs triage Pending check for reproducibility or if it fits our roadmap and removed 3. to review Waiting for reviews labels Jan 9, 2023
@KopfKrieg
Copy link
Author

Just tested with Nextcloud v25.0.2, the issue still exists. I can't create a user with a dash in the username.

@KopfKrieg
Copy link
Author

Edit: I'm very sorry, I just tested it again at it seems that it works now, even though I did get a notification that (quote) "an error occurred". But creating a user with a dash in it is possible now (or, better, I do have a user now with a dash sign in it). Not sure why I got the notification, though, because the Nextcloud logs don't report an error (I'm a bit confused honestly).

@szaimen
Copy link
Contributor

szaimen commented Jan 9, 2023

Okay, thanks for the follow-up.

@szaimen szaimen closed this as completed Jan 9, 2023
@Bai-Chiang
Copy link

I can't setup a admin account with hyphen in username using 25.0.4 image.

Here is the docker-compose.yml

version: "2.1"
services:
  nextcloud:
    image: nextcloud:25.0.4
    container_name: nextcloud
    volumes:
      - nextcloud:/var/www/html
    depends_on:
      - postgres
    ports:
      - 8080:80
    restart: unless-stopped

  postgres:
    image: postgres:15-alpine
    container_name: postgres
    volumes:
      - postgres:/var/lib/postgresql/data
    environment:
      - POSTGRES_DB=nextcloud
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=password
    restart: unless-stopped

volumes:
  nextcloud:
  postgres:

It failed to create an admin account john-smith during initial setup.

The error message from postgres:

postgres   | 2023-03-07 22:47:06.903 UTC [58] ERROR:  syntax error at or near "-" at character 20
postgres   | 2023-03-07 22:47:06.903 UTC [58] STATEMENT:  CREATE USER oc_john-smith CREATEDB PASSWORD '5XZWMYCxJBbtaDfRM164LrBumO7JD7'
postgres   | 2023-03-07 22:47:06.918 UTC [59] FATAL:  password authentication failed for user "oc_john-smith"
postgres   | 2023-03-07 22:47:06.918 UTC [59] DETAIL:  Role "oc_john-smith" does not exist.
postgres   | 	Connection matched pg_hba.conf line 100: "host all all all scram-sha-256"

@szaimen
Copy link
Contributor

szaimen commented Mar 7, 2023

Hi, please create a new issue for this with up-to-date information. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap 25-feedback bug feature: install and update
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants