nwconn: derive AFP access privileges from trustees
All checks were successful
Source release / source-package (push) Successful in 47s

This commit is contained in:
OpenAI
2026-05-30 17:49:45 +00:00
committed by Mario Fetka
parent fc7f099494
commit a18de6abd2
3 changed files with 86 additions and 6 deletions

View File

@@ -30,7 +30,7 @@ static void usage(const char *prog)
{
fprintf(stderr,
"Usage: %s [--afp20] [--allow-invalid-namespace] [--allow-invalid-path] "
"[--volume N] [--entry-id ID] [--request-mask MASK] [ncpfs options] PATH\n"
"[--volume N] [--entry-id ID] [--request-mask MASK] [--expect-rights-set MASK] [--expect-rights-clear MASK] [ncpfs options] PATH\n"
"\n"
"ncpfs options are parsed by ncp_initialize(), for example:\n"
" -S SERVER -U USER -P PASSWORD -n\n"
@@ -106,6 +106,8 @@ int main(int argc, char **argv)
uint32_t volume_number = 0;
uint32_t entry_id = 0;
uint32_t request_mask = AFP_GET_ALL;
uint32_t expect_rights_set = 0;
uint32_t expect_rights_clear = 0;
uint32_t afp_subfunction = AFP_GET_FILE_INFORMATION;
int i;
size_t path_len;
@@ -152,6 +154,18 @@ int main(int argc, char **argv)
ncp_close(conn);
return 2;
}
} else if (!strcmp(argv[i], "--expect-rights-set")) {
if (++i >= argc || parse_u32(argv[i], &expect_rights_set) || expect_rights_set > 0xffff) {
fprintf(stderr, "invalid --expect-rights-set value\n");
ncp_close(conn);
return 2;
}
} else if (!strcmp(argv[i], "--expect-rights-clear")) {
if (++i >= argc || parse_u32(argv[i], &expect_rights_clear) || expect_rights_clear > 0xffff) {
fprintf(stderr, "invalid --expect-rights-clear value\n");
ncp_close(conn);
return 2;
}
} else if (!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help")) {
usage(argv[0]);
ncp_close(conn);
@@ -226,6 +240,21 @@ int main(int argc, char **argv)
copy_fixed_string(long_name, sizeof(long_name), reply_buf + 64, 32);
copy_fixed_string(short_name, sizeof(short_name), reply_buf + 100, 12);
if (expect_rights_set &&
(be16_to_cpu(reply_buf + 112) & expect_rights_set) != expect_rights_set) {
fprintf(stderr, "AFP File Info rights missing expected bits: rights=0x%04x expected_set=0x%04x path=%s\n",
be16_to_cpu(reply_buf + 112), (unsigned int)expect_rights_set, path);
ncp_close(conn);
return 1;
}
if (expect_rights_clear &&
(be16_to_cpu(reply_buf + 112) & expect_rights_clear) != 0) {
fprintf(stderr, "AFP File Info rights has unexpected bits: rights=0x%04x expected_clear=0x%04x path=%s\n",
be16_to_cpu(reply_buf + 112), (unsigned int)expect_rights_clear, path);
ncp_close(conn);
return 1;
}
printf("AFP File Info subfunction=0x%02x path=%s entry_id=0x%08x parent_id=0x%08x attrs=0x%04x "
"data_len=%u resource_len=%u offspring=%u long_name=%s short_name=%s rights=0x%04x\n",
(unsigned int)afp_subfunction,

View File

@@ -418,6 +418,12 @@ if [ -n "$READONLY_USER" ]; then
READONLY_AUTH_ARGS=(-P "$READONLY_PASSWORD")
fi
run_cmd \
"AFP Get File Information readonly rights" \
"./afp_file_info_smoke --expect-rights-set 0x0100 --expect-rights-clear 0x9200 $READONLY_PRINT '$NETWARE_PATH'" \
"$SCRIPT_DIR/afp_file_info_smoke" --expect-rights-set 0x0100 --expect-rights-clear 0x9200 \
-S "$SERVER" -U "$READONLY_USER" "${READONLY_AUTH_ARGS[@]}" "$NETWARE_PATH"
run_cmd \
"AFP metadata Modify rights rejected: FinderInfo" \
"./afp_set_file_info_smoke --expect-completion 0x8c $READONLY_PRINT --finder-info-only --type '$FINDER_TYPE' --creator '$FINDER_CREATOR' '$NETWARE_PATH'" \