| 1 | /*
|
|---|
| 2 | Unix SMB/CIFS implementation.
|
|---|
| 3 | Portable SMB ACL interface
|
|---|
| 4 | Copyright (C) Jeremy Allison 2000
|
|---|
| 5 | Copyright (C) Andrew Bartlett 2012
|
|---|
| 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 |
|
|---|
| 22 | /*
|
|---|
| 23 | * Allow the smb_acl interface to be pushed into an NDR blob and
|
|---|
| 24 | * read/written in python.
|
|---|
| 25 | *
|
|---|
| 26 | * The exact layout of these stuctures is CRITICAL, as a SHA-256 hash is
|
|---|
| 27 | * taken over these after they are pushed as NDR blobs, and stored in an
|
|---|
| 28 | * xattr for ACL verification.
|
|---|
| 29 | */
|
|---|
| 30 | [
|
|---|
| 31 | pointer_default(unique)
|
|---|
| 32 | ]
|
|---|
| 33 | interface smb_acl
|
|---|
| 34 | {
|
|---|
| 35 |
|
|---|
| 36 | const int SMB_ACL_READ = 4;
|
|---|
| 37 | const int SMB_ACL_WRITE = 2;
|
|---|
| 38 | const int SMB_ACL_EXECUTE = 1;
|
|---|
| 39 |
|
|---|
| 40 | /* Types of ACLs. */
|
|---|
| 41 | typedef enum {
|
|---|
| 42 | SMB_ACL_TAG_INVALID = 0,
|
|---|
| 43 | SMB_ACL_USER = 1,
|
|---|
| 44 | SMB_ACL_USER_OBJ = 2,
|
|---|
| 45 | SMB_ACL_GROUP = 3,
|
|---|
| 46 | SMB_ACL_GROUP_OBJ = 4,
|
|---|
| 47 | SMB_ACL_OTHER = 5,
|
|---|
| 48 | SMB_ACL_MASK = 6
|
|---|
| 49 | } smb_acl_tag_t;
|
|---|
| 50 |
|
|---|
| 51 | typedef struct {
|
|---|
| 52 | uid_t uid;
|
|---|
| 53 | } smb_acl_user;
|
|---|
| 54 |
|
|---|
| 55 | typedef struct {
|
|---|
| 56 | gid_t gid;
|
|---|
| 57 | } smb_acl_group;
|
|---|
| 58 |
|
|---|
| 59 | typedef [switch_type(uint16)] union {
|
|---|
| 60 | [case (SMB_ACL_USER)] smb_acl_user user;
|
|---|
| 61 | [case (SMB_ACL_USER_OBJ)];
|
|---|
| 62 | [case (SMB_ACL_GROUP)] smb_acl_group group;
|
|---|
| 63 | [case (SMB_ACL_GROUP_OBJ)];
|
|---|
| 64 | [case (SMB_ACL_OTHER)];
|
|---|
| 65 | [case (SMB_ACL_MASK)];
|
|---|
| 66 | } smb_acl_entry_info;
|
|---|
| 67 |
|
|---|
| 68 | typedef struct {
|
|---|
| 69 | smb_acl_tag_t a_type;
|
|---|
| 70 | [switch_is(a_type)] smb_acl_entry_info info;
|
|---|
| 71 | mode_t a_perm;
|
|---|
| 72 | } smb_acl_entry;
|
|---|
| 73 |
|
|---|
| 74 | [public] typedef struct {
|
|---|
| 75 | int count;
|
|---|
| 76 | [value(0)] int next;
|
|---|
| 77 | [size_is(count)] smb_acl_entry acl[*];
|
|---|
| 78 | } smb_acl_t;
|
|---|
| 79 |
|
|---|
| 80 | const int SMB_ACL_FIRST_ENTRY = 0;
|
|---|
| 81 | const int SMB_ACL_NEXT_ENTRY = 1;
|
|---|
| 82 |
|
|---|
| 83 | const int SMB_ACL_TYPE_ACCESS = 0;
|
|---|
| 84 | const int SMB_ACL_TYPE_DEFAULT = 1;
|
|---|
| 85 |
|
|---|
| 86 | /* A wrapper of all the information required to reproduce an
|
|---|
| 87 | * ACL, so we can hash it for the acl_xattr and acl_tdb
|
|---|
| 88 | * modules */
|
|---|
| 89 | [public] typedef struct {
|
|---|
| 90 | smb_acl_t *access_acl;
|
|---|
| 91 | smb_acl_t *default_acl; /* NULL on files */
|
|---|
| 92 | uid_t owner;
|
|---|
| 93 | gid_t group;
|
|---|
| 94 | mode_t mode;
|
|---|
| 95 | } smb_acl_wrapper;
|
|---|
| 96 | }
|
|---|