File 0202-ftp-set-vsftpd-to-force-what-unit-test-is-testing.patch of Package erlang

From 0e0d1c3965b418cebeaf284a81ddaaa2982fcda5 Mon Sep 17 00:00:00 2001
From: Alexander Clouter <alex@digriz.org.uk>
Date: Thu, 28 May 2020 16:27:30 +0100
Subject: [PATCH 12/14] ftp: set vsftpd to force what unit test is testing

---
 lib/ftp/test/ftp_SUITE.erl              | 34 ++++++++++++++++++-------
 lib/ftp/test/ftp_SUITE_data/vsftpd.conf |  3 +--
 2 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/lib/ftp/test/ftp_SUITE.erl b/lib/ftp/test/ftp_SUITE.erl
index 5327e27a4d..2ba54211e4 100644
--- a/lib/ftp/test/ftp_SUITE.erl
+++ b/lib/ftp/test/ftp_SUITE.erl
@@ -147,15 +147,31 @@ ftp_sup_tests() ->
                   AnonRoot = PrivDir,
                   Cmd0 = AbsName,
                   Args0 = [filename:join(DataDir,"vsftpd.conf"),
-                          "-oftpd_banner=erlang_otp_testing",
-                          "-oanon_root=\"" ++ AnonRoot ++ "\"",
-                          "-orsa_cert_file=\"" ++ filename:join(DataDir,"server-cert.pem") ++ "\"",
-                          "-orsa_private_key_file=\"" ++ filename:join(DataDir,"server-key.pem") ++ "\""
-                         ],
-                  Args = lists:append(Args0, case proplists:get_value(ftpd_ssl_reuse,__CONF__) of
-                      true -> ["-orequire_ssl_reuse=YES"];
+                           "-oftpd_banner=erlang_otp_testing",
+                           "-oanon_root=\"" ++ AnonRoot ++ "\""
+                          ],
+                  Args1 = lists:append(Args0, case proplists:get_value(name, proplists:get_value(tc_group_properties,__CONF__,[])) of
+                      ftp_active -> ["-opasv_enable=NO"];
+                      ftp_passive -> ["-oport_enable=NO"];
                       _ -> []
                   end),
+                  Args = case proplists:get_value(ftpd_ssl,__CONF__) of
+                      true ->
+                          A0 = [
+                                "-ossl_enable=YES",
+                                "-orsa_cert_file=\"" ++ filename:join(DataDir,"server-cert.pem") ++ "\"",
+                                "-orsa_private_key_file=\"" ++ filename:join(DataDir,"server-key.pem") ++ "\"",
+                                "-oforce_anon_logins_ssl=YES",
+                                "-oforce_anon_data_ssl=YES"
+                               ],
+                          A1 = case proplists:get_value(ftpd_ssl_reuse,__CONF__) of
+                              true -> ["-orequire_ssl_reuse=YES"];
+                              _ -> []
+                          end,
+                          lists:append([Args1, A0, A1]);
+                      _ ->
+                          Args1
+                  end,
                   % eof on stdin does not kill vsftpd
                   Cmd = "script -qefc '" ++ "stty -echo intr ^D && exec " ++ string:join([Cmd0|Args], " ") ++ "' /dev/null",
                   Parent = self(),
@@ -238,7 +254,7 @@ init_per_group(Group, Config) when Group == ftps_active;
     catch crypto:stop(),
     try crypto:start() of
         ok ->
-            start_ftpd(Config)
+            start_ftpd([{ftpd_ssl,true}|Config])
     catch
         _:_ ->
             {skip, "Crypto did not start"}
@@ -272,7 +288,7 @@ init_per_testcase(Case, Config0) ->
             catch crypto:stop(),
             try crypto:start() of
                 ok ->
-                    Config = start_ftpd([{ftpd_ssl_reuse,true}|Config0]),
+                    Config = start_ftpd([{ftpd_ssl,true},{ftpd_ssl_reuse,true}|Config0]),
                     init_per_testcase2(Case, Config)
             catch
                 _:_ ->
diff --git a/lib/ftp/test/ftp_SUITE_data/vsftpd.conf b/lib/ftp/test/ftp_SUITE_data/vsftpd.conf
index d615ad4d7b..51cea2dcd8 100644
--- a/lib/ftp/test/ftp_SUITE_data/vsftpd.conf
+++ b/lib/ftp/test/ftp_SUITE_data/vsftpd.conf
@@ -10,7 +10,6 @@
 listen=YES
 listen_port=9999
 run_as_launching_user=YES
-ssl_enable=YES
 ssl_ciphers=HIGH:!aNULL:!MD5
 allow_anon_ssl=YES
 
@@ -25,7 +24,7 @@ anon_mkdir_write_enable=YES
 anon_other_write_enable=YES
 anon_world_readable_only=NO
 
-### Shouldn't be necessary....
+### Explicitly changed by unit test
 require_ssl_reuse=NO
 
 ### Logging
-- 
2.26.2

openSUSE Build Service is sponsored by