diff --git a/.gitignore b/.gitignore index cb852dc..d31c8a4 100644 --- a/.gitignore +++ b/.gitignore @@ -57,3 +57,5 @@ __pycache__/ /clients/retro-browser/test-rbp /upstream/build-complete + +/upstream/failed-*/ diff --git a/INTEGRATION-0.9.8-1.md b/INTEGRATION-0.9.8-1.md new file mode 100644 index 0000000..294d1be --- /dev/null +++ b/INTEGRATION-0.9.8-1.md @@ -0,0 +1,25 @@ +# Integration 0.9.8-1 — 2026-11-30 + +Base: b9fe2e6 plus supplier changes between 0.9.3 and 0.9.8 archives. +Existing token regression fixes, packaging and source-bundle corrections preserved. +Build: MARS_ENABLE_NDS_LAB=1 ./build.sh, original upstream from existing checkout. +NDS laboratory is compiled but remains disabled without explicit runtime flags. + +Fixed upstream hook: preserve Latin-1 historical source bytes; replace only the +known NDS unsupported-operation stub. Other 0x68 queue operations stay unchanged. +Unknown handlers and repeated patch application still fail closed. + +UI: German concepts/help, normal-vs-laboratory distinction, snapshot refresh and +rollback instructions, IPX / TCP+SLP draft presets, no automatic save or restart. +Preset controls remain disabled until configuration is loaded. + +Verified: full check-release and native/upstream build; NDS wire/dispatcher/schema/ +snapshot tests; real socket integration with disabled/enabled/invalid NDS metadata +in isolated network/mount/PID namespaces; isolated real Bindery; real HTTP security +smoke tests; Chromium 390x844 wizard and draft presets with mock API. +DEB contains new native server/UI and unchanged existing Windows/DOS/PPC packages. + +No local installation performed for this update. No original XP/NDS login or +ncpfs interoperability test here; native NDS authentication remains unavailable. +Source archive contains the lab administration tools; run these from the matching +successfully built project, not from an arbitrary older installed source tree. diff --git a/Makefile b/Makefile index 0fee4fe..21de91f 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ all: build/mars-pcapd build/libmarspcap.a build: mkdir -p $@ build/mars-pcapd: src/broker.c src/slp.c src/ncp_ip.c src/ncp_ip_config.c src/wire.c src/pcap_dyn.c src/ipxpkt.c src/gateway.c src/dhcp.c src/gateway_config.c src/gateway.h src/ipxpkt.h src/wire.h src/pcap_dyn.h src/ncp_ip.h src/slp.h | build - $(CC) $(CPPFLAGS) $(CFLAGS) -std=c11 src/broker.c src/slp.c src/ncp_ip.c src/ncp_ip_config.c src/wire.c src/pcap_dyn.c src/ipxpkt.c src/gateway.c src/dhcp.c src/gateway_config.c $(shell pkg-config --cflags --libs json-c) -ldl -o $@ + $(CC) $(CPPFLAGS) $(CFLAGS) -std=c11 src/broker.c src/slp.c src/ncp_ip.c src/ncp_ip_config.c src/wire.c src/pcap_dyn.c src/ipxpkt.c src/gateway.c src/dhcp.c src/gateway_config.c $(shell pkg-config --cflags --libs json-c sqlite3) -ldl -o $@ build/shim.o: src/shim.c src/shim.h src/wire.h | build $(CC) $(CPPFLAGS) $(CFLAGS) -std=c11 -c $< -o $@ build/libmarspcap.a: build/shim.o @@ -173,6 +173,8 @@ check-ncp-ip: build/test-ncp-ip-config ./build/test-ncp-ip-config check-ncp-ip-integration: build/test-ncp-ip build/mars-pcapd ./tests/run_ncp_ip.sh + ./tests/run_ncp_ip.sh --nds + ./tests/run_ncp_ip.sh --invalid-nds check-release: check-ncp-ip check-ncp-ip: check-ncp-ip-ui @@ -186,3 +188,50 @@ build/test-slp: tests/test_slp.c src/slp.c src/slp.h src/wire.h | build check-slp: build/test-slp ./build/test-slp check-release: check-slp + +.PHONY: check-nds-lab +build/test-nds-lab: tests/test_nds_server.c nds/server.c nds/server.h nds/fragger.c nds/fragger.h nds/nds_directory.c nds/nds_directory.h | build + $(CC) $(CPPFLAGS) $(CFLAGS) -std=c11 -Inds tests/test_nds_server.c nds/server.c nds/fragger.c nds/nds_directory.c -o $@ $(shell pkg-config --cflags --libs json-c sqlite3) +check-nds-lab: build/test-nds-lab + ./build/test-nds-lab + MARS_NDS_LAB=0 ./build/test-nds-lab disabled + MARS_NDS_LAB=1 MARS_NDS_LAB_CONFIG='{"tree":"X","organization":"Y","units":["A/B"]}' ./build/test-nds-lab invalid + python3 tests/test_nds_hook.py +check-release: check-nds-lab + +.PHONY: check-nds-directory +build/test-nds-directory: tests/test_nds_directory.c nds/nds_directory.c nds/nds_directory.h | build + $(CC) $(CPPFLAGS) $(CFLAGS) -Werror -std=c11 -Inds tests/test_nds_directory.c nds/nds_directory.c -o $@ $(shell pkg-config --cflags --libs sqlite3) +check-nds-directory: build/test-nds-directory build/test-nds-lab + python3 tests/test_nds_directory.py + python3 tests/test_nds_snapshot.py +check-release: check-nds-directory + +.PHONY: check-nds-probe +check-nds-probe: + python3 tests/test_nds_probe.py +check-release: check-nds-probe + +.PHONY: check-nds-schema +build/mars-nds-inspect: nds/tools/inspect.c nds/nds_directory.c nds/nds_directory.h | build + $(CC) $(CPPFLAGS) $(CFLAGS) -Werror -std=c11 -Inds nds/tools/inspect.c nds/nds_directory.c -o $@ $(shell pkg-config --cflags --libs sqlite3) +check-nds-schema: build/mars-nds-inspect build/test-nds-lab build/test-nds-schema + python3 tests/test_nds_schema.py +build/test-nds-schema: tests/test_nds_schema.c nds/nds_directory.c nds/nds_directory.h | build + $(CC) $(CPPFLAGS) $(CFLAGS) -Werror -std=c11 -Inds tests/test_nds_schema.c nds/nds_directory.c -o $@ $(shell pkg-config --cflags --libs sqlite3) +check-release: check-nds-schema + +.PHONY: check-nds-wire +build/test-nds-wire.so: nds/server.c nds/server.h nds/fragger.c nds/fragger.h nds/nds_directory.c nds/nds_directory.h | build + $(CC) $(CPPFLAGS) $(CFLAGS) -Werror -std=c11 -shared -fPIC -Inds nds/server.c nds/fragger.c nds/nds_directory.c -o $@ $(shell pkg-config --cflags --libs json-c sqlite3) +check-nds-wire: build/test-nds-wire.so + python3 tests/test_nds_wire.py +check-release: check-nds-wire + +# Optional independent legacy decoder/encoder check. NCPFS_DIR points to a +# configured ncpfs 2.2.6 checkout containing lib/libncp.a, not bundled here. +.PHONY: check-nds-ncpfs +check-nds-ncpfs: | build + test -n "$(NCPFS_DIR)" && test -f "$(NCPFS_DIR)/lib/libncp.a" + $(CC) -std=gnu11 -O2 -g -D_GNU_SOURCE -D_DEFAULT_SOURCE -DN_PLAT_LINUX -I"$(NCPFS_DIR)/include" -I"$(NCPFS_DIR)/lib" -I"$(NCPFS_DIR)" -Inds tests/test_nds_ncpfs.c nds/server.c nds/fragger.c nds/nds_directory.c "$(NCPFS_DIR)/lib/libncp.a" -Wl,--wrap=ncp_send_nds_frag -pthread $(shell pkg-config --cflags --libs json-c sqlite3) -o build/test-nds-ncpfs + python3 tests/test_nds_ncpfs.py diff --git a/README.md b/README.md index e394c3a..3c64e26 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,11 @@ +> **0.9.8 NDAP Read Operations Lab:** [Anleitung und Grenzen](RELEASE-0.9.8-NDS-WIRE-DE.md). Native experimentelle Read Entry Info, Read, Compare, List, Search nach ncpfs 2.2.6; keine NDS-Anmeldung. + +> **0.9.7 NDS Schema & Diagnostics Lab:** [Anleitung und Grenzen](RELEASE-0.9.7-NDS-SCHEMA-DE.md). Server-/Volume-Objekte, lokale typisierte Attribute und Compare, NCP 104/06; keine native NDS-Anmeldung. + +> **0.9.6 NDS Discovery Lab:** [Anleitung und Grenzen](RELEASE-0.9.6-NDS-DISCOVERY-DE.md). Optionale SAP-/SLPv2-Baumerkennung und aktiver TCP/IP-Diagnosetest; keine native NDS-Anmeldung. + +> **0.9.5 NDS Directory Integration (Labor):** [Anleitung und Grenzen](RELEASE-0.9.5-NDS-INTEGRATION-DE.md). SQLite-gestütztes NCP Resolve Name; keine native NDS-Anmeldung oder Baum-Ankündigung. + > **0.9.2 IP Preview:** [Anleitung und Grenzen](RELEASE-0.9.2-IP-PREVIEW-DE.md). Optionaler experimenteller NCP/TCP-Listener; keine native NDS-Anmeldung. > **Integrierter Entwicklungsstand 0.9.1-4:** siehe [Release- und Einrichtungsanleitung](RELEASE-0.9.1-4-DE.md). Classic/Bindery ist der aktive Protokollmodus; native NDS-Anmeldung bleibt offen. diff --git a/RELEASE-0.9.4-NDS-LAB-DE.md b/RELEASE-0.9.4-NDS-LAB-DE.md new file mode 100644 index 0000000..29da145 --- /dev/null +++ b/RELEASE-0.9.4-NDS-LAB-DE.md @@ -0,0 +1,33 @@ +# MARS NWE 0.9.4 – NDS Protocol Lab + +Basis: 0.9.3-SLP. Entwicklungsstand, keine NetWare-4/5-Freigabe. + +## Was neu ist + +- Nativer C-Endpunkt für NCP 104/1 (Ping), 104/2 (fragmentierter Resolve Name V0), 104/3 (Close) und 104/4 (Bindery Context). +- Öffentliche Organisation/Organisationseinheiten aus dem gespeicherten Verzeichnisentwurf, typisierte und untypisierte vollständige Namen. Nur ASCII-Namen; Baum maximal 32 Zeichen. Synthetische lokale Objekt-IDs sind deterministisch innerhalb einer unveränderten Hierarchie, keine Bindery-IDs. Keine Benutzer- oder Gruppenabfragen und keine Schreiboperationen. Resolve unterstützt ausschließlich Flags 0 und Confidence 0–2; keine Referrals. Die Ping-Antwort folgt dem historischen ncpfs-Clientformat, nicht allen in der NDK beschriebenen Varianten. +- Pro `nwconn`-Prozess ein Fragmentzustand, Task-Prüfung, Wiederholungsschutz für die letzte Fragmentoperation, Größenlimits und 30 Sekunden Inaktivitätsgrenze. Annahme: ein Prozess pro NCP-Verbindung; im echten Upstream noch zu überprüfen. +- Opt-in-Hook in `nwconn` mit Layoutprüfung. Nicht aktivierter Build bleibt unverändert. Keine SAP- oder SLP-Ankündigung eines NDS-Baums, keine erfolgreiche NDS-Anmeldung, keine Änderung an den bestehenden Bindery-Rechten. + +## Installation und Aktivierung auf einem isolierten Testsystem + +1. ZIP entpacken, in `mars_nwe` wechseln. Sicherung von Serverkonfiguration und Daten erstellen. +2. `./setup-assistant.sh --check`, bei Bedarf `./setup-assistant.sh --install-deps`. +3. `make check-release` und `make check-nds-lab` ausführen. +4. `MARS_ENABLE_NDS_LAB=1 ./rebuild.sh` (gegebenenfalls `MARS_SOURCE_DIR=/pfad/zum/original` zusätzlich setzen). Bei Layout- oder Buildfehler nicht installieren. Der reale Upstream-Build wurde hier nicht ausgeführt. +5. Erst nach erfolgreichem Build `sudo ./install.sh`. Im Webfrontend Verzeichnis-Assistent öffnen, Baum, Organisation und OUs speichern. Beispiel: MARS_TREE, HOME, USERS, USERS/RETRO. +6. `sudo ./nds-lab.sh enable` erstellt einen systemd-Drop-in mit einem Snapshot ausschließlich der öffentlichen Container. Abweichender Pfad: `sudo ./nds-lab.sh enable /pfad/nwserv.conf.directory.json`. Kein Kennwort wird exportiert. `sudo systemctl restart mars_vme.service` übernimmt den Snapshot; laufende Sitzungen werden unterbrochen. Bei Verzeichnisänderungen Schritt 6 wiederholen. Der Status des Drop-ins allein beweist nicht, dass nwconn die Umgebung geerbt hat. +7. `sudo ./nds-lab.sh disable` und Dienstneustart schalten das Labor aus. Der klassische Modus bleibt nutzbar. Kein dauerhaftes Umschalten auf NDS im Webfrontend. + +## Verifikation und Grenzen + +`make check-release` erfolgreich, inklusive neuer Tests. Separater ASan/UBSan-Lauf mit 50.000 zufälligen Anfragen erfolgreich. Hook gegen nachgebildeten Dispatcher kompiliert und gelinkt, nicht gegen das echte Upstream-Projekt. Die Aktivierungsskripte wurden syntaktisch geprüft; kein echtes systemd-Deployment. Kein Test eines Original-Novell-Clients. Fehlende CivetWeb-Header und nicht verfügbarer Upstream-Quellbaum verhindern die vollständige lokale Integration. + +Die bestehenden IPX- und TCP-Transporte bleiben unverändert. Ob beide Pfade den neuen Hook im laufenden Server erreichen, muss praktisch nachgewiesen werden. Echte NDS-Authentifizierung (Schlüssel, Login, Authentication, NCP-Sitzungsbindung), Benutzerobjekte, Schema, Baum-Ankündigung, Paketsignierung, Pure IP und Replikation bleiben offen. Nicht für Produktion oder öffentliche Netze. + +## Referenzen + +- NCP NDS: https://www.microfocus.com/documentation/open-enterprise-server-developer-documentation/ncp/ncpdocs/nds.htm +- ncpfs: https://sources.debian.org/src/ncpfs/2.2.6-9/lib/ndslib.c und https://sources.debian.org/src/ncpfs/2.2.6-9/lib/nwnet.c +- Wireshark: https://sources.debian.org/src/wireshark/1.12.1%2Bg01b65bf-4/epan/dissectors/packet-ncp2222.inc +- MARS upstream: https://github.com/davidrg/mars_nwe/blob/main/src/nwconn.c diff --git a/RELEASE-0.9.5-NDS-INTEGRATION-DE.md b/RELEASE-0.9.5-NDS-INTEGRATION-DE.md new file mode 100644 index 0000000..3c6b373 --- /dev/null +++ b/RELEASE-0.9.5-NDS-INTEGRATION-DE.md @@ -0,0 +1,61 @@ +# MARS NWE 0.9.5 – integriertes NDS Directory Lab + +Basis: vom Nutzer hochgeladenes `MARS_NWE-0.9.4-NDS-Lab-Source(1).zip` und vorhandene 0.9.5 Directory Extension. Der angegebene Git-Server war weder per Git (DNS) noch per Web abrufbar. Kein Abgleich mit einem möglicherweise neueren Commit. Dieses Archiv ist der vollständige Wrapper-/Adapter-Quellstand, **nicht** das externe Upstream-Repository und kein fertig gebauter NetWare-Server. Kein produktiver NDS-Modus. + +## Neu + +- `nds/nds_directory.c`: schreibgeschütztes SQLite-Backend (Resolve, Read, List und Search auf lokaler API-Ebene). Die NCP-104/2-Resolve-Name-Antwort verwendet die persistente Objekt-ID statt eines Namenshashes, wenn die Labor-Datenbank konfiguriert ist. Ping und Bindery Context bleiben bestehen. Ohne neue DB-Umgebungsvariable bleibt das alte 0.9.4-Labor kompatibel. +- `nds/tools/snapshot.py`: validierter Export aus dem gespeicherten Web-Verzeichnisentwurf. Standardmäßig ausschließlich Organisation und OUs. Auf ausdrücklichen Wunsch auch die gespeicherten Benutzer-/Gruppenzuordnungen. Keine Passwörter, UID/GID, Gruppenmitgliedschaften, Trustee-Rechte oder Login-Informationen. Keine Live-Bindery-Verifikation; veraltete Zuordnungen müssen vor dem Export entfernt werden. +- Unveränderte DNs und Objektklassen erhalten bei erneutem Export ihre IDs. Gelöschte oder umbenannte DNs werden nicht automatisch wiederverwendet; Umbenennung entspricht Löschen/Neuanlegen. Die erste SQLite-Aktivierung ersetzt die früheren synthetischen Labor-IDs. Keine Verbindung zu Bindery-IDs. Keine Migration von Benutzerrechten. Bei Baumwechsel wird Export verweigert; neue Datenbank bewusst anlegen, alte sichern. +- DB wird aus Kopie aktualisiert und atomar ausgetauscht; ungültige Zuordnungen verändern die vorige DB nicht. NCP verweigert Anfragen, falls die konfigurierte DB fehlt oder Baum/Organisation nicht übereinstimmen. `nds-lab.sh` serialisiert Änderungen mit flock. Änderungen im Web-Assistenten sind Entwürfe; sie werden nicht automatisch exportiert. Während eines Wartungsfensters aktivieren und unmittelbar neu starten; bereits geöffnete SQLite-Leseverbindungen können den alten Snapshot behalten. +- Im Web-Assistenten erscheint eine NDS-Labor-Anleitung mit Hinweis auf max. 32 Zeichen für Baumnamen. Classic-Modus behält seine bestehenden Eingabegrenzen. +- Build-Adapter linkt das SQLite-Backend in `nwconn`, nur wenn `MARS_ENABLE_NDS_LAB=1` gesetzt ist. +- `nds/tools/nds_trace.py`: rein lokale Metadatenzusammenfassung von tshark-kompatiblen Captures oder TSV-Exporten. Keine Paketnutzdaten im Bericht. Die Verfügbarkeit der Feldnamen in der installierten tshark-Version prüfen. Originalmitschnitte vertraulich behandeln, können Login-Daten enthalten. + +## Installation (isolierte Retro-Testumgebung) + +1. Bestehende Konfiguration, Bindery, Identitäts-DB, NDS-DB (falls vorhanden) und Volumes einschließlich Eigentümer/Rechten bei gestopptem Server sichern. Archiv in getrennten Ordner entpacken; ggf. vorhandenen `upstream/original` aus dem Arbeitsrepo übernehmen bzw. `MARS_SOURCE_DIR` setzen. +2. `./setup-assistant.sh --check` und ggf. `./setup-assistant.sh --install-deps`. +3. `make check-release`; `MARS_ENABLE_NDS_LAB=1 ./rebuild.sh`. Erst nach vollständigem erfolgreichen Build `sudo ./install.sh`. +4. Webfrontend: **Verzeichnis & Assistent**. Baum, Organisation, OUs speichern. Beispiel MARS_TREE / HOME / USERS. Die vorhandene Bindery-Anmeldung bleibt unverändert. Kein NDS-Login auswählen. +5. Aus dem Quellordner: + +```sh +sudo ./nds-lab.sh check +sudo ./nds-lab.sh enable +sudo systemctl restart mars_vme.service +sudo ./nds-lab.sh status +``` + +Das Standardverzeichnis `/usr/local/etc/mars_nwe/nwserv.conf.directory.json` kann als Argument angegeben werden. Die Datenbank `/var/lib/mars-nds/directory.sqlite3` ist root-eigentümlich und 0644 (nur öffentliche Metadaten, `nwconn` benötigt nach Privilegwechsel Lesezugriff). Kein Ersatz für `/var/lib/mars-identities/identities.sqlite3` oder Bindery. Bei erneuter Aktivierung DB sichern, nicht löschen. Optionaler Export von Namen nur in einem isolierten Labornetz: + +```sh +sudo ./nds-lab.sh check --public-placements +sudo ./nds-lab.sh enable --public-placements +sudo systemctl restart mars_vme.service +``` + +Die Namen werden ohne Authentifizierung über Resolve Name auflösbar. Das Abschalten bzw. erneutes Aktivieren ohne Flag entfernt diese Namen aus dem aktiven Snapshot nach Neustart, nicht zwingend aus Backups oder bereits erstellten Mitschnitten. Keine Gruppenmitgliedschaft oder Benutzer-Anmeldung freigeschaltet. + +```sh +sudo ./nds-lab.sh disable +sudo systemctl restart mars_vme.service +``` + +Der Dienststatus zeigt nur den Drop-in, keine Protokollbestätigung. Vor Produktivnutzung den bisherigen Bindery-Zugang und die Dateirechte auf echter Hardware prüfen. Kein offener NCP-Zugang zum Internet. + +## XP-Diagnose + +Original Novell Client im isolierten Test-LAN, vorhandenen Server direkt per Bindery verbinden; separate Tests für IPX und NCP/TCP. Auf Server oder Mirror-Port eine kurze Aufzeichnung starten (Schnittstelle durch tatsächlich benutzte ersetzen): + +```sh +sudo tcpdump -i eth0 -s0 -w nds-test.pcap 'ipx or tcp port 524 or udp port 427' +# Nach Test mit Strg+C beenden; Paketdatei lokal schützen. +python3 nds/tools/nds_trace.py --pcap nds-test.pcap +``` + +Wenn die installierte tshark-Version die Felder nicht kennt, `tshark -G fields | grep -i nds` ausführen und die Feldnamen im Skript abgleichen. Ohne erkannten NCP 104 ist zuerst Discovery/Transport zu prüfen. Ein erfolgreiches Resolve ist noch keine Anmeldung. Die NDS-NCP-Fragmentierung ist in der offiziellen Dokumentation beschrieben: https://www.microfocus.com/documentation/open-enterprise-server-developer-documentation/ncp/ncpdocs/nds.htm ; https://support.novell.com/techcenter/articles/dnd19980601.html . + +## Noch offen + +Keine SAP-0x0278- oder SLP-NDS-Baumbekanntmachung, kein natives NDAP Read/List/Search-Encoding, keine NDS-Schlüssel- und Challenge/Response-Authentifizierung, keine Bindung einer NDS-Identität an NCP-Sitzung, keine Replikation. Diese Funktionen sind für eine echte XP-NDS-Anmeldung noch erforderlich. Keine Scheindiscovery und keine Umgehung der Authentifizierung. Der Original-Upstream-Build, CivetWeb-Link, systemd-Installation, echte IPX-/TCP-Verbindungen und echte XP-Anmeldung wurden nicht ausgeführt. Siehe Testprotokoll. diff --git a/RELEASE-0.9.6-NDS-DISCOVERY-DE.md b/RELEASE-0.9.6-NDS-DISCOVERY-DE.md new file mode 100644 index 0000000..2c1fb90 --- /dev/null +++ b/RELEASE-0.9.6-NDS-DISCOVERY-DE.md @@ -0,0 +1,88 @@ +# MARS NWE 0.9.6 – NDS Discovery Lab + +Basis: vollständig integriertes Quellarchiv 0.9.5 aus der Unterhaltung. Das Paket enthält den Wrapper, den Broker, die Weboberfläche und die Upstream-Adapter. Es enthält **nicht** das externe Original-MARS-Repository, keine bereits gebaute Serverinstallation und keine vollständig implementierte NetWare-4/5-Authentifizierung. Nicht im produktiven oder öffentlichen Netz verwenden. + +## Neu + +- IPX: der Broker beantwortet direkte SAP-General-Service- (1) und Nearest-Service-Anfragen (3) für den Diensttyp 0x0278. Die Antworten enthalten den bis 32 Zeichen langen, mit Unterstrichen aufgefüllten Baumnamen und die interne IPX-Adresse des tatsächlich beobachteten lokalen Dateiservers (NCP-Socket 0x0451). Der 16-Zeichen-Suffix ist ein eigener, deterministischer Labor-Discriminator aus Netznummer und den letzten vier Node-Bytes; die proprietäre Novell-Adresscodierung wurde noch nicht verifiziert. Keine Zusage, dass der Originalclient diesen akzeptiert. Nur direkte LAN-Clients; keine Weiterleitung dieser neuen Antworten; Rate-Limit 40 Antwortversuche/s. Normale Bindery-SAP-Anfragen bleiben beim ursprünglichen SAP-Handler. Noch keine periodische 0x0278-Ankündigung, keine SAP-Operation 14 (Get Specific), keine Einspeisung in die ursprüngliche Bindery-Service-Liste und keine allgemeine Wildcard-Anfrage nach allen Diensttypen. +- TCP/IP: zusätzlicher SLPv2-Service `service:ndap.novell:///MARS_TREE.` für die Labor-Root-Partition, im Scope DEFAULT, einschließlich `svcname-ws`, `svcaddr-ws` (TCP-Protokoll 2-1-6, Port 524) und `enabled-ws`. Direkte, Prefix-/Presence-Suche und bestehender eingeschränkter UND-Filter. Keine Directory-Agent-Registrierung, kein SLPv1, kein SLP/TCP, keine signierten SLP-Pakete und keine Replikation. Der vorhandene Bindery-Service bleibt unverändert. Das Statusfeld `SLP-Replies` zählt weiterhin alle SLP-Antworten, nicht ausschließlich NDAP. +- Beide Erweiterungen sind **standardmäßig deaktiviert**. Aktivierung mit `--discovery`. Der Broker prüft die schreibgeschützte Snapshot-DB, Eigentümer, Modus, Metaversion, Baum und Organisation beim Start; bei fehlender/abweichender DB keine neue Bekanntmachung. Zusätzlich muss der Original-Dateiserver aktiv sein und seine lokale Bindery-SAP-Ankündigung in den letzten 180 Sekunden beobachtet worden sein. SLP benötigt den aktiven TCP-Listener. Diese Prüfungen beweisen nicht, dass der Upstream-NDS-Hook erreichbar ist. Nach Konfigurations-/Snapshotänderungen neu starten; im laufenden Betrieb wird der Snapshot nicht neu eingelesen. +- Webassistent und TCP/IP-Dialog zeigen den Laborcharakter und den Aktivierungsweg. `nds-lab.sh status` ergänzt die Laufzeitausgabe `NDS-Discovery`, `NDS-Discovery-Tree` und `NDS-SAP-Replies`. Kein automatisches Starten einer NDS-Anmeldung und keine Übernahme bestehender Rechte. +- `nds/tools/probe.py`: aktiver, lokaler TCP/IP-Test ohne Passwort. Überprüft SLP-Service und Adresse, dann separat NCP-Verbindungsaufbau, NDS-Ping (104/1), optional Resolve Name (104/2), Freigabe des NCP-Slots. Nur explizite RFC1918-/Loopback-IPv4-Adressen, Timeouts und Antwortlängenbegrenzung; kein Login und keine Schreiboperationen. Prüft den begrenzten Labor-Wire-Dialekt 0.9.5/0.9.6, nicht jede originale NDS-Version. Fehler in SLP werden unabhängig vom NCP-Test ausgegeben. + +## Installation / Upgrade + +1. Auf einem isolierten Laborsystem laufende Sitzungen beenden. Serverkonfiguration, Bindery, Volumes (inklusive Rechte/Eigentümer), Identitäts- und NDS-Datenbank sowie vorhandene ausführbare Dateien sichern. Bei einem Upgrade niemals die vorhandene NDS-Datenbank löschen. +2. Neues Archiv separat entpacken; in `mars_nwe` wechseln. Original-Upstream-Baum aus deinem bestehenden Repo übernehmen oder `MARS_SOURCE_DIR` auf ihn setzen. Alternativ Patch im sauberen 0.9.5-Repo anwenden, zuvor `git apply --check`. + +```sh +./setup-assistant.sh --check +# Nur bei fehlenden Abhängigkeiten: +# ./setup-assistant.sh --install-deps +make -j2 check-release +MARS_ENABLE_NDS_LAB=1 ./rebuild.sh +# Nur nach vollständig erfolgreichem Build: +sudo ./install.sh +``` + +3. Webfrontend → Verzeichnis & Assistent: `MARS_TREE`, `HOME`, OUs wie `USERS` speichern. Für Discovery max. 32 Zeichen, kein abschließender Unterstrich (SAP-Padding). Für TCP/IP zusätzlich den Dialog NetWare über TCP/IP öffnen, private Server-IP auswählen und SLPv2 aktivieren. IPX bleibt unabhängig davon verfügbar. + +```sh +sudo ./nds-lab.sh check --discovery +sudo ./nds-lab.sh enable --discovery +sudo systemctl restart mars_vme.service +sudo ./nds-lab.sh status +``` + +Der optionale Flag `--public-placements` kann in beiden Befehlen ergänzt werden, falls gespeicherte Benutzer-/Gruppennamen ohne Anmeldung auflösbar sein sollen. Standardmäßig bleiben sie privat; keine Kennwörter oder Trustee-Rechte im Snapshot. Nicht im produktiven LAN freigeben. Änderungen trennen Sitzungen bei Neustart. + +Nur NDS-Discovery wieder ausschalten (Labor-Ping/Resolve bleibt, öffentliche Zuordnungen nur bei erneuter expliziter Wahl): + +```sh +sudo ./nds-lab.sh enable +sudo systemctl restart mars_vme.service +``` + +Das gesamte Labor ausschalten: + +```sh +sudo ./nds-lab.sh disable +sudo systemctl restart mars_vme.service +``` + +## Diagnose + +Von einem Linux-Rechner im gleichen Retro-Netz (IP durch tatsächlich gewählte private Server-IP ersetzen): + +```sh +python3 nds/tools/probe.py 192.168.1.42 --tree MARS_TREE --dn OU=USERS.O=HOME +``` + +Bei absichtlich deaktiviertem SLP `--skip-slp` hinzufügen. Ausgaben sind separate Prüfergebnisse, kein Login-Nachweis. Status auf dem Server: `sudo ./nds-lab.sh status`; bei `invalid or missing NDS lab snapshot` Konfiguration und DB kontrollieren. Bei wartendem SLP lokale SAP-Ankündigung, Interface und TCP-Listener prüfen. Bei ausbleibender SLP-Antwort UDP 427, Scope DEFAULT und Subnetz überprüfen; bei fehlerhaftem Ping tatsächlichen Upstream-Build und NCP 104 prüfen. + +Für IPX im isolierten Retro-LAN mit tatsächlicher Schnittstelle: + +```sh +sudo tcpdump -i eth0 -s0 -w nds-discovery.pcap 'ipx or tcp port 524 or udp port 427' +# Mit Strg+C nach kurzem Test beenden. +python3 nds/tools/nds_trace.py --pcap nds-discovery.pcap +``` + +In Wireshark `ipxsap` und `ncp` separat prüfen. Beim originalen XP-Novell-Client zuerst weiterhin Bindery-Anmeldung direkt am Server testen (Baum und Kontext leer). Anschließend getrennt testen, ob der Baum im Auswahlfenster sichtbar ist, der Client NDS-Ping sendet und Resolve Name erreicht. Keine echte Anmeldung oder Dateifreigabe über NDS zu erwarten. Mitschnitte lokal schützen, keine Kennwörter übertragen, wenn nur Discovery geprüft wird. tshark ist optional und wurde hier nicht auf realen Mitschnitten getestet. + +## Noch offen / Abnahme + +- Echtes IPX-LAN, SAP-Suffix und Tree-Auswahldialog, weitere SAP-Abfragen und dynamische Bindery-Service-Objekte. +- Vollständige NDAP-Drahtformate für Read Entry Information, Read, List, Search, Compare, Schema und Server-/Volume-Attribute. Die bisherigen lokalen SQLite-Funktionen bleiben erhalten, aber diese Netzwerkverben sind nicht aktiviert. Die zugänglichen Quellen reichten nicht für eine belastbare vollständige Wire-Implementierung. Keine frei erfundenen Antwortlayouts. +- Native NDS-Schlüsselverwaltung und Login/Authentication (Verbs 57–60), sichere Zuordnung zur NCP-Sitzung, Identitäts-DB, Trustees und Signierung; erst danach echte XP-Anmeldung. +- Echter Upstream-Build, CivetWeb-Link, systemd-Installation, Tests mit Windows XP und physischen IPX-Frames fehlen. Die Socket-Integration verwendet den realen Broker in Offline-Modus mit simuliertem NCP-Server. Die unabhängige Probe wird mit separaten Loopback-Testservern geprüft. Die SAP-Encoder-Tests prüfen Pakete im Speicher; sie sind kein Test auf echter Hardware. + +## Protokollreferenzen + +- Novell TID 10027163: https://support.novell.com/docs/Tids/Solutions/10027163.html – NDAP-URL und Attribute, Root-Service. +- Novell NDS Q&A: https://support.novell.com/techcenter/articles/dnd19961109.html – SAP 0x0278, 32-Zeichen-Baumname, 16-Zeichen-Suffix. +- Novell TID 10022605: https://support.novell.com/docs/Tids/Solutions/10022605.html – Client-Discovery und zusätzliche SAP-Abfragen. +- Novell NetWare/IP: https://support.novell.com/techcenter/articles/ana19960801.html – Suffix kodiert im Original die IPX-Adresse; genaue Codierung nicht verifiziert. +- Novell IPX Packet Structure: https://www.novell.com/documentation/nw6p/ipx_enu/data/hc1w6pvi.html +- RFC 2608: https://www.rfc-editor.org/rfc/rfc2608 +- NCP NDS: https://www.microfocus.com/documentation/open-enterprise-server-developer-documentation/ncp/ncpdocs/nds.htm diff --git a/RELEASE-0.9.7-NDS-SCHEMA-DE.md b/RELEASE-0.9.7-NDS-SCHEMA-DE.md new file mode 100644 index 0000000..c3d9f1e --- /dev/null +++ b/RELEASE-0.9.7-NDS-SCHEMA-DE.md @@ -0,0 +1,56 @@ +# MARS NWE 0.9.7 – NDS Schema & Diagnostics Lab + +Basis: bereitgestelltes 0.9.6-NDS-Discovery-Source.zip, nicht ein neuer Git-Remote-Commit. Dies ist ein experimenteller Quellstand, kein NetWare-4/5-kompatibler Loginserver. + +## Neuer Funktionsumfang + +- Opt-in `--resources`: importiert den Servernamen und die NetWare-Volume-Namen aus den Einträgen 2 und 1 der nwserv.conf. Server und Volumes werden unter OU=SERVERS (falls vorhanden) oder direkt unter der Organisation angelegt. Beispiel CN=MARS.OU=SERVERS.O=HOME und CN=MARS_SYS.OU=SERVERS.O=HOME. Keine lokalen Volume-Pfade oder Kennwörter im Snapshot. SYS erforderlich, bis zu 64 Volumes; ASCII-Namen und eindeutige Volume-Namen, maximal acht Zeichen je Volume. Keine automatischen Trustee-Freigaben. +- Persistente IDs bleiben für unveränderte Objekte stabil. Gelöschte und später wieder angelegte Objekte erhalten neue IDs. Atomare Veröffentlichung, Integritäts- und Fremdschlüsselprüfung. Ältere Snapshots ohne Volume-Tabelle bleiben lesbar. +- Lokale C-API `nds_attributes` und `nds_compare`: Object Class, O/OU/CN, Login Disabled, Host Server, Host Resource Name, interne String-/DN-/Boolean-Typen. Typkennungen sind interne Werte, keine NDAP-Syntax-IDs. Login Disabled spiegelt nur den lokalen Objektstatus im Snapshot wider, keine tatsächliche Bindery-Loginbeschränkung. DN-Vergleiche beziehen sich auf die Objektidentität. Keine Netzfreigabe dieser Attribute. +- Lokales schreibgeschütztes Diagnoseprogramm für read/list/search/compare. NCP Resolve Name kann die neuen Server- und Volume-Objekte auflösen. +- NCP 104/06 Return Statistics (nicht NDAP-Verb 6 Search): unterstützte Ausgabeoptionen entsprechend der dokumentierten Maske 0xe7; Zähler je Verbindungsprozess, nur abgeschlossene Resolve-Dispatches und deren Nutzdatenbytes ohne Fragmentheader. Keine globale Statistik, keine Reset-Funktion (104/07 bleibt gesperrt). +- `--trace`: optional maximal 32 Diagnosezeilen je nwconn-Prozess, nur numerisches Verb, Länge des initialen Subfunktionspakets und Status (unsupported/resolve-start). Keine Namen, Kennwörter oder Nutzdaten. Webassistent ergänzt die Aktivierungsanleitung. + +## Build und Aktivierung + +```sh +unzip MARS_NWE-0.9.7-NDS-Schema-Source.zip +cd mars_nwe +./setup-assistant.sh --check +make -j2 check-release +MARS_ENABLE_NDS_LAB=1 ./rebuild.sh +# Nur nach erfolgreichem vollständigem Upstream-Build installieren: +sudo ./install.sh +``` + +Vor Installation Konfiguration und Serverdaten sichern. Im Webfrontend unter Verzeichnis & Assistent Baum, Organisation und OUs speichern. IP-basierte Erkennung erfordert separat aktiviertes TCP/IP und SLP. Nur in einem isolierten Labornetz verwenden. Der klassische Bindery-Modus bleibt unverändert. + +```sh +sudo ./nds-lab.sh check --discovery --resources +sudo ./nds-lab.sh enable --discovery --resources --trace +sudo systemctl restart mars_vme.service +sudo ./nds-lab.sh status +``` + +`--resources` liest `/usr/local/etc/mars_nwe/nwserv.conf`. `--public-placements` ist weiterhin eine separate Option, die Benutzer-/Gruppennamen ohne Anmeldung sichtbar macht; standardmäßig nicht aktiv. Nach Änderungen des Entwurfs erneut exportieren (enable) und Dienst neu starten; alle gewünschten Optionen dabei erneut angeben. Neustart trennt bestehende Sitzungen. `status` allein beweist keine aktive NDS-Verbindung. `--trace` nicht für dauerhaften Betrieb einschalten. + +## Lokale Diagnose + +```sh +make build/mars-nds-inspect +sudo ./nds-lab.sh inspect list OU=SERVERS.O=HOME +sudo ./nds-lab.sh inspect read CN=MARS_SYS.OU=SERVERS.O=HOME +sudo ./nds-lab.sh inspect compare CN=MARS_SYS.OU=SERVERS.O=HOME 'Host Resource Name' SYS +sudo ./nds-lab.sh inspect search O=HOME +sudo journalctl -u mars_vme.service -g MARS_NDS +``` + +Die Beispielnamen durch die tatsächlichen Namen ersetzen; `OU=SERVERS` muss existieren, sonst werden Ressourcen unter der Organisation eingeordnet. Die Journalanzeige setzt voraus, dass der tatsächliche Upstream-Prozess stderr an das Journal weitergibt; das wurde nicht auf einem Zielserver getestet. Für den bisherigen TCP/IP-Test `python3 nds/tools/probe.py SERVER_IP --tree MARS_TREE --dn CN=MARS_SYS.OU=SERVERS.O=HOME` nutzen. Probe und lokale CLI ändern keine NDS-Objekte. + +## Grenzen und Quellen + +Natives NDAP Read/List/Search/Compare, Schemaabfragen über NCP, Set Keys, Begin/Finish Login und Authentication, Sitzungsbindung, gemeinsame Bindery/NDS-Identitäten sowie der verifizierte SAP-Namenssuffix bleiben offen. Keine vorgetäuschte erfolgreiche Anmeldung. Der tatsächliche Upstream-Build und Windows-XP-Test sind nicht ausgeführt; die Tests verwenden den echten Broker im Loopback mit simuliertem Upstream und einen nachgebildeten Dispatcher. Das Projekt ist kein Produktionsrelease. + +- NCP NDS / Return Statistics: https://www.microfocus.com/documentation/open-enterprise-server-developer-documentation/ncp/ncpdocs/nds.htm +- Historischer ncpfs-Quellcode (als Referenz für NDAP-Formate und Login noch zu beschaffen): https://archive.debian.org/debian/pool/main/n/ncpfs/ncpfs_2.2.6.orig.tar.gz +- Testprotokoll: TEST-RESULTS-0.9.7-NDS-SCHEMA.txt diff --git a/RELEASE-0.9.8-NDS-WIRE-DE.md b/RELEASE-0.9.8-NDS-WIRE-DE.md new file mode 100644 index 0000000..3f5b02d --- /dev/null +++ b/RELEASE-0.9.8-NDS-WIRE-DE.md @@ -0,0 +1,67 @@ +# MARS NWE 0.9.8 – NDAP Read Operations Lab + +Basis: integriertes Quellarchiv 0.9.7. Referenz: vom Anwender bereitgestelltes `ncpfs_2.2.6.orig.tar.gz`, Originalcode von 2005. Dies ist ein experimenteller read-only Server, kein NetWare-4/5-Ersatz und keine native NDS-Anmeldung. + +## Neu + +Der bestehende NCP-104/2-Dispatcher akzeptiert nach expliziter Aktivierung folgende NDAP-Operationen gegen die SQLite-Snapshot-Datenbank. Ohne Opt-in bleibt der Stand 0.9.7 (Resolve/Ping etc.) erhalten. + +| Verb | Version | Unterstützt | +|---|---|---| +| 1 Resolve Name | 0 | zusätzliche Flags ENTRY_ID, READABLE, DEREF_ALIASES (keine Aliasobjekte); Root-Auflösung; keine Schreib-/Replikatflags | +| 2 Read Entry Info | 2 | ID, Parent-ID, Anzahl direkter Kinder, Base Class, RDN, DN; DSI_OUTPUT_FIELDS erlaubt Auslassen nicht implementierter Felder | +| 3 Read | 1 | Attributnamen und Werte, alle oder bis zu 32 ausgewählte Namen | +| 4 Compare | 0 | ein Attribut / ein Wert; Bool, CI-String, DN, Class Name; fehlende Attribute als Fehler | +| 5 List | 1 | direkte Kinder, exakter Name und/oder Klasse, optional Container-only | +| 6 Search | 3 | Base, One-Level, Subtree; leeres AND, einzelne BaseClass-/Presence-/Equality-/untypisierte RDN-Filter | + +Die belegten Formate enthalten gemischte Endianness (Objekt-ID BE, andere u32 LE), längenpräfixierte nullterminierte UTF-16LE-Zeichenketten mit 4-Byte-Alignment, Syntax-IDs für String (3), DN (1), Boolean (7) und Class Name (20). Namen bleiben ASCII, weil der bestehende Snapshot nur diese Namen erlaubt. Antwortfragmentierung nutzt den vorhandenen NCP-104/2-Transport. Verzeichnisiteration ist **noch nicht** implementiert: eine vollständige Antwort oder expliziter Fehler, maximal 64 KiB und 2048 untersuchte Objekte; fremde Iterationshandles werden abgewiesen. Keine komplexen AND/OR/NOT-Filter, Wildcards, Alias-/Referralauflösung, Zeitstempel, Schreiboperationen oder Replikation. Unbekannte Formate/Verben werden nicht als Erfolg quittiert. Die Snapshot-Attribute (auch Login Disabled) sind Verwaltungsmetadaten, keine Live-Authentifizierungsentscheidung; Rechte und Gruppenmitgliedschaften werden nicht daraus abgeleitet. + +## Installation auf einem isolierten Retro-Testnetz + +1. ZIP entpacken; `cd mars_nwe`. Vorher die produktive Konfiguration und Daten sichern. +2. `./setup-assistant.sh --check`; bei Bedarf `./setup-assistant.sh --install-deps`. +3. `make -j2 check-release`. +4. `MARS_ENABLE_NDS_LAB=1 ./rebuild.sh` (ggf. `MARS_SOURCE_DIR=/pfad/zum/original` setzen). Erst nach vollständigem erfolgreichen Build `sudo ./install.sh`. +5. Im Webfrontend „Verzeichnis & Assistent“ den Baum, Organisation und OUs speichern. Das Frontend erläutert die neue Option, schaltet sie aber nicht automatisch ein. +6. `sudo ./nds-lab.sh check --discovery --resources` +7. `sudo ./nds-lab.sh enable --discovery --resources --read-ops --trace` +8. `sudo systemctl restart mars_vme.service`. Laufende Sitzungen werden getrennt. TCP/IP und SLP müssen separat im Webfrontend aktiviert sein. + +Standardmäßig werden nur öffentliche Container sowie bei `--resources` die Server-/Volume-Metadaten ausgegeben. `--public-placements` veröffentlicht zusätzlich Benutzer-/Gruppennamen ohne Anmeldung; nur mit Testdaten und expliziter Absicht einsetzen. Die Option `--read-ops` aktiviert `MARS_NDS_LAB_READ=1` im systemd-Drop-in. Sie gibt keinerlei Dateisystemberechtigung. `sudo ./nds-lab.sh disable` und ein Dienstneustart deaktivieren das Labor. + +## Diagnose + +``` +python3 nds/tools/probe.py 192.168.1.42 --tree MARS_TREE --dn OU=SERVERS.O=HOME --read-ops +``` + +Adresse und DN anpassen. `--skip-slp` überspringt Discovery, um direkten NCP-Zugriff getrennt zu prüfen. Der neue Read-V1-Test liest nur Attributnamen und unterstützt Antwortfragmentierung. Keine Kennwörter, keine Anmeldung, keine Änderungen. Bestehende Namensauflösung, Ping, SLP und Release des Connection Slots bleiben Bestandteil der Probe. + +## Reproduzierbare Tests + +`make check-nds-wire` führt die neuen nativen Dispatcher-Tests mit unabhängigen Python-Paketfixtures aus. `make check-release` enthält diese Tests. Die zusätzliche, optionale Interoperabilitätsprüfung verwendet die tatsächlich kompilierte originale ncpfs-Bibliothek (nicht mitgeliefert). Für einen temporären Build des bereitgestellten historischen Quellcodes auf modernem GCC waren zwei Kompatibilitätsmaßnahmen nötig: `static` vor der verschachtelten Funktion `get_argument` in `lib/ncplib.c` entfernen; Compilerdiagnosen für inkompatible Zeiger/implizite Deklarationen auf Warnungen herabstufen. Keine Änderung an den NDAP-Codecs. Beispiel im separat entpackten ncpfs-Verzeichnis: + +``` +./configure --disable-nls --disable-kernel --disable-ipx --disable-ipx-tools --disable-mount-v2 --disable-mount-v3 +# Nur in temporärer Testkopie, nicht am produktiven Client: +sed -i 's/static int get_argument(int arg_no/int get_argument(int arg_no/' lib/ncplib.c +make -C lib CFLAGS='-Wno-error=incompatible-pointer-types -Wno-error=implicit-function-declaration -Wno-error=int-conversion -fcommon' libncp.a +``` + +Dann in MARS: `make check-nds-ncpfs NCPFS_DIR=/pfad/zum/ncpfs-2.2.6`. Verwendet die echten ncpfs-Read-/Compare-/EntryInfo-Encoder und Read-/List-/Search-Decoder; ausschließlich die Transportfunktion wird über einen Linker-Wrapper auf den MARS-Dispatcher umgeleitet. List-/Search-Requests werden im Fixture anhand der Quellformate gebaut. Kein vollständiger ncpfs-Clientlogin, kein physischer IPX-Test. Vollständiger MARS-Upstream-Build, systemd-Installation, echter Windows-XP-Test fehlen. + +## NDS-Authentifizierung: aus dem Originalcode bestätigte Schnittstellen + +Referenz: `lib/nwnet.c`: `__NWDSBeginLoginV0`, `__NWDSFinishLoginV2`, `__NWDSBeginAuthenticationV0`, `__NWDSFinishAuthenticationV0`; `lib/ndslib.c` (Public Key, RSA-Verarbeitung, Login-/Authentifizierungsdaten); `lib/ds/setkeys.c` (Schlüssel-/Passwortoperationen). Clientseitige Implementierung liegt vor, eine vollständige Servergegenstelle nicht. + +- 53 Get Server Address V0: Server-DN und tatsächliche Netzwerkadressen in typisierten Feldern; muss an den aktiven Broker/Upstream gebunden werden, nicht an erfundene Adressen. +- 54–56: Schlüsselanlage, Passwortänderung, Passwortprüfung; benötigen getrennte geschützte Schlüssel-/Identitätsdatenbank und Berechtigungsprüfung. +- 57 Begin Login V0: Version und Objekt-ID; Client erwartet mindestens acht Antwortbytes (Pseudo-ID und vier Bytes Seed). +- 58 Finish Login V2: Version, Flags, Objekt-ID und längenpräfixierter verschlüsselter Block; Client erwartet u.a. acht Bytes Login-Daten und kryptografisch gültige Antwort. +- 59 Begin Authentication V0: Version, Objekt-ID, Client-Seed; Client prüft Auth-ID und längenpräfixierten kryptografischen Antwortblock. +- 60 Finish Authentication V0: drei längenpräfixierte Blöcke (Signaturschlüssel, Login-Identität, Auth-Key). Nur nach vollständiger serverseitiger Prüfung dürfen NCP-Sitzung, Identität und Trustee-Rechte gebunden werden. + +Diese Angaben dokumentieren den nächsten Implementierungsschritt; Verben 53–60 bleiben in diesem Build abgewiesen. Keine generischen RSA-Schlüssel als vermeintliche NDS-Schlüssel, kein Passwort-Fallback, keine vorgetäuschte Authentifizierung. Auch native Schemaabfragen 12/15, NDS-Schlüsselattribute, gesicherte Anmeldung, Packet Signing, Rechte/ACLs, echte Baumerkennung mit Novell Client und gemeinsame Identitäten sind noch offen. SAP-Suffix bleibt experimentell: ncpfs `lib/resolve.c` bestätigt 32 Bytes mit `_`-Padding und ignoriert bei kurzen Baumnamen das Suffix; es belegt nicht dessen originalen Aufbau. + +Weitere Referenzstellen: `lib/ds/dsread.c`, `lib/ds/dslist.c`, `lib/ds/search.c`, `lib/ds/filter.c`, `lib/nwnet.c` (`NWDSGetObjectName`, `NWDSGetAttrName`, `NWDSGetAttrVal`, `__NWDSCompare`), `include/ncp/nwnet.h.in`, `lib/nwnet_i.h`. Die neue Implementierung bleibt unter GPL-2.0-or-later; ncpfs-Originalcode wird nicht im MARS-Archiv verteilt. diff --git a/TEST-RESULTS-0.9.4-NDS-LAB.txt b/TEST-RESULTS-0.9.4-NDS-LAB.txt new file mode 100644 index 0000000..651ff80 --- /dev/null +++ b/TEST-RESULTS-0.9.4-NDS-LAB.txt @@ -0,0 +1,172 @@ +MARS NWE 0.9.4 NDS Lab +Full upstream / Windows runtime NOT tested. + +cc -D_DEFAULT_SOURCE -O2 -g -Wall -Wextra -std=c11 -Inds tests/test_nds_server.c nds/server.c nds/fragger.c -o build/test-nds-lab -I/usr/include/json-c -ljson-c +./build/test-nds-lab +PASS ping, context, public Resolve Name, fragment isolation, replay, close, denied auth, malformed packets and 50000 random requests +MARS_NDS_LAB=0 ./build/test-nds-lab disabled +PASS disabled or invalid model fails closed +MARS_NDS_LAB=1 MARS_NDS_LAB_CONFIG='{"tree":"X","organization":"Y","units":["A/B"]}' ./build/test-nds-lab invalid +PASS disabled or invalid model fails closed +python3 tests/test_nds_hook.py +PASS dispatcher hook compile/link fixture, rejects repeated or incompatible patch; actual upstream not tested +PASS ping, context, public Resolve Name, fragment isolation, replay, close, denied auth, malformed packets and 50000 random requests + +make check-release exit 0 +cc -D_DEFAULT_SOURCE -O2 -g -Wall -Wextra -std=c11 src/broker.c src/slp.c src/ncp_ip.c src/ncp_ip_config.c src/wire.c src/pcap_dyn.c src/ipxpkt.c src/gateway.c src/dhcp.c src/gateway_config.c -I/usr/include/json-c -ljson-c -ldl -o build/mars-pcapd +cc -D_DEFAULT_SOURCE -O2 -g -Wall -Wextra -std=c11 -c src/shim.c -o build/shim.o +ar rcs build/libmarspcap.a build/shim.o +cc -D_DEFAULT_SOURCE -O2 -g -Wall -Wextra -std=c11 -Isrc tests/test_wire.c src/wire.c -o build/test-wire +cc -D_DEFAULT_SOURCE -O2 -g -Wall -Wextra -std=c11 -Isrc tests/test_ipc.c build/libmarspcap.a -o build/test-ipc +./build/test-wire +PASS: 4 frame types, addresses, padding, lengths, malformed frames and MTU +cc -O2 -g -Wall -Wextra -std=c11 -Inative -I/usr/include/json-c tests/test_native.c native/core.c -o build/test-native -ljson-c -lssl -lcrypto -pthread +./build/test-native +PASS merge, CRLF, unknown lines, injection rejection +PASS managed LFN server version merge +PASS backup, revision conflict, private file, traversal rejection +PASS PBKDF2, default, persistent password, wrong password +PASS validation invalid configuration and detected Ethernet interface +cc -O2 -g -Wall -Wextra -std=c11 -DMARS_TESTING -Inative -I/usr/include/json-c tests/test_supervisor.c native/supervisor.c native/core.c -o build/test-supervisor -ljson-c -lssl -lcrypto -pthread +./build/test-supervisor +PASS supervisor: start, restart, stop, restart after stop, shutdown; browser independent start, update restart, crash recovery, shutdown (mock child processes) +cc -D_DEFAULT_SOURCE -O2 -g -Wall -Wextra -std=c11 -Isrc tests/test_gateway.c src/ipxpkt.c src/gateway_config.c -o build/test-gateway -I/usr/include/json-c -ljson-c +./build/test-gateway +PASS: IPXPKT both sockets, little-endian IDs, fragmentation, out-of-order, duplicates, expiry, throughput, malformed data, config validation, static MAC/IP and ARP policy +cc -D_DEFAULT_SOURCE -O2 -g -Wall -Wextra -std=c11 -Isrc -I/usr/include/json-c tests/test_gateway_auto.c native/gateway_auto.c native/core.c src/dhcp.c src/gateway_config.c -o build/test-gateway-auto -ljson-c -lssl -lcrypto -pthread +./build/test-gateway-auto +PASS: overlapping routes, DHCP OFFER/ACK/NAK, malformed and spoofed packets +cc -D_DEFAULT_SOURCE -O2 -g -Wall -Wextra -std=c11 -Isrc -Iclients/windows -Iclients/windows/ndis5 tests/test_winclient.c clients/windows/client_core.c clients/windows/ndis5/frame_queue.c src/ipxpkt.c src/dhcp.c -o build/test-winclient -I/usr/include/json-c -ljson-c +./build/test-winclient +PASS: Windows client core + actual server codec/DHCP; peer validation, fragments, queue +cc -O2 -g -Wall -Wextra -std=c89 -pedantic -DMARS_LEGACY_KERNEL -Iclients/windows/ndis3 tests/test_legacy.c clients/windows/ndis3/legacy_core.c clients/windows/ndis5/frame_queue.c -o build/test-legacy +./build/test-legacy +legacy core: queue, MAC, packet filter, invalid frames, lease expiry passed +cc -O2 -g -Wall -Wextra -std=c11 -Inative -I/usr/include/json-c tests/test_print.c native/printing.c native/core.c -o build/test-print -ljson-c -lssl -lcrypto -pthread -ldl +cc -O2 -g -Wall -Wextra -std=c11 -I/usr/include/json-c native/print_stdin.c native/rawprint.c native/printing.c native/core.c -o build/mars-print -ljson-c -lssl -lcrypto -pthread -ldl +./build/test-print +CUPS probe (actual library): { "error": "Bad file descriptor" } +PASS: invalid destination rejected +cc -O2 -g -Wall -Wextra -std=c11 tests/test_raw.c native/rawprint.c -o build/test-raw +./build/test-raw +PASS: RAW TCP 9100 exact binary bytes over local TCP +cc -O2 -g -Wall -Wextra -std=c11 -Inative -I/usr/include/json-c tests/test_directory.c native/directory.c native/core.c -o build/test-directory -ljson-c -lssl -lcrypto -pthread +./build/test-directory +PASS directory validation, persistence, revisions, backup, live reports +cc -O2 -g -Wall -Wextra -Werror -std=c11 -Inative -DMARS_WRAPPED -DMARS_ID_TESTING '-DMARS_ID_DB="/tmp/mars094/mars_nwe/build/identity-test/ids.sqlite3"' tests/test_identity.c native/identity.c native/identity_wrap.c -Wl,--wrap=getpwnam -Wl,--wrap=getpwuid -Wl,--wrap=getpwnam_r -Wl,--wrap=getpwuid_r -Wl,--wrap=getgrnam -Wl,--wrap=getgrgid -Wl,--wrap=getgrnam_r -Wl,--wrap=getgrgid_r -Wl,--wrap=initgroups -Wl,--wrap=getgrouplist -lsqlite3 -o build/test-identity +cc -O2 -g -Wall -Wextra -Werror -std=c11 -Inative -I/usr/include/json-c -DMARS_ID_TESTING '-DMARS_ID_DB="/tmp/mars094/mars_nwe/build/identity-test/api.sqlite3"' tests/test_identity_api.c native/identity.c native/identity_api.c native/core.c -ljson-c -lssl -lcrypto -pthread -lsqlite3 -o build/test-identity-api +mkdir -p build/identity-test +chmod 0700 build/identity-test +./build/test-identity +PASS actual kernel UID-based file permission separation +PASS virtual UID/GID allocation, persistence, libc lookups, groups, permission and symlink rejection, no reuse +./build/test-identity-api +PASS API capability check, failed probe reservation, successful mocked Bindery create, duplicate rejection, no password in SQLite/API +cc -O2 -g -Wall -Wextra -std=c11 -I/usr/include/json-c tests/test_scripts.c -o build/test-scripts -ljson-c -lssl -lcrypto -pthread +./build/test-scripts +PASS system/personal scripts, CRLF, backup, inode/mode, stale revision, ASCII, symlink rejection +cc -O2 -g -Wall -Wextra -std=c11 tests/test_trustee.c -o build/test-trustee +./build/test-trustee + +MARS-TRUSTEE -1 + +MARS-TRUSTEE 65 + +MARS-TRUSTEE -1 +PASS trustee path/rights validation, mock get/set/remove, revision conflict, symlink rejection +cc -O2 -g -Wall -Wextra -Werror -std=c11 -Inds tests/test_nds_frag.c nds/fragger.c -o build/test-nds-frag +./build/test-nds-frag +PASS experimental NDS 104/2 fragment assembly, reply fragmentation, handles, bounds, errors +node --test browser/test.mjs browser/audio-controller.test.mjs browser/lifecycle.test.mjs +TAP version 13 +# Subtest: managed audio only starts on request, stops, and can restart after failure +ok 1 - managed audio only starts on request, stops, and can restart after failure + --- + duration_ms: 3.078498 + type: 'test' + ... +# Subtest: missing audio server and spawn failure remain unavailable +ok 2 - missing audio server and spawn failure remain unavailable + --- + duration_ms: 0.920216 + type: 'test' + ... +# Subtest: external audio mode does not start or kill a separate process +ok 3 - external audio mode does not start or kill a separate process + --- + duration_ms: 0.136956 + type: 'test' + ... +# Subtest: admin accessible while disabled, listener toggle and persisted restart +ok 4 - admin accessible while disabled, listener toggle and persisted restart + --- + duration_ms: 538.551496 + type: 'test' + ... +# Subtest: configuration bounds and secure defaults +ok 5 - configuration bounds and secure defaults + --- + duration_ms: 1.396294 + type: 'test' + ... +# Subtest: packet fragmentation and network order +ok 6 - packet fragmentation and network order + --- + duration_ms: 1.392378 + type: 'test' + ... +# Subtest: RLE565 +ok 7 - RLE565 + --- + duration_ms: 0.237037 + type: 'test' + ... +# Subtest: ADPCM independent block +ok 8 - ADPCM independent block + --- + duration_ms: 0.274303 + type: 'test' + ... +1..8 +# tests 8 +# suites 0 +# pass 8 +# fail 0 +# cancelled 0 +# skipped 0 +# todo 0 +# duration_ms 604.507636 +node --check websetup/app.js +make -C clients/retro-browser check +make[1]: Entering directory '/tmp/mars094/mars_nwe/clients/retro-browser' +cc -O2 -Wall -Wextra -std=c89 -pedantic common/rbp.c common/test.c -o rbp-test +./rbp-test +PASS C89 wire fragmentation, endian, RLE bounds, PCM, IMA ADPCM +rm -f rbp-test +make[1]: Leaving directory '/tmp/mars094/mars_nwe/clients/retro-browser' +cc -D_DEFAULT_SOURCE -O2 -g -Wall -Wextra -Werror -std=c11 -Isrc tests/test_ncp_ip_config.c src/ncp_ip_config.c -o build/test-ncp-ip-config -I/usr/include/json-c -ljson-c +node tests/test_ncp_ip_ui.cjs +PASS NCP/IP UI: local address selection, validation, revision, save, failed load +./build/test-ncp-ip-config +PASS NCP/IP local/private address and type validation +cc -D_DEFAULT_SOURCE -O2 -g -Wall -Wextra -Werror -std=c11 -Isrc tests/test_slp.c src/slp.c -o build/test-slp +./build/test-slp +PASS SLPv2 query, attributes, scope/filter, no NDS advertisement, malformed packets and random inputs +./build/test-nds-lab +PASS ping, context, public Resolve Name, fragment isolation, replay, close, denied auth, malformed packets and 50000 random requests +MARS_NDS_LAB=0 ./build/test-nds-lab disabled +PASS disabled or invalid model fails closed +MARS_NDS_LAB=1 MARS_NDS_LAB_CONFIG='{"tree":"X","organization":"Y","units":["A/B"]}' ./build/test-nds-lab invalid +PASS disabled or invalid model fails closed +python3 tests/test_nds_hook.py +PASS dispatcher hook compile/link fixture, rejects repeated or incompatible patch; actual upstream not tested +node tests/test_directory_ui.cjs +PASS wizard form validation and generated client instructions +python3 tests/test_dos_export.py +Read-only DOS snapshot: /tmp/tmp_6fv0wax/dos +Configure a SEPARATE read-only NetWare volume and its trustee rights. Source ACLs are not copied. +PASS: DOS aliases, collisions, reserved names, bytes, CP850 catalog, link rejection + +CivetWeb check: +:1:10: fatal error: civetweb.h: No such file or directory +compilation terminated. diff --git a/TEST-RESULTS-0.9.5-NDS-INTEGRATION.txt b/TEST-RESULTS-0.9.5-NDS-INTEGRATION.txt new file mode 100644 index 0000000..de95028 --- /dev/null +++ b/TEST-RESULTS-0.9.5-NDS-INTEGRATION.txt @@ -0,0 +1,191 @@ +MARS NWE 0.9.5 NDS Integration – actual test run +Base: uploaded 0.9.4 archive; remote Git DNS/fetch failed. +make -j2 check-release: exit 0 +cc -D_DEFAULT_SOURCE -O2 -g -Wall -Wextra -std=c11 src/broker.c src/slp.c src/ncp_ip.c src/ncp_ip_config.c src/wire.c src/pcap_dyn.c src/ipxpkt.c src/gateway.c src/dhcp.c src/gateway_config.c -I/usr/include/json-c -ljson-c -ldl -o build/mars-pcapd +cc -D_DEFAULT_SOURCE -O2 -g -Wall -Wextra -std=c11 -c src/shim.c -o build/shim.o +cc -D_DEFAULT_SOURCE -O2 -g -Wall -Wextra -std=c11 -Isrc tests/test_wire.c src/wire.c -o build/test-wire +cc -O2 -g -Wall -Wextra -std=c11 -Inative -I/usr/include/json-c tests/test_native.c native/core.c -o build/test-native -ljson-c -lssl -lcrypto -pthread +cc -O2 -g -Wall -Wextra -std=c11 -DMARS_TESTING -Inative -I/usr/include/json-c tests/test_supervisor.c native/supervisor.c native/core.c -o build/test-supervisor -ljson-c -lssl -lcrypto -pthread +cc -D_DEFAULT_SOURCE -O2 -g -Wall -Wextra -std=c11 -Isrc tests/test_gateway.c src/ipxpkt.c src/gateway_config.c -o build/test-gateway -I/usr/include/json-c -ljson-c +cc -D_DEFAULT_SOURCE -O2 -g -Wall -Wextra -std=c11 -Isrc -I/usr/include/json-c tests/test_gateway_auto.c native/gateway_auto.c native/core.c src/dhcp.c src/gateway_config.c -o build/test-gateway-auto -ljson-c -lssl -lcrypto -pthread +cc -D_DEFAULT_SOURCE -O2 -g -Wall -Wextra -std=c11 -Isrc -Iclients/windows -Iclients/windows/ndis5 tests/test_winclient.c clients/windows/client_core.c clients/windows/ndis5/frame_queue.c src/ipxpkt.c src/dhcp.c -o build/test-winclient -I/usr/include/json-c -ljson-c +cc -O2 -g -Wall -Wextra -std=c89 -pedantic -DMARS_LEGACY_KERNEL -Iclients/windows/ndis3 tests/test_legacy.c clients/windows/ndis3/legacy_core.c clients/windows/ndis5/frame_queue.c -o build/test-legacy +cc -O2 -g -Wall -Wextra -std=c11 -Inative -I/usr/include/json-c tests/test_print.c native/printing.c native/core.c -o build/test-print -ljson-c -lssl -lcrypto -pthread -ldl +cc -O2 -g -Wall -Wextra -std=c11 -I/usr/include/json-c native/print_stdin.c native/rawprint.c native/printing.c native/core.c -o build/mars-print -ljson-c -lssl -lcrypto -pthread -ldl +cc -O2 -g -Wall -Wextra -std=c11 tests/test_raw.c native/rawprint.c -o build/test-raw +cc -O2 -g -Wall -Wextra -std=c11 -Inative -I/usr/include/json-c tests/test_directory.c native/directory.c native/core.c -o build/test-directory -ljson-c -lssl -lcrypto -pthread +cc -O2 -g -Wall -Wextra -Werror -std=c11 -Inative -DMARS_WRAPPED -DMARS_ID_TESTING '-DMARS_ID_DB="/mnt/data/work/mars_nwe/build/identity-test/ids.sqlite3"' tests/test_identity.c native/identity.c native/identity_wrap.c -Wl,--wrap=getpwnam -Wl,--wrap=getpwuid -Wl,--wrap=getpwnam_r -Wl,--wrap=getpwuid_r -Wl,--wrap=getgrnam -Wl,--wrap=getgrgid -Wl,--wrap=getgrnam_r -Wl,--wrap=getgrgid_r -Wl,--wrap=initgroups -Wl,--wrap=getgrouplist -lsqlite3 -o build/test-identity +cc -O2 -g -Wall -Wextra -Werror -std=c11 -Inative -I/usr/include/json-c -DMARS_ID_TESTING '-DMARS_ID_DB="/mnt/data/work/mars_nwe/build/identity-test/api.sqlite3"' tests/test_identity_api.c native/identity.c native/identity_api.c native/core.c -ljson-c -lssl -lcrypto -pthread -lsqlite3 -o build/test-identity-api +cc -O2 -g -Wall -Wextra -std=c11 -I/usr/include/json-c tests/test_scripts.c -o build/test-scripts -ljson-c -lssl -lcrypto -pthread +cc -O2 -g -Wall -Wextra -std=c11 tests/test_trustee.c -o build/test-trustee +./build/test-nds-frag +PASS experimental NDS 104/2 fragment assembly, reply fragmentation, handles, bounds, errors +node --test browser/test.mjs browser/audio-controller.test.mjs browser/lifecycle.test.mjs +TAP version 13 +cc -D_DEFAULT_SOURCE -O2 -g -Wall -Wextra -Werror -std=c11 -Isrc tests/test_ncp_ip_config.c src/ncp_ip_config.c -o build/test-ncp-ip-config -I/usr/include/json-c -ljson-c +# Subtest: managed audio only starts on request, stops, and can restart after failure +ok 1 - managed audio only starts on request, stops, and can restart after failure + --- + duration_ms: 3.344764 + type: 'test' + ... +# Subtest: missing audio server and spawn failure remain unavailable +ok 2 - missing audio server and spawn failure remain unavailable + --- + duration_ms: 0.975358 + type: 'test' + ... +# Subtest: external audio mode does not start or kill a separate process +ok 3 - external audio mode does not start or kill a separate process + --- + duration_ms: 0.141953 + type: 'test' + ... +node tests/test_ncp_ip_ui.cjs +PASS NCP/IP UI: local address selection, validation, revision, save, failed load +cc -D_DEFAULT_SOURCE -O2 -g -Wall -Wextra -Werror -std=c11 -Isrc tests/test_slp.c src/slp.c -o build/test-slp +./build/test-nds-lab +PASS ping, context, public Resolve Name, fragment isolation, replay, close, denied auth, malformed packets and 50000 random requests +MARS_NDS_LAB=0 ./build/test-nds-lab disabled +PASS disabled or invalid model fails closed +MARS_NDS_LAB=1 MARS_NDS_LAB_CONFIG='{"tree":"X","organization":"Y","units":["A/B"]}' ./build/test-nds-lab invalid +PASS disabled or invalid model fails closed +python3 tests/test_nds_hook.py +# Subtest: admin accessible while disabled, listener toggle and persisted restart +ok 4 - admin accessible while disabled, listener toggle and persisted restart + --- + duration_ms: 570.039747 + type: 'test' + ... +# Subtest: configuration bounds and secure defaults +ok 5 - configuration bounds and secure defaults + --- + duration_ms: 2.230146 + type: 'test' + ... +# Subtest: packet fragmentation and network order +ok 6 - packet fragmentation and network order + --- + duration_ms: 1.847311 + type: 'test' + ... +# Subtest: RLE565 +ok 7 - RLE565 + --- + duration_ms: 0.87733 + type: 'test' + ... +# Subtest: ADPCM independent block +ok 8 - ADPCM independent block + --- + duration_ms: 0.392 + type: 'test' + ... +1..8 +# tests 8 +# suites 0 +# pass 8 +# fail 0 +# cancelled 0 +# skipped 0 +# todo 0 +# duration_ms 638.798093 +node --check websetup/app.js +make -C clients/retro-browser check +make[1]: Entering directory '/mnt/data/work/mars_nwe/clients/retro-browser' +cc -O2 -Wall -Wextra -std=c89 -pedantic common/rbp.c common/test.c -o rbp-test +./rbp-test +PASS C89 wire fragmentation, endian, RLE bounds, PCM, IMA ADPCM +rm -f rbp-test +make[1]: Leaving directory '/mnt/data/work/mars_nwe/clients/retro-browser' +python3 tests/test_nds_directory.py +PASS native resolve/read/list/search, ambiguity, pagination, readonly, stable IDs +PASS provisioning, permission mode, duplicate and malformed object rejection +PASS trace metadata aggregation and signed error decoding (synthetic TSV) +python3 tests/test_nds_snapshot.py +PASS database-backed NCP Resolve Name and fail-closed login +PASS database-backed NCP Resolve Name and fail-closed login +PASS disabled or invalid model fails closed +PASS disabled or invalid model fails closed +PASS database-backed NCP Resolve Name and fail-closed login +PASS snapshot default privacy, stable IDs, no reuse, rollback on collision, absent/mismatched database fails closed +ar rcs build/libmarspcap.a build/shim.o +./build/test-native +PASS merge, CRLF, unknown lines, injection rejection +PASS managed LFN server version merge +PASS backup, revision conflict, private file, traversal rejection +PASS PBKDF2, default, persistent password, wrong password +PASS validation invalid configuration and detected Ethernet interface +./build/test-supervisor +PASS dispatcher hook compile/link fixture, rejects repeated or incompatible patch; actual upstream not tested +./build/test-gateway +PASS: IPXPKT both sockets, little-endian IDs, fragmentation, out-of-order, duplicates, expiry, throughput, malformed data, config validation, static MAC/IP and ARP policy +./build/test-gateway-auto +PASS: overlapping routes, DHCP OFFER/ACK/NAK, malformed and spoofed packets +./build/test-winclient +PASS: Windows client core + actual server codec/DHCP; peer validation, fragments, queue +./build/test-legacy +legacy core: queue, MAC, packet filter, invalid frames, lease expiry passed +./build/test-print +CUPS probe (actual library): { "error": "Bad file descriptor" } +PASS: invalid destination rejected +./build/test-raw +PASS: RAW TCP 9100 exact binary bytes over local TCP +./build/test-directory +PASS directory validation, persistence, revisions, backup, live reports +mkdir -p build/identity-test +chmod 0700 build/identity-test +./build/test-identity +PASS actual kernel UID-based file permission separation +PASS virtual UID/GID allocation, persistence, libc lookups, groups, permission and symlink rejection, no reuse +./build/test-identity-api +PASS API capability check, failed probe reservation, successful mocked Bindery create, duplicate rejection, no password in SQLite/API +./build/test-scripts +PASS system/personal scripts, CRLF, backup, inode/mode, stale revision, ASCII, symlink rejection +./build/test-trustee + +MARS-TRUSTEE -1 + +MARS-TRUSTEE 65 + +MARS-TRUSTEE -1 +PASS trustee path/rights validation, mock get/set/remove, revision conflict, symlink rejection +./build/test-ncp-ip-config +PASS NCP/IP local/private address and type validation +./build/test-slp +PASS SLPv2 query, attributes, scope/filter, no NDS advertisement, malformed packets and random inputs +cc -D_DEFAULT_SOURCE -O2 -g -Wall -Wextra -std=c11 -Isrc tests/test_ipc.c build/libmarspcap.a -o build/test-ipc +./build/test-wire +PASS: 4 frame types, addresses, padding, lengths, malformed frames and MTU +PASS supervisor: start, restart, stop, restart after stop, shutdown; browser independent start, update restart, crash recovery, shutdown (mock child processes) +node tests/test_directory_ui.cjs +PASS wizard form validation and generated client instructions +python3 tests/test_dos_export.py +Read-only DOS snapshot: /tmp/tmpbph8deu7/dos +Configure a SEPARATE read-only NetWare volume and its trustee rights. Source ACLs are not copied. +PASS: DOS aliases, collisions, reserved names, bytes, CP850 catalog, link rejection + +Final NDS rerun after input validation change: exit 0 +python3 tests/test_nds_directory.py +PASS native resolve/read/list/search, ambiguity, pagination, readonly, stable IDs +PASS provisioning, permission mode, duplicate and malformed object rejection +PASS trace metadata aggregation and signed error decoding (synthetic TSV) +python3 tests/test_nds_snapshot.py +PASS database-backed NCP Resolve Name and fail-closed login +PASS database-backed NCP Resolve Name and fail-closed login +PASS disabled or invalid model fails closed +PASS disabled or invalid model fails closed +PASS database-backed NCP Resolve Name and fail-closed login +PASS snapshot default privacy, stable IDs, no reuse, rollback on collision, absent/mismatched database fails closed +./build/test-nds-lab +PASS ping, context, public Resolve Name, fragment isolation, replay, close, denied auth, malformed packets and 50000 random requests +MARS_NDS_LAB=0 ./build/test-nds-lab disabled +PASS disabled or invalid model fails closed +MARS_NDS_LAB=1 MARS_NDS_LAB_CONFIG='{"tree":"X","organization":"Y","units":["A/B"]}' ./build/test-nds-lab invalid +PASS disabled or invalid model fails closed +python3 tests/test_nds_hook.py +PASS dispatcher hook compile/link fixture, rejects repeated or incompatible patch; actual upstream not tested +Shell and JS syntax checks: exit 0 +ASan/UBSan synthetic packet fuzz: exit 0 (leak detection disabled) +PASS ping, context, public Resolve Name, fragment isolation, replay, close, denied auth, malformed packets and 50000 random requests +NOT RUN: upstream build (external tree and CivetWeb headers unavailable), systemd, actual client login, tshark pcap parsing, real IPX/TCP network integration. diff --git a/TEST-RESULTS-0.9.6-NDS-DISCOVERY.txt b/TEST-RESULTS-0.9.6-NDS-DISCOVERY.txt new file mode 100644 index 0000000..e0b797f --- /dev/null +++ b/TEST-RESULTS-0.9.6-NDS-DISCOVERY.txt @@ -0,0 +1,176 @@ +MARS NWE 0.9.6 – NDS Discovery Lab – executed validation +Mon Nov 30 20:15:15 UTC 2026 +PASS make -j2 check-release (exit 0) +./build/test-wire +./build/test-native +PASS: 4 frame types, addresses, padding, lengths, malformed frames and MTU +./build/test-supervisor +PASS merge, CRLF, unknown lines, injection rejection +PASS managed LFN server version merge +PASS backup, revision conflict, private file, traversal rejection +PASS PBKDF2, default, persistent password, wrong password +PASS validation invalid configuration and detected Ethernet interface +./build/test-gateway +PASS: IPXPKT both sockets, little-endian IDs, fragmentation, out-of-order, duplicates, expiry, throughput, malformed data, config validation, static MAC/IP and ARP policy +./build/test-gateway-auto +PASS: overlapping routes, DHCP OFFER/ACK/NAK, malformed and spoofed packets +./build/test-winclient +PASS: Windows client core + actual server codec/DHCP; peer validation, fragments, queue +./build/test-legacy +legacy core: queue, MAC, packet filter, invalid frames, lease expiry passed +./build/test-print +CUPS probe (actual library): { "error": "Bad file descriptor" } +PASS: invalid destination rejected +./build/test-raw +PASS: RAW TCP 9100 exact binary bytes over local TCP +./build/test-directory +PASS directory validation, persistence, revisions, backup, live reports +mkdir -p build/identity-test +chmod 0700 build/identity-test +./build/test-identity +PASS actual kernel UID-based file permission separation +PASS virtual UID/GID allocation, persistence, libc lookups, groups, permission and symlink rejection, no reuse +./build/test-identity-api +PASS API capability check, failed probe reservation, successful mocked Bindery create, duplicate rejection, no password in SQLite/API +./build/test-scripts +PASS system/personal scripts, CRLF, backup, inode/mode, stale revision, ASCII, symlink rejection +./build/test-trustee + +MARS-TRUSTEE -1 + +MARS-TRUSTEE 65 + +MARS-TRUSTEE -1 +PASS trustee path/rights validation, mock get/set/remove, revision conflict, symlink rejection +./build/test-nds-frag +PASS experimental NDS 104/2 fragment assembly, reply fragmentation, handles, bounds, errors +node --test browser/test.mjs browser/audio-controller.test.mjs browser/lifecycle.test.mjs +TAP version 13 +# Subtest: managed audio only starts on request, stops, and can restart after failure +ok 1 - managed audio only starts on request, stops, and can restart after failure + --- + duration_ms: 8.477084 + type: 'test' + ... +# Subtest: missing audio server and spawn failure remain unavailable +ok 2 - missing audio server and spawn failure remain unavailable + --- + duration_ms: 1.017507 + type: 'test' + ... +# Subtest: external audio mode does not start or kill a separate process +ok 3 - external audio mode does not start or kill a separate process + --- + duration_ms: 0.140919 + type: 'test' + ... +# Subtest: admin accessible while disabled, listener toggle and persisted restart +ok 4 - admin accessible while disabled, listener toggle and persisted restart + --- + duration_ms: 646.240586 + type: 'test' + ... +# Subtest: configuration bounds and secure defaults +ok 5 - configuration bounds and secure defaults + --- + duration_ms: 2.018149 + type: 'test' + ... +# Subtest: packet fragmentation and network order +ok 6 - packet fragmentation and network order + --- + duration_ms: 2.132043 + type: 'test' + ... +# Subtest: RLE565 +ok 7 - RLE565 + --- + duration_ms: 0.302849 + type: 'test' + ... +# Subtest: ADPCM independent block +ok 8 - ADPCM independent block + --- + duration_ms: 0.322437 + type: 'test' + ... +1..8 +# tests 8 +# suites 0 +# pass 8 +# fail 0 +# cancelled 0 +# skipped 0 +# todo 0 +# duration_ms 726.620774 +node --check websetup/app.js +make -C clients/retro-browser check +make[1]: Entering directory '/tmp/mars96/mars_nwe/clients/retro-browser' +cc -O2 -Wall -Wextra -std=c89 -pedantic common/rbp.c common/test.c -o rbp-test +./rbp-test +PASS C89 wire fragmentation, endian, RLE bounds, PCM, IMA ADPCM +rm -f rbp-test +make[1]: Leaving directory '/tmp/mars96/mars_nwe/clients/retro-browser' +node tests/test_ncp_ip_ui.cjs +PASS NCP/IP UI: local address selection, validation, revision, save, failed load +./build/test-slp +PASS optional NDAP root URL/attributes, scope, filters, unchanged bindery and NDS SAP query encoding +PASS SLPv2 query, attributes, scope/filter, no NDS advertisement, malformed packets and random inputs +./build/test-nds-lab +PASS ping, context, public Resolve Name, fragment isolation, replay, close, denied auth, malformed packets and 50000 random requests +MARS_NDS_LAB=0 ./build/test-nds-lab disabled +PASS disabled or invalid model fails closed +MARS_NDS_LAB=1 MARS_NDS_LAB_CONFIG='{"tree":"X","organization":"Y","units":["A/B"]}' ./build/test-nds-lab invalid +PASS disabled or invalid model fails closed +python3 tests/test_nds_hook.py +PASS supervisor: start, restart, stop, restart after stop, shutdown; browser independent start, update restart, crash recovery, shutdown (mock child processes) +python3 tests/test_nds_directory.py +PASS dispatcher hook compile/link fixture, rejects repeated or incompatible patch; actual upstream not tested +python3 tests/test_nds_probe.py +PASS native resolve/read/list/search, ambiguity, pagination, readonly, stable IDs +PASS provisioning, permission mode, duplicate and malformed object rejection +PASS trace metadata aggregation and signed error decoding (synthetic TSV) +python3 tests/test_nds_snapshot.py +PASS independent probe UDP/TCP loopback fixtures, Ping, Resolve, slot release and malformed reply rejection +PASS database-backed NCP Resolve Name and fail-closed login +PASS database-backed NCP Resolve Name and fail-closed login +PASS disabled or invalid model fails closed +PASS disabled or invalid model fails closed +./build/test-ncp-ip-config +PASS NCP/IP local/private address and type validation +PASS database-backed NCP Resolve Name and fail-closed login +PASS snapshot default privacy, stable IDs, no reuse, rollback on collision, absent/mismatched database fails closed +node tests/test_directory_ui.cjs +PASS wizard form validation and generated client instructions +python3 tests/test_dos_export.py +Read-only DOS snapshot: /tmp/tmpbhc0bzjh/dos +Configure a SEPARATE read-only NetWare volume and its trustee rights. Source ACLs are not copied. +PASS: DOS aliases, collisions, reserved names, bytes, CP850 catalog, link rejection +PASS make -j2 check-ncp-ip-integration (exit 0) +cc -D_DEFAULT_SOURCE -O2 -g -Wall -Wextra -Werror -std=c11 -Isrc tests/test_ncp_ip.c build/libmarspcap.a -o build/test-ncp-ip +./tests/run_ncp_ip.sh +MARS PCAP broker ready (OFFLINE TEST) +IPX interface 12345678 Internal None +PASS real broker SLP UDP unicast/multicast, attributes, NDS opt-in state, SAP withdrawal +PASS NDS request metadata and upstream shutdown invalidates TCP sessions +PASS real TCP framing, fragmented input, separate session nodes, spoof rejection, watchdog, disconnect, malformed signed frame +Broker stopped, dropped=0 +./tests/run_ncp_ip.sh --nds +MARS PCAP broker ready (OFFLINE TEST) +IPX interface 12345678 Internal None +PASS real broker SLP UDP unicast/multicast, attributes, NDS opt-in state, SAP withdrawal +PASS NDS request metadata and upstream shutdown invalidates TCP sessions +PASS real TCP framing, fragmented input, separate session nodes, spoof rejection, watchdog, disconnect, malformed signed frame +Broker stopped, dropped=0 +./tests/run_ncp_ip.sh --invalid-nds +MARS PCAP broker ready (OFFLINE TEST) +IPX interface 12345678 Internal None +PASS real broker SLP UDP unicast/multicast, attributes, NDS opt-in state, SAP withdrawal +PASS NDS request metadata and upstream shutdown invalidates TCP sessions +PASS real TCP framing, fragmented input, separate session nodes, spoof rejection, watchdog, disconnect, malformed signed frame +Broker stopped, dropped=0 +PASS AddressSanitizer/UndefinedBehaviorSanitizer (SLP/SAP tests, 100000 random inputs) +PASS optional NDAP root URL/attributes, scope, filters, unchanged bindery and NDS SAP query encoding +PASS SLPv2 query, attributes, scope/filter, no NDS advertisement, malformed packets and random inputs +PASS bash -n nds-lab.sh tests/run_ncp_ip.sh; node --check websetup/app.js; Python compile and CLI discovery validation +NOT EXECUTED: real upstream nwconn build, CivetWeb native link, physical IPX/SAP, original Windows XP Novell Client, systemd deployment. Probe loopback fixtures, simulated upstream NCP server. diff --git a/TEST-RESULTS-0.9.7-NDS-SCHEMA.txt b/TEST-RESULTS-0.9.7-NDS-SCHEMA.txt new file mode 100644 index 0000000..176b7fe --- /dev/null +++ b/TEST-RESULTS-0.9.7-NDS-SCHEMA.txt @@ -0,0 +1,191 @@ +MARS NWE 0.9.7 – Testprotokoll + +PASS: make -j2 check-release (exit 0) +./build/test-wire +./build/test-native +PASS: 4 frame types, addresses, padding, lengths, malformed frames and MTU +./build/test-supervisor +PASS merge, CRLF, unknown lines, injection rejection +PASS managed LFN server version merge +PASS backup, revision conflict, private file, traversal rejection +PASS PBKDF2, default, persistent password, wrong password +PASS validation invalid configuration and detected Ethernet interface +./build/test-gateway +PASS: IPXPKT both sockets, little-endian IDs, fragmentation, out-of-order, duplicates, expiry, throughput, malformed data, config validation, static MAC/IP and ARP policy +./build/test-gateway-auto +PASS: overlapping routes, DHCP OFFER/ACK/NAK, malformed and spoofed packets +./build/test-winclient +PASS: Windows client core + actual server codec/DHCP; peer validation, fragments, queue +./build/test-legacy +legacy core: queue, MAC, packet filter, invalid frames, lease expiry passed +./build/test-print +CUPS probe (actual library): { "error": "Bad file descriptor" } +PASS: invalid destination rejected +./build/test-raw +PASS: RAW TCP 9100 exact binary bytes over local TCP +./build/test-directory +PASS directory validation, persistence, revisions, backup, live reports +mkdir -p build/identity-test +chmod 0700 build/identity-test +./build/test-identity +PASS actual kernel UID-based file permission separation +PASS virtual UID/GID allocation, persistence, libc lookups, groups, permission and symlink rejection, no reuse +./build/test-identity-api +PASS API capability check, failed probe reservation, successful mocked Bindery create, duplicate rejection, no password in SQLite/API +./build/test-scripts +PASS system/personal scripts, CRLF, backup, inode/mode, stale revision, ASCII, symlink rejection +./build/test-trustee + +MARS-TRUSTEE -1 + +MARS-TRUSTEE 65 + +MARS-TRUSTEE -1 +PASS trustee path/rights validation, mock get/set/remove, revision conflict, symlink rejection +./build/test-nds-frag +PASS experimental NDS 104/2 fragment assembly, reply fragmentation, handles, bounds, errors +node --test browser/test.mjs browser/audio-controller.test.mjs browser/lifecycle.test.mjs +TAP version 13 +# Subtest: managed audio only starts on request, stops, and can restart after failure +ok 1 - managed audio only starts on request, stops, and can restart after failure + --- + duration_ms: 2.621393 + type: 'test' + ... +# Subtest: missing audio server and spawn failure remain unavailable +ok 2 - missing audio server and spawn failure remain unavailable + --- + duration_ms: 0.969417 + type: 'test' + ... +# Subtest: external audio mode does not start or kill a separate process +ok 3 - external audio mode does not start or kill a separate process + --- + duration_ms: 0.138385 + type: 'test' + ... +# Subtest: admin accessible while disabled, listener toggle and persisted restart +ok 4 - admin accessible while disabled, listener toggle and persisted restart + --- + duration_ms: 568.549724 + type: 'test' + ... +# Subtest: configuration bounds and secure defaults +ok 5 - configuration bounds and secure defaults + --- + duration_ms: 1.628582 + type: 'test' + ... +# Subtest: packet fragmentation and network order +ok 6 - packet fragmentation and network order + --- + duration_ms: 1.027211 + type: 'test' + ... +# Subtest: RLE565 +ok 7 - RLE565 + --- + duration_ms: 0.16922 + type: 'test' + ... +# Subtest: ADPCM independent block +ok 8 - ADPCM independent block + --- + duration_ms: 0.26358 + type: 'test' + ... +1..8 +# tests 8 +# suites 0 +# pass 8 +# fail 0 +# cancelled 0 +# skipped 0 +# todo 0 +# duration_ms 620.328451 +node --check websetup/app.js +make -C clients/retro-browser check +make[1]: Entering directory '/tmp/m97/mars_nwe/clients/retro-browser' +cc -O2 -Wall -Wextra -std=c89 -pedantic common/rbp.c common/test.c -o rbp-test +./rbp-test +PASS C89 wire fragmentation, endian, RLE bounds, PCM, IMA ADPCM +rm -f rbp-test +make[1]: Leaving directory '/tmp/m97/mars_nwe/clients/retro-browser' +node tests/test_ncp_ip_ui.cjs +PASS NCP/IP UI: local address selection, validation, revision, save, failed load +./build/test-slp +PASS optional NDAP root URL/attributes, scope, filters, unchanged bindery and NDS SAP query encoding +PASS SLPv2 query, attributes, scope/filter, no NDS advertisement, malformed packets and random inputs +cc -D_DEFAULT_SOURCE -O2 -g -Wall -Wextra -std=c11 -Inds tests/test_nds_server.c nds/server.c nds/fragger.c nds/nds_directory.c -o build/test-nds-lab -I/usr/include/json-c -ljson-c -lsqlite3 +cc -D_DEFAULT_SOURCE -O2 -g -Wall -Wextra -Werror -std=c11 -Inds tests/test_nds_directory.c nds/nds_directory.c -o build/test-nds-directory -lsqlite3 +python3 tests/test_nds_probe.py +PASS independent probe UDP/TCP loopback fixtures, Ping, Resolve, slot release and malformed reply rejection +cc -D_DEFAULT_SOURCE -O2 -g -Wall -Wextra -Werror -std=c11 -Inds nds/tools/inspect.c nds/nds_directory.c -o build/mars-nds-inspect -lsqlite3 +cc -D_DEFAULT_SOURCE -O2 -g -Wall -Wextra -Werror -std=c11 -Inds tests/test_nds_schema.c nds/nds_directory.c -o build/test-nds-schema -lsqlite3 +./build/test-ncp-ip-config +PASS NCP/IP local/private address and type validation +./build/test-nds-lab +PASS ping, context, public Resolve Name, fragment isolation, replay, close, denied auth, malformed packets and 50000 random requests +MARS_NDS_LAB=0 ./build/test-nds-lab disabled +PASS disabled or invalid model fails closed +MARS_NDS_LAB=1 MARS_NDS_LAB_CONFIG='{"tree":"X","organization":"Y","units":["A/B"]}' ./build/test-nds-lab invalid +PASS disabled or invalid model fails closed +python3 tests/test_nds_hook.py +PASS supervisor: start, restart, stop, restart after stop, shutdown; browser independent start, update restart, crash recovery, shutdown (mock child processes) +python3 tests/test_nds_directory.py +PASS native resolve/read/list/search, ambiguity, pagination, readonly, stable IDs +PASS provisioning, permission mode, duplicate and malformed object rejection +PASS trace metadata aggregation and signed error decoding (synthetic TSV) +python3 tests/test_nds_snapshot.py +PASS dispatcher hook compile/link fixture, rejects repeated or incompatible patch; actual upstream not tested +python3 tests/test_nds_schema.py +PASS database-backed NCP Resolve Name and fail-closed login +PASS database-backed NCP Resolve Name and fail-closed login +PASS disabled or invalid model fails closed +PASS disabled or invalid model fails closed +PASS database-backed NCP Resolve Name and fail-closed login +PASS snapshot default privacy, stable IDs, no reuse, rollback on collision, absent/mismatched database fails closed +PASS native attributes, typed DN/bool/string compare, missing attributes, bounds, read-only DB +PASS NCP 104/06 statistics, flag negotiation, bounds, reset denied +PASS resource object NCP Resolve, unsupported NDAP/auth verbs denied +PASS optional verb-only trace, no names or packet payload +PASS resource import, no secrets/paths, stable IDs, NCP resolve, local CLI, collisions, opt-in and validation +node tests/test_directory_ui.cjs +PASS wizard form validation and generated client instructions +python3 tests/test_dos_export.py +Read-only DOS snapshot: /tmp/tmptn1gjhqj/dos +Configure a SEPARATE read-only NetWare volume and its trustee rights. Source ACLs are not copied. +PASS: DOS aliases, collisions, reserved names, bytes, CP850 catalog, link rejection + +PASS: make check-ncp-ip-integration (exit 0; real broker with mock upstream) +cc -D_DEFAULT_SOURCE -O2 -g -Wall -Wextra -Werror -std=c11 -Isrc tests/test_ncp_ip.c build/libmarspcap.a -o build/test-ncp-ip +./tests/run_ncp_ip.sh +MARS PCAP broker ready (OFFLINE TEST) +IPX interface 12345678 Internal None +PASS real broker SLP UDP unicast/multicast, attributes, NDS opt-in state, SAP withdrawal +PASS NDS request metadata and upstream shutdown invalidates TCP sessions +PASS real TCP framing, fragmented input, separate session nodes, spoof rejection, watchdog, disconnect, malformed signed frame +Broker stopped, dropped=0 +./tests/run_ncp_ip.sh --nds +MARS PCAP broker ready (OFFLINE TEST) +IPX interface 12345678 Internal None +PASS real broker SLP UDP unicast/multicast, attributes, NDS opt-in state, SAP withdrawal +PASS NDS request metadata and upstream shutdown invalidates TCP sessions +PASS real TCP framing, fragmented input, separate session nodes, spoof rejection, watchdog, disconnect, malformed signed frame +Broker stopped, dropped=0 +./tests/run_ncp_ip.sh --invalid-nds +MARS PCAP broker ready (OFFLINE TEST) +IPX interface 12345678 Internal None +PASS real broker SLP UDP unicast/multicast, attributes, NDS opt-in state, SAP withdrawal +PASS NDS request metadata and upstream shutdown invalidates TCP sessions +PASS real TCP framing, fragmented input, separate session nodes, spoof rejection, watchdog, disconnect, malformed signed frame +Broker stopped, dropped=0 + +PASS: ASan/UBSan server and schema tests (exit 0) +PASS ping, context, public Resolve Name, fragment isolation, replay, close, denied auth, malformed packets and 50000 random requests +PASS native attributes, typed DN/bool/string compare, missing attributes, bounds, read-only DB +PASS NCP 104/06 statistics, flag negotiation, bounds, reset denied +PASS resource object NCP Resolve, unsupported NDAP/auth verbs denied + +PASS: shell, JavaScript and Python syntax checks. +NOT TESTED: actual upstream build, CivetWeb full integration, systemd deployment, physical IPX network, original Novell Client, native NDS authentication. diff --git a/TEST-RESULTS-0.9.8-NDS-WIRE.txt b/TEST-RESULTS-0.9.8-NDS-WIRE.txt new file mode 100644 index 0000000..84f5c58 --- /dev/null +++ b/TEST-RESULTS-0.9.8-NDS-WIRE.txt @@ -0,0 +1,173 @@ +MARS NWE 0.9.8 – Tests + +make -j2 check-release: exit 0 +./build/test-wire +./build/test-native +PASS: 4 frame types, addresses, padding, lengths, malformed frames and MTU +./build/test-supervisor +PASS merge, CRLF, unknown lines, injection rejection +PASS managed LFN server version merge +PASS backup, revision conflict, private file, traversal rejection +PASS PBKDF2, default, persistent password, wrong password +PASS validation invalid configuration and detected Ethernet interface +./build/test-gateway +PASS: IPXPKT both sockets, little-endian IDs, fragmentation, out-of-order, duplicates, expiry, throughput, malformed data, config validation, static MAC/IP and ARP policy +./build/test-gateway-auto +PASS: overlapping routes, DHCP OFFER/ACK/NAK, malformed and spoofed packets +./build/test-winclient +PASS: Windows client core + actual server codec/DHCP; peer validation, fragments, queue +./build/test-legacy +legacy core: queue, MAC, packet filter, invalid frames, lease expiry passed +./build/test-print +CUPS probe (actual library): { "error": "Bad file descriptor" } +PASS: invalid destination rejected +./build/test-raw +PASS: RAW TCP 9100 exact binary bytes over local TCP +./build/test-directory +PASS directory validation, persistence, revisions, backup, live reports +mkdir -p build/identity-test +chmod 0700 build/identity-test +./build/test-identity +PASS actual kernel UID-based file permission separation +PASS virtual UID/GID allocation, persistence, libc lookups, groups, permission and symlink rejection, no reuse +./build/test-identity-api +PASS API capability check, failed probe reservation, successful mocked Bindery create, duplicate rejection, no password in SQLite/API +./build/test-scripts +PASS system/personal scripts, CRLF, backup, inode/mode, stale revision, ASCII, symlink rejection +./build/test-trustee + +MARS-TRUSTEE -1 + +MARS-TRUSTEE 65 + +MARS-TRUSTEE -1 +PASS trustee path/rights validation, mock get/set/remove, revision conflict, symlink rejection +./build/test-nds-frag +PASS experimental NDS 104/2 fragment assembly, reply fragmentation, handles, bounds, errors +node --test browser/test.mjs browser/audio-controller.test.mjs browser/lifecycle.test.mjs +TAP version 13 +# Subtest: managed audio only starts on request, stops, and can restart after failure +ok 1 - managed audio only starts on request, stops, and can restart after failure + --- + duration_ms: 3.993464 + type: 'test' + ... +# Subtest: missing audio server and spawn failure remain unavailable +ok 2 - missing audio server and spawn failure remain unavailable + --- + duration_ms: 1.124926 + type: 'test' + ... +# Subtest: external audio mode does not start or kill a separate process +ok 3 - external audio mode does not start or kill a separate process + --- + duration_ms: 0.180477 + type: 'test' + ... +# Subtest: admin accessible while disabled, listener toggle and persisted restart +ok 4 - admin accessible while disabled, listener toggle and persisted restart + --- + duration_ms: 423.626251 + type: 'test' + ... +# Subtest: configuration bounds and secure defaults +ok 5 - configuration bounds and secure defaults + --- + duration_ms: 1.403979 + type: 'test' + ... +# Subtest: packet fragmentation and network order +ok 6 - packet fragmentation and network order + --- + duration_ms: 1.0197 + type: 'test' + ... +# Subtest: RLE565 +ok 7 - RLE565 + --- + duration_ms: 0.193917 + type: 'test' + ... +# Subtest: ADPCM independent block +ok 8 - ADPCM independent block + --- + duration_ms: 0.268587 + type: 'test' + ... +1..8 +# tests 8 +# suites 0 +# pass 8 +# fail 0 +# cancelled 0 +# skipped 0 +# todo 0 +# duration_ms 496.322144 +node --check websetup/app.js +make -C clients/retro-browser check +make[1]: Entering directory '/tmp/ndswork/mars_nwe/clients/retro-browser' +cc -O2 -Wall -Wextra -std=c89 -pedantic common/rbp.c common/test.c -o rbp-test +./rbp-test +PASS C89 wire fragmentation, endian, RLE bounds, PCM, IMA ADPCM +rm -f rbp-test +make[1]: Leaving directory '/tmp/ndswork/mars_nwe/clients/retro-browser' +node tests/test_ncp_ip_ui.cjs +PASS NCP/IP UI: local address selection, validation, revision, save, failed load +./build/test-slp +PASS optional NDAP root URL/attributes, scope, filters, unchanged bindery and NDS SAP query encoding +PASS SLPv2 query, attributes, scope/filter, no NDS advertisement, malformed packets and random inputs +./build/test-nds-lab +PASS ping, context, public Resolve Name, fragment isolation, replay, close, denied auth, malformed packets and 50000 random requests +MARS_NDS_LAB=0 ./build/test-nds-lab disabled +PASS disabled or invalid model fails closed +MARS_NDS_LAB=1 MARS_NDS_LAB_CONFIG='{"tree":"X","organization":"Y","units":["A/B"]}' ./build/test-nds-lab invalid +PASS disabled or invalid model fails closed +python3 tests/test_nds_hook.py +PASS dispatcher hook compile/link fixture, rejects repeated or incompatible patch; actual upstream not tested +python3 tests/test_nds_directory.py +PASS native resolve/read/list/search, ambiguity, pagination, readonly, stable IDs +PASS provisioning, permission mode, duplicate and malformed object rejection +PASS trace metadata aggregation and signed error decoding (synthetic TSV) +python3 tests/test_nds_snapshot.py +PASS database-backed NCP Resolve Name and fail-closed login +PASS database-backed NCP Resolve Name and fail-closed login +PASS supervisor: start, restart, stop, restart after stop, shutdown; browser independent start, update restart, crash recovery, shutdown (mock child processes) +python3 tests/test_nds_probe.py +PASS disabled or invalid model fails closed +PASS disabled or invalid model fails closed +PASS database-backed NCP Resolve Name and fail-closed login +PASS snapshot default privacy, stable IDs, no reuse, rollback on collision, absent/mismatched database fails closed +python3 tests/test_nds_schema.py +PASS independent probe UDP/TCP loopback fixtures, Ping, Resolve, slot release and malformed reply rejection +PASS NDAP Read (Attributnamen): Object Class +PASS Read probe fragmented reply and slot release +python3 tests/test_nds_wire.py +PASS native attributes, typed DN/bool/string compare, missing attributes, bounds, read-only DB +PASS NCP 104/06 statistics, flag negotiation, bounds, reset denied +PASS resource object NCP Resolve, unsupported NDAP/auth verbs denied +PASS optional verb-only trace, no names or packet payload +PASS resource import, no secrets/paths, stable IDs, NCP resolve, local CLI, collisions, opt-in and validation +./build/test-ncp-ip-config +PASS NCP/IP local/private address and type validation +PASS NDAP 2/3/4/5/6 wire fixtures, root and readable resolve, multiframe, bool/DN/string, selection, search, bounds, 10000 malformed inner requests, denied writes/auth +node tests/test_directory_ui.cjs +PASS wizard form validation and generated client instructions +python3 tests/test_dos_export.py +Read-only DOS snapshot: /tmp/tmpncfbke4y/dos +Configure a SEPARATE read-only NetWare volume and its trustee rights. Source ACLs are not copied. +PASS: DOS aliases, collisions, reserved names, bytes, CP850 catalog, link rejection + +Original ncpfs libncp.a: configure PASS; initial modern GCC build failed (nested static function and pointer type), temporary fixes per guide; static library built. +ar r libncp.a ncplib.o filemgmt.o queue.o nwcalls.o nwtime.o cfgfile.o fs/eas.o strops.o ncpext.o nwclient.o resolve.o fs/filelock.o stats.o ndscrypt.o nwnet.o wcs.o rdn.o ds/filter.o ds/search.o ds/request.o ds/setkeys.o ds/dsgetstat.o ds/partops.o ds/iterhandle.o ds/effright.o ds/dsread.o ds/dslist.o ds/bindctx.o ds/classes.o ds/syntaxes.o ds/dsstream.o o_ndslib.o ncpsign.o ndslib.o mpilib.o +ar: creating libncp.a +make: Leaving directory '/tmp/ndswork/ncpfs-2.2.6/lib' + +make check-nds-ncpfs: exit 0 +python3 tests/test_nds_ncpfs.py +PASS original ncpfs 2.2.6 Read/Compare/EntryInfo constructors and Read/List/Search decoders via NCP transport fixture + +ASan/UBSan, shared C dispatcher (leak detection disabled for Python host): exit 0 +PASS NDAP 2/3/4/5/6 wire fixtures, root and readable resolve, multiframe, bool/DN/string, selection, search, bounds, 10000 malformed inner requests, denied writes/auth + +Shell and JS syntax checks: exit 0. +NOT TESTED: actual upstream build, production service installation, physical IPX, original Windows XP client, native NDS login. CivetWeb header and original upstream tree unavailable. diff --git a/nds-lab.sh b/nds-lab.sh new file mode 100755 index 0000000..86da24f --- /dev/null +++ b/nds-lab.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash +set -euo pipefail +cd "$(dirname "$0")" +source_file=/usr/local/etc/mars_nwe/nwserv.conf.directory.json +case ${1:-status} in + status) systemctl show mars_vme.service -p DropInPaths; echo 'NDS-Labor: Resolve Name, optionale Leseoperationen und Baumerkennung, keine Anmeldung. Der Dienststatus allein bestätigt keine NDS-Unterstützung.'; if [[ -r /run/mars-pcap/ncp-ip-status ]]; then grep -E '^(NDS-|SLP=|SLP-Replies=)' /run/mars-pcap/ncp-ip-status || true; fi;; + check) shift; flags=(); while [[ ${1:-} == --* ]]; do case $1 in --public-placements|--discovery) flags+=("$1");; --resources) flags+=(--server-config /usr/local/etc/mars_nwe/nwserv.conf);; *) echo "Unbekannte Option: $1" >&2; exit 2;; esac; shift; done; [[ $# -le 1 ]] || exit 2; python3 nds/tools/snapshot.py "${1:-$source_file}" /dev/null --check "${flags[@]}";; + inspect) + shift + [[ -x build/mars-nds-inspect ]] || { echo 'Zuerst make build/mars-nds-inspect ausführen.' >&2; exit 1; } + exec build/mars-nds-inspect /var/lib/mars-nds/directory.sqlite3 "$@";; + enable|disable) + [[ $EUID == 0 ]] || { echo 'Bitte mit sudo ausführen.' >&2; exit 1; } + exec 9>/run/lock/mars-nds-lab.lock; flock -x 9 + if [[ ${1} == enable ]]; then + [[ -f upstream/build-complete && -f upstream/patched/src/nds_directory.c ]] || { echo 'Zuerst MARS_ENABLE_NDS_LAB=1 ./rebuild.sh erfolgreich bauen und installieren.' >&2; exit 1; } + shift + flags=(); discovery=0; trace=0; readops=0 + while [[ ${1:-} == --* ]]; do + case $1 in + --public-placements) flags+=(--public-placements); echo 'WARNUNG: gespeicherte Benutzer-/Gruppennamen werden ohne Authentifizierung auflösbar. Nur isoliertes Testnetz.';; + --read-ops) readops=1; echo 'WARNUNG: NDAP-Leseoperationen ohne Anmeldung, ausschließlich für öffentlichen Snapshot im isolierten Testnetz.';; + --trace) trace=1; echo 'NDS-Diagnose: nur Verb, Paketlänge und Status, maximal 32 Zeilen je nwconn-Prozess.';; + --resources) flags+=(--server-config /usr/local/etc/mars_nwe/nwserv.conf);; + --discovery) discovery=1; echo 'WARNUNG: experimentelle Baumerkennung, keine NDS-Anmeldung. Nur isoliertes Testnetz.';; + *) echo "Unbekannte Option: $1" >&2; exit 2;; + esac; shift + done + [[ $# -le 1 ]] || { echo 'Zu viele Argumente.' >&2; exit 2; } + install -d -o root -g root -m 0755 /var/lib/mars-nds + if [[ $discovery == 1 ]]; then flags+=(--discovery); fi + raw=$(python3 nds/tools/snapshot.py "${1:-$source_file}" /var/lib/mars-nds/directory.sqlite3 "${flags[@]}") + python3 - "$raw" "$discovery" "$trace" "$readops" <<'PY' +import json, pathlib, sys, os, tempfile +raw=sys.argv[1]; data=json.loads(raw) +base=pathlib.Path('/etc/systemd/system/mars_vme.service.d');base.mkdir(parents=True,exist_ok=True) +fd,tmp=tempfile.mkstemp(prefix='.nds-lab-',dir=base) +with os.fdopen(fd,'w') as f: + f.write('[Service]\nEnvironment="MARS_NDS_LAB=1"\nEnvironment="MARS_NDS_LAB_CONFIG='+raw.replace('"','\\"')+'"\nEnvironment="MARS_NDS_LAB_DB=/var/lib/mars-nds/directory.sqlite3"\n') + if sys.argv[4]=='1': f.write('Environment="MARS_NDS_LAB_READ=1"\n') + if sys.argv[3]=='1': f.write('Environment="MARS_NDS_LAB_TRACE=1"\n') + if sys.argv[2]=='1': f.write('Environment="MARS_NDS_DISCOVERY_TREE='+data['tree']+'"\n') +os.replace(tmp,base/'90-nds-lab.conf') +print('NDS-Labor-Konfiguration vorbereitet: '+data['tree']+' / O='+data['organization']) +PY + else + rm -f /etc/systemd/system/mars_vme.service.d/90-nds-lab.conf + echo 'NDS-Labor deaktiviert; Datenbank zur Erhaltung der Objekt-IDs nicht gelöscht.' + fi + systemctl daemon-reload + echo 'Zum Anwenden sudo systemctl restart mars_vme.service ausführen. Bestehende Sitzungen werden getrennt.';; + *) echo 'Verwendung: ./nds-lab.sh check [--discovery] [--resources] [--public-placements] [Verzeichnisdatei] | sudo ./nds-lab.sh enable [--read-ops] [--trace] [--discovery] [--resources] [--public-placements] [Verzeichnisdatei] | disable | status | inspect read/list/search/compare DN [Argumente]' >&2; exit 2;; +esac diff --git a/nds/nds_directory.c b/nds/nds_directory.c new file mode 100644 index 0000000..b157deb --- /dev/null +++ b/nds/nds_directory.c @@ -0,0 +1,123 @@ +#include "nds_directory.h" +#include +#include +static const char cols[]="id,coalesce(parent,0),dn,name,cls,enabled"; +static int copycol(sqlite3_stmt *s,int i,char *dest,size_t cap){ + const unsigned char *v=sqlite3_column_text(s,i); int n=sqlite3_column_bytes(s,i); + if(!v||n<0||(size_t)n>=cap||memchr(v,0,(size_t)n)) return 0; + memcpy(dest,v,(size_t)n); dest[n]=0; return 1; +} +static int entry(sqlite3_stmt *s,struct nds_entry *out){ + sqlite3_int64 id=sqlite3_column_int64(s,0),parent=sqlite3_column_int64(s,1); + struct nds_entry t={0}; + if(id<1||id>=UINT32_MAX||parent<0||parent>=UINT32_MAX) return NDS_DB_ERROR; + t.id=(uint32_t)id;t.parent=(uint32_t)parent;t.enabled=sqlite3_column_int(s,5); + if((t.enabled!=0&&t.enabled!=1)||!copycol(s,2,t.dn,sizeof t.dn)||!copycol(s,3,t.name,sizeof t.name)||!copycol(s,4,t.cls,sizeof t.cls)) return NDS_DB_ERROR; + *out=t;return NDS_OK; +} +int nds_open(sqlite3 **db,const char *path){ + sqlite3_stmt *s=NULL;int ok=0; + if(!db||!path||!*path) return NDS_INVALID; + *db=NULL; + if(sqlite3_open_v2(path,db,SQLITE_OPEN_READONLY,NULL)!=SQLITE_OK) goto fail; + sqlite3_busy_timeout(*db,2000); + if(sqlite3_exec(*db,"PRAGMA query_only=ON; PRAGMA trusted_schema=OFF;",NULL,NULL,NULL)!=SQLITE_OK) goto fail; + if(sqlite3_prepare_v2(*db,"SELECT version FROM nds_meta WHERE id=1",-1,&s,NULL)==SQLITE_OK&&sqlite3_step(s)==SQLITE_ROW&&sqlite3_column_int(s,0)==1) ok=1; + sqlite3_finalize(s);if(ok)return NDS_OK; +fail:sqlite3_close(*db);*db=NULL;return NDS_DB_ERROR; +} +static int one(sqlite3_stmt *s,struct nds_entry *out){ + int r=sqlite3_step(s),rc; + if(r==SQLITE_DONE)rc=NDS_NOT_FOUND; + else if(r!=SQLITE_ROW)rc=NDS_DB_ERROR; + else if((rc=entry(s,out))==NDS_OK){r=sqlite3_step(s);if(r==SQLITE_ROW)rc=NDS_AMBIGUOUS;else if(r!=SQLITE_DONE)rc=NDS_DB_ERROR;} + sqlite3_finalize(s);if(rc!=NDS_OK)memset(out,0,sizeof *out);return rc; +} +int nds_resolve(sqlite3 *db,const char *dn,struct nds_entry *out){ + sqlite3_stmt *s=NULL;char q[256];size_t n; + if(!db||!dn||!out)return NDS_INVALID; + memset(out,0,sizeof *out);if(*dn=='.')dn++; + n=strlen(dn);if(!n||n>NDS_DN_MAX)return NDS_INVALID; + /* Typed names match DN; untyped names match UDN. Mixed forms intentionally rejected. */ + sqlite3_snprintf(sizeof q,q,"SELECT %s FROM nds_entries WHERE %s=?1 COLLATE NOCASE",cols,strchr(dn,'=')?"dn":"udn"); + if(sqlite3_prepare_v2(db,q,-1,&s,NULL)!=SQLITE_OK)return NDS_DB_ERROR; + if(sqlite3_bind_text(s,1,dn,-1,SQLITE_TRANSIENT)!=SQLITE_OK){sqlite3_finalize(s);return NDS_DB_ERROR;}return one(s,out); +} +int nds_read(sqlite3 *db,uint32_t id,struct nds_entry *out){ + sqlite3_stmt *s=NULL;char q[160];if(!db||!out||!id||id==UINT32_MAX)return NDS_INVALID; + memset(out,0,sizeof *out);sqlite3_snprintf(sizeof q,q,"SELECT %s FROM nds_entries WHERE id=?1",cols); + if(sqlite3_prepare_v2(db,q,-1,&s,NULL)!=SQLITE_OK)return NDS_DB_ERROR; + if(sqlite3_bind_int64(s,1,id)!=SQLITE_OK){sqlite3_finalize(s);return NDS_DB_ERROR;}return one(s,out); +} +int nds_search(sqlite3 *db,uint32_t base,enum nds_scope scope,const char *name,const char *cls,uint32_t after,struct nds_entry *out,size_t capacity,size_t *count,uint32_t *next){ + char q[1024];sqlite3_stmt *s=NULL;int r,rc=NDS_OK;struct nds_entry tmp; + if(count)*count=0; + if(next)*next=0; + if(!db||!out||!count||!next||!capacity||capacity>NDS_PAGE_MAX||scopeNDS_SUBTREE||after==UINT32_MAX||(name&&strlen(name)>NDS_NAME_MAX)||(cls&&strlen(cls)>23))return NDS_INVALID; + if((rc=nds_read(db,base,&tmp))!=NDS_OK)return rc; + /* UNION (not UNION ALL) prevents looping on a corrupt cyclic DB. */ + const char *where=scope==NDS_BASE?"id=?1":scope==NDS_ONE?"parent=?1":"id IN (SELECT id FROM descendants)"; + const char *cte=scope==NDS_SUBTREE?"WITH RECURSIVE descendants(id) AS (SELECT id FROM nds_entries WHERE id=?1 UNION SELECT e.id FROM nds_entries e JOIN descendants d ON e.parent=d.id) ":""; + sqlite3_snprintf(sizeof q,q,"%sSELECT %s FROM nds_entries WHERE %s AND id>?2 AND (?3 IS NULL OR name=?3 COLLATE NOCASE) AND (?4 IS NULL OR cls=?4 COLLATE NOCASE) ORDER BY id LIMIT ?5",cte,cols,where); + if(sqlite3_prepare_v2(db,q,-1,&s,NULL)!=SQLITE_OK)return NDS_DB_ERROR; + if(sqlite3_bind_int64(s,1,base)!=SQLITE_OK||sqlite3_bind_int64(s,2,after)!=SQLITE_OK||(name?sqlite3_bind_text(s,3,name,-1,SQLITE_TRANSIENT):sqlite3_bind_null(s,3))!=SQLITE_OK||(cls?sqlite3_bind_text(s,4,cls,-1,SQLITE_TRANSIENT):sqlite3_bind_null(s,4))!=SQLITE_OK||sqlite3_bind_int(s,5,(int)capacity+1)!=SQLITE_OK){rc=NDS_DB_ERROR;goto done;} + while((r=sqlite3_step(s))==SQLITE_ROW){if(*count==capacity){*next=out[*count-1].id;break;}rc=entry(s,&out[*count]);if(rc!=NDS_OK)goto done;(*count)++;} + if(r!=SQLITE_ROW&&r!=SQLITE_DONE)rc=NDS_DB_ERROR; +done:sqlite3_finalize(s);if(rc!=NDS_OK){*count=0;*next=0;}return rc; +} + +/* Small, explicitly local schema projection; no fabricated NDAP syntax IDs. */ +static void attr(struct nds_attr *a, const char *name, enum nds_attr_kind kind, const char *value){ + a->name=name;a->kind=kind;sqlite3_snprintf(sizeof a->value,a->value,"%s",value); +} +int nds_attributes(sqlite3 *db,uint32_t id,struct nds_attr *out,size_t cap,size_t *count){ + struct nds_entry e;struct nds_attr a[NDS_ATTR_MAX]={0};size_t n=0;int rc; + if(!count)return NDS_INVALID; + *count=0;if(!db||(!out&&cap))return NDS_INVALID; + rc=nds_read(db,id,&e);if(rc!=NDS_OK)return rc; + const char *naming=NULL; + if(!strcmp(e.cls,"Organization"))naming="O"; + else if(!strcmp(e.cls,"Organizational Unit"))naming="OU"; + else if(!strcmp(e.cls,"User")||!strcmp(e.cls,"Group")||!strcmp(e.cls,"NCP Server")||!strcmp(e.cls,"Volume"))naming="CN"; + else if(strcmp(e.cls,"Root"))return NDS_DB_ERROR; + attr(&a[n++],"Object Class",NDS_ATTR_CI_STRING,e.cls); + if(naming)attr(&a[n++],naming,NDS_ATTR_CI_STRING,e.name); + if(!strcmp(e.cls,"User"))attr(&a[n++],"Login Disabled",NDS_ATTR_BOOL,e.enabled?"FALSE":"TRUE"); + if(!strcmp(e.cls,"Volume")){ + /* Older/manual directories need not have the optional volume table. */ + sqlite3_stmt *s=NULL; + if(sqlite3_prepare_v2(db,"SELECT 1 FROM sqlite_master WHERE type='table' AND name='mars_nds_volume'",-1,&s,NULL)!=SQLITE_OK)return NDS_DB_ERROR; + int exists=sqlite3_step(s);sqlite3_finalize(s); + if(exists!=SQLITE_ROW&&exists!=SQLITE_DONE)return NDS_DB_ERROR; + if(exists==SQLITE_ROW){ + if(sqlite3_prepare_v2(db,"SELECT e.dn,v.resource FROM mars_nds_volume v JOIN nds_entries e ON e.id=v.server_id WHERE v.id=?1 AND e.cls='NCP Server'",-1,&s,NULL)!=SQLITE_OK)return NDS_DB_ERROR; + if(sqlite3_bind_int64(s,1,id)!=SQLITE_OK){sqlite3_finalize(s);return NDS_DB_ERROR;} + int r=sqlite3_step(s); + if(r==SQLITE_ROW){char dn[NDS_DN_MAX+1],res[NDS_NAME_MAX+1]; + if(!copycol(s,0,dn,sizeof dn)||!copycol(s,1,res,sizeof res)||!dn[0]||!res[0]){sqlite3_finalize(s);return NDS_DB_ERROR;} + attr(&a[n++],"Host Server",NDS_ATTR_DN,dn); + attr(&a[n++],"Host Resource Name",NDS_ATTR_CI_STRING,res); + r=sqlite3_step(s); + } + sqlite3_finalize(s);if(r!=SQLITE_DONE)return NDS_DB_ERROR; + } + } + *count=n;if(cap63||strlen(value)>NDS_DN_MAX)return NDS_INVALID; + rc=nds_attributes(db,id,a,NDS_ATTR_MAX,&n);if(rc!=NDS_OK)return rc; + for(size_t i=0;i +#include +#include +/* Trusted local backend only: no wire encoding or authentication. */ +#define NDS_DN_MAX 511 +#define NDS_NAME_MAX 63 +#define NDS_PAGE_MAX 128 +#define NDS_OK 0 +#define NDS_NOT_FOUND 1 +#define NDS_INVALID 2 +#define NDS_DB_ERROR 3 +#define NDS_AMBIGUOUS 4 +struct nds_entry { uint32_t id, parent; char dn[NDS_DN_MAX+1], name[NDS_NAME_MAX+1], cls[24]; int enabled; }; +enum nds_scope { NDS_BASE=0, NDS_ONE=1, NDS_SUBTREE=2 }; +int nds_open(sqlite3 **db, const char *path); +int nds_resolve(sqlite3 *db, const char *dn, struct nds_entry *out); +int nds_read(sqlite3 *db, uint32_t id, struct nds_entry *out); +/* after=0 for first page; next=0 at EOF, else last ID. Exact name/class filters, NULL = all. */ +int nds_search(sqlite3 *db, uint32_t base, enum nds_scope scope, const char *name, const char *cls, uint32_t after, struct nds_entry *out, size_t capacity, size_t *count, uint32_t *next); +/* Local schema subset. These enum values are internal, NOT NDAP wire IDs. + * No credential, membership or ACL attributes are exposed by this API. */ +enum nds_attr_kind { NDS_ATTR_CI_STRING=1, NDS_ATTR_DN, NDS_ATTR_BOOL }; +#define NDS_ATTR_MAX 8 +#define NDS_BUFFER_SMALL 5 +struct nds_attr { const char *name; enum nds_attr_kind kind; char value[NDS_DN_MAX+1]; }; +/* On insufficient capacity, count is the required size, out untouched. */ +int nds_attributes(sqlite3 *db, uint32_t id, struct nds_attr *out, size_t capacity, size_t *count); +/* NDS_NOT_FOUND means missing object or absent attribute, not a false match. */ +int nds_compare(sqlite3 *db, uint32_t id, const char *attribute, const char *value, int *matched); +#endif diff --git a/nds/server.c b/nds/server.c new file mode 100644 index 0000000..ef9633f --- /dev/null +++ b/nds/server.c @@ -0,0 +1,231 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#include "server.h" +#include "fragger.h" +#include "nds_directory.h" +#include +#include +#include +#include +#include +#include +/* Experimental public-container lookup, deliberately not an authenticated DS. */ +#define MAX_OBJECTS 130 +#define MAX_DN 256 +#define MAX_PACKET 4096 +#define UNAVAILABLE 0xfb +#define MALFORMED 0xfe +struct object {char typed[MAX_DN], plain[MAX_DN], path[192]; uint32_t id;}; +static struct object objects[MAX_OBJECTS]; +static size_t count; +static char tree[33], org[48]; +static int initialized, enabled, trace_enabled, wire_enabled; +static unsigned trace_count; +/* NCP 104/06: only counters we can measure truthfully in this process. + * Counts completed Resolve dispatches, not global DS requests. */ +#define STAT_MASK UINT32_C(0xe7) +static uint32_t stat_no_entry,stat_local,stat_requests,stat_request_bytes,stat_reply_bytes; +static sqlite3 *directory_db; +static struct nds_frag frag; +static uint32_t handle; +static uint8_t owner, last_task, last_seq; +static unsigned char last_in[MAX_PACKET], last_out[MAX_PACKET]; +static size_t last_n, last_used; +static int cached; +static time_t last_time; +static uint32_t le(const unsigned char *p){return (uint32_t)p[0]|(uint32_t)p[1]<<8|(uint32_t)p[2]<<16|(uint32_t)p[3]<<24;} +static void put(unsigned char *p,uint32_t x){for(unsigned i=0;i<4;i++)p[i]=(unsigned char)(x>>(8*i));} +static int label(const char *s,size_t max){size_t n=strlen(s);if(!n||n>max)return 0;for(size_t i=0;i='A'&&s[i]<='Z')||(s[i]>='0'&&s[i]<='9')||s[i]=='_'||s[i]=='-'))return 0;return 1;} +static const char *str(json_object *o,const char *k){json_object *v=NULL;if(!json_object_object_get_ex(o,k,&v)||!json_object_is_type(v,json_type_string))return NULL;const char *s=json_object_get_string(v);return strlen(s)==(size_t)json_object_get_string_len(v)?s:NULL;} +static int add(const char *typed,const char *plain,const char *path){if(count>=MAX_OBJECTS||strlen(typed)>=MAX_DN||strlen(plain)>=MAX_DN||strlen(path)>=sizeof objects[0].path)return -1;uint32_t h=2166136261u;for(const unsigned char *p=(const unsigned char*)typed;*p;p++)h=(h^*p)*16777619u;h=(h&0x3fffffffu)|0x40000000u;for(size_t i=0;ityped,typed);strcpy(o->plain,plain);strcpy(o->path,path);o->id=h;return 0;} +static int load(const char *raw){ + if(!raw||strlen(raw)>32768)return -1; + struct json_tokener *tok=json_tokener_new();if(!tok)return -1;json_tokener_set_flags(tok,JSON_TOKENER_STRICT);json_object *o=json_tokener_parse_ex(tok,raw,(int)strlen(raw)+1);int ok=json_tokener_get_error(tok)==json_tokener_success;json_tokener_free(tok);int rc=-1; + if(!ok||!o||!json_object_is_type(o,json_type_object))goto end; + const char *t=str(o,"tree"),*g=str(o,"organization");json_object *u=NULL; + if(!t||!g||!label(t,32)||!label(g,47)||!json_object_object_get_ex(o,"units",&u)||!json_object_is_type(u,json_type_array)||json_object_array_length(u)>128)goto end; + strcpy(tree,t);strcpy(org,g);char base[MAX_DN];snprintf(base,sizeof base,"O=%s",g);if(add(base,g,""))goto end; + for(size_t i=0;i=192||n!=(size_t)json_object_get_string_len(v)||s[0]=='/'||s[n-1]=='/'||strstr(s,"//"))goto end; + char path[192],typed[MAX_DN],plain[MAX_DN];strcpy(path,s);strcpy(typed,base);strcpy(plain,g);char *save=NULL,*p=strtok_r(path,"/",&save);unsigned depth=0; + while(p){char a[MAX_DN],b[MAX_DN];if(!label(p,47)||++depth>8)goto end;int x=snprintf(a,sizeof a,"OU=%s.%s",p,typed),y=snprintf(b,sizeof b,"%s.%s",p,plain);if(x<0||y<0||x>=MAX_DN||y>=MAX_DN)goto end;strcpy(typed,a);strcpy(plain,b);p=strtok_r(NULL,"/",&save);} + if(add(typed,plain,s))goto end; + } + for(size_t i=1;i2*MAX_DN||len%2)return -1;size_t padded=(len+3u)&~3u;if(padded>n-4)return -1;for(size_t i=0;i127)return -1;s[i]=(char)(c>='a'&&c<='z'?c-'a'+'A':c);}*consumed=4+padded;return 0;} +/* Read-only NDAP subset. Wire layout reference: ncpfs 2.2.6 GPL-2.0-or-later, + * lib/nwnet.c (NWDSGetDSIRaw, NWDSGetObjectName, NWDSGetAttrName, + * __NWDSCompare), lib/ds/{dsread,dslist,search,filter}.c. + * Independent server implementation. No authentication, rights, or writes. + * A response is all-or-error (no directory iteration handles yet). + */ +#define DS_BAD (-641) +#define DS_DENIED (-672) +#define DS_MISSING (-601) +#define DS_NO_ATTR (-603) +#define DS_FULL (-304) +#define DS_HANDLE (-322) +struct rd {const unsigned char *p;size_t n;}; +struct wr {unsigned char *p;size_t cap,n;int err;}; +static uint32_t be(const unsigned char *p){return (uint32_t)p[0]<<24|(uint32_t)p[1]<<16|(uint32_t)p[2]<<8|p[3];} +static int r32(struct rd *r,uint32_t *v){if(r->n<4)return -1;*v=le(r->p);r->p+=4;r->n-=4;return 0;} +static int rid(struct rd *r,uint32_t *v){if(r->n<4)return -1;*v=be(r->p);r->p+=4;r->n-=4;return 0;} +/* Length is bytes, not code units; 4-byte alignment. ASCII snapshot only. */ +static int rstr(struct rd *r,char *s,size_t cap,int empty){uint32_t n;if(r32(r,&n))return -1;if(!n){if(!empty)return -1;*s=0;return 0;}if(n<2||n%2||n/2>cap||n>r->n)return -1;size_t pad=((size_t)n+3)&~(size_t)3;if(pad>r->n)return -1;for(size_t i=0;ip[2*i];if(r->p[2*i+1]||c>127||(!c)!=(i==n/2-1))return -1;s[i]=(char)c;}r->p+=pad;r->n-=pad;return 0;} +static unsigned char *space(struct wr *w,size_t n){if(w->err||n>w->cap-w->n){w->err=1;return NULL;}unsigned char *p=w->p+w->n;memset(p,0,n);w->n+=n;return p;} +static void w32(struct wr *w,uint32_t x){unsigned char *p=space(w,4);if(p)put(p,x);} +static void wid(struct wr *w,uint32_t x){unsigned char *p=space(w,4);if(p){p[0]=x>>24;p[1]=x>>16;p[2]=x>>8;p[3]=x;}} +static void wstr(struct wr *w,const char *s){size_t n=strlen(s)+1;if(n>NDS_DN_MAX+1){w->err=1;return;}w32(w,(uint32_t)(2*n));unsigned char *p=space(w,(2*n+3)&~(size_t)3);if(p)for(size_t i=0;i127){w->err=1;return;}p[2*i]=(unsigned char)s[i];}} +static void wdn(struct wr *w,const char *dn,int typeless){char b[NDS_DN_MAX+1];if(!strcmp(dn,"[Root]")){wstr(w,"");return;}if(!typeless){wstr(w,dn);return;}size_t j=0;const char *p=dn;while(*p){const char *eq=strchr(p,'=');if(!eq){w->err=1;return;}p=eq+1;while(*p&&*p!='.'){if(j>=sizeof b-1){w->err=1;return;}b[j++]=*p++;}if(*p){if(j>=sizeof b-1){w->err=1;return;}b[j++]=*p++;}}b[j]=0;wstr(w,b);} +static int ds_rc(int rc){return rc==NDS_NOT_FOUND?DS_MISSING:rc==NDS_INVALID?DS_BAD:DS_DENIED;} +static int iscontainer(const struct nds_entry *e){return !strcmp(e->cls,"Organization")||!strcmp(e->cls,"Organizational Unit")||!strcmp(e->cls,"Root");} +/* DSI_OUTPUT_FIELDS lets us omit unimplemented metadata, not invent it. + * Supported: ID, subordinate count, parent ID, class, RDN, DN. */ +#define DSI_SUPPORTED UINT32_C(0x390b) +static int dsi_mask(uint32_t req,uint32_t *mask){if(!(req&1)&&(req&~DSI_SUPPORTED))return DS_DENIED;*mask=req&DSI_SUPPORTED;return 0;} +static int childcount(uint32_t id,uint32_t *count){sqlite3_stmt *s=NULL;int rc=DS_DENIED; if(sqlite3_prepare_v2(directory_db,"SELECT count(*) FROM nds_entries WHERE parent=?1",-1,&s,NULL)==SQLITE_OK&&sqlite3_bind_int64(s,1,id)==SQLITE_OK&&sqlite3_step(s)==SQLITE_ROW){sqlite3_int64 n=sqlite3_column_int64(s,0);if(n>=0&&n<=UINT32_MAX){*count=(uint32_t)n;rc=0;}}sqlite3_finalize(s);return rc;} +static int dsi(struct wr *w,const struct nds_entry *e,uint32_t m,int typeless){if(m&1)w32(w,m);if(m&2)wid(w,e->id);if(m&8){uint32_t n;if(childcount(e->id,&n))return DS_DENIED;w32(w,n);}if(m&0x100)wid(w,e->parent);if(m&0x800)wstr(w,e->cls);if(m&0x1000){char rdn[NDS_DN_MAX+1];strcpy(rdn,e->dn);char *dot=strchr(rdn,'.');if(dot)*dot=0;wdn(w,rdn,typeless);}if(m&0x2000)wdn(w,e->dn,typeless);return w->err?DS_FULL:0;} +struct selection {uint32_t all,count;char name[32][64];}; +static int selection(struct rd *r,uint32_t all,struct selection *s){if(all>1||r32(r,&s->count)||s->count>32||(all&&s->count))return -1;s->all=all;for(uint32_t i=0;icount;i++)if(rstr(r,s->name[i],sizeof s->name[i],0))return -1;return 0;} +static int selected(const struct selection *s,const char *a){if(s->all)return 1;for(uint32_t i=0;icount;i++)if(!sqlite3_stricmp(s->name[i],a))return 1;return 0;} +static uint32_t syntax(const struct nds_attr *a){if(a->kind==NDS_ATTR_DN)return 1;if(a->kind==NDS_ATTR_BOOL)return 7;if(!strcmp(a->name,"Object Class"))return 20;return 3;} +static int attrs(struct wr *w,uint32_t id,uint32_t info,const struct selection *s,int typeless){struct nds_attr a[NDS_ATTR_MAX];size_t n;int rc=nds_attributes(directory_db,id,a,NDS_ATTR_MAX,&n);if(rc!=NDS_OK)return ds_rc(rc);uint32_t cnt=0;for(size_t i=0;ierr?DS_FULL:0;} +/* Compare and single-leaf equality search: values use the attribute syntax, + * no separate syntax word in the request (NWDSPutAttrNameAndVal). */ +static int value_kind(const char *name){ + if(!sqlite3_stricmp(name,"Login Disabled"))return NDS_ATTR_BOOL; + if(!sqlite3_stricmp(name,"Host Server"))return NDS_ATTR_DN; + if(!sqlite3_stricmp(name,"Object Class")||!sqlite3_stricmp(name,"CN")||!sqlite3_stricmp(name,"O")||!sqlite3_stricmp(name,"OU")||!sqlite3_stricmp(name,"Host Resource Name"))return NDS_ATTR_CI_STRING; + return 0; +} +static int parse_value(struct rd *r,const char *name,char *value){int kind=value_kind(name);if(!kind)return DS_NO_ATTR; + if(kind==NDS_ATTR_BOOL){uint32_t len;if(r32(r,&len)||len!=1||r->n<4||*r->p>1)return DS_BAD;strcpy(value,*r->p?"TRUE":"FALSE");r->p+=4;r->n-=4;} + else if(rstr(r,value,NDS_DN_MAX+1,0))return DS_BAD; + return r->n?DS_BAD:0; +} +static int compare_value(uint32_t id,const char *name,const char *value,int *match){int rc=nds_compare(directory_db,id,name,value,match);return rc==NDS_OK?0:rc==NDS_NOT_FOUND?DS_NO_ATTR:ds_rc(rc);} +static int match_value(struct rd *r,uint32_t id,const char *name,int *match){char value[NDS_DN_MAX+1];struct nds_entry e;int rc=nds_read(directory_db,id,&e);if(rc!=NDS_OK)return ds_rc(rc);rc=parse_value(r,name,value);return rc?rc:compare_value(id,name,value,match);} +static int wire_read(uint32_t verb,const unsigned char *p,size_t n,unsigned char *out,size_t cap,size_t *used){struct rd r={p,n};struct wr w={out,cap,0,0};uint32_t ver,flags,id,iter,info,all,mask;struct nds_entry e;struct selection sel={0};int rc; + if(!directory_db)return DS_DENIED; + if(r32(&r,&ver))return DS_BAD; + if(verb==2){if(ver!=2||r32(&r,&flags)||r32(&r,&mask)||rid(&r,&id)||r.n||flags>1)return DS_BAD;if((rc=dsi_mask(mask,&mask)))return rc;rc=nds_read(directory_db,id,&e);if(rc!=NDS_OK)return ds_rc(rc);rc=dsi(&w,&e,mask,flags&1);if(rc)return rc;} + else if(verb==3){if(ver!=1||r32(&r,&flags)||r32(&r,&iter)||rid(&r,&id)||r32(&r,&info)||r32(&r,&all)||selection(&r,all,&sel)||r.n||flags>1||info>1)return DS_BAD; + if(iter!=NDS_END)return DS_HANDLE; + w32(&w,NDS_END);w32(&w,info);if((rc=attrs(&w,id,info,&sel,flags&1)))return rc;} + else if(verb==4){uint32_t cnt,vals;char name[64];int matched=0;if(ver||rid(&r,&id)||r32(&r,&cnt)||cnt!=1||rstr(&r,name,sizeof name,0)||r32(&r,&vals)||vals!=1)return DS_BAD;if((rc=match_value(&r,id,name,&matched)))return rc;unsigned char *b=space(&w,4);if(b)*b=(unsigned char)matched;} + else if(verb==5||verb==6){char name[64]={0},cls[64]={0},attrname[64]={0};uint32_t scope=1,unknown,tag=2,op=0;int containers=0;char value[NDS_DN_MAX+1]={0}; + if(r32(&r,&flags)||r32(&r,&iter)||rid(&r,&id))return DS_BAD; + if(iter!=NDS_END)return DS_HANDLE; + if(verb==5){if(ver!=1||(flags&~3u)||r32(&r,&mask)||rstr(&r,name,sizeof name,1)||rstr(&r,cls,sizeof cls,1)||r.n)return DS_BAD;containers=(flags&2)!=0;/* exact simple filters only */if(strchr(name,'*')||strchr(name,'?')||strchr(cls,'*')||strchr(cls,'?'))return DS_DENIED;} + else{if(ver!=3||(flags&~UINT32_C(0x10001))||r32(&r,&scope)||scope>2||r32(&r,&unknown)||unknown||r32(&r,&info)||info>1||r32(&r,&mask)||r32(&r,&all)||selection(&r,all,&sel)||r32(&r,&tag)||r32(&r,&op))return DS_BAD; + if(tag==2&&op==0){if(r.n)return DS_BAD;}else if(tag==0){if(op==17){if(rstr(&r,cls,sizeof cls,0)||r.n)return DS_BAD;}else if(op==16){if(rstr(&r,name,sizeof name,0)||r.n)return DS_BAD;/* RDN syntax ambiguous; reject typed RDN filter for now */if(strchr(name,'='))return DS_DENIED;}else if(op==15){if(rstr(&r,attrname,sizeof attrname,0)||r.n)return DS_BAD;}else if(op==7){if(rstr(&r,attrname,sizeof attrname,0))return DS_BAD;if((rc=parse_value(&r,attrname,value)))return rc;}else return DS_DENIED;}else return DS_DENIED;} + if(strlen(cls)>23)return DS_BAD; + if((rc=dsi_mask(mask,&mask)))return rc; + w32(&w,NDS_END);size_t searched_off=0,len_off=0,count_off; + if(verb==6){searched_off=w.n;w32(&w,0);w32(&w,info);len_off=w.n;w32(&w,0);} + count_off=w.n;w32(&w,0);uint32_t total=0,searched=0,after=0,next; + /* Bounded work per request; snapshot exporter max ~1200 objects. */ + do{struct nds_entry page[16];size_t got=0;rc=nds_search(directory_db,id,(enum nds_scope)scope,NULL,NULL,after,page,16,&got,&next);if(rc!=NDS_OK)return ds_rc(rc); + for(size_t i=0;i2048)return DS_FULL;if(containers&&!iscontainer(&e))continue;if(*name&&sqlite3_stricmp(name,e.name))continue;if(*cls&&sqlite3_stricmp(cls,e.cls))continue; + if(verb==6&&*attrname){if(op==15){struct nds_attr a[NDS_ATTR_MAX];size_t an;rc=nds_attributes(directory_db,e.id,a,NDS_ATTR_MAX,&an);if(rc!=NDS_OK)return ds_rc(rc);size_t j;for(j=0;j2)return -672; + char name[MAX_DN];size_t z;if(wire_enabled&&directory_db&&n>=16&&le(p+12)==0){strcpy(name,"[Root]");z=4;}else if(utf16_name(p+12,n-12,name,&z))return -641;size_t off=12+z; + for(unsigned i=0;i<2;i++){if(n-off<4)return -641;uint32_t k=le(p+off);off+=4;if(k>(n-off)/4)return -641;off+=(size_t)k*4;} + if(off!=n)return -641; + const char *q=name;if(*q=='.')q++;if(wire_enabled&&directory_db&&!*q)q="[Root]";size_t i;for(i=0;i>24;out[5]=id>>16;out[6]=id>>8;out[7]=id;put(out+8,0);*used=12;return 0; +} +static void add_stat(uint32_t *v,size_t n){ + if(n>UINT32_MAX-*v)*v=UINT32_MAX;else *v+=(uint32_t)n; +} +static int32_t resolve(void *ctx,uint32_t verb,const unsigned char *p,size_t n,unsigned char *out,size_t cap,size_t *used){ + int32_t rc=resolve_inner(ctx,verb,p,n,out,cap,used); + add_stat(&stat_requests,1);add_stat(&stat_request_bytes,n);add_stat(&stat_reply_bytes,*used); + if(rc==-601)add_stat(&stat_no_entry,1); + if(rc==0)add_stat(&stat_local,1); + return rc; +} +static int statistics(const unsigned char *p,size_t n,unsigned char *out,size_t cap,size_t *used){ + if(n!=5)return MALFORMED; + uint32_t flags=le(p+1),mask=flags&STAT_MASK; + /* When Output Fields is absent all requested statistics must be supported. */ + if(!(flags&1)&&(flags&~STAT_MASK))return MALFORMED; + const uint32_t values[]={mask,stat_no_entry,stat_local,0,0,stat_requests,stat_request_bytes,stat_reply_bytes}; + size_t len=0;for(unsigned i=0;i<8;i++)if(mask&(1u<MAX_PACKET)return MALFORMED; + time_t now=time(NULL);if(now==(time_t)-1||now30)reset();last_time=now; + if(cached&&task==last_task&&seq==last_seq&&n==last_n&&!memcmp(p,last_in,n)){if(cap6)){trace_request(verb,n,"unsupported");return UNAVAILABLE;}trace_request(verb,n,verb==1?"resolve-start":"read-start");owner=task;if(++handle==NDS_END||!handle)handle=1;} + else if(!frag.phase||owner!=task||le(p+1)!=frag.handle)return MALFORMED; + if(cap>MAX_PACKET)cap=MAX_PACKET; + if(nds_frag_step(&frag,handle,p,n,out,cap,used,resolve,NULL)){reset();return MALFORMED;} + memcpy(last_in,p,n);memcpy(last_out,out,*used);last_n=n;last_used=*used;last_task=task;last_seq=seq;cached=1;return 0; +} diff --git a/nds/server.h b/nds/server.h new file mode 100644 index 0000000..88d2c1d --- /dev/null +++ b/nds/server.h @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +#ifndef MARS_NDS_SERVER_H +#define MARS_NDS_SERVER_H +#include +#include +/* Process-local state: nwconn serves one connection. No authentication. */ +int mars_nds_request(uint8_t task, uint8_t seq, const unsigned char *p, size_t n, + unsigned char *out, size_t cap, size_t *used); +#endif diff --git a/nds/tools/directory.py b/nds/tools/directory.py new file mode 100644 index 0000000..0b6d110 --- /dev/null +++ b/nds/tools/directory.py @@ -0,0 +1,57 @@ +#!/usr/bin/env python3 +"""Local lab directory provisioning. Independent DB; never reads password data.""" +import argparse, os, re, sqlite3, sys +from pathlib import Path +SCHEMA = """ +CREATE TABLE nds_meta(id INTEGER PRIMARY KEY CHECK(id=1), version INTEGER NOT NULL); +INSERT INTO nds_meta VALUES(1,1); +CREATE TABLE nds_entries(id INTEGER PRIMARY KEY AUTOINCREMENT CHECK(id BETWEEN 1 AND 4294967294), + parent INTEGER REFERENCES nds_entries(id) ON DELETE RESTRICT, + dn TEXT NOT NULL COLLATE NOCASE UNIQUE, udn TEXT NOT NULL COLLATE NOCASE, + name TEXT NOT NULL COLLATE NOCASE, cls TEXT NOT NULL, enabled INTEGER NOT NULL DEFAULT 1 CHECK(enabled IN (0,1))); +CREATE INDEX nds_parent ON nds_entries(parent,id); +CREATE INDEX nds_udn ON nds_entries(udn); +INSERT INTO nds_entries(parent,dn,udn,name,cls) VALUES(NULL,'[Root]','[Root]','[Root]','Root'); +""" +CLASSES = {'Organization':'O', 'Organizational Unit':'OU','User':'CN','Group':'CN','NCP Server':'CN','Volume':'CN'} +CONTAINERS={'Root','Organization','Organizational Unit'} +def connect(path): + db=sqlite3.connect(Path(path).resolve().as_uri()+'?mode=rw',uri=True) + db.execute('PRAGMA foreign_keys=ON') + if db.execute('SELECT version FROM nds_meta WHERE id=1').fetchone() != (1,): + db.close(); raise ValueError('Unbekannte Datenbankversion') + return db +def initialize(path): + fd=os.open(path,os.O_CREAT|os.O_EXCL|os.O_WRONLY,0o600);os.close(fd) + try: + with sqlite3.connect(path) as db: db.executescript(SCHEMA) + except Exception: + os.unlink(path);raise + +def add(db,parent,cls,name): + if cls not in CLASSES or not re.fullmatch(r'[A-Za-z0-9_-]{1,63}',name):raise ValueError('Ungültige Klasse oder Name (ASCII, 1–63 Zeichen)') + with db: + db.execute('BEGIN IMMEDIATE') + p=db.execute('SELECT id,dn,udn,cls FROM nds_entries WHERE dn=? COLLATE NOCASE',(parent.lstrip('.'),)).fetchone() + if not p or p[3] not in CONTAINERS:raise ValueError('Übergeordnetes Objekt fehlt oder ist kein Container') + if (p[3]=='Root' and cls!='Organization') or (p[3]!='Root' and cls=='Organization'):raise ValueError('Nur Organisationen direkt unter Root; keine verschachtelten Organisationen') + dn=CLASSES[cls]+'='+name+('' if p[3]=='Root' else '.'+p[1]);udn=name+('' if p[3]=='Root' else '.'+p[2]) + if len(dn)>511 or len(udn)>511:raise ValueError('DN zu lang') + return db.execute('INSERT INTO nds_entries(parent,dn,udn,name,cls) VALUES(?,?,?,?,?)',(p[0],dn,udn,name,cls)).lastrowid + +def main(): + p=argparse.ArgumentParser(description=__doc__);p.add_argument('--db',required=True);s=p.add_subparsers(dest='command',required=True) + s.add_parser('init');a=s.add_parser('add');a.add_argument('--parent',required=True);a.add_argument('--class',dest='cls',choices=CLASSES,required=True);a.add_argument('--name',required=True) + s.add_parser('list');a=s.add_parser('disable');a.add_argument('dn');a=s.add_parser('enable');a.add_argument('dn') + a=p.parse_args() + try: + if a.command=='init':initialize(a.db);return + with connect(a.db) as db: + if a.command=='add':print(add(db,a.parent,a.cls,a.name)) + elif a.command=='list': + for row in db.execute('SELECT id,dn,cls,enabled FROM nds_entries ORDER BY id'):print(*row,sep='\t') + else: + r=db.execute("UPDATE nds_entries SET enabled=? WHERE dn=? COLLATE NOCASE AND cls='User'",(int(a.command=='enable'),a.dn.lstrip('.'))) + if r.rowcount!=1:raise ValueError('Benutzer nicht gefunden') + except (OSError,sqlite3.Error,ValueError) as e:p.exit(1,f'Fehler: {e}\n') +if __name__=='__main__':main() diff --git a/nds/tools/inspect.c b/nds/tools/inspect.c new file mode 100644 index 0000000..250f937 --- /dev/null +++ b/nds/tools/inspect.c @@ -0,0 +1,37 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* Local read-only inspector. Never a network service or login mechanism. */ +#include "nds_directory.h" +#include +#include +#include + +static void show(const struct nds_entry *e){printf("%u\t%s\t%s\n",(unsigned)e->id,e->cls,e->dn);} +static int run(sqlite3 *db,int argc,char **argv){ + struct nds_entry e; + int rc=nds_resolve(db,argv[3],&e);if(rc!=NDS_OK)return rc; + if(!strcmp(argv[2],"read")&&argc==4){ + struct nds_attr a[NDS_ATTR_MAX];size_t n; + rc=nds_attributes(db,e.id,a,NDS_ATTR_MAX,&n);if(rc!=NDS_OK)return rc; + show(&e);for(size_t i=0;i=4&&argc<=6)){ + struct nds_entry page[32];size_t n;uint32_t next=0; + do {rc=nds_search(db,e.id,search?NDS_SUBTREE:NDS_ONE,argc>=6?argv[5]:NULL,argc>=5?argv[4]:NULL,next,page,32,&n,&next);if(rc!=NDS_OK)return rc; + for(size_t i=0;i=2**31:error-=2**32 + if error:errors[error]+=1 + return total,verbs,errors,malformed + +def main(): + p=argparse.ArgumentParser(description=__doc__);g=p.add_mutually_exclusive_group(required=True);g.add_argument('--pcap');g.add_argument('--tsv');a=p.parse_args() + try: + if a.pcap: + cmd=['tshark','-n','-2','-r',a.pcap,'-Y','ncp.ndsverb || ncp.ndsreplyerror','-T','fields','-E','separator=/t','-E','occurrence=a'] + for f in FIELDS:cmd+=['-e',f] + with subprocess.Popen(cmd,stdout=subprocess.PIPE,text=True,encoding='utf-8',errors='replace') as proc: + result=summarize(csv.reader(proc.stdout,delimiter='\t'));rc=proc.wait() + if rc:raise ValueError(f'tshark exit {rc}') + else: + with open(a.tsv,encoding='utf-8',newline='') as f:result=summarize(csv.reader(f,delimiter='\t')) + except (OSError,ValueError) as e:p.exit(1,f'Fehler: {e}\n') + total,verbs,errors,bad=result + print(f'NDS-Metadatenzeilen: {total}; ungültig: {bad}') + for v,n in sorted(verbs.items()):print(f'Verb {v:3} {VERBS.get(v,"Unbekannt")}: {n}') + for e,n in sorted(errors.items()):print(f'NDS-Fehler {e}: {n}') + if not total:print('Keine dekodierten NDS-Metadaten; Discovery/Transport/Dissektor separat prüfen.') + print('Anzahlen sind Feldvorkommen, keine erfolgreichen Sitzungen. Keine Request/Reply-Zuordnung.') + return int(bad>0) +if __name__=='__main__':sys.exit(main()) diff --git a/nds/tools/probe.py b/nds/tools/probe.py new file mode 100644 index 0000000..b48cb3b --- /dev/null +++ b/nds/tools/probe.py @@ -0,0 +1,184 @@ +#!/usr/bin/env python3 +"""Read-only probe for MARS NDS lab: SLPv2 and NCP 104 Ping/Resolve. +No passwords, no authentication, no write verbs. Only explicit private IPv4 targets. +""" +import argparse +import ipaddress +import re +import secrets +import socket +import struct +import sys + +PRIVATE = tuple(ipaddress.ip_network(x) for x in ('10.0.0.0/8','172.16.0.0/12','192.168.0.0/16','127.0.0.0/8')) +TYPE = 'service:ndap.novell' +END = 0xffffffff + +def require(ok, message): + if not ok: + raise ValueError(message) + +def field(text): + data = text.encode('ascii') + return struct.pack('!H', len(data)) + data + +def slp_request(function, service, predicate, xid): + body = b''.join(field(x) for x in ('', service, 'DEFAULT', predicate, '')) + size = 16 + len(body) + return bytes((2, function)) + size.to_bytes(3, 'big') + b'\0'*5 + struct.pack('!HH', xid, 2) + b'en' + body + +def slp_parse(data, function, xid): + require(len(data)>=16 and data[0]==2 and data[1]==function and int.from_bytes(data[2:5],'big')==len(data), 'Ungültiger SLP-Header') + require(data[5:10]==b'\0'*5 and int.from_bytes(data[10:12],'big')==xid,'SLP-Flags, Erweiterungen oder Transaktions-ID nicht unterstützt') + pos=14+int.from_bytes(data[12:14],'big') + require(pos+2<=len(data),'SLP-Sprachfeld unvollständig') + def take(n): + nonlocal pos + require(pos+n<=len(data),'SLP-Antwort abgeschnitten') + result=data[pos:pos+n]; pos+=n; return result + def u16(): return int.from_bytes(take(2),'big') + def string(): return take(u16()).decode('ascii') + code=u16(); require(code==0,f'SLP Fehler {code}') + if function==2: + count=u16();require(count<=32,'Zu viele SLP-Einträge') + result=[] + for _ in range(count): + require(take(1)==b'\0','Ungültiger URL-Eintrag') + lifetime=u16(); url=string();require(take(1)==b'\0','Signierte URL nicht unterstützt') + if lifetime: result.append(url) + else: + result=string();require(take(1)==b'\0','Signierte Attribute nicht unterstützt') + require(pos==len(data),'Zusätzliche SLP-Daten') + return result + +def slp_probe(host, port, tree, timeout): + with socket.socket(socket.AF_INET,socket.SOCK_DGRAM) as sock: + sock.settimeout(timeout);sock.connect((host,port)) + xid=secrets.randbelow(65536) + sock.send(slp_request(1,TYPE,f'(svcname-ws={tree})',xid)) + urls=slp_parse(sock.recv(1401),2,xid) + url=f'{TYPE}:///{tree}.' + require(any(x.casefold()==url.casefold() for x in urls),'NDS-Baum nicht in SLP-Antwort enthalten') + xid=(xid+1)%65536 + sock.send(slp_request(6,url,'svcname-ws,svcaddr-ws,enabled-ws',xid)) + attrs=slp_parse(sock.recv(1401),7,xid) + expected=f'2-1-6-{ipaddress.IPv4Address(host).packed.hex()}020C0000000000000000' + require(expected.casefold() in attrs.casefold(),'SLP enthält nicht die erwartete NCP/TCP-Adresse Port 524') + require(f'(svcname-ws={tree}.)'.casefold() in attrs.casefold(),'SLP-Baumname weicht ab') + return url + +def recv_exact(sock,n): + data=bytearray() + while len(data)>8)+payload + sock.sendall(struct.pack('!IIII',0x446d6454,len(body)+16,1,4096)+body) + magic,size=struct.unpack('!II',recv_exact(sock,8));require(magic==0x744e6350 and 16<=size<=1408,'Ungültiger NCP/TCP-Header') + reply=recv_exact(sock,size-8) + require(reply[:2]==b'\x33\x33' and reply[2]==seq and reply[4]==1,'NCP Antwort passt nicht zur Anfrage') + result=reply[3]|reply[5]<<8 + require(kind==0x1111 or result==conn,'NCP Connection-ID weicht ab') + require(reply[6:8]==b'\0\0',f'NCP Completion/Status {reply[6]:02X}/{reply[7]:02X}') + return result,reply[8:] + +def parse_ping(data): + require(len(data)>=10,'NDS Ping-Antwort zu kurz') + flags,n=struct.unpack_from('=12 and int.from_bytes(data[:4],'little')==len(data)-4,'NDS Resolve-Fragment ungültig') + handle,code=struct.unpack_from('=(12 if first else 8),'NDAP-Fragment zu kurz') + size,handle=struct.unpack_from('0),'Ungültige NDAP-Fortsetzung') + result.extend(chunk);require(len(result)<=65536,'NDAP Antwort zu groß') + if handle==END:return bytes(result),seq + payload=b'\x68\x02'+struct.pack('I',oid)+struct.pack('1048576 or b'\0' in raw: raise ValueError('Serverkonfiguration ungültig oder zu groß') + servers=[]; volumes=[] + for line in raw.split(b'\n'): + m=re.match(rb'^[ \t]*(1|2)[ \t]+(.*)$',line.rstrip(b'\r')) + if not m: continue + fields=m[2].split(b'#',1)[0].split() + if m[1]==b'2': + if len(fields)!=1: raise ValueError('Abschnitt 2: genau ein Servername erforderlich') + servers.append(fields[0].decode('ascii').upper()) + else: + if len(fields)<2 or len(fields)>12: raise ValueError('Abschnitt 1: Volume und Pfad erforderlich') + volumes.append(fields[0].decode('ascii').upper()) + if len(servers)!=1: raise ValueError('Genau ein ASCII-Servername erforderlich') + validate_resources(servers[0],volumes) + return servers[0],volumes + +def validate_resources(server,volumes): + if not label(server,47): raise ValueError('Ungültiger ASCII-Servername') + if not isinstance(volumes,list) or not 1<=len(volumes)<=64 or not all(label(v,8) for v in volumes) or volumes.count('SYS')!=1 or len(set(volumes))!=len(volumes): + raise ValueError('Volumes: genau ein SYS, eindeutige ASCII-Namen bis 8 Zeichen, maximal 64') + +def plan(data, placements=False, resources=None): + t,o,u=data['tree'],data['organization'],data['units'] + if not label(t,32) or not label(o,47) or not isinstance(u,list) or len(u)>128: + raise ValueError('Baum/Organisation/OU-Liste ungültig') + if not all(isinstance(x,str) and len(x)<=191 and len(x.split('/'))<=8 and all(label(y,47) for y in x.split('/')) for x in u): + raise ValueError('OU-Pfad ungültig') + if len(set(u))!=len(u) or any('/' in x and x.rsplit('/',1)[0] not in u for x in u): + raise ValueError('OU doppelt oder Eltern-OU fehlt') + base='O='+o; paths={'':base}; rows=[('[Root]','Organization',o,base)] + for unit in sorted(u,key=lambda x:(x.count('/'),x)): + parent,_,name=unit.rpartition('/'); dn='OU='+name+'.'+paths[parent] + if len(dn)>255:raise ValueError('OU-DN zu lang') + paths[unit]=dn;rows.append((paths[parent],'Organizational Unit',name,dn)) + if placements: + p=data.get('placements',[]) + if not isinstance(p,list) or len(p)>1024:raise ValueError('Zuordnungsliste ungültig') + for item in p: + raw_name=item['name']; unit=item['unit']; typ=item['type'] + if not isinstance(raw_name,str) or not re.fullmatch(r'[A-Za-z0-9_-]{1,47}',raw_name):raise ValueError('Objektname muss ASCII sein') + name=raw_name.upper() + if not label(name,47) or unit not in paths or type(typ) is not int or typ not in (1,2): + raise ValueError('Nur ASCII-Zuordnungen A-Z, 0-9, _ und - im NDS-Labor') + dn='CN='+name+'.'+paths[unit] + if len(dn)>255:raise ValueError('Objekt-DN zu lang') + rows.append((paths[unit],'User' if typ==1 else 'Group',name,dn)) + if resources is not None: + server,volumes=resources + validate_resources(server,volumes) + parent=paths.get('SERVERS',base) + sd='CN='+server+'.'+parent + rows.append((parent,'NCP Server',server,sd)) + for volume in sorted(volumes): + name=server+'_'+volume + dn='CN='+name+'.'+parent + if len(name)>63 or len(dn)>255:raise ValueError('Volume-Objektname oder DN zu lang') + rows.append((parent,'Volume',name,dn)) + if len({r[3] for r in rows})!=len(rows):raise ValueError('NDS-Namenskollision') + return {'tree':t,'organization':o,'units':u},rows + +def publish(data, path, placements=False, resources=None): + config,rows=plan(data,placements,resources) + path=Path(path);fd,tmp=tempfile.mkstemp(prefix='.nds-',dir=path.parent);os.close(fd);os.unlink(tmp) + try: + if path.exists(): + with contextlib.closing(d.connect(path)) as old, contextlib.closing(sqlite3.connect(tmp)) as new: + old.backup(new) + else:d.initialize(tmp) + with contextlib.closing(d.connect(tmp)) as db: + db.execute('BEGIN IMMEDIATE') + db.execute('CREATE TABLE IF NOT EXISTS mars_nds_snapshot(id INTEGER PRIMARY KEY CHECK(id=1),tree TEXT NOT NULL,organization TEXT NOT NULL)') + db.execute('CREATE TABLE IF NOT EXISTS mars_nds_volume(id INTEGER PRIMARY KEY REFERENCES nds_entries(id) ON DELETE CASCADE, server_id INTEGER NOT NULL REFERENCES nds_entries(id) ON DELETE CASCADE, resource TEXT NOT NULL)') + db.execute('DELETE FROM mars_nds_volume') + prior=db.execute('SELECT tree FROM mars_nds_snapshot WHERE id=1').fetchone() + if prior and prior[0]!=config['tree']:raise ValueError('Baumname geändert: neue Datenbank erforderlich; alte vorher sichern') + wanted={r[3]:r[1] for r in rows};wanted['[Root]']='Root' + for i,dn,cls in db.execute('SELECT id,dn,cls FROM nds_entries ORDER BY length(dn) DESC').fetchall(): + if dn not in wanted or wanted[dn]!=cls:db.execute('DELETE FROM nds_entries WHERE id=?',(i,)) + for parent,cls,name,dn in rows: + if db.execute('SELECT id FROM nds_entries WHERE dn=?',(dn,)).fetchone():continue + pid,pudn,pcls=db.execute('SELECT id,udn,cls FROM nds_entries WHERE dn=?',(parent,)).fetchone() + udn=name if pcls=='Root' else name+'.'+pudn + db.execute('INSERT INTO nds_entries(parent,dn,udn,name,cls) VALUES(?,?,?,?,?)',(pid,dn,udn,name,cls)) + if resources is not None: + server,volumes=resources + server_dn=next(r[3] for r in rows if r[1]=='NCP Server') + sid=db.execute('SELECT id FROM nds_entries WHERE dn=?',(server_dn,)).fetchone()[0] + for volume in volumes: + dn=next(r[3] for r in rows if r[1]=='Volume' and r[2]==server+'_'+volume) + vid=db.execute('SELECT id FROM nds_entries WHERE dn=?',(dn,)).fetchone()[0] + db.execute('INSERT INTO mars_nds_volume VALUES(?,?,?)',(vid,sid,volume)) + db.execute('INSERT OR REPLACE INTO mars_nds_snapshot VALUES(1,?,?)',(config['tree'],config['organization'])) + db.commit() + if db.execute('PRAGMA integrity_check').fetchone()!=('ok',) or db.execute('PRAGMA foreign_key_check').fetchone() is not None:raise ValueError('SQLite-Integritätsfehler') + os.chmod(tmp,0o644) # public metadata only; nwconn may drop privileges + os.replace(tmp,path) + return config + finally: + if os.path.exists(tmp):os.unlink(tmp) + +def main(): + p=argparse.ArgumentParser(description=__doc__);p.add_argument('source',type=Path);p.add_argument('database',type=Path);p.add_argument('--public-placements',action='store_true');p.add_argument('--check',action='store_true');p.add_argument('--discovery',action='store_true',help='validate tree name for SAP/SLP lab discovery');p.add_argument('--server-config',type=Path,help='optional: import only server and volume names from nwserv.conf');a=p.parse_args() + try: + with a.source.open('rb') as f:raw=f.read(524289) + if len(raw)>524288:raise ValueError('Verzeichnisdatei zu groß') + data=json.loads(raw);resources=parse_resources(a.server_config) if a.server_config else None;config,rows=plan(data,a.public_placements,resources) + if a.discovery and config['tree'].endswith('_'):raise ValueError('Discovery: Baumname darf nicht auf Unterstrich enden (SAP-Padding)') + if not a.check:publish(data,a.database,a.public_placements,resources) + print(json.dumps(config,separators=(',',':'))) + except (OSError,ValueError,TypeError,KeyError,AttributeError,sqlite3.Error) as e:p.exit(1,'NDS: '+str(e)+'\n') +if __name__=='__main__':main() diff --git a/packaging/build-deb.py b/packaging/build-deb.py index 522e4ed..73182be 100644 --- a/packaging/build-deb.py +++ b/packaging/build-deb.py @@ -34,7 +34,7 @@ with tempfile.TemporaryDirectory(prefix='mars-deb-') as tmp: control=pathlib.Path(tmp)/'debian';control.mkdir();(control/'control').write_text('Source: mars-vme\nMaintainer: MARS VME \n\nPackage: mars-vme\nArchitecture: any\nDescription: MARS VME\n') elfs=[p for p in stage.rglob('*') if p.is_file() and p.read_bytes()[:4]==b'\x7fELF'] deps=run('dpkg-shlibdeps','-O',*[str(p) for p in elfs],cwd=tmp).strip().split('shlibs:Depends=',1)[1] - (deb/'control').write_text(f'Package: mars-vme\nVersion: 0.9.3-1\nArchitecture: {arch}\nMaintainer: MARS VME \nDepends: {deps}, python3, jq, iproute2, nftables, libpcap0.8t64, nodejs (>= 20), ffmpeg, pulseaudio, pulseaudio-utils, util-linux, zip, passwd\nRecommends: chromium | google-chrome-stable\nSection: net\nPriority: optional\nDescription: MARS VME server with web administration and Windows driver packages\n Host-native Ubuntu 26.04 build. Windows drivers are experimental.\n') + (deb/'control').write_text(f'Package: mars-vme\nVersion: 0.9.8-1\nArchitecture: {arch}\nMaintainer: MARS VME \nDepends: {deps}, python3, jq, iproute2, nftables, libpcap0.8t64, nodejs (>= 20), ffmpeg, pulseaudio, pulseaudio-utils, util-linux, zip, passwd\nRecommends: chromium | google-chrome-stable\nSection: net\nPriority: optional\nDescription: MARS VME server with web administration and Windows driver packages\n Host-native Ubuntu 26.04 build. Windows drivers are experimental.\n') (deb/'preinst').write_text('#!/bin/sh\nset -e\nbase=/var/lib/mars_nwe/bindery\nif [ -s "$base/nwobj.pag" ] && [ ! -f "$base/.mars-fixed-width-v1" ]; then\n echo \'Upgrade blocked: existing Bindery may use the incompatible old LP64 layout.\' >&2\n echo \'Back up configuration, Bindery and trustees; migrate/recreate and verify it before this upgrade.\' >&2\n echo \'Do not simply create the marker on an old database. See SERVER-64BIT-REPAIR.md.\' >&2\n exit 1\nfi\n') (deb/'postinst').write_text('''#!/bin/sh set -e @@ -71,7 +71,7 @@ fi ''') (deb/'conffiles').write_text(''.join('/'+str(f.relative_to(stage))+'\n' for f in (stage/'usr/local/etc').rglob('*') if f.is_file())) for name in ('preinst','postinst','prerm'):(deb/name).chmod(0o755) - for name in ('COPYING','LEGACY-BUILD.md','WINDOWS.md','DRIVER-RELEASE.md','LONG-NAMES.md','BROWSER.md','BUILD-RETROBROWSER.md','MARS-BROWSER-LIFECYCLE.md','SERVER-64BIT-REPAIR.md','RELEASE-0.9.3-SLP-DE.md','SQLITE-IDENTITIES.md','DIRECTORY-WIZARD.md','TOKENFIX.md'):copy(name,'usr/share/doc/mars-vme/'+name) - package=out/f'mars-vme_0.9.3-1_{arch}.deb';run('dpkg-deb','--root-owner-group','--build',str(stage),str(package)) + for name in ('COPYING','LEGACY-BUILD.md','WINDOWS.md','DRIVER-RELEASE.md','LONG-NAMES.md','BROWSER.md','BUILD-RETROBROWSER.md','MARS-BROWSER-LIFECYCLE.md','SERVER-64BIT-REPAIR.md','RELEASE-0.9.3-SLP-DE.md','SQLITE-IDENTITIES.md','DIRECTORY-WIZARD.md','TOKENFIX.md','RELEASE-0.9.8-NDS-WIRE-DE.md'):copy(name,'usr/share/doc/mars-vme/'+name) + package=out/f'mars-vme_0.9.8-1_{arch}.deb';run('dpkg-deb','--root-owner-group','--build',str(stage),str(package)) (out/'SHA256SUMS').write_text(''.join(hashlib.sha256(f.read_bytes()).hexdigest()+' '+f.name+'\n' for f in sorted(out.glob('*.deb')))) print(package) diff --git a/patch-upstream.sh b/patch-upstream.sh index abe4e43..cdcf8cf 100755 --- a/patch-upstream.sh +++ b/patch-upstream.sh @@ -93,3 +93,16 @@ foreach(t nwserv nwconn ncpserv nwclient nwbind nwrouted dbmtool ftrustee nwqcon endif() endforeach() CMAKE + +# Opt-in while native NDS compatibility is not certified. Discovery and read operations require separate runtime flags. +if [[ ${MARS_ENABLE_NDS_LAB:-0} == 1 ]]; then + python3 "$here/upstream-adapter/add-nds.py" "$root" + cp "$here/nds/server.c" "$root/src/mars_nds_server.c" + cp "$here/nds/server.h" "$root/src/mars_nds_server.h" + cp "$here/nds/fragger.c" "$here/nds/fragger.h" "$here/nds/nds_directory.c" "$here/nds/nds_directory.h" "$root/src/" + sed -i 's/#include "server.h"/#include "mars_nds_server.h"/' "$root/src/mars_nds_server.c" + cat >> "$root/src/CMakeLists.txt" <<'CMAKE' +target_sources(nwconn PRIVATE mars_nds_server.c fragger.c nds_directory.c) +target_link_libraries(nwconn PkgConfig::MARS_JSON PkgConfig::MARS_SQLITE) +CMAKE +fi diff --git a/releases/BUILD-0.9.8-1.json b/releases/BUILD-0.9.8-1.json new file mode 100644 index 0000000..056f04c --- /dev/null +++ b/releases/BUILD-0.9.8-1.json @@ -0,0 +1,46 @@ +{ + "version": "0.9.8-1", + "runtime_status": "Mac audio and XP connectivity unverified; no native 68k binary", + "existing_database": "LP64 Bindery requires reviewed migration; installation guarded", + "artifacts": { + "README.md": "1f7b55a15a71b75586dda97abdc31e926a3d867c321210fb643717d044c67c54", + "MARS_NWE-0.9.8-1-source.zip": "79e70cb5747e47bae0de428bc10d61305afb2a47664fd905456b06c94d538e3a", + "deb/mars-vme_0.9.8-1_amd64.deb": "ca5cc1f7ff12beb0fc90ddd0c58a7f44e2c14f6d99a964a5a73d9c5e951e88cf", + "browser/Open-Transport-1-3-1.iso.zip": "c46ac391b8fa95c1b2c294c1adfbad0d01ee462e07c013963825da8dbff0ada7", + "browser/linux-x11.zip": "ee6a05dcf9a9734691317b60b58fff2f3c7c5958b460d57bfad852103d7c5067", + "browser/browser-client-source.zip": "0ce99f5e5f9d746b040da6a8b7193d9d5083d98da697cf0ba293b61af0f83ef8", + "browser/windows-x86.zip": "d6637150ca1a5adcba3315f31141d59f9e4f617a773200b348bd34fde3c19b5e", + "browser/STATUS.json": "f38bc3b21a777b5e5afbb00f4633a2c1163d839099166ff0178b602c93e8f5cb", + "browser/SHA256SUMS": "cb0cb0b210422aca026baa064b6d881107a0bd6ca358303be1806e68f0faf029", + "browser/macclassic-powerpc.zip": "1eebab13c8bdd1dc3daea82c876278e706cf5166b00d067cbcc5023e24ff7efd", + "browser/macclassic-powerpc-source.zip": "2c4e9be21e224a6903d51003b0a89534f22dc08e7e2345842cb587a6396034e9", + "windows/manifest.json": "0f99d95b8f26e475797a5507bf3f4e38d36a4836d6f903ac0d7a5f26102b441b", + "windows/WINME.zip": "4cdb4ff3037c8c602a5d0077a82f0ac240b4d49864b1e23953703862368d00e9", + "windows/WINXP.zip": "15a5df3238ce74088b5c55b110215f971048fca0699fcb49371072a75e953d0a", + "windows/WIN2000.zip": "6ae38583a41c9e2b866ae52ac9e7c1f99a417db39da4c1ddf8b344a74d6ac3b1", + "windows/SHA256SUMS": "fc49c7405c11db641de418d9834e1d549b6b52402651a0adda975089c6faabe0", + "windows/WIN98.zip": "2cc15b77a8fdc82987d2979da0312060a5f897514fa0d97f45245f6695595fba", + "windows/WINNT40.zip": "f0a6b39c09678e50e7e721d99b1b2f92585d3e83d644b69cc1da853febded670", + "windows/WIN95.zip": "ecd3f7ea695171cd9b83a62f5aba56ea7ec5eced7f765a7d9a1a6b1fcbc138a6", + "dos/free-client32.zip": "42530a3ec5f6176c5062f4bcfb45035a37bd3695b6cdf73cc4121dc2361d49dc", + "dos/ms5-client32.zip": "2f50dc2100d310a52d5d21f1d3597f5af886c8b68a5efaa938583412c12c0079", + "dos/manifest.json": "0f947a469b6e9ea09e4e19b772ca11daea8fa0491c04e4d7bfef13f0dbc8ffe7", + "dos/free-netx.zip": "369a505fa2c882d320124feaa20d577cffd33bd90d9478e68d5439eb51e84669", + "dos/dr-vlm.zip": "e184ac5b227d06ab1c2faf33349936694a3e786a3584d08388dea6d50e7ce039", + "dos/dr-client32.zip": "067743b0cae17e0dc63bcd56be20fe2cdf53e5b8ccf9d03fc3ff500bf955e368", + "dos/ms6-vlm.zip": "cd3b276e4e2abd561cc9d157eb61c7b4eac6b8b751802ea36f7b7e5825d59561", + "dos/ms6-netx.zip": "896981463f95f709efde78c132383f86562d1226d1d023cfd2a4f204de6a3a8f", + "dos/pc-vlm.zip": "36f88f5d303a3cb217398179a0c6a9f700fec9090b6931acb3ea267f882a7abd", + "dos/ms5-netx.zip": "6f1d87295fe9fcaf7162b613a6dcd839c5e11f39117ee3258e59e1a01a421ed7", + "dos/free-vlm.zip": "7c5fb1cb41e5600aa6abe53371f7d2f9a4ddda86045de09ff7363caa462ad727", + "dos/pc-netx.zip": "fe205f579c4d127c364f211e77fe987c95014a6f4a8702df8f2fe1210a1890fc", + "dos/pc-client32.zip": "037aede627c48ea1c2898d7ad843dacb421330b4375a1dc65181ebe0adacac44", + "dos/ms7-client32.zip": "d21be03ea3b05117ebd7eac4d00358fc811eb47e09781db98810f56658968ee4", + "dos/ms7-vlm.zip": "b8b8e3fece59522d5efe831e2abf5f62b3ea7605f537c260d9748e915ad9b2ce", + "dos/dr-netx.zip": "6218d1e61ad17c5952606846558151cc698c6f77ce2e7ad0102f2fa5f9a1294a", + "dos/ms7-netx.zip": "d3ab71b3a2ff17eb6983d8b7247e5ec5c5fb380b2641d489b0acfc42160001d1", + "dos/ms5-vlm.zip": "ef709d9e3beec18851c2d8c6f3b7a03b79830f6e8658d178a46859e11b491571", + "dos/SHA256SUMS": "919ca21c4e5eba8b5e814547e184daa31d1050ab42f80cb4152e41d16b1835dc", + "dos/ms6-client32.zip": "8db275bb7e77108b6dfeb3f7538498dcb830f7f55f3dce2a7cad09a59c42950c" + } +} diff --git a/releases/MARS_NWE-0.9.8-1-source.zip b/releases/MARS_NWE-0.9.8-1-source.zip new file mode 100644 index 0000000..2708eb9 Binary files /dev/null and b/releases/MARS_NWE-0.9.8-1-source.zip differ diff --git a/releases/MARS_NWE-0.9.8-1.sha256 b/releases/MARS_NWE-0.9.8-1.sha256 new file mode 100644 index 0000000..4b557b9 --- /dev/null +++ b/releases/MARS_NWE-0.9.8-1.sha256 @@ -0,0 +1,2 @@ +fd05d252074b5bd0f5109e9ddff038b997548ee1b16194bb2641550b6941c5bd MARS_NWE-0.9.8-1.zip +79e70cb5747e47bae0de428bc10d61305afb2a47664fd905456b06c94d538e3a MARS_NWE-0.9.8-1-source.zip diff --git a/releases/MARS_NWE-0.9.8-1.zip b/releases/MARS_NWE-0.9.8-1.zip new file mode 100644 index 0000000..5597c64 Binary files /dev/null and b/releases/MARS_NWE-0.9.8-1.zip differ diff --git a/releases/README.md b/releases/README.md index 66fc372..870370c 100644 --- a/releases/README.md +++ b/releases/README.md @@ -1,8 +1,10 @@ -# MARS NWE 0.9.3-1 +# MARS NWE 0.9.8-1 -Integrated SLP/IP preview, directory wizard, SQLite identities and token fix. -Full bundle: MARS_NWE-0.9.3-1.zip; DEB: deb/mars-vme_0.9.3-1_amd64.deb. -Windows, DOS and Classic PPC browser packages are preserved from 0.9.1-3. -TCP/IP and SLP default to disabled. No native NDS login, no native 68k binary. -Read RELEASE-0.9.3-SLP-DE.md and SERVER-64BIT-REPAIR.md before installation. -Actual XP login and Mac audio remain unverified. +Integrated read-only NDS laboratory, with explicit runtime opt-in (disabled by default). +No native NDS login. Normal Bindery operation remains the recommended mode. +Simplified German configuration help and draft-only IPX / TCP+SLP presets. + +DEB: deb/mars-vme_0.9.8-1_amd64.deb +Bundle: MARS_NWE-0.9.8-1.zip +Existing Windows, DOS and PPC packages unchanged from 0.9.3-1. +Read INTEGRATION-0.9.8-1.md and RELEASE-0.9.8-NDS-WIRE-DE.md. diff --git a/releases/deb/SHA256SUMS b/releases/deb/SHA256SUMS index c716d2f..6a0d323 100644 --- a/releases/deb/SHA256SUMS +++ b/releases/deb/SHA256SUMS @@ -6,3 +6,4 @@ b4799e4589626a01a9aa5138a81c40120f44cb9a2aa5f1fb78f5ca4821034231 mars-vme_0.8.4 36147f7f6e8562dd5bbd9dbdd2acc171d02eca2a248e05be4f9a0a24311f0e93 mars-vme_0.9.1-2_amd64.deb 831b2dee671f776d3e83670cbba0e4021acc67f70afd72c1768c2f50e99131c4 mars-vme_0.9.1-3_amd64.deb 50ade66b63492f148bebd5cc7cd680fb9b0acb26e4888612cec41c4f02500eed mars-vme_0.9.3-1_amd64.deb +ca5cc1f7ff12beb0fc90ddd0c58a7f44e2c14f6d99a964a5a73d9c5e951e88cf mars-vme_0.9.8-1_amd64.deb diff --git a/releases/deb/mars-vme_0.9.8-1_amd64.deb b/releases/deb/mars-vme_0.9.8-1_amd64.deb new file mode 100644 index 0000000..2ad2726 Binary files /dev/null and b/releases/deb/mars-vme_0.9.8-1_amd64.deb differ diff --git a/src/broker.c b/src/broker.c index 9b5fd0d..6fb8dec 100644 --- a/src/broker.c +++ b/src/broker.c @@ -2,6 +2,7 @@ #define _GNU_SOURCE #include "wire.h" #include "ncp_ip.h" +#include "slp.h" #include "gateway.h" #include "pcap_dyn.h" #include @@ -66,6 +67,20 @@ static void outbound(int idx,struct msg *m){struct iface *p=primary();if(!p||!cl if(private_data(m->data,m->len)){dropped++;return;}uint8_t packet[IPX_MAX],mac[6];if(!dst.sipx_network||dst.sipx_network==UINT32_MAX){if(!bc){dropped++;return;}for(int i=0;idata,m->len);if(n>0)transmit(&ifs[i],d.sipx_node,packet,n);}return;} struct iface *out=route_for(dst.sipx_network,dst.sipx_node,mac);if(!out){dropped++;return;}/* RIP/SAP must announce from the external network, NCP retains its internal identity. */if(ntohs(src.sipx_port)==0x453||ntohs(src.sipx_port)==0x452)addr_for(&src,out,clients[idx].port);int n=ipx_make(packet,sizeof packet,&src,&dst,m->data,m->len);if(n>0)transmit(out,mac,packet,n);} static void inbound(struct iface *in,const uint8_t *frame,size_t size){const uint8_t *p;size_t n;int kind;if(frame_decode(frame,size,&kind,&p,&n)<0||kind!=in->kind)return;if(memcmp(frame,in->mac,6)&&!isbc(frame))return;if(!memcmp(frame+6,in->mac,6))return;struct sockaddr_ipx src,dst;read_addr(&dst,p+6,p[5]);read_addr(&src,p+18,p[5]);if(!src.sipx_network)src.sipx_network=in->net;if(!dst.sipx_network)dst.sipx_network=in->net;if(isbc(src.sipx_node)||iszero(src.sipx_node)||!src.sipx_port||!dst.sipx_port)return;if(gw_reserved(ntohs(dst.sipx_port))&&(dst.sipx_network==in->net||dst.sipx_network==UINT32_MAX)&&(!memcmp(dst.sipx_node,in->mac,6)||isbc(dst.sipx_node))){if(p[4]==0)gw_input(in->net,frame+6,frame,&src,&dst,p+30,n-30,gw_transmit);return;}if(private_data(p+30,n-30))return;struct iface *s=by_net(src.sipx_network);if(s&&(s->special==IPX_INTERNAL||!memcmp(s->mac,src.sipx_node,6)))return;rx_frames[kind]++;observe_peer(&src);if(ntohs(src.sipx_port)==0x452)observe_sap(p+30,n-30); + /* Explicit NDS-only SAP queries; original SAP handler still owns other types. + * Answer only directly attached peers and only after a local file-service advertisement. */ + if(!offline&&p[5]==4&&p[4]==0&&ntohs(dst.sipx_port)==0x452&&src.sipx_network==in->net&& + !memcmp(src.sipx_node,frame+6,6)&&(dst.sipx_network==in->net||dst.sipx_network==UINT32_MAX)&& + (!memcmp(dst.sipx_node,in->mac,6)||isbc(dst.sipx_node))){ + struct iface *server=primary();const char *tree=nds_discovery_tree(); + if(tree&&server&&server->special==IPX_INTERNAL&&port_owner(0x451)>=0&&ncp_ip_local_ready(server->net)){ + uint8_t reply[66],packet[96];size_t len=nds_sap_reply(p+30,n-30,reply,sizeof reply,tree,server->net,server->mac); + if(len){static time_t window;static unsigned sent;time_t t=time(NULL);if(t!=window){window=t;sent=0;} + if(sent<40){sent++;struct sockaddr_ipx from;addr_for(&from,in,0x452);src.sipx_type=4;int k=ipx_make(packet,sizeof packet,&from,&src,reply,len);if(k>0&&transmit(in,frame+6,packet,k)==0){observe_sap(reply,len);ncp_ip_nds_sap_sent();}} + return; + } + } + } struct iface *d=by_net(dst.sipx_network);if(d&&(!memcmp(d->mac,dst.sipx_node,6)||(d==in&&isbc(dst.sipx_node)))){deliver(ntohs(dst.sipx_port),&src,p+30,n-30);return;} if(!forwarding||isbc(dst.sipx_node)||isbc(frame)||p[4]>=15)return; uint8_t mac[6],buf[IPX_MAX];struct iface *out=route_for(dst.sipx_network,dst.sipx_node,mac);if(!out||out==in)return;memcpy(buf,p,n);buf[4]++;write_addr(buf+18,&src);write_addr(buf+6,&dst);transmit(out,mac,buf,n);} @@ -74,6 +89,7 @@ static void capture(struct iface *in){if(!in->pc)return;for(int j=0;j<64;j++){st static int ip_dispatch(const struct sockaddr_ipx *src,uint16_t dst,const uint8_t *p,size_t n){int i=port_owner(dst);if(i<0)return -1;struct msg m={.op=M_DATA,.len=n,.addr=*src};memcpy(m.data,p,n);int rc=emit(clients[i].fd,&m);if(!rc&&dst==0x451)ncp_ip_observe_request(p,n,1);return rc;} static void on_signal(int s){(void)s;stop=1;} int main(int argc,char **argv){const char *ip_config=NCP_IP_CONFIG;unsigned ip_port=NCP_TCP_PORT;for(int i=1;i=0){f[count]=(struct pollfd){clients[i].fd,POLLIN,0};type[count]=1;index[count++]=i;}for(int i=0;i=0){f[count]=(struct pollfd){ifs[i].fd,POLLIN,0};type[count]=2;index[count++]=i;}int r=poll(f,count,20);if(r<0){if(errno==EINTR)continue;perror("poll");break;} /* Process capture before commands which may close/reopen interfaces. */for(int k=1;k #include +#include +#include #include #include #include @@ -21,7 +23,22 @@ static struct session sessions[SLOTS];static int listener=-1,enabled;static uint static unsigned long nds_ipx,nds_tcp,nds_ping,nds_frag,nds_other; /* Metadata only; never store credentials or request payloads. */ void ncp_ip_observe_request(const uint8_t*p,size_t n,int tcp){if(n<8||get16(p)!=0x2222||p[6]!=104)return;if(tcp)nds_tcp++;else nds_ipx++;if(p[7]==1)nds_ping++;else if(p[7]==2)nds_frag++;else nds_other++;} -static int discovery;static char local_name[49];static time_t local_seen;static uint32_t local_net,active_net; +static int discovery;static unsigned long sap_nds_replies;static const char *nds_discovery_status="disabled"; +void ncp_ip_nds_sap_sent(void){sap_nds_replies++;} +/* Called once at broker startup. Config/DB must agree; never advertise an absent snapshot. */ +void ncp_ip_nds_discovery_init(void){ + const char *flag=getenv("MARS_NDS_LAB"),*tree=getenv("MARS_NDS_DISCOVERY_TREE"),*raw=getenv("MARS_NDS_LAB_CONFIG"),*path=getenv("MARS_NDS_LAB_DB"); + nds_discovery_set_tree(NULL);nds_discovery_status="disabled";if(!tree)return;nds_discovery_status="invalid or missing NDS lab snapshot"; + struct stat st; if(!flag||strcmp(flag,"1")||!nds_tree_valid(tree)||!raw||strlen(raw)>32768||!path||lstat(path,&st)||!S_ISREG(st.st_mode)||st.st_uid!=geteuid()||(st.st_mode&022))return; + json_object *cfg=json_tokener_parse(raw),*t=NULL,*o=NULL;sqlite3 *db=NULL;sqlite3_stmt *stmt=NULL; + if(!cfg||!json_object_is_type(cfg,json_type_object)||!json_object_object_get_ex(cfg,"tree",&t)||!json_object_is_type(t,json_type_string)||strcmp(json_object_get_string(t),tree)||!json_object_object_get_ex(cfg,"organization",&o)||!json_object_is_type(o,json_type_string))goto done; + if(sqlite3_open_v2(path,&db,SQLITE_OPEN_READONLY,NULL)!=SQLITE_OK)goto done; + if(sqlite3_exec(db,"PRAGMA query_only=ON; PRAGMA trusted_schema=OFF;",NULL,NULL,NULL)!=SQLITE_OK)goto done; + if(sqlite3_prepare_v2(db,"SELECT tree,organization FROM mars_nds_snapshot WHERE id=1 AND EXISTS(SELECT 1 FROM nds_meta WHERE id=1 AND version=1)",-1,&stmt,NULL)!=SQLITE_OK||sqlite3_step(stmt)!=SQLITE_ROW)goto done; + const unsigned char *dt=sqlite3_column_text(stmt,0),*dorg=sqlite3_column_text(stmt,1);if(dt&&dorg&&!strcmp((const char*)dt,tree)&&!strcmp((const char*)dorg,json_object_get_string(o))){nds_discovery_set_tree(tree);nds_discovery_status="configured (experimental, no login)";} + done:sqlite3_finalize(stmt);sqlite3_close(db);if(cfg)json_object_put(cfg); +} +static char local_name[49];static time_t local_seen;static uint32_t local_net,active_net; static time_t now(void); void ncp_ip_local_sap(const uint8_t*p,size_t n,uint32_t net,const uint8_t*node){ if(n<2||(n-2)%64||(get16(p)!=2&&get16(p)!=4))return; @@ -33,7 +50,8 @@ void ncp_ip_local_sap(const uint8_t*p,size_t n,uint32_t net,const uint8_t*node){ } static time_t now(void){struct timespec t;clock_gettime(CLOCK_MONOTONIC,&t);return t.tv_sec;} -static void report(void){unsigned n=0;for(int i=0;ifd>=0)close(s->fd);memset(s,0,sizeof *s);s->fd=-1;} void ncp_ip_server_lost(void){if(listener>=0){close(listener);listener=-1;}slp_stop();local_seen=0;local_name[0]=0;for(int i=0;iseq+1),(uint8_t)s->conn,s->task,(uint8_t)(s->conn>>8),0};if(!s->allocated||!dispatch)return -1;s->seq=p[2];s->kind=0x5555;s->pending=1;s->until=now()+5;return dispatch(&s->src,0x451,p,sizeof p);} diff --git a/src/ncp_ip.h b/src/ncp_ip.h index af034d0..9f14dfd 100644 --- a/src/ncp_ip.h +++ b/src/ncp_ip.h @@ -16,5 +16,8 @@ int ncp_ip_reply(const struct sockaddr_ipx *,uint16_t,const uint8_t *,size_t); void ncp_ip_stop(void); void ncp_ip_server_lost(void); void ncp_ip_observe_request(const uint8_t *,size_t,int); +void ncp_ip_nds_discovery_init(void); +void ncp_ip_nds_sap_sent(void); +int ncp_ip_local_ready(uint32_t net); void ncp_ip_local_sap(const uint8_t *,size_t,uint32_t,const uint8_t *); #endif diff --git a/src/slp.c b/src/slp.c index 027fa9a..9268f40 100644 --- a/src/slp.c +++ b/src/slp.c @@ -1,11 +1,12 @@ /* SPDX-License-Identifier: GPL-2.0-or-later */ /* RFC 2608 subset. Novell service:bindery.novell URL/attributes per TID 10027163. - * No directory agent, NDS, registration, SLPv1, TCP or authentication claims. */ + * Optional read-only NDAP lab discovery. No directory agent, registration, SLPv1, TCP or authentication claims. */ #define _GNU_SOURCE #include "slp.h" #include "wire.h" #include #include +#include #include #include #include @@ -14,6 +15,17 @@ #include #define SLP_MAX 1400 #define TYPE "service:bindery.novell" +#define NDAP "service:ndap.novell" +int nds_tree_valid(const char *s){return s&&slp_name_valid(s)&&strlen(s)<=32&&s[strlen(s)-1]!='_';} +static char discovery_tree[33]; +void nds_discovery_set_tree(const char *tree){discovery_tree[0]=0;if(nds_tree_valid(tree))memcpy(discovery_tree,tree,strlen(tree)+1);} +const char *nds_discovery_tree(void){return discovery_tree[0]?discovery_tree:NULL;} +/* SAP name: 32-byte underscore-padded tree, 16-character local server discriminator. */ +size_t nds_sap_reply(const uint8_t *in,size_t n,uint8_t *out,size_t cap,const char *tree,uint32_t net,const uint8_t *node){ + if(!in||!out||!node||!net||net==UINT32_MAX||iszero(node)||isbc(node)||!nds_tree_valid(tree)||n!=4||cap<66||get16(in+2)!=0x0278)return 0; + unsigned op=get16(in);if(op!=1&&op!=3)return 0; + memset(out,0,66);put16(out,op==1?2:4);put16(out+2,0x0278);memset(out+4,'_',32);memcpy(out+4,tree,strlen(tree));char suffix[17];snprintf(suffix,sizeof suffix,"%08X%02X%02X%02X%02X",ntohl(net),node[2],node[3],node[4],node[5]);memcpy(out+36,suffix,16);memcpy(out+52,&net,4);memcpy(out+56,node,6);put16(out+62,0x451);put16(out+64,1);return 66; +} struct span {const uint8_t *p;size_t n;}; static int field(const uint8_t **p,size_t *n,struct span *s){if(*n<2)return -1;size_t k=get16(*p);*p+=2;*n-=2;if(k>*n)return -1;s->p=*p;s->n=k;*p+=k;*n-=k;return 0;} static int eq(struct span s,const char *t){return strlen(t)==s.n&&!strncasecmp((const char*)s.p,t,s.n);} @@ -24,19 +36,22 @@ int slp_name_valid(const char *s){if(!s||!*s||strlen(s)>48)return 0;for(;*s;s++) static int atom(struct span s,const char*name){const char *prefix="(svcname-ws=";size_t k=strlen(prefix);if(eq(s,"(enabled-ws=true)"))return 1;if(s.n<=k||strncasecmp((const char*)s.p,prefix,k)||s.p[s.n-1]!=')')return 0;s.p+=k;s.n-=k+1;if(s.n&&s.p[s.n-1]=='*'){s.n--;return s.n<=strlen(name)&&!strncasecmp((const char*)s.p,name,s.n);}return eq(s,name);} static int predicate(struct span s,const char*name){if(!s.n)return 1;if(s.n>4&&s.p[0]=='('&&s.p[1]=='&'&&s.p[s.n-1]==')'){s.p+=2;s.n-=3;unsigned count=0;while(s.n){size_t k=0;while(k0;}return atom(s,name);} static int addstr(uint8_t **p,size_t *cap,const char*s){size_t n=strlen(s);if(n>65535||*capSLP_MAX||cap<18||in[0]!=2||(in[1]!=1&&in[1]!=6)||((uint32_t)in[2]<<16|get16(in+3))!=n||in[7]||in[8]||in[9]||(get16(in+5)&~0x2000u))return 0; size_t lang=get16(in+12);if(!lang||lang>32||14+lang>n||14+lang+5>cap)return 0;for(size_t i=0;i126)return 0; multicast=multicast||(in[5]&0x20);const uint8_t *p=in+14+lang;size_t left=n-14-lang;struct span pr,service,scope,filter,spi; if(field(&p,&left,&pr)||field(&p,&left,&service)||field(&p,&left,&scope)||field(&p,&left,&filter)||field(&p,&left,&spi)||left||spi.n)return 0; char ip[INET_ADDRSTRLEN],url[96],attrs[384],addrattr[96],nm[96];if(!inet_ntop(AF_INET,&address,ip,sizeof ip)||list_has(pr,ip))return 0; - snprintf(url,sizeof url,TYPE ":///%s",name);const uint8_t *a=(const uint8_t*)&address; - snprintf(addrattr,sizeof addrattr,"(svcaddr-ws=2-1-6-%02X%02X%02X%02X020C0000000000000000)",a[0],a[1],a[2],a[3]);snprintf(nm,sizeof nm,"(svcname-ws=%s)",name); + const char *type=TYPE;char root[34],ndurl[96];int nds=0; + if(nds_tree_valid(tree)){snprintf(root,sizeof root,"%s.",tree);snprintf(ndurl,sizeof ndurl,NDAP ":///%s",root);if(eq(service,NDAP)||eq(service,ndurl)){type=NDAP;name=root;nds=1;}} + snprintf(url,sizeof url,"%s:///%s",type,name);const uint8_t *a=(const uint8_t*)&address; + snprintf(addrattr,sizeof addrattr,"(svcaddr-ws=%s-%02X%02X%02X%02X020C0000000000000000)","2-1-6",a[0],a[1],a[2],a[3]);snprintf(nm,sizeof nm,"(svcname-ws=%s)",name); int match=list_has(scope,"DEFAULT");size_t h=14+lang;memset(out,0,h);out[0]=2;out[1]=in[1]==1?2:7;memcpy(out+10,in+10,4+lang);uint8_t *w=out+h;cap-=h;put16(w,0);w+=2;cap-=2; - if(in[1]==1){match=match&&eq(service,TYPE)&&predicate(filter,name);if(!match&&multicast)return 0;if(cap<2)return 0;put16(w,match?1:0);w+=2;cap-=2;if(match){if(cap<6)return 0;*w++=0;put16(w,120);w+=2;cap-=3;if(addstr(&w,&cap,url)||!cap)return 0;*w++=0;}} - else {match=match&&(eq(service,url)||eq(service,TYPE));if(!match&&multicast)return 0;attrs[0]=0;if(match){const char *tags[]={"svcname-ws","svcaddr-ws","enabled-ws"};const char *vals[]={nm,addrattr,"(enabled-ws=true)"};for(int i=0;i<3;i++)if(!filter.n||list_has(filter,tags[i])){if(*attrs)strcat(attrs,",");strcat(attrs,vals[i]);}}if(addstr(&w,&cap,attrs)||!cap)return 0;*w++=0;} + if(in[1]==1){match=match&&eq(service,type)&&(predicate(filter,name)||(nds&&predicate(filter,tree)));if(!match&&multicast)return 0;if(cap<2)return 0;put16(w,match?1:0);w+=2;cap-=2;if(match){if(cap<6)return 0;*w++=0;put16(w,120);w+=2;cap-=3;if(addstr(&w,&cap,url)||!cap)return 0;*w++=0;}} + else {match=match&&(eq(service,url)||eq(service,type));if(!match&&multicast)return 0;attrs[0]=0;if(match){const char *tags[]={"svcname-ws","svcaddr-ws","enabled-ws"};const char *vals[]={nm,addrattr,"(enabled-ws=true)"};for(int i=0;i<3;i++)if(!filter.n||list_has(filter,tags[i])){if(*attrs)strcat(attrs,",");strcat(attrs,vals[i]);}}if(addstr(&w,&cap,attrs)||!cap)return 0;*w++=0;} size_t len=(size_t)(w-out);out[2]=len>>16;put16(out+3,len);return len; } +size_t slp_response(const uint8_t *in,size_t n,uint8_t *out,size_t cap,const char *name,uint32_t address,int multicast){return slp_response_tree(in,n,out,cap,name,address,multicast,NULL);} static int fd=-1,ifindex;static uint32_t bound;static const char *status="disabled";static unsigned long replies;static time_t attempt,window;static unsigned sent; const char *slp_status(void){return status;}unsigned long slp_replies(void){return replies;} void slp_stop(void){if(fd>=0)close(fd);fd=-1;bound=0;status="disabled";} @@ -44,13 +59,13 @@ static int open_slp(uint32_t address,unsigned port){struct ifaddrs *ifs;if(getif int s=socket(AF_INET,SOCK_DGRAM|SOCK_NONBLOCK|SOCK_CLOEXEC,0);if(s<0)return -1;int one=1,zero=0;struct sockaddr_in local={.sin_family=AF_INET,.sin_port=htons(port)};struct ip_mreqn m={.imr_address.s_addr=address,.imr_ifindex=ifindex};inet_pton(AF_INET,"239.255.255.253",&m.imr_multiaddr); if(setsockopt(s,IPPROTO_IP,IP_PKTINFO,&one,sizeof one)||setsockopt(s,IPPROTO_IP,IP_MULTICAST_ALL,&zero,sizeof zero)||bind(s,(void*)&local,sizeof local)||setsockopt(s,IPPROTO_IP,IP_ADD_MEMBERSHIP,&m,sizeof m)){close(s);return -1;}fd=s;bound=address;return 0; } -void slp_tick(int ready,uint32_t address,uint32_t mask,const char *name,unsigned port){time_t t=time(NULL);if(!ready||!slp_name_valid(name)){slp_stop();status="waiting for local server name / NCP";return;}if(bound&&bound!=address)slp_stop();if(fd<0){if(attempt==t)return;attempt=t;if(open_slp(address,port)){status="UDP bind/join failed";return;}status="SLPv2 UDP active (bindery only)";} +void slp_tick(int ready,uint32_t address,uint32_t mask,const char *name,unsigned port){time_t t=time(NULL);if(!ready||!slp_name_valid(name)){slp_stop();status="waiting for local server name / NCP";return;}if(bound&&bound!=address)slp_stop();if(fd<0){if(attempt==t)return;attempt=t;if(open_slp(address,port)){status="UDP bind/join failed";return;}status=nds_discovery_tree()?"SLPv2 UDP active (bindery + NDAP lab)":"SLPv2 UDP active (bindery only)";} if(t!=window){window=t;sent=0;}uint32_t group;inet_pton(AF_INET,"239.255.255.253",&group); for(int i=0;i<16;i++){uint8_t buf[SLP_MAX],out[SLP_MAX];struct sockaddr_in peer={0};struct iovec vec={buf,sizeof buf};union {struct cmsghdr align;char buf[CMSG_SPACE(sizeof(struct in_pktinfo))];} control;struct msghdr msg={.msg_name=&peer,.msg_namelen=sizeof peer,.msg_iov=&vec,.msg_iovlen=1,.msg_control=control.buf,.msg_controllen=sizeof control.buf};ssize_t n=recvmsg(fd,&msg,MSG_DONTWAIT);if(n<0)break;if(msg.msg_flags&(MSG_TRUNC|MSG_CTRUNC)||peer.sin_family!=AF_INET||!peer.sin_port||sent>=40)continue; uint32_t remote=ntohl(peer.sin_addr.s_addr);if(!((remote>>24)==10||(remote>>20)==0xac1||(remote>>16)==0xc0a8||(remote>>24)==127)||(peer.sin_addr.s_addr&mask)!=(address&mask))continue; struct in_pktinfo info={0};for(struct cmsghdr*c=CMSG_FIRSTHDR(&msg);c;c=CMSG_NXTHDR(&msg,c))if(c->cmsg_level==IPPROTO_IP&&c->cmsg_type==IP_PKTINFO&&c->cmsg_len>=CMSG_LEN(sizeof info))memcpy(&info,CMSG_DATA(c),sizeof info); if(info.ipi_ifindex!=ifindex||(info.ipi_addr.s_addr!=address&&info.ipi_addr.s_addr!=group))continue; - size_t len=slp_response(buf,n,out,sizeof out,name,address,info.ipi_addr.s_addr==group);if(!len)continue; + size_t len=slp_response_tree(buf,n,out,sizeof out,name,address,info.ipi_addr.s_addr==group,nds_discovery_tree());if(!len)continue; vec.iov_base=out;vec.iov_len=len;memset(control.buf,0,sizeof control.buf);msg.msg_controllen=sizeof control.buf;struct cmsghdr*c=CMSG_FIRSTHDR(&msg);c->cmsg_level=IPPROTO_IP;c->cmsg_type=IP_PKTINFO;c->cmsg_len=CMSG_LEN(sizeof info);memset(&info,0,sizeof info);info.ipi_ifindex=ifindex;info.ipi_spec_dst.s_addr=address;memcpy(CMSG_DATA(c),&info,sizeof info);sent++;if(sendmsg(fd,&msg,MSG_DONTWAIT)==(ssize_t)len)replies++; } } diff --git a/src/slp.h b/src/slp.h index 89a2fc3..eff8a53 100644 --- a/src/slp.h +++ b/src/slp.h @@ -6,6 +6,11 @@ /* Limited SLPv2 service agent: one locally observed bindery service, DEFAULT scope. */ int slp_name_valid(const char *name); size_t slp_response(const uint8_t *in,size_t n,uint8_t *out,size_t cap,const char *name,uint32_t address,int multicast); +int nds_tree_valid(const char *tree); +void nds_discovery_set_tree(const char *tree); +const char *nds_discovery_tree(void); +size_t nds_sap_reply(const uint8_t *,size_t,uint8_t *,size_t,const char *,uint32_t,const uint8_t *); +size_t slp_response_tree(const uint8_t *,size_t,uint8_t *,size_t,const char *,uint32_t,int,const char *); void slp_tick(int ready,uint32_t address,uint32_t mask,const char *name,unsigned port); void slp_stop(void); const char *slp_status(void); diff --git a/tests/run_ncp_ip.sh b/tests/run_ncp_ip.sh index 57e84a5..321c5fb 100755 --- a/tests/run_ncp_ip.sh +++ b/tests/run_ncp_ip.sh @@ -4,8 +4,15 @@ set -euo pipefail cd "$(dirname "$0")/.." [[ $EUID == 0 ]] || { echo 'Use sudo make check-ncp-ip-integration on an isolated test host'; exit 1; } [[ ! -S /run/mars-pcap/transport.sock ]] || { echo 'Existing MARS broker; test aborted'; exit 1; } -config=$(mktemp); chmod 600 "$config"; printf '{"enabled":true,"address":"127.0.0.1","slp":true}' > "$config" +work=$(mktemp -d); config=$work/ip.json; touch "$config"; chmod 600 "$config"; printf '{"enabled":true,"address":"127.0.0.1","slp":true}' > "$config" +unset MARS_NDS_LAB MARS_NDS_LAB_CONFIG MARS_NDS_LAB_DB MARS_NDS_DISCOVERY_TREE MARS_TEST_NDS_DISCOVERY MARS_TEST_INVALID_NDS +if [[ ${1:-} == --nds || ${1:-} == --invalid-nds ]]; then + printf '{"tree":"MARS_TREE","organization":"HOME","units":["USERS"]}' > "$work/tree.json" + export MARS_NDS_LAB=1 MARS_NDS_LAB_DB="$work/directory.sqlite3" MARS_NDS_DISCOVERY_TREE=MARS_TREE MARS_TEST_NDS_DISCOVERY=1 + MARS_NDS_LAB_CONFIG=$(python3 nds/tools/snapshot.py "$work/tree.json" "$MARS_NDS_LAB_DB"); export MARS_NDS_LAB_CONFIG + if [[ ${1:-} == --invalid-nds ]]; then unset MARS_TEST_NDS_DISCOVERY; export MARS_TEST_INVALID_NDS=1; rm -f "$MARS_NDS_LAB_DB"; fi +fi ./build/mars-pcapd --offline-test --test-ip-config "$config" & pid=$! -trap 'kill "$pid" 2>/dev/null || true; wait "$pid" 2>/dev/null || true; rm -f "$config"' EXIT +trap 'kill "$pid" 2>/dev/null || true; wait "$pid" 2>/dev/null || true; rm -rf -- "$work"' EXIT for i in $(seq 1 50); do [[ -S /run/mars-pcap/transport.sock ]] && break; sleep .1; done ./build/test-ncp-ip diff --git a/tests/test_identity_wizard_browser.py b/tests/test_identity_wizard_browser.py index c44cee3..95e5baa 100644 --- a/tests/test_identity_wizard_browser.py +++ b/tests/test_identity_wizard_browser.py @@ -10,6 +10,9 @@ config=dict(version=1,tree='MARS_TREE',organization='HOME',units=['USERS','GROUP rev='r1'; fail=False; created=0; errors=[] def fixture(source,path,body): global config,rev,created + if path=='/api/ncp-ip': + assert not body, 'Presets must not save automatically' + return dict(config={'enabled':False,'address':'192.168.1.10','slp':False},addresses=[{'address':'192.168.1.10','interface':'eth0'}],runtime='disabled',revision='ip1',valid=True) if path=='/api/state':return state if path=='/api/status':return {'mars-nwe-pcap.service':'ActiveState=active','mars-pcapd.service':'ActiveState=active'} if path=='/api/directory': @@ -31,9 +34,13 @@ with sync_playwright() as p: page.evaluate("()=>{window.fetch=async(path,opts)=>{const d=await window.fixture(path,opts?.body?JSON.parse(opts.body):null);return {ok:!d.error,status:d.error?503:200,json:()=>d}};}") html=(root/'index.html').read_text().replace('','').replace('','');page.set_content(html);page.add_script_tag(content=(root/'app.js').read_text());page.wait_for_function("document.getElementById('serverStatus').textContent==='active'") page.locator('#directoryOpen').click();page.wait_for_function("document.getElementById('directoryChecks').textContent.includes('Betriebsmodus')") - assert 'Noch nicht verfügbar' in page.locator('#directoryChecks').inner_text() + assert 'Keine native NDS-Anmeldung' in page.locator('#directoryChecks').inner_text() page.locator('#directoryNext').click();page.locator('#directoryTree').fill('INVALID NAME');page.locator('#directoryNext').click();assert 'zulässige' in page.locator('#directoryMessage').inner_text();page.locator('#directoryTree').fill('MARS_TREE');page.locator('#directoryNext').click();page.locator('#directoryAuto').click();page.locator('#directoryNext').click();assert 'Tree / Baum: leer lassen' in page.locator('#directoryClient').input_value();page.locator('#directorySave').click();page.wait_for_function("document.getElementById('directoryMessage').textContent.includes('gespeichert')");assert config['placements'] # A failed reload must not permit a save of stale data. fail=True;page.locator('#directoryBack').click();page.locator('#directoryBack').click();page.locator('#directoryBack').click();page.locator('#directoryReload').click();page.wait_for_function("document.getElementById('directoryMessage').textContent.includes('Bitte erneut laden')");assert page.locator('#directoryNext').is_disabled();fail=False;page.locator('#directoryReload').click();page.wait_for_function("!document.getElementById('directoryNext').disabled");page.locator('#directoryBindery').click();page.wait_for_function("document.getElementById('bindSummary').textContent.includes('2 Objekte')") page.locator('#createUser').click();page.locator('[name=name]').fill('alice');page.get_by_role('button',name='Sicheres Kennwort erzeugen').click();pw=page.locator('[name=password]').input_value();assert len(pw)==20 and all(c in '0123456789ABCDEF' for c in pw);page.locator('#actionSubmit').click();page.wait_for_function("document.getElementById('bindSummary').textContent.includes('3 Objekte')");assert created==1;assert page.locator('[name=password]').input_value()=='' + page.evaluate("()=>document.querySelectorAll('dialog[open]').forEach(d=>d.close())") + page.locator('#ncpIpOpen').click();page.wait_for_function("!document.getElementById('ncpPresetIp').disabled") + page.locator('#ncpPresetIp').click();assert page.locator('#ncpIpEnabled').is_checked();assert page.locator('#ncpIpSlp').is_checked();assert page.locator('#ncpIpRestart').is_disabled() + page.locator('#ncpPresetIpx').click();assert not page.locator('#ncpIpEnabled').is_checked();assert not page.locator('#ncpIpSlp').is_checked() assert not errors,errors;print('PASS Chromium mobile 390x844: wizard, mode disclosure, invalid input, auto assignment, save, failed reload, recovery, generated password, user creation, cleared password (mock API)');b.close() diff --git a/tests/test_ncp_ip.c b/tests/test_ncp_ip.c index cfefc61..7e5a750 100644 --- a/tests/test_ncp_ip.c +++ b/tests/test_ncp_ip.c @@ -12,6 +12,7 @@ #include #include #include +#include static int ctl,server,reply_fd; static int ipc_socket(unsigned port){int fd=mars_socket(AF_IPX,SOCK_DGRAM,AF_IPX);assert(fd>=0);struct sockaddr_ipx a={.sipx_family=AF_IPX,.sipx_port=htons(port)};assert(!mars_bind(fd,(void*)&a,sizeof a));return fd;} static void setup(void){ctl=mars_socket(AF_IPX,SOCK_DGRAM,AF_IPX);assert(ctl>=0);struct ifreq r={0};struct sockaddr_ipx v={.sipx_family=AF_IPX,.sipx_network=htonl(0x12345678),.sipx_special=IPX_INTERNAL,.sipx_action=IPX_CRTITF,.sipx_node={0,0,0,0,0,1}};memcpy(&r.ifr_addr,&v,sizeof v);assert(!mars_ioctl(ctl,SIOCSIFADDR,&r));server=ipc_socket(0x451);reply_fd=ipc_socket(0);} @@ -28,7 +29,7 @@ static size_t slp_query(int fd,int func,const char*type,uint8_t*out,size_t cap){ static int slp_fd(void){int fd=socket(AF_INET,SOCK_DGRAM,0);assert(fd>=0);struct timeval tv={0,200000};assert(!setsockopt(fd,SOL_SOCKET,SO_RCVTIMEO,&tv,sizeof tv));struct sockaddr_in a={.sin_family=AF_INET,.sin_port=htons(15427),.sin_addr.s_addr=htonl(INADDR_LOOPBACK)};assert(!connect(fd,(void*)&a,sizeof a));return fd;} static void advertise(int fd,int hops){uint8_t p[66]={0};put16(p,2);put16(p+2,4);memcpy(p+4,"MARS_TEST",9);put32(p+52,0x12345678);p[61]=1;put16(p+62,0x451);put16(p+64,hops);struct sockaddr_ipx dst={.sipx_family=AF_IPX,.sipx_network=htonl(0x12345678),.sipx_port=htons(0x452),.sipx_node={0,0,0,0,0,1}};assert(mars_sendto(fd,p,sizeof p,0,(void*)&dst,sizeof dst)==sizeof p);} static void test_slp(void){int fd=slp_fd(),sap=ipc_socket(0x452);uint8_t out[512];assert(!slp_query(fd,1,"service:bindery.novell",out,sizeof out));advertise(sap,1);size_t r=0;for(int i=0;i<30&&!r;i++){r=slp_query(fd,1,"service:bindery.novell",out,sizeof out);if(!r)usleep(50000);}assert(r>20&&out[1]==2&&get16(out+10)==0x7263&&get16(out+18)==1&&memmem(out,r,"MARS_TEST",9));int multi=socket(AF_INET,SOCK_DGRAM,0);assert(multi>=0);struct timeval tv={1,0};struct in_addr lo={htonl(INADDR_LOOPBACK)};assert(!setsockopt(multi,SOL_SOCKET,SO_RCVTIMEO,&tv,sizeof tv));assert(!setsockopt(multi,IPPROTO_IP,IP_MULTICAST_IF,&lo,sizeof lo));struct sockaddr_in group={.sin_family=AF_INET,.sin_port=htons(15427)};assert(inet_pton(AF_INET,"239.255.255.253",&group.sin_addr)==1);uint8_t mq[128]={2,1};mq[5]=0x20;put16(mq+10,0x7264);put16(mq+12,2);memcpy(mq+14,"en",2);size_t qn=16;const char*fields[]={"","service:bindery.novell","DEFAULT","",""};for(int i=0;i<5;i++){size_t k=strlen(fields[i]);put16(mq+qn,k);memcpy(mq+qn+2,fields[i],k);qn+=2+k;}put16(mq+3,qn);assert(sendto(multi,mq,qn,0,(void*)&group,sizeof group)==(ssize_t)qn);ssize_t mr=recv(multi,out,sizeof out,0);assert(mr>20&&get16(out+10)==0x7264&&get16(out+18)==1);close(multi); - r=slp_query(fd,6,"service:bindery.novell:///MARS_TEST",out,sizeof out);assert(r>20&&out[1]==7&&memmem(out,r,"7F000001020C",12));r=slp_query(fd,1,"service:ndap.novell",out,sizeof out);assert(r==20&&get16(out+18)==0);advertise(sap,16);usleep(100000);assert(!slp_query(fd,1,"service:bindery.novell",out,sizeof out));close(fd);close(sap);puts("PASS real broker SLP UDP unicast/multicast, attributes, no NDS advertisement, SAP withdrawal");} + r=slp_query(fd,6,"service:bindery.novell:///MARS_TEST",out,sizeof out);assert(r>20&&out[1]==7&&memmem(out,r,"7F000001020C",12));r=slp_query(fd,1,"service:ndap.novell",out,sizeof out);if(getenv("MARS_TEST_NDS_DISCOVERY")){assert(r>20&&get16(out+18)==1&&memmem(out,r,"service:ndap.novell:///MARS_TREE.",sizeof("service:ndap.novell:///MARS_TREE.")-1));r=slp_query(fd,6,"service:ndap.novell:///MARS_TREE.",out,sizeof out);assert(r>20&&memmem(out,r,"(svcname-ws=MARS_TREE.)",sizeof("(svcname-ws=MARS_TREE.)")-1));}else assert(r==20&&get16(out+18)==0);advertise(sap,16);usleep(100000);assert(!slp_query(fd,1,"service:bindery.novell",out,sizeof out));close(fd);close(sap);puts("PASS real broker SLP UDP unicast/multicast, attributes, NDS opt-in state, SAP withdrawal");} int main(void){setup();test_slp();int a=connect_tcp(),b=connect_tcp();tx(a,0x1111,0,65535,-1);struct sockaddr_ipx x=rx(0x1111,0,65535);answer(&x,0,7);response(a,0,7);tx(b,0x1111,1,65535,-1);struct sockaddr_ipx y=rx(0x1111,0,65535);assert(memcmp(x.sipx_node,y.sipx_node,6));answer(&y,0,9);response(b,1,9); tx(a,0x2222,1,7,23);x=rx(0x2222,1,7);/* incorrect connection reply must be ignored */answer(&x,1,9);answer(&x,1,7);response(a,1,7); /* Watchdog: upstream asks on source port+1; reply on local IPC. */struct sockaddr_ipx wd=x;wd.sipx_port=htons(ntohs(x.sipx_port)+1);uint8_t ping[2]={7,'?'};assert(mars_sendto(reply_fd,ping,2,0,(void*)&wd,sizeof wd)==2);struct pollfd pfd={reply_fd,POLLIN,0};assert(poll(&pfd,1,3000)==1);socklen_t sz=sizeof wd;assert(mars_recvfrom(reply_fd,ping,2,0,(void*)&wd,&sz)==2&&ping[0]==7&&ping[1]=='Y'); @@ -40,4 +41,6 @@ int main(void){setup();test_slp();int a=connect_tcp(),b=connect_tcp();tx(a,0x111 uint8_t ping104[24]={0};put32(ping104,0x446d6454);put32(ping104+4,sizeof ping104);put32(ping104+8,1);put32(ping104+12,4096);put16(ping104+16,0x2222);ping104[18]=1;ping104[19]=11;ping104[20]=1;ping104[22]=104;ping104[23]=1;fullwrite(nd,ping104,sizeof ping104);x=rx(0x2222,1,11);answer(&x,1,11);response(nd,1,11); /* An upstream shutdown must invalidate all TCP sessions immediately. */ close(server);eof(nd);close(nd);sleep(2);FILE*status=fopen("/run/mars-pcap/ncp-ip-status","r");assert(status);char diag[1024]={0};assert(fread(diag,1,sizeof diag-1,status)>0);fclose(status);assert(strstr(diag,"NDS-Requests-TCP=1")&&strstr(diag,"NDS-Ping=1")&&strstr(diag,"waiting for local NCP server")); + if(getenv("MARS_TEST_NDS_DISCOVERY"))assert(strstr(diag,"NDS-Discovery-Tree=MARS_TREE")); + if(getenv("MARS_TEST_INVALID_NDS"))assert(strstr(diag,"NDS-Discovery=invalid or missing NDS lab snapshot")&&strstr(diag,"NDS-Discovery-Tree=-")); close(ctl);close(reply_fd);puts("PASS NDS request metadata and upstream shutdown invalidates TCP sessions");puts("PASS real TCP framing, fragmented input, separate session nodes, spoof rejection, watchdog, disconnect, malformed signed frame");return 0;} diff --git a/tests/test_ncp_ip_ui.cjs b/tests/test_ncp_ip_ui.cjs index bf9fd51..78ed1d6 100644 --- a/tests/test_ncp_ip_ui.cjs +++ b/tests/test_ncp_ip_ui.cjs @@ -4,4 +4,5 @@ const elements={};function $(id){assert.ok(html.includes('id="'+id+'"'),id);retu let failure=false,posts=0;const response={config:{enabled:false,address:''},addresses:[{address:'127.0.0.1',interface:'lo'},{address:'192.168.1.10',interface:'eth0'}],runtime:'disabled',revision:'r1',valid:true}; const ctx=vm.createContext({$,document:{createElement(){return {}; }},api:async(path,body)=>{if(failure)throw Error('Nicht erreichbar');if(body){posts++;assert.equal(body.config.address,'192.168.1.10');assert.equal(body.revision,'r1');assert.equal(body.config.slp,true);}return response;},confirm:()=>true,state:{defaultPassword:false},busy:false,dirty:false,notice(){}}); vm.runInContext(src.slice(src.indexOf('let ncpIpData=null')),ctx); -(async()=>{await vm.runInContext('ncpIpLoad()',ctx);assert.equal($('ncpIpAddress').value,'192.168.1.10');assert.equal($('ncpIpSave').disabled,true);$('ncpIpEnabled').checked=true;$('ncpIpEnabled').onchange();$('ncpIpSlp').checked=true;$('ncpIpSlp').onchange();assert.equal($('ncpIpSave').disabled,false);assert.equal($('ncpIpRestart').disabled,true);$('ncpIpAddress').value='1.2.3.4';await $('ncpIpForm').onsubmit({preventDefault(){}});assert.equal(posts,0);$('ncpIpAddress').value='192.168.1.10';await $('ncpIpForm').onsubmit({preventDefault(){}});assert.equal(posts,1);failure=true;await vm.runInContext('ncpIpLoad()',ctx);assert.equal($('ncpIpSave').disabled,true);assert.equal($('ncpIpRestart').disabled,true);console.log('PASS NCP/IP UI: local address selection, validation, revision, save, failed load');})().catch(e=>{console.error(e);process.exitCode=1;}); +function ncpPresets(){ $('ncpPresetIp').onclick();assert.equal(posts,0);assert.equal($('ncpIpEnabled').checked,true);assert.equal($('ncpIpSlp').checked,true);$('ncpPresetIpx').onclick();assert.equal(posts,0);assert.equal($('ncpIpEnabled').checked,false);assert.equal($('ncpIpSlp').checked,false);} +(async()=>{await vm.runInContext('ncpIpLoad()',ctx);assert.equal($('ncpIpAddress').value,'192.168.1.10');assert.equal($('ncpIpSave').disabled,true);ncpPresets();$('ncpIpEnabled').checked=true;$('ncpIpEnabled').onchange();$('ncpIpSlp').checked=true;$('ncpIpSlp').onchange();assert.equal($('ncpIpSave').disabled,false);assert.equal($('ncpIpRestart').disabled,true);$('ncpIpAddress').value='1.2.3.4';await $('ncpIpForm').onsubmit({preventDefault(){}});assert.equal(posts,0);$('ncpIpAddress').value='192.168.1.10';await $('ncpIpForm').onsubmit({preventDefault(){}});assert.equal(posts,1);failure=true;await vm.runInContext('ncpIpLoad()',ctx);assert.equal($('ncpIpSave').disabled,true);assert.equal($('ncpIpRestart').disabled,true);console.log('PASS NCP/IP UI: local address selection, validation, revision, save, failed load');})().catch(e=>{console.error(e);process.exitCode=1;}); diff --git a/tests/test_nds_directory.c b/tests/test_nds_directory.c new file mode 100644 index 0000000..72d1042 --- /dev/null +++ b/tests/test_nds_directory.c @@ -0,0 +1,26 @@ +#include "nds_directory.h" +#include +#include +#include +int main(int argc,char **argv){ + sqlite3 *db=NULL; struct nds_entry e, page[2];size_t n;uint32_t next,id,root; + assert(argc==2);assert(nds_open(&db,argv[1])==NDS_OK); + assert(nds_resolve(db,"[Root]",&e)==NDS_OK);root=e.id; + assert(nds_resolve(db,".cn=ALICE.ou=retro.o=home",&e)==NDS_OK);id=e.id; + assert(!strcmp(e.cls,"User")&&e.enabled==0); + assert(nds_resolve(db,"alice.retro.home",&e)==NDS_OK&&e.id==id); + assert(nds_read(db,id,&e)==NDS_OK&&e.id==id); + assert(nds_resolve(db,"CN=missing.O=HOME",&e)==NDS_NOT_FOUND&&e.id==0); + assert(nds_resolve(db,"RETRO.HOME",&e)==NDS_AMBIGUOUS&&e.id==0); + assert(nds_resolve(db,"OU=RETRO.O=HOME",&e)==NDS_OK); + assert(nds_search(db,e.id,NDS_ONE,NULL,NULL,0,page,2,&n,&next)==NDS_OK&&n==2&&next!=0); + assert(nds_search(db,e.id,NDS_ONE,NULL,NULL,next,page,2,&n,&next)==NDS_OK&&n==1&&next==0); + assert(nds_search(db,root,NDS_SUBTREE,NULL,"User",0,page,2,&n,&next)==NDS_OK&&n==2&&next==0); + assert(nds_search(db,root,NDS_BASE,NULL,NULL,0,page,2,&n,&next)==NDS_OK&&n==1&&page[0].id==root); + assert(nds_search(db,root,NDS_SUBTREE,"alice","user",0,page,2,&n,&next)==NDS_OK&&n==1&&page[0].id==id); + assert(nds_search(db,root,NDS_ONE,NULL,NULL,0,page,0,&n,&next)==NDS_INVALID&&n==0); + assert(nds_search(db,99999,NDS_SUBTREE,NULL,NULL,0,page,2,&n,&next)==NDS_NOT_FOUND); + assert(sqlite3_exec(db,"DELETE FROM nds_entries",NULL,NULL,NULL)==SQLITE_READONLY); + sqlite3_close(db);assert(nds_open(&db,argv[1])==NDS_OK);assert(nds_resolve(db,"alice.retro.home",&e)==NDS_OK&&e.id==id);sqlite3_close(db); + puts("PASS native resolve/read/list/search, ambiguity, pagination, readonly, stable IDs");return 0; +} diff --git a/tests/test_nds_directory.py b/tests/test_nds_directory.py new file mode 100644 index 0000000..ae11992 --- /dev/null +++ b/tests/test_nds_directory.py @@ -0,0 +1,29 @@ +import pathlib, subprocess, tempfile, sys, sqlite3, os +ROOT=pathlib.Path(__file__).resolve().parents[1] +sys.path.insert(0,str(ROOT/'nds'/'tools')) +import directory as d +with tempfile.TemporaryDirectory() as tmp: + p=pathlib.Path(tmp)/'directory.db';d.initialize(p) + assert p.stat().st_mode & 0o777 == 0o600 + try:d.initialize(p) + except FileExistsError:pass + else:raise AssertionError('overwrote DB') + with d.connect(p) as db: + d.add(db,'[Root]','Organization','HOME') + d.add(db,'O=HOME','Organizational Unit','RETRO') + d.add(db,'O=HOME','Group','RETRO') + d.add(db,'OU=RETRO.O=HOME','User','ALICE') + d.add(db,'OU=RETRO.O=HOME','User','BOB') + d.add(db,'OU=RETRO.O=HOME','Group','PLAYERS') + db.execute("UPDATE nds_entries SET enabled=0 WHERE name='ALICE'") + for parent,cls,name in [('O=HOME','Group','retro'),('CN=ALICE.OU=RETRO.O=HOME','User','CHILD'),('O=HOME','User','A.B'),('[Root]','User','ROOTUSER')]: + with d.connect(p) as db: + try:d.add(db,parent,cls,name) + except (sqlite3.IntegrityError,ValueError):pass + else:raise AssertionError('invalid object accepted') + subprocess.run([str(ROOT/'build/test-nds-directory'),str(p)],check=True) + print('PASS provisioning, permission mode, duplicate and malformed object rejection') +from nds_trace import summarize +n,verbs,errors,bad=summarize([['1','1,57',''],['2','','0xffffff00'],['3','60','0'],['invalid','3',''],['4','999','']]) +assert n==3 and verbs=={1:1,57:1,60:1} and errors=={-256:1} and bad==2 +print('PASS trace metadata aggregation and signed error decoding (synthetic TSV)') diff --git a/tests/test_nds_hook.py b/tests/test_nds_hook.py new file mode 100644 index 0000000..2bf58b8 --- /dev/null +++ b/tests/test_nds_hook.py @@ -0,0 +1,32 @@ +import pathlib, tempfile, subprocess +root=pathlib.Path(__file__).resolve().parents[1] +fixture='''#include +typedef unsigned char uint8; +typedef struct {uint8 task,sequence;} NCPREQUEST; +typedef struct {uint8 a[8];} NCPRESPONSE; +static uint8 ipxdata[4096],readbuff[4096]; +static uint8 *responsedata=((uint8*)&ipxdata)+sizeof(NCPRESPONSE); +static uint8 *requestdata=readbuff+sizeof(NCPREQUEST); +int run(NCPREQUEST *ncprequest,int ncp_type,int function,int data_len){int requestlen,completition=0; +requestlen = data_len - sizeof(NCPREQUEST); +if (ncp_type == 0x2222) { switch (function) { default: completition=0xfb; break; }} +return completition;} +int main(void){NCPREQUEST r={1,1};return run(&r,0x2222,104,2)==0xfb?0:1;} +''' +with tempfile.TemporaryDirectory() as t: + p=pathlib.Path(t);(p/'src').mkdir();f=p/'src/nwconn.c';f.write_text(fixture) + subprocess.run(['python3',str(root/'upstream-adapter/add-nds.py'),t],check=True) + (p/'src/mars_nds_server.h').write_bytes((root/'nds/server.h').read_bytes()) + subprocess.run(['cc','-D_DEFAULT_SOURCE','-std=c11',str(f),str(root/'nds/server.c'),str(root/'nds/fragger.c'),str(root/'nds/nds_directory.c'),'-ljson-c','-lsqlite3','-o',str(p/'test')],check=True) + subprocess.run([str(p/'test')],check=True,env={'MARS_NDS_LAB':'0'}) + assert subprocess.run(['python3',str(root/'upstream-adapter/add-nds.py'),t],capture_output=True).returncode!=0 + stub = 'case 0x68 : /* NDS NCP, NDS Fragger Protokoll ?? */\n XDPRINTF((2,0, "NDS Fragger Protokoll not supportet"));\n nw_debug=0;\n completition = 0xfb; /* unknown request */\n break;' + legacy = fixture.replace('default: completition=0xfb;', stub+' default: completition=0xfb;') + '\n/* legacy umlaut: ü */\n' + f.write_bytes(legacy.encode('latin-1')) + subprocess.run(['python3',str(root/'upstream-adapter/add-nds.py'),t],check=True) + patched=f.read_bytes() + assert b'\xfc' in patched and patched.count(b'case 0x68')==1 + assert b'mars_nds_request' in patched + f.write_text(fixture.replace('switch (function)','switch (unknown)')) + assert subprocess.run(['python3',str(root/'upstream-adapter/add-nds.py'),t],capture_output=True).returncode!=0 +print('PASS dispatcher hook compile/link fixture, rejects repeated or incompatible patch; actual upstream not tested') diff --git a/tests/test_nds_ncpfs.c b/tests/test_nds_ncpfs.c new file mode 100644 index 0000000..1c6dded --- /dev/null +++ b/tests/test_nds_ncpfs.c @@ -0,0 +1,42 @@ +/* Optional interoperability fixture with the separately supplied ncpfs 2.2.6 + * static library (GPL-2.0-or-later). Only the transport is intercepted; + * ncpfs constructs/decodes the actual inner NDAP buffers. No real login. */ +#define _DEFAULT_SOURCE +#include +#include "nwnet_i.h" +#include "server.h" +#include +#include +#include +#include +#include +static void leput(unsigned char *p,uint32_t v){for(int i=0;i<4;i++)p[i]=(unsigned char)(v>>(i*8));} +static uint32_t leget(const unsigned char *p){return p[0]|(uint32_t)p[1]<<8|(uint32_t)p[2]<<16|(uint32_t)p[3]<<24;} +static unsigned char seq; +long __wrap_ncp_send_nds_frag(NWCONN_HANDLE conn,int verb,const char *in,size_t n,char *out,size_t cap,size_t *used){ + (void)conn;unsigned char pkt[4096]={2},reply[512];size_t rn=0;uint32_t h;*used=0; + assert(n<=sizeof pkt-25&&cap<=65536); + leput(pkt+1,0xffffffff);leput(pkt+5,sizeof reply);leput(pkt+9,n+12);leput(pkt+17,verb);leput(pkt+21,cap);memcpy(pkt+25,in,n); + int rc=mars_nds_request(1,++seq,pkt,n+25,reply,sizeof reply,&rn);assert(!rc&&rn>=12&&leget(reply)==rn-4);h=leget(reply+4);int32_t status=(int32_t)leget(reply+8);size_t payload=rn-12;assert(payload<=cap);memcpy(out,reply+12,payload);*used=payload; + while(h!=0xffffffff){leput(pkt+1,h);rc=mars_nds_request(1,++seq,pkt,5,reply,sizeof reply,&rn);assert(!rc&&rn>=8&&leget(reply)==rn-4&&rn-8<=cap-*used);h=leget(reply+4);memcpy(out+*used,reply+8,rn-8);*used+=rn-8;} + return status; +} +extern NWDSCCODE __NWDSCompare(NWDSContextHandle,NWCONN_HANDLE,NWObjectID,Buf_T*,nbool8*); +int main(int argc,char **argv){ + assert(argc==4);NWObjectID volume=strtoul(argv[1],NULL,10),serverou=strtoul(argv[2],NULL,10),user=strtoul(argv[3],NULL,10); + NWDSContextHandle ctx;assert(!NWDSCreateContextHandle(&ctx));nuint32 flags=DCV_XLATE_STRINGS;assert(!NWDSSetContext(ctx,DCK_FLAGS,&flags)); + char rqmem[2048],rpmem[8192],name[MAX_DN_BYTES+1],val[MAX_DN_BYTES+1];Buf_T rq,rp;NWDSSetupBuf(&rq,rqmem,sizeof rqmem);NWDSSetupBuf(&rp,rpmem,sizeof rpmem);nuint32 iter=NO_MORE_ITERATIONS;NWObjectCount count,values;enum SYNTAX syntax; + /* Actual ncpfs Read V1 constructor and attribute parser. */ + assert(!NWDSInitBuf(ctx,DSV_READ,&rq));assert(!NWDSPutAttrName(ctx,&rq,"Host Server"));assert(!NWDSPutAttrName(ctx,&rq,"Host Resource Name"));assert(!__NWDSReadV1(NULL,0,volume,DS_ATTRIBUTE_VALUES,0,&rq,&iter,NULL,&rp));assert(iter==NO_MORE_ITERATIONS);assert(!NWDSGetAttrCount(ctx,&rp,&count)&&count==2); + unsigned seen=0;for(unsigned i=0;i>24;b[1]=serverou>>16;b[2]=serverou>>8;b[3]=serverou;assert(!NWDSBufPutLE32(&rq,mask));assert(!NWDSBufPutLE32(&rq,0));assert(!NWDSPutAttrVal_XX_STRING(ctx,&rq,"Volume"));size_t n=0;assert(!__wrap_ncp_send_nds_frag(NULL,DSV_LIST,rqmem,rq.curPos-rq.data,rpmem,sizeof rpmem,&n));assert(leget((unsigned char*)rpmem)==NO_MORE_ITERATIONS);NWDSSetupBuf(&rp,rpmem+4,n-4);NWDSBufStartPut(&rp,DSV_LIST);NWDSBufSetDSIFlags(&rp,mask);NWDSBufPutSkip(&rp,n-4);NWDSBufFinishPut(&rp);assert(!NWDSGetObjectCount(ctx,&rp,&count)&&count==2);for(unsigned i=0;i>24;b[1]=serverou>>16;b[2]=serverou>>8;b[3]=serverou;assert(!NWDSBufPutLE32(&rq,1));assert(!NWDSBufPutLE32(&rq,0));assert(!NWDSBufPutLE32(&rq,DS_ATTRIBUTE_VALUES));assert(!NWDSBufPutLE32(&rq,mask));assert(!NWDSBufPutLE32(&rq,1));assert(!NWDSBufPutLE32(&rq,0));assert(!NWDSBufPutLE32(&rq,0));assert(!NWDSBufPutLE32(&rq,FTOK_BASECLS));assert(!NWDSPutAttrVal_XX_STRING(ctx,&rq,"Volume"));assert(!__wrap_ncp_send_nds_frag(NULL,DSV_SEARCH,rqmem,rq.curPos-rq.data,rpmem,sizeof rpmem,&n));assert(n>=24&&leget((unsigned char*)rpmem)==NO_MORE_ITERATIONS&&leget((unsigned char*)rpmem+4)==3&&leget((unsigned char*)rpmem+8)==DS_ATTRIBUTE_VALUES);size_t objlen=leget((unsigned char*)rpmem+12);assert(objlen+24==n&&leget((unsigned char*)rpmem+16+objlen)==4&&leget((unsigned char*)rpmem+20+objlen)==0);NWDSSetupBuf(&rp,rpmem+16,objlen);NWDSBufStartPut(&rp,DSV_SEARCH);NWDSBufSetDSIFlags(&rp,mask);NWDSBufPutSkip(&rp,objlen);NWDSBufFinishPut(&rp);assert(!NWDSGetObjectCount(ctx,&rp,&count)&&count==2);for(unsigned i=0;iI',oid)+struct.pack(' +#include +#include +int main(int argc,char **argv){ + sqlite3 *db=NULL;struct nds_entry e;struct nds_attr a[NDS_ATTR_MAX];size_t n=0;int matched=0; + assert(argc==2&&nds_open(&db,argv[1])==NDS_OK); + assert(nds_resolve(db,"CN=MARS_SYS.OU=SERVERS.O=HOME",&e)==NDS_OK); + assert(nds_attributes(db,e.id,NULL,0,&n)==NDS_BUFFER_SMALL&&n==4); + memset(a,0,sizeof a);assert(nds_attributes(db,e.id,a,1,&n)==NDS_BUFFER_SMALL&&a[0].name==NULL); + assert(nds_attributes(db,e.id,a,NDS_ATTR_MAX,&n)==NDS_OK&&n==4); + assert(!strcmp(a[2].name,"Host Server")&&a[2].kind==NDS_ATTR_DN&&!strcmp(a[2].value,"CN=MARS.OU=SERVERS.O=HOME")); + assert(nds_compare(db,e.id,"host server","mars.servers.home",&matched)==NDS_OK&&matched); + assert(nds_compare(db,e.id,"host server","missing.home",&matched)==NDS_OK&&!matched); + assert(nds_compare(db,e.id,"host resource name","sys",&matched)==NDS_OK&&matched); + assert(nds_compare(db,e.id,"host resource name","DATA",&matched)==NDS_OK&&!matched); + assert(nds_compare(db,e.id,"Password","secret",&matched)==NDS_NOT_FOUND&&!matched); + assert(nds_resolve(db,"CN=ALICE.OU=USERS.O=HOME",&e)==NDS_OK); + assert(nds_compare(db,e.id,"Login Disabled","FALSE",&matched)==NDS_OK&&matched); + assert(nds_compare(db,e.id,"Login Disabled","maybe",&matched)==NDS_INVALID&&!matched); + assert(nds_compare(db,e.id,"Object Class","USER",&matched)==NDS_OK&&matched); + assert(nds_attributes(db,UINT32_MAX,a,NDS_ATTR_MAX,&n)==NDS_INVALID&&n==0); + assert(sqlite3_exec(db,"DELETE FROM mars_nds_volume",NULL,NULL,NULL)==SQLITE_READONLY); + sqlite3_close(db);puts("PASS native attributes, typed DN/bool/string compare, missing attributes, bounds, read-only DB");return 0; +} diff --git a/tests/test_nds_schema.py b/tests/test_nds_schema.py new file mode 100644 index 0000000..fe4a3a2 --- /dev/null +++ b/tests/test_nds_schema.py @@ -0,0 +1,48 @@ +import json, os, pathlib, sqlite3, subprocess, sys, tempfile +from contextlib import closing +root=pathlib.Path(__file__).resolve().parents[1] +sys.path.insert(0,str(root/'nds'/'tools')) +import snapshot as s +with tempfile.TemporaryDirectory() as t: + t=pathlib.Path(t);conf=t/'nwserv.conf';db=t/'directory.sqlite3' + data={'tree':'MARS_TREE','organization':'HOME','units':['USERS','SERVERS'],'placements':[{'name':'alice','type':1,'unit':'USERS'}]} + conf.write_text('2 mars # server\n1 sys /secret-host-path ikO\n1 DATA /another-private-path\n12 SUPERVISOR root test-secret-password\n') + resources=s.parse_resources(conf);assert resources==('MARS',['SYS','DATA']) + # Simulate the 0.9.6 layout with no mars_nds_volume table, then upgrade. + s.publish(data,db,True) + with closing(sqlite3.connect(db)) as c: + oldid=c.execute("SELECT id FROM nds_entries WHERE dn='O=HOME'").fetchone()[0] + c.execute('DROP TABLE mars_nds_volume');c.commit() + cfg=s.publish(data,db,True,resources) + def get(dn): + with closing(sqlite3.connect(db)) as c:return c.execute('SELECT id FROM nds_entries WHERE dn=?',(dn,)).fetchone() + assert get('O=HOME')[0]==oldid + v='CN=MARS_SYS.OU=SERVERS.O=HOME';vid=get(v)[0];sid=get('CN=MARS.OU=SERVERS.O=HOME')[0] + assert b'secret-host-path' not in db.read_bytes() and b'test-secret-password' not in db.read_bytes() + subprocess.run([str(root/'build/test-nds-schema'),str(db)],check=True) + cli=[str(root/'build/mars-nds-inspect'),str(db)] + assert 'Host Resource Name\tSYS' in subprocess.check_output(cli+['read',v],text=True) + assert subprocess.check_output(cli+['compare',v,'Host Server','MARS.SERVERS.HOME'],text=True).strip()=='TRUE' + assert len(subprocess.check_output(cli+['list','OU=SERVERS.O=HOME'],text=True).splitlines())==3 + assert len(subprocess.check_output(cli+['search','[Root]','Volume'],text=True).splitlines())==2 + assert subprocess.run(cli+['read','MISSING'],capture_output=True).returncode!=0 + s.publish(data,db,True,resources);assert get(v)[0]==vid and get('CN=MARS.OU=SERVERS.O=HOME')[0]==sid + # Verify an actual NCP 104/2 response from the existing C dispatcher. + env=dict(os.environ,MARS_NDS_LAB='1',MARS_NDS_LAB_CONFIG=json.dumps(cfg),MARS_NDS_LAB_DB=str(db)) + subprocess.run([str(root/'build/test-nds-lab'),'resource',v,str(vid)],env=env,check=True) + logged=subprocess.run([str(root/'build/test-nds-lab'),'resource',v,str(vid)],env=dict(env,MARS_NDS_LAB_TRACE='1'),check=True,capture_output=True,text=True) + lines=logged.stderr.splitlines();assert len(lines)==14 and 'verb=57 packet_bytes=25 result=unsupported' in logged.stderr + assert v not in logged.stderr and 'ALICE' not in logged.stderr + print('PASS optional verb-only trace, no names or packet payload') + before=db.read_bytes() + try:s.publish(dict(data,placements=data['placements']+[{'name':'mars','type':1,'unit':'SERVERS'}]),db,True,resources) + except ValueError:pass + else:raise AssertionError('collision accepted') + assert db.read_bytes()==before + for bad in ['2 MARS\n2 DUP\n1 SYS /x','2 MARS\n1 DATA /x','2 MARS\n1 SYS /x\n1 sys /y','2 MARS\n1 SYS','2 MARS\n1 SYS /x\n1 TOOLONG99 /y']: + conf.write_text(bad) + try:s.parse_resources(conf) + except ValueError:pass + else:raise AssertionError('invalid resources accepted') + s.publish(data,db,False);assert get(v) is None and get('CN=ALICE.OU=USERS.O=HOME') is None +print('PASS resource import, no secrets/paths, stable IDs, NCP resolve, local CLI, collisions, opt-in and validation') diff --git a/tests/test_nds_server.c b/tests/test_nds_server.c new file mode 100644 index 0000000..2cced70 --- /dev/null +++ b/tests/test_nds_server.c @@ -0,0 +1,59 @@ +#define _POSIX_C_SOURCE 200809L +#include "server.h" +#include "fragger.h" +#include +#include +#include +#include +static void put(unsigned char *p,uint32_t v){for(int i=0;i<4;i++)p[i]=(unsigned char)(v>>(i*8));} +static uint32_t get(const unsigned char *p){return p[0]|(uint32_t)p[1]<<8|(uint32_t)p[2]<<16|(uint32_t)p[3]<<24;} +static unsigned char in[512],out[512],copy[512],req[512];static size_t used; +static int call(unsigned task,unsigned seq,size_t n,size_t cap){return mars_nds_request(task,seq,in,n,out,cap,&used);} +static size_t name(const char *s){memset(req,0,sizeof req);size_t l=(strlen(s)+1)*2;put(req+12,l);for(size_t i=0;s[i];i++)req[16+i*2]=s[i];return 16+((l+3)&~3u)+8;} +static void first(size_t len,unsigned verb,unsigned wire){memset(in,0,sizeof in);in[0]=2;put(in+1,NDS_END);put(in+5,wire);put(in+9,len+12);put(in+17,verb);put(in+21,128);} +int main(int argc,char **argv){ + (void)argv; + if(argc==4&&!strcmp(argv[1],"resource")){ + size_t n=name(argv[2]);first(n,1,512);memcpy(in+25,req,n); + assert(!call(1,1,n+25,sizeof out)&&used==24&&get(out+8)==0); + uint32_t id=(uint32_t)out[16]<<24|(uint32_t)out[17]<<16|(uint32_t)out[18]<<8|out[19]; + assert(id==(uint32_t)strtoul(argv[3],NULL,10)); + /* Documented NCP 104/06, not NDAP verb 6. */ + in[0]=6;put(in+1,0xffffffff);assert(!call(1,2,5,sizeof out)&&used==24); + assert(get(out)==0xe7&&get(out+4)==0&&get(out+8)==1&&get(out+12)==1&&get(out+16)==n&&get(out+20)==12); + put(in+1,0x20);assert(!call(1,3,5,sizeof out)&&used==4&&get(out)==1); + put(in+1,0x100);assert(call(1,4,5,sizeof out)==0xfe&&used==0); + put(in+1,0x101);assert(!call(1,5,5,sizeof out)&&used==4&&get(out)==1); + put(in+1,0xe7);assert(call(1,6,5,23)==0xfe&&used==0); + assert(call(1,7,4,sizeof out)==0xfe&&used==0); + in[0]=7;assert(call(1,8,1,sizeof out)==0xfb&&used==0); /* no unauthenticated reset */ + puts("PASS NCP 104/06 statistics, flag negotiation, bounds, reset denied"); + /* Unknown wire format and authentication continue to fail closed. */ + for(unsigned v=2;v<=6;v++){first(0,v,512);assert(call(1,v,25,sizeof out)==0xfb&&used==0);} + for(unsigned v=54;v<=61;v++){first(0,v,512);assert(call(1,v,25,sizeof out)==0xfb&&used==0);} + puts("PASS resource object NCP Resolve, unsupported NDAP/auth verbs denied");return 0; + } + if(argc>1&&!strcmp(argv[1],"database")){ + in[0]=1;assert(!call(1,1,4,sizeof out)&&!strcmp((char*)out+8,"MARS_TREE")); + size_t n=name("CN=ALICE.OU=USERS.O=HOME");first(n,1,512);memcpy(in+25,req,n); + assert(!call(1,2,n+25,sizeof out)); + if(argc==3){assert(used==24&&get(out+8)==0);uint32_t id=(uint32_t)out[16]<<24|(uint32_t)out[17]<<16|(uint32_t)out[18]<<8|out[19];assert(id==(uint32_t)strtoul(argv[2],NULL,10));} + else assert(used==12&&(int32_t)get(out+8)==-601); + first(0,57,512);assert(call(1,3,25,sizeof out)==0xfb&&used==0); + puts("PASS database-backed NCP Resolve Name and fail-closed login");return 0; + } + if(argc>1){in[0]=1;assert(call(1,1,4,sizeof out)==0xfb&&used==0);puts("PASS disabled or invalid model fails closed");return 0;} + assert(!setenv("MARS_NDS_LAB","1",1));assert(!setenv("MARS_NDS_LAB_CONFIG","{\"tree\":\"MARS_TREE\",\"organization\":\"HOME\",\"units\":[\"USERS\",\"USERS/RETRO\",\"GROUPS\"]}",1)); + in[0]=1;assert(!call(1,1,4,sizeof out)&&used==18&&get(out+4)==10&&!strcmp((char*)out+8,"MARS_TREE"));assert(call(1,1,4,8)==0xfe&&used==0);in[1]=1;assert(call(1,2,4,sizeof out)==0xfe);in[1]=0; + in[0]=4;assert(!call(1,3,1,sizeof out)&&used==18&&get(out)==14&&!memcmp(out+4,"O\0=\0H\0O\0M\0E\0\0",14)); + size_t n=name(".ou=retro.ou=users.o=home");first(n,1,512);memcpy(in+25,req,13);assert(!call(1,4,38,sizeof out)&&used==8);uint32_t h=get(out+4);memcpy(copy,out,used);assert(!call(1,4,38,sizeof out)&&!memcmp(copy,out,used)); + in[0]=2;put(in+1,h);memcpy(in+5,req+13,n-13);assert(call(2,5,n-8,sizeof out)==0xfe);assert(!call(1,5,n-8,sizeof out)&&used==24&&get(out+4)==NDS_END&&get(out+8)==0&&get(out+12)==1&&get(out+20)==0);memcpy(copy,out,used);assert(!call(1,5,n-8,sizeof out)&&!memcmp(copy,out,used)); + n=name("RETRO.USERS.HOME");first(n,1,512);memcpy(in+25,req,n);assert(!call(1,6,n+25,sizeof out)&&used==24&&!memcmp(out+16,copy+16,4)); + n=name("CN=SECRET.OU=USERS.O=HOME");first(n,1,512);memcpy(in+25,req,n);assert(!call(1,7,n+25,sizeof out)&&used==12&&(int32_t)get(out+8)==-601); + n=name("HOME");put(req+4,1);first(n,1,512);memcpy(in+25,req,n);assert(!call(1,8,n+25,sizeof out)&&(int32_t)get(out+8)==-672); + first(0,57,512);assert(call(1,9,25,sizeof out)==0xfb&&used==0); + n=name("HOME");first(n,1,512);memcpy(in+25,req,2);assert(!call(1,10,27,sizeof out));h=get(out+4);in[0]=3;put(in+1,h);assert(call(2,11,5,sizeof out)==0xfe);assert(!call(1,11,5,sizeof out)&&used==0);assert(call(1,12,5,sizeof out)==0xfe); + n=name("HOME");put(req+12,0xffffffff);first(n,1,512);memcpy(in+25,req,n);assert(!call(1,13,n+25,sizeof out)&&(int32_t)get(out+8)==-641); + for(unsigned i=0;i<50000;i++){size_t k=rand()%sizeof in;for(size_t j=0;ja[0] + assert get('O=HOME')==org and p.stat().st_mode&0o777==0o644 +print('PASS snapshot default privacy, stable IDs, no reuse, rollback on collision, absent/mismatched database fails closed') diff --git a/tests/test_nds_wire.py b/tests/test_nds_wire.py new file mode 100644 index 0000000..c51969c --- /dev/null +++ b/tests/test_nds_wire.py @@ -0,0 +1,92 @@ +#!/usr/bin/env python3 +"""Independent packet fixtures based on ncpfs 2.2.6 read/list/search decoders.""" +import ctypes as C, json, os, pathlib, random, sqlite3, struct, sys, tempfile +from contextlib import closing +root=pathlib.Path(__file__).resolve().parents[1] +sys.path.insert(0,str(root/'nds/tools')) +import snapshot +END=0xffffffff +le=lambda *v:struct.pack('<'+'I'*len(v),*v) +be=lambda i:struct.pack('>I',i) +def string(s): + b=(s+'\0').encode('utf-16le');return le(len(b))+b+b'\0'*((-len(b))%4) +class Reader: + def __init__(self,b):self.b=b;self.i=0 + def take(self,n): + assert self.i+n<=len(self.b);v=self.b[self.i:self.i+n];self.i+=n;return v + def u32(self):return struct.unpack('I',self.take(4))[0] + def string(self): + n=self.u32();s=self.take(n);assert self.take((-n)%4)==b'\0'*((-n)%4) + assert n>=2 and n%2==0 and s[-2:]==b'\0\0';return s[:-2].decode('utf-16le') + def end(self):assert self.i==len(self.b) + def dsi(self): + mask=self.u32();d={} + for bit,k,read in [(2,'id',self.oid),(8,'children',self.u32),(0x100,'parent',self.oid),(0x800,'class',self.string),(0x1000,'rdn',self.string),(0x2000,'dn',self.string)]: + if mask&bit:d[k]=read() + assert not mask&~0x390b;return d + def attrs(self,info): + a={} + for _ in range(self.u32()): + if not info:a[self.string()]=None;continue + syntax=self.u32();name=self.string();assert self.u32()==1 + if syntax==7: + assert self.u32()==1;v=self.take(4);assert v in (b'\0'*4,b'\1\0\0\0');value=bool(v[0]) + else:assert syntax in (1,3,20);value=self.string() + a[name]=(syntax,value) + return a +with tempfile.TemporaryDirectory() as td: + path=pathlib.Path(td)/'directory.sqlite3' + data={'tree':'MARS_TREE','organization':'HOME','units':['SERVERS','USERS'],'placements':[{'name':'alice','type':1,'unit':'USERS'}]} + cfg=snapshot.publish(data,path,True,('MARS',['SYS','DATA'])) + with closing(sqlite3.connect(path)) as db:ids=dict(db.execute('SELECT dn,id FROM nds_entries')) + os.environ.update(MARS_NDS_LAB='1',MARS_NDS_LAB_READ='1',MARS_NDS_LAB_CONFIG=json.dumps(cfg),MARS_NDS_LAB_DB=str(path)) + lib=C.CDLL(str(root/'build/test-nds-wire.so'));call=lib.mars_nds_request;call.argtypes=[C.c_uint8,C.c_uint8,C.c_void_p,C.c_size_t,C.c_void_p,C.c_size_t,C.POINTER(C.c_size_t)];call.restype=C.c_int + seq=0 + def ncp(p): + global seq + seq=(seq+1)%256;out=C.create_string_buffer(4096);used=C.c_size_t();rc=call(1,seq,p,len(p),out,len(out),C.byref(used));return rc,out.raw[:used.value] + def request(v,p,limit=65536,wire=512,split=0): + h=b'\2'+le(END,wire,len(p)+12,0,v,limit);rc,out=ncp(h+p[:split] if split else h+p) + if rc:return rc,b'' + if split: + assert len(out)==8;rc,out=ncp(b'\2'+out[4:8]+p[split:]);assert not rc + assert len(out)>=12 and len(out)-4==int.from_bytes(out[:4],'little');r=Reader(out);r.u32();handle=r.u32();status=struct.unpack('20&&get16(out+18)==1&&has(out,r,"service:ndap.novell:///MARS_TREE."));assert(!R()); + n=req(b,1,"","service:ndap.novell","DEFAULT","(&(svcname-ws=MARS_TREE.)(enabled-ws=true))","",1);assert(D()); + n=req(b,1,"","service:ndap.novell","DEFAULT","(svcname-ws=OTHER)","",1);assert(!D()); + n=req(b,1,"","service:ndap.novell","OTHER","","",1);assert(!D()); + n=req(b,1,"192.168.1.42","service:ndap.novell","DEFAULT","","",1);assert(!D()); + n=req(b,6,"","service:ndap.novell:///MARS_TREE.","DEFAULT","svcaddr-ws,svcname-ws","",0);r=D();assert(r>20&&has(out,r,"(svcaddr-ws=2-1-6-C0A8012A020C0000000000000000)")&&has(out,r,"(svcname-ws=MARS_TREE.)")); + n=req(b,1,"","service:bindery.novell","DEFAULT","","",1);r=D();assert(r&&has(out,r,"service:bindery.novell:///MARS_PCAP")&&!has(out,r,"ndap")); + uint8_t q[4]={0,3,2,0x78},node[6]={0,0,0,0,0,1};uint32_t net=htonl(0x12345678); + assert(nds_sap_reply(q,4,out,sizeof out,"MARS_TREE",net,node)==66); + assert(get16(out)==4&&get16(out+2)==0x278&&!memcmp(out+4,"MARS_TREE",9)&&get32(out+52)==0x12345678&&!memcmp(out+56,node,6)&&get16(out+62)==0x451&&get16(out+64)==1); + for(size_t j=13;j<36;j++)assert(out[j]=='_'); + q[1]=1;assert(nds_sap_reply(q,4,out,sizeof out,"MARS_TREE",net,node)==66&&get16(out)==2); + assert(!nds_sap_reply(q,4,out,65,"MARS_TREE",net,node));assert(!nds_sap_reply(q,3,out,sizeof out,"MARS_TREE",net,node));assert(!nds_sap_reply(q,4,out,sizeof out,"MARS_TREE_",net,node));q[3]=4;assert(!nds_sap_reply(q,4,out,sizeof out,"MARS_TREE",net,node)); + puts("PASS optional NDAP root URL/attributes, scope, filters, unchanged bindery and NDS SAP query encoding"); + srand(123);for(int i=0;i<100000;i++){n=rand()%sizeof b;for(size_t j=0;jtask, ncprequest->sequence, + requestdata, requestlen < 0 ? 0 : (size_t)requestlen, + responsedata, sizeof(ipxdata)-sizeof(NCPRESPONSE), &nds_used); + data_len = (int)nds_used; + break; + } +''' +if known_stub: + s=s.replace(stub,hook,1) +else: + s=s[:start]+hook+s[start:] +p.write_text('#include "mars_nds_server.h"\n'+s, encoding="latin-1") diff --git a/websetup/app.js b/websetup/app.js index 5ecf7b7..123499c 100644 --- a/websetup/app.js +++ b/websetup/app.js @@ -248,10 +248,10 @@ function dirFields(){if(!directoryDraft)return;directoryDraft.tree=$('directoryT function dirErrors(){if(!directoryDraft)return ['Verzeichnis zuerst laden.'];dirFields();const d=directoryDraft,e=[];if(!dirLabel.test(d.tree)||!dirLabel.test(d.organization))e.push('Baumname und Organisation: 1–47 zulässige Zeichen.');if(d.units.length>128)e.push('Maximal 128 Organisationseinheiten.');const u=new Set(d.units);if(u.size!==d.units.length)e.push('Doppelte Organisationseinheiten entfernen.');for(const p of u){const parts=p.split('/');if(p.length>191||parts.length>8||!parts.every(x=>dirLabel.test(x)))e.push('Ungültiger OU-Pfad: '+p);if(parts.length>1&&!u.has(parts.slice(0,-1).join('/')))e.push('Übergeordnete OU fehlt: '+p);}for(const p of d.placements)if(p.unit&&!u.has(p.unit))e.push('Zuordnung verweist auf fehlende OU: '+p.name+' → '+p.unit);if(d.placements.length>1024)e.push('Maximal 1024 Zuordnungen.');return e;} function dirMessage(t){$('directoryMessage').textContent=t||'';} function dirText(parent,tag,t,cls){const n=document.createElement(tag);n.textContent=t;if(cls)n.className=cls;parent.append(n);return n;} -function dirChecks(){const r=directoryData,el=$('directoryChecks');el.replaceChildren();function check(ok,title,detail){const b=document.createElement('div');b.className='message '+(ok?'ok':'warning');dirText(b,'strong',(ok?'OK · ':'Prüfen · ')+title);dirText(b,'p',detail);el.append(b);}check(!r.validation.errors.length,'Gespeicherte Serverkonfiguration',r.validation.errors.join('\n')||'Grundprüfung bestanden.');if(r.validation.warnings.length)check(false,'Konfigurationshinweise',r.validation.warnings.join('\n'));check(r.runningConfigMatches,'Laufende Konfiguration',r.runningConfigMatches?'Dateiserver verwendet die gespeicherte Konfiguration.':'Server starten oder gespeicherte Änderungen nach Prüfung anwenden.');check(r.liveAvailable,'Live-Bindery',r.liveAvailable?r.objects.length+' Objekte gefunden.':r.liveError);if(r.liveAvailable&&!r.liveComplete)check(false,'Objektliste begrenzt','Nicht alle Objekte konnten gelesen werden. Fehlende Zuordnungen sind nicht sicher prüfbar.');if(r.missing.length)check(false,'Nicht mehr gefundene Objekte',r.missing.map(x=>x.name).join(', '));check(true,'Betriebsmodus: NetWare 3.x / Bindery','Aktiver Protokollmodus.');check(false,'Betriebsmodus: NetWare 4.x / NDS','Noch nicht verfügbar; keine SAP-Baumankündigung. Tree und Context am Client leer lassen.');if(r.identityStatus){const i=r.identityStatus;check(i.wrappedBindery&&!i.databaseError&&i.liveComplete,'SQLite-Benutzerverwaltung',i.databaseError||(i.wrappedBindery?(i.databaseAvailable?'Identitätsdatenbank lesbar.':'Datenbank wird bei erster Benutzeranlage erstellt.'):'Upstream-Build mit SQLite erforderlich.'));if(!i.liveComplete)check(false,'Benutzerabgleich nicht vollständig','Dateiserver und Live-Bindery starten. Erst danach Konten anlegen.');for(const issue of i.issues||[])check(false,issue.name,issue.detail);}dirText(el,'p','Die lokale Prüfung ersetzt keinen Login-Test am Retro-PC.','hint');} +function dirChecks(){const r=directoryData,el=$('directoryChecks');el.replaceChildren();function check(ok,title,detail){const b=document.createElement('div');b.className='message '+(ok?'ok':'warning');dirText(b,'strong',(ok?'OK · ':'Prüfen · ')+title);dirText(b,'p',detail);el.append(b);}check(!r.validation.errors.length,'Gespeicherte Serverkonfiguration',r.validation.errors.join('\n')||'Grundprüfung bestanden.');if(r.validation.warnings.length)check(false,'Konfigurationshinweise',r.validation.warnings.join('\n'));check(r.runningConfigMatches,'Laufende Konfiguration',r.runningConfigMatches?'Dateiserver verwendet die gespeicherte Konfiguration.':'Server starten oder gespeicherte Änderungen nach Prüfung anwenden.');check(r.liveAvailable,'Live-Bindery',r.liveAvailable?r.objects.length+' Objekte gefunden.':r.liveError);if(r.liveAvailable&&!r.liveComplete)check(false,'Objektliste begrenzt','Nicht alle Objekte konnten gelesen werden. Fehlende Zuordnungen sind nicht sicher prüfbar.');if(r.missing.length)check(false,'Nicht mehr gefundene Objekte',r.missing.map(x=>x.name).join(', '));check(true,'Betriebsmodus: NetWare 3.x / Bindery','Aktiver Protokollmodus.');check(false,'Betriebsmodus: NetWare 4.x / NDS','Keine native NDS-Anmeldung. Optionale Labor-Baumerkennung ist kein Login; für den normalen Betrieb Tree und Context leer lassen.');if(r.identityStatus){const i=r.identityStatus;check(i.wrappedBindery&&!i.databaseError&&i.liveComplete,'SQLite-Benutzerverwaltung',i.databaseError||(i.wrappedBindery?(i.databaseAvailable?'Identitätsdatenbank lesbar.':'Datenbank wird bei erster Benutzeranlage erstellt.'):'Upstream-Build mit SQLite erforderlich.'));if(!i.liveComplete)check(false,'Benutzerabgleich nicht vollständig','Dateiserver und Live-Bindery starten. Erst danach Konten anlegen.');for(const issue of i.issues||[])check(false,issue.name,issue.detail);}dirText(el,'p','Die lokale Prüfung ersetzt keinen Login-Test am Retro-PC.','hint');} function dirObjects(){const d=directoryDraft,el=$('directoryObjects'),q=$('directoryFilter').value.toUpperCase();el.replaceChildren();const current=directoryData.objects.filter(o=>[1,2].includes(o.type));const list=current.map(o=>({...o,live:true}));for(const p of d.placements)if(!current.some(o=>o.type===p.type&&o.name===p.name))list.push({...p,live:false});$('directoryObjectHint').textContent=directoryData.liveAvailable?'Live-Objekte; gespeicherte, nicht gelistete Zuordnungen bleiben erhalten.':'Live-Bindery nicht erreichbar. Nur gespeicherte Zuordnungen sichtbar.';for(const o of list.filter(o=>o.name.toUpperCase().includes(q))){const tr=document.createElement('tr');dirText(tr,'td',o.name+(o.live?'':' (nicht gelistet)'));dirText(tr,'td',(o.type===1?'Benutzer':'Gruppe')+(o.unix?' · '+o.unix:''));const td=document.createElement('td'),sel=document.createElement('select');sel.setAttribute('aria-label','OU für '+o.name);option(sel,'~','Nicht zugeordnet');option(sel,'','Organisation (Wurzel)');for(const u of d.units)option(sel,u,u);const prior=d.placements.find(p=>p.name===o.name&&p.type===o.type);if(prior&&!d.units.includes(prior.unit)&&prior.unit)option(sel,prior.unit,prior.unit+' (fehlt)');sel.value=prior?prior.unit:'~';sel.onchange=()=>{d.placements=d.placements.filter(p=>!(p.name===o.name&&p.type===o.type));if(sel.value!=='~')d.placements.push({name:o.name,type:o.type,unit:sel.value});directoryDirty=true;};td.append(sel);tr.append(td);el.append(tr);}} function dirClientText(){const r=directoryData,d=directoryDraft;return ['MARS NWE – Client-Einrichtung (Bindery)','Server: '+(r.servers[0]||'NICHT KONFIGURIERT'),'Protokoll: IPX/SPX (nativ, nicht Compatibility Mode)','Tree / Baum: leer lassen','Context / Kontext: leer lassen','Benutzer: vorhandener NetWare-Benutzer; NetWare-Kennwort verwenden.','Externes IPX-Netz / Interface / Frame / Ticks:',...r.networks,'Frame-Typ passend zum physischen Netzwerk des Clients einstellen.','Windows XP: Novell Client, Custom Installation, Bindery-Anmeldung.','Test: Server suchen, direkt anmelden, SYS öffnen, Dateirechte prüfen.','Verwaltungsbaum (nur MARS-Webfrontend): '+d.tree+' / O='+d.organization,'Kein NDAP / keine echte NDS-Anmeldung.','Keine Kennwörter in dieser Datei.'].join('\r\n');} -function dirReview(){const e=dirErrors(),el=$('directoryReview');el.replaceChildren();for(const t of e)dirText(el,'p',t,'message error');dirText(el,'p',e.length?'Entwurf korrigieren.':'Verzeichnisentwurf formal gültig.','message '+(e.length?'warning':'ok'));if(directoryData.validation.errors.length)dirText(el,'p','Serverkonfiguration hat Fehler. Der Verwaltungsbaum kann dennoch gespeichert werden; keine Client-Betriebsfreigabe.','message warning');const d=directoryDraft,r=directoryData,lines=[d.tree,' O='+d.organization];const show=(unit,depth)=>{const indent=' '.repeat(depth);for(const p of d.placements.filter(x=>x.unit===unit))lines.push(indent+'CN='+p.name+' ('+(p.type===1?'Benutzer':'Gruppe')+')');for(const u of d.units.filter(x=>x.includes('/')?x.slice(0,x.lastIndexOf('/'))===unit:unit==='').sort()){lines.push(indent+'OU='+u.split('/').at(-1));if(depth<11)show(u,depth+1);}};show('',2);lines.push(' Server (aus nwserv.conf):',...r.servers.map(x=>' '+x),' Volumes (aus nwserv.conf):',...r.volumes.map(x=>' '+x.split(/\s+/)[0]));$('directoryPreview').textContent=lines.join('\n');$('directoryClient').value=dirClientText();$('directorySave').disabled=!!e.length;} +function dirReview(){const e=dirErrors(),el=$('directoryReview');el.replaceChildren();for(const t of e)dirText(el,'p',t,'message error');dirText(el,'p',e.length?'Entwurf korrigieren.':'Verzeichnisentwurf formal gültig.','message '+(e.length?'warning':'ok'));if(directoryData.validation.errors.length)dirText(el,'p','Serverkonfiguration hat Fehler. Der Verwaltungsbaum kann dennoch gespeichert werden; keine Client-Betriebsfreigabe.','message warning');const d=directoryDraft,r=directoryData,lines=[d.tree,' O='+d.organization];dirText(el,'p',d.tree.length>32?'NDS-Labor: Baumname auf höchstens 32 Zeichen kürzen.':'NDS-Labor (optional): gespeicherten Entwurf auf dem Server mit ./nds-lab.sh check prüfen; danach sudo ./nds-lab.sh enable und Dienst neu starten. Nur öffentliche Container; keine NDS-Anmeldung. Optional im isolierten Testnetz: sudo ./nds-lab.sh enable --discovery --resources --read-ops (Baumerkennung, Server/Volumes und experimentelle NDAP-Leseoperationen des öffentlichen Snapshots; keine Anmeldung); danach Dienst neu starten. TCP/IP und SLP müssen separat aktiviert sein.','message warning');const show=(unit,depth)=>{const indent=' '.repeat(depth);for(const p of d.placements.filter(x=>x.unit===unit))lines.push(indent+'CN='+p.name+' ('+(p.type===1?'Benutzer':'Gruppe')+')');for(const u of d.units.filter(x=>x.includes('/')?x.slice(0,x.lastIndexOf('/'))===unit:unit==='').sort()){lines.push(indent+'OU='+u.split('/').at(-1));if(depth<11)show(u,depth+1);}};show('',2);lines.push(' Server (aus nwserv.conf):',...r.servers.map(x=>' '+x),' Volumes (aus nwserv.conf):',...r.volumes.map(x=>' '+x.split(/\s+/)[0]));$('directoryPreview').textContent=lines.join('\n');$('directoryClient').value=dirClientText();$('directorySave').disabled=!!e.length;} function dirShow(n){directoryStep=n;for(let i=0;i<4;i++)$('directoryStep'+i).hidden=i!==n;$('directoryStepLabel').textContent='SCHRITT '+(n+1)+' / 4';$('directoryBack').hidden=n===0;$('directoryNext').hidden=n===3;dirMessage('');if(n===0)dirChecks();if(n===2)dirObjects();if(n===3)dirReview();} async function dirLoad(){if(directoryBusy)return false;directoryBusy=true;try{directoryData=await api('/api/directory');try{directoryData.identityStatus=await api('/api/identities');}catch(e){directoryData.identityStatus={wrappedBindery:false,databaseError:e.message};}directoryDraft=JSON.parse(JSON.stringify(directoryData.config));$('directoryTree').value=directoryDraft.tree;$('directoryOrg').value=directoryDraft.organization;$('directoryUnits').value=directoryDraft.units.join('\n');$('directoryFilter').value='';directoryDirty=false;dirShow(0);return true;}catch(e){directoryData=null;directoryDraft=null;dirMessage(e.message+' – Bitte erneut laden.');$('directoryNext').disabled=true;$('directorySave').disabled=true;return false;}finally{directoryBusy=false;if(directoryDraft)$('directoryNext').disabled=false;}} async function dirOpen(){if(!state||busy)return;if(state.defaultPassword){notice('Zuerst Web-Kennwort ändern.','error');return;}if(!$('directoryDialog').open)$('directoryDialog').showModal();await dirLoad();} @@ -293,11 +293,26 @@ $('directorySuggest').onclick=async()=>{ // Optional NCP/TCP transport. No NDS claim; settings apply on restart. let ncpIpData=null,ncpIpBusy=false,ncpIpDirty=false; -function ncpIpControls(){const ok=!!ncpIpData&&!ncpIpBusy;$('ncpIpEnabled').disabled=!ok;$('ncpIpAddress').disabled=!ok||!$('ncpIpEnabled').checked;$('ncpIpSlp').disabled=!ok||!$('ncpIpEnabled').checked;$('ncpIpSave').disabled=!ok||!ncpIpDirty;$('ncpIpRestart').disabled=!ok||ncpIpDirty||dirty;$('ncpIpRefresh').disabled=ncpIpBusy;} -async function ncpIpLoad(){if(ncpIpBusy)return;ncpIpBusy=true;ncpIpData=null;ncpIpControls();try{const r=await api('/api/ncp-ip');const sel=$('ncpIpAddress');sel.replaceChildren();for(const a of r.addresses){const o=document.createElement('option');o.value=a.address;o.textContent=a.interface+' — '+a.address+(a.address.startsWith('127.')?' (nur lokaler Test)':'');sel.append(o);}const cfg=r.config||{};if(cfg.address&&!r.addresses.some(a=>a.address===cfg.address)){const o=document.createElement('option');o.value=cfg.address;o.textContent=cfg.address+' (nicht verfügbar)';sel.append(o);}if(cfg.address)sel.value=cfg.address;else{const a=r.addresses.find(a=>!a.address.startsWith('127.'));if(a)sel.value=a.address;}$('ncpIpEnabled').checked=!!cfg.enabled;$('ncpIpSlp').checked=!!cfg.slp;$('ncpIpStatus').textContent=r.runtime;const lines=String(r.runtime||'').split('\n');const slp=lines.find(x=>x.startsWith('SLP='))||'';const seen=Number((lines.find(x=>x.startsWith('NDS-Requests-IPX='))||'0').split('=').pop())+Number((lines.find(x=>x.startsWith('NDS-Requests-TCP='))||'0').split('=').pop());$('ncpIpDiagnosis').textContent=(slp.includes('active')?'Servererkennung aktiv (nur Bindery). ':slp.includes('failed')?'SLP nicht verfügbar: UDP-Port 427 / Netzwerkkarte prüfen. ':slp.includes('waiting')?'SLP wartet auf die lokale Serverankündigung. ':'')+(seen>0?'NDS-Anfragen erkannt, NDS-Anmeldung noch nicht unterstützt. Baum und Kontext leer lassen.':'Eine erreichbare Verbindung bestätigt noch keine Anmeldung.');$('ncpIpMessage').textContent=r.valid?'Einstellung geladen. Änderungen werden nach Neustart wirksam.':'Gespeicherte Adresse ist nicht mehr gültig. Neue Adresse auswählen oder deaktivieren.';ncpIpData=r;ncpIpDirty=false;}catch(e){$('ncpIpMessage').textContent=e.message;$('ncpIpStatus').textContent='Nicht geladen';$('ncpIpDiagnosis').textContent='Status nicht verfügbar.';}finally{ncpIpBusy=false;ncpIpControls();}} +function ncpIpControls(){const ok=!!ncpIpData&&!ncpIpBusy;$('ncpPresetIpx').disabled=!ok;$('ncpPresetIp').disabled=!ok;$('ncpIpEnabled').disabled=!ok;$('ncpIpAddress').disabled=!ok||!$('ncpIpEnabled').checked;$('ncpIpSlp').disabled=!ok||!$('ncpIpEnabled').checked;$('ncpIpSave').disabled=!ok||!ncpIpDirty;$('ncpIpRestart').disabled=!ok||ncpIpDirty||dirty;$('ncpIpRefresh').disabled=ncpIpBusy;} +async function ncpIpLoad(){if(ncpIpBusy)return;ncpIpBusy=true;ncpIpData=null;ncpIpControls();try{const r=await api('/api/ncp-ip');const sel=$('ncpIpAddress');sel.replaceChildren();for(const a of r.addresses){const o=document.createElement('option');o.value=a.address;o.textContent=a.interface+' — '+a.address+(a.address.startsWith('127.')?' (nur lokaler Test)':'');sel.append(o);}const cfg=r.config||{};if(cfg.address&&!r.addresses.some(a=>a.address===cfg.address)){const o=document.createElement('option');o.value=cfg.address;o.textContent=cfg.address+' (nicht verfügbar)';sel.append(o);}if(cfg.address)sel.value=cfg.address;else{const a=r.addresses.find(a=>!a.address.startsWith('127.'));if(a)sel.value=a.address;}$('ncpIpEnabled').checked=!!cfg.enabled;$('ncpIpSlp').checked=!!cfg.slp;$('ncpIpStatus').textContent=r.runtime;const lines=String(r.runtime||'').split('\n');const slp=lines.find(x=>x.startsWith('SLP='))||'';const seen=Number((lines.find(x=>x.startsWith('NDS-Requests-IPX='))||'0').split('=').pop())+Number((lines.find(x=>x.startsWith('NDS-Requests-TCP='))||'0').split('=').pop());$('ncpIpDiagnosis').textContent=(slp.includes('active')?(slp.includes('NDAP')?'Server- und NDS-Baumerkennung aktiv (Labor, keine Anmeldung). ':'Servererkennung aktiv (nur Bindery). '):slp.includes('failed')?'SLP nicht verfügbar: UDP-Port 427 / Netzwerkkarte prüfen. ':slp.includes('waiting')?'SLP wartet auf die lokale Serverankündigung. ':'')+(seen>0?'NDS-Anfragen erkannt, NDS-Anmeldung noch nicht unterstützt. Baum und Kontext leer lassen.':'Eine erreichbare Verbindung bestätigt noch keine Anmeldung.');$('ncpIpMessage').textContent=r.valid?'Einstellung geladen. Änderungen werden nach Neustart wirksam.':'Gespeicherte Adresse ist nicht mehr gültig. Neue Adresse auswählen oder deaktivieren.';ncpIpData=r;ncpIpDirty=false;}catch(e){$('ncpIpMessage').textContent=e.message;$('ncpIpStatus').textContent='Nicht geladen';$('ncpIpDiagnosis').textContent='Status nicht verfügbar.';}finally{ncpIpBusy=false;ncpIpControls();}} async function ncpIpOpen(){if(!state||busy)return;if(state.defaultPassword){notice('Zuerst Web-Kennwort ändern.','error');return;}$('ncpIpDialog').showModal();await ncpIpLoad();} function ncpIpClose(){if(ncpIpBusy)return;if(ncpIpDirty&&!confirm('Ungespeicherte TCP/IP-Einstellungen verwerfen?'))return;ncpIpDirty=false;$('ncpIpDialog').close();} $('ncpIpNav').onclick=$('ncpIpOpen').onclick=ncpIpOpen;$('ncpIpClose').onclick=ncpIpClose;$('ncpIpDialog').addEventListener('cancel',e=>{e.preventDefault();ncpIpClose();}); $('ncpIpRefresh').onclick=()=>{if(!ncpIpDirty||confirm('Entwurf verwerfen?'))ncpIpLoad();};for(const id of ['ncpIpEnabled','ncpIpAddress','ncpIpSlp'])$(id).onchange=()=>{ncpIpDirty=true;ncpIpControls();}; $('ncpIpForm').onsubmit=async e=>{e.preventDefault();if(!ncpIpData||ncpIpBusy)return;const enabled=$('ncpIpEnabled').checked,address=$('ncpIpAddress').value;if(enabled&&!ncpIpData.addresses.some(a=>a.address===address)){$('ncpIpMessage').textContent='Bitte eine verfügbare private Adresse auswählen.';return;}if(enabled&&!confirm('Experimentellen TCP/IP-Listener im isolierten Retro-LAN aktivieren?'))return;ncpIpBusy=true;ncpIpControls();try{await api('/api/ncp-ip',{revision:ncpIpData.revision,confirm:true,config:{enabled,address,slp:enabled&&$('ncpIpSlp').checked}});ncpIpDirty=false;}catch(e){$('ncpIpMessage').textContent=e.message;return;}finally{ncpIpBusy=false;ncpIpControls();}await ncpIpLoad();}; $('ncpIpRestart').onclick=async()=>{if(ncpIpDirty||dirty||ncpIpBusy||!ncpIpData)return;if(!confirm('NetWare neu starten? Aktive Clients werden getrennt.'))return;ncpIpBusy=true;ncpIpControls();try{await api('/api/service',{revision:state.revision,action:'restart',confirm:true});$('ncpIpMessage').textContent='Neustart angefordert. Nach einigen Sekunden Status neu laden.';}catch(e){$('ncpIpMessage').textContent=e.message;}finally{ncpIpBusy=false;ncpIpControls();}}; + +// Assisted presets only modify the draft; save/restart remain explicit actions. +function ncpIpPreset(useIp){ + if(!ncpIpData||ncpIpBusy)return; + if(useIp){ + const choices=ncpIpData.addresses.filter(a=>!a.address.startsWith('127.')); + if(!choices.length){$('ncpIpMessage').textContent='Keine Retro-LAN-Adresse gefunden. Netzwerkkarte verbinden und Neu laden wählen.';return;} + if(!choices.some(a=>a.address===$('ncpIpAddress').value))$('ncpIpAddress').value=choices[0].address; + } + $('ncpIpEnabled').checked=useIp;$('ncpIpSlp').checked=useIp; + ncpIpDirty=true;ncpIpControls(); + $('ncpIpMessage').textContent=useIp?'Vorschlag vorbereitet. Netzwerkkarte prüfen, speichern und danach neu starten.':'IPX-Betrieb vorbereitet. Speichern und danach neu starten; TCP/IP und SLP werden abgeschaltet.'; +} +$('ncpPresetIpx').onclick=()=>ncpIpPreset(false); +$('ncpPresetIp').onclick=()=>ncpIpPreset(true); diff --git a/websetup/index.html b/websetup/index.html index fea6f38..4d88052 100644 --- a/websetup/index.html +++ b/websetup/index.html @@ -25,12 +25,14 @@ T:\SETUP.BAT T:\DHCP.EXE

MAP gehört ins NetWare-Login-Skript; SETUP.BAT und DHCP.EXE werden an der DOS-Eingabeaufforderung ausgeführt. Kein gemeinsam beschreibbares MTCP.CFG.

Windows-Clientsoftware

Windows 95, 98, ME, NT 4.0, 2000 und XP (Entwicklungsvorschau).

Laufzeitstatus

–

Linux muss IPv4-Forwarding explizit erlauben; siehe Gateway-Guide. Änderungen werden erst beim Neustart der NetWare-Kindprozesse aktiv.

Windows-Treiber und Installation

1. Lokal vorbereiten

Passendes ZIP herunterladen, komplett in einen lokalen Ordner entpacken. Vor Treibertests einen VM-Snapshot anlegen. IPX muss an der physischen Netzwerkkarte eingerichtet sein.

2. Windows 95 / 98 / ME

Im Paketordner INSTALL.BAT starten. Der enthaltene Original-WinPcap-3.1-Installer führt durch die Installation. Danach über „Neue Hardware / Datenträger“ MARSNET.INF auswählen. Keine automatische Änderung vorhandener Netzwerkbindungen.

3. Windows NT 4.0

INSTALL.BAT startet WinPcap. Vor der Adapterinstallation in OEMSETUP.INF unter [FileConstants] NetworkAddress auf die echte physische IPX-Node setzen: 12 Hexzeichen ohne Trennzeichen. Danach Netzwerk → Netzwerkkarten → Hinzufügen → Diskette. Details: NT4-INSTALL.txt.

