access_table()... - got it

Matt Chapman matty at samba.org
Tue Jan 18 09:28:08 GMT 2000


[well, except for DENY_FCB which I maintain does not exist]

static BOOL is_compatible(int old_deny, int old_mode, int new_deny,
                        int new_mode, BOOL same_process, BOOL is_exe)
{
        switch (old_deny) {
                case DENY_ALL:
                        return 0;
                case DENY_NONE:
                        return 1;
                case DENY_READ:
                        return (new_mode == DOS_OPEN_WRONLY);
                case DENY_WRITE:
                        return (new_mode == DOS_OPEN_RDONLY);
                case DENY_DOS:
                        return is_exe || ((old_mode == DOS_OPEN_RDONLY)
                                        && (new_mode == DOS_OPEN_RDONLY))
                                || (same_process && (old_deny == DENY_DOS)
                                        && (new_deny == DENY_DOS));
        }
}

static BOOL is_allowed(int new_deny, int new_mode, int old_deny,
                        int old_mode, BOOL same_process, BOOL is_exe)
{
        if ((old_deny == DENY_DOS) && (old_mode == DOS_OPEN_RDONLY)
                && (new_mode != DOS_OPEN_RDONLY) && same_process && !is_exe)
                return 0;

        return is_compatible(old_deny, old_mode, new_deny, new_mode,
                                                same_process, is_exe)
                && is_compatible(new_deny, new_mode, old_deny, old_mode,
                                                same_process, is_exe);
}

The special case in is_allowed is interesting...

Full test source (which generates smbtorture-like tables) is at
ftp://cifs.org/pub/samba/atable.c

	Matt


-- 
Matthew "Austin" Chapman
SysAdmin, Developer, Samba Team Member


More information about the samba-technical mailing list