From 13737d03c31d4a3721bcce9a5a07761dd88f136e Mon Sep 17 00:00:00 2001 From: Mario Fetka Date: Sat, 30 May 2026 01:25:55 +0200 Subject: [PATCH] build: add optional Netatalk libatalk backend hook Add an opt-in CMake hook for Netatalk/libatalk and a small nwconn-side helper layer for future AFP/Mac namespace work. NetWare AFP NCP 0x23 calls still have to be decoded and answered by MARS-NWE; libatalk is not used as an afpd proxy. Instead, expose local helper wrappers that can read AppleDouble/Finder Info metadata and resource-fork sizes from a backing Unix path when libatalk is available. The WebSDK documents the AFP calls as NetWare server entry points for Mac namespace semantics, and the SDK headers expose probes such as NWAFPSupported() plus AFP entry-id and file-information calls. Those calls require AFP entry IDs, Finder Info, resource forks, and per-volume Mac namespace state before MARS-NWE can return success. Keep NCP 0x23 returning invalid namespace for now, but record whether the libatalk metadata backend was compiled in when rejecting AFP calls. Update TODO.md to track the remaining NetWare AFP implementation work on top of the new backend hook. This adds build-time integration and local metadata helpers only; it does not change AFP protocol behavior. --- CMakeLists.txt | 18 ++++++++++++++++++ TODO.md | 22 ++++++++++++++++++++++ include/config.h.cmake | 2 ++ src/CMakeLists.txt | 6 +++++- src/nwconn.c | 16 ++++++++++++++++ 5 files changed, 63 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7509126..069cd84 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,6 +74,7 @@ option(ENABLE_INTERNAL_RIP_SAP "Should we build Mars Nwe with Internal Router?" option(ENABLE_SHADOW_PWD "Should we build Mars Nwe with Shadow Password Support?" ON) option(ENABLE_QUOTA_SUPPORT "Should we build Mars Nwe with Quota Support?" ON) option(ENABLE_XATTR "Should we build Mars Nwe with extended attribute support?" ON) +option(ENABLE_NETATALK_LIBATALK "Enable optional Netatalk/libatalk AFP metadata backend" OFF) option(MARS_NWE_INSTALL_DOSUTILS "Install DOS client utilities" ON) option(MARS_NWE_INSTALL_NEW_DOSUTILS "Install the new/experimental DOS client utilities instead of legacy netold.exe" OFF) option(MARS_NWE_BUILD_DOSUTILS "Build DOS client utilities with Open Watcom" OFF) @@ -150,6 +151,13 @@ ELSE (ENABLE_XATTR AND XATTR_FOUND) SET (MARS_NWE_XATTR_SUPPORT "0") ENDIF (ENABLE_XATTR AND XATTR_FOUND) +find_package(Netatalk QUIET) +IF (ENABLE_NETATALK_LIBATALK AND NETATALK_FOUND) + SET (MARS_NWE_NETATALK_SUPPORT "1") +ELSE (ENABLE_NETATALK_LIBATALK AND NETATALK_FOUND) + SET (MARS_NWE_NETATALK_SUPPORT "0") +ENDIF (ENABLE_NETATALK_LIBATALK AND NETATALK_FOUND) + IF (NOT MAX_CONNECTIONS) SET (MAX_CONNECTIONS "50") ENDIF (NOT MAX_CONNECTIONS) @@ -185,6 +193,16 @@ else() message(STATUS "XAttr support: disabled") endif() +if(MARS_NWE_NETATALK_SUPPORT) + message(STATUS "Netatalk/libatalk AFP metadata backend: enabled") +else() + if(ENABLE_NETATALK_LIBATALK) + message(STATUS "Netatalk/libatalk AFP metadata backend: disabled (headers/library not found)") + else() + message(STATUS "Netatalk/libatalk AFP metadata backend: disabled") + endif() +endif() + # we want to use systemd, if possible set(SYSTEMD_SERVICES_INSTALL_DIR "" CACHE PATH "Directory for systemd service files") INCLUDE(${CMAKE_MODULE_PATH}/systemdservice.cmake) diff --git a/TODO.md b/TODO.md index b4f5243..e00b0c3 100644 --- a/TODO.md +++ b/TODO.md @@ -186,6 +186,28 @@ Follow-up: the WebSDK TTS calls include begin/end/abort transaction, status, threshold, and control/statistics operations. +### AFP / Mac namespace backend + +Current status: + +- `NCP 0x23` AFP calls still return invalid namespace. +- Optional build-time detection/linking for Netatalk/libatalk exists as a first + local metadata backend hook. It is deliberately not an AFP protocol + implementation yet. +- NetWare AFP calls are NCP entry points for Mac namespace semantics on a + NetWare volume, not transport-level AFP proxy calls to `afpd`. + +Follow-up: + +- Implement the NetWare AFP NCP calls locally, using libatalk helpers rather + than proxying requests to `afpd`. +- Candidate libatalk pieces include the new AppleDouble/Finder Info/resource + fork helper wrappers, plus future CNID/directory-id helpers, attribute + mapping, and filename conversion. +- Keep returning invalid namespace until MARS-NWE has a real per-volume Mac + namespace/AFP metadata layer. Do not return success for AFP calls without + data/resource fork and Finder Info semantics. + ## Deferred / optional protocol work * Basic Packet Burst file transfer support is implemented and verified with a diff --git a/include/config.h.cmake b/include/config.h.cmake index f70a8ec..fadce04 100644 --- a/include/config.h.cmake +++ b/include/config.h.cmake @@ -97,6 +97,8 @@ /* change to '1' for quota support */ #define XATTR_SUPPORT @MARS_NWE_XATTR_SUPPORT@ /* change to '1' for Linux xattr support */ +#define NETATALK_SUPPORT @MARS_NWE_NETATALK_SUPPORT@ + /* change to '1' for Netatalk/libatalk AFP metadata backend */ /* for sending 'Request being serviced' replys, /lenz */ #define CALL_NWCONN_OVER_SOCKET 0 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index eda9a4c..a48f5ca 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -60,7 +60,7 @@ ELSE(ENABLE_INTERNAL_RIP_SAP) ENDIF(ENABLE_INTERNAL_RIP_SAP) add_executable(nwserv nwserv.c net1.c tools.c ${EMUTLI} ${EMUTLI1} ${NWROUTE_0} ) -add_executable(nwconn nwconn.c net1.c tools.c connect.c namspace.c nwvolume.c nwfile.c unxfile.c nwqconn.c nameos2.c namedos.c nwfname.c nwshare.c extpipe.c nwattrib.c trustee.c nwarchive.c ${EMUTLI} ) +add_executable(nwconn nwconn.c net1.c tools.c connect.c namspace.c nwvolume.c nwfile.c unxfile.c nwqconn.c nameos2.c namedos.c nwfname.c nwshare.c extpipe.c nwattrib.c trustee.c nwarchive.c nwatalk.c ${EMUTLI} ) add_executable(ncpserv ncpserv.c net1.c tools.c ${EMUTLI} ) add_executable(nwclient nwclient.c net1.c tools.c ${EMUTLI} ) add_executable(nwbind nwbind.c net1.c tools.c nwdbm.c nwcrypt.c unxlog.c sema.c nwqueue.c unxfile.c ${EMUTLI} ) @@ -77,6 +77,10 @@ add_executable(ftrustee ftrustee.c tools.c nwfname.c unxfile.c nwvolume.c nwattr target_link_libraries(nwserv ${CRYPT_LIBRARIES} ) target_link_libraries(nwconn ${CRYPT_LIBRARIES} ${XATTR_LIBRARIES} ) +IF(MARS_NWE_NETATALK_SUPPORT) + target_include_directories(nwconn PRIVATE ${NETATALK_INCLUDE_DIRS}) + target_link_libraries(nwconn ${NETATALK_LIBRARIES}) +ENDIF(MARS_NWE_NETATALK_SUPPORT) target_link_libraries(ncpserv ${CRYPT_LIBRARIES} ) target_link_libraries(nwclient ${CRYPT_LIBRARIES} ) target_link_libraries(nwbind ${CRYPT_LIBRARIES} ${GDBM_LIBRARIES} ) diff --git a/src/nwconn.c b/src/nwconn.c index a0ab1a2..5ef3b6c 100644 --- a/src/nwconn.c +++ b/src/nwconn.c @@ -46,6 +46,7 @@ #include "nwdbm.h" #include "nwconn.h" #include "trustee.h" +#include "nwatalk.h" int act_pid = 0; @@ -2383,9 +2384,24 @@ static int handle_ncp_serv(void) } break; case 0x23 : { /* div AFP Calls */ + /* + * NetWare AFP calls are server-side NCP entry points for + * Mac namespace semantics: AFP entry IDs, Finder Info, + * AppleDouble metadata, resource forks, and per-volume Mac + * namespace state. + * + * Netatalk/libatalk can be enabled at build time as an + * optional local metadata backend for AppleDouble/Finder + * Info/resource-fork access, but mars_nwe must still + * decode and answer the NetWare NCP calls itself. Do not + * proxy these calls to afpd or report success until the + * required Mac namespace semantics exist. + */ #if 0 int ufunc = (int) *requestdata; #endif + XDPRINTF((3,0, "AFP call rejected: Mac namespace unavailable, libatalk backend=%s", + nwatalk_backend_available() ? "enabled" : "disabled")); completition=0xbf; /* we say invalid namespace here */ } break;