1
0
mirror of https://github.com/samba-team/samba.git synced 2025-07-30 19:42:05 +03:00

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@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Tue Sep 29 06:00:49 CEST 2015 on sn-devel-104
This commit is contained in:
Ralph Boehme
2015-09-26 01:16:50 +02:00
committed by Volker Lendecke
parent 44aff1a164
commit 875beefced
3 changed files with 32 additions and 1 deletions

View File

@ -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

View File

@ -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()

View File

@ -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: