summaryrefslogtreecommitdiffstats
path: root/meta-openstack
diff options
context:
space:
mode:
authorBruce Ashfield <bruce.ashfield@windriver.com>2013-11-28 23:28:04 -0500
committerBruce Ashfield <bruce.ashfield@windriver.com>2013-11-28 23:39:16 -0500
commit811633754e5cf5e51b26c569f650d3fd115cb089 (patch)
tree432b22d9c1f0092457dcfef2d3a808b82fda13e0 /meta-openstack
parentc158209a05d11cdfaf35b13888151777eaf41dba (diff)
downloadmeta-cloud-services-811633754e5cf5e51b26c569f650d3fd115cb089.tar.gz
python-nova: run services as nova user instead of root
With this change we now run both the nova controller services and compute node agents as the dedicated "nova" user. Changes to configuration were made to relocated locks and logs to nova writeable directories. Wherever possible configuration files and directories have been changed to nova instead of root (with the notable exception of rootwrap configuration). nova has also been granted sudo privileges to run rootwrap commands. And finally, a libvirt system group has been created and nova added to that group. This allows the compute agent to communicate with libvirtd via the "libvirt" group while keeping permissions tight. Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
Diffstat (limited to 'meta-openstack')
-rw-r--r--meta-openstack/recipes-devtools/python/python-nova/nova.conf2
-rw-r--r--meta-openstack/recipes-devtools/python/python-nova/nova.init3
-rw-r--r--meta-openstack/recipes-devtools/python/python-nova_git.bb20
-rw-r--r--meta-openstack/recipes-extended/libvirt/libvirt_1.1.2.bbappend9
4 files changed, 26 insertions, 8 deletions
diff --git a/meta-openstack/recipes-devtools/python/python-nova/nova.conf b/meta-openstack/recipes-devtools/python/python-nova/nova.conf
index a495a7d..84ef48b 100644
--- a/meta-openstack/recipes-devtools/python/python-nova/nova.conf
+++ b/meta-openstack/recipes-devtools/python/python-nova/nova.conf
@@ -19,6 +19,8 @@ debug = True
19verbose = True 19verbose = True
20my_ip = %CONTROLLER_IP% 20my_ip = %CONTROLLER_IP%
21glance_host = %CONTROLLER_IP% 21glance_host = %CONTROLLER_IP%
22lock_path=/var/lock/nova/
23state_path=/var/run/nova/
22 24
23#VNC 25#VNC
24vnc_enabled = true 26vnc_enabled = true
diff --git a/meta-openstack/recipes-devtools/python/python-nova/nova.init b/meta-openstack/recipes-devtools/python/python-nova/nova.init
index 3a2bbac..c2882b6 100644
--- a/meta-openstack/recipes-devtools/python/python-nova/nova.init
+++ b/meta-openstack/recipes-devtools/python/python-nova/nova.init
@@ -30,7 +30,8 @@ start ()
30 30
31 echo -n "Starting $DESC..." 31 echo -n "Starting $DESC..."
32 32
33 start-stop-daemon --start --quiet --background \ 33 sudo -u nova \
34 start-stop-daemon --start --quiet --background \
34 --pidfile ${PIDFILE} --make-pidfile --exec ${DAEMON} 35 --pidfile ${PIDFILE} --make-pidfile --exec ${DAEMON}
35 36
36 if [ $? -eq 0 ]; then 37 if [ $? -eq 0 ]; then
diff --git a/meta-openstack/recipes-devtools/python/python-nova_git.bb b/meta-openstack/recipes-devtools/python/python-nova_git.bb
index 6a065cb..dd199a7 100644
--- a/meta-openstack/recipes-devtools/python/python-nova_git.bb
+++ b/meta-openstack/recipes-devtools/python/python-nova_git.bb
@@ -38,7 +38,7 @@ do_install_append() {
38 NOVA_CONF_DIR=${D}/${sysconfdir}/nova 38 NOVA_CONF_DIR=${D}/${sysconfdir}/nova
39 39
40 install -d ${NOVA_CONF_DIR} 40 install -d ${NOVA_CONF_DIR}
41 install -m 600 ${S}/etc/nova/policy.json ${NOVA_CONF_DIR}/ 41 install -o nova -m 664 ${S}/etc/nova/policy.json ${NOVA_CONF_DIR}/
42 42
43 # Deploy filters to /etc/nova/rootwrap.d 43 # Deploy filters to /etc/nova/rootwrap.d
44 install -m 755 -d ${NOVA_CONF_DIR}/rootwrap.d 44 install -m 755 -d ${NOVA_CONF_DIR}/rootwrap.d
@@ -57,8 +57,12 @@ do_install_append() {
57 touch ${D}${sysconfdir}/sudoers.d/nova-rootwrap 57 touch ${D}${sysconfdir}/sudoers.d/nova-rootwrap
58 chmod 0440 ${D}${sysconfdir}/sudoers.d/nova-rootwrap 58 chmod 0440 ${D}${sysconfdir}/sudoers.d/nova-rootwrap
59 chown root:root ${D}${sysconfdir}/sudoers.d/nova-rootwrap 59 chown root:root ${D}${sysconfdir}/sudoers.d/nova-rootwrap
60 # root user setup
60 echo "root ALL=(root) NOPASSWD: ${bindir}/nova-rootwrap" > \ 61 echo "root ALL=(root) NOPASSWD: ${bindir}/nova-rootwrap" > \
61 ${D}${sysconfdir}/sudoers.d/nova-rootwrap 62 ${D}${sysconfdir}/sudoers.d/nova-rootwrap
63 # nova user setup
64 echo "nova ALL=(root) NOPASSWD: ${bindir}/nova-rootwrap ${sysconfdir}/nova/rootwrap.conf *" >> \
65 ${D}${sysconfdir}/sudoers.d/nova-rootwrap
62 66
63 # Configuration options 67 # Configuration options
64 sed -e "s:%SERVICE_TENANT_NAME%:${SERVICE_TENANT_NAME}:g" \ 68 sed -e "s:%SERVICE_TENANT_NAME%:${SERVICE_TENANT_NAME}:g" \
@@ -84,11 +88,11 @@ do_install_append() {
84 sed -e "s:%CONTROLLER_HOST%:${CONTROLLER_HOST}:g" -i ${WORKDIR}/openrc 88 sed -e "s:%CONTROLLER_HOST%:${CONTROLLER_HOST}:g" -i ${WORKDIR}/openrc
85 89
86 # Copy the configuration file 90 # Copy the configuration file
87 install -m 664 ${WORKDIR}/nova.conf ${NOVA_CONF_DIR}/nova.conf 91 install -o nova -m 664 ${WORKDIR}/nova.conf ${NOVA_CONF_DIR}/nova.conf
88 install -m 664 ${WORKDIR}/api-paste.ini ${NOVA_CONF_DIR} 92 install -o nova -m 664 ${WORKDIR}/api-paste.ini ${NOVA_CONF_DIR}
89 install -m 664 ${WORKDIR}/openrc ${NOVA_CONF_DIR} 93 install -o nova -m 664 ${WORKDIR}/openrc ${NOVA_CONF_DIR}
90 94
91 install -d ${NOVA_CONF_DIR}/instances 95 install -o nova -d ${NOVA_CONF_DIR}/instances
92 96
93 if ${@base_contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then 97 if ${@base_contains('DISTRO_FEATURES', 'sysvinit', 'true', 'false', d)}; then
94 install -d ${D}${sysconfdir}/init.d 98 install -d ${D}${sysconfdir}/init.d
@@ -136,7 +140,7 @@ pkg_postinst_${SRCNAME}-common () {
136 140
137USERADD_PACKAGES = "${PN}" 141USERADD_PACKAGES = "${PN}"
138GROUPADD_PARAM_${PN} = "--system nova" 142GROUPADD_PARAM_${PN} = "--system nova"
139USERADD_PARAM_${PN} = "--system --home /var/lib/nova -g nova \ 143USERADD_PARAM_${PN} = "--system --home /var/lib/nova -g nova -G libvirt \
140 --no-create-home --shell /bin/false nova" 144 --no-create-home --shell /bin/false nova"
141 145
142PACKAGES += " ${SRCNAME}-setup ${SRCNAME}-common ${SRCNAME}-compute ${SRCNAME}-controller" 146PACKAGES += " ${SRCNAME}-setup ${SRCNAME}-common ${SRCNAME}-compute ${SRCNAME}-controller"
@@ -185,7 +189,8 @@ FILES_${SRCNAME}-api = " \
185 ${sysconfdir}/init.d/nova-api \ 189 ${sysconfdir}/init.d/nova-api \
186" 190"
187 191
188RDEPENDS_${PN} = " python-modules \ 192RDEPENDS_${PN} = " libvirt \
193 python-modules \
189 python-misc \ 194 python-misc \
190 python-argparse \ 195 python-argparse \
191 python-amqplib \ 196 python-amqplib \
@@ -193,6 +198,7 @@ RDEPENDS_${PN} = " python-modules \
193 python-babel \ 198 python-babel \
194 python-boto \ 199 python-boto \
195 python-cinderclient \ 200 python-cinderclient \
201 python-cliff \
196 python-cheetah \ 202 python-cheetah \
197 python-eventlet \ 203 python-eventlet \
198 python-feedparser \ 204 python-feedparser \
diff --git a/meta-openstack/recipes-extended/libvirt/libvirt_1.1.2.bbappend b/meta-openstack/recipes-extended/libvirt/libvirt_1.1.2.bbappend
index 3a6634e..eb7a921 100644
--- a/meta-openstack/recipes-extended/libvirt/libvirt_1.1.2.bbappend
+++ b/meta-openstack/recipes-extended/libvirt/libvirt_1.1.2.bbappend
@@ -2,3 +2,12 @@ PACKAGECONFIG ?= "qemu lxc test remote macvtap libvirtd udev yajl \
2 python numactl sanlock ebtables \ 2 python numactl sanlock ebtables \
3 ${@base_contains('DISTRO_FEATURES', 'selinux', 'selinux', '', d)} \ 3 ${@base_contains('DISTRO_FEATURES', 'selinux', 'selinux', '', d)} \
4 " 4 "
5
6inherit useradd
7USERADD_PACKAGES = "${PN}"
8GROUPADD_PARAM_${PN} = "--system libvirt"
9
10do_install_append() {
11 sed -e "s:^#unix_sock_group =:unix_sock_group =:g" -i ${D}/etc/libvirt/libvirtd.conf
12 sed -e "s:^#unix_sock_rw_perms =:unix_sock_rw_perms =:g" -i ${D}/etc/libvirt/libvirtd.conf
13}