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

Bug #1598937 reported by Larry Michel on 2016-07-04
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
MAAS
High
Gavin Panella
2.0
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 Edit Tag help

Related branches

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
Larry Michel (lmic) wrote :

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

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
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) on 2016-07-12
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  Edit
Everyone can see this information.

Other bug subscribers