4. Windows 2000 / XP

Hardware-Assistent → Netzwerkadapter → Datenträger → MARSNDIS.INF. Eigener NDIS5-Treiber; WinPcap ist für diesen Pfad nicht erforderlich. NetworkAddress auf die physische IPX-Node setzen.

5. Netzwerk und Start

TCP/IP an den virtuellen Adapter binden, IPX auf der physischen Karte belassen. Neustarten, Client im Gateway freigeben und DHCP erneuern. GATEWAY.INI muss die Werte des eigenen Servers enthalten – keine Beispielwerte übernehmen. Die Bridge-Befehle stehen in der beigelegten WINDOWS.md und LEGACY-BUILD.md.

Als NetWare-Laufwerk bereitstellen

Freigegebene Betriebssysteme

Nach dem Speichern eines SYS-Volumes mit PUBLIC-Verzeichnis aktiviert diese Schaltfläche Downloads und die Laufwerkskopie. Alternativ auf dem VME-Server im Repository ausführen:

sudo ./install-driver-packages.py

Das Skript installiert die Web-ZIPs und legt eine versionierte, nicht überschreibende Kopie auf SYS:PUBLIC/DRIVERS an. Es gibt den konkreten MAP-Befehl aus, zum Beispiel:

MAP ROOT T:=SYS:PUBLIC/DRIVERS/<Release-ID>

