home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / etc / bash_completion.d / heimdal < prev    next >
Encoding:
Text File  |  2010-11-16  |  3.1 KB  |  134 lines

  1. # bash completion for heimdal
  2.  
  3. have ktutil && {
  4. _heimdal_principals()
  5. {
  6.  
  7.     COMPREPLY=( $( compgen -W "$( kadmin -l dump 2>/dev/null | \
  8.         awk '{print $1}' )" -- "$cur" ) )
  9. }
  10.  
  11. _heimdal_realms()
  12. {
  13.  
  14.     COMPREPLY=( $( compgen -W "( kadmin -l dump 2>/dev/null | \
  15.         awk '{print $1}' | awk -F@ '{print $2}' )" -- "$cur" ) )
  16. }
  17.  
  18. _heimdal_encodings()
  19. {
  20.  
  21.     COMPREPLY=( $( compgen -W 'des-cbc-mcrc des-cbc-md4 des-cbc-md5 \
  22.         des3-cbc-sha1 arcfour-hmac-md5 aes128-cts-hmac-sha1-96 \
  23.         aes256-cts-hmac-sha1-96' -- "$cur" ) )
  24. }
  25.  
  26. _ktutil()
  27. {
  28.     local cur prev command options split=false
  29.  
  30.     COMPREPLY=()
  31.     _get_comp_words_by_ref cur prev
  32.  
  33.     _split_longopt && split=true
  34.  
  35.     case $prev in
  36.         -p|--principal)
  37.             _heimdal_principals
  38.             return 0
  39.             ;;
  40.         -e|--enctype)
  41.             _heimdal_encodings
  42.             return 0
  43.             ;;
  44.         -a|--admin-server)
  45.             _known_hosts_real "$cur"
  46.             return 0
  47.             ;;
  48.         -r|--realm)
  49.             _heimdal_realms
  50.             return 0
  51.             ;;
  52.         -s|-k|--srvtab|--keytab)
  53.             _filedir
  54.             return 0
  55.             ;;
  56.     esac
  57.  
  58.     $split && return 0
  59.  
  60.     commands='add change copy get list remove rename purge srvconvert \
  61.         srv2keytab srvcreate key2srvtab'
  62.  
  63.     for (( i=1; i < COMP_CWORD; i++ )); do
  64.         case ${COMP_WORDS[i]} in
  65.             -k|--keytab)
  66.                 i=$(($i+1))
  67.                 ;;
  68.             -*)
  69.                 ;;
  70.             *)
  71.                 command=${COMP_WORDS[i]}
  72.                 break
  73.                 ;;
  74.         esac
  75.     done
  76.  
  77.     if [[ "$cur" == -* ]]; then
  78.         case $command in
  79.             add)
  80.                 options='-p --principal -V -e --enctype -w --password -r \
  81.                     --random -s --no-salt -h --hex'
  82.             ;;
  83.             change)
  84.                 options='-r --realm -a --admin-server -s --server-port'
  85.             ;;
  86.             get)
  87.                 options='-p --principal -e --enctype -r --realm -a \
  88.                     --admin-server -s server --server-port'
  89.                 ;;
  90.             list)
  91.                 options='--keys --timestamp'
  92.                 ;;
  93.             remove)
  94.                 options='-p --principal -V --kvno -e --enctype'
  95.                 ;;
  96.             purge)
  97.                 options='--age'
  98.                 ;;
  99.             srv2keytab|key2srvtab)
  100.                 options='-s --srvtab'
  101.                 ;;
  102.             *)
  103.                 options='-k --keytab -v --verbose --version -v --help'
  104.                 ;;
  105.         esac
  106.         COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
  107.     else
  108.         case $command in
  109.             copy)
  110.                 _filedir
  111.                 ;;
  112.             get)
  113.                 _heimdal_principals
  114.                 ;;
  115.             rename)
  116.                 _heimdal_principals
  117.                 ;;
  118.             *)
  119.                 COMPREPLY=( $( compgen -W "$commands" -- "$cur" ) )
  120.                 ;;
  121.         esac
  122.     fi
  123. }
  124. complete -F _ktutil ktutil
  125. }
  126.  
  127. # Local variables:
  128. # mode: shell-script
  129. # sh-basic-offset: 4
  130. # sh-indent-comment: t
  131. # indent-tabs-mode: nil
  132. # End:
  133. # ex: ts=4 sw=4 et filetype=sh
  134.