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)  

volume_status.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 <mntent.h>
21 #include <sys/statvfs.h>
22 #include <blkid/blkid.h>
23 #include <stdint.h>
24 #include <stdio.h>
25 #include <locale.h>
26 #include <libintl.h>
27 
28 #include "../zuluCrypt-cli/lib/includes.h"
29 #include "../zuluCrypt-cli/bin/includes.h"
30 
32 
33 static const char * _fs( const char * e )
34 {
35  if( StringPrefixEqual( e,"fuse" ) ){
36 
37  return e + 5 ;
38  }else{
39  return e ;
40  }
41 }
42 
43 void zuluMountPartitionProperties( const char * dev,const char * UUID,
44  const char * mapper,const char * m_point,const char * fs )
45 {
46  #define SIZE 64
47 
48  const char * g ;
49  const char * e ;
50 
51  char * m ;
52 
53  blkid_probe blkid ;
54 
55  struct statvfs vfs ;
56  u_int64_t total ;
57  u_int64_t used ;
58  u_int64_t free_space ;
59  u_int32_t block_size ;
60  u_int64_t volume_size = 0 ;
61 
62  char buff[ SIZE ] ;
63  char * buffer = buff ;
64 
65  const char * device = NULL ;
66  char * device_1 = NULL ;
67 
68  if( StringAtLeastOneMatch_1( fs,"fuse.encfs","fuse.cryfs",
69  "fuse.gocryptfs","fuse.securefs","ecryptfs",NULL ) ){
70 
71  if( m_point != NULL ){
72 
73  printf( "%s\t%s\t%s\tNil\tNil\tNil\n",dev,m_point,_fs( fs ) ) ;
74  }else{
75  printf( "%s\tNil\t%s\tNil\tNil\tNil\n",dev,_fs( fs ) ) ;
76  }
77  return ;
78  }
79 
81 
82  if( StringPrefixEqual( dev,"/dev/" ) ){
83 
84  device = dev ;
85  }else{
86  /*
87  * got a path to an image file,convert it to its associated loop device first
88  * because we dont want to pass image files paths to blkid.
89  */
90  /*
91  * zuluCryptGetALoopDeviceAssociatedWithAnImageFile()
92  * is defined in ../zuluCrypt-cli/lib/create_loop_device.c
93  */
94  device = device_1 = zuluCryptGetALoopDeviceAssociatedWithAnImageFile( dev ) ;
95  }
96 
97  if( device == NULL ){
98 
100 
101  return ;
102  }
103 
104  blkid = blkid_new_probe_from_filename( device ) ;
105 
106  if( blkid == NULL ){
107 
109 
110  printf( "%s\tNil\tNil\tNil\tNil\tNil\n",device ) ;
111 
112  StringFree( device_1 ) ;
113 
114  return ;
115  }
116 
117  if( UUID != NULL ){
118 
119  printf( "%s\t",UUID ) ;
120  }else{
121  if( zuluCryptNoPartitionLoopDevice( dev ) ){
122  /*
123  * zuluCryptLoopDeviceAddress_1() is defined in ../zuluCrypt-cli/lib/create_loop_device.c
124  */
125  g = zuluCryptLoopDeviceAddress_1( dev ) ;
126 
127  if( g != NULL ){
128  printf( "%s\t",g ) ;
129  StringFree( g ) ;
130  }else{
131  printf( "%s\t",dev ) ;
132  }
133  }else{
134  printf( "%s\t",dev ) ;
135  }
136  }
137 
138  if( m_point == NULL ){
139 
140  printf( "Nil\t" ) ;
141  }else{
142  printf( "%s\t",m_point ) ;
143  }
144 
145  if( StringsAreEqual( dev,mapper ) ){
146 
147  blkid_do_probe( blkid ) ;
148 
150 
151  printf( "%s\t",fs ) ;
152  }else{
153  e = zuluCryptVolumeType( blkid,device ) ;
154 
155  if( StringPrefixEqual( e,"crypto_LUKS" ) ){
156 
157  m = zuluCryptGetVolumeType_1( device ) ;
158 
159  if( m ){
160 
161  printf( "%s\t",m ) ;
162 
163  StringFree( m ) ;
164  }else{
165  printf( "%s\t",e ) ;
166  }
167  }else{
168  printf( "%s\t",e ) ;
169  }
170  }
171 
172  if( blkid_probe_lookup_value( blkid,"LABEL",&g,NULL ) == 0 ){
173 
174  printf( "%s",g ) ;
175  }else{
176  printf( "Nil" ) ;
177  }
178 
179  blkid_free_probe( blkid ) ;
180 
181  /*
182  * zuluCryptGetVolumeSize() is defined in ../zuluCrypt-cli/lib/blkid_evaluate_tag.c
183  */
184  if( m_point == NULL ){
185 
186  volume_size = zuluCryptGetVolumeSize( device ) ;
187  }
188  }else{
189  blkid_free_probe( blkid ) ;
190 
191  blkid = blkid_new_probe_from_filename( mapper ) ;
192 
193  if( blkid == NULL ){
194 
195  printf( "Nil\tNil" ) ;
196  }else{
197  blkid_do_probe( blkid ) ;
198  /*
199  * zuluCryptGetVolumeTypeFromMapperPath() is defined in ../zuluCrypt-cli/lib/status.c
200  */
202 
203  if( blkid_probe_lookup_value( blkid,"TYPE",&g,NULL ) == 0 ){
204 
205  printf( "%s/%s\t",e,g ) ;
206  }else{
207  printf( "%s/Nil\t",e ) ;
208  }
209 
210  if( blkid_probe_lookup_value( blkid,"LABEL",&g,NULL ) == 0 ){
211 
212  printf( "%s",g ) ;
213  }else{
214  printf( "Nil" ) ;
215  }
216 
217  blkid_free_probe( blkid ) ;
218  StringFree( e ) ;
219 
220  if( m_point == NULL ){
221 
222  volume_size = zuluCryptGetVolumeSize( mapper ) ;
223  }
224  }
225  }
226 
227  if( m_point == NULL ){
228 
229  zuluCryptFormatSize( volume_size,buffer,SIZE ) ;
230  printf( "\t%s\tNil\n",buffer ) ;
231  }else{
232  if( statvfs( m_point,&vfs ) != 0 ){
233 
234  printf( "\tNil\tNil\n" ) ;
235  }else{
236  block_size = vfs.f_frsize ;
237 
238  total = block_size * vfs.f_blocks ;
239 
240  zuluCryptFormatSize( total,buffer,SIZE ) ;
241  printf( "\t%s",buffer ) ;
242 
243  free_space = block_size * vfs.f_bavail ;
244 
245  used = total - free_space ;
246 
247  if( used == total ){
248 
249  puts( "\t100%" ) ;
250  }else{
251  snprintf( buff,SIZE,"%.2f%%",100 * ( ( float ) used / ( float ) total ) ) ;
252  printf( "\t%s\n",buff ) ;
253  }
254  }
255  }
256 
257  StringFree( device_1 ) ;
258 
260 }
261 
262 static void _print_device_properties( string_t entry,const char * mapper_path,size_t mapper_length,uid_t uid )
263 {
264  char * x ;
265 
266  const char * q ;
267  const char * e ;
268  const char * f ;
269 
270  const char * fs ;
271 
272  ssize_t index ;
273 
274  string_t st = StringVoid ;
275  string_t xt ;
276 
277  stringList_t stx = StringListStringSplit( entry,' ' ) ;
278 
279  if( stx == StringListVoid ){
280 
281  return ;
282  }
283 
284  fs = StringListContentAtThirdPlace( stx ) ;
285 
286  q = StringListContentAtFirstPlace( stx ) ;
287 
288  if( StringPrefixMatch( q,mapper_path,mapper_length ) ){
289  /*
290  * zuluCryptSecurityGainElevatedPrivileges() and zuluCryptSecurityDropElevatedPrivileges()
291  * are defined in ../zuluCrypt-cli/bin/security.c
292  */
294  /*
295  * zuluCryptVolumeDeviceName() is defined in ../zuluCrypt-cli/lib/status.c
296  */
297  x = zuluCryptVolumeDeviceName( q ) ;
298 
300 
301  if( x != NULL ){
302 
303  index = StringHasComponent_1( q,"-UUID-" ) ;
304 
305  if( index != -1 ){
306 
307  st = String( q ) ;
308  StringRemoveLeft( st,index + 6 ) ;
309  e = StringPrepend( st,"UUID=\"" ) ;
310  index = StringLastIndexOfChar( st,'-' ) ;
311 
312  if( index >= 0 ){
313 
314  StringSubChar( st,index,'\"' ) ;
315  e = StringSubChar( st,index+1,'\0' ) ;
316  }
317  }else{
318  e = x ;
319  }
320 
321  StringReplace( entry,e ) ;
322  /*
323  * zuluCryptDecodeMountEntry() is defined in ../zuluCrypt-cli/lib/mount_volume.c
324  * it decodes space,tab,new line and backslash characters since they are written differently in "/etc/mtab"
325  */
327 
328  zuluMountPartitionProperties( x,e,q,f,fs ) ;
329 
330  StringFree( x ) ;
331  StringDelete( &st ) ;
332  }else{
333  StringReplaceChar_1( entry,0,' ','\0' ) ;
334  }
335 
336  }else if( zuluCryptBitLockerVolume( q ) ){
337 
339 
340  e = zuluCryptDecodeMountEntry( st ) ;
342 
343  StringReplace( entry,e ) ;
344 
346 
348 
349  if( xt != StringVoid ){
350 
352 
354  }else{
356  }
357 
359 
360  StringMultipleDelete( &st,&xt,NULL ) ;
361  }else{
362  StringReplaceChar_1( entry,0,' ','\0' ) ;
363 
366 
367  zuluMountPartitionProperties( e,NULL,e,f,fs ) ;
368  }
369 
371  StringListDelete( &stx ) ;
372 }
373 
375 {
376  StringIterator it ;
377  StringIterator end ;
378 
379  char e ;
380 
381  StringGetIterators( st,&it,&end ) ;
382 
383  while( it != end ){
384 
385  e = *it ;
386 
387  it++ ;
388 
389  if( e == ' ' ){
390 
391  return 1 ;
392  }
393  if( !( e >= '0' && e <= '9' ) ){
394 
395  return 0 ;
396  }
397  }
398 
399  return 1 ;
400 }
401 
403 {
404  if( StringStartsWithAtLeastOne( st,"/proc","/sys","/dev ",NULL ) ){
405 
406  return 0 ;
407  }
408  if( StringsAreEqual_2( st,"/dev" ) ){
409 
410  return 0 ;
411  }
412  if( StringStartsWith( st,"/" ) ){
413 
414  return 1 ;
415  }
416  if( _starts_with_digits_only( st ) )
417  {
418  return 1 ;
419  }
420  return 0 ;
421 }
422 
424 {
425  stringList_t stl ;
426  stringList_t stz ;
427 
428  StringListIterator it ;
429  StringListIterator end ;
430 
431  string_t st ;
432 
433  const char * e ;
434  const char * z ;
435 
436  size_t l ;
437 
438  /*
439  * zuluCryptGetMoutedList() is defined in ../zuluCrypt-cli/lib/process_mountinfo.c
440  * run StringListPrintList( stl ) to get a list of entries being worked on
441  */
442  stl = zuluCryptGetMoutedList() ;
443 
444  /*
445  * zuluCryptGetAListOfAllPartitions() is defined in ../zuluCrypt-cli/bin/volumes.c
446  */
448 
449  if( uid ){;}
450  /*
451  * zuluCryptMapperPrefix() is defined in ../zuluCrypt-cli/lib/create_mapper_name.c
452  * it should return something like "/dev/mapper"
453  */
454  z = zuluCryptMapperPrefix() ;
455  l = StringSize( z ) ;
456 
457  StringListGetIterators( stl,&it,&end ) ;
458  /*
459  * print a list of mounted volumes
460  */
461  while( it != end ){
462 
463  st = *it ;
464 
465  it++ ;
466 
467  if( _normal_mounted_volume( st ) ){
468 
469  _print_device_properties( st,z,l,uid ) ;
470 
471  if( StringStartsWith( st,"UUID=" ) ){
472 
473  e = StringRemoveString( st,"\"" ) ;
474  /*
475  * zuluCryptEvaluateDeviceTags() ../zuluCrypt-cli/bin/path_access.c
476  */
477  e = zuluCryptEvaluateDeviceTags( "UUID",e + 5 ) ;
478 
480 
481  StringFree( e ) ;
482  }else{
484  StringListRemoveIfPresent_1( stz,st ) ;
485  }
486  }else{
488 
489  StringReplaceChar_1( st,0,' ','\0' ) ;
490 
491  StringListRemoveIfPresent_1( stz,st ) ;
492  }
493  }
494 
495  StringListGetIterators( stz,&it,&end ) ;
496  /*
497  * print a list of not mounted volumes
498  */
499  while( it != end ){
500 
501  e = StringContent( *it ) ;
502 
503  it++ ;
504 
505  zuluMountPartitionProperties( e,NULL,e,NULL,NULL ) ;
506  }
507 
508  StringListMultipleDelete( &stl,&stz,NULL ) ;
509 
510  return 0 ;
511 }
512 
514 {
515  const char * e ;
516  const char * f ;
517 
518  /*
519  * zuluCryptMapperPrefix() is defined in ../zuluCrypt-cli/lib/create_mapper_name.c
520  * mapper_prefix will probably contain "/dev/mapper/"
521  */
522  const char * mapper_prefix = zuluCryptMapperPrefix() ;
523 
524  string_t q ;
525 
526  if( StringStartsWith( st,mapper_prefix ) ){
527  /*
528  * we will get here is the path starts with "/dev/mapper/".
529  * This path could be an LVM path or an encrypted mapper path
530  */
531  /*
532  * zuluCryptConvertIfPathIsLVM() is defined in ../zuluCrypt-cli/lib/status.c
533  */
535 
536  if( StringStartsWith( q,mapper_prefix ) ){
537  /*
538  * volume is probably an encrypted one
539  */
540  if( StringContains( q,"-NAAN-" ) ){
541 
543  /*
544  * zuluCryptVolumeDeviceName() is defined in ../zuluCrypt-cli/lib/status.c
545  */
547 
549 
550  if( f != NULL ){
551 
552  puts( f ) ;
553  StringFree( f ) ;
554  }
555  }else if( StringContains( q,"-UUID-" ) ){
556 
557  StringReplaceString( q,"-UUID-","-UUID=\"" ) ;
558 
559  e = StringAppend( q,"\"" ) ;
560  e = e + StringHasComponent_1( e,"UUID=" ) ;
561 
562  puts( e ) ;
563  }else{
564  /*
565  * Still assuming its an encrypted volume opened and outside of zuluCrypt/zuluMount
566  */
568 
570 
572 
573  if( f != NULL ){
574 
575  puts( f ) ;
576  StringFree( f ) ;
577  }else{
578  /*
579  * not exactly sure what this is,just print it and let the user sort it out
580  */
582  StringPrintLine( q ) ;
583  }
584  }
585  }else{
586  /*
587  * the volume is probably an LVM volume
588  */
590  StringPrintLine( q ) ;
591  }
592 
593  StringDelete( &q ) ;
594 
595  }else if( zuluCryptBitLockerVolume( StringContent( st ) ) ){
596 
598 
599  StringPrintLine( q ) ;
600 
601  StringDelete( &q ) ;
602  }else{
604  StringPrintLine( st ) ;
605  }
606 }
607 
609 {
610  /*
611  * zuluCryptGetAListOfMountedVolumes() is defined in ../zuluCrypt-cli/lib/process_mountinfo.c
612  */
615 
616  string_t st ;
617 
618  StringListIterator it ;
619  StringListIterator end ;
620 
621  const char * f ;
622  /*
623  * remove duplicates caused by bind mounts and other entries we dont care about
624  */
625  StringListGetIterators( stz,&it,&end ) ;
626 
627  while( it != end ){
628 
629  st = *it ;
630 
631  it++ ;
632 
633  if( _normal_mounted_volume( st ) ){
634 
635  f = StringContent( st ) ;
636 
637  if( StringListHasNoEntry( stx,f ) ){
638 
639  /*
640  * Only print one entry if there are more due to bind mounts
641  */
643  stx = StringListAppend( stx,f ) ;
644  }
645  }
646  }
647 
648  StringListMultipleDelete( &stz,&stx,NULL ) ;
649  return 0 ;
650 }
651 
652 int zuluMountPrintDeviceProperties( const char * device,const char * UUID,uid_t uid )
653 {
654  string_t p ;
655  string_t q ;
656  string_t z = StringVoid ;
657  string_t f = StringVoid ;
658 
659  char * dev = NULL ;
660  const char * device_1 ;
661  const char * e ;
662 
663  /*
664  * zuluCryptMapperPrefix() is defined in ../zuluCrypt-cli/lib/create_mapper_name.c
665  * mapper_prefix will probably contain "/dev/mapper/"
666  */
667  const char * mapper_prefix = zuluCryptMapperPrefix() ;
668 
669  size_t mapper_length = StringSize( mapper_prefix ) ;
670 
671  StringListIterator it ;
672  StringListIterator end ;
673 
674  /*
675  * zuluCryptGetMoutedList() is defined in ../zuluCrypt-cli/lib/process_mountinfo.c
676  */
678 
679  device_1 = device ;
680 
681  if( UUID == NULL ){
682 
683  if( StringPrefixEqual( device,"/dev/loop" ) ){
684 
685  /*
686  * zuluCryptLoopDeviceAddress() is defined in ../zuluCrypt-cli/lib/create_loop_device.c
687  */
688 
689  if( zuluCryptMultiPartitionLoopDevice( device ) ){
690 
691  dev = StringCopy_2( device ) ;
692  }else{
693  dev = zuluCryptLoopDeviceAddress( device ) ;
694  }
695 
696  device_1 = dev ;
697 
698  z = String( dev ) ;
700  /*
701  * ZULUCRYPTlongMapperPath is set in ../zuluCrypt-cli/constants.h
702  * zuluCryptCreateMapperName() is defined at ../zuluCrypt-cli/lib/create_mapper_name.c
703  */
704  e = e + StringLastIndexOfChar_1( e,'/' ) + 1 ;
706  }else{
707  /*
708  * ZULUCRYPTlongMapperPath is set in ../zuluCrypt-cli/constants.h
709  * zuluCryptCreateMapperName() is defined at ../zuluCrypt-cli/lib/create_mapper_name.c
710  */
711  e = device + StringLastIndexOfChar_1( device,'/' ) + 1 ;
713  }
714  }else{
715  p = String( UUID ) ;
716  StringRemoveString( p,"\"" ) ;
717  e = StringReplaceString( p,"UUID=","UUID-" ) ;
719  StringDelete( &p ) ;
720  }
721 
722  e = StringContent( q ) ;
723 
724  p = StringListHasStartSequence_1( stl,e ) ;
725 
726  if( p != StringVoid ){
727 
728  /*
729  * mounted and encrypted volume opened by this user
730  */
731  _print_device_properties( p,mapper_prefix,mapper_length,uid ) ;
732  }else{
733  /*
734  * We will get if:
735  * 1. The volume is not mounted.
736  * 2. The volume is mounted,encrypted and opened by a different user
737  * 3. The volume is mouted and unencrypted
738  */
739  f = String( device_1 ) ;
740  p = StringListHasStartSequence_1( stl,StringAppend( f," " ) ) ;
741 
742  StringDelete( &f ) ;
743 
744  if( p != StringVoid ){
745  /*
746  * volume is unencrypted and mounted by any user
747  */
748  _print_device_properties( p,mapper_prefix,mapper_length,uid ) ;
749  }else{
750  /*
751  * We will get here is:
752  * 1. The volume is not mounted
753  * 2. The volume is encrypted and mounted by a different user
754  */
755  StringListGetIterators( stl,&it,&end ) ;
756 
758 
759  while( it != end ){
760 
761  p = *it ;
762 
763  it++ ;
764 
765  if( StringStartsWith( p,mapper_prefix ) ){
766 
767  e = StringReplaceChar_1( p,0,' ','\0' ) ;
768  /*
769  * zuluCryptVolumeDeviceName() is defined in ../zuluCrypt-cli/lib/status.c
770  */
772 
773  if( StringsAreEqual( e,device ) ){
774 
775  f = p ;
776  StringReplaceChar_1( p,0,'\0',' ' ) ;
777 
778  StringFree( e ) ;
779 
780  break ;
781  }else{
782  StringFree( e ) ;
783  }
784  }
785  }
786 
788 
789  if( f != StringVoid ){
790 
791  /*
792  * The volume is encrypted and mounted by any user,probably a different user
793  * since volumes mounted by this user are already checked.
794  */
795  _print_device_properties( f,mapper_prefix,mapper_length,uid ) ;
796  }else{
797  /*
798  * volume is not mounted
799  */
800  zuluMountPartitionProperties( device,NULL,device,NULL,NULL ) ;
801  }
802  }
803  }
804 
805  StringListDelete( &stl ) ;
806  StringFree( dev ) ;
807 
808  StringDelete( &z ) ;
809  StringDelete( &q ) ;
810 
811  return 0 ;
812 }
813 
814 int zuluMountUnEncryptedVolumeStatus( const char * device,const char * fs,const char * device1 )
815 {
816  char * e ;
817  char * z ;
818 
819  stringList_t stl ;
820 
821  string_t p ;
822  string_t q ;
823 
824  /*
825  * zuluCryptGetMountEntry() is defined in ../zuluCrypt/cli/lib/process_mountinfo.c
826  */
827  if( device1 != NULL ){
828 
829  p = zuluCryptGetMountEntry( device1 ) ;
830  }else{
831  p = zuluCryptGetMountEntry( device ) ;
832  }
833 
834  stl = StringListStringSplit( p,' ' ) ;
835 
836  StringDelete( &p ) ;
837 
838  if( fs != NULL ){
839 
840  p = String_1( "\n type: \t",fs,"\n cipher: \tNil\n keysize: \tNil\n offset: \tNil\n",NULL ) ;
841  }else{
842  p = String( "\n type: \tNil\n cipher: \tNil\n keysize: \tNil\n offset: \tNil\n" ) ;
843  }
844 
845  if( zuluCryptNoPartitionLoopDevice( device ) ){
846  /*
847  * zuluCryptLoopDeviceAddress_1() is defined in ../zuluCrypt-cli/lib/create_loop_device.c
848  */
849  e = zuluCryptLoopDeviceAddress_1( device ) ;
850  /*
851  * zuluCryptGetLoopDeviceAddress() is defined in ../zuluCrypt-cli/lib/create_loop_device.c
852  */
853  z = zuluCryptGetLoopDeviceAddress( device ) ;
854 
855  if( e != NULL && z != NULL ){
856 
857  StringMultipleAppend( p," device: \t",z,"\n loop: \t",e,NULL ) ;
858  }else{
859  StringMultipleAppend( p," device: \t","Nil","\n loop: \tNil",NULL ) ;
860  }
861 
862  StringFree( e ) ;
863  StringFree( z ) ;
864  }else{
865  StringMultipleAppend( p," device: \t",device," \n loop: \tNil",NULL ) ;
866  }
867 
868  if( StringHasAtLeastOneComponent( StringListStringAt( stl,3 ),"ro,",",ro,",",ro",NULL ) ){
869 
870  StringAppend( p," \n mode: \tread only\n active slots:\tNil" ) ;
871  }else{
872  StringAppend( p," \n mode: \tread and write\n active slots:\tNil" ) ;
873  }
874 
876 
877  q = StringListStringAtSecondPlace( stl ) ;
878  /*
879  * zuluCryptFileSystemProperties() is defined in ../zuluCrypt-cli/lib/status.c
880  * zuluCryptDecodeMountEntry() is defined in ../zuluCrypt-cli/lib/mount_volume.c
881  */
882 
883  if( device1 != NULL ){
884 
886  }else{
888  }
889 
890 
892 
893  /*
894  * zuluCryptSecurityUUIDFromPath() is defined in ../zuluCrypt/cli/bin/path_access.c
895  */
896  e = zuluCryptUUIDFromPath( device ) ;
897 
898  if( e != NULL ){
899 
900  q = String( "" ) ;
901  StringReplaceString( p,"\"Nil\"",StringMultipleAppend( q,"\"",e,"\"",NULL ) ) ;
902  StringFree( e ) ;
903  StringDelete( &q ) ;
904  }
905 
906  StringPrintLine( p ) ;
907 
908  StringDelete( &p ) ;
909 
910  StringListDelete( &stl ) ;
911 
912  return 0 ;
913 }
914 
915 int zuluMountVolumeStatus( const char * device,const char * UUID,uid_t uid )
916 {
917  char * dev = NULL ;
918  int st ;
919  string_t p ;
920  const char * e ;
921 
922  if( UUID == NULL ){
923 
924  if( StringPrefixEqual( device,"/dev/loop" ) ){
925 
926  /*
927  * zuluCryptLoopDeviceAddress_1() is defined in ../zuluCrypt-cli/lib/create_loop_device.c
928  */
929  dev = zuluCryptLoopDeviceAddress_1( device ) ;
930 
931  if( dev != NULL ){
932 
933  e = dev + StringLastIndexOfChar_1( dev,'/' ) + 1 ;
934  st = zuluCryptEXEVolumeInfo( e,dev,uid ) ;
935  free( dev ) ;
936  }else{
937  printf( gettext( "ERROR: Could not get volume properties,volume is not open or was opened by a different user\n" ) ) ;
938  st = 1 ;
939  }
940  }else{
941  e = device + StringLastIndexOfChar_1( device,'/' ) + 1 ;
942  st = zuluCryptEXEVolumeInfo( e,device,uid ) ;
943  }
944  }else{
945  p = String( UUID ) ;
946  StringRemoveString( p,"\"" ) ;
947  e = StringSubChar( p,4,'-' ) ;
948 
949  if( StringPrefixEqual( device,"/dev/loop" ) ){
950 
951  /*
952  * zuluCryptLoopDeviceAddress_1() is defined in ../zuluCrypt-cli/lib/create_loop_device.c
953  */
954  dev = zuluCryptLoopDeviceAddress_1( device ) ;
955 
956  if( dev != NULL ){
957 
958  st = zuluCryptEXEVolumeInfo( e,dev,uid ) ;
959  StringFree( dev ) ;
960  }else{
961  printf( gettext( "ERROR: Could not get volume properties,volume is not open or was opened by a different user" ) ) ;
962  st = 1 ;
963  }
964  }else{
965  st = zuluCryptEXEVolumeInfo( e,device,uid ) ;
966  }
967  StringDelete( &p ) ;
968  }
969 
970  return st ;
971 }
972 
973 int zuluMountPrintBitLockerProperties( const char * device,uid_t uid )
974 {
975  string_t xt ;
976  string_t mt ;
977 
978  int r ;
979 
980  const char * e ;
981 
982  if( zuluCryptNoPartitionLoopDevice( device ) ){
983 
984  xt = zuluCryptLoopDeviceAddress_2( device ) ;
985  mt = StringCopy( xt ) ;
986 
988 
989  r = zuluMountUnEncryptedVolumeStatus( StringContent( mt ),"bitlocker",e ) ;
990 
991  StringDelete( &mt ) ;
992  }else{
993  xt = String( device ) ;
994 
996 
997  r = zuluMountUnEncryptedVolumeStatus( device,"bitlocker",e ) ;
998  }
999 
1000  StringDelete( &xt ) ;
1001 
1002  return r ;
1003 }
StringRemoveLeft
const char * StringRemoveLeft(string_t st, size_t x)
Definition: String.c:647
zuluCryptMultiPartitionLoopDevice
int zuluCryptMultiPartitionLoopDevice(const char *e)
Definition: blkid_evaluate_tag.c:171
StringListVoid
#define StringListVoid
Definition: StringList.h:41
StringReplace
const char * StringReplace(string_t st, const char *s)
Definition: String.c:984
zuluMountVolumeStatus
int zuluMountVolumeStatus(const char *device, const char *UUID, uid_t uid)
Definition: volume_status.c:915
zuluCryptBitLockerResolveMapperPath
string_t zuluCryptBitLockerResolveMapperPath(const char *e, uid_t uid)
Definition: bitlocker.c:203
_normal_mounted_volume
static int _normal_mounted_volume(string_t st)
Definition: volume_status.c:402
zuluCryptGetLoopDeviceAddress
char * zuluCryptGetLoopDeviceAddress(const char *device)
Definition: create_loop_device.c:203
StringsAreEqual_2
int StringsAreEqual_2(string_t x, const char *y)
Definition: String.c:1469
zuluCryptPartitionList
stringList_t zuluCryptPartitionList(void)
zuluCryptEvaluateDeviceTags
char * zuluCryptEvaluateDeviceTags(const char *tag, const char *path)
Definition: path_access.c:175
StringSubChar
const char * StringSubChar(string_t st, size_t x, char s)
Definition: String.c:881
StringCopy
string_t StringCopy(string_t st)
Definition: String.c:260
zuluCryptFormatSize
void zuluCryptFormatSize(u_int64_t number, char *buffer, size_t buffer_size)
Definition: status.c:113
zuluMountUnEncryptedVolumeStatus
int zuluMountUnEncryptedVolumeStatus(const char *device, const char *fs, const char *device1)
Definition: volume_status.c:814
StringListContentAtFirstPlace
static const __inline__ char * StringListContentAtFirstPlace(stringList_t stl)
Definition: StringList.h:182
_print_device_properties
static void _print_device_properties(string_t entry, const char *mapper_path, size_t mapper_length, uid_t uid)
Definition: volume_status.c:262
zuluCryptGetVolumeTypeFromMapperPath
char * zuluCryptGetVolumeTypeFromMapperPath(const char *mapper)
Definition: status.c:449
StringStartsWith
int StringStartsWith(string_t st, const char *s)
Definition: String.c:821
zuluCryptConvertIfPathIsLVM
string_t zuluCryptConvertIfPathIsLVM(const char *path)
Definition: resolve_paths.c:136
StringListHasStartSequence_1
string_t StringListHasStartSequence_1(stringList_t stl, const char *str)
Definition: StringList.c:897
StringReplaceChar_1
const char * StringReplaceChar_1(string_t st, size_t index, char x, char y)
Definition: String.c:1365
StringListGetIterators
void StringListGetIterators(stringList_t stl, StringListIterator *begin, StringListIterator *end)
Definition: StringList.c:210
zuluCryptLoopDeviceAddress_2
string_t zuluCryptLoopDeviceAddress_2(const char *device)
Definition: create_loop_device.c:101
StringListHasNoEntry
static int StringListHasNoEntry(stringList_t stl, const char *cstring)
Definition: StringList.h:485
zuluCryptLoopDeviceAddress_1
char * zuluCryptLoopDeviceAddress_1(const char *device)
Definition: create_loop_device.c:140
zuluCryptCreateMapperName
string_t zuluCryptCreateMapperName(const char *device, const char *mapping_name, uid_t uid, int i)
Definition: create_mapper_name.c:42
StringPrepend
const char * StringPrepend(string_t st, const char *s)
Definition: String.c:1015
zuluCryptNoPartitionLoopDevice
int zuluCryptNoPartitionLoopDevice(const char *e)
Definition: blkid_evaluate_tag.c:147
StringHasAtLeastOneComponent
int StringHasAtLeastOneComponent(string_t st,...)
Definition: String.c:1552
StringListDelete
void StringListDelete(stringList_t *stl)
Definition: StringList.c:1184
zuluCryptGetALoopDeviceAssociatedWithAnImageFile
char * zuluCryptGetALoopDeviceAssociatedWithAnImageFile(const char *path)
Definition: create_loop_device.c:174
zuluCryptGetAListOfAllVolumes
stringList_t zuluCryptGetAListOfAllVolumes(void)
Definition: volumes.c:406
StringListRemoveIfPresent
size_t StringListRemoveIfPresent(stringList_t stl, const char *str)
Definition: StringList.c:1030
StringMultipleAppend
const char * StringMultipleAppend(string_t st,...)
Definition: String.c:1123
StringCopy_2
char * StringCopy_2(const char *str)
Definition: String.c:725
zuluMountPartitionProperties
void zuluMountPartitionProperties(const char *dev, const char *UUID, const char *mapper, const char *m_point, const char *fs)
Definition: volume_status.c:43
StringListStringSplit
stringList_t StringListStringSplit(string_t st, char splitter)
Definition: StringList.c:483
_starts_with_digits_only
static int _starts_with_digits_only(string_t st)
Definition: volume_status.c:374
StringsAreEqual
#define StringsAreEqual(x, y)
Definition: zuluSafe.c:46
StringListContentAtThirdPlace
static const __inline__ char * StringListContentAtThirdPlace(stringList_t stl)
Definition: StringList.h:192
StringListStringAtFirstPlace
static __inline__ string_t StringListStringAtFirstPlace(stringList_t stl)
Definition: StringList.h:166
zuluCryptEXEVolumeInfo
int zuluCryptEXEVolumeInfo(const char *mapper, const char *device, uid_t)
Definition: volume_info.c:26
StringRemoveString
const char * StringRemoveString(string_t st, const char *s)
Definition: String.c:1328
zuluCryptMapperPrefix
const char * zuluCryptMapperPrefix(void)
Definition: create_mapper_name.c:95
StringListStringAt
string_t StringListStringAt(stringList_t stl, size_t index)
Definition: StringList.c:1171
StringContains
int StringContains(string_t st, const char *str)
Definition: String.c:420
zuluCryptUUIDFromPath
char * zuluCryptUUIDFromPath(const char *device)
Definition: path_access.c:197
StringLastIndexOfChar
ssize_t StringLastIndexOfChar(string_t st, char s)
Definition: String.c:488
StringListMultipleDelete
void StringListMultipleDelete(stringList_t *stl,...)
Definition: StringList.c:1249
zuluCryptVolumeType
const char * zuluCryptVolumeType(blkid_probe blkid, const char *device)
Definition: blkid_evaluate_tag.c:210
StringSize
static __inline__ size_t StringSize(const char *str)
Definition: String.h:846
zuluCryptVolumeDeviceName
char * zuluCryptVolumeDeviceName(const char *)
Definition: status.c:895
_zuluMountprintAListOfMountedVolumes
static void _zuluMountprintAListOfMountedVolumes(string_t st, uid_t uid)
Definition: volume_status.c:513
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
StringHasComponent_1
static __inline__ ssize_t StringHasComponent_1(const char *x, const char *y)
Definition: String.h:923
StringType
Definition: String.c:49
zuluCryptSecurityDropElevatedPrivileges
int zuluCryptSecurityDropElevatedPrivileges(void)
Definition: security.c:109
zuluCryptGetMoutedList
stringList_t zuluCryptGetMoutedList(void)
Definition: mountinfo.c:159
UUID
#define UUID
Definition: status.c:41
StringMultipleDelete
void StringMultipleDelete(string_t *xt,...)
Definition: String.c:195
zuluMountPrintVolumesProperties
int zuluMountPrintVolumesProperties(uid_t uid)
Definition: volume_status.c:423
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
String_1
string_t String_1(const char *cstring,...)
Definition: String.c:363
StringStartsWithAtLeastOne
int StringStartsWithAtLeastOne(string_t st,...)
Definition: String.c:1076
zuluCryptSecurityGainElevatedPrivileges
int zuluCryptSecurityGainElevatedPrivileges(void)
Definition: security.c:64
zuluCryptGetVolumeSize
u_int64_t zuluCryptGetVolumeSize(const char *device)
Definition: volumes.c:726
zuluCryptBitLockerType
const char * zuluCryptBitLockerType()
Definition: bitlocker.c:36
StringListStringAtSecondPlace
static __inline__ string_t StringListStringAtSecondPlace(stringList_t stl)
Definition: StringList.h:171
StringReplaceString
const char * StringReplaceString(string_t st, const char *x, const char *s)
Definition: String.c:1318
SIZE
#define SIZE
zuluCryptDecodeMountEntry
const char * zuluCryptDecodeMountEntry(string_t)
Definition: mount_volume.c:417
zuluCryptBitLockerCreateMapperPath
const char * zuluCryptBitLockerCreateMapperPath(string_t e, uid_t uid)
Definition: bitlocker.c:217
StringListType
Definition: StringList.c:33
zuluCryptGetVolumeType_1
char * zuluCryptGetVolumeType_1(const char *m)
Definition: status.c:470
e
static QString e
Definition: about.cpp:31
StringMultiplePrepend
const char * StringMultiplePrepend(string_t st,...)
Definition: String.c:1159
StringIterator
char * StringIterator
Definition: String.h:49
zuluCryptGetFileSystemFromDevice
string_t zuluCryptGetFileSystemFromDevice(const char *device)
Definition: blkid_evaluate_tag.c:137
StringDelete
void StringDelete(string_t *st)
Definition: String.c:162
StringListAppend
stringList_t StringListAppend(stringList_t stl, const char *cstring)
Definition: StringList.c:763
zuluMountprintAListOfMountedVolumes
int zuluMountprintAListOfMountedVolumes(uid_t uid)
Definition: volume_status.c:608
zuluCryptFileSystemProperties
void zuluCryptFileSystemProperties(string_t p, const char *mapper, const char *m_point)
Definition: status.c:253
StringListRemoveIfPresent_1
size_t StringListRemoveIfPresent_1(stringList_t stl, string_t st)
Definition: StringList.c:1025
StringGetIterators
void StringGetIterators(string_t st, StringIterator *begin, StringIterator *end)
Definition: String.c:133
StringPrintLine
void StringPrintLine(string_t st)
Definition: String.c:413
zuluCryptGetAListOfMountedVolumes
stringList_t zuluCryptGetAListOfMountedVolumes(void)
Definition: mountinfo.c:182
_fs
static const char * _fs(const char *e)
Definition: volume_status.c:33
zuluMountPrintBitLockerProperties
int zuluMountPrintBitLockerProperties(const char *device, uid_t uid)
Definition: volume_status.c:973
zuluCryptGetMountEntry
string_t zuluCryptGetMountEntry(const char *path)
Definition: mountinfo.c:347
StringAppend
const char * StringAppend(string_t st, const char *s)
Definition: String.c:1052
zuluCryptBitLockerVolume
int zuluCryptBitLockerVolume(const char *e)
Definition: bitlocker.c:150
zuluCryptLoopDeviceAddress
char * zuluCryptLoopDeviceAddress(const char *device)
Definition: create_loop_device.c:134
zuluMountPrintDeviceProperties
int zuluMountPrintDeviceProperties(const char *device, const char *UUID, uid_t uid)
Definition: volume_status.c:652
ZULUCRYPTlongMapperPath
#define ZULUCRYPTlongMapperPath
Definition: constants.h:36
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