Opened 9 years ago

Closed 6 years ago

#264 closed defect (fixed)

[kean] bindctl should recognize if has a tty or not, and wrong error message

Reported by: jreed Owned by: kean
Priority: medium Milestone: Sprint-20131015
Component: ~bind-ctl (obsolete) Version:
Keywords: Cc:
CVSS Scoring: Parent Tickets:
Sensitive: no Defect Severity: N/A
Sub-Project: Core Feature Depending on Ticket:
Estimated Difficulty: 0.0 Add Hours to Ticket:
Total Hours: Internal?: no

Description

when piped into bindctl, but no ~/.bind10/default_user.csv, it will read for username, but error before it reads for password (at least it appears that way).

[TEMP MESSAGE]: username :root  password :bind10
Username:Password: 
["user doesn't exist"]
Username:EOF when reading a line 
Failed to connect with b10-cmdctl module, is it running?

It should check if not a tty (like in a pipe) and if no default_user.csv file, then it should not prompt for a username and password and should report the problem clearly.

It should not give error message saying "is it running?" -- that is misleading (it is running!).

Subtickets

Change History (12)

comment:1 Changed 9 years ago by zhanglikun

  • billable set to 0
  • Estimated Difficulty set to 0.0
  • Internal? unset
  • Owner set to shentingting
  • Status changed from new to assigned

comment:2 Changed 9 years ago by shane

  • Owner changed from shentingting to shane
  • Status changed from assigned to accepted

comment:3 Changed 9 years ago by shane

  • Owner changed from shane to UnAssigned
  • Status changed from accepted to assigned

comment:4 Changed 8 years ago by shane

  • Defect Severity set to N/A
  • Sub-Project set to DNS

Possibly somewhat related to ticket #81.

comment:5 Changed 8 years ago by shane

  • Sub-Project changed from DNS to Core

comment:6 Changed 6 years ago by shane

os.isatty() will provide this information

comment:7 Changed 6 years ago by jreed

Also see #3118 and #718.

comment:8 Changed 6 years ago by muks

  • Milestone set to Sprint-20130903
  • Summary changed from bindctl should recognize if has a tty or not, and wrong error message to [kean] bindctl should recognize if has a tty or not, and wrong error message

comment:9 Changed 6 years ago by kean

  • Owner changed from UnAssigned to kean
  • Status changed from assigned to accepted

comment:10 follow-up: Changed 6 years ago by kean

  • Owner changed from kean to UnAssigned
  • Status changed from accepted to reviewing

Very simple fix. This is the output received before the fix:

$ echo "help" | ./bindctl 
Error reading saved username and password from /home/kean/.bind10/default_user.csv: [Errno 2] No such file or directory: '/home/kean/.bind10/default_user.csv'

No stored password file found.

When the system is first set up you need to create at least one user account.
For information on how to set up a BIND 10 system, please check see the
BIND 10 Guide: 

http://bind10.isc.org/docs/bind10-guide.html#quick-start-auth-dns

If a user account has been set up, please check the b10-cmdctl log for other
information.

Username: /usr/lib64/python3.3/getpass.py:83: GetPassWarning: Can not control echo on the terminal.
  passwd = fallback_getpass(prompt, stream)
Warning: Password input may be echoed.
Password: Traceback (most recent call last):
  File "/usr/lib64/python3.3/getpass.py", line 63, in unix_getpass
    old = termios.tcgetattr(fd)     # a copy to save
termios.error: (25, 'Inappropriate ioctl for device')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/kean/isc/B10/lib64/python3.3/site-packages/isc/util/traceback_handler.py", line 33, in traceback_handler
    return main()
  File "./bindctl", line 163, in main
    result = tool.run()
  File "/home/kean/isc/B10/lib64/python3.3/site-packages/bindctl/bindcmd.py", line 156, in run
    if not self.login_to_cmdctl():
  File "/home/kean/isc/B10/lib64/python3.3/site-packages/bindctl/bindcmd.py", line 282, in login_to_cmdctl
    passwd = getpass.getpass()
  File "/usr/lib64/python3.3/getpass.py", line 83, in unix_getpass
    passwd = fallback_getpass(prompt, stream)
  File "/usr/lib64/python3.3/getpass.py", line 118, in fallback_getpass
    return _raw_input(prompt, stream)
  File "/usr/lib64/python3.3/getpass.py", line 134, in _raw_input
    raise EOFError
EOFError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "./bindctl", line 167, in <module>
    isc.util.traceback_handler.traceback_handler(main)
  File "/home/kean/isc/B10/lib64/python3.3/site-packages/isc/util/traceback_handler.py", line 38, in traceback_handler
    logger.fatal(PYTHON_UNHANDLED_EXCEPTION, type(e).__name__, e, name)
RuntimeError: attempt to access logging function before logging has been initialized

and after the fix this is what is produced:

$ echo "help" | ./bindctl 
Error reading saved username and password from /home/kean/.bind10/default_user.csv: [Errno 2] No such file or directory: '/home/kean/.bind10/default_user.csv'

No stored password file found.

When the system is first set up you need to create at least one user account.
For information on how to set up a BIND 10 system, please check see the
BIND 10 Guide: 

http://bind10.isc.org/docs/bind10-guide.html#quick-start-auth-dns

If a user account has been set up, please check the b10-cmdctl log for other
information.

and bindctl exits cleanly (other than that message).

Proposed changelog entry:

When bindctl is used as a pipe, no longer attempt to query the user name
and password if no default user name and password file is present, or it
contains no valid entries.

comment:11 in reply to: ↑ 10 Changed 6 years ago by muks

  • Owner changed from UnAssigned to kean

#81 seems to be unrelated to this ticket.

This branch looks fine. Please go ahead and merge.

Replying to kean:

Proposed changelog entry:

When bindctl is used as a pipe, no longer attempt to query the user name
and password if no default user name and password file is present, or it
contains no valid entries.

Here, I suggest changing "use as a pipe" to "used in a pipe" or something like "When commands are piped into bindctl...".

comment:12 Changed 6 years ago by kean

  • Resolution set to fixed
  • Status changed from reviewing to closed
Note: See TracTickets for help on using tickets.