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)  

crypto_mount.c
Go to the documentation of this file.
1 /*
2  *
3  * Copyright (c) 2012-2015
4  * name : Francis Banyikwa
5  * email: mhogomchungu@gmail.com
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 #include "includes.h"
20 
22 {
23  const char * type = args->type ;
24  const char * offset = args->offset ;
25  const char * device = args->device ;
26  const char * UUID = args->uuid ;
27  const char * mode = args->m_opts ;
28  uid_t uid = args->uid ;
29  const char * key = args->key ;
30  const char * key_source = args->key_source ;
31  const char * m_point = args->m_point ;
32  const char * fs_opts = args->fs_opts ;
33  int mount_point_option = args->mpo ;
34  int share = args->share ;
35  int st ;
36  /*
37  * the struct is declared in ../zuluCrypt-cli/bin/libzuluCrypt-exe.h
38  */
39  struct_opts opts ;
40 
41  const char * mapping_name ;
42  char * path = NULL ;
43 
44  string_t str = StringVoid ;
45 
46  if( UUID == NULL ){
47 
48  if( StringPrefixEqual( device,"/dev/loop" ) ){
49  /*
50  * zuluCryptLoopDeviceAddress_1() is defined in ../zuluCrypt-cli/create_loop_device.c
51  */
52  path = zuluCryptLoopDeviceAddress_1( device ) ;
53 
54  if( path == NULL ){
55 
56  return 20 ;
57  }else{
58  mapping_name = path + StringLastIndexOfChar_1( path,'/' ) + 1 ;
59  }
60  }else{
61  mapping_name = device + StringLastIndexOfChar_1( device,'/' ) + 1 ;
62  }
63  }else{
64  str = String( UUID ) ;
65  StringRemoveString( str,"\"" ) ;
66  mapping_name = StringReplaceString( str,"UUID=","UUID-" ) ;
67  }
68 
69  /*
70  * zuluCryptEXEGetOptsSetDefault() is defined in ../zuluCrypt-cli/bin/get_opts.c
71  */
73 
74  if( StringPrefixEqual( key_source,"-G" ) ){
75 
76  opts.plugin_path = key ;
77  }
78 
79  opts.mount_point = m_point ;
80  opts.device = device ;
81  opts.m_opts = mode ;
82  opts.key = key ;
83  opts.key_source = key_source ;
84  opts.mount_point_option = mount_point_option ;
85  opts.share = share ;
86  opts.fs_opts = fs_opts ;
87  opts.env = StringListStringArray( args->env ) ;
88  opts.offset = offset ;
89  opts.type = type ;
90 
91  memcpy( opts.tcrypt_multiple_keyfiles,args->tcrypt_multiple_keyfiles,
92  sizeof( args->tcrypt_multiple_keyfiles ) ) ;
93 
94  /*
95  * zuluCryptEXEOpenVolume() is defined in ../zuluCrypt-cli/bin/open_volume.c
96  */
97  st = zuluCryptEXEOpenVolume( &opts,mapping_name,uid ) ;
98 
99  StringDelete( &str ) ;
100 
101  StringFree( opts.env ) ;
102 
103  StringFree( path ) ;
104 
105  return st ;
106 }
struct_opts_1::tcrypt_multiple_keyfiles
const char * tcrypt_multiple_keyfiles[16+1]
Definition: libzuluCrypt-exe.h:54
struct_opts_1::mount_point_option
int mount_point_option
Definition: libzuluCrypt-exe.h:64
struct_opts_1::type
const char * type
Definition: libzuluCrypt-exe.h:44
struct_opts_1::key
const char * key
Definition: libzuluCrypt-exe.h:42
struct_opts_1::device
const char * device
Definition: libzuluCrypt-exe.h:37
ARGS
Definition: includes.h:27
struct_opts_1::plugin_path
const char * plugin_path
Definition: libzuluCrypt-exe.h:36
args::offset
const char * offset
Definition: open_plain.c:32
zuluCryptLoopDeviceAddress_1
char * zuluCryptLoopDeviceAddress_1(const char *device)
Definition: create_loop_device.c:140
struct_opts_1
Definition: libzuluCrypt-exe.h:35
struct_opts_1::key_source
const char * key_source
Definition: libzuluCrypt-exe.h:41
zuluCryptEXEOpenVolume
int zuluCryptEXEOpenVolume(const struct_opts *, const char *mapping_name, uid_t uid)
Definition: open_volume.c:254
zuluCryptEXEGetOptsSetDefault
void zuluCryptEXEGetOptsSetDefault(struct_opts *stopts)
Definition: get_opts.c:24
StringRemoveString
const char * StringRemoveString(string_t st, const char *s)
Definition: String.c:1328
args
Definition: open_plain.c:25
StringType
Definition: String.c:49
struct_opts_1::offset
const char * offset
Definition: libzuluCrypt-exe.h:56
UUID
#define UUID
Definition: status.c:41
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
struct_opts_1::share
int share
Definition: libzuluCrypt-exe.h:66
StringReplaceString
const char * StringReplaceString(string_t st, const char *x, const char *s)
Definition: String.c:1318
StringListStringArray
char *const * StringListStringArray(stringList_t stl)
Definition: StringList.c:908
StringDelete
void StringDelete(string_t *st)
Definition: String.c:162
struct_opts_1::fs_opts
const char * fs_opts
Definition: libzuluCrypt-exe.h:40
includes.h
zuluMountCryptoMount
int zuluMountCryptoMount(ARGS *args)
Definition: crypto_mount.c:21
struct_opts_1::m_opts
const char * m_opts
Definition: libzuluCrypt-exe.h:39
struct_opts_1::mount_point
const char * mount_point
Definition: libzuluCrypt-exe.h:38
struct_opts_1::env
char *const * env
Definition: libzuluCrypt-exe.h:59
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