mirror of
https://github.com/samba-team/samba.git
synced 2025-02-28 01:58:17 +03:00
s3: Trim lines in nfs4_acls.c
Autobuild-User: Volker Lendecke <vlendec@samba.org> Autobuild-Date: Fri Sep 16 01:39:36 CEST 2011 on sn-devel-104
This commit is contained in:
parent
9021934887
commit
e952c69317
@ -61,7 +61,8 @@ typedef struct _SMB_ACL4_INT_T
|
|||||||
are mapped to what in one place.
|
are mapped to what in one place.
|
||||||
************************************************/
|
************************************************/
|
||||||
|
|
||||||
static uint32_t map_nfs4_ace_flags_to_windows_ace_flags(uint32_t nfs4_ace_flags)
|
static uint32_t map_nfs4_ace_flags_to_windows_ace_flags(
|
||||||
|
uint32_t nfs4_ace_flags)
|
||||||
{
|
{
|
||||||
uint32_t win_ace_flags = 0;
|
uint32_t win_ace_flags = 0;
|
||||||
|
|
||||||
@ -144,7 +145,8 @@ static SMB_ACE4_INT_T *get_validated_aceint(SMB4ACE_T *ace)
|
|||||||
SMB4ACL_T *smb_create_smb4acl(void)
|
SMB4ACL_T *smb_create_smb4acl(void)
|
||||||
{
|
{
|
||||||
TALLOC_CTX *mem_ctx = talloc_tos();
|
TALLOC_CTX *mem_ctx = talloc_tos();
|
||||||
SMB_ACL4_INT_T *theacl = (SMB_ACL4_INT_T *)TALLOC_ZERO_SIZE(mem_ctx, sizeof(SMB_ACL4_INT_T));
|
SMB_ACL4_INT_T *theacl = (SMB_ACL4_INT_T *)TALLOC_ZERO_SIZE(
|
||||||
|
mem_ctx, sizeof(SMB_ACL4_INT_T));
|
||||||
if (theacl==NULL)
|
if (theacl==NULL)
|
||||||
{
|
{
|
||||||
DEBUG(0, ("TALLOC_SIZE failed\n"));
|
DEBUG(0, ("TALLOC_SIZE failed\n"));
|
||||||
@ -162,7 +164,8 @@ SMB4ACE_T *smb_add_ace4(SMB4ACL_T *theacl, SMB_ACE4PROP_T *prop)
|
|||||||
TALLOC_CTX *mem_ctx = talloc_tos();
|
TALLOC_CTX *mem_ctx = talloc_tos();
|
||||||
SMB_ACE4_INT_T *ace;
|
SMB_ACE4_INT_T *ace;
|
||||||
|
|
||||||
ace = (SMB_ACE4_INT_T *)TALLOC_ZERO_SIZE(mem_ctx, sizeof(SMB_ACE4_INT_T));
|
ace = (SMB_ACE4_INT_T *)TALLOC_ZERO_SIZE(
|
||||||
|
mem_ctx, sizeof(SMB_ACE4_INT_T));
|
||||||
if (ace==NULL)
|
if (ace==NULL)
|
||||||
{
|
{
|
||||||
DEBUG(0, ("TALLOC_SIZE failed\n"));
|
DEBUG(0, ("TALLOC_SIZE failed\n"));
|
||||||
@ -273,9 +276,11 @@ static bool smbacl4_nfs42win(TALLOC_CTX *mem_ctx, SMB4ACL_T *theacl, /* in */
|
|||||||
DEBUG(10, ("smbacl_nfs42win entered\n"));
|
DEBUG(10, ("smbacl_nfs42win entered\n"));
|
||||||
|
|
||||||
aclint = get_validated_aclint(theacl);
|
aclint = get_validated_aclint(theacl);
|
||||||
/* We do not check for naces being 0 or theacl being NULL here because it is done upstream */
|
/* We do not check for naces being 0 or theacl being NULL here
|
||||||
|
* because it is done upstream */
|
||||||
/* in smb_get_nt_acl_nfs4(). */
|
/* in smb_get_nt_acl_nfs4(). */
|
||||||
nt_ace_list = (struct security_ace *)TALLOC_ZERO_SIZE(mem_ctx, aclint->naces * sizeof(struct security_ace));
|
nt_ace_list = (struct security_ace *)TALLOC_ZERO_SIZE(
|
||||||
|
mem_ctx, aclint->naces * sizeof(struct security_ace));
|
||||||
if (nt_ace_list==NULL)
|
if (nt_ace_list==NULL)
|
||||||
{
|
{
|
||||||
DEBUG(10, ("talloc error"));
|
DEBUG(10, ("talloc error"));
|
||||||
@ -283,15 +288,18 @@ static bool smbacl4_nfs42win(TALLOC_CTX *mem_ctx, SMB4ACL_T *theacl, /* in */
|
|||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (aceint=aclint->first; aceint!=NULL; aceint=(SMB_ACE4_INT_T *)aceint->next) {
|
for (aceint=aclint->first;
|
||||||
|
aceint!=NULL;
|
||||||
|
aceint=(SMB_ACE4_INT_T *)aceint->next) {
|
||||||
uint32_t mask;
|
uint32_t mask;
|
||||||
struct dom_sid sid;
|
struct dom_sid sid;
|
||||||
SMB_ACE4PROP_T *ace = &aceint->prop;
|
SMB_ACE4PROP_T *ace = &aceint->prop;
|
||||||
uint32_t win_ace_flags;
|
uint32_t win_ace_flags;
|
||||||
|
|
||||||
DEBUG(10, ("magic: 0x%x, type: %d, iflags: %x, flags: %x, mask: %x, "
|
DEBUG(10, ("magic: 0x%x, type: %d, iflags: %x, flags: %x, "
|
||||||
"who: %d\n", aceint->magic, ace->aceType, ace->flags,
|
"mask: %x, who: %d\n",
|
||||||
ace->aceFlags, ace->aceMask, ace->who.id));
|
aceint->magic, ace->aceType, ace->flags,
|
||||||
|
ace->aceFlags, ace->aceMask, ace->who.id));
|
||||||
|
|
||||||
SMB_ASSERT(aceint->magic==SMB_ACE4_INT_MAGIC);
|
SMB_ASSERT(aceint->magic==SMB_ACE4_INT_MAGIC);
|
||||||
|
|
||||||
@ -324,15 +332,19 @@ static bool smbacl4_nfs42win(TALLOC_CTX *mem_ctx, SMB4ACL_T *theacl, /* in */
|
|||||||
ace->aceMask |= SMB_ACE4_DELETE_CHILD;
|
ace->aceMask |= SMB_ACE4_DELETE_CHILD;
|
||||||
}
|
}
|
||||||
|
|
||||||
win_ace_flags = map_nfs4_ace_flags_to_windows_ace_flags(ace->aceFlags);
|
win_ace_flags = map_nfs4_ace_flags_to_windows_ace_flags(
|
||||||
if (!is_directory && (win_ace_flags & (SEC_ACE_FLAG_OBJECT_INHERIT|SEC_ACE_FLAG_CONTAINER_INHERIT))) {
|
ace->aceFlags);
|
||||||
|
if (!is_directory &&
|
||||||
|
(win_ace_flags & (SEC_ACE_FLAG_OBJECT_INHERIT|
|
||||||
|
SEC_ACE_FLAG_CONTAINER_INHERIT))) {
|
||||||
/*
|
/*
|
||||||
* GPFS sets inherits dir_inhert and file_inherit flags
|
* GPFS sets inherits dir_inhert and file_inherit flags
|
||||||
* to files, too, which confuses windows, and seems to
|
* to files, too, which confuses windows, and seems to
|
||||||
* be wrong anyways. ==> Map these bits away for files.
|
* be wrong anyways. ==> Map these bits away for files.
|
||||||
*/
|
*/
|
||||||
DEBUG(10, ("removing inherit flags from nfs4 ace\n"));
|
DEBUG(10, ("removing inherit flags from nfs4 ace\n"));
|
||||||
win_ace_flags &= ~(SEC_ACE_FLAG_OBJECT_INHERIT|SEC_ACE_FLAG_CONTAINER_INHERIT);
|
win_ace_flags &= ~(SEC_ACE_FLAG_OBJECT_INHERIT|
|
||||||
|
SEC_ACE_FLAG_CONTAINER_INHERIT);
|
||||||
}
|
}
|
||||||
DEBUG(10, ("Windows mapped ace flags: 0x%x => 0x%x\n",
|
DEBUG(10, ("Windows mapped ace flags: 0x%x => 0x%x\n",
|
||||||
ace->aceFlags, win_ace_flags));
|
ace->aceFlags, win_ace_flags));
|
||||||
@ -389,24 +401,27 @@ static NTSTATUS smb_get_nt_acl_nfs4_common(const SMB_STRUCT_STAT *sbuf,
|
|||||||
}
|
}
|
||||||
|
|
||||||
DEBUG(10,("after make sec_acl\n"));
|
DEBUG(10,("after make sec_acl\n"));
|
||||||
*ppdesc = make_sec_desc(mem_ctx, SD_REVISION, SEC_DESC_SELF_RELATIVE,
|
*ppdesc = make_sec_desc(
|
||||||
(security_info & SECINFO_OWNER) ? &sid_owner : NULL,
|
mem_ctx, SD_REVISION, SEC_DESC_SELF_RELATIVE,
|
||||||
(security_info & SECINFO_GROUP) ? &sid_group : NULL,
|
(security_info & SECINFO_OWNER) ? &sid_owner : NULL,
|
||||||
NULL, psa, &sd_size);
|
(security_info & SECINFO_GROUP) ? &sid_group : NULL,
|
||||||
|
NULL, psa, &sd_size);
|
||||||
if (*ppdesc==NULL) {
|
if (*ppdesc==NULL) {
|
||||||
DEBUG(2,("make_sec_desc failed\n"));
|
DEBUG(2,("make_sec_desc failed\n"));
|
||||||
return NT_STATUS_NO_MEMORY;
|
return NT_STATUS_NO_MEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG(10, ("smb_get_nt_acl_nfs4_common successfully exited with sd_size %d\n",
|
DEBUG(10, ("smb_get_nt_acl_nfs4_common successfully exited with "
|
||||||
|
"sd_size %d\n",
|
||||||
(int)ndr_size_security_descriptor(*ppdesc, 0)));
|
(int)ndr_size_security_descriptor(*ppdesc, 0)));
|
||||||
|
|
||||||
return NT_STATUS_OK;
|
return NT_STATUS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS smb_fget_nt_acl_nfs4(files_struct *fsp,
|
NTSTATUS smb_fget_nt_acl_nfs4(files_struct *fsp,
|
||||||
uint32 security_info,
|
uint32 security_info,
|
||||||
struct security_descriptor **ppdesc, SMB4ACL_T *theacl)
|
struct security_descriptor **ppdesc,
|
||||||
|
SMB4ACL_T *theacl)
|
||||||
{
|
{
|
||||||
SMB_STRUCT_STAT sbuf;
|
SMB_STRUCT_STAT sbuf;
|
||||||
|
|
||||||
@ -416,13 +431,15 @@ NTSTATUS smb_fget_nt_acl_nfs4(files_struct *fsp,
|
|||||||
return map_nt_error_from_unix(errno);
|
return map_nt_error_from_unix(errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
return smb_get_nt_acl_nfs4_common(&sbuf, security_info, ppdesc, theacl);
|
return smb_get_nt_acl_nfs4_common(&sbuf, security_info, ppdesc,
|
||||||
|
theacl);
|
||||||
}
|
}
|
||||||
|
|
||||||
NTSTATUS smb_get_nt_acl_nfs4(struct connection_struct *conn,
|
NTSTATUS smb_get_nt_acl_nfs4(struct connection_struct *conn,
|
||||||
const char *name,
|
const char *name,
|
||||||
uint32 security_info,
|
uint32 security_info,
|
||||||
struct security_descriptor **ppdesc, SMB4ACL_T *theacl)
|
struct security_descriptor **ppdesc,
|
||||||
|
SMB4ACL_T *theacl)
|
||||||
{
|
{
|
||||||
SMB_STRUCT_STAT sbuf;
|
SMB_STRUCT_STAT sbuf;
|
||||||
|
|
||||||
@ -432,7 +449,8 @@ NTSTATUS smb_get_nt_acl_nfs4(struct connection_struct *conn,
|
|||||||
return map_nt_error_from_unix(errno);
|
return map_nt_error_from_unix(errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
return smb_get_nt_acl_nfs4_common(&sbuf, security_info, ppdesc, theacl);
|
return smb_get_nt_acl_nfs4_common(&sbuf, security_info, ppdesc,
|
||||||
|
theacl);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum smbacl4_mode_enum {e_simple=0, e_special=1};
|
enum smbacl4_mode_enum {e_simple=0, e_special=1};
|
||||||
@ -492,14 +510,17 @@ static void smbacl4_dump_nfs4acl(int level, SMB4ACL_T *theacl)
|
|||||||
|
|
||||||
DEBUG(level, ("NFS4ACL: size=%d\n", aclint->naces));
|
DEBUG(level, ("NFS4ACL: size=%d\n", aclint->naces));
|
||||||
|
|
||||||
for(aceint = aclint->first; aceint!=NULL; aceint=(SMB_ACE4_INT_T *)aceint->next) {
|
for (aceint = aclint->first;
|
||||||
|
aceint!=NULL;
|
||||||
|
aceint=(SMB_ACE4_INT_T *)aceint->next) {
|
||||||
SMB_ACE4PROP_T *ace = &aceint->prop;
|
SMB_ACE4PROP_T *ace = &aceint->prop;
|
||||||
|
|
||||||
DEBUG(level, ("\tACE: type=%d, flags=0x%x, fflags=0x%x, mask=0x%x, id=%d\n",
|
DEBUG(level, ("\tACE: type=%d, flags=0x%x, fflags=0x%x, "
|
||||||
ace->aceType,
|
"mask=0x%x, id=%d\n",
|
||||||
ace->aceFlags, ace->flags,
|
ace->aceType,
|
||||||
ace->aceMask,
|
ace->aceFlags, ace->flags,
|
||||||
ace->who.id));
|
ace->aceMask,
|
||||||
|
ace->who.id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -515,7 +536,8 @@ static SMB_ACE4PROP_T *smbacl4_find_equal_special(
|
|||||||
SMB_ACL4_INT_T *aclint = get_validated_aclint(theacl);
|
SMB_ACL4_INT_T *aclint = get_validated_aclint(theacl);
|
||||||
SMB_ACE4_INT_T *aceint;
|
SMB_ACE4_INT_T *aceint;
|
||||||
|
|
||||||
for(aceint = aclint->first; aceint!=NULL; aceint=(SMB_ACE4_INT_T *)aceint->next) {
|
for (aceint = aclint->first; aceint != NULL;
|
||||||
|
aceint=(SMB_ACE4_INT_T *)aceint->next) {
|
||||||
SMB_ACE4PROP_T *ace = &aceint->prop;
|
SMB_ACE4PROP_T *ace = &aceint->prop;
|
||||||
|
|
||||||
DEBUG(10,("ace type:0x%x flags:0x%x aceFlags:0x%x "
|
DEBUG(10,("ace type:0x%x flags:0x%x aceFlags:0x%x "
|
||||||
@ -530,7 +552,8 @@ static SMB_ACE4PROP_T *smbacl4_find_equal_special(
|
|||||||
/* keep type safety; e.g. gid is an u.short */
|
/* keep type safety; e.g. gid is an u.short */
|
||||||
if (ace->flags & SMB_ACE4_ID_SPECIAL)
|
if (ace->flags & SMB_ACE4_ID_SPECIAL)
|
||||||
{
|
{
|
||||||
if (ace->who.special_id==aceNew->who.special_id)
|
if (ace->who.special_id ==
|
||||||
|
aceNew->who.special_id)
|
||||||
return ace;
|
return ace;
|
||||||
} else {
|
} else {
|
||||||
if (ace->aceFlags & SMB_ACE4_IDENTIFIER_GROUP)
|
if (ace->aceFlags & SMB_ACE4_IDENTIFIER_GROUP)
|
||||||
@ -617,8 +640,12 @@ static bool smbacl4_fill_ace4(
|
|||||||
DEBUG(10, ("got ace for %s\n", sid_string_dbg(&ace_nt->trustee)));
|
DEBUG(10, ("got ace for %s\n", sid_string_dbg(&ace_nt->trustee)));
|
||||||
|
|
||||||
memset(ace_v4, 0, sizeof(SMB_ACE4PROP_T));
|
memset(ace_v4, 0, sizeof(SMB_ACE4PROP_T));
|
||||||
ace_v4->aceType = ace_nt->type; /* only ACCESS|DENY supported right now */
|
|
||||||
ace_v4->aceFlags = map_windows_ace_flags_to_nfs4_ace_flags(ace_nt->flags);
|
/* only ACCESS|DENY supported right now */
|
||||||
|
ace_v4->aceType = ace_nt->type;
|
||||||
|
|
||||||
|
ace_v4->aceFlags = map_windows_ace_flags_to_nfs4_ace_flags(
|
||||||
|
ace_nt->flags);
|
||||||
ace_v4->aceMask = ace_nt->access_mask &
|
ace_v4->aceMask = ace_nt->access_mask &
|
||||||
(SEC_STD_ALL | SEC_FILE_ALL);
|
(SEC_STD_ALL | SEC_FILE_ALL);
|
||||||
|
|
||||||
@ -650,19 +677,22 @@ static bool smbacl4_fill_ace4(
|
|||||||
|
|
||||||
if (!nfs4_map_sid(params, &sid, &mapped)) {
|
if (!nfs4_map_sid(params, &sid, &mapped)) {
|
||||||
DEBUG(1, ("nfs4_acls.c: file [%s]: SID %s "
|
DEBUG(1, ("nfs4_acls.c: file [%s]: SID %s "
|
||||||
"unknown\n", filename, sid_string_dbg(&sid)));
|
"unknown\n", filename,
|
||||||
|
sid_string_dbg(&sid)));
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEBUG(2, ("nfs4_acls.c: file [%s]: mapped SID %s "
|
DEBUG(2, ("nfs4_acls.c: file [%s]: mapped SID %s "
|
||||||
"to %s\n", filename, sid_string_dbg(&sid), sid_string_dbg(&mapped)));
|
"to %s\n", filename, sid_string_dbg(&sid),
|
||||||
|
sid_string_dbg(&mapped)));
|
||||||
|
|
||||||
if (!lookup_sid(mem_ctx, &mapped, &dom,
|
if (!lookup_sid(mem_ctx, &mapped, &dom,
|
||||||
&name, &type)) {
|
&name, &type)) {
|
||||||
DEBUG(1, ("nfs4_acls.c: file [%s]: SID %s "
|
DEBUG(1, ("nfs4_acls.c: file [%s]: SID %s "
|
||||||
"mapped from %s is unknown\n",
|
"mapped from %s is unknown\n",
|
||||||
filename, sid_string_dbg(&mapped), sid_string_dbg(&sid)));
|
filename, sid_string_dbg(&mapped),
|
||||||
|
sid_string_dbg(&sid)));
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return False;
|
return False;
|
||||||
}
|
}
|
||||||
@ -806,7 +836,8 @@ NTSTATUS smb_set_nt_acl_nfs4(files_struct *fsp,
|
|||||||
{
|
{
|
||||||
DEBUG(9, ("security_info_sent (0x%x) ignored\n",
|
DEBUG(9, ("security_info_sent (0x%x) ignored\n",
|
||||||
security_info_sent));
|
security_info_sent));
|
||||||
return NT_STATUS_OK; /* won't show error - later to be refined... */
|
return NT_STATUS_OK; /* won't show error - later to be
|
||||||
|
* refined... */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Special behaviours */
|
/* Special behaviours */
|
||||||
@ -818,7 +849,8 @@ NTSTATUS smb_set_nt_acl_nfs4(files_struct *fsp,
|
|||||||
|
|
||||||
if (params.do_chown) {
|
if (params.do_chown) {
|
||||||
/* chown logic is a copy/paste from posix_acl.c:set_nt_acl */
|
/* chown logic is a copy/paste from posix_acl.c:set_nt_acl */
|
||||||
NTSTATUS status = unpack_nt_owners(fsp->conn, &newUID, &newGID, security_info_sent, psd);
|
NTSTATUS status = unpack_nt_owners(fsp->conn, &newUID, &newGID,
|
||||||
|
security_info_sent, psd);
|
||||||
if (!NT_STATUS_IS_OK(status)) {
|
if (!NT_STATUS_IS_OK(status)) {
|
||||||
DEBUG(8, ("unpack_nt_owners failed"));
|
DEBUG(8, ("unpack_nt_owners failed"));
|
||||||
return status;
|
return status;
|
||||||
@ -852,7 +884,8 @@ NTSTATUS smb_set_nt_acl_nfs4(files_struct *fsp,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!(security_info_sent & SECINFO_DACL) || psd->dacl ==NULL) {
|
if (!(security_info_sent & SECINFO_DACL) || psd->dacl ==NULL) {
|
||||||
DEBUG(10, ("no dacl found; security_info_sent = 0x%x\n", security_info_sent));
|
DEBUG(10, ("no dacl found; security_info_sent = 0x%x\n",
|
||||||
|
security_info_sent));
|
||||||
return NT_STATUS_OK;
|
return NT_STATUS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -873,7 +906,8 @@ NTSTATUS smb_set_nt_acl_nfs4(files_struct *fsp,
|
|||||||
}
|
}
|
||||||
if (result!=True) {
|
if (result!=True) {
|
||||||
errno = saved_errno;
|
errno = saved_errno;
|
||||||
DEBUG(10, ("set_nfs4_native failed with %s\n", strerror(errno)));
|
DEBUG(10, ("set_nfs4_native failed with %s\n",
|
||||||
|
strerror(errno)));
|
||||||
return map_nt_error_from_unix(errno);
|
return map_nt_error_from_unix(errno);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user