Den Betriebssystemordner von T: zunächst auf die lokale Festplatte kopieren. Auf NetWare nur Lese-/Dateiscan-Rechte vergeben, keine Schreibrechte. Vorhandene Volumes und Freigaben bleiben unverändert.

MARS NWE · Administration
-
MARS NWE 0.9.1-4 · Setup Console · Nur für vertrauenswürdige Administratoren

Retro Browser

Aktive Sitzungen

RetroBrowser – Client-Token

Der Token wird beim erstmaligen Aktivieren automatisch erzeugt. Er bleibt beim Deaktivieren und Neustart erhalten. Ein neuer Token beendet aktive Sitzungen und macht den alten Schlüssel ungültig.

MARS · Verzeichnis & Einrichtungsassistent
-

Verzeichnis einrichten

Benutzer, Gruppen und Server an einem Ort organisieren und die Verbindung für alte Novell-Clients vorbereiten.

Kompatibilitätsmodus (Bindery)

Dieser Verwaltungsbaum ist kein echter NDS-Baum. Er erscheint nicht in der Tree-Auswahl des Novell Clients. Organisationseinheiten sind keine Zugriffsrechte. Anmeldung weiterhin direkt am Server.

-

1 · Server prüfen

Welchen Betriebsmodus kann ich verwenden?

