| 1 | /*
|
|---|
| 2 | * Store Windows ACLs in xattrs.
|
|---|
| 3 | *
|
|---|
| 4 | * Copyright (C) Volker Lendecke, 2008
|
|---|
| 5 | * Copyright (C) Jeremy Allison, 2008
|
|---|
| 6 | *
|
|---|
| 7 | * This program is free software; you can redistribute it and/or modify
|
|---|
| 8 | * it under the terms of the GNU General Public License as published by
|
|---|
| 9 | * the Free Software Foundation; either version 3 of the License, or
|
|---|
| 10 | * (at your option) any later version.
|
|---|
| 11 | *
|
|---|
| 12 | * This program is distributed in the hope that it will be useful,
|
|---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 15 | * GNU General Public License for more details.
|
|---|
| 16 | *
|
|---|
| 17 | * You should have received a copy of the GNU General Public License
|
|---|
| 18 | * along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|---|
| 19 | */
|
|---|
| 20 |
|
|---|
| 21 | /* NOTE: This is an experimental module, not yet finished. JRA. */
|
|---|
| 22 |
|
|---|
| 23 | #include "includes.h"
|
|---|
| 24 | #include "smbd/smbd.h"
|
|---|
| 25 | #include "librpc/gen_ndr/xattr.h"
|
|---|
| 26 | #include "librpc/gen_ndr/ndr_xattr.h"
|
|---|
| 27 | #include "../lib/crypto/crypto.h"
|
|---|
| 28 | #include "auth.h"
|
|---|
| 29 |
|
|---|
| 30 | #undef DBGC_CLASS
|
|---|
| 31 | #define DBGC_CLASS DBGC_VFS
|
|---|
| 32 |
|
|---|
| 33 | /* Pull in the common functions. */
|
|---|
| 34 | #define ACL_MODULE_NAME "acl_xattr"
|
|---|
| 35 |
|
|---|
| 36 | #include "modules/vfs_acl_common.c"
|
|---|
| 37 |
|
|---|
| 38 | /*******************************************************************
|
|---|
| 39 | Pull a security descriptor into a DATA_BLOB from a xattr.
|
|---|
| 40 | *******************************************************************/
|
|---|
| 41 |
|
|---|
| 42 | static NTSTATUS get_acl_blob(TALLOC_CTX *ctx,
|
|---|
| 43 | vfs_handle_struct *handle,
|
|---|
| 44 | files_struct *fsp,
|
|---|
| 45 | const char *name,
|
|---|
| 46 | DATA_BLOB *pblob)
|
|---|
| 47 | {
|
|---|
| 48 | size_t size = 1024;
|
|---|
| 49 | uint8_t *val = NULL;
|
|---|
| 50 | uint8_t *tmp;
|
|---|
| 51 | ssize_t sizeret;
|
|---|
| 52 | int saved_errno = 0;
|
|---|
| 53 |
|
|---|
| 54 | ZERO_STRUCTP(pblob);
|
|---|
| 55 |
|
|---|
| 56 | again:
|
|---|
| 57 |
|
|---|
| 58 | tmp = TALLOC_REALLOC_ARRAY(ctx, val, uint8_t, size);
|
|---|
| 59 | if (tmp == NULL) {
|
|---|
| 60 | TALLOC_FREE(val);
|
|---|
| 61 | return NT_STATUS_NO_MEMORY;
|
|---|
| 62 | }
|
|---|
| 63 | val = tmp;
|
|---|
| 64 |
|
|---|
| 65 | become_root();
|
|---|
| 66 | if (fsp && fsp->fh->fd != -1) {
|
|---|
| 67 | sizeret = SMB_VFS_FGETXATTR(fsp, XATTR_NTACL_NAME, val, size);
|
|---|
| 68 | } else {
|
|---|
| 69 | sizeret = SMB_VFS_GETXATTR(handle->conn, name,
|
|---|
| 70 | XATTR_NTACL_NAME, val, size);
|
|---|
| 71 | }
|
|---|
| 72 | if (sizeret == -1) {
|
|---|
|
|---|