package.py 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #/usr/bin/python
  2. import os
  3. import getpass
  4. permissions = {
  5. "/etc/libvirt" : ["0700", "root:root"],
  6. "/etc/libvirt/qemu" : ["0700", "root:root"],
  7. "/etc/libvirt/nwfilter" : ["0700", "root:root"],
  8. "/etc/libvirt/qemu/networks" : ["0700", "root:root"],
  9. "/etc/libvirt/qemu/networks/autostart" : ["0700", "root:root"],
  10. "/var/log/libvirt" : ["0700", "root:root"],
  11. "/var/log/libvirt/qemu" : ["0700", "root:root"],
  12. "/var/log/libvirt/lxc" : ["0700", "root:root"],
  13. "/var/log/libvirt/uml" : ["0700", "root:root"],
  14. "/var/lib/libvirt" : ["0755", "root:root"],
  15. "/var/lib/libvirt/images" : ["0711", "root:root"],
  16. "/var/lib/libvirt/boot" : ["0711", "root:root"],
  17. "/var/lib/libvirt/qemu" : ["0750", "qemu:qemu"],
  18. "/var/lib/libvirt/lxc" : ["0700", "root:root"],
  19. "/var/lib/libvirt/uml" : ["0700", "root:root"],
  20. "/var/lib/libvirt/network" : ["0700", "root:root"],
  21. "/var/lib/libvirt/dnsmasq" : ["0755", "root:root"],
  22. "/var/cache/libvirt/qemu" : ["0750", "qemu:qemu"],
  23. "/var/cache/libvirt" : ["0700", "root:root"],
  24. "/run/libvirt" : ["0755", "root:root"],
  25. "/run/libvirt/qemu" : ["0700", "qemu:qemu"],
  26. "/run/libvirt/uml" : ["0700", "root:root"],
  27. "/usr/libexec/libvirt_proxy" : ["4755", "root:root"],
  28. }
  29. def postInstall(fromVersion, fromRelease, toVersion, toRelease):
  30. for _file, perms in permissions.items():
  31. # The list above is general, some paths may not exist depending on the configuration
  32. if os.path.exists(_file):
  33. os.system("/bin/chown -R %s %s" % (perms[1], _file))
  34. os.system("/bin/chmod %s %s" % (perms[0], _file))
  35. os.system("groupadd libvirt")
  36. #os.system("usermod -G libvirt %s" % os.getusername())
  37. os.system("usermod -G libvirt %s" % getpass.getuser())