2004-11-05 07:29:02 +00:00
#include "idl_types.h"
/*
IDL structures for xattr file attributes
this has nothing to do with RPC, we are just using our NDR/IDL
infrastructure as a convenient way to store linearised information
about a file in a architecture independent manner
*/
2006-11-06 22:54:49 +00:00
import "security.idl";
2004-11-18 03:31:35 +00:00
[
2009-10-28 15:42:47 -07:00
version(0.0),
helper("../librpc/ndr/ndr_xattr.h"),
2010-01-11 02:19:22 +03:00
pyhelper("librpc/ndr/py_xattr.c"),
2005-02-12 23:03:26 +00:00
pointer_default(unique)
2004-11-18 03:31:35 +00:00
]
2004-11-05 07:29:02 +00:00
interface xattr
{
2005-10-16 17:17:57 +00:00
const char *XATTR_DOSATTRIB_NAME = "user.DosAttrib";
2015-09-26 01:16:50 +02:00
const char *XATTR_DOSATTRIB_NAME_S3 = "user.DOSATTRIB";
2005-10-16 17:17:57 +00:00
const int XATTR_DOSATTRIB_ESTIMATED_SIZE = 64;
2004-11-05 07:29:02 +00:00
2004-11-05 11:31:35 +00:00
/* we store basic dos attributes in a DosAttrib xattr. By
using a union we can cope with new version of this
structure more easily */
2004-11-24 06:09:14 +00:00
2009-10-28 15:42:47 -07:00
/*
* the FFFF level is never really used,
* it's used to pass the information from
* the old hex string attrib information
* we have a handwritten parser which converts
2023-06-06 12:58:34 +02:00
* the hex string to the xattr_DosInfoFFFFCompat structure
2009-10-28 15:42:47 -07:00
*/
typedef struct {
uint32 attrib;
} xattr_DosInfoFFFFCompat;
2004-11-05 07:29:02 +00:00
typedef struct {
uint32 attrib;
uint32 ea_size;
2005-01-27 06:16:59 +00:00
udlong size;
udlong alloc_size;
2004-11-05 07:29:02 +00:00
NTTIME create_time;
NTTIME change_time;
} xattr_DosInfo1;
2008-05-07 15:46:22 +02:00
/*
We use xattrDosInfo1 again when we store values.
Because the sticky write time is now stored in the opendb
and xattr_DosInfo2Old is only present to parse existing
values from disk.
2004-11-24 06:09:14 +00:00
2008-05-07 15:46:22 +02:00
const int XATTR_ATTRIB_FLAG_STICKY_WRITE_TIME = 0x1;
*/
2004-11-24 06:09:14 +00:00
typedef struct {
uint32 flags;
uint32 attrib;
uint32 ea_size;
2005-01-27 06:16:59 +00:00
udlong size;
udlong alloc_size;
2004-11-24 06:09:14 +00:00
NTTIME create_time;
NTTIME change_time;
NTTIME write_time; /* only used when sticky write time is set */
2005-12-06 05:25:03 +00:00
utf8string name;
2008-05-07 15:46:22 +02:00
} xattr_DosInfo2Old;
2004-11-24 06:09:14 +00:00
2009-10-28 15:42:47 -07:00
typedef [bitmap32bit] bitmap {
XATTR_DOSINFO_ATTRIB = 0x00000001,
XATTR_DOSINFO_EA_SIZE = 0x00000002,
XATTR_DOSINFO_SIZE = 0x00000004,
XATTR_DOSINFO_ALLOC_SIZE = 0x00000008,
XATTR_DOSINFO_CREATE_TIME = 0x00000010,
2019-06-30 14:43:28 +02:00
XATTR_DOSINFO_CHANGE_TIME = 0x00000020,
XATTR_DOSINFO_ITIME = 0x00000040
2009-10-28 15:42:47 -07:00
} xattr_DosInfoValidFlags;
typedef struct {
xattr_DosInfoValidFlags valid_flags;
uint32 attrib;
uint32 ea_size;
udlong size;
udlong alloc_size;
NTTIME create_time;
NTTIME change_time;
} xattr_DosInfo3;
2019-06-30 14:43:28 +02:00
typedef struct {
xattr_DosInfoValidFlags valid_flags;
uint32 attrib;
NTTIME itime;
NTTIME create_time;
} xattr_DosInfo4;
2022-03-28 11:48:37 +02:00
typedef struct {
xattr_DosInfoValidFlags valid_flags;
uint32 attrib;
NTTIME create_time;
} xattr_DosInfo5;
2009-10-28 15:42:47 -07:00
typedef [public,switch_type(uint16)] union {
[case(0xFFFF)] xattr_DosInfoFFFFCompat compatinfoFFFF;
[case(1)] xattr_DosInfo1 info1;
[case(2)] xattr_DosInfo2Old oldinfo2;
[case(3)] xattr_DosInfo3 info3;
2019-06-30 14:43:28 +02:00
[case(4)] xattr_DosInfo4 info4;
2022-03-28 11:48:37 +02:00
[case(5)] xattr_DosInfo5 info5;
2009-10-28 15:42:47 -07:00
} xattr_DosInfo;
2004-11-05 07:29:02 +00:00
typedef [public] struct {
uint16 version;
[switch_is(version)] xattr_DosInfo info;
} xattr_DosAttrib;
2004-11-05 11:31:35 +00:00
2009-10-28 15:42:47 -07:00
typedef [public,nopush,nopull,noprint] struct {
astring attrib_hex;
uint16 version;
[switch_is(version)] xattr_DosInfo info;
} xattr_DOSATTRIB;
2004-11-05 11:31:35 +00:00
/* we store DOS style extended attributes in a DosEAs xattr */
2005-10-16 17:17:57 +00:00
const char *XATTR_DOSEAS_NAME = "user.DosEAs";
2004-11-05 11:31:35 +00:00
typedef struct {
2005-12-06 05:25:03 +00:00
utf8string name;
2004-11-05 11:31:35 +00:00
DATA_BLOB value;
} xattr_EA;
typedef [public] struct {
uint16 num_eas;
2005-05-27 15:49:15 +00:00
[size_is(num_eas)] xattr_EA *eas;
2004-11-05 11:31:35 +00:00
} xattr_DosEAs;
2004-11-15 06:57:26 +00:00
2008-10-15 15:57:39 +02:00
/* Slightly different version, used by the vfs_xattr_tdb module */
typedef [public] struct {
uint32 num_eas;
xattr_EA eas[num_eas];
} tdb_xattrs;
2004-11-15 06:57:26 +00:00
/* we store stream information in this xattr structure. Then
the streams themselves are stored in
user.DosStream.STREAMNAME or in external files, according
to the flags */
2005-10-16 17:17:57 +00:00
const char *XATTR_DOSSTREAMS_NAME = "user.DosStreams";
2004-11-15 06:57:26 +00:00
const int XATTR_STREAM_FLAG_INTERNAL = 0x00000001;
2004-11-17 05:58:04 +00:00
/* stream data is stored in attributes with the given prefix */
2005-10-16 17:17:57 +00:00
const char *XATTR_DOSSTREAM_PREFIX = "user.DosStream.";
2004-11-17 05:58:04 +00:00
2008-05-26 14:59:58 +10:00
const int XATTR_MAX_STREAM_SIZE = 0x4000;
const int XATTR_MAX_STREAM_SIZE_TDB = 0x100000;
2004-11-17 12:36:14 +00:00
2004-11-15 06:57:26 +00:00
typedef struct {
uint32 flags;
2005-01-27 06:16:59 +00:00
udlong size;
udlong alloc_size;
2005-12-06 05:25:03 +00:00
utf8string name;
2004-11-15 06:57:26 +00:00
} xattr_DosStream;
typedef [public] struct {
uint32 num_streams;
2005-05-27 15:49:15 +00:00
[size_is(num_streams)] xattr_DosStream *streams;
2004-11-15 06:57:26 +00:00
} xattr_DosStreams;
2004-11-18 03:31:35 +00:00
2004-11-24 06:09:14 +00:00
/* we store the NT ACL a NTACL xattr. It is versioned so we
2004-11-18 03:41:50 +00:00
can later add other acl attribs (such as posix acl mapping)
2008-07-09 16:55:51 -07:00
2004-11-18 03:31:35 +00:00
we put this xattr in the security namespace to ensure that
only trusted users can write to the ACL
2008-07-09 16:55:51 -07:00
stored in "security.NTACL"
Version 1. raw SD stored as Samba4 does it.
2008-11-13 17:18:41 -08:00
Version 2. raw SD + last changed hash so we
can discard if this doesn't match the underlying ACL hash.
2004-11-18 03:31:35 +00:00
*/
2008-07-09 16:55:51 -07:00
2008-07-09 17:46:11 -07:00
const char *XATTR_NTACL_NAME = "security.NTACL";
2009-07-24 14:09:42 -07:00
const int XATTR_SD_HASH_SIZE = 64;
const int XATTR_SD_HASH_TYPE_NONE = 0x0;
const int XATTR_SD_HASH_TYPE_SHA256 = 0x1;
2008-07-09 16:55:51 -07:00
typedef [public] struct {
security_descriptor *sd;
2008-11-13 17:18:41 -08:00
uint8 hash[16];
2009-07-24 14:09:42 -07:00
} security_descriptor_hash_v2; /* Hash never used in this version. */
typedef [public] struct {
security_descriptor *sd;
uint16 hash_type;
2009-07-24 14:13:42 -07:00
uint8 hash[64]; /* 64 bytes hash. */
2009-07-24 14:09:42 -07:00
} security_descriptor_hash_v3;
2004-11-18 03:31:35 +00:00
2012-10-10 16:42:38 +11:00
typedef [public] struct {
security_descriptor *sd;
uint16 hash_type;
uint8 hash[64]; /* 64 bytes hash. */
utf8string description; /* description of what created
* this hash (to allow
2017-08-18 14:59:58 +02:00
* forensics later, if we have
2012-10-10 16:42:38 +11:00
* a bug in one codepath */
2023-06-20 09:56:22 +02:00
/*
* "time" is always set to 0. Left here to avoid
* bumping the union versions. Remove in case a v5 is
* necessary.
*/
2012-10-10 16:42:38 +11:00
NTTIME time;
uint8 sys_acl_hash[64]; /* 64 bytes hash. */
} security_descriptor_hash_v4;
2005-03-06 17:02:14 +00:00
typedef [switch_type(uint16)] union {
2004-11-18 03:31:35 +00:00
[case(1)] security_descriptor *sd;
2009-07-24 14:09:42 -07:00
[case(2)] security_descriptor_hash_v2 *sd_hs2;
[case(3)] security_descriptor_hash_v3 *sd_hs3;
2012-10-10 16:42:38 +11:00
[case(4)] security_descriptor_hash_v4 *sd_hs4;
2004-11-18 03:41:50 +00:00
} xattr_NTACL_Info;
2004-11-18 03:31:35 +00:00
typedef [public] struct {
uint16 version;
2004-11-18 03:41:50 +00:00
[switch_is(version)] xattr_NTACL_Info info;
} xattr_NTACL;
2012-10-24 17:06:33 +11:00
/*
* A wrapper of the common information required to be in the
* hash of the ACL, for the acl_xattr and acl_tdb modules.
*/
[public] typedef struct {
DATA_BLOB acl_as_blob;
uid_t owner;
gid_t group;
mode_t mode;
} xattr_sys_acl_hash_wrapper;
2004-11-05 07:29:02 +00:00
}