22 lines
1.4 KiB
Python
22 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
"""sharing.py — R-972 Part 4 on demo-hp 9201: turn sharing on, set the household SMB password, create one share,
|
|
through the dashboard's own form posts (drill.form). The password is read from $SC/.smbpw (0600) and never printed."""
|
|
import os, sys, time
|
|
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
|
|
import drill # noqa: E402
|
|
w = drill.w
|
|
w.login()
|
|
pw = open(os.path.join(w.SC, ".smbpw")).read().strip()
|
|
drill.form("/sharing/enable", {"enabled": "on", "server_name": "FELHOMHP"})
|
|
args = ["curl", "-sk", "-D", "-", "-o", "/dev/null", "-H", w.HOSTHDR, "-H", "Cookie: " + open(f"{w.SC}/sess{os.getpid()}.txt").read().strip(),
|
|
"-X", "POST", "--data-urlencode", "_csrf=" + open(f"{w.SC}/csrf{os.getpid()}.txt").read().strip(),
|
|
"--data-urlencode", "smb_password@" + os.path.join(w.SC, ".smbpw"), "--data-urlencode", "smb_password_confirm@" + os.path.join(w.SC, ".smbpw"),
|
|
f"{w.BASE}/sharing/password"]
|
|
r = w.sh(args, timeout=240)
|
|
loc = [l for l in (r.stdout or "").split("\n") if l.lower().startswith("location:")]
|
|
drill.say(f"POST /sharing/password (value from the 0600 file, not shown) -> {(r.stdout or '').splitlines()[0] if r.stdout else '?'} {loc}")
|
|
drill.form("/sharing/shares", {"name": "r1105", "mode": "new", "storage_root": "/mnt/felhom-drives/hdd_1"})
|
|
time.sleep(20)
|
|
c, d = w.ctl("GET", "/sharing/status")
|
|
drill.say(f"GET /sharing/status -> {c} {str(d)[:500]}")
|