@@ -11,6 +11,7 @@ import (
11
11
"path/filepath"
12
12
"runtime"
13
13
"runtime/pprof"
14
+ "strconv"
14
15
"syscall"
15
16
"time"
16
17
@@ -25,6 +26,7 @@ import (
25
26
"github.com/rfjakob/gocryptfs/internal/cryptocore"
26
27
"github.com/rfjakob/gocryptfs/internal/fusefrontend"
27
28
"github.com/rfjakob/gocryptfs/internal/nametransform"
29
+ "github.com/rfjakob/gocryptfs/internal/prefer_openssl"
28
30
"github.com/rfjakob/gocryptfs/internal/toggledlog"
29
31
)
30
32
@@ -149,14 +151,15 @@ func main() {
149
151
setupColors ()
150
152
151
153
// Parse command line arguments
154
+ var opensslAuto string
152
155
flagSet = flag .NewFlagSet (toggledlog .ProgramName , flag .ExitOnError )
153
156
flagSet .Usage = usageText
154
157
flagSet .BoolVar (& args .debug , "d" , false , "" )
155
158
flagSet .BoolVar (& args .debug , "debug" , false , "Enable debug output" )
156
159
flagSet .BoolVar (& args .fusedebug , "fusedebug" , false , "Enable fuse library debug output" )
157
160
flagSet .BoolVar (& args .init , "init" , false , "Initialize encrypted directory" )
158
161
flagSet .BoolVar (& args .zerokey , "zerokey" , false , "Use all-zero dummy master key" )
159
- flagSet .BoolVar ( & args . openssl , "openssl" , true , "Use OpenSSL instead of built-in Go crypto" )
162
+ flagSet .StringVar ( & opensslAuto , "openssl" , "auto" , "Use OpenSSL instead of built-in Go crypto" )
160
163
flagSet .BoolVar (& args .passwd , "passwd" , false , "Change password" )
161
164
flagSet .BoolVar (& args .foreground , "f" , false , "Stay in the foreground" )
162
165
flagSet .BoolVar (& args .version , "version" , false , "Print version and exit" )
@@ -180,19 +183,30 @@ func main() {
180
183
"Setting this to a lower value speeds up mounting but makes the password susceptible to brute-force attacks" )
181
184
flagSet .Parse (os .Args [1 :])
182
185
186
+ // "-openssl" needs some post-processing
187
+ if opensslAuto == "auto" {
188
+ args .openssl = prefer_openssl .PreferOpenSSL ()
189
+ } else {
190
+ args .openssl , err = strconv .ParseBool (opensslAuto )
191
+ if err != nil {
192
+ fmt .Printf (colorRed + "Invalid \" -openssl\" setting: %v\n " + colorReset , err )
193
+ os .Exit (ERREXIT_USAGE )
194
+ }
195
+ }
196
+
183
197
// Fork a child into the background if "-f" is not set AND we are mounting a filesystem
184
198
if ! args .foreground && flagSet .NArg () == 2 {
185
199
forkChild () // does not return
186
200
}
201
+ if args .debug {
202
+ toggledlog .Debug .Enabled = true
203
+ }
187
204
// "-v"
188
205
if args .version {
206
+ toggledlog .Debug .Printf ("openssl=%v\n " , args .openssl )
189
207
printVersion ()
190
208
os .Exit (0 )
191
209
}
192
- if args .debug {
193
- toggledlog .Debug .Enabled = true
194
- toggledlog .Debug .Printf ("Debug output enabled" )
195
- }
196
210
if args .wpanic {
197
211
toggledlog .Warn .Wpanic = true
198
212
toggledlog .Debug .Printf ("Panicing on warnings" )
@@ -255,7 +269,9 @@ func main() {
255
269
}
256
270
// "-openssl"
257
271
if args .openssl == false {
258
- toggledlog .Info .Printf ("Openssl disabled" )
272
+ toggledlog .Debug .Printf ("OpenSSL disabled, using Go GCM" )
273
+ } else {
274
+ toggledlog .Debug .Printf ("OpenSSL enabled" )
259
275
}
260
276
// Operation flags: init, passwd or mount
261
277
// "-init"
0 commit comments