cli icon indicating copy to clipboard operation
cli copied to clipboard

statamic new <site> incorrectly saves the superuser password on Windows

Open AtmoFX opened this issue 1 year ago • 4 comments

Bug description

The statamic new <site name> command may not save the superuser password correctly, resulting in the impossibility to connect with the password typed during the process, which makes it confusing.

How to reproduce

  1. Run statamic new <site name> with a site name of your choosing. Make it so a superuser will be created in the process.
  2. When asked for the super user password, type anything that contains a $, for instance 123$456789.
  3. Open the site and try to connect to the control panel. Using 123$456789 is not the correct password but 123 is. Apparently, $ and everything to its right is ignored.

Logs

No response

Environment

Environment
Application Name: Statamic
Laravel Version: 11.26.0
PHP Version: 8.3.12
Composer Version: 2.7.7
Environment: local
Debug Mode: ENABLED
URL: Test.test
Maintenance Mode: OFF
Timezone: UTC
Locale: en

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: file
Database: sqlite
Logs: stack / single
Mail: log
Queue: sync
Session: file

Statamic
Addons: 0
Sites: 1
Stache Watcher: Enabled (auto)
Static Caching: Disabled
Version: 5.29.0 Solo

Installation

Fresh statamic/statamic site via CLI

Additional details

No response

AtmoFX avatar Oct 03 '24 01:10 AtmoFX

Which operating system are you using?

duncanmcclean avatar Oct 03 '24 09:10 duncanmcclean

I am on Windows 11.

AtmoFX avatar Oct 03 '24 13:10 AtmoFX

Works fine on Mac, at least.

jasonvarga avatar Oct 04 '24 15:10 jasonvarga

It probably has something to do with the CLI's "make user" code.

Since Windows doesn't have TTY (which means we can't defer to Core's make:user command), the user gets created manually.

https://github.com/statamic/cli/blob/304a0b265dc7f569ddb50e01bd13d54d96bd04e2/src/NewCommand.php#L669-L702

escapeshellarg($password) might be causing it.

duncanmcclean avatar Oct 04 '24 17:10 duncanmcclean