From 3138fad8494d9e1e39a0f8f039e2669fad93b327 Mon Sep 17 00:00:00 2001 From: Rob Date: Thu, 30 Jul 2009 15:24:36 +0200 Subject: [PATCH] Some more debugging wrt the manual makefile output, especially the sudo example. Added --print-execute for debugging $() commands --- signduterre.py | 44 ++++++++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 12 deletions(-) diff --git a/signduterre.py b/signduterre.py index c35987e..48f6a62 100755 --- a/signduterre.py +++ b/signduterre.py @@ -71,10 +71,12 @@ Options:[[[/p]]][[[pre]]] (default True) -d, --detailed-view Print hashes of individual files, is unset by --total- only (default False) - -e, --execute Interpret ${ENV} and $(cmd) (default False) + -e, --execute Interpret $(cmd) (default False) --execute-args=ARGS Arguments for the $(cmd) commands ($1 ....) - -n, --no-execute Explicitely do NOT Interpret ${ENV} and $(cmd) - -m, --manual Print the manual and exit + -n, --no-execute Explicitely do NOT Interpret $(cmd) + --print-execute Print the results of $() command execution to STDERR + for debugging purposes + -m, --manual Print the manual and exit --manual-html Print the manual in HTML format and exit --manual-make Print the examples in the manual as a makefile and exit @@ -346,14 +348,25 @@ The next command will check all 20 passphrases generated before from the Signatu [[[/p]]][[[pre make=sudo]]] # # Check MBR and current root directory (sudo and root user) -$ sudo python signduterre.py -u root -s SUGGESTED -p SUGGESTED --Status-values='i' -v -e -t \\ ---output-file test-boot-sector.sdt --Private-file test-boot-sector.pwd \\ -'?/proc/self/root' `which dd` '$(dd if=/dev/hda bs=512 count=1 | od -X)' +$ sudo python3.0 signduterre.py -u root -s SUGGESTED -p SUGGESTED --Status-values='i' -v -e -t \\ +--output-file test-boot-sector.sdt --Private-file test-boot-sector.pwd --execute-args=sda \\ +'?/proc/self/root' `which dd` '$(dd if=/dev/$1 bs=512 count=1 status=noxfer | od -X)' +$ sudo python3.0 signduterre.py -u root -e -p test-boot-sector.pwd -c test-boot-sector.sdt [[[/pre]]][[[p]]] Will hash the inode numbers of the effective root directory (eg, chroot) and the executable (python) -together with the contents of the MBR (Master Boot Record) in Hex. It uses suggested salt and passphrase. -Accessing /dev/hda is only possible when root, so the command is entered with sudo and --user root. -[[[/p]]][[[/body]]][[[/html]]] +together with the contents of the MBR (Master Boot Record) on /dev/sda in Hex. It uses suggested salt and +passphrase. Accessing /dev/sda is only possible when root, so the command is entered with sudo and +--user root. Use the '--print-execute' option if you want to check the output of the dd command. +[[[/p]]][[[p]]] +The examples can be run as a makefile using make. Use one of the following commands: +[[[/p]]][[[pre]]] +# General examples +python3.0 signduterre.py --manual-make |make -f - example +# Linux specific examples +python3.0 signduterre.py --manual-make |make -f - linux +# Examples requiring sudo +python3.0 signduterre.py --manual-make | sudo make -f - sudo +[[[/pre]]][[[/body]]][[[/html]]] """ # license = """ @@ -500,13 +513,16 @@ parser.add_option("-d", "--detailed-view", help="Print hashes of individual files, is unset by --total-only (default False)") parser.add_option("-e", "--execute", dest="execute", default=False, action="store_true", - help="Interpret ${ENV} and $(cmd) (default False)") + help="Interpret $(cmd) (default False)") parser.add_option("--execute-args", dest="executeargs", default='', metavar="ARGS", help="Arguments for the $(cmd) commands ($1 ....)") parser.add_option("-n", "--no-execute", dest="noexecute", default=False, action="store_true", - help="Explicitely do NOT Interpret ${ENV} and $(cmd)") + help="Explicitely do NOT Interpret $(cmd)") +parser.add_option("--print-execute", + dest="printexecute", default=False, action="store_true", + help="Print the results of $() command execution to STDERR for debugging purposes") parser.add_option("-m", "--manual", dest="manual", default=False, action="store_true", help="Print the manual and exit") @@ -587,7 +603,9 @@ if options.manualmake: if category != previous_cat: previous_cat = category; print("\n"+previous_cat+":", file=sys.stdout); - print(commands); + print(commands, file=sys.stdout); + # Clean option + print("\nclean:\n\trm test-*.sdt test-*.pwd", file=sys.stdout); exit(0); # Print release notes if options.releasenotes: @@ -910,6 +928,8 @@ for my_passphrase in passphrase_list: if status != 0: print('$('+current_command+')'+"\n"+b, file=sys.stderr); exit(status); + elif options.printexecute: # For debugging commands + print(b, file=sys.stderr); match = re.search('^\$[\{]?([^\}\(\)]+)[\}]?$', filename); if match != None: current_var = not_allowed_chars.sub(" ", match.group(1)); -- 2.11.4.GIT