~andreserl/maas/fix_lp1413388

« back to all changes in this revision

Viewing changes to debian/extras/maas-provision

  • Committer: MAAS Lander
  • Author(s): Andres Rodriguez, Gavin Panella
  • Date: 2015-06-24 21:36:21 UTC
  • mfrom: (381.2.14 packaging.regiond-conf)
  • Revision ID: maas_lander-20150624213621-odxv7u7bi72a2bw4
[r=andreserl][bug=][author=allenap] Use new local configuration support for the region.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/sh
2
 
if [ "$(id -u)" != "0" ]; then
3
 
        echo "This utility may only be run as root." 1>&2
4
 
        exit 1
5
 
fi
6
 
export PYTHONPATH="/usr/share/maas${PYTHONPATH:+:}${PYTHONPATH}"
7
 
exec /usr/bin/python -m provisioningserver "$@"
 
1
#!/usr/bin/python
 
2
# Copyright 2015 Canonical Ltd.  This software is licensed under the
 
3
# GNU Affero General Public License version 3 (see the file LICENSE).
 
4
 
 
5
from __future__ import (
 
6
    absolute_import,
 
7
    print_function,
 
8
    unicode_literals,
 
9
)
 
10
 
 
11
str = None
 
12
 
 
13
__metaclass__ = type
 
14
__all__ = []
 
15
 
 
16
import grp
 
17
import os
 
18
 
 
19
 
 
20
def check_user():
 
21
    # At present, only root should execute this.
 
22
    if os.getuid() != 0:
 
23
        raise SystemExit("This utility may only be run as root.")
 
24
 
 
25
 
 
26
def set_group():
 
27
    # Ensure that we're running as the `maas` group.
 
28
    try:
 
29
        gr_maas = grp.getgrnam("maas")
 
30
    except KeyError:
 
31
        raise SystemExit("No such group: maas")
 
32
    else:
 
33
        os.setegid(gr_maas.gr_gid)
 
34
 
 
35
 
 
36
def set_umask():
 
37
    # Prevent creation of world-readable (or writable, executable) files.
 
38
    os.umask(0o007)
 
39
 
 
40
 
 
41
def run():
 
42
    # Run the main provisioning script.
 
43
    from provisioningserver.__main__ import main
 
44
    main()
 
45
 
 
46
 
 
47
def main():
 
48
    check_user()
 
49
    set_group()
 
50
    set_umask()
 
51
    run()
 
52
 
 
53
 
 
54
if __name__ == "__main__":
 
55
    main()