Index: vws ================================================================== --- vws +++ vws @@ -249,11 +249,10 @@ sys.stdout.flush() elif options.sock in readfd: print "UNSOLICITED MESSAGE %" + options.sock.readline().rstrip() except KeyboardInterrupt: print "Keyboard interrupt" - sys.exit() def cmd_reset(options): """ vws reset """ print send_command(options.sock, 'system_reset') @@ -276,14 +275,15 @@ if re.search("cd", dev): options.id = dev break if options.id is None: print >>sys.stderr, "No CDROM device found among:\n" + devlist - sys.exit(1) + return 1 if options.file == "": + print >>sys.stderr, "Please specify either --eject or iso image" - sys.exit(1) + return 1 if options.file is None: answer = send_command(options.sock, "eject " + options.id) else: answer = send_command(options.sock, "change %s %s" % (options.id, os.path.abspath(options.file))) @@ -301,10 +301,11 @@ options.address = dev[0] break elif not hasattr("address", options): print >>sys.stderr, ("Address or search pattern for device " + "is not specified") + options.sock.close() sys.exit(1) else: return options.address def get_host_devices(): @@ -548,13 +549,17 @@ """ Starts all VMs which are in the autostart directory """ import pwd dirname = config.get("directories", "AutostartVMs") - os.seteuid(pwd.getpwnam( - config.get("permissions","autostart_user") - ).pw_uid) + 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")) + sys.exit(1) + os.setgid(userinfo.pw_gid) + os.setuid(userinfo.pw_uid) if not os.access(dirname,os.R_OK): return for name in os.listdir(dirname): if not os.access(os.path.join(dirname,name,"start"), os.X_OK): continue @@ -568,19 +573,20 @@ start_opts = Namespace(machine = name, command = 'start', dir = machine_dir, snapshot = False, stopped = True, - atrgs = "", + args = "", gui = False, cdrom = None) try: cmd_start(start_opts) print name," ", finally: # pylint: disable=no-member - start_opts.sock.shutdown(socket.SHUT_RDWR) + if start_opts.sock: + start_opts.sock.shutdown(socket.SHUT_RDWR) print "" def cmd_shutdown(options): """ Search for all running machines and stops all of them """ dirlist=[config.get("directories","AutostartVMs"),