Skip to content

fix(ddev-hostname): sudo can't find ddev-hostname in linuxbrew, fixes #7510 - #7512

Merged
rfay merged 3 commits into
ddev:mainfrom
rfay:20250805_rfay_homebrew_hostname
Aug 8, 2025
Merged

rfay merged 3 commits into
ddev:mainfrom
rfay:20250805_rfay_homebrew_hostname

Conversation

@rfay

@rfay rfay commented Aug 5, 2025 •

Copy link
Copy Markdown
Member

The Issue

With a Linux homebrew installation, ddev-hostname elevation does not succeed

How This PR Solves The Issue

  • Run sudo /absolute/path/to/ddev-hostname to make sure sudo doesn't stumble finding the target
  • Minor docs changes to use "elevate" or "elevation" instead of "escalation", which is usually about security problems.

Manual Testing Instructions

On linux AND macOS, with homebrew-installed ddev (but overwritten with the ddev from this PR)

ddev config --additional-fqdns=2.example.com
ddev start
  • Linuxbrew
  • macOS/homebrew
  • Linux apt
  • WSL2

Automated Testing Overview

We don't have a strategy for testing things that use sudo; we used to allow passwordless sudo on the buildkite machines, but that hid other problems. Maybe there's a way to solve this with a temporary overwrite of the /etc/sudoers.d/something

Release/Deployment Notes

@github-actions github-actions Bot added the bugfix label Aug 5, 2025
@github-actions

github-actions Bot commented Aug 5, 2025 •

Copy link
Copy Markdown

@rfay

rfay commented Aug 6, 2025

Copy link
Copy Markdown
Member Author

This doesn't work yet. sudo doesn't use the PATH to find the ddev-hostname binary, even if you do the --preserve-env. What needs to happen is that GetDdevHostnameBinary() will have to return the absolute path of the binary.

@rfay
rfay force-pushed the 20250805_rfay_homebrew_hostname branch from f877b83 to 499b526 Compare August 6, 2025 21:04
@rfay
rfay marked this pull request as ready for review August 6, 2025 21:04
@rfay
rfay requested review from a team as code owners August 6, 2025 21:04
@rfay
rfay requested a review from stasadev August 6, 2025 21:07
@rfay rfay changed the title fix: some environments like linuxbrew require --preserve-env=PATH to run ddev-hostname, fixes #7510 fix(sudo): some environments like linuxbrew require --preserve-env=PATH to run ddev-hostname, fixes #7510 Aug 6, 2025
@rfay rfay changed the title fix(sudo): some environments like linuxbrew require --preserve-env=PATH to run ddev-hostname, fixes #7510 fix(sudo): sudo can't find ddev-hostname in linuxbrew, fixes #7510 Aug 6, 2025
@rfay rfay changed the title fix(sudo): sudo can't find ddev-hostname in linuxbrew, fixes #7510 fix(ddev-hostname): sudo can't find ddev-hostname in linuxbrew, fixes #7510 Aug 6, 2025

@stasadev stasadev left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good and works well.

Ubuntu Homebrew:

/home/linuxbrew/.linuxbrew/bin/ddev-hostname needs to run with administrative privileges.
This is required to add unresolvable hostnames to the hosts file.
You may need to enter your password for sudo or allow elevation. 
DDEV will issue the command:
  /home/linuxbrew/.linuxbrew/bin/ddev-hostname test.example.com 127.0.0.1
 
[sudo] password for stas: 

Arch Linux:

/usr/bin/ddev-hostname needs to run with administrative privileges.
This is required to add unresolvable hostnames to the hosts file.
You may need to enter your password for sudo or allow elevation. 
DDEV will issue the command:
  /usr/bin/ddev-hostname test.example.com 127.0.0.1
 
[sudo] password for stas: 

Traditional Windows

C:\Program Files\DDEV\ddev-hostname.exe needs to run with administrative privileges.
This is required to add unresolvable hostnames to the hosts file.
You may need to enter your password for sudo or allow elevation.
DDEV will issue the command:
  C:\Program Files\DDEV\ddev-hostname.exe test.example.com 127.0.0.1

  (UAC popup appears)

@rfay

rfay commented Aug 7, 2025

Copy link
Copy Markdown
Member Author

macOS homebrew:

$ ddev start
Starting d11...
The hostname 3.example.com is not currently resolvable, trying to add it to the hosts file
/opt/homebrew/bin/ddev-hostname needs to run with administrative privileges.
This is required to add unresolvable hostnames to the hosts file.
You may need to enter your password for sudo or allow elevation.
DDEV will issue the command:
  /opt/homebrew/bin/ddev-hostname 3.example.com 127.0.0.1

Added '3.example.com' (127.0.0.1) to the hosts file

@rfay

rfay commented Aug 8, 2025

Copy link
Copy Markdown
Member Author

WSL2:

The hostname 4.example.com is not currently resolvable, trying to add it to the hosts file
/usr/bin/ddev-hostname.exe needs to run with administrative privileges.
This is required to add unresolvable hostnames to the hosts file.
You may need to enter your password for sudo or allow elevation.
DDEV will issue the command:
  /usr/bin/ddev-hostname.exe 4.example.com 127.0.0.1

@rfay
rfay merged commit 78db1f7 into ddev:main Aug 8, 2025
@rfay
rfay deleted the 20250805_rfay_homebrew_hostname branch August 8, 2025 03:50
@rfay rfay mentioned this pull request Sep 17, 2025
30 of 42 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants