Changeset 1253

Show
Ignore:
Timestamp:
09/28/08 18:02:20 (2 months ago)
Author:
mbr
Message:

minor update to validate command line args in a separate function, and added checks for --gpg-path

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • fwknop/trunk/fwknop

    r1251 r1253  
    243243### set LC_ALL env variable 
    244244$ENV{'LC_ALL'} = $locale unless $no_locale; 
    245  
    246 die "[*] Cannot run in both --quiet and --verbose modes simultaneously" 
    247     if $quiet and $verbose; 
    248  
    249 die "[*] Must also specify a GnuPG signing key with --gpg-signing-key or\n", 
    250     "    use --gpg-default-key to use a default key (specified in\n", 
    251     "    ~/.gnupg/options with the default-key variable).\n" 
    252     if ($gpg_recipient and (not $gpg_default_key and not $gpg_signing_key)); 
    253  
    254 die "[*] Must specify a GnuPG recipient key (on the fwknopd side) with\n", 
    255     "    --gpg-recipient" 
    256     if (($gpg_default_key or $gpg_signing_key) and not $gpg_recipient); 
    257  
    258 die "[*] Cannot assume a default key when --gpg-no-options is used." 
    259     if ($gpg_default_key and $gpg_no_options); 
    260  
    261 die "[*] Cannot spoof source address for a real TCP socket." 
    262     if ($spoof_src and $spa_established_tcp); 
    263  
    264 die "[*] Server auth method not supported in NAT access mode.\n" 
    265     if $server_auth_method and $NAT_access_str; 
    266245 
    267246&set_digest_type() if $cmdl_digest_alg; 
     
    16951674        'help'           => \$print_help 
    16961675    ); 
     1676 
     1677    ### run a few minor checks against the supplied args 
     1678    &validate_command_line(); 
     1679 
    16971680    return; 
    16981681} 
     
    19071890sub rand_port() { 
    19081891    return int(rand($max_port - $min_port)) + $min_port; 
     1892} 
     1893 
     1894sub validate_command_line() { 
     1895    die "[*] Cannot run in both --quiet and --verbose modes simultaneously" 
     1896        if $quiet and $verbose; 
     1897 
     1898    die "[*] Must also specify a GnuPG signing key with --gpg-signing-key or\n", 
     1899        "    use --gpg-default-key to use a default key (specified in\n", 
     1900        "    ~/.gnupg/options with the default-key variable).\n" 
     1901        if ($gpg_recipient and (not $gpg_default_key and not $gpg_signing_key)); 
     1902 
     1903    die "[*] Must specify a GnuPG recipient key (on the fwknopd side) with\n", 
     1904        "    --gpg-recipient" 
     1905        if (($gpg_default_key or $gpg_signing_key) and not $gpg_recipient); 
     1906 
     1907    die "[*] Cannot assume a default key when --gpg-no-options is used." 
     1908        if ($gpg_default_key and $gpg_no_options); 
     1909 
     1910    die "[*] Cannot spoof source address for a real TCP socket." 
     1911        if ($spoof_src and $spa_established_tcp); 
     1912 
     1913    die "[*] Server auth method not supported in NAT access mode.\n" 
     1914        if $server_auth_method and $NAT_access_str; 
     1915 
     1916    if ($gpg_path) { 
     1917        die "[*] $gpg_path does not exist." unless -e $gpg_path; 
     1918        die "[*] $gpg_path not executable." unless -x $gpg_path; 
     1919    } 
     1920    return; 
    19091921} 
    19101922