[PATCH] samba-tool ntacl dosinfo
Ralph Böhme
slow at samba.org
Sun Sep 27 22:26:37 UTC 2015
On Sun, Sep 27, 2015 at 08:40:41AM -0700, Guenther Deschner wrote:
> no patch attached
Oh, here it is. :)
-slow
-------------- next part --------------
From 21293dc13231de1f2e2eced3deebb0b08dd58b6e Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Sat, 26 Sep 2015 01:16:50 +0200
Subject: [PATCH] samba-tool: add command to dump dosinfo xattr from a file
Add a new command "getdosinfo" to samba-tool to dump dosinfo xattr from
a file.
Signed-off-by: Ralph Boehme <slow at samba.org>
---
librpc/idl/xattr.idl | 1 +
python/samba/netcmd/ntacl.py | 24 +++++++++++++++++++++++-
python/samba/ntacls.py | 8 ++++++++
3 files changed, 32 insertions(+), 1 deletion(-)
diff --git a/librpc/idl/xattr.idl b/librpc/idl/xattr.idl
index b4c1b98..efbc84e 100644
--- a/librpc/idl/xattr.idl
+++ b/librpc/idl/xattr.idl
@@ -20,6 +20,7 @@ import "security.idl";
interface xattr
{
const char *XATTR_DOSATTRIB_NAME = "user.DosAttrib";
+ const char *XATTR_DOSATTRIB_NAME_S3 = "user.DOSATTRIB";
const int XATTR_DOSATTRIB_ESTIMATED_SIZE = 64;
/* we store basic dos attributes in a DosAttrib xattr. By
diff --git a/python/samba/netcmd/ntacl.py b/python/samba/netcmd/ntacl.py
index dff1550..eaea0e7 100644
--- a/python/samba/netcmd/ntacl.py
+++ b/python/samba/netcmd/ntacl.py
@@ -19,7 +19,7 @@
from samba.credentials import DONT_USE_KERBEROS
import samba.getopt as options
from samba.dcerpc import security, idmap
-from samba.ntacls import setntacl, getntacl
+from samba.ntacls import setntacl, getntacl,getdosinfo
from samba import Ldb
from samba.ndr import ndr_unpack, ndr_print
from samba.samdb import SamDB
@@ -95,6 +95,27 @@ class cmd_ntacl_set(Command):
logger.warning("Please note that POSIX permissions have NOT been changed, only the stored NT ACL")
+class cmd_dosinfo_get(Command):
+ """Get DOS info of a file from xattr."""
+ synopsis = "%prog <file> [options]"
+
+ takes_optiongroups = {
+ "sambaopts": options.SambaOptions,
+ "credopts": options.CredentialsOptions,
+ "versionopts": options.VersionOptions,
+ }
+
+ takes_args = ["file"]
+
+ def run(self, file, credopts=None, sambaopts=None, versionopts=None):
+ lp = sambaopts.get_loadparm()
+ s3conf = s3param.get_context()
+ s3conf.load(lp.configfile)
+
+ dosinfo = getdosinfo(lp, file)
+ if dosinfo:
+ self.outf.write(ndr_print(dosinfo))
+
class cmd_ntacl_get(Command):
"""Get ACLs of a file."""
synopsis = "%prog <file> [options]"
@@ -257,4 +278,5 @@ class cmd_ntacl(SuperCommand):
subcommands["get"] = cmd_ntacl_get()
subcommands["sysvolreset"] = cmd_ntacl_sysvolreset()
subcommands["sysvolcheck"] = cmd_ntacl_sysvolcheck()
+ subcommands["getdosinfo"] = cmd_dosinfo_get()
diff --git a/python/samba/ntacls.py b/python/samba/ntacls.py
index 53438d8..0eeb497 100644
--- a/python/samba/ntacls.py
+++ b/python/samba/ntacls.py
@@ -54,6 +54,14 @@ def checkset_backend(lp, backend, eadbfile):
else:
raise XattrBackendError("Invalid xattr backend choice %s"%backend)
+def getdosinfo(lp, file):
+ try:
+ attribute = samba.xattr_native.wrap_getxattr(file,
+ xattr.XATTR_DOSATTRIB_NAME_S3)
+ except Exception:
+ return
+
+ return ndr_unpack(xattr.DOSATTRIB, attribute)
def getntacl(lp, file, backend=None, eadbfile=None, direct_db_access=True, service=None):
if direct_db_access:
--
2.1.0
More information about the samba-technical
mailing list