File: perm_acl_module.py

package info (click to toggle)
pyftpd 0.8.1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 524 kB
  • ctags: 448
  • sloc: python: 2,748; sh: 80; makefile: 43
file content (23 lines) | stat: -rw-r--r-- 681 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from utils import myfnmatch

from perm_acl_config import *

def permcheck(f, user, group, session, operation):
    accesslist = {}
    #f = session.v2fs(f)
    for i in acllist:
        if (   myfnmatch(user, i[0]) and
               myfnmatch(group, i[1]) and
               myfnmatch(session.ip, i[2]) and
               myfnmatch(f, i[3]+"*")
            ):
            for j in i[4]: # append allowed operations
                accesslist[j] = 1
            for j in i[5]: # and then remove denied ones
                if accesslist.has_key(j):
                    del(accesslist[j])
    if accesslist.has_key(operation):
        return 1, 1
    else:
        return 0, 1