zuluCrypt  5.7.1
About: zuluCrypt is a simple but feature rich solution for hard drives encryption. It can manage PLAIN dm-crypt, LUKS, TrueCrypt and VeraCrypt encrypted volumes.
  Fossies Dox: zuluCrypt-5.7.1.tar.xz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

get_opts.c
Go to the documentation of this file.
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 
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 
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' ) :
112  stopts->action = 'A' ;
113  break ;
114  case( 'S' ) :
116  stopts->action = 'S' ;
117  break ;
118  case( 'N' ) :
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 }
struct_opts_1::tcrypt_multiple_keyfiles
const char * tcrypt_multiple_keyfiles[16+1]
Definition: libzuluCrypt-exe.h:54
struct_opts_1::tcrypt_hidden_volume_multiple_keyfiles
const char * tcrypt_hidden_volume_multiple_keyfiles[16+1]
Definition: libzuluCrypt-exe.h:53
struct_opts_1::type
const char * type
Definition: libzuluCrypt-exe.h:44
struct_opts_1::key
const char * key
Definition: libzuluCrypt-exe.h:42
struct_opts_1::partition_number
int partition_number
Definition: libzuluCrypt-exe.h:61
struct_opts_1::device
const char * device
Definition: libzuluCrypt-exe.h:37
struct_opts_1::open_mount
int open_mount
Definition: libzuluCrypt-exe.h:63
struct_opts_1::new_key
const char * new_key
Definition: libzuluCrypt-exe.h:48
struct_opts_1::plugin_path
const char * plugin_path
Definition: libzuluCrypt-exe.h:36
ZULUCRYPTnonSystemPartitions
#define ZULUCRYPTnonSystemPartitions
Definition: constants.h:33
ZULUCRYPTsystemPartitions
#define ZULUCRYPTsystemPartitions
Definition: constants.h:32
struct_opts_1::back_up_file_path
const char * back_up_file_path
Definition: libzuluCrypt-exe.h:55
struct_opts_1
Definition: libzuluCrypt-exe.h:35
struct_opts_1::key_source
const char * key_source
Definition: libzuluCrypt-exe.h:41
struct_opts_1::new_key_source
const char * new_key_source
Definition: libzuluCrypt-exe.h:49
struct_opts_1::fs
const char * fs
Definition: libzuluCrypt-exe.h:43
zuluCryptEXEGetOptsSetDefault
void zuluCryptEXEGetOptsSetDefault(struct_opts *stopts)
Definition: get_opts.c:24
struct_opts_1::existing_key
const char * existing_key
Definition: libzuluCrypt-exe.h:47
zuluCryptEXEGetOpts
void zuluCryptEXEGetOpts(int argc, char *argv[], struct_opts *stopts)
Definition: get_opts.c:46
struct_opts_1::tcrypt_hidden_volume_key
const char * tcrypt_hidden_volume_key
Definition: libzuluCrypt-exe.h:52
struct_opts_1::action
char action
Definition: libzuluCrypt-exe.h:60
struct_opts_1::ask_confirmation
int ask_confirmation
Definition: libzuluCrypt-exe.h:62
struct_opts_1::existing_key_source
const char * existing_key_source
Definition: libzuluCrypt-exe.h:46
struct_opts_1::uid
const char * uid
Definition: libzuluCrypt-exe.h:57
struct_opts_1::rng
const char * rng
Definition: libzuluCrypt-exe.h:45
struct_opts_1::share
int share
Definition: libzuluCrypt-exe.h:66
struct_opts_1::tcrypt_hidden_volume_size
const char * tcrypt_hidden_volume_size
Definition: libzuluCrypt-exe.h:51
struct_opts_1::luks_external_header
const char * luks_external_header
Definition: libzuluCrypt-exe.h:58
TRUECRYPT_MAX_KEYFILES
#define TRUECRYPT_MAX_KEYFILES
Definition: libzuluCrypt-exe.h:29
struct_opts_1::fs_opts
const char * fs_opts
Definition: libzuluCrypt-exe.h:40
ZULUCRYPTallPartitions
#define ZULUCRYPTallPartitions
Definition: constants.h:31
struct_opts_1::m_opts
const char * m_opts
Definition: libzuluCrypt-exe.h:39
struct_opts_1::mount_point
const char * mount_point
Definition: libzuluCrypt-exe.h:38
struct_opts_1::print_partition_type
int print_partition_type
Definition: libzuluCrypt-exe.h:65
includes.h
struct_opts_1::use_cryptsetup_for_bitlocker
int use_cryptsetup_for_bitlocker
Definition: libzuluCrypt-exe.h:67
zuluCryptPathIsValid
int zuluCryptPathIsValid(const char *path)
Definition: is_path_valid.c:23