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)  

save_and_restore_volume_header.c
Go to the documentation of this file.
1 
2 /*
3  *
4  * Copyright (c) 2012-2015
5  * name : Francis Banyikwa
6  * email: mhogomchungu@gmail.com
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #include "includes.h"
22 #include "../lib/includes.h"
23 #include <libcryptsetup.h>
24 #include <sys/syscall.h>
25 #include <errno.h>
26 #include <sys/mman.h>
27 #include <libintl.h>
28 #include <locale.h>
29 #include <stdio.h>
30 #include <sys/stat.h>
31 #include <fcntl.h>
32 #include <unistd.h>
33 #include "truecrypt_support_1.h"
34 
35 #define SIZE 512
36 
37 #define ignore_result( x ) if( x ){;}
38 
39 static int zuluExit( int st,const char * dev )
40 {
41  switch( st ){
42  case 0 : printf( gettext( "SUCCESS: Header saved successfully\n" ) ) ; break ;
43  case 1 : printf( gettext( "SUCCESS: Header restored successfully\n" ) ) ; break ;
44  case 2 : printf( gettext( "ERROR: Presented device is not a LUKS device\n" ) ) ; break ;
45  case 3 : printf( gettext( "ERROR: Failed to perform requested operation\n" ) ) ; break ;
46  case 4 : printf( gettext( "ERROR: Failed to perform requested operation\n" ) ) ; break ;
47  case 5 : printf( gettext( "INFO: Operation terminater per user request\n" ) ) ; break ;
48  case 6 : printf( gettext( "ERROR: Path to be used to create a back up file is occupied or permission denied\n" ) ); break ;
49  case 7 : printf( gettext( "ERROR: Failed to perform requested operation\n" ) ) ; break ;
50  case 8 : printf( gettext( "ERROR: Insufficient privilege to open backup header file for reading\n" ) ) ; break ;
51  case 9 : printf( gettext( "ERROR: Invalid path to back up header file\n" ) ) ; break ;
52  case 10: printf( gettext( "ERROR: Insufficient privilege to create a backup header in a destination folder\n" )); break ;
53  case 11: printf( gettext( "ERROR: Invalid path to device\n" ) ) ; break ;
54  case 12: printf( gettext( "ERROR: Argument for path to a backup header file is missing\n" ) ) ; break ;
55  case 13: printf( gettext( "ERROR: Argument for path to a backup header file is missing\n" ) ) ; break ;
56  case 14: printf( gettext( "ERROR: Only root and \"zulucrypt\" group members can restore and back up luks headers on system devices\n" ) ); break ;
57  case 15: printf( gettext( "ERROR: Insufficient privilege to open device for writing\n" ) ) ; break ;
58  case 16: printf( gettext( "ERROR: Could not resolve path to device\n" ) ) ; break ;
59  case 17: printf( gettext( "ERROR: Backup file does not appear to contain luks header\n" ) ) ; break ;
60  case 18: printf( gettext( "ERROR: Insufficient privilege to open device for reading\n" ) ) ; break ;
61  case 19: printf( gettext( "ERROR: Insufficient memory to hold your responce\n" ) ) ; break ;
62  case 20: printf( gettext( "ERROR: Wrong password entered or volume is not a truecrypt volume\n" ) ) ; break ;
63  case 21: printf( gettext( "ERROR: Wrong password entered or volume is not a veracrypt volume\n" ) ) ; break ;
64 
65  }
66 
67  StringFree( dev ) ;
68 
69  if( st == 1 ){
70 
71  return 0 ;
72  }else{
73  return st ;
74  }
75 }
76 
77 /*
78  * This place is a bit involving and an explanation seem to be the least i can do.
79  *
80  * We do not want cryptsetup and tcplay to access file paths a normal can modify for security
81  * reasons and hence we copy user provided files to "/run/zuluCrypt" folder and then
82  * pass these copied files to cryptsetup or tcplay.This happens when we are restoring
83  * header files.
84  *
85  * When we are taking header backups,we let these tools create the header backups in
86  * "/run/zuluCrypt" and then we copied these created header files from "/run/zuluCrypt"
87  * to where the normal user expect them to be.
88  *
89  * normal user should zero access to "/run/zuluCrypt" path.
90  */
91 
92 /*
93  * Below function creates a secured folder path,ie a folder path a normal user has no access to
94  */
96 {
97  /*
98  * ZULUCRYPTtempFolder and ZULUCRYPtmountMiniPath are set in ../constants.h
99  */
100  const char * temp_path = "/run/zuluCrypt/" ;
101  struct stat xt ;
102  mode_t mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IXOTH | S_IROTH ;
103 
105 
106  #define path_does_not_exist( x ) stat( x,&xt ) != 0
107 
108  if( path_does_not_exist( "/run" ) ){
109 
110  mkdir( "/run",mode ) ;
111  ignore_result( chown( "/run",0,0 ) ) ;
112  }
113  if( path_does_not_exist( temp_path ) ){
114 
115  mkdir( temp_path,S_IRWXU ) ;
116  ignore_result( chown( temp_path,0,0 ) ) ;
117  }
118 
120 
121  return String( temp_path ) ;
122 }
123 
124 /*
125  * Below function copies a file owned and managed by a user to a secured location so that it can be accessed securely.
126  */
127 static int _secure_file_path( const char ** path,const char * source )
128 {
129  int fd_source ;
130  int fd_temp ;
131  char buffer[ SIZE ] ;
132  size_t len ;
133  const char * temp_path ;
134  struct stat ststr ;
135 
136  string_t st_path = _create_work_directory() ;
137 
138  StringAppend( st_path,"0-" ) ;
139  temp_path = StringAppendInt( st_path,syscall( SYS_gettid ) ) ;
140 
142 
143  fd_source = open( source,O_RDONLY ) ;
144 
145  if( fd_source == -1 ){
146 
147  StringDelete( &st_path ) ;
148  return 0 ;
149  }
150 
151  fstat( fd_source,&ststr ) ;
152 
153 
154  if( ststr.st_size >= ZULUCRYPT_LUKS2_MAX_HEADER_SIZE ){
155  /*
156  * Lets assume a header can not be larger that ZULUCRYPT_LUKS2_MAX_HEADER_SIZE.
157  */
158  StringDelete( &st_path ) ;
159  return 0 ;
160  }
161 
163 
164  fd_temp = open( temp_path,O_WRONLY | O_CREAT,S_IRUSR | S_IWUSR | S_IRGRP |S_IROTH ) ;
165 
166  if( fd_temp == -1 ){
167 
168  close( fd_source ) ;
169 
170  StringDelete( &st_path ) ;
171 
172  return 0 ;
173  }
174 
175  while( 1 ){
176 
177  len = read( fd_source,buffer,SIZE ) ;
178 
179  if( len < SIZE ){
180 
181  ignore_result( write( fd_temp,buffer,len ) ) ;
182 
183  break ;
184  }else{
185  ignore_result( write( fd_temp,buffer,len ) ) ;
186  }
187  }
188 
189  close( fd_source ) ;
190  close( fd_temp ) ;
191 
193 
194  *path = StringDeleteHandle( &st_path ) ;
195  return 1 ;
196 }
197 
198 /*
199  * this function return a secured file path to be used to create a file at the path
200  */
201 static const char * _secure_file_path_1( void )
202 {
203  string_t st_path = _create_work_directory() ;
204 
205  StringAppend( st_path,"1-" ) ;
206  StringAppendInt( st_path,syscall( SYS_gettid ) ) ;
207 
208  return StringDeleteHandle( &st_path ) ;
209 }
210 
211 /*
212  * Below function copies a secured file from secured location to a user owned and managed location.
213  * The source file will be deleted when the copy is done.
214  */
215 static int _secure_copy_file( const char * source,const char * dest,uid_t uid )
216 {
217  int st = 4 ;
218  int fd_source ;
219  int fd_dest ;
220  size_t len ;
221  char buffer[ SIZE ] ;
222 
224 
225  fd_dest = open( dest,O_WRONLY | O_CREAT,S_IRUSR | S_IWUSR | S_IRGRP |S_IROTH ) ;
226 
227  if( fd_dest == -1 ){
228 
230  zuluCryptDeleteFile( source ) ;
232  return 6 ;
233  }
234 
236 
237  fd_source = open( source,O_RDONLY ) ;
238 
239  if( fd_source != -1 ){
240 
241  while( 1 ){
242 
243  len = read( fd_source,buffer,SIZE ) ;
244 
245  if( len < SIZE ){
246 
247  ignore_result( write( fd_dest,buffer,len ) ) ;
248 
249  break ;
250  }else{
251  ignore_result( write( fd_dest,buffer,len ) ) ;
252  }
253  }
254 
255  ignore_result( chmod( dest,S_IRUSR ) ) ;
256  ignore_result( chown( dest,uid,uid ) ) ;
257 
258  st = 0 ;
259  }
260 
261  /*
262  * zuluCryptDeleteFile() is defined in ../lib/file_path_security.c
263  */
264  zuluCryptDeleteFile( source ) ;
265 
267  return st ;
268 }
269 
270 static int _save_luks_header( const struct_opts * opts,const char * temp_path,const char * path,uid_t uid )
271 {
272  struct crypt_device * cd ;
273  int st ;
274 
275  if( crypt_init( &cd,opts->device ) != 0 ){
276 
277  st = 3 ;
278  }else{
279  st = crypt_header_backup( cd,NULL,temp_path ) ;
280 
281  crypt_free( cd ) ;
282 
283  if( st == 0 ){
284 
285  st = _secure_copy_file( temp_path,path,uid ) ;
286  }else{
287  st = 4 ;
288  }
289  }
290  return st ;
291 }
292 
293 static int zuluExit_1( int r,string_t st,string_t xt )
294 {
295  StringMultipleDelete( &xt,&st,NULL ) ;
296  return r ;
297 }
298 
299 static string_t _get_password( int * r )
300 {
301  string_t st = StringVoid ;
302 
303  *r = 1 ;
304 
305  printf( gettext( "Enter passphrase in the volume: " ) ) ;
306 
307  /*
308  * ZULUCRYPT_KEY_MAX_SIZE is set in ../constants.h
309  */
311  return st ;
312 }
313 
314 static string_t _get_password_0( int * r )
315 {
316  string_t st = StringVoid ;
317 
318  *r = 1 ;
319 
320  printf( gettext( "Enter passphrase in the header file: " ) ) ;
321 
322  /*
323  * ZULUCRYPT_KEY_MAX_SIZE is set in ../constants.h
324  */
326  return st ;
327 }
328 
329 static int _modify_tcrypt( info_t * info,const struct_opts * opts )
330 {
331  int k = 4 ;
332  int r ;
333 
334  int socket_path ;
335 
336  string_t st = StringVoid ;
337  string_t xt = StringVoid ;
338 
339  if( StringsAreEqual( opts->key_source,"-p" ) ){
340 
341  info->header_key = opts->key ;
342  info->header_key_source = "passphrase" ;
343  info->header_new_key_source = "new_passphrase" ;
344 
345  }else if( opts->key == NULL && StringsAreNotEqual( opts->key_source,"-f" ) ){
346 
347  st = info->getKey( &r ) ;
348 
349  if( r ){
350  info->key = StringContent( st ) ;
351  info->header_key = info->key ;
352  info->header_key_source = "passphrase" ;
353  info->header_new_key_source = "new_passphrase" ;
354  }else{
355  return zuluExit_1( k,st,xt ) ;
356  }
357  }else{
358  /*
359  * function is defined at "path_access.c"
360  */
361  zuluCryptGetPassFromFile( &socket_path,opts->key,info->uid,&st ) ;
362 
364 
365  if( st == StringVoid ){
366 
367  return zuluExit_1( k,st,xt ) ;
368  }else{
369  if( socket_path ){
370 
371  info->key = StringContent( st ) ;
372  info->header_key = info->key ;
373  info->header_key_source = "passphrase" ;
374  info->header_new_key_source = "new_passphrase" ;
375  }else{
376  /*
377  * zuluCryptCreateKeyFile_1 is defined in ../lib/open_tcrypt.c
378  */
379  xt = zuluCryptCreateKeyFile_1( st,"tcrypt-bk-" ) ;
380 
381  if( xt == StringVoid ){
382 
383  return zuluExit_1( k,st,xt ) ;
384  }else{
385  info->key = StringContent( xt ) ;
386  info->header_key = info->key ;
387  info->header_key_source = "keyfiles" ;
388  info->header_new_key_source = "new_keyfiles" ;
389  }
390  }
391  }
392  }
393 
394  info->header_new_key = info->header_key ;
395 
396  /*
397  * zuluCryptModifyTcryptHeader() is defined in ../lib/create_tcrypt.c
398  */
399  k = zuluCryptModifyTcryptHeader( info ) ;
400 
401  if( xt != StringVoid ){
402  /*
403  * zuluCryptDeleteFile_1() is defined in ../lib/file_path_security.c
404  */
405  zuluCryptDeleteFile_1( xt ) ;
406  }
407 
408  return zuluExit_1( k,st,xt ) ;
409 }
410 
412 {
413  stringList_t stl = StringListSplit( type,'.' ) ;
414 
415  const char * e = StringListContentAtFirstPlace( stl ) ;
416  const char * f = StringListContentAtSecondPlace( stl ) ;
417 
418  s->veraCrypt_volume = StringsAreEqual( e,"vcrypt" ) ;
419  s->iteration_count = ( int ) StringConvertToInt( f ) ;
420 
421  return stl ;
422 }
423 
424 static int _save_truecrypt_header( const struct_opts * opts,const char * temp_path,const char * path,uid_t uid )
425 {
426  int r ;
427  stringList_t stl ;
428  /*
429  * info_t structure is declared in ../lib/include.h
430  */
431  info_t info ;
432 
433  memset( &info,'\0',sizeof( info_t ) ) ;
434 
435  info.device = opts->device ;
436  info.header_source = "save_header_to_file" ;
437  info.getKey = _get_password ;
438  info.tmp_path = temp_path ;
439  info.uid = uid ;
440  info.rng = opts->rng ;
441  info.opt = opts->m_opts ;
442 
443  stl = veraCryptVolumePIMValue( &info,opts->type ) ;
444 
445  r = _modify_tcrypt( &info,opts ) ;
446 
447  StringListDelete( &stl ) ;
448 
449  if( opts->key == NULL && StringsAreNotEqual( opts->key_source,"-f" ) ){
450 
451  printf( "\n" ) ;
452  }
453  if( r == TC_OK ){
454 
455  return _secure_copy_file( temp_path,path,uid ) ;
456  }else{
457  if( StringPrefixEqual( opts->type,"vcrypt" ) ){
458 
459  return 21 ;
460  }else{
461  return 20 ;
462  }
463  }
464 }
465 
466 static int _restore_truecrypt_header( const struct_opts * opts,const char * temp_path,uid_t uid )
467 {
468  stringList_t stl ;
469 
470  int r ;
471  /*
472  * info_t structure is declared in ../lib/include.h
473  */
474  info_t info ;
475 
476  memset( &info,'\0',sizeof( info_t ) ) ;
477 
478  info.device = opts->device ;
479  info.header_source = "header_from_file" ;
480  info.getKey = _get_password_0 ;
481  info.tmp_path = temp_path ;
482  info.uid = uid ;
483  info.rng = opts->rng ;
484  info.opt = opts->m_opts ;
485 
486  stl = veraCryptVolumePIMValue( &info,opts->type ) ;
487 
488  r = _modify_tcrypt( &info,opts ) ;
489 
490  StringListDelete( &stl ) ;
491 
492  if( opts->key == NULL && StringsAreNotEqual( opts->key_source,"-f" ) ){
493 
494  printf( "\n" ) ;
495  }
496  if( r == TC_OK ){
497 
498  return 1 ;
499  }else{
500  if( StringPrefixEqual( opts->type,"vcrypt" ) ){
501 
502  return 21 ;
503  }else{
504  return 20 ;
505  }
506  }
507 }
508 
509 static int _save_header( const struct_opts * opts,const char * path,uid_t uid )
510 {
511  int st = 4 ;
512  const char * temp_path = _secure_file_path_1() ;
513 
515 
516  if( zuluCryptVolumeIsLuks( opts->device ) ){
517 
518  st = _save_luks_header( opts,temp_path,path,uid ) ;
519  }else{
520  st = _save_truecrypt_header( opts,temp_path,path,uid ) ;
521  }
522 
524 
525  StringFree( temp_path ) ;
526  return st ;
527 }
528 
529 static int _restore_luks_header( const struct_opts * opts,const char * temp_path )
530 {
531  int st ;
532  struct crypt_device * cd ;
533 
534  if( crypt_init( &cd,opts->device ) != 0 ){
535 
536  st = 7 ;
537  }else{
538  if( crypt_header_restore( cd,NULL,temp_path ) == 0 ){
539 
540  st = 1 ;
541  }else{
542  st = 7 ;
543  }
544 
545  crypt_free( cd ) ;
546  }
547  return st ;
548 }
549 
550 static int _restore_header( const struct_opts * opts,const char * dev,const char * path,int ask_confirmation,uid_t uid )
551 {
552  const char * temp_path = NULL ;
553  int k ;
554  int st = 7;
555  string_t confirm ;
556  const char * warn = gettext( "\
557 Are you sure you want to replace a header on device \"%s\" with a backup copy at \"%s\"?\n\
558 Type \"YES\" and press Enter to continue: " ) ;
559  if( uid ){;}
560 
561  if( ask_confirmation ){
563 
564  printf( warn,dev,path ) ;
565 
566  confirm = StringGetFromTerminal_1( 3 ) ;
567 
568  if( confirm != StringVoid ){
569 
570  k = StringsAreEqual_2( confirm,gettext( "YES" ) );
571  StringDelete( &confirm ) ;
572 
573  if( k == 0 ){
574 
575  return 5 ;
576  }
577  }else{
578  return 19 ;
579  }
580  }
581 
582  if( _secure_file_path( &temp_path,path ) ){
583 
585 
586  if( zuluCryptVolumeIsLuks( temp_path ) ){
587  /*
588  * temp_path will point to a header back up file and it is assumed that a user
589  * want to restore a header to a luks volume since the backup header has luks signature
590  */
591  st = _restore_luks_header( opts,temp_path ) ;
592  }else{
593  /*
594  * the header back up has no luks signature and hence it is assumed that a request is
595  * made to restore a truecrypt header backup
596  */
597  st = _restore_truecrypt_header( opts,temp_path,uid ) ;
598  }
599 
600  zuluCryptDeleteFile( temp_path ) ;
601 
602  StringFree( temp_path ) ;
603 
605 
606  return st ;
607  }else{
608  return 7 ;
609  }
610 }
611 
612 int zuluCryptEXESaveAndRestoreVolumeHeader( const struct_opts * opts,uid_t uid,int option )
613 {
614  const char * device = opts->device ;
615 
616  const char * path = opts->back_up_file_path ;
617  int st ;
618  int k ;
619 
620  const char * dev = NULL ;
621  const char * dev_1 = NULL ;
622 
623  if( StringPrefixEqual( device,"/dev/loop" ) ){
624 
625  /*
626  * zuluCryptLoopDeviceAddress_1() is defined in ../lib/create_loop_device.c
627  */
628 
629  dev = zuluCryptLoopDeviceAddress_1( device ) ;
630  dev_1 = dev ;
631 
632  /*
633  * zuluCryptPartitionIsSystemPartition() is defined in partitions.c
634  */
635 
636  k = zuluCryptPartitionIsSystemPartition( dev,uid ) ;
637  }else{
638  dev_1 = device ;
639  /*
640  * zuluCryptPartitionIsSystemPartition() is defined in partitions.c
641  */
642  k = zuluCryptPartitionIsSystemPartition( device,uid ) ;
643  }
644 
645  if( k == 1 ){
646 
648 
649  if( uid != 0 && !zuluCryptUserIsAMemberOfAGroup( uid,"zulucrypt" ) ){
650 
651  return zuluExit( 14,dev ) ;
652  }
653  }
654  }
655 
656  if( path == NULL ){
657 
658  if( option == VOLUME_HEADER_RESTORE ){
659 
660  return zuluExit( 12,dev ) ;
661  }else{
662  return zuluExit( 13,dev ) ;
663  }
664  }
665 
666  if( option == VOLUME_HEADER_RESTORE ){
667 
668  st = _restore_header( opts,dev_1,path,opts->ask_confirmation,uid ) ;
669  }else{
670  st = _save_header( opts,path,uid ) ;
671  }
672 
673  return zuluExit( st,dev ) ;
674 }
675 
676 static int _files_are_equal( const char * file1,const char * file2 )
677 {
678  struct stat st1 ;
679  struct stat st2 ;
680 
681  int fd1;
682  int fd2;
683  int r = 1 ;
684 
685  void * map1 ;
686  void * map2 ;
687 
688  fd1 = open( file1,O_RDONLY ) ;
689 
690  if( fd1 == -1 ){
691 
692  return 0 ;
693  }
694 
695  fd2 = open( file2,O_RDONLY ) ;
696 
697  if( fd2 == -1 ){
698 
699  close( fd1 ) ;
700  return 0 ;
701  }
702 
703  fstat( fd1,&st1 ) ;
704  fstat( fd2,&st2 ) ;
705 
706  /*
707  * headers are less than 10MB,anything larger is automatically an error
708  */
709  if( st1.st_size < ZULUCRYPT_LUKS2_MAX_HEADER_SIZE && st2.st_size < ZULUCRYPT_LUKS2_MAX_HEADER_SIZE ){
710 
711  map1 = mmap( 0,st1.st_size,PROT_READ,MAP_PRIVATE,fd1,0 ) ;
712 
713  if( map1 != MAP_FAILED ){
714 
715  map2 = mmap( 0,st2.st_size,PROT_READ,MAP_PRIVATE,fd2,0 ) ;
716 
717  if( map2 != MAP_FAILED ){
718 
719  if( st1.st_size > st2.st_size ){
720 
721  r = memcmp( map1,map2,st1.st_size ) ;
722  }else{
723  r = memcmp( map1,map2,st2.st_size ) ;
724  }
725  munmap( map2,st2.st_size ) ;
726  }
727  munmap( map1,st1.st_size ) ;
728  }
729  }else{
730  return 0 ;
731  }
732 
733  close( fd1 ) ;
734  close( fd2 ) ;
735 
736  return r == 0 ;
737 }
738 
739 static int _save_tmp_header( const char * device,const char * backup )
740 {
741  struct crypt_device * cd ;
742 
743  int st = 1 ;
744 
745  if( crypt_init( &cd,device ) == 0 ){
746 
747  st = crypt_header_backup( cd,NULL,backup ) ;
748  crypt_free( cd ) ;
749  }
750  return st == 0 ;
751 }
752 
753 int zuluCryptHeaderMatchBackUpHeader( const char * device,const char * header_backup,uid_t uid )
754 {
755  const char * header_path = NULL;
756  const char * device_header = NULL;
757 
758  int st = 0 ;
759 
760  if( uid ){;}
761 
762  if( device == NULL || header_backup == NULL ){
763 
764  return 0 ;
765  }
766 
767  _secure_file_path( &header_path,header_backup ) ;
768 
769  if( header_path == NULL ){
770 
771  return 0 ;
772  }
773 
774  device_header = _secure_file_path_1() ;
775 
776  if( device_header == NULL ){
777 
778  StringFree( header_path ) ;
779  return 0 ;
780  }
781 
783 
784  if( _save_tmp_header( device,device_header ) ){
785 
786  st = _files_are_equal( header_path,device_header ) ;
787  }
788 
789  zuluCryptDeleteFile( header_path ) ;
790  zuluCryptDeleteFile( device_header ) ;
791 
793 
794  StringFree( header_path ) ;
795  StringFree( device_header ) ;
796 
797  return st ;
798 }
StringSilentlyGetFromTerminal_1
int StringSilentlyGetFromTerminal_1(string_t *q, size_t s)
Definition: String.c:1752
StringAppendInt
const char * StringAppendInt(string_t st, u_int64_t z)
Definition: String.c:1410
StringListContentAtSecondPlace
static const __inline__ char * StringListContentAtSecondPlace(stringList_t stl)
Definition: StringList.h:187
StringsAreEqual_2
int StringsAreEqual_2(string_t x, const char *y)
Definition: String.c:1469
struct_opts_1::type
const char * type
Definition: libzuluCrypt-exe.h:44
_restore_luks_header
static int _restore_luks_header(const struct_opts *opts, const char *temp_path)
Definition: save_and_restore_volume_header.c:529
struct_opts_1::key
const char * key
Definition: libzuluCrypt-exe.h:42
_files_are_equal
static int _files_are_equal(const char *file1, const char *file2)
Definition: save_and_restore_volume_header.c:676
_secure_copy_file
static int _secure_copy_file(const char *source, const char *dest, uid_t uid)
Definition: save_and_restore_volume_header.c:215
info_t::header_new_key_source
const char * header_new_key_source
Definition: includes.h:61
info_t::header_new_key
const char * header_new_key
Definition: includes.h:60
info_t::device
const char * device
Definition: includes.h:52
_restore_truecrypt_header
static int _restore_truecrypt_header(const struct_opts *opts, const char *temp_path, uid_t uid)
Definition: save_and_restore_volume_header.c:466
struct_opts_1::device
const char * device
Definition: libzuluCrypt-exe.h:37
StringListContentAtFirstPlace
static const __inline__ char * StringListContentAtFirstPlace(stringList_t stl)
Definition: StringList.h:182
StringsAreNotEqual
#define StringsAreNotEqual(x, y)
Definition: zuluSafe.c:47
info_t::key
const char * key
Definition: includes.h:56
zuluCryptEXESaveAndRestoreVolumeHeader
int zuluCryptEXESaveAndRestoreVolumeHeader(const struct_opts *opts, uid_t uid, int option)
Definition: save_and_restore_volume_header.c:612
zuluCryptLoopDeviceAddress_1
char * zuluCryptLoopDeviceAddress_1(const char *device)
Definition: create_loop_device.c:140
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
veraCryptVolumePIMValue
stringList_t veraCryptVolumePIMValue(info_t *s, const char *type)
Definition: save_and_restore_volume_header.c:411
zuluCryptDeleteFile
void zuluCryptDeleteFile(const char *file)
Definition: file_path_security.c:57
struct_opts_1::key_source
const char * key_source
Definition: libzuluCrypt-exe.h:41
info_t::uid
uid_t uid
Definition: includes.h:62
zuluCryptUserIsAMemberOfAGroup
int zuluCryptUserIsAMemberOfAGroup(uid_t uid, const char *groupname)
Definition: mount_fs_options.c:172
StringListDelete
void StringListDelete(stringList_t *stl)
Definition: StringList.c:1184
zuluCryptHeaderMatchBackUpHeader
int zuluCryptHeaderMatchBackUpHeader(const char *device, const char *header_backup, uid_t uid)
Definition: save_and_restore_volume_header.c:753
info_t::header_key_source
const char * header_key_source
Definition: includes.h:59
ZULUCRYPT_LUKS2_MAX_HEADER_SIZE
#define ZULUCRYPT_LUKS2_MAX_HEADER_SIZE
Definition: constants.h:45
_save_truecrypt_header
static int _save_truecrypt_header(const struct_opts *opts, const char *temp_path, const char *path, uid_t uid)
Definition: save_and_restore_volume_header.c:424
StringsAreEqual
#define StringsAreEqual(x, y)
Definition: zuluSafe.c:46
info_t::header_source
const char * header_source
Definition: includes.h:53
info_t::iteration_count
int iteration_count
Definition: includes.h:64
StringDeleteHandle
char * StringDeleteHandle(string_t *xt)
Definition: String.c:233
path_does_not_exist
#define path_does_not_exist(x)
_get_password
static string_t _get_password(int *r)
Definition: save_and_restore_volume_header.c:299
StringContent
static const __inline__ char * StringContent(string_t st)
Definition: String.h:1011
_secure_file_path
static int _secure_file_path(const char **path, const char *source)
Definition: save_and_restore_volume_header.c:127
StringType
Definition: String.c:49
ignore_result
#define ignore_result(x)
Definition: save_and_restore_volume_header.c:37
zuluCryptCreateKeyFile_1
string_t zuluCryptCreateKeyFile_1(string_t key, const char *fileName)
Definition: open_tcrypt.c:167
zuluCryptSecurityDropElevatedPrivileges
int zuluCryptSecurityDropElevatedPrivileges(void)
Definition: security.c:109
StringMultipleDelete
void StringMultipleDelete(string_t *xt,...)
Definition: String.c:195
TC_OK
#define TC_OK
Definition: zuluplay_api.h:36
zuluCryptModifyTcryptHeader
int zuluCryptModifyTcryptHeader(const info_t *info)
Definition: create_tcrypt.c:229
zuluCryptVolumeIsLuks
int zuluCryptVolumeIsLuks(const char *device)
Definition: is_luks.c:45
info_t::veraCrypt_volume
int veraCrypt_volume
Definition: includes.h:63
info_t::tmp_path
const char * tmp_path
Definition: includes.h:54
String
string_t String(const char *cstring)
Definition: String.c:318
info_t::opt
const char * opt
Definition: includes.h:55
_secure_file_path_1
static const char * _secure_file_path_1(void)
Definition: save_and_restore_volume_header.c:201
struct_opts_1::ask_confirmation
int ask_confirmation
Definition: libzuluCrypt-exe.h:62
VOLUME_HEADER_RESTORE
#define VOLUME_HEADER_RESTORE
Definition: includes.h:47
zuluCryptSecurityGainElevatedPrivileges
int zuluCryptSecurityGainElevatedPrivileges(void)
Definition: security.c:64
struct_opts_1::rng
const char * rng
Definition: libzuluCrypt-exe.h:45
info_t::getKey
string_t(* getKey)(int *)
Definition: includes.h:65
_save_header
static int _save_header(const struct_opts *opts, const char *path, uid_t uid)
Definition: save_and_restore_volume_header.c:509
ZULUCRYPT_KEY_MAX_SIZE
#define ZULUCRYPT_KEY_MAX_SIZE
Definition: constants.h:49
SIZE
#define SIZE
Definition: save_and_restore_volume_header.c:35
StringListType
Definition: StringList.c:33
info_t::rng
const char * rng
Definition: includes.h:57
info_t::header_key
const char * header_key
Definition: includes.h:58
e
static QString e
Definition: about.cpp:31
StringListSplit
stringList_t StringListSplit(const char *cstring, char splitter)
Definition: StringList.c:428
zuluCryptDeleteFile_1
void zuluCryptDeleteFile_1(string_t st)
Definition: file_path_security.c:83
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
StringDelete
void StringDelete(string_t *st)
Definition: String.c:162
StringConvertToInt
u_int64_t StringConvertToInt(const char *s)
Definition: String.c:1416
_create_work_directory
static string_t _create_work_directory(void)
Definition: save_and_restore_volume_header.c:95
info_t
Definition: includes.h:51
struct_opts_1::m_opts
const char * m_opts
Definition: libzuluCrypt-exe.h:39
_save_luks_header
static int _save_luks_header(const struct_opts *opts, const char *temp_path, const char *path, uid_t uid)
Definition: save_and_restore_volume_header.c:270
StringGetFromTerminal_1
string_t StringGetFromTerminal_1(size_t s)
Definition: String.c:1675
_get_password_0
static string_t _get_password_0(int *r)
Definition: save_and_restore_volume_header.c:314
StringAppend
const char * StringAppend(string_t st, const char *s)
Definition: String.c:1052
includes.h
zuluCryptExeOriginalUserIsNotRoot
int zuluCryptExeOriginalUserIsNotRoot()
Definition: security.c:59
_restore_header
static int _restore_header(const struct_opts *opts, const char *dev, const char *path, int ask_confirmation, uid_t uid)
Definition: save_and_restore_volume_header.c:550
_modify_tcrypt
static int _modify_tcrypt(info_t *info, const struct_opts *opts)
Definition: save_and_restore_volume_header.c:329
_save_tmp_header
static int _save_tmp_header(const char *device, const char *backup)
Definition: save_and_restore_volume_header.c:739
zuluExit
static int zuluExit(int st, const char *dev)
Definition: save_and_restore_volume_header.c:39
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
zuluExit_1
static int zuluExit_1(int r, string_t st, string_t xt)
Definition: save_and_restore_volume_header.c:293
StringVoid
#define StringVoid
Definition: String.h:47