# # FetchURL downloading a file from a LightTPD server through a Wireguard VPN # # By default, the file is an short inline HTML file at lighttpd and downloaded # into RAM in fetchurl. However, when the test is run with base-linux, # lighttpd uses a file created by the host filled filled with zeroes and of # customizable size and fetchurl downloads into the host FS, so the test can # then check the MD5 sum of the file. # if {[expr ![have_spec arm_64] && ![have_spec x86_64]]} { puts "Run script is not supported on this platform." exit 0 } if {[have_spec linux]} { set linux 1 set not_linux 0 } else { set linux 0 set not_linux 1 } # # Note that in the not_linux case, the file size is rounded # down to a multiple of 100. # set file_size_in_bytes 1000000 create_boot_directory import_from_depot [depot_user]/src/libc \ [depot_user]/src/libssh \ [depot_user]/src/lighttpd \ [depot_user]/src/openssl \ [depot_user]/src/posix \ [depot_user]/src/vfs \ [depot_user]/src/vfs_lwip \ [depot_user]/src/zlib \ [depot_user]/pkg/wireguard append config { } append_if $linux config { } append config { 2019-07-04 12:00 01234567890123456789 } append_if $linux config { } append_if $not_linux config { } append config { 2000-01-01 00:00 0123456789012345678901234567890123456789 # lighttpd configuration server.port = 80 server.document-root = "/website" server.event-handler = "select" server.network-backend = "write" server.upload-dirs = ( "/tmp" ) server.modules = ("mod_openssl") index-file.names = ( "index.xhtml", "index.html", "index.htm" ) mimetype.assign = ( ".html" => "text/html", ".htm" => "text/html" ) $SERVER["socket"] == ":443" { ssl.engine = "enable" ssl.pemfile = "/etc/lighttpd/example.pem" } -----BEGIN PRIVATE KEY----- MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQC4KHUZjDRew89c wDlYPz9XFigcMDnDlHzdg2ByrGZIOUNYC5LH1QUK0TDbPP45Xx455niA0QY85dMQ 4DQx0Qk6+TDpVD3F2MYQgbIX6YkX9kgqX+jiHgsNzRD4KamNYmfUY+dJhlZEXWAF uNSnRLvg4EH72AVKLLKiruGwkisW/AYU6dNE8iFOYL8Q75bBUADiQSDdD8vkpeXg 1NqxNyHPR6YRbA+vqcK0kbC8btKR9wG6m99OhTR4x3M87vtFFLN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eFvOfjAPBgNVHRMBAf8EBTADAQH/MA0GCSqGSIb3DQEBCwUAA4IBAQBR sGYEuRwIU/tmAmTbniptItN9VE0NNj9QeKh+hKQ9cHvhxmlBlf5b7Vb2JaRZdy88 kRIFKiNkyjgQVg+5KuEIcg17mHSal7zG+jIZ3c1bIpVCM4AjUe7EXl8LM4+dJ5sX Bwpd34tUk2edOiT8R/dU7uesxCdeIQ2FfvKyrXca73nj+UTvFGXUk/9mWY8KAaYc F/PWBhiZhJD4/dkUHJnrVtjpcqW2Io8bFmrMq2vfqQv+W2FZGCsHgXkAZO2E0jyQ 5eOrwzgWRtMc5PvoGvqQfefseaLs0fvSQdcPqfv88Eqk5NGTOCIW8/KEsBwFJuwa EpA5DBBklj8UE2CdONvN -----END CERTIFICATE----- } append_if $linux config { } if {$not_linux} { append config {} for {set i 0} {$i < $file_size_in_bytes} {incr i 64} { # append 100 bytes of "0" append config {0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000} } append config {} } append config { } install_config $config append targets { core init timer lib/ld server/nic_router server/report_rom lib/curl app/fetchurl } if $linux { append targets { server/lx_fs } # create the lx_fs root of fetchurl where it will store the downloaded file proc lx_fs_root {} { return [run_dir]/genode } exec rm -rf [lx_fs_root]/fetchurl_fs exec mkdir -p [lx_fs_root]/fetchurl_fs # create the lx_fs root of lighttpd and the downloadable file inside it exec rm -rf [lx_fs_root]/lighttpd_fs exec mkdir -p [lx_fs_root]/lighttpd_fs exec head -c $file_size_in_bytes /dev/zero > [lx_fs_root]/lighttpd_fs/index.html } build $targets build_boot_image [build_artifacts] append qemu_args "-nographic " # run the scenario till fetchurl succeeded to download the file run_genode_until "fetchurl. exited with exit value 0.*\n" 60 if {$linux} { # check that the md5 sum of the downloaded file is correct set lighttpd_index_md5 [exec md5sum [lx_fs_root]/lighttpd_fs/index.html] set fetchurl_index_md5 [exec md5sum [lx_fs_root]/fetchurl_fs/index.html] puts "" puts $lighttpd_index_md5 puts $fetchurl_index_md5 puts "MD5SUM of transferred files is correct" if {[string compare -length 32 $lighttpd_index_md5 $fetchurl_index_md5]} { puts "" puts "Error: MD5SUM of transferred files is incorrect" puts "" exit -1 } }