Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 236271 Details for
Bug 264841
anaconda vnc install rejects too-short password late, but never asks for longer version
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
proposed solution.
vnc.diff (text/plain), 13.26 KB, created by
Joel Andres Granados
on 2007-10-24 15:24:15 UTC
(
hide
)
Description:
proposed solution.
Filename:
MIME Type:
Creator:
Joel Andres Granados
Created:
2007-10-24 15:24:15 UTC
Size:
13.26 KB
patch
obsolete
>Index: vnc.py >=================================================================== >RCS file: /usr/local/CVS/anaconda/vnc.py,v >retrieving revision 1.22 >diff -u -p -r1.22 vnc.py >--- vnc.py 19 Sep 2007 18:35:16 -0000 1.22 >+++ vnc.py 24 Oct 2007 15:00:45 -0000 >@@ -23,11 +23,11 @@ import isys > import product > import iutil > import socket >+import subprocess > > import logging > log = logging.getLogger("anaconda") > >-# return -1 to use text mode, None for no vncpass, or vncpass otherwise > def askVncWindow(): > if not os.access('/usr/bin/Xvnc', os.X_OK): > return -1 >@@ -125,7 +125,73 @@ def askVncWindow(): > screen.finish() > return -1 > >+def changeVNCPasswdWindow(): >+ """ Change the passwd to a sane parameter. >+ >+ We ask user to input a passwd that len(passwd) > 6 >+ or passwd == ''. Have to find a way to put askVNCWindow >+ and this method together. >+ """ >+ screen = SnackScreen() >+ grid = GridFormHelp(screen, _("VNC Configuration"),"vnc", 1, 10) >+ >+ bb = ButtonBar(screen, (TEXT_OK_BUTTON, >+ (_("No password"), "nopass"))) >+ >+ text = _("A password will prevent unauthorized listeners " >+ "connecting and monitoring your installation progress. " >+ "Please enter a password to be used for the installation") >+ grid.add(TextboxReflowed(40, text), 0, 0, (0, 0, 0, 1)) >+ >+ entry1 = Entry (16, password = 1) >+ entry2 = Entry (16, password = 1) >+ passgrid = Grid (2, 2) >+ passgrid.setField (Label (_("Password:")), 0, 0, (0, 0, 1, 0), anchorLeft = 1) >+ passgrid.setField (Label (_("Password (confirm):")), 0, 1, (0, 0, 1, 0), anchorLeft = 1) >+ passgrid.setField (entry1, 1, 0) >+ passgrid.setField (entry2, 1, 1) >+ grid.add (passgrid, 0, 1, (0, 0, 0, 1)) >+ >+ grid.add(bb, 0, 8, (0, 1, 1, 0), growx = 1) >+ >+ while 1: >+ res = grid.run() >+ rc = bb.buttonPressed(res) >+ >+ if rc == "nopass": >+ screen.finish() >+ return "" >+ else: >+ pw = entry1.value() >+ cf = entry2.value() >+ if pw != cf: >+ ButtonChoiceWindow(screen, _("Password Mismatch"), >+ _("The passwords you entered were " >+ "different. Please try again."), >+ buttons = [ TEXT_OK_BUTTON ], >+ width = 50) >+ elif len(pw) < 6: >+ ButtonChoiceWindow(screen, _("Password Length"), >+ _("The password must be at least " >+ "six characters long."), >+ buttons = [ TEXT_OK_BUTTON ], >+ width = 50) >+ else: >+ screen.finish() >+ return pw >+ >+ entry1.set("") >+ entry2.set("") >+ continue >+ continue >+ > def getVNCPassword(): >+ """Rescue the vncpassword from where loader left it >+ >+ We are not to check for validity yet, if there is a file >+ pass it to the variable, if there is not, set the var >+ to ''. We will check valididty later. >+ """ > # see if there is a vnc password file > try: > pfile = open("/tmp/vncpassword.dat", "r") >@@ -135,55 +201,66 @@ def getVNCPassword(): > except: > vncpassword="" > pass >- >- # check length of vnc password >- if vncpassword != "" and len(vncpassword) < 6: >- screen = SnackScreen() >- ButtonChoiceWindow(screen, _('VNC Password Error'), >- _('You need to specify a vnc password of at least 6 characters long.\n\n' >- 'Press <return> to reboot your system.\n'), >- buttons = (_("OK"),)) >- screen.finish() >- sys.exit(0) >- > return vncpassword > >-# startup vnc X server >-def startVNCServer(vncpassword="", root='/', vncconnecthost="", >- vncconnectport="", vncStartedCB=None): >- >- stdoutLog = logging.getLogger("anaconda.stdout") >- >- def set_vnc_password(root, passwd, passwd_file): >- (pid, fd) = os.forkpty() >+def set_vnc_password(root, passwd, passwd_file): >+ """ Change the vnc server password.""" > >- if not pid: >- os.execv(root + "/usr/bin/vncpasswd", [root + "/usr/bin/vncpasswd", passwd_file]) >- sys.exit(1) >+ # password input combination. >+ pwinput = "%s\n%s\n" % (passwd, passwd) >+ vnccommand = ["/usr/bin/vncpasswd", passwd_file] >+ vncpswdo = subprocess.Popen(vnccommand, stdin=subprocess.PIPE) >+ (out, err) = vncpswdo.communicate(input=pwinput) >+ return vncpswdo.returncode > >- # read password prompt >- os.read(fd, 1000) >- >- # write password >- os.write(fd, passwd + "\n") >+def openlogfile(filename="/tmp/vncserver.log"): >+ try: >+ err = os.open(filename, os.O_RDWR | os.O_CREAT) >+ if err < 0: >+ sys.stderr.write("error opening %s\n", filename) >+ return None >+ else: >+ return err >+ except: >+ return None > >- # read challenge again, and newline >- os.read(fd, 1000) >- os.read(fd, 1000) >+def connectToViewer(vncconnecthost, vncconnectport, connxinfo, stdoutLog ): >+ """ Return false if connection timed out """ >+ stdoutLog.info(_("Attempting to connect to vnc client on host %s...") % (vncconnecthost,)) >+ maxTries = 50 > >- # write password again >- os.write(fd, passwd + "\n") >+ if vncconnectport != "": >+ hostarg = vncconnecthost + ":" + vncconnectport >+ else: >+ hostarg = vncconnecthost > >- # read remaining output >- os.read(fd, 1000) >+ vncconfigcommand = ["/usr/bin/vncconfig", "-display", ":1", "-connect", hostarg] > >- # wait for status >- try: >- (pid, status) = os.waitpid(pid, 0) >- except OSError, (errno, msg): >- print __name__, "waitpid:", msg >+ for i in range(maxTries): >+ vncconfp = subprocess.Popen(vncconfigcommand) # vncconfig process >+ (out, err) = vncconfp.communicate() >+ >+ #out = iutil.execWithCapture("/usr/bin/vncconfig", argv) >+ >+ if out == None: >+ stdoutLog.info(_("Connected!")) >+ return True >+ elif out.startswith("connecting") and out.endswith("failed\n"): >+ stdoutLog.info(out) >+ stdoutLog.info(_("Will try to connect again in 15 seconds...")) >+ time.sleep(15) >+ continue >+ else: >+ stdoutLog.critical(out) >+ sys.exit(1) >+ stdoutLog.error(_("Giving up attempting to connect after %d tries!\n" % maxTries )) >+ return False >+ >+# startup vnc X server >+def startVNCServer(vncpassword="", root='/', vncconnecthost="", >+ vncconnectport="", vncStartedCB=None): > >- return status >+ stdoutLog = logging.getLogger("anaconda.stdout") > > stdoutLog.info(_("Starting VNC...")) > >@@ -245,109 +322,77 @@ def startVNCServer(vncpassword="", root= > else: > desktopname = _("%s %s installation") % (product.productName, product.productVersion) > >- vncpid = os.fork() >- >- if not vncpid: >- args = [ root + "/usr/bin/Xvnc", ":1", "-nevershared", >- "-depth", "16", "-geometry", "800x600", "-br", >- "IdleTimeout=0", "-auth", "/dev/null", "-once", >- "DisconnectClients=false", "desktop=%s" % (desktopname,)] >- >- # set passwd if necessary >- if vncpassword != "": >- try: >- rc = set_vnc_password(root, vncpassword, "/tmp/vncpasswd_file") >- except Exception, e: >- stdoutLog.error("Unknown exception setting vnc password.") >- log.error("Exception was: %s" %(e,)) >- rc = 1 >- >- if rc: >- stdoutLog.warning(_("Unable to set vnc password - using no password!")) >- stdoutLog.warning(_("Make sure your password is at least 6 characters in length.")) >- else: >- args = args + ["-rfbauth", "/tmp/vncpasswd_file"] >- else: >- # needed if no password specified >- args = args + ["SecurityTypes=None",] >- >- tmplogFile = "/tmp/vncserver.log" >- try: >- err = os.open(tmplogFile, os.O_RDWR | os.O_CREAT) >- if err < 0: >- sys.stderr.write("error opening %s\n", tmplogFile) >- else: >- os.dup2(err, 2) >- os.close(err) >- except: >- # oh well >- pass >- >+ # Make sure that the password is sane >+ if vncconnecthost == "" and vncpassword != "" and len(vncpassword) < 6: >+ vncpassword = changeVNCPasswdWindow() >+ >+ # Construct the Xvnc command >+ xvnccommand = [ root + "/usr/bin/Xvnc", ":1", "-nevershared", >+ "-depth", "16", "-geometry", "800x600", "-br", >+ "IdleTimeout=0", "-auth", "/dev/null", "-once", >+ "DisconnectClients=false", "desktop=%s" % (desktopname,)] >+ >+ # If we have the vncconnecthost variable it means that we dont >+ # need to set the password. >+ if vncconnecthost == "" and vncpassword == "": >+ # The user wants to initialize connection from a remote host >+ # With no authentication. >+ xvnccommand = xvnccommand+["SecurityTypes=None"] >+ stdoutLog.warning(_("\n\nWARNING!!! VNC server running with NO PASSWORD!\n" >+ "You can use the vncpassword=<password> boot option\n" >+ "if you would like to secure the server.\n\n")) >+ elif vncconnecthost == "" and vncpassword != "": >+ # The user wants to connect from remote host with passwd. > try: >- os.execv(args[0], args) >- sys.exit (1) >- except OSError, e: >- stdoutLog.critical("Error running %s: %s" % (root + "/usr/bin/Xvnc", e.strerror)) >- sys.exit(1) >+ rc = set_vnc_password(root, vncpassword, "/tmp/vncpasswd_file") >+ except Exception, e: >+ stdoutLog.error("Unknown exception setting vnc password.") >+ log.error("Exception was: %s" %(e,)) >+ rc = 1 >+ >+ if rc: >+ stdoutLog.warning(_("Unable to set vnc password - using no password!")) >+ xvnccommand = xvnccommand+["SecurityTypes=None"] >+ #stdoutLog.warning(_("Make sure your password is at least 6 characters in length.")) >+ else: >+ xvnccommand = xvnccommand+["-rfbauth","/tmp/vncpasswd_file"] > >- # Wait for a bit, then make sure the VNC server really started before >- # stating that it did. >- time.sleep(1) >+ elif vncconnecthost != "": >+ # The server is going to start the connection. dont have to >+ # worry about password things. >+ stdoutLog.warning(_("\n\nYou Chose to connect to a listening vncviewer. \n" >+ "This does not require a password to be set.\n\n")) >+ pass > > try: >- (pid, status) = os.waitpid(vncpid, os.WNOHANG) >+ logfd = openlogfile(filename="/tmp/vncserver.log") >+ xvncp = subprocess.Popen(xvnccommand, stdout=openlogfile(filename="/tmp/vncserver.log"),\ >+ stderr=subprocess.STDOUT) > except: > stdoutLog.critical("Could not start the VNC server. Aborting.") > sys.exit(1) > >- if os.WIFEXITED(status) and os.WEXITSTATUS(status) > 0: >- sys.exit(1) >- >- if vncpassword == "": >- stdoutLog.warning(_("\n\nWARNING!!! VNC server running with NO PASSWORD!\n" >- "You can use the vncpassword=<password> boot option\n" >- "if you would like to secure the server.\n\n")) >+ # Lets give the xvnc time to initialize >+ time.sleep(1) > >- stdoutLog.info(_("The VNC server is now running.")) >+ # Make sure it hasn't blown up >+ if xvncp.poll() != None: >+ sys.exit(1) >+ else: >+ stdoutLog.info(_("The VNC server is now running.")) > >+ # Connect to a vncviewer if needed. > if vncconnecthost != "": >- stdoutLog.info(_("Attempting to connect to vnc client on host %s...") % (vncconnecthost,)) >- >- if vncconnectport != "": >- hostarg = vncconnecthost + ":" + vncconnectport >- else: >- hostarg = vncconnecthost >- >- argv = ["-display", ":1", "-connect", hostarg] >- ntries = 0 >- while 1: >- output = iutil.execWithCapture("/usr/bin/vncconfig", argv) >- >- if output == "": >- stdoutLog.info(_("Connected!")) >- break >- elif output.startswith("connecting") and output.endswith("failed\n"): >- ntries += 1 >- if ntries > 50: >- stdoutLog.error(_("Giving up attempting to connect after 50 tries!\n")) >- if connxinfo is not None: >- stdoutLog.info(_("Please manually connect your vnc client to %s to begin the install.") % (connxinfo,)) >- else: >- stdoutLog.info(_("Please manually connect your vnc client to begin the install.")) >- break >- >- stdoutLog.info(output) >- stdoutLog.info(_("Will try to connect again in 15 seconds...")) >- time.sleep(15) >- continue >- else: >- stdoutLog.critical(output) >- sys.exit(1) >+ if not connectToViewer(vncconnecthost, vncconnectport, connxinfo, stdoutLog): >+ if connxinfo is not None: >+ stdoutLog.info(_("Please manually connect your vnc client to %s to begin the install.") % (connxinfo,)) >+ else: >+ stdoutLog.info(_("Please manually connect your vnc client to begin the install.")) > else: >- if connxinfo is not None: >- stdoutLog.info(_("Please connect to %s to begin the install...") % (connxinfo,)) >- else: >- stdoutLog.info(_("Please connect to begin the install...")) >+ if connxinfo is not None: >+ stdoutLog.info(_("Please manually connect your vnc client to %s to begin the install.") % (connxinfo,)) >+ else: >+ stdoutLog.info(_("Please manually connect your vnc client to begin the install.")) > > os.environ["DISPLAY"]=":1" >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 264841
:
236271
|
243331