Index: vws ================================================================== --- vws +++ vws @@ -6,15 +6,16 @@ import fcntl import socket, select import errno import re import os, sys, time, os.path +import pwd VERSION = 0.4 def find_vm(name): """ Search and return VM directory """ - search_path = [os.path.join(os.environ['HOME'], "VWs"), + search_path = [os.path.join(pwd.getpwuid(os.getuid()).pw_dir, "VWs"), config.get("directories", "SharedVMs"), config.get("directories", "AutostartVMs")] for dirname in search_path: if not os.access(dirname, os.X_OK): continue @@ -355,11 +356,11 @@ print answer def cmd_list(options): """ vws list """ count = 0 - search_path = [("private",os.environ['HOME'] + "/VWs"), + search_path = [("private",os.path.join(pwd.getpwuid(os.getuid()).pw_dir, "VWs")), ("shared",config.get("directories", "SharedVMs")), ("autostart",config.get("directories", "AutostartVMs"))] maxlen = 0 vms = [] @@ -547,11 +548,10 @@ def cmd_autostart(options): """ Starts all VMs which are in the autostart directory """ - import pwd dirname = config.get("directories", "AutostartVMs") userinfo=pwd.getpwnam(config.get("permissions","autostart_user")) if not userinfo: print >>sys.stderr, ("User %s doesn't exists %s" % config.get("permissions","autostart_user")) @@ -697,11 +697,11 @@ if parsed_args.shared: machinedir = os.path.join(config.get("directories", "SharedVMs"), parsed_args.machine) dirmode = 0775 else: - machinedir = os.path.join(os.environ["HOME"], "VWs", + machinedir = os.path.join(pwd.getpwuid(os.getuid()).pw_dir, "VWs", parsed_args.machine) dirmode = 0775 if parsed_args.net != 'user': bridges = list_bridges() @@ -826,11 +826,14 @@ config.add_section('permissions') config.set('permissions','vm_group','kvm') config.set('permissions','autostart_user','root') config.set('permissions','setgid_vm','yes') # Read configration files -config.read(['/etc/vws.conf', os.environ['HOME'] + '/.vwsrc']) +if os.getuid() != 0: + config.read(['/etc/vws.conf',os.path.join(pwd.getpwuid(os.getuid()).pw_dir + '.vwsrc')]) +else: + config.read(['/etc/vws.conf']) # Parse argument args = ArgumentParser(description="Manage Virtual Workstations") cmds = args.add_subparsers(dest='command', help="sub-command help") p = cmds.add_parser("list", help="List existing VWs", description="List existing VWs") Index: vws.service ================================================================== --- vws.service +++ vws.service @@ -2,11 +2,11 @@ Description=Virtual Workstation Autostart Documentation=man:vws(1) After=network.target dnsmasq.service [Service] Type=forking -ExecStart=vws autostart -ExecStop=vws shutdown --wait +ExecStart=/usr/local/bin/vws autostart +ExecStop=/usr/local/bin/vws shutdown --wait Restart=no [Install] WantedBy=muiti-user.target Alias=vws.service