"Fossies" - the Fresh Open Source Software Archive

Member "zuluCrypt-5.7.1/zuluCrypt-cli/bin/get_opts.c" (15 Jan 2020, 5376 Bytes) of package /linux/misc/zuluCrypt-5.7.1.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "get_opts.c" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 5.7.0_vs_5.7.1.

    1 /*
    2  *
    3  *  Copyright ( c ) 2012-2015
    4  *  name : Francis Banyikwa
    5  *  email: mhogomchungu@gmail.com
    6  *  This program is free software: you can redistribute it and/or modify
    7  *  it under the terms of the GNU General Public License as published by
    8  *  the Free Software Foundation, either version 2 of the License, or
    9  *  ( at your option ) any later version.
   10  *
   11  *  This program is distributed in the hope that it will be useful,
   12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
   13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   14  *  GNU General Public License for more details.
   15  *
   16  *  You should have received a copy of the GNU General Public License
   17  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
   18  */
   19 
   20 #include "includes.h"
   21 #include <unistd.h>
   22 #include <stdio.h>
   23 
   24 void zuluCryptEXEGetOptsSetDefault( struct_opts * stopts )
   25 {
   26     static char random[] = "/dev/urandom" ;
   27     static char type[]   = "luks" ;
   28 
   29     memset( stopts,'\0',sizeof( struct_opts ) ) ;
   30 
   31     stopts->fs   = "ext4" ;
   32     stopts->rng  = random ;
   33     stopts->type = type ;
   34 
   35     stopts->open_mount = 1 ;
   36     stopts->ask_confirmation = 1 ;
   37 
   38     if( zuluCryptPathIsValid( "/etc/zuluCrypt/dislocker" ) ){
   39 
   40         stopts->use_cryptsetup_for_bitlocker = 0 ;
   41     }else{
   42         stopts->use_cryptsetup_for_bitlocker = 1 ;
   43     }
   44 }
   45 
   46 void zuluCryptEXEGetOpts( int argc,char * argv[],struct_opts * stopts )
   47 {
   48     int c ;
   49 
   50     int k = 0 ;
   51     int n = 0 ;
   52 
   53     zuluCryptEXEGetOptsSetDefault( stopts ) ;
   54 
   55     while ( ( c = getopt( argc,argv,"MHZCUWTJLORBXASNPkhocsarqwibEDs:m:d:p:f:e:Y:i:z:g:y:u:l:n:j:t:G:F:V:K:" ) ) != -1 ) {
   56 
   57         switch( c ){
   58 
   59             case( 'H' ) : stopts->action = 'H'  ; break ;
   60             case( 'C' ) : stopts->action = 'C'  ; break ;
   61             case( 'U' ) : stopts->action = 'U'  ; break ;
   62             case( 'W' ) : stopts->action = 'W'  ; break ;
   63             case( 'E' ) : stopts->action = 'E'  ; break ;
   64             case( 'D' ) : stopts->action = 'D'  ; break ;
   65             case( 'X' ) : stopts->action = 'X'      ; break ;
   66             case( 'J' ) : stopts->action = 'J'      ; break ;
   67             case( 'L' ) : stopts->action = 'L'      ; break ;
   68             case( 'o' ) : stopts->action = 'o'      ; break ;
   69             case( 'c' ) : stopts->action = 'c'      ; break ;
   70             case( 's' ) : stopts->action = 's'      ; break ;
   71             case( 'a' ) : stopts->action = 'a'      ; break ;
   72             case( 'r' ) : stopts->action = 'r'      ; break ;
   73             case( 'q' ) : stopts->action = 'q'      ; break ;
   74             case( 'w' ) : stopts->action = 'w'      ; break ;
   75             case( 'i' ) : stopts->action = 'i'      ; break ;
   76             case( 'b' ) : stopts->action = 'b'      ; break ;
   77             case( 'P' ) : stopts->action = 'P'      ; break ;
   78 
   79             case( 'O' ) :
   80                 stopts->action = 'O' ;
   81                 stopts->open_mount = 0 ;
   82                 break ;
   83             case( 'T' ) :
   84                 stopts->print_partition_type = 1 ;
   85                 break;
   86             case( 'M' ) :
   87                 stopts->share = 1 ;
   88                 break ;
   89             case( 'Z' ) :
   90                 stopts->print_partition_type = 2 ;
   91                 break;
   92             case( 'B' ) :
   93                 stopts->action = 'B' ;
   94                 stopts->key_source = optarg ;
   95                 break ;
   96             case( 'G' ) :
   97                 stopts->plugin_path = optarg ;
   98                 break ;
   99             case( 'R' ) :
  100                 stopts->action = 'R' ;
  101                 stopts->key_source = optarg ;
  102                 break ;
  103             case( 'k' ) :
  104                 stopts->ask_confirmation = 0 ;
  105                 break ;
  106             /*
  107              * ZULUCRYPTallPartitions,ZULUCRYPTsystemPartitions and ZULUCRYPTnonSystemPartitions
  108              * are set in ../constants.h
  109              */
  110             case( 'A' ) :
  111                 stopts->partition_number = ZULUCRYPTallPartitions ;
  112                 stopts->action = 'A' ;
  113                 break ;
  114             case( 'S' ) :
  115                 stopts->partition_number = ZULUCRYPTsystemPartitions ;
  116                 stopts->action = 'S' ;
  117                 break ;
  118             case( 'N' ) :
  119                 stopts->partition_number = ZULUCRYPTnonSystemPartitions ;
  120                 stopts->action = 'N' ;
  121                 break ;
  122             case( 't' ) :
  123                 stopts->type = optarg ;
  124                 break ;
  125             case( 'K' ) :
  126                 stopts->uid = optarg ;
  127                 break ;
  128             case( 'm' ) :
  129                 stopts->mount_point = optarg ;
  130                 break ;
  131             case( 'd' ) :
  132                 stopts->device = optarg ;
  133                 break ;
  134             case( 'p' ) :
  135                 stopts->key_source = "-p" ;
  136                 stopts->key = optarg ;
  137                 break ;
  138             case( 'F' ) :
  139                 if( k < TRUECRYPT_MAX_KEYFILES ){
  140                     /*
  141                     * TRUECRYPT_MAX_KEYFILES is set at libzuluCrypt-exe.h
  142                     */
  143                     stopts->tcrypt_multiple_keyfiles[ k ] = optarg ;
  144                     k++ ;
  145                 }
  146                 break ;
  147             case( 'f' ) :
  148                 stopts->key_source = "-f" ;
  149                 stopts->key = optarg ;
  150                 break ;
  151             case( 'e' ) :
  152                 stopts->m_opts = optarg ;
  153                 stopts->tcrypt_hidden_volume_size = optarg ;
  154                 break ;
  155             case( 'Y' ) :
  156                 stopts->fs_opts = optarg ;
  157                 break ;
  158             case( 'z' ) :
  159                 stopts->fs = optarg ;
  160                 stopts->back_up_file_path = optarg ;
  161                 stopts->luks_external_header = optarg ;
  162                 break ;
  163             case( 'g' ) :
  164                 stopts->rng = optarg ;
  165                 break ;
  166             case( 'y' ) :
  167                 stopts->existing_key_source = "-p" ;
  168                 stopts->existing_key = optarg ;
  169                 break ;
  170             case( 'u' ) :
  171                 stopts->existing_key_source = "-f" ;
  172                 stopts->existing_key = optarg ;
  173                 break ;
  174             case( 'V' ) :
  175                 if( n < TRUECRYPT_MAX_KEYFILES ){
  176                     /*
  177                     * TRUECRYPT_MAX_KEYFILES is set at libzuluCrypt-exe.h
  178                     */
  179                     stopts->tcrypt_hidden_volume_multiple_keyfiles[ n ] = optarg ;
  180                     n++ ;
  181                 }
  182             break ;
  183             case( 'l' ) :
  184                 stopts->new_key_source = "-p" ;
  185                 stopts->new_key = optarg ;
  186                 stopts->tcrypt_hidden_volume_key = optarg ;
  187                 break ;
  188             case( 'n' ) :
  189                 stopts->new_key_source = "-f" ;
  190                 stopts->new_key = optarg ;
  191                 break ;
  192             default: printf( "run zuluCrypt-cli --help for help\n" ) ;
  193         }
  194     }
  195 }