[2.0 rc1] Following fresh install maas command fails - PermissionError: [Errno 13] Permission denied: '/home/ubuntu/.maascli.db'

Bug #1598937 reported by Larry Michel
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MAAS
Fix Released
High
Gavin Panella
2.0
Fix Released
High
Mike Pontillo

Bug Description

After a fresh install, permissions on .maascli.db are not set for user ubuntu, so commands fail.

ubuntu@maas2-production:~$ maas root login
Traceback (most recent call last):
  File "/usr/bin/maas", line 12, in <module>
    sys.exit(maascli.main())
  File "/usr/lib/python3/dist-packages/maascli/__init__.py", line 24, in main
    parser = prepare_parser(argv)
  File "/usr/lib/python3/dist-packages/maascli/parser.py", line 71, in prepare_parser
    api.register_api_commands(parser)
  File "/usr/lib/python3/dist-packages/maascli/api.py", line 476, in register_api_commands
    with ProfileConfig.open() as config:
  File "/usr/lib/python3.5/contextlib.py", line 59, in __enter__
    return next(self.gen)
  File "/usr/lib/python3/dist-packages/maascli/config.py", line 75, in open
    os.close(os.open(dbpath, os.O_CREAT | os.O_APPEND, 0o600))
PermissionError: [Errno 13] Permission denied: '/home/ubuntu/.maascli.db'

ubuntu@maas2-production:~$ ls -l /home/ubuntu/.maascli.db
-rw------- 1 root root 3072 Jul 4 20:20 /home/ubuntu/.maascli.db

After doing sudo chown ubuntu:ubuntu /home/ubuntu/.maascli.db, then it works.

Tags: oil

Related branches

Revision history for this message
Gavin Panella (allenap) wrote :

Someone or something has run `maas` as root where HOME=/home/ubuntu, e.g. `sudo maas ...` when logged in as ubuntu. I can't find anything in MAAS that would do that. Can you check your shell history and whatever scripts you used when deploying this machine?

Changed in maas:
status: New → Incomplete
Revision history for this message
Larry Michel (lmic) wrote :

I couldn't find any sudo maas in the shell history, but I will try to recreate.

Revision history for this message
Larry Michel (lmic) wrote :

Gavin, I installed maas and was going through my typical installation steps and the very first thing that maas ask user to run is sudo maas createadmin. I think that would do it.

Here are the steps: https://pastebin.canonical.com/160496/ .. In this case I executed maas first which created the file, but typically I will execute sudo maas createadmin which seems to be the logical first steop.

Changed in maas:
status: Incomplete → New
Revision history for this message
Blake Rouse (blake-rouse) wrote :

Larry,

You do have a point. Now that we expose some region commands in the "maascli" the first command running as "sudo" would create that file as the root user. Lets see if we can not create the database for those commands, or create it with the correct permissions.

Changed in maas:
status: New → Triaged
importance: Undecided → High
milestone: none → 2.1.0
Gavin Panella (allenap)
Changed in maas:
assignee: nobody → Gavin Panella (allenap)
status: Triaged → In Progress
Changed in maas:
status: In Progress → Fix Committed
summary: - [2.0 RC1 ] Following fresh install maas command fails -
- PermissionError: [Errno 13] Permission denied:
- '/home/ubuntu/.maascli.db'
+ [2.0 rc1] Following fresh install maas command fails - PermissionError:
+ [Errno 13] Permission denied: '/home/ubuntu/.maascli.db'
Changed in maas:
status: Fix Committed → Fix Released
milestone: 2.0.1 → none
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.