Vector get_nt_acl/set_nt_acl via vfs. POSIX ACL support should be added
[samba.git] / source / include / vfs.h
1 /* 
2    Unix SMB/Netbios implementation.
3    Version 1.9.
4    VFS structures and parameters
5    Copyright (C) Tim Potter 1999
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 2 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, write to the Free Software
19    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 */
21
22 #ifndef _VFS_H
23 #define _VFS_H
24
25 /* Types used in the definition of VFS operations.  These are included
26    here so the vfs.h file can be included by VFS modules without
27    having to pull in unnecessary amounts of other stuff.  Note to VFS
28    writers: you must include config.h before including this file.
29    The following type definitions reference the HAVE_* symbols which
30    are defined in config.h */
31
32 #ifndef SMB_OFF_T
33 #  ifdef HAVE_OFF64_T
34 #    define SMB_OFF_T off64_t
35 #  else
36 #    define SMB_OFF_T off_t
37 #  endif
38 #endif
39
40 #ifndef SMB_STRUCT_STAT
41 #  if defined(HAVE_STAT64) && defined(HAVE_OFF64_T)
42 #    define SMB_STRUCT_STAT struct stat64
43 #  else
44 #    define SMB_STRUCT_STAT struct stat
45 #  endif
46 #endif
47
48 #ifndef _BOOL
49 typedef int BOOL;
50 #endif
51
52 #ifndef _PSTRING
53 #define PSTRING_LEN 1024
54 #define FSTRING_LEN 128
55
56 typedef char pstring[PSTRING_LEN];
57 typedef char fstring[FSTRING_LEN];
58 #define _PSTRING
59 #endif
60
61 #if defined(HAVE_LONGLONG)
62 #define SMB_BIG_UINT unsigned long long
63 #else
64 #define SMB_BIG_UINT unsigned long
65 #endif
66
67 #ifndef MAXSUBAUTHS
68 #define MAXSUBAUTHS 15 /* max sub authorities in a SID */
69 #endif
70
71 #ifndef uint8
72 #define uint8 unsigned char
73 #endif 
74
75 #if !defined(uint32) && !defined(HAVE_UINT32_FROM_RPC_RPC_H)
76 #if (SIZEOF_INT == 4)
77 #define uint32 unsigned int
78 #elif (SIZEOF_LONG == 4)
79 #define uint32 unsigned long
80 #elif (SIZEOF_SHORT == 4)
81 #define uint32 unsigned short
82 #endif
83 #endif
84
85 #ifndef _DOM_SID
86 /* DOM_SID - security id */
87 typedef struct sid_info
88 {
89   uint8  sid_rev_num;             /* SID revision number */
90   uint8  num_auths;               /* number of sub-authorities */
91   uint8  id_auth[6];              /* Identifier Authority */
92   /*
93    * Note that the values in these uint32's are in *native* byteorder,
94    * not neccessarily little-endian...... JRA.
95    */
96   uint32 sub_auths[MAXSUBAUTHS];  /* pointer to sub-authorities. */
97
98 } DOM_SID;
99 #define _DOM_SID
100 #endif
101
102 #ifndef _SEC_ACCESS
103 /* SEC_ACCESS */
104 typedef struct security_info_info
105 {
106     uint32 mask;
107
108 } SEC_ACCESS;
109 #define _SEC_ACCESS
110 #endif
111
112 #ifndef _SEC_ACE
113 /* SEC_ACE */
114 typedef struct security_ace_info
115 {
116     uint8 type;  /* xxxx_xxxx_ACE_TYPE - e.g allowed / denied etc */
117     uint8 flags; /* xxxx_INHERIT_xxxx - e.g OBJECT_INHERIT_ACE */
118     uint16 size;
119
120     SEC_ACCESS info;
121     DOM_SID sid;
122
123 } SEC_ACE;
124 #define _SEC_ACE
125 #endif
126
127 #ifndef ACL_REVISION
128 #define ACL_REVISION 0x3
129 #endif
130
131 #ifndef _SEC_ACL
132 /* SEC_ACL */
133 typedef struct security_acl_info
134 {
135     uint16 revision; /* 0x0003 */
136     uint16 size; /* size in bytes of the entire ACL structure */
137     uint32 num_aces; /* number of Access Control Entries */
138
139     SEC_ACE *ace;
140
141 } SEC_ACL;
142 #define _SEC_ACL
143 #endif
144
145 #ifndef SEC_DESC_REVISION
146 #define SEC_DESC_REVISION 0x1
147 #endif
148
149 #ifndef _SEC_DESC
150 /* SEC_DESC */
151 typedef struct security_descriptor_info
152 {
153     uint16 revision; /* 0x0001 */
154     uint16 type;     /* SEC_DESC_xxxx flags */
155
156     uint32 off_owner_sid; /* offset to owner sid */
157     uint32 off_grp_sid  ; /* offset to group sid */
158     uint32 off_sacl     ; /* offset to system list of permissions */
159     uint32 off_dacl     ; /* offset to list of permissions */
160
161     SEC_ACL *dacl; /* user ACL */
162     SEC_ACL *sacl; /* system ACL */
163     DOM_SID *owner_sid;
164     DOM_SID *grp_sid;
165
166 } SEC_DESC;
167 #define _SEC_DESC
168 #endif
169
170 /*
171  * The complete list of SIDS belonging to this user.
172  * Created when a vuid is registered.
173  */
174
175 #ifndef _NT_USER_TOKEN
176 typedef struct _nt_user_token {
177     size_t num_sids;
178     DOM_SID *user_sids;
179 } NT_USER_TOKEN;
180 #define _NT_USER_TOKEN
181 #endif
182
183 /* Avoid conflict with an AIX include file */
184
185 #ifdef vfs_ops
186 #undef vfs_ops
187 #endif
188
189 /* Information from the connection_struct passed to the vfs layer */
190
191 struct vfs_connection_struct {
192
193     /* Connection information */
194
195     BOOL printer;
196     BOOL ipc;
197     BOOL read_only;
198     BOOL admin_user;
199
200     /* Handle on dlopen() call */
201
202     void *dl_handle;
203
204     /* Paths */
205
206     pstring dirpath;
207     pstring connectpath;
208     pstring origpath;
209     pstring service;
210     
211     /* Information on user who *opened* this connection */
212
213     pstring user;
214     uid_t uid;
215     gid_t gid;
216     int ngroups;
217     gid_t *groups;
218         NT_USER_TOKEN *nt_user_token;
219 };
220
221 /* VFS operations structure */
222
223 struct vfs_ops {
224
225     /* Disk operations */
226     
227     int (*connect)(struct vfs_connection_struct *conn, char *service, char *user);
228     void (*disconnect)(void);
229     SMB_BIG_UINT (*disk_free)(char *path, BOOL small_query, SMB_BIG_UINT *bsize, 
230                               SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize);
231     
232     /* Directory operations */
233
234     DIR *(*opendir)(char *fname);
235     struct dirent *(*readdir)(DIR *dirp);
236     int (*mkdir)(char *path, mode_t mode);
237     int (*rmdir)(char *path);
238     int (*closedir)(DIR *dir);
239     
240     /* File operations */
241     
242     int (*open)(char *fname, int flags, mode_t mode);
243     int (*close)(int fd);
244     ssize_t (*read)(int fd, char *data, size_t n);
245     ssize_t (*write)(int fd, char *data, size_t n);
246     SMB_OFF_T (*lseek)(int filedes, SMB_OFF_T offset, int whence);
247     int (*rename)(char *old, char *new);
248     int (*fsync)(int fd);
249     int (*stat)(char *fname, SMB_STRUCT_STAT *sbuf);
250     int (*fstat)(int fd, SMB_STRUCT_STAT *sbuf);
251     int (*lstat)(char *path, SMB_STRUCT_STAT *sbuf);
252     int (*unlink)(char *path);
253     int (*chmod)(char *path, mode_t mode);
254         int (*chown)(char *path, uid_t uid, gid_t gid);
255         int (*chdir)(char *path);
256         char *(*getwd)(char *buf);
257     int (*utime)(char *path, struct utimbuf *times);
258         int (*ftruncate)(int fd, SMB_OFF_T offset);
259         BOOL (*lock)(int fd, int op, SMB_OFF_T offset, SMB_OFF_T count, int type);
260
261         size_t (*fget_nt_acl)(int fd, SEC_DESC **ppdesc);
262         size_t (*get_nt_acl)(char *name, SEC_DESC **ppdesc);
263         BOOL (*fset_nt_acl)(int fd, uint32 security_info_sent, SEC_DESC *psd);
264         BOOL (*set_nt_acl)(char *name, uint32 security_info_sent, SEC_DESC *psd);
265 };
266
267 struct vfs_options {
268     struct vfs_options *prev, *next;
269     char *name;
270     char *value;
271 };
272
273 #endif /* _VFS_H */