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)  

main.c
Go to the documentation of this file.
1 /*
2  *
3  * Copyright ( c ) 2011-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 "../lib/includes.h"
22 #include "../lib/libzuluCrypt.h"
23 #include <signal.h>
24 #include <sys/resource.h>
25 #include <locale.h>
26 #include <libintl.h>
27 #include <locale.h>
28 #include <stdio.h>
29 #include <sys/types.h>
30 #include <unistd.h>
31 #include <grp.h>
32 
33 static void _seteuid( uid_t uid )
34 {
35  if( seteuid( uid ) ){;}
36 }
37 
38 static void _setuid( uid_t uid )
39 {
40  if( setuid( uid ) ){;}
41 }
42 
43 static int zuluCryptEXEGetDevice( const char * device )
44 {
45  /*
46  * zuluCryptVolumeDeviceName() is defined in ../lib/status.c
47  */
48  char * c = NULL ;
49  int st = 1 ;
50 
52  /*
53  * zuluCryptVolumeDeviceName() is defined in ../lib/status.c
54  */
55  c = zuluCryptVolumeDeviceName( device ) ;
56 
58 
59  if( c == NULL ){
60 
61  printf( gettext( "ERROR: Could not get device address from mapper address\n" ) ) ;
62  st = 1 ;
63  }else{
64  printf( "%s\n",c ) ;
65  StringFree( c ) ;
66  st = 0 ;
67  }
68 
69  return st ;
70 }
71 
72 static int zuluCryptEXECheckIfLuks( const char * device )
73 {
74  int status ;
75 
76  char * e ;
77 
79  /*
80  * this zuluCryptVolumeIsLuks() is defined in ../lib/is_luks.c
81  */
82  status = zuluCryptVolumeIsLuks( device ) ;
83 
84  /*
85  * zuluCryptUUIDFromPath_1() is defined in ../lib/blkid_evaluate_tag.c
86  */
87  e = zuluCryptUUIDFromPath_1( device ) ;
88 
90 
91  if( status ){
92 
93  printf( gettext( "Device is a luks volume\n" ) ) ;
94 
95  if( e ){
96 
97  printf( "%s %s\n",gettext( "Its UUID is:" ),e ) ;
98  }
99  }else{
100  printf( gettext( "Device is not a luks volume\n" ) ) ;
101  }
102 
103  StringFree( e ) ;
104 
105  return status ;
106 }
107 
108 static int zuluCryptEXECheckIfTcrypt( struct_opts * clargs,uid_t uid )
109 {
110  string_t st_key = StringVoid ;
111 
112  const char * device = clargs->device ;
113  const char * key = clargs->key ;
114  const char * source = clargs->key_source ;
115 
116  size_t key_len ;
117 
118  int st = 1 ;
119 
120  if( key == NULL ){
121 
122  printf( gettext( "ERROR: Key argument is missing\n" ) ) ;
123  return 1 ;
124  }
125  if( source == NULL ){
126 
127  printf( gettext( "ERROR: Key source argument is missing\n" ) ) ;
128  return 1 ;
129  }
130  if( StringsAreEqual( source,"-p" ) ){
131 
133 
134  /*
135  * zuluCryptGetVolumeType() is defined in ../lib/volume_type.c
136  */
137 
138  if( zuluCryptGetVolumeType( device,key,strlen( key ) ) == 2 ){
139 
140  printf( gettext( "\"%s\" is a tcrypt device\n" ),device ) ;
141  st = 0 ;
142  }
143 
145 
146  }else if( StringsAreEqual( source,"-f" ) ){
147  /*
148  * zuluCryptGetPassFromFile() is defined in path_access.c
149  */
150  if( zuluCryptGetPassFromFile( NULL,key,uid,&st_key ) == 0 ){
151 
152  key = StringContent( st_key ) ;
153  key_len = StringLength( st_key ) ;
155 
156  if( zuluCryptGetVolumeType( device,key,key_len ) == 2 ){
157 
158  printf( gettext( "\"%s\" is a tcrypt device\n" ),device ) ;
159  st = 0 ;
160  }else{
161  printf( gettext( "\"%s\" is a not tcrypt device\n" ),device ) ;
162  st = 1 ;
163  }
164  StringDelete( &st_key ) ;
166  }else{
167  printf( gettext( "\"%s\" is not a tcrypt device\n"),device ) ;
168  st = 1 ;
169  }
170  }else{
171  /*
172  * shouldnt get here
173  */
174  printf( gettext( "\"%s\" is not a tcrypt device\n" ),device ) ;
175  st = 1 ;
176  }
177 
178  return st ;
179 }
180 
181 static int zuluCryptEXECheckEmptySlots( const char * device )
182 {
183  int status ;
184  char * c ;
186  /*
187  * zuluCryptEmptySlots() is defined in ../lib/empty_slots.c
188  */
189  c = zuluCryptEmptySlots( device ) ;
190 
192 
193  if( c == NULL ){
194 
195  printf( gettext( "Device \"%s\" is not a luks device\n" ),device ) ;
196  status = 2 ;
197  }else{
198  printf( "%s\n",c ) ;
199  status = 0 ;
200  free( c ) ;
201  }
202 
203  return status ;
204 }
205 
206 static int zuluCryptEXECheckUUID( const char * device )
207 {
208  printf( "%s\n",device ) ;
209  return 0 ;
210 }
211 
212 static int zuluCryptEXEHeaderMatchBackUpHeader( const char * device,const char * header_backup,uid_t uid )
213 {
214  /*
215  * zuluCryptPartitionIsSystemPartition() is defined in partitions.c
216  */
217  int r = zuluCryptPartitionIsSystemPartition( device,uid ) ;
218 
219  if( r == 1 ){
220 
221  if( uid != 0 || !zuluCryptUserIsAMemberOfAGroup( uid,"zulucrypt" ) ){
222 
223  printf( gettext( "ERROR: Insufficient privilges to operate on a system device\n" ) ) ;
224  return 1 ;
225  }
226  }
227  /*
228  * zuluCryptHeaderMatchBackUpHeader() is defined in save_and_restore_luks_header.c
229  */
230  r = zuluCryptHeaderMatchBackUpHeader( device,header_backup,uid ) ;
231 
232  if( r ){
233  printf( gettext( "Header backup match the one on the device\n" ) ) ;
234  return 0 ;
235  }else{
236  printf( gettext( "Header backup does not match the one on the device\n" ) ) ;
237  return 1 ;
238  }
239 }
240 
241 static int zuluCryptEXE( struct_opts * clargs,const char * mapping_name,uid_t uid )
242 {
243  switch( clargs->action ){
244 
245  case 'H' : return zuluCryptEXEHeaderMatchBackUpHeader( clargs->device,clargs->key,uid ) ;
246  case 'W' : return zuluCryptEXECheckIfTcrypt( clargs,uid ) ;
247  case 'B' : return zuluCryptEXESaveAndRestoreVolumeHeader( clargs,uid,VOLUME_HEADER_SAVE ) ;
248  case 'R' : return zuluCryptEXESaveAndRestoreVolumeHeader( clargs,uid,VOLUME_HEADER_RESTORE ) ;
249  case 'J' : return zuluCryptEXEOpenPlainAsMe( clargs,mapping_name,uid ) ; /* function is defined in write_device_with_junk.c */
250  case 'X' : return zuluCryptEXEWriteDeviceWithJunk( clargs,mapping_name,uid ) ;
251  case 'w' : return zuluCryptEXECheckUUID( clargs->device ) ;
252  case 'b' : return zuluCryptEXECheckEmptySlots( clargs->device ) ;
253  case 'i' : return zuluCryptEXECheckIfLuks( clargs->device ) ;
254  case 'P' : return zuluCryptEXEGetDevice( clargs->device ) ;
255  case 's' : return zuluCryptEXEVolumeInfo( mapping_name,clargs->device,uid ) ;
256  case 'q' : return zuluCryptEXECloseVolume( clargs->device,mapping_name,uid ) ;
257  case 'o' : return zuluCryptEXEOpenVolume( clargs,mapping_name,uid ) ;
258  case 'O' : return zuluCryptEXEOpenVolume( clargs,mapping_name,uid ) ;
259  case 'c' : return zuluCryptEXECreateVolume( clargs,mapping_name,uid ) ;
260  case 'a' : return zuluCryptEXEAddKey( clargs,uid ) ;
261  case 'r' : return zuluCryptEXERemoveKey( clargs,uid );
262  case 'E' : return zuluCryptExeFileEncrypt( clargs,uid ) ;
263  case 'D' : return zuluCryptExeFileDecrypt( clargs,uid ) ;
264  }
265 
266  printf( gettext( "ERROR!!!!!!!!!!: cli option missed!\n" ) ) ;
267  return 200 ; /* shouldnt get here */
268 }
269 
270 static int zuluExit( int st,stringList_t stl,stringList_t stx,char * const * env,const char * msg )
271 {
273  StringListClearDelete( &stl ) ;
274  StringListDelete( &stx ) ;
275 
276  if( env != NULL ){
277 
278  StringFree( env ) ;
279  }
280  if( msg != NULL ){
281 
282  printf( "%s\n",msg ) ;
283  }
284  return st ;
285 }
286 
287 static void ExitOnMemoryExaustion( void )
288 {
289  printf( gettext( "Unexpected exiting because you have run out of memory\n" ) ) ;
290  exit( 1 ) ;
291 }
292 
293 static int _print_uuid_from_path( const char * device )
294 {
295  /*
296  * zuluCryptSecurityUUIDFromPath() is defined in path_access.c
297  */
298  char * e = zuluCryptUUIDFromPath( device ) ;
299 
300  if( e == NULL ){
301 
302  puts( "UUID=\"Nil\"" ) ;
303  return 1 ;
304  }else{
305  printf( "UUID=\"%s\"\n",e ) ;
306  StringFree( e ) ;
307  return 0 ;
308  }
309 }
310 
311 static void _privilegeEvelationError( const char * msg )
312 {
313  perror( msg ) ;
314  exit( 255 ) ;
315 }
316 
317 static void _forceTerminateOnSeriousError( int sig )
318 {
319  if( sig ){;}
320  puts( "SIGSEGV caught,exiting" ) ;
321  exit( 255 ) ;
322 }
323 
324 static int _clear_dead_mappers( uid_t uid )
325 {
326  /*
327  * zuluCryptClearDeadMappers() is defined in ../zuluCrypt-cli/bin/clear_dead_mappers.c
328  */
329  zuluCryptClearDeadMappers( uid,0 ) ;
330  return 0 ;
331 }
332 
333 static int _printOpenedVolumes( uid_t uid )
334 {
335  /*
336  * zuluCryptOpenedVolumesList() is defined in ../lib/process_mountinfo.c
337  */
338  stringList_t stl ;
339 
341 
342  stl = zuluCryptOpenedVolumesList( uid ) ;
343 
345 
346  StringListPrintList( stl ) ;
347 
348  StringListDelete( &stl ) ;
349 
350  return 0 ;
351 }
352 
353 int main( int argc,char * argv[] )
354 {
355  int fd1 = -1 ;
356  int fd = -1;
357  const char * device ;
358  const char * mapping_name ;
359  char * ac ;
360  char * ac_1 ;
361  char * dev ;
362  char action ;
363  int st ;
364  char * const * env = NULL ;
365  ssize_t i ;
366 
367  string_t q = StringVoid ;
368 
371 
372  struct_opts clargs ;
373 
374  uid_t uid = getuid() ;
375  gid_t gid = uid ;
376 
377  struct sigaction sa ;
378  memset( &sa,'\0',sizeof( struct sigaction ) ) ;
379  sa.sa_handler = _forceTerminateOnSeriousError ;
380  sigaction( SIGSEGV,&sa,NULL ) ;
381 
383 
384  /*
385  * zuluCryptDisableMetadataLocking() is defined in ../lib/create_luks.c
386  */
388 
389  if( argc >= 2 && StringsAreEqual( argv[ 1 ],"--test" ) ){
390 
391  /*
392  * zuluCryptRunTest() is defined in test.c
393  */
394  return zuluCryptRunTest() ;
395  }
396 
397  /*
398  * setgroups() requires seteuid(0) ;
399  */
400  _seteuid( 0 ) ;
401 
402  if( setgroups( 1,&gid ) != 0 ){
403 
404  _privilegeEvelationError( gettext( "ERROR: setgroups() failed" ) ) ;
405  }
406  if( setegid( uid ) != 0 ){
407 
408  _privilegeEvelationError( gettext( "ERROR: setegid() failed" ) ) ;
409  }
410 
411  setlocale( LC_ALL,"" );
412  bindtextdomain( "zuluCrypt-cli",TRANSLATION_PATH ) ;
413  textdomain( "zuluCrypt-cli" ) ;
414 
415  memset( &clargs,'\0',sizeof( struct_opts ) ) ;
416 
417  /*
418  * zuluCryptEXEGetOpts() is defined in ./get_opts.c
419  */
420  zuluCryptEXEGetOpts( argc,argv,&clargs ) ;
421 
422  /*
423  * zuluCryptSecurityConvertUID() is defined in security.c
424  */
425  st = zuluCryptSecurityConvertUID( uid,clargs.uid ) ;
426 
427  if( st == -1 ){
428 
429  printf( gettext( "User is not root\n" ) ) ;
430  return 114 ;
431  }else{
432  uid = st ;
433  }
434 
435  /*
436  * Run with higher priority to speed things up
437  */
438  setpriority( PRIO_PROCESS,0,-15 ) ;
439 
440  _setuid( 0 ) ;
441  _seteuid( uid ) ;
442 
443  /*
444  * zuluCryptSetUserUIDForPrivilegeManagement() is defined in ./security.c
445  */
447 
448  /*
449  * zuluCryptSecuritySetPrivilegeElevationErrorFunction() is defined in ./security.c
450  * _privilegeEvelationError() function will be called when functions that elevate or drop privilges fail
451  */
453 
458 
459  /*
460  * zuluCryptSecurityDropElevatedPrivileges() is defined in ./security.c
461  */
463 
464  if( argc == 1 ){
465 
467  return 1;
468  }
469  if( argc == 2 ){
470 
471  ac = argv[ 1 ] ;
472 
473  if( StringAtLeastOneMatch_1( ac,"-h","--help","-help",NULL ) ){
474 
476 
477  return 0 ;
478  }
479  if( StringAtLeastOneMatch_1( ac,"-v","-version","--version",NULL ) ){
480 
481  printf( "%s\n",zuluCryptVersion() );
482 
483  return 0 ;
484  }
485  if( StringsAreEqual( ac,"--clear-dead-mount-points" ) ){
486 
487  zuluCryptClearDeadMappers( uid,1 ) ;
488  return 0 ;
489  }
490  }
491 
492  /*
493  * this object is used as a form of memory management.It collects all string objects to make them easily deletable
494  * at the end of the function and allows a function to have easily managebale multiple exit points.
495  */
496  stl = StringListInit() ;
497 
498  /*
499  * zuluCryptSecuritySanitizeTheEnvironment() is defined in ./security.c
500  */
502 
503  /*
504  * clargs.env contains a copy of the inherited environment because the above function clears it because we dont need it.
505  * The copy will ultimately be passed to a plugin architecture system just in case a plugin needs it.
506  *
507  * The plugin system is managed by code in ../pluginManager/zuluCryptPluginManager.c
508  *
509  */
510  clargs.env = env = StringListStringArray( stx ) ;
511 
512  q = StringListAssignString( stl,String( "" ) ) ;
513 
514  if( argc > 0 ){
515 
516  while( *argv ){
517 
518  StringMultipleAppend( q,*argv," ",NULL ) ;
519 
520  argv++ ;
521  }
522  StringSubChar( q,StringLength( q ) - 1,'\0' ) ;
523  }
524 
525  clargs.argv = StringListContentAtFirstPlace( stl ) ;
526 
527  /*
528  * Hide "sensitive" command line arguments from ps comamnd and related tools.
529  * Best way to pass keys to zuluCrypt-cli is to use libzuluCryptPluginManager API
530  */
531  #define hide( z ) strncpy( ( char * )z,"x",StringLength( q ) ) ;
532 
533  if( clargs.key != NULL ){
534 
535  q = StringListAssignString( stl,String( clargs.key ) ) ;
536  hide( clargs.key ) ;
537  clargs.key = StringContent( q ) ;
538  }
539  if( clargs.new_key != NULL ){
540 
541  q = StringListAssignString( stl,String( clargs.new_key ) ) ;
542  hide( clargs.new_key ) ;
543  clargs.new_key = StringContent( q ) ;
544  clargs.tcrypt_hidden_volume_key = clargs.new_key ;
545  }
546  if( clargs.existing_key != NULL ){
547 
548  q = StringListAssignString( stl,String( clargs.existing_key ) ) ;
549  hide( clargs.existing_key ) ;
550  clargs.existing_key = StringContent( q ) ;
551  }
552  if( clargs.device != NULL ){
553 
554  q = StringListAssignString( stl,String( clargs.device ) ) ;
555  hide( clargs.device ) ;
556  clargs.device = StringContent( q ) ;
557  }
558  if( clargs.type != NULL ){
559 
560  q = StringListAssignString( stl,String( clargs.type ) ) ;
561  hide( clargs.type ) ;
562  clargs.type = StringContent( q ) ;
563  }
564  if( clargs.rng != NULL ){
565 
566  q = StringListAssignString( stl,String( clargs.rng ) ) ;
567  hide( clargs.rng ) ;
568  clargs.rng = StringContent( q ) ;
569  }
570  for( i = 0 ; clargs.tcrypt_multiple_keyfiles[ i ] != NULL ; i++ ){
571 
572  q = StringListAssignString( stl,String( clargs.tcrypt_multiple_keyfiles[ i ] ) ) ;
573  hide( clargs.tcrypt_multiple_keyfiles[ i ] ) ;
574  clargs.tcrypt_multiple_keyfiles[ i ] = StringContent( q ) ;
575  }
576 
577  for( i = 0 ; clargs.tcrypt_hidden_volume_multiple_keyfiles[ i ] != NULL ; i++ ){
578 
582  }
583 
585 
586  action = clargs.action ;
587  device = clargs.device ;
588 
589  if( action == 'C' ){
590 
591  return zuluExit( _clear_dead_mappers( uid ),stl,stx,env,NULL ) ;
592  }else{
593  _clear_dead_mappers( uid ) ;
594  }
595 
596  /*
597  * below tests are here because they do not use -d option
598  *
599  * zuluCryptPrintPartitions() function is defined in volumes.c
600  * zuluCryptSecurityCheckPartitionPermissions() is defined in security.c
601  */
602  switch( action ){
603 
604  case 'A':
605  case 'N':
606  case 'S': st = zuluCryptPrintPartitions( clargs.partition_number,clargs.print_partition_type,uid ) ;
607  return zuluExit( st,stl,stx,env,NULL ) ;
608  case 'L': st = _printOpenedVolumes( uid ) ;
609  return zuluExit( st,stl,stx,env,NULL ) ;
610  }
611 
612  if( action == '\0' ){
613 
614  return zuluExit( 130,stl,stx,env,gettext( "ERROR: \"action\" argument is missing" ) ) ;
615  }
616  if( device == NULL ){
617 
618  return zuluExit( 120,stl,stx,env,gettext( "ERROR: Required option( device path ) is missing for this operation" ) ) ;
619  }
620  if( action == 'U' ){
621 
622  st = _print_uuid_from_path( device ) ;
623  return zuluExit( st,stl,stx,env,NULL ) ;
624  }
625  if( StringPrefixEqual( device,"UUID=" ) ){
626 
627  q = String( device ) ;
628  StringRemoveString( q,"\"" ) ;
629  StringSubChar( q,4,'-' ) ;
630 
631  mapping_name = StringContent( q ) ;
632 
633  /*
634  * zuluCryptEvaluateDeviceTags() is defined in path_access.c
635  */
636  ac = zuluCryptEvaluateDeviceTags( "UUID",mapping_name + 5 ) ;
637 
638  if( ac != NULL ) {
639 
640  clargs.device = ac ;
641  st = zuluCryptEXE( &clargs,mapping_name,uid ) ;
642  StringFree( ac ) ;
643  StringDelete( &q ) ;
644  return zuluExit( st,stl,stx,env,NULL ) ;
645  }else{
646  StringDelete( &q ) ;
647  return zuluExit( 110,stl,stx,env,gettext( "ERROR: Could not find any partition with the presented UUID" ) ) ;
648  }
649  }else{
650  /*
651  * this function is defined in ../zuluCrypt-lib/file_path_security.c
652  */
653  switch( zuluCryptGetDeviceFileProperties( device,&fd,&fd1,&dev,uid ) ){
654 
655  case 0 : break ;
656  case 1 : return zuluExit( 111,stl,stx,env,gettext( "ERROR: Devices in /dev/shm/ path is not suppored" ) ) ;
657  case 2 : return zuluExit( 112,stl,stx,env,gettext( "ERROR: Given path is a directory" ) ) ;
658  case 3 : return zuluExit( 113,stl,stx,env,gettext( "ERROR: A file can have only one hard link" ) ) ;
659  case 4 : return zuluExit( 113,stl,stx,env,gettext( "ERROR: Insufficient privilges to access the device" ) ) ;
660  default: return zuluExit( 113,stl,stx,env,gettext( "ERROR: A non supported device encountered,device is missing or permission denied\n\
661 Possible reasons for getting the error are:\n1.Device path is invalid.\n2.The device has LVM or MDRAID signature" ) ) ;
662  }
663 
664  if( dev == NULL ){
665 
666  if( fd1 != -1 ){
667 
668  close( fd1 ) ;
669  }
670  if( fd != -1 ){
671 
672  close( fd ) ;
673  }
674  return zuluExit( 114,stl,stx,env,gettext( "ERROR: Could not resolve path to device" ) ) ;
675  }else{
676  q = String( "/dev/mapper/zuluCrypt-" ) ;
677 
678  StringAppendInt( q,uid ) ;
679  StringAppend( q,"-" ) ;
680 
681  st = StringPrefixMatch( dev,StringContent( q ),StringLength( q ) ) ;
682 
683  StringDelete( &q ) ;
684 
685  if( st && clargs.action == 'P' ){
686 
687  return zuluCryptEXEGetDevice( clargs.device ) ;
688  }
689 
690  /*
691  * zuluCryptDeviceIsSupported() is defined in partitions.c
692  */
693  if( zuluCryptDeviceIsSupported( dev,uid ) ){
694 
695  clargs.device = dev ;
696 
697  if( StringPrefixEqual( dev,"/dev/loop" ) ){
698 
699  /*
700  * zuluCryptLoopDeviceAddress_1() is defined in ../zuluCrypt-cli/create_loop_device.c
701  */
702  ac_1 = zuluCryptLoopDeviceAddress_1( dev ) ;
703 
704  i = StringLastIndexOfChar_1( ac_1,'/' ) ;
705 
706  if( i != -1 ){
707 
708  mapping_name = ac_1 + i + 1 ;
709  }else{
710  mapping_name = dev ;
711  }
712 
713  st = zuluCryptEXE( &clargs,mapping_name,uid ) ;
714  StringFree( ac_1 ) ;
715  }else{
716  i = StringLastIndexOfChar_1( dev,'/' ) ;
717 
718  if( i != -1 ){
719 
720  mapping_name = dev + i + 1 ;
721  }else{
722  mapping_name = dev ;
723  }
724 
725  st = zuluCryptEXE( &clargs,mapping_name,uid ) ;
726  }
727  }else{
728  st = 113 ;
729  puts( gettext( "ERROR: A non supported device encountered,device is missing or permission denied\n\
730 Possible reasons for getting the error are:\n1.Device path is invalid.\n2.The device has LVM or MDRAID signature" ) ) ;
731  }
732 
733  StringFree( dev ) ;
734 
735  if( fd1 != -1 ){
736 
737  close( fd1 ) ;
738  }
739  if( fd != -1 ){
740 
741  close( fd ) ;
742  }
743  return zuluExit( st,stl,stx,env,NULL ) ;
744  }
745  }
746 }
zuluCryptEXECheckEmptySlots
static int zuluCryptEXECheckEmptySlots(const char *device)
Definition: main.c:181
zuluCryptEXECheckIfLuks
static int zuluCryptEXECheckIfLuks(const char *device)
Definition: main.c:72
struct_opts_1::tcrypt_multiple_keyfiles
const char * tcrypt_multiple_keyfiles[16+1]
Definition: libzuluCrypt-exe.h:54
StringListVoid
#define StringListVoid
Definition: StringList.h:41
zuluCryptEXEGetDevice
static int zuluCryptEXEGetDevice(const char *device)
Definition: main.c:43
StringAppendInt
const char * StringAppendInt(string_t st, u_int64_t z)
Definition: String.c:1410
ProcessExitOnMemoryExaustion
void ProcessExitOnMemoryExaustion(void(*f)(void))
Definition: process.c:62
SocketExitOnMemoryExaustion
void SocketExitOnMemoryExaustion(void(*f)(void))
Definition: socket.c:57
_setuid
static void _setuid(uid_t uid)
Definition: main.c:38
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::argv
const char * argv
Definition: libzuluCrypt-exe.h:50
struct_opts_1::type
const char * type
Definition: libzuluCrypt-exe.h:44
zuluCryptEvaluateDeviceTags
char * zuluCryptEvaluateDeviceTags(const char *tag, const char *path)
Definition: path_access.c:175
zuluCryptDisableMetadataLocking
void zuluCryptDisableMetadataLocking(void)
Definition: create_luks.c:423
StringSubChar
const char * StringSubChar(string_t st, size_t x, char s)
Definition: String.c:881
struct_opts_1::key
const char * key
Definition: libzuluCrypt-exe.h:42
tcplay_opts::dev
const char * dev
Definition: tcplay.h:194
StringListAssignString
string_t StringListAssignString(stringList_t stl, string_t st)
Definition: StringList.c:268
zuluCryptPrintPartitions
int zuluCryptPrintPartitions(int option, int info, uid_t uid)
Definition: volumes.c:972
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
StringLength
size_t StringLength(string_t st)
Definition: String.c:678
zuluCryptEXEOpenPlainAsMe
int zuluCryptEXEOpenPlainAsMe(const struct_opts *opts, const char *mapping_name, uid_t uid)
Definition: write_device_with_junk.c:252
StringListContentAtFirstPlace
static const __inline__ char * StringListContentAtFirstPlace(stringList_t stl)
Definition: StringList.h:182
struct_opts_1::new_key
const char * new_key
Definition: libzuluCrypt-exe.h:48
_seteuid
static void _seteuid(uid_t uid)
Definition: main.c:33
zuluCryptExeSetOriginalUID
void zuluCryptExeSetOriginalUID(uid_t s)
Definition: security.c:54
zuluCryptLoopDeviceAddress_1
char * zuluCryptLoopDeviceAddress_1(const char *device)
Definition: create_loop_device.c:140
struct_opts_1
Definition: libzuluCrypt-exe.h:35
hide
#define hide(z)
struct_opts_1::key_source
const char * key_source
Definition: libzuluCrypt-exe.h:41
StringListInit
stringList_t StringListInit(void)
Definition: StringList.c:293
zuluCryptUserIsAMemberOfAGroup
int zuluCryptUserIsAMemberOfAGroup(uid_t uid, const char *groupname)
Definition: mount_fs_options.c:172
zuluCryptEXEOpenVolume
int zuluCryptEXEOpenVolume(const struct_opts *, const char *mapping_name, uid_t uid)
Definition: open_volume.c:254
StringListDelete
void StringListDelete(stringList_t *stl)
Definition: StringList.c:1184
zuluCryptEXERemoveKey
int zuluCryptEXERemoveKey(const struct_opts *, uid_t)
Definition: remove_key.c:95
zuluExit
static int zuluExit(int st, stringList_t stl, stringList_t stx, char *const *env, const char *msg)
Definition: main.c:270
_forceTerminateOnSeriousError
static void _forceTerminateOnSeriousError(int sig)
Definition: main.c:317
StringMultipleAppend
const char * StringMultipleAppend(string_t st,...)
Definition: String.c:1123
zuluCryptEXEWriteDeviceWithJunk
int zuluCryptEXEWriteDeviceWithJunk(const struct_opts *opts, const char *mapping_name, uid_t uid)
Definition: write_device_with_junk.c:263
StringsAreEqual
#define StringsAreEqual(x, y)
Definition: zuluSafe.c:46
zuluCryptEXEVolumeInfo
int zuluCryptEXEVolumeInfo(const char *mapper, const char *device, uid_t)
Definition: volume_info.c:26
struct_opts_1::existing_key
const char * existing_key
Definition: libzuluCrypt-exe.h:47
zuluCryptOpenedVolumesList
stringList_t zuluCryptOpenedVolumesList(uid_t)
Definition: mountinfo.c:210
StringRemoveString
const char * StringRemoveString(string_t st, const char *s)
Definition: String.c:1328
zuluCryptUUIDFromPath_1
char * zuluCryptUUIDFromPath_1(const char *device)
Definition: blkid_evaluate_tag.c:62
_print_uuid_from_path
static int _print_uuid_from_path(const char *device)
Definition: main.c:293
zuluCryptVersion
const char * zuluCryptVersion(void)
Definition: version.c:22
zuluCryptUUIDFromPath
char * zuluCryptUUIDFromPath(const char *device)
Definition: path_access.c:197
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
zuluCryptVolumeDeviceName
char * zuluCryptVolumeDeviceName(const char *)
Definition: status.c:895
StringAtLeastOneMatch_1
int StringAtLeastOneMatch_1(const char *x,...)
Definition: String.c:1504
StringContent
static const __inline__ char * StringContent(string_t st)
Definition: String.h:1011
zuluCryptEXECloseVolume
int zuluCryptEXECloseVolume(const char *dev, const char *mapping_name, uid_t uid)
Definition: close_volume.c:50
StringType
Definition: String.c:49
zuluCryptSecurityDropElevatedPrivileges
int zuluCryptSecurityDropElevatedPrivileges(void)
Definition: security.c:109
StringListPrintList
void StringListPrintList(stringList_t stl)
Definition: StringList.c:1352
zuluCryptEXESaveAndRestoreVolumeHeader
int zuluCryptEXESaveAndRestoreVolumeHeader(const struct_opts *opts, uid_t uid, int option)
Definition: save_and_restore_volume_header.c:612
zuluCryptGetVolumeType
int zuluCryptGetVolumeType(const char *device, const char *pass, size_t pass_size)
Definition: volume_type.c:39
main
int main(int argc, char *argv[])
Definition: main.c:268
zuluCryptVolumeIsLuks
int zuluCryptVolumeIsLuks(const char *device)
Definition: is_luks.c:45
StringLastIndexOfChar_1
static __inline__ ssize_t StringLastIndexOfChar_1(const char *str, char s)
Definition: String.h:982
String
string_t String(const char *cstring)
Definition: String.c:318
StringPrefixMatch
static __inline__ int StringPrefixMatch(const char *x, const char *y, size_t z)
Definition: String.h:878
VOLUME_HEADER_SAVE
#define VOLUME_HEADER_SAVE
Definition: includes.h:48
zuluCryptSecurityUnlockMemory
void zuluCryptSecurityUnlockMemory(stringList_t stl)
Definition: security.c:229
VOLUME_HEADER_RESTORE
#define VOLUME_HEADER_RESTORE
Definition: includes.h:47
zuluCryptSetUserUIDForPrivilegeManagement
void zuluCryptSetUserUIDForPrivilegeManagement(uid_t uid)
Definition: security.c:97
siritask::status
status
Definition: siritask.h:114
struct_opts_1::uid
const char * uid
Definition: libzuluCrypt-exe.h:57
zuluCryptEXE
static int zuluCryptEXE(struct_opts *clargs, const char *mapping_name, uid_t uid)
Definition: main.c:241
zuluCryptSecurityGainElevatedPrivileges
int zuluCryptSecurityGainElevatedPrivileges(void)
Definition: security.c:64
struct_opts_1::rng
const char * rng
Definition: libzuluCrypt-exe.h:45
zuluCryptSecurityConvertUID
int zuluCryptSecurityConvertUID(uid_t uid, const char *u_id)
Definition: security.c:81
zuluCryptEXEAddKey
int zuluCryptEXEAddKey(const struct_opts *opts, uid_t uid)
Definition: add_key.c:244
zuluCryptEXECheckUUID
static int zuluCryptEXECheckUUID(const char *device)
Definition: main.c:206
ExitOnMemoryExaustion
static void ExitOnMemoryExaustion(void)
Definition: main.c:287
zuluCryptSecuritySanitizeTheEnvironment
void zuluCryptSecuritySanitizeTheEnvironment(uid_t uid, stringList_t *stx)
Definition: security.c:124
zuluCryptEXEHelp
void zuluCryptEXEHelp(void)
Definition: help.c:29
StringListType
Definition: StringList.c:33
zuluCryptEXECreateVolume
int zuluCryptEXECreateVolume(const struct_opts *opts, const char *mapping_name, uid_t uid)
Definition: create_volumes.c:80
StringListStringArray
char *const * StringListStringArray(stringList_t stl)
Definition: StringList.c:908
_clear_dead_mappers
static int _clear_dead_mappers(uid_t uid)
Definition: main.c:324
e
static QString e
Definition: about.cpp:31
zuluCryptSecurityLockMemory
void zuluCryptSecurityLockMemory(stringList_t stl)
Definition: security.c:210
zuluCryptGetPassFromFile
int zuluCryptGetPassFromFile(int *socket_path, const char *path, uid_t uid, string_t *st)
Definition: path_access.c:121
zuluCryptPartitionIsSystemPartition
int zuluCryptPartitionIsSystemPartition(const char *dev, uid_t uid)
Definition: volumes.c:1143
zuluCryptSecuritySetPrivilegeElevationErrorFunction
void zuluCryptSecuritySetPrivilegeElevationErrorFunction(void(*f)(const char *))
Definition: security.c:104
StringDelete
void StringDelete(string_t *st)
Definition: String.c:162
StringListClearDelete
void StringListClearDelete(stringList_t *stl)
Definition: StringList.c:1216
StringExitOnMemoryExaustion
void StringExitOnMemoryExaustion(void(*f)(void))
Definition: String.c:75
zuluCryptEmptySlots
char * zuluCryptEmptySlots(const char *device)
Definition: empty_slots.c:86
zuluCryptExeFileDecrypt
int zuluCryptExeFileDecrypt(const struct_opts *opts, uid_t uid)
Definition: crypt_file.c:204
zuluCryptEXEHeaderMatchBackUpHeader
static int zuluCryptEXEHeaderMatchBackUpHeader(const char *device, const char *header_backup, uid_t uid)
Definition: main.c:212
struct_opts_1::print_partition_type
int print_partition_type
Definition: libzuluCrypt-exe.h:65
struct_opts_1::env
char *const * env
Definition: libzuluCrypt-exe.h:59
StringAppend
const char * StringAppend(string_t st, const char *s)
Definition: String.c:1052
includes.h
zuluCryptEXECheckIfTcrypt
static int zuluCryptEXECheckIfTcrypt(struct_opts *clargs, uid_t uid)
Definition: main.c:108
zuluCryptHeaderMatchBackUpHeader
int zuluCryptHeaderMatchBackUpHeader(const char *device, const char *header_backup, uid_t uid)
Definition: save_and_restore_volume_header.c:753
zuluCryptClearDeadMappers
void zuluCryptClearDeadMappers(uid_t uid, int s)
Definition: clear_dead_mappers.c:184
zuluCryptDeviceIsSupported
int zuluCryptDeviceIsSupported(const char *device, uid_t uid)
Definition: volumes.c:411
zuluCryptRunTest
int zuluCryptRunTest(void)
zuluCryptGetDeviceFileProperties
int zuluCryptGetDeviceFileProperties(const char *file, int *fd_path, int *fd_loop, char **dev, uid_t uid)
Definition: file_path_security.c:116
_printOpenedVolumes
static int _printOpenedVolumes(uid_t uid)
Definition: main.c:333
StringListExitOnMemoryExaustion
void StringListExitOnMemoryExaustion(void(*f)(void))
Definition: StringList.c:54
_privilegeEvelationError
static void _privilegeEvelationError(const char *msg)
Definition: main.c:311
zuluCryptExeFileEncrypt
int zuluCryptExeFileEncrypt(const struct_opts *opts, uid_t uid)
Definition: crypt_file.c:209
StringPrefixEqual
static __inline__ int StringPrefixEqual(const char *x, const char *y)
Definition: String.h:905
StringFree
static __inline__ void StringFree(const void *str)
Definition: String.h:823
StringVoid
#define StringVoid
Definition: String.h:47