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))
@cherrypy.expose
@cherrypy.tools.method(accept="GET")
def getuserandgroupids(self):
self.release_session()
fs = self.get("fs")
self.release_database()
return fs.get_user_and_group_ids()
@cherrypy.expose
@cherrypy.tools.method(accept="POST")
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
try:
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] = [""]
facls.append(tuple(e))
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_")))
try:
ret["facl"] = list(check_output(["getfacl", "-pc", path]).splitlines())
except CalledProcessError:
pass
try:
ret["nfs4_facl"] = list(check_output(["nfs4_getfacl", path]).splitlines())
except CalledProcessError:
pass
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"):
......
Markdown is supported
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