NetWare 3.x / Bindery – verfügbar. Empfohlen für DOS und Windows; am Client direkt den Server auswählen.

NetWare 4.x / NDS – noch nicht verfügbar. Keine native Baumanmeldung; die folgenden Organisationseinheiten sind nur für die MARS-Verwaltung.

- +
MARS NWE 0.9.8 · Setup Console · Nur für vertrauenswürdige Administratoren

Retro Browser

Aktive Sitzungen

RetroBrowser – Client-Token

Der Token wird beim erstmaligen Aktivieren automatisch erzeugt. Er bleibt beim Deaktivieren und Neustart erhalten. Ein neuer Token beendet aktive Sitzungen und macht den alten Schlüssel ungültig.

MARS · Verzeichnis & Einrichtungsassistent
+

Verzeichnis einrichten

Benutzer, Gruppen und Server an einem Ort organisieren und die Verbindung für alte Novell-Clients vorbereiten.

Kompatibilitätsmodus (Bindery)

Dieser Verwaltungsbaum ist standardmäßig nicht im Netzwerk sichtbar. Eine optionale NDS-Labor-Baumerkennung kann auf dem Server aktiviert werden; die Anzeige im Originalclient ist noch nicht bestätigt. Organisationseinheiten sind keine Zugriffsrechte. Anmeldung weiterhin direkt am Server.

+

1 · Server prüfen

Welchen Betriebsmodus kann ich verwenden?

NetWare 3.x / Bindery – verfügbar. Empfohlen für DOS und Windows; am Client direkt den Server auswählen.

NetWare 4.x / NDS – experimentelle Baumerkennung, Namensauflösung und optionale Leseoperationen, keine native Baumanmeldung.

Begriffe und NDS-Labor einfach erklärt

Bindery bedeutet: direkt am Server anmelden. Das ist der empfohlene Weg für Dateien und Laufwerke. Baum, Organisation und OU sind zunächst nur Ordnungshilfen; eine OU ist eine Abteilung, keine Zugriffsberechtigung.

  1. Mit „Server prüfen“ beginnen und vorhandene Fehler beheben.
  2. Baum und Organisation benennen, bei Bedarf Abteilungen ergänzen.
  3. Benutzer zuordnen und den Entwurf prüfen und speichern. Vorhandene Dateirechte bleiben unverändert.
  4. Die Client-Anleitung herunterladen und zuerst die direkte Serveranmeldung testen.

Optional: NDS-Labor für Fortgeschrittene

0.9.8 kann einen getrennten, schreibgeschützten Verzeichnis-Schnappschuss anbieten. Er ist eine Momentaufnahme, keine automatische Synchronisierung. Baumerkennung und Lesen sind keine Anmeldung; Dateien werden dadurch nicht freigegeben.

Das Labor bleibt aus. Nur auf einem isolierten Testnetz aktivieren. Benutzer- und Gruppennamen werden standardmäßig nicht veröffentlicht. Für den normalen Betrieb ist dieser Schritt nicht erforderlich.

Nach Speichern des Verwaltungsbaums im Projektverzeichnis zuerst prüfen:

sudo ./nds-lab.sh check --discovery --resources

Erst nach erfolgreicher Prüfung und mit einem NDS-Labor-Build:

sudo ./nds-lab.sh enable --discovery --resources --read-ops
+sudo systemctl restart mars_vme.service

Der Neustart trennt Clients. Zum Abschalten:

sudo ./nds-lab.sh disable
+sudo systemctl restart mars_vme.service

Nach Änderungen am Verwaltungsbaum den Schnappschuss erneut vorbereiten. Details und Grenzen: RELEASE-0.9.8-NDS-WIRE-DE.md im Quellpaket.

+

-
NetWare über TCP/IP

Verbindung einrichten

Testbetrieb: NCP über TCP-Port 524. Keine bestätigte Anmeldung mit Novell Client. NDS-Baum und Paketsignierung fehlen. Optionale SLPv2-Servererkennung im Testbetrieb. Nur im isolierten Retro-LAN verwenden. IPX bleibt aktiv.

Optional: UDP 427, Scope DEFAULT, nur lokales Retro-Netz. Es wird ausschließlich der echte Bindery-Server angekündigt, kein NDS-Baum.

Wähle die private Adresse im Netzwerk deiner Retro-PCs. Nur Clients im zugehörigen Subnetz sind zugelassen. Port 524 ist fest vorgegeben.

Laufzeit und Diagnose

Noch nicht geprüft.

Noch nicht geladen

Client testen

Windows XP: TCP/IP im Novell Client auswählen, SLP Scope DEFAULT verwenden oder Serveradresse manuell eintragen; Baum und Kontext leer lassen. Der Transport ist experimentell. Port erreichbar bedeutet nicht, dass die Anmeldung funktioniert.

+
NetWare über TCP/IP

Verbindung einrichten

Testbetrieb: NCP über TCP-Port 524. Keine bestätigte Anmeldung mit Novell Client. NDS-Anmeldung und Paketsignierung fehlen. Optionale SLPv2-Server- und NDS-Labor-Baumerkennung. Nur im isolierten Retro-LAN verwenden. IPX bleibt aktiv.

Einrichtung in drei Schritten

  1. Verbindungsart wählen. DOS und ältere PCs verwenden normalerweise IPX. TCP/IP ist für passende Novell-Clients gedacht, nicht für die Windows-Netzwerkumgebung.
  2. Bei TCP/IP die Adresse der Netzwerkkarte zum Retro-PC auswählen. Bei mehreren Karten unten bewusst auswählen. Die Vorauswahl ist nur ein Vorschlag.
  3. Einstellung speichern, anschließend „Neu starten / anwenden“. Danach am Client direkt mit Servername oder IP anmelden; Baum und Kontext leer lassen.

Diese Schaltflächen ändern nur den Entwurf. Es wird nichts automatisch gespeichert oder neu gestartet. IPX bleibt auch mit TCP/IP verfügbar.

Der Server wird nicht gefunden – was tun?

Novell Client installieren; MARS erscheint nicht als normale Windows-SMB-Freigabe. Zuerst die IP-Adresse direkt im Novell Client probieren. Bei einer VM das passende Netzwerk (normalerweise Netzwerkbrücke) prüfen. Für automatische Suche SLP aktivieren, Scope DEFAULT verwenden und UDP 427 im Retro-LAN zulassen; TCP 524 ist für die Verbindung nötig. Keine Internetfreigabe einrichten. Ein offener Port bestätigt noch keinen erfolgreichen Login.

Optional: UDP 427, Scope DEFAULT, nur lokales Retro-Netz. Standardmäßig nur Bindery; mit separat aktivierter NDS-Labor-Discovery zusätzlich der konfigurierte Baum.

Wähle die private Adresse im Netzwerk deiner Retro-PCs. Nur Clients im zugehörigen Subnetz sind zugelassen. Port 524 ist fest vorgegeben.

Laufzeit und Diagnose

Noch nicht geprüft.

Noch nicht geladen

Client testen

Windows XP: TCP/IP im Novell Client auswählen, SLP Scope DEFAULT verwenden oder Serveradresse manuell eintragen; Baum und Kontext leer lassen. Der Transport ist experimentell. Port erreichbar bedeutet nicht, dass die Anmeldung funktioniert.