diff --git a/dtrfs_api/src/main.rs b/dtrfs_api/src/main.rs index b4f8e18..cd11718 100644 --- a/dtrfs_api/src/main.rs +++ b/dtrfs_api/src/main.rs @@ -199,7 +199,7 @@ async fn main() -> std::io::Result<()> { .service(get_report) .service(homepage) }) - .bind_rustls_0_23("[::]:8443", config)? + .bind_rustls_0_23("[::]:22", config)? .run() .await } diff --git a/scripts/create.sh b/scripts/create.sh index 5518a8f..aa6d6f2 100755 --- a/scripts/create.sh +++ b/scripts/create.sh @@ -19,6 +19,7 @@ install_binary $(which openssl) && cp -r /etc/ssl "${ROOT}/etc/" install_binary $(which cryptsetup) install_binary $(which blkid) install_binary $(which fdisk) +install_binary $(which sysctl) install_binary $(which mkfs.ext4) install_binary $(which fsarchiver) install_kmod diff --git a/scripts/creator_functions.sh b/scripts/creator_functions.sh index fdc8881..1bcbd26 100644 --- a/scripts/creator_functions.sh +++ b/scripts/creator_functions.sh @@ -184,6 +184,7 @@ scan_modules() { install_dtrfs_api() { local my_location="$(pwd)" + echo_cyan "Building dtrfs_api..." cd ../../dtrfs_api && cargo build --release || { echo_yellow "Could not build dtrfs_api. Looking for binary at $(pwd)/dtrfs_api" } @@ -194,7 +195,7 @@ install_dtrfs_api() { create_archive() { local archive="detee-$(hostnamectl hostname)-${KERNEL}.cpio.gz" - echo_cyan "Creating archive build/$archive" + echo_cyan "Creating archive $(pwd)/$archive" echo $archive > .archive_name my_location="$(pwd)" cd ${ROOT} diff --git a/scripts/init_functions.sh b/scripts/init_functions.sh index 79ab032..81baec1 100644 --- a/scripts/init_functions.sh +++ b/scripts/init_functions.sh @@ -39,27 +39,48 @@ create_certs() { -days 365 -subj "$subject" 2>/dev/null } -# expects kernel param in this format: detee_net=192.168.122.140_24_192.168.122.1_1.1.1.1 -setup_network() { - local settings='' ip_addr='' mask='' cidr='' gateway='' nameserver='' - settings=$(cat /proc/cmdline | grep -oE 'detee_net=[0-9a-z\_\:\.]+' | cut -d '=' -f2) - # TODO: replace with exit 0 when you are ready to force a kernel panic +setup_network_device() { + local device="$1" settings="$2" ip_addr='' mask='' cidr='' gateway='' [[ -z "$settings" ]] && return 0 - settings="${settings#detee_net=}" - ip_addr="$( echo ${settings} | cut -d'_' -f1 )" - mask="$( echo ${settings} | cut -d'_' -f2 )" + ip_addr="$( echo ${settings} | cut -d '_' -f1 )" + mask="$( echo ${settings} | cut -d '_' -f2 )" cidr="${ip_addr}/${mask}" - gateway="$( echo ${settings} | cut -d'_' -f3 )" - nameserver="$( echo ${settings} | cut -d'_' -f4 )" + gateway="$( echo ${settings} | cut -d '_' -f3 )" - ip addr add $cidr dev eth0 - ip link set eth0 up + ip addr add $cidr dev $device + ip link set $device up + sysctl -w net.ipv6.conf.$device.accept_ra=0 ip route add default via $gateway - echo nameserver $nameserver > /etc/resolv.conf sleep 2 ping -c 2 $gateway } +# Expects kernel param in this format: detee_net=192.168.122.140_24_192.168.122.1_1.1.1.1 +# In case the interface name is not specified, it defaults to eth0 +# Supports manual device, for example: detee_net_eth1 +# TODO: test if it is required to specify mac instead of device name +setup_network() { + local device_eth0_cfg='' device_cfg='' device_configs='' + sysctl -w net.ipv6.conf.all.accept_ra=0 + sysctl -w net.ipv6.conf.default.accept_ra=0 + # handle the default: detee_net=... + device_eth0_cfg=$(cat /proc/cmdline | grep -oE "detee_net=[0-9a-f\_\:\.]+" | cut -d '=' -f2) + [[ -z "$device_eth0_cfg" ]] || setup_network_device eth0 $device_eth0_cfg + + # handle extra devices: detee_net_eth1=... + device_configs=$(cat /proc/cmdline| grep -oE "detee_net_[a-z0-9]*=[0-9a-f\_\:\.]+") + while read -r device_cfg; do + setup_network_device \ + $(echo $device_cfg | cut -d '=' -f1 | cut -d '_' -f3) \ + $(echo $device_cfg | cut -d '=' -f2) + done <<< "$( echo "$device_configs" )" + + echo nameserver 1.1.1.1 >> /etc/resolv.conf + echo nameserver 1.0.0.1 >> /etc/resolv.conf + echo nameserver 2606:4700:4700::1111 >> /etc/resolv.conf + echo nameserver 2606:4700:4700::1001 >> /etc/resolv.conf +} + # detee_ghu stands for GitHub user and expects format detee_ghu=ghe0 github_ssh_key() {