Commit deb0a238 authored by Benjamin Fischer's avatar Benjamin Fischer
Browse files

Filesystem: partially updated ACL handling

- added retrieval of NFSv4 ACLs
- added retrieval of all user & groups
parent e79e5f77
......@@ -481,6 +481,14 @@ class FSAjaxController(AbstractController):
path = fs.expand(path)
return list(fs.getfacl(path))
def getuserandgroupids(self):
fs = self.get("fs")
return fs.get_user_and_group_ids()
def setfacl(self, path, type, name, mode, remove=False, recursive=False, default=False):
......@@ -62,6 +62,8 @@ import subprocess
import fsmonitor
import vispa
import tempfile
from pwd import getpwall
from grp import getgrall
import Image
......@@ -524,15 +526,24 @@ class FileSystem(object):
return os.access(path, permission)
def getfacl(self, path):
o = check_output(["getfacl", "-p", "-t", path])
facls = []
for line in o.splitlines():
if not line: continue
if line.startswith("#"): continue
e = line.split()
if e[0] in ["mask", "other"]: e[1:1] = [""]
return facls
path = self.expand(path)
s = os.stat(path)
ret = dict(stat=dict((k[3:], getattr(s, k)) for k in dir(s) if k.startswith("st_")))
ret["facl"] = list(check_output(["getfacl", "-pc", path]).splitlines())
except CalledProcessError:
ret["nfs4_facl"] = list(check_output(["nfs4_getfacl", path]).splitlines())
except CalledProcessError:
return ret
def get_user_and_group_ids(self):
return dict(
users=dict((s.pw_name, s.pw_uid) for s in getpwall()),
groups=dict((s.gr_name, s.gr_gid) for s in getgrall()),
def setfacl(self, path, type, name, mode, remove=False, recursive=False, default=False):
if type not in ("user", "group", "mask", "other"):
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment