From 38756af1c138a8cee18da10accdf68dd802be150 Mon Sep 17 00:00:00 2001 From: Daniel Barlow Date: Fri, 3 Mar 2023 23:06:18 +0000 Subject: [PATCH] add in_outputs shell function which ensures umask is set --- devices/gl-ar750/default.nix | 2 +- pkgs/liminix-tools/networking/pppoe.nix | 2 +- pkgs/liminix-tools/networking/udhcpc.nix | 2 +- pkgs/service-fns/default.nix | 3 +++ rotuer.nix | 8 +++----- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/devices/gl-ar750/default.nix b/devices/gl-ar750/default.nix index a513a78..be683e1 100644 --- a/devices/gl-ar750/default.nix +++ b/devices/gl-ar750/default.nix @@ -78,7 +78,7 @@ part=$(basename $(dirname $(grep -l art /sys/class/mtd/*/name))) echo ART partition is ''${part-unset} test -n "$part" || exit 1 - (cd $(mkoutputs ${name}); umask 0027 + (in_outputs ${name} dd if=/dev/$part of=data iflag=skip_bytes,fullblock bs=${toString size} skip=${toString offset} count=1 ) ''; diff --git a/pkgs/liminix-tools/networking/pppoe.nix b/pkgs/liminix-tools/networking/pppoe.nix index e2aaac9..d5c5d69 100644 --- a/pkgs/liminix-tools/networking/pppoe.nix +++ b/pkgs/liminix-tools/networking/pppoe.nix @@ -19,7 +19,7 @@ let name = "${interface.device}.pppoe"; ip-up = writeAshScript "ip-up" {} '' . ${serviceFns} - (cd $(mkoutputs ${name}); umask 0027 + (in_outputs ${name} echo $1 > ifname echo $2 > tty echo $3 > speed diff --git a/pkgs/liminix-tools/networking/udhcpc.nix b/pkgs/liminix-tools/networking/udhcpc.nix index 8d8d522..b55a489 100644 --- a/pkgs/liminix-tools/networking/udhcpc.nix +++ b/pkgs/liminix-tools/networking/udhcpc.nix @@ -16,7 +16,7 @@ let set_address() { ip address replace $ip/$mask dev $interface - (cd $(mkoutputs ${name}); umask 0027 + (in_outputs ${name} for i in lease mask ip router siaddr dns serverid subnet opt53 interface ; do echo ''${!i} > $i done) diff --git a/pkgs/service-fns/default.nix b/pkgs/service-fns/default.nix index 2c6dd36..15c5300 100644 --- a/pkgs/service-fns/default.nix +++ b/pkgs/service-fns/default.nix @@ -7,4 +7,7 @@ writeText "service-fns.sh" '' mkdir -m 2750 -p $d && chown root:system $d echo $d } + in_outputs() { + cd `mkoutputs $1` && umask 0027 + } '' diff --git a/rotuer.nix b/rotuer.nix index 59f2986..9be278b 100644 --- a/rotuer.nix +++ b/rotuer.nix @@ -141,10 +141,8 @@ in rec { }; in bundle { name = "bridge-members"; - contents = map addif [ - config.hardware.networkInterfaces.wlan_24 - config.hardware.networkInterfaces.lan - config.hardware.networkInterfaces.wlan_5 + contents = with config.hardware.networkInterfaces; map addif [ + wlan_24 lan wlan_5 ]; }; @@ -181,7 +179,7 @@ in rec { name = "resolvconf"; up = '' . ${serviceFns} - ( cd `mkoutputs ${name}`; umask 0027 + ( in_outputs ${name} echo "nameserver $(output ${services.wan} ns1)" > resolv.conf echo "nameserver $(output ${services.wan} ns2)" >> resolv.conf )