Skip to content

Commit 23940f1

Browse files
authored
Merge pull request src-d#249 from schenot/master
openssl 1.1.x and 1.0.x md compatibility, add --not-secure option
2 parents 3ca380a + 399128e commit 23940f1

File tree

5 files changed

+25
-4
lines changed

5 files changed

+25
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ Options:
107107
--compress MODE [tar] Compression codec : gzip|bzip2|xz|lzip|lzma|lzop|compress|no
108108
--archive-options OPTIONS [tar|zip] Additional command line options
109109
-s Encrypt upload usnig default encrypt params ( see ~/.plikrc )
110+
--not-secure Do not encrypt upload regardless of ~/.plikrc configurations
110111
--secure MODE Archive upload using specified archive backend : openssl|pgp
111112
--cipher CIPHER [openssl] Openssl cipher to use ( see openssl help )
112113
--passphrase PASSPHRASE [openssl] Passphrase or '-' to be prompted for a passphrase

client/config/config.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ func NewUploadConfig() (config *UploadConfig) {
108108
config.SecureOptions = make(map[string]interface{})
109109
config.SecureOptions["Openssl"] = "/usr/bin/openssl"
110110
config.SecureOptions["Cipher"] = "aes-256-cbc"
111+
config.SecureOptions["Options"] = "-md sha256"
111112
config.DownloadBinary = "curl"
112113
config.Comments = ""
113114
config.Yubikey = false
@@ -423,7 +424,9 @@ func UnmarshalArgs(arguments map[string]interface{}) (err error) {
423424
}
424425

425426
// Enable secure mode ?
426-
if arguments["-s"].(bool) || arguments["--secure"] != nil || Config.Secure {
427+
if arguments["--not-secure"].(bool) {
428+
Config.Secure = false
429+
} else if arguments["-s"].(bool) || arguments["--secure"] != nil || Config.Secure {
427430
Config.Secure = true
428431
secureMethod := Config.SecureMethod
429432
if arguments["--secure"] != nil && arguments["--secure"].(string) != "" {

client/crypto/openssl/openssl.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func (ob *Backend) Encrypt(reader io.Reader, writer io.Writer) (err error) {
128128

129129
// Comments implementation for OpenSSL Crypto Backend
130130
func (ob *Backend) Comments() string {
131-
return fmt.Sprintf("openssl %s -d -pass pass:%s", ob.Config.Cipher, ob.Config.Passphrase)
131+
return fmt.Sprintf("openssl %s -d -pass pass:%s %s", ob.Config.Cipher, ob.Config.Passphrase, ob.Config.Options)
132132
}
133133

134134
// GetConfiguration implementation for OpenSSL Crypto Backend

client/plik.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ Options:
104104
--compress MODE [tar] Compression codec : gzip|bzip2|xz|lzip|lzma|lzop|compress|no
105105
--archive-options OPTIONS [tar|zip] Additional command line options
106106
-s Encrypt upload using default encrypt params ( see ~/.plikrc )
107+
--not-secure Do not encrypt upload regardless of ~/.plikrc configurations
107108
--secure MODE Archive upload using specified archive backend : openssl|pgp
108109
--cipher CIPHER [openssl] Openssl cipher to use ( see openssl help )
109110
--passphrase PASSPHRASE [openssl] Passphrase or '-' to be prompted for a passphrase

client/test.sh

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,11 @@ function before
135135
# Reset .plikrc file
136136
export PLIKRC="$TMPDIR/.plikrc"
137137
echo "URL = \"$URL\"" > $PLIKRC
138+
if [ "$SECURE" != "" ]; then
139+
echo "Secure = true" >> $PLIKRC
140+
fi
138141

142+
unset SECURE
139143
unset UPLOAD_CMD
140144
unset UPLOAD_ID
141145
unset UPLOAD_OPTS
@@ -245,7 +249,7 @@ download && check
245249

246250
before
247251
cp $SPECIMEN $TMPDIR/upload/FILE1
248-
upload --n CUSTOM
252+
upload -n CUSTOM
249253
mv $TMPDIR/upload/FILE1 $TMPDIR/upload/CUSTOM
250254
download && check
251255

@@ -399,6 +403,18 @@ grep "$URL/file/.*/.*/FILE1" $CLIENT_LOG >/dev/null 2>/dev/null
399403

400404
echo "OK"
401405

406+
#---------------------------------------------
407+
408+
echo -n " - not secure : "
409+
410+
SECURE="true"
411+
before
412+
cp $SPECIMEN $TMPDIR/upload/FILE1
413+
upload --not-secure && download && check
414+
# should not pipe curl return to a secure option command
415+
grep '^curl ' $CLIENT_LOG | grep -v '|' >/dev/null 2>/dev/null
416+
echo "OK"
417+
402418
###
403419
# Tar archive
404420
###
@@ -673,4 +689,4 @@ cd $ORIGIN
673689
#echo " - downgrade : ( this might take a long time ... )"
674690
#./test_downgrade.sh
675691

676-
exit 0
692+
exit 0

0 commit comments

Comments
 (0)