nwconn: route AFP set file timestamps via NetWare helper
All checks were successful
Source release / source-package (push) Successful in 51s
All checks were successful
Source release / source-package (push) Successful in 51s
Extend the conservative AFP Set File Information implementation to accept the file modification timestamp bitmap for path-backed file requests. The WebSDK/NWAFP Set File Information payload carries the timestamp in the same bitmap-ordered parameter stream as file attributes and FinderInfo, so the parser now admits the documented modification timestamp field while continuing to reject every other Set File Information bitmap bit. Do not implement a new AFP-specific timestamp backend. After resolving the raw VOL:-style smoke path to the effective mars_nwe volume and Unix path, convert the AFP/NW DOS date+time fields to time_t and route the update through the existing nw_utime_node() helper. That keeps trustee Modify-right checks and the established utime(2) fallback behavior shared with classic NetWare/NCP timestamp updates. Keep the implementation deliberately file-only and path-backed. Directory timestamps, create/access/backup timestamp fields, Entry-ID-only Set File Information, resource-fork semantics, DOS attribute mapping, Delete, Rename, Create, and Remove stay TODO so later patches can wire them to the existing NetWare helpers with focused smoke coverage. Update afp_set_file_info_smoke with --mtime-epoch and --timestamp-only, verify the written AFP date/time via the follow-up Get File Information record, and extend afp_smoke_suite.sh to run the timestamp probe and record the backing Linux stat output. The suite helper is already copied as a build target, so the new test is propagated into the build tree by the normal tests build. Tests: - git diff --check - bash -n tests/linux/afp_smoke_suite.sh - gcc -Iinclude -I/mnt/data/stubs -fsyntax-only tests/linux/afp_set_file_info_smoke.c
This commit is contained in:
40
src/nwconn.c
40
src/nwconn.c
@@ -1095,6 +1095,7 @@ static int afp_get_file_information(uint8 *afp_req, int afp_len,
|
||||
|
||||
|
||||
#define AFP_FILE_BITMAP_ATTRIBUTES 0x0001
|
||||
#define AFP_FILE_BITMAP_MODIFY_DATE 0x0010
|
||||
#define AFP_FILE_BITMAP_FINDER_INFO 0x0020
|
||||
#define AFP_ATTR_INVISIBLE 0x0001
|
||||
#define AFP_ATTR_SYSTEM 0x0004
|
||||
@@ -1111,9 +1112,12 @@ static int afp_set_file_information(uint8 *afp_req, int afp_len,
|
||||
* Netatalk's FPSetFileParams tests use the FinderInfo bitmap as a small,
|
||||
* metadata-only write probes. Mirror the safest slices for the NCP AFP
|
||||
* extension: accept the same path-backed VOL:-style smoke requests as Get File
|
||||
* Information, persist only the file attribute word and/or 32-byte FinderInfo
|
||||
* block in mars_nwe's private xattr namespace, and reject all other bitmap
|
||||
* bits until DOS attribute, timestamp, resource-fork, and entry-id lookup
|
||||
* Information, persist only the file attribute word, the file modification timestamp,
|
||||
* and/or 32-byte FinderInfo block. Attribute and FinderInfo data live in
|
||||
* mars_nwe's private xattr namespace; the modification timestamp is routed
|
||||
* through the existing NetWare timestamp helper so trustee Modify rights and
|
||||
* utime handling stay shared with the classic NCP paths. Reject all other
|
||||
* bitmap bits until DOS attribute, resource-fork, and entry-id lookup
|
||||
* semantics are deliberately wired in.
|
||||
*/
|
||||
{
|
||||
@@ -1127,6 +1131,7 @@ static int afp_set_file_information(uint8 *afp_req, int afp_len,
|
||||
struct stat stbuff;
|
||||
int result;
|
||||
uint16 log_attrs = 0;
|
||||
time_t log_mtime = (time_t)-1;
|
||||
|
||||
if (afp_len < 9) {
|
||||
XDPRINTF((2,0, "%s rejected: short request len=%d",
|
||||
@@ -1155,7 +1160,8 @@ static int afp_set_file_information(uint8 *afp_req, int afp_len,
|
||||
return(-0x9c); /* Invalid Path until persistent entry-id lookup exists */
|
||||
}
|
||||
|
||||
if (request_mask & ~(AFP_FILE_BITMAP_ATTRIBUTES | AFP_FILE_BITMAP_FINDER_INFO)) {
|
||||
if (request_mask & ~(AFP_FILE_BITMAP_ATTRIBUTES | AFP_FILE_BITMAP_MODIFY_DATE |
|
||||
AFP_FILE_BITMAP_FINDER_INFO)) {
|
||||
XDPRINTF((2,0, "%s rejected: unsupported bitmap vol=%d entry=0x%08x mask=0x%04x path='%s'",
|
||||
call_name, (int)volume_number, request_entry_id, request_mask,
|
||||
visable_data(afp_req + 9, path_len)));
|
||||
@@ -1185,6 +1191,13 @@ static int afp_set_file_information(uint8 *afp_req, int afp_len,
|
||||
}
|
||||
data_off += 2;
|
||||
}
|
||||
if ((request_mask & AFP_FILE_BITMAP_MODIFY_DATE) && afp_len < data_off + 4) {
|
||||
XDPRINTF((2,0, "%s rejected: short modify timestamp data len=%d data_off=%d",
|
||||
call_name, afp_len, data_off));
|
||||
return(-0x7e);
|
||||
}
|
||||
if (request_mask & AFP_FILE_BITMAP_MODIFY_DATE)
|
||||
data_off += 4;
|
||||
if ((request_mask & AFP_FILE_BITMAP_FINDER_INFO) && data_off & 1) data_off++;
|
||||
if ((request_mask & AFP_FILE_BITMAP_FINDER_INFO) &&
|
||||
afp_len < data_off + NWATALK_FINDER_INFO_LEN) {
|
||||
@@ -1225,6 +1238,20 @@ static int afp_set_file_information(uint8 *afp_req, int afp_len,
|
||||
return(result);
|
||||
data_off += 2;
|
||||
}
|
||||
if (request_mask & AFP_FILE_BITMAP_MODIFY_DATE) {
|
||||
time_t new_mtime = nw_2_un_time(afp_req + data_off, afp_req + data_off + 2);
|
||||
if (new_mtime == (time_t)-1) {
|
||||
XDPRINTF((2,0, "%s rejected: invalid modify timestamp path='%s'",
|
||||
call_name, visable_data(afp_req + 9, path_len)));
|
||||
return(-0x8c);
|
||||
}
|
||||
result = nw_utime_node(path_volume, (uint8 *)unixname, &stbuff, new_mtime);
|
||||
if (result < 0)
|
||||
return(result);
|
||||
log_mtime = new_mtime;
|
||||
if (!stat(unixname, &stbuff)) {}
|
||||
data_off += 4;
|
||||
}
|
||||
if ((request_mask & AFP_FILE_BITMAP_FINDER_INFO) && data_off & 1) data_off++;
|
||||
if (request_mask & AFP_FILE_BITMAP_FINDER_INFO) {
|
||||
result = nwatalk_set_finder_info(unixname, afp_req + data_off,
|
||||
@@ -1233,12 +1260,13 @@ static int afp_set_file_information(uint8 *afp_req, int afp_len,
|
||||
return(result);
|
||||
}
|
||||
|
||||
XDPRINTF((3,0, "%s: vol=%d request_vol=%d entry=0x%08x mask=0x%04x path='%s'%s%s attrs=0x%04x",
|
||||
XDPRINTF((3,0, "%s: vol=%d request_vol=%d entry=0x%08x mask=0x%04x path='%s'%s%s%s attrs=0x%04x mtime=%ld",
|
||||
call_name, path_volume, (int)volume_number, request_entry_id,
|
||||
request_mask, visable_data(afp_req + 9, path_len),
|
||||
(request_mask & AFP_FILE_BITMAP_ATTRIBUTES) ? " attributes" : "",
|
||||
(request_mask & AFP_FILE_BITMAP_MODIFY_DATE) ? " modify_time" : "",
|
||||
(request_mask & AFP_FILE_BITMAP_FINDER_INFO) ? " finder_info" : "",
|
||||
log_attrs));
|
||||
log_attrs, (long)log_mtime));
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user