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): ...@@ -481,6 +481,14 @@ class FSAjaxController(AbstractController):
path = fs.expand(path) path = fs.expand(path)
return list(fs.getfacl(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.expose
@cherrypy.tools.method(accept="POST") @cherrypy.tools.method(accept="POST")
def setfacl(self, path, type, name, mode, remove=False, recursive=False, default=False): def setfacl(self, path, type, name, mode, remove=False, recursive=False, default=False):
......
...@@ -62,6 +62,8 @@ import subprocess ...@@ -62,6 +62,8 @@ import subprocess
import fsmonitor import fsmonitor
import vispa import vispa
import tempfile import tempfile
from pwd import getpwall
from grp import getgrall
try: try:
import Image import Image
...@@ -524,15 +526,24 @@ class FileSystem(object): ...@@ -524,15 +526,24 @@ class FileSystem(object):
return os.access(path, permission) return os.access(path, permission)
def getfacl(self, path): def getfacl(self, path):
o = check_output(["getfacl", "-p", "-t", path]) path = self.expand(path)
facls = [] s = os.stat(path)
for line in o.splitlines(): ret = dict(stat=dict((k[3:], getattr(s, k)) for k in dir(s) if k.startswith("st_")))
if not line: continue try:
if line.startswith("#"): continue ret["facl"] = list(check_output(["getfacl", "-pc", path]).splitlines())
e = line.split() except CalledProcessError:
if e[0] in ["mask", "other"]: e[1:1] = [""] pass
facls.append(tuple(e)) try:
return facls 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): def setfacl(self, path, type, name, mode, remove=False, recursive=False, default=False):
if type not in ("user", "group", "mask", "other"): 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