shithub: riscv

Download patch

ref: b0a470fa0d47cf46d47aec7229f97c6ef700dcb1
parent: 833831ad98a27b1a1b7b5136224741392659d2ba
author: cinap_lenrek <[email protected]>
date: Thu Aug 1 21:22:53 EDT 2013

smtp: fix -t flag

--- a/sys/src/cmd/upas/smtp/smtp.c
+++ b/sys/src/cmd/upas/smtp/smtp.c
@@ -120,7 +120,8 @@
 	ARGBEGIN{
 	case 'a':
 		tryauth = 1;
-		trysecure = 1;
+		if(trysecure == 0)
+			trysecure = 1;
 		break;
 	case 'A':	/* autistic: won't talk to us until we talk (Verizon) */
 		autistic = 1;
@@ -150,7 +151,8 @@
 		ping = 1;
 		break;
 	case 's':
-		trysecure = 1;
+		if(trysecure == 0)
+			trysecure = 1;
 		break;
 	case 't':
 		trysecure = 2;
@@ -221,10 +223,8 @@
 	/* 10 minutes to get through the initial handshake */
 	atnotify(timeout, 1);
 	alarm(10*alarmscale);
-	if(trysecure > 1 && (rv = wraptls()) != nil)
+	if((rv = hello(hellodomain, 0)) != 0)
 		goto error;
-	if((rv = hello(hellodomain, trysecure > 1)) != 0)
-		goto error;
 	alarm(10*alarmscale);
 	if((rv = mailfrom(s_to_c(from))) != 0)
 		goto error;
@@ -474,6 +474,12 @@
 	char *ret, *s, *t;
 
 	if (!encrypted) {
+		if(trysecure > 1){
+			if((ret = wraptls()) != nil)
+				return ret;
+			encrypted = 1;
+		}
+
 		/*
 		 * Verizon fails to print the smtp greeting banner when it
 		 * answers a call.  Send a no-op in the hope of making it