Bug 631804 - condor_router_history not handled exception when bad option is passed
Summary: condor_router_history not handled exception when bad option is passed
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise MRG
Classification: Red Hat
Component: condor
Version: 1.0
Hardware: All
OS: Linux
low
medium
Target Milestone: 2.0.1
: ---
Assignee: Erik Erlandson
QA Contact: Lubos Trilety
URL:
Whiteboard:
Depends On: 712529
Blocks: 723887
TreeView+ depends on / blocked
 
Reported: 2010-09-08 12:37 UTC by Lubos Trilety
Modified: 2011-09-07 16:44 UTC (History)
4 users (show)

Fixed In Version: condor-7.6.2-0.2
Doc Type: Bug Fix
Doc Text:
Running the condor_router_history utility with incorrect argument values could have caused a stack dump due to uncaught argument-handling exceptions. Argument parsing now includes proper exception-handling routines so that command usage errors are now handled gracefully, and helpful error messages are printed to the console when an argument is incorrect.
Clone Of:
Environment:
Last Closed: 2011-09-07 16:44:45 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHSA-2011:1249 0 normal SHIPPED_LIVE Moderate: Red Hat Enterprise MRG Grid 2.0 security, bug fix and enhancement update 2011-09-07 16:40:45 UTC

Description Lubos Trilety 2010-09-08 12:37:43 UTC
Description of problem:
When condor_router_history is run with bad option like '-bad' it prints traceback instead of proper error message or a usage.

Version-Release number of selected component (if applicable):
condor-7.4.4-0.9

How reproducible:
100%

Steps to Reproduce:
1. run 'condor_router_history -bad'

# condor_router_history -bad
Traceback (most recent call last):
  File "/usr/bin/condor_router_history", line 129, in ?
    options,args = getopt.getopt(sys.argv[1:],"h",long_options)
  File "/usr/lib64/python2.4/getopt.py", line 91, in getopt
    opts, args = do_shorts(opts, args[0][1:], shortopts, args[1:])
  File "/usr/lib64/python2.4/getopt.py", line 191, in do_shorts
    if short_has_arg(opt, shortopts):
  File "/usr/lib64/python2.4/getopt.py", line 207, in short_has_arg
    raise GetoptError('option -%s not recognized' % opt, opt)
getopt.GetoptError: option -b not recognized


Actual results:
condor_router_history prints Traceback

Expected results:
error message or a usage should be printed

Additional info:

Comment 2 Erik Erlandson 2011-06-13 22:09:25 UTC
Upstream patch: 

https://condor-wiki.cs.wisc.edu/index.cgi/attach_get/375/gt2234-router-history-except


repro/test:
before fix, bad options yield a stack trace:

$ condor_router_history --xxx
Traceback (most recent call last):
File "/usr/local/condor/bin/condor_router_history", line 129, in <module>
    options,args = getopt.getopt(sys.argv[1:],"h",long_options)
File "/usr/lib64/python2.6/getopt.py", line 89, in getopt
    opts, args = do_longs(opts, args[0][2:], longopts, args[1:])
File "/usr/lib64/python2.6/getopt.py", line 153, in do_longs
    has_arg, opt = long_has_args(opt, longopts)
File "/usr/lib64/python2.6/getopt.py", line 170, in long_has_args
    raise GetoptError('option --%s not recognized' % opt, opt)
getopt.GetoptError: option --xxx not recognized



after fix, bad options yield error message with usage:

$ condor_router_history --xxx
Command line argument error: option --xxx not recognized

USAGE: condor_router_history [OPTIONS]
 --show_records             (show individual records in addition to summary)
 --show_iwd                 (when showing records, include working directory)
 --age=<days>               (how many days ago end time should be)
 --days=<days>              (how many days report should cover)
 --start="YYYY-MM-DD HH:MM" (date of start time of report)



$ condor_router_history --age=xxx
Command line argument error: invalid literal for float(): xxx

USAGE: condor_router_history [OPTIONS]
 --show_records             (show individual records in addition to summary)
 --show_iwd                 (when showing records, include working directory)
 --age=<days>               (how many days ago end time should be)
 --days=<days>              (how many days report should cover)
 --start="YYYY-MM-DD HH:MM" (date of start time of report)

Comment 3 Erik Erlandson 2011-06-15 23:28:11 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Cause:
Argument handling exceptions in condor_router_history were not caught and handled.

Consequence:
Argument errors caused a stack dump instead of a helpful error message.

Fix:
Added proper exception handling around argument parsing.

Result:
Argument errors now are now handled gracefully with a helpful error message.

Comment 4 Erik Erlandson 2011-06-17 00:28:27 UTC
Fix pending upstream, targeted for 7.6.2

Comment 6 Lubos Trilety 2011-07-26 14:15:54 UTC
Tested on:
$CondorVersion: 7.6.3 Jul 13 2011 BuildID: RH-7.6.3-0.2.el5 $
$CondorPlatform: I686-RedHat_5.7 $

$CondorVersion: 7.6.3 Jul 13 2011 BuildID: RH-7.6.3-0.2.el5 $
$CondorPlatform: X86_64-RedHat_5.7 $

$CondorVersion: 7.6.3 Jul 13 2011 BuildID: RH-7.6.3-0.2.el6 $
$CondorPlatform: I686-RedHat_6.1 $

$CondorVersion: 7.6.3 Jul 13 2011 BuildID: RH-7.6.3-0.2.el6 $
$CondorPlatform: X86_64-RedHat_6.1 $

$ condor_router_history -bad
Command line argument error: option -b not recognized

USAGE: condor_router_history [OPTIONS]
 --show_records             (show individual records in addition to summary)
 --show_iwd                 (when showing records, include working directory)
 --age=<days>               (how many days ago end time should be)
 --days=<days>              (how many days report should cover)
 --start="YYYY-MM-DD HH:MM" (date of start time of report)
You have new mail in /var/spool/mail/condor_user

$ condor_router_history --days=x
Command line argument error: invalid literal for float(): x

USAGE: condor_router_history [OPTIONS]
 --show_records             (show individual records in addition to summary)
 --show_iwd                 (when showing records, include working directory)
 --age=<days>               (how many days ago end time should be)
 --days=<days>              (how many days report should cover)
 --start="YYYY-MM-DD HH:MM" (date of start time of report)

$ condor_router_history --days=0.01
Routed job history from 2011-07-26 16:44 to 2011-07-26 16:58
Site            Hours    Jobs    Runs
                      Completed Aborted
-------------------------------------------------------
Site1               0      13     0
Site2               0      13     0
-------------------------------------------------------
TOTAL               0      26     0


>>> VERIFIED

Comment 7 Douglas Silas 2011-08-09 12:53:50 UTC
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1,11 +1 @@
-Cause:
+Running the condor_router_history utility with incorrect argument values could have caused a stack dump due to uncaught argument-handling exceptions. Argument parsing now includes proper exception-handling routines so that command usage errors are now handled gracefully, and helpful error messages are printed to the console when an argument is incorrect.-Argument handling exceptions in condor_router_history were not caught and handled.
-
-Consequence:
-Argument errors caused a stack dump instead of a helpful error message.
-
-Fix:
-Added proper exception handling around argument parsing.
-
-Result:
-Argument errors now are now handled gracefully with a helpful error message.

Comment 8 errata-xmlrpc 2011-09-07 16:44:45 UTC
An advisory has been issued which should help the problem
described in this bug report. This report is therefore being
closed with a resolution of ERRATA. For more information
on therefore solution and/or where to find the updated files,
please follow the link below. You may reopen this bug report
if the solution does not work for you.

http://rhn.redhat.com/errata/RHSA-2011-1249.html


Note You need to log in before you can comment on or make changes to this bug.