Change in vdsm[master]: [WIP]normalize startup: start supervdsm when startup

lvroyce at linux.vnet.ibm.com lvroyce at linux.vnet.ibm.com
Mon Jan 7 09:57:16 UTC 2013


Royce Lv has uploaded a new change for review.

Change subject: [WIP]normalize startup: start supervdsm when startup
......................................................................

[WIP]normalize startup: start supervdsm when startup

start vdsm as root, after restart supervdsm,
drop previledge to begin normal start flow

Change-Id: I23d9c4f4cd13f92e820a1a261fc4bbacb0f7d55a
Signed-off-by: Royce Lv<lvroyce at linux.vnet.ibm.com>
---
M vdsm/vdsm
M vdsm/vdsmd.init.in
2 files changed, 15 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/08/10708/1

diff --git a/vdsm/vdsm b/vdsm/vdsm
index 4746a0f..3c37b26 100755
--- a/vdsm/vdsm
+++ b/vdsm/vdsm
@@ -23,6 +23,8 @@
 from vdsm import constants
 import zombieReaper
 import dsaversion
+from supervdsm import restartSuperVdsm
+
 if sys.version_info[0] == 2:
     # as long as we work with Python 2, we need to monkey-patch threading
     # module before it is ever used.
@@ -139,9 +141,20 @@
         syslog.syslog("VDSM failed to start: vdsm user is not in KVM group")
         sys.exit(1)
 
+
+def dropPrivileges():
+    if os.getuid() != 0:
+        sys.exit(1)
+    vdsm_uid, vdsm_gid = pwd.getpwnam(constants.VDSM_USER)[2:4:]
+
+    os.setgroups([])
+    os.setgid(vdsm_gid)
+    os.setuid(vdsm_uid)
+
 if __name__ == '__main__':
+    restartSuperVdsm()
+    dropPrivileges()
     __assertVdsmUser()
     __assertLogPermission()
-    os.setpgrp()
     parse_args()
     run()
diff --git a/vdsm/vdsmd.init.in b/vdsm/vdsmd.init.in
index c8223d3..a4a75b5 100755
--- a/vdsm/vdsmd.init.in
+++ b/vdsm/vdsmd.init.in
@@ -499,7 +499,7 @@
 
     LIBVIRT_LOG_FILTERS=`$GETCONFITEM $CONF_FILE vars libvirt_log_filters "1:libvirt 1:remote"` \
     LIBVIRT_LOG_OUTPUTS=`$GETCONFITEM $CONF_FILE vars libvirt_log_outputs "1:file:/var/log/vdsm/libvirt.log"` \
-    LC_ALL=C NICELEVEL=$vdsm_nice daemon --user=vdsm @VDSMDIR@/respawn --minlifetime 10 --daemon --masterpid $RESPAWNPIDFILE $VDSM_BIN
+    LC_ALL=C NICELEVEL=$vdsm_nice daemon @VDSMDIR@/respawn --minlifetime 10 --daemon --masterpid $RESPAWNPIDFILE $VDSM_BIN
     RETVAL=$?
     [ "$RETVAL" -eq 0 ] && log_success_msg $"$prog start" || log_failure_msg $"$prog start"
     [ "$RETVAL" -eq 0 ] && touch /var/lock/subsys/vdsmd


--
To view, visit http://gerrit.ovirt.org/10708
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I23d9c4f4cd13f92e820a1a261fc4bbacb0f7d55a
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Royce Lv <lvroyce at linux.vnet.ibm.com>


More information about the vdsm-patches mailing list