crc: [BUG]macOS FATA /etc/hosts is not readable/writable by the current user

General information

  • OS: macOS
  • Hypervisor: hyperkit
  • Did you run crc setup before starting it: Yes

CRC version

version: 1.0.0-beta.5+f2aa58c

CRC status

CRC VM:          Stopped
OpenShift:       Stopped
Disk Usage:      0B of 0B (Inside the CRC VM)
Cache Usage:     10.48GB
Cache Directory: /Users/jr00n/.crc/cache

CRC config

output is empty

Host Operating System

~ » sw_vers
ProductName:	Mac OS X
ProductVersion:	10.14.6
BuildVersion:	18G95

Steps to reproduce

  1. rm -rf ~/.crc
  2. crc setup
  3. crc start

Expected

starting cluster

Actual

FATA /etc/hosts is not readable/writable by the current user stops

Logs

https://gist.github.com/jr00n/9c3bc02e1fe9fdbde042dc7d5b317cfa

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 1
  • Comments: 20 (9 by maintainers)

Commits related to this issue

Most upvoted comments

Hi @cfergeau crc is doing it. Repro steps:

Ownership and permissions of /etc/hosts (this is MacOS default):

$ ls -l /etc/hosts
-rw-r--r--  1 root  wheel  1093 May 27 09:23 /etc/hosts

Run crc setup… Note the: INFO Setting file permissions for /etc/hosts that is logged.

$ crc setup
INFO Checking if oc binary is cached              
INFO Caching oc binary                            
INFO Checking if podman remote binary is cached   
INFO Checking if CRC bundle is cached in '$HOME/.crc' 
INFO Unpacking bundle from the CRC binary         
INFO Checking if running as non-root              
INFO Checking if HyperKit is installed            
INFO Setting up virtualization with HyperKit      
INFO Will use root access: change ownership of /Users/bgehmanus.xxx.com/.crc/bin/hyperkit 
INFO Will use root access: set suid for /Users/bgehmanus.xxx.com/.crc/bin/hyperkit 
INFO Checking if crc-driver-hyperkit is installed 
INFO Installing crc-machine-hyperkit              
INFO Will use root access: change ownership of /Users/bgehmanus.xxx.com/.crc/bin/crc-driver-hyperkit 
INFO Will use root access: set suid for /Users/bgehmanus.xxx.com/.crc/bin/crc-driver-hyperkit 
INFO Checking file permissions for /etc/resolver/testing 
INFO Checking file permissions for /etc/hosts     
INFO Setting file permissions for /etc/hosts      
INFO Will use root access: change ownership of /etc/hosts 
Setup is complete, you can now run 'crc start' to start the OpenShift cluster

Ownership and permissions of /etc/hosts after crc setup:

$ ls -l /etc/hosts
-rw-------  1 bgehmanus.xxx.com  wheel  1093 May 27 09:23 /etc/hosts

The ownership & permissions of system files should not be mucked with (IMHO), and the installer should prompt for creds if/when it needs them to modify system files.

@jr00n looks like we found out the bug so if you are new user of crc you are hitting it because of recent changes in the file permission. As a work around can you do following and then use the crc ?

$ crc setup
$ chmod 0600 /etc/hosts
$ crc start

Ah yes, of course it’s doing this. I misread your initial comment because the bug you answered to was a bug where crc failed to change these permissions. I agree with you that it’s suboptimal, but we don’t want to ask for sudo permissions at crc start time, we want to limit this at crc setup time. This is being reworked in https://github.com/code-ready/crc/pull/1136 through the use of a suid binary. And changing /etc/hosts would not be needed if oc was built to use native macos DNS resolution APIs 😦

@boomkap - I had the same issues and then got your error. I deleted the folder ~/.crc folder and went through setup again and was able to get the cluster to start