aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2021-06-21 21:08:26 +0200
committerGravatar Christian Hesse <mail@eworm.de>2021-06-21 22:58:17 +0200
commit7fb4fdfca264b9ab481994bed6f3ebc5c9623903 (patch)
tree6925869a837dad8d9bdac730aa66bc47a5463898
parentc0b954abbb67ef4b1d66cce47984b7bdfda8b2c7 (diff)
global-functions: $MkDir: abuse smb share to create directory
The smb feature is provided by system package... So we have it anyway. It gives some benefits compared to abusing fetch: * It is faster! * No need to alter, enable and restore a service! (The share is created disabled.) * Firewall rules can not break this. * No temporary file is created. * Less code! Let's hope we do not introduce new breakage. Closes #14
-rw-r--r--global-functions12
1 files changed, 5 insertions, 7 deletions
diff --git a/global-functions b/global-functions
index 422eac0..a4b4c4c 100644
--- a/global-functions
+++ b/global-functions
@@ -536,6 +536,7 @@
:local Dir [ :tostr $1 ];
:global CleanFilePath;
+ :global GetRandom20CharHex;
:global WaitForFile;
:set Dir [ $CleanFilePath $Dir ];
@@ -545,17 +546,14 @@
}
:local Return true;
- :local WwwVal [ / ip service get www ];
- / ip service set www address=127.0.0.1/32 disabled=no port=80;
+ :local Name ($Dir . "-" . [ $GetRandom20CharHex ])
:do {
- / tool fetch http://127.0.0.1/ dst-path=($Dir . "/tmp") as-value;
- $WaitForFile ($Dir . "/tmp");
- / file remove ($Dir . "/tmp");
+ / ip smb share add disabled=yes directory=$Dir name=$Name;
+ $WaitForFile $Dir;
} on-error={
:set Return false;
}
- / ip service set www address=($WwwVal->"address") \
- disabled=($WwwVal->"disabled") port=($WwwVal->"port");
+ / ip smb share remove [ find where name=$Name ];
:return $Return;
}