nwconn: derive AFP access privileges from trustees
All checks were successful
Source release / source-package (push) Successful in 47s
All checks were successful
Source release / source-package (push) Successful in 47s
This commit is contained in:
55
src/nwconn.c
55
src/nwconn.c
@@ -1150,11 +1150,56 @@ static uint16 afp_basic_attributes(int volume, const char *unixname, const struc
|
||||
return(attributes);
|
||||
}
|
||||
|
||||
static uint16 afp_basic_access_privileges(const struct stat *stb)
|
||||
#define AFP_PRIV_READ 0x0100
|
||||
#define AFP_PRIV_WRITE 0x0200
|
||||
#define AFP_PRIV_OPEN 0x0400
|
||||
#define AFP_PRIV_CREATE 0x0800
|
||||
#define AFP_PRIV_DELETE 0x1000
|
||||
#define AFP_PRIV_PARENTAL 0x2000
|
||||
#define AFP_PRIV_SEARCH 0x4000
|
||||
#define AFP_PRIV_MODIFY_ATTRS 0x8000
|
||||
|
||||
static uint16 afp_access_privileges(int volume, const char *unixname,
|
||||
const struct stat *stb)
|
||||
{
|
||||
if (S_ISDIR(stb->st_mode))
|
||||
return(0x4000 | 0x2000 | 0x8000); /* search, parental, modify attrs */
|
||||
return(0x0100 | 0x0200 | 0x0400 | 0x1000 | 0x8000); /* rw open delete modify */
|
||||
int rights;
|
||||
uint16 privileges = 0;
|
||||
|
||||
rights = tru_get_eff_rights(volume, (uint8 *)unixname, (struct stat *)stb);
|
||||
if (rights < 0)
|
||||
return(0);
|
||||
|
||||
if (rights & TRUSTEE_S)
|
||||
rights |= TRUSTEE_R | TRUSTEE_W | TRUSTEE_O | TRUSTEE_C |
|
||||
TRUSTEE_E | TRUSTEE_A | TRUSTEE_F | TRUSTEE_M;
|
||||
|
||||
if (S_ISDIR(stb->st_mode)) {
|
||||
if (rights & (TRUSTEE_C | TRUSTEE_E | TRUSTEE_M))
|
||||
privileges |= AFP_PRIV_PARENTAL;
|
||||
if (rights & TRUSTEE_F)
|
||||
privileges |= AFP_PRIV_SEARCH;
|
||||
if (rights & TRUSTEE_M)
|
||||
privileges |= AFP_PRIV_MODIFY_ATTRS;
|
||||
return(privileges);
|
||||
}
|
||||
|
||||
if (rights & TRUSTEE_R)
|
||||
privileges |= AFP_PRIV_READ;
|
||||
if (rights & TRUSTEE_W)
|
||||
privileges |= AFP_PRIV_WRITE;
|
||||
if (rights & TRUSTEE_O)
|
||||
privileges |= AFP_PRIV_OPEN;
|
||||
if (rights & TRUSTEE_C)
|
||||
privileges |= AFP_PRIV_CREATE;
|
||||
if (rights & TRUSTEE_E)
|
||||
privileges |= AFP_PRIV_DELETE;
|
||||
if (rights & TRUSTEE_M)
|
||||
privileges |= AFP_PRIV_MODIFY_ATTRS;
|
||||
|
||||
if (get_nw_attrib_dword(volume, (char *)unixname, (struct stat *)stb) & FILE_ATTR_R)
|
||||
privileges &= ~(AFP_PRIV_WRITE | AFP_PRIV_DELETE);
|
||||
|
||||
return(privileges);
|
||||
}
|
||||
|
||||
static uint16 afp_count_offspring(const char *unixname, const struct stat *stb)
|
||||
@@ -1246,7 +1291,7 @@ static int afp_fill_file_info_response(const char *unixname,
|
||||
afp_leaf_name_from_path(response + 64, 32, display_path, display_path_len);
|
||||
U32_TO_BE32(get_file_owner(&stbuff), response + 96);
|
||||
afp_leaf_name_from_path(response + 100, 12, display_path, display_path_len);
|
||||
U16_TO_BE16(afp_basic_access_privileges(&stbuff), response + 112);
|
||||
U16_TO_BE16(afp_access_privileges(volume, unixname, &stbuff), response + 112);
|
||||
/* ProDOS info at offset 114 stays zero until a real Mac namespace maps it. */
|
||||
|
||||
if (entry_id_out) *entry_id_out = entry_id;
|
||||
|
||||
Reference in New Issue
Block a user