70ad6ee253411b15d4f8a91ca337982232ddd022
[samba.git] / source4 / ntvfs / unixuid / vfs_unixuid.c
1 /* 
2    Unix SMB/CIFS implementation.
3
4    a pass-thru NTVFS module to setup a security context using unix
5    uid/gid
6
7    Copyright (C) Andrew Tridgell 2004
8
9    This program is free software; you can redistribute it and/or modify
10    it under the terms of the GNU General Public License as published by
11    the Free Software Foundation; either version 3 of the License, or
12    (at your option) any later version.
13    
14    This program is distributed in the hope that it will be useful,
15    but WITHOUT ANY WARRANTY; without even the implied warranty of
16    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17    GNU General Public License for more details.
18    
19    You should have received a copy of the GNU General Public License
20    along with this program.  If not, see <http://www.gnu.org/licenses/>.
21 */
22
23 #include "includes.h"
24 #include "system/filesys.h"
25 #include "system/passwd.h"
26 #include "auth/auth.h"
27 #include "ntvfs/ntvfs.h"
28 #include "libcli/wbclient/wbclient.h"
29 #define TEVENT_DEPRECATED
30 #include <tevent.h>
31
32 struct unixuid_private {
33         struct wbc_context *wbc_ctx;
34         struct unix_sec_ctx *last_sec_ctx;
35         struct security_token *last_token;
36 };
37
38
39
40 struct unix_sec_ctx {
41         uid_t uid;
42         gid_t gid;
43         uint_t ngroups;
44         gid_t *groups;
45 };
46
47 /*
48   pull the current security context into a unix_sec_ctx
49 */
50 static struct unix_sec_ctx *save_unix_security(TALLOC_CTX *mem_ctx)
51 {
52         struct unix_sec_ctx *sec = talloc(mem_ctx, struct unix_sec_ctx);
53         if (sec == NULL) {
54                 return NULL;
55         }
56         sec->uid = geteuid();
57         sec->gid = getegid();
58         sec->ngroups = getgroups(0, NULL);
59         if (sec->ngroups == -1) {
60                 talloc_free(sec);
61                 return NULL;
62         }
63         sec->groups = talloc_array(sec, gid_t, sec->ngroups);
64         if (sec->groups == NULL) {
65                 talloc_free(sec);
66                 return NULL;
67         }
68
69         if (getgroups(sec->ngroups, sec->groups) != sec->ngroups) {
70                 talloc_free(sec);
71                 return NULL;
72         }
73
74         return sec;
75 }
76
77 /*
78   set the current security context from a unix_sec_ctx
79 */
80 static NTSTATUS set_unix_security(struct unix_sec_ctx *sec)
81 {
82         seteuid(0);
83
84         if (setgroups(sec->ngroups, sec->groups) != 0) {
85                 return NT_STATUS_ACCESS_DENIED;
86         }
87         if (setegid(sec->gid) != 0) {
88                 return NT_STATUS_ACCESS_DENIED;
89         }
90         if (seteuid(sec->uid) != 0) {
91                 return NT_STATUS_ACCESS_DENIED;
92         }
93         return NT_STATUS_OK;
94 }
95
96 static int unixuid_nesting_level;
97
98 /*
99   called at the start and end of a tevent nesting loop. Needs to save/restore
100   unix security context
101  */
102 static int unixuid_event_nesting_hook(struct tevent_context *ev,
103                                       void *private_data,
104                                       uint32_t level,
105                                       bool begin,
106                                       void *stack_ptr,
107                                       const char *location)
108 {
109         struct unix_sec_ctx *sec_ctx;
110
111         if (unixuid_nesting_level == 0) {
112                 /* we don't need to do anything unless we are nested
113                    inside of a call in this module */
114                 return 0;
115         }
116
117         if (begin) {
118                 sec_ctx = save_unix_security(ev);
119                 if (sec_ctx == NULL) {
120                         DEBUG(0,("%s: Failed to save security context\n", location));
121                         return -1;
122                 }
123                 *(struct unix_sec_ctx **)stack_ptr = sec_ctx;
124                 if (seteuid(0) != 0 || setegid(0) != 0) {
125                         DEBUG(0,("%s: Failed to change to root\n", location));
126                         return -1;                      
127                 }
128         } else {
129                 /* called when we come out of a nesting level */
130                 NTSTATUS status;
131
132                 sec_ctx = *(struct unix_sec_ctx **)stack_ptr;
133                 if (sec_ctx == NULL) {
134                         /* this happens the first time this function
135                            is called, as we install the hook while
136                            inside an event in unixuid_connect() */
137                         return 0;
138                 }
139
140                 sec_ctx = talloc_get_type_abort(sec_ctx, struct unix_sec_ctx);
141                 status = set_unix_security(sec_ctx);
142                 talloc_free(sec_ctx);
143                 if (!NT_STATUS_IS_OK(status)) {
144                         DEBUG(0,("%s: Failed to revert security context (%s)\n", 
145                                  location, nt_errstr(status)));
146                         return -1;
147                 }
148         }
149
150         return 0;
151 }
152
153
154 /*
155   form a unix_sec_ctx from the current security_token
156 */
157 static NTSTATUS nt_token_to_unix_security(struct ntvfs_module_context *ntvfs,
158                                           struct ntvfs_request *req,
159                                           struct security_token *token,
160                                           struct unix_sec_ctx **sec)
161 {
162         struct unixuid_private *priv = ntvfs->private_data;
163         int i;
164         NTSTATUS status;
165         struct id_mapping *ids;
166         struct composite_context *ctx;
167         *sec = talloc(req, struct unix_sec_ctx);
168
169         /* we can't do unix security without a user and group */
170         if (token->num_sids < 2) {
171                 return NT_STATUS_ACCESS_DENIED;
172         }
173
174         ids = talloc_array(req, struct id_mapping, token->num_sids);
175         NT_STATUS_HAVE_NO_MEMORY(ids);
176
177         ids[0].unixid = NULL;
178         ids[0].sid = token->user_sid;
179         ids[0].status = NT_STATUS_NONE_MAPPED;
180
181         ids[1].unixid = NULL;
182         ids[1].sid = token->group_sid;
183         ids[1].status = NT_STATUS_NONE_MAPPED;
184
185         (*sec)->ngroups = token->num_sids - 2;
186         (*sec)->groups = talloc_array(*sec, gid_t, (*sec)->ngroups);
187         NT_STATUS_HAVE_NO_MEMORY((*sec)->groups);
188
189         for (i=0;i<(*sec)->ngroups;i++) {
190                 ids[i+2].unixid = NULL;
191                 ids[i+2].sid = token->sids[i+2];
192                 ids[i+2].status = NT_STATUS_NONE_MAPPED;
193         }
194
195         ctx = wbc_sids_to_xids_send(priv->wbc_ctx, ids, token->num_sids, ids);
196         NT_STATUS_HAVE_NO_MEMORY(ctx);
197
198         status = wbc_sids_to_xids_recv(ctx, &ids);
199         NT_STATUS_NOT_OK_RETURN(status);
200
201         if (ids[0].unixid->type == ID_TYPE_BOTH ||
202             ids[0].unixid->type == ID_TYPE_UID) {
203                 (*sec)->uid = ids[0].unixid->id;
204         } else {
205                 return NT_STATUS_INVALID_SID;
206         }
207
208         if (ids[1].unixid->type == ID_TYPE_BOTH ||
209             ids[1].unixid->type == ID_TYPE_GID) {
210                 (*sec)->gid = ids[1].unixid->id;
211         } else {
212                 return NT_STATUS_INVALID_SID;
213         }
214
215         for (i=0;i<(*sec)->ngroups;i++) {
216                 if (ids[i+2].unixid->type == ID_TYPE_BOTH ||
217                     ids[i+2].unixid->type == ID_TYPE_GID) {
218                         (*sec)->groups[i] = ids[i+2].unixid->id;
219                 } else {
220                         return NT_STATUS_INVALID_SID;
221                 }
222         }
223
224         return NT_STATUS_OK;
225 }
226
227 /*
228   setup our unix security context according to the session authentication info
229 */
230 static NTSTATUS unixuid_setup_security(struct ntvfs_module_context *ntvfs,
231                                        struct ntvfs_request *req, struct unix_sec_ctx **sec)
232 {
233         struct unixuid_private *priv = ntvfs->private_data;
234         struct security_token *token;
235         struct unix_sec_ctx *newsec;
236         NTSTATUS status;
237
238         /* If we are asked to set up, but have not had a successful
239          * session setup or tree connect, then these may not be filled
240          * in.  ACCESS_DENIED is the right error code here */
241         if (req->session_info == NULL || priv == NULL) {
242                 return NT_STATUS_ACCESS_DENIED;
243         }
244
245         token = req->session_info->security_token;
246
247         *sec = save_unix_security(ntvfs);
248         if (*sec == NULL) {
249                 return NT_STATUS_NO_MEMORY;
250         }
251
252         if (token == priv->last_token) {
253                 newsec = priv->last_sec_ctx;
254         } else {
255                 status = nt_token_to_unix_security(ntvfs, req, token, &newsec);
256                 if (!NT_STATUS_IS_OK(status)) {
257                         talloc_free(*sec);
258                         return status;
259                 }
260                 if (priv->last_sec_ctx) {
261                         talloc_free(priv->last_sec_ctx);
262                 }
263                 priv->last_sec_ctx = newsec;
264                 priv->last_token = token;
265                 talloc_steal(priv, newsec);
266         }
267
268         status = set_unix_security(newsec);
269         if (!NT_STATUS_IS_OK(status)) {
270                 talloc_free(*sec);
271                 return status;
272         }
273
274         return NT_STATUS_OK;
275 }
276
277 /*
278   this pass through macro operates on request contexts
279 */
280 #define PASS_THRU_REQ(ntvfs, req, op, args) do { \
281         NTSTATUS status2; \
282         struct unix_sec_ctx *sec; \
283         status = unixuid_setup_security(ntvfs, req, &sec); \
284         NT_STATUS_NOT_OK_RETURN(status); \
285         unixuid_nesting_level++; \
286         status = ntvfs_next_##op args; \
287         unixuid_nesting_level--; \
288         status2 = set_unix_security(sec); \
289         talloc_free(sec); \
290         if (!NT_STATUS_IS_OK(status2)) smb_panic("Unable to reset security context"); \
291 } while (0)
292
293
294
295 /*
296   connect to a share - used when a tree_connect operation comes in.
297 */
298 static NTSTATUS unixuid_connect(struct ntvfs_module_context *ntvfs,
299                                 struct ntvfs_request *req, union smb_tcon *tcon)
300 {
301         struct unixuid_private *priv;
302         NTSTATUS status;
303
304         priv = talloc(ntvfs, struct unixuid_private);
305         if (!priv) {
306                 return NT_STATUS_NO_MEMORY;
307         }
308
309         priv->wbc_ctx = wbc_init(priv, ntvfs->ctx->msg_ctx,
310                                     ntvfs->ctx->event_ctx);
311         if (priv->wbc_ctx == NULL) {
312                 talloc_free(priv);
313                 return NT_STATUS_INTERNAL_ERROR;
314         }
315
316         priv->last_sec_ctx = NULL;
317         priv->last_token = NULL;
318         ntvfs->private_data = priv;
319
320         tevent_loop_set_nesting_hook(ntvfs->ctx->event_ctx, 
321                                      unixuid_event_nesting_hook,
322                                      &unixuid_nesting_level);
323
324         /* we don't use PASS_THRU_REQ here, as the connect operation runs with 
325            root privileges. This allows the backends to setup any database
326            links they might need during the connect. */
327         status = ntvfs_next_connect(ntvfs, req, tcon);
328
329         return status;
330 }
331
332 /*
333   disconnect from a share
334 */
335 static NTSTATUS unixuid_disconnect(struct ntvfs_module_context *ntvfs)
336 {
337         struct unixuid_private *priv = ntvfs->private_data;
338         NTSTATUS status;
339
340         talloc_free(priv);
341         ntvfs->private_data = NULL;
342
343         status = ntvfs_next_disconnect(ntvfs);
344  
345         return status;
346 }
347
348
349 /*
350   delete a file
351 */
352 static NTSTATUS unixuid_unlink(struct ntvfs_module_context *ntvfs,
353                               struct ntvfs_request *req,
354                               union smb_unlink *unl)
355 {
356         NTSTATUS status;
357
358         PASS_THRU_REQ(ntvfs, req, unlink, (ntvfs, req, unl));
359
360         return status;
361 }
362
363 /*
364   ioctl interface
365 */
366 static NTSTATUS unixuid_ioctl(struct ntvfs_module_context *ntvfs,
367                              struct ntvfs_request *req, union smb_ioctl *io)
368 {
369         NTSTATUS status;
370
371         PASS_THRU_REQ(ntvfs, req, ioctl, (ntvfs, req, io));
372
373         return status;
374 }
375
376 /*
377   check if a directory exists
378 */
379 static NTSTATUS unixuid_chkpath(struct ntvfs_module_context *ntvfs,
380                                 struct ntvfs_request *req,
381                                 union smb_chkpath *cp)
382 {
383         NTSTATUS status;
384
385         PASS_THRU_REQ(ntvfs, req, chkpath, (ntvfs, req, cp));
386
387         return status;
388 }
389
390 /*
391   return info on a pathname
392 */
393 static NTSTATUS unixuid_qpathinfo(struct ntvfs_module_context *ntvfs,
394                                  struct ntvfs_request *req, union smb_fileinfo *info)
395 {
396         NTSTATUS status;
397
398         PASS_THRU_REQ(ntvfs, req, qpathinfo, (ntvfs, req, info));
399
400         return status;
401 }
402
403 /*
404   query info on a open file
405 */
406 static NTSTATUS unixuid_qfileinfo(struct ntvfs_module_context *ntvfs,
407                                  struct ntvfs_request *req, union smb_fileinfo *info)
408 {
409         NTSTATUS status;
410
411         PASS_THRU_REQ(ntvfs, req, qfileinfo, (ntvfs, req, info));
412
413         return status;
414 }
415
416
417 /*
418   set info on a pathname
419 */
420 static NTSTATUS unixuid_setpathinfo(struct ntvfs_module_context *ntvfs,
421                                    struct ntvfs_request *req, union smb_setfileinfo *st)
422 {
423         NTSTATUS status;
424
425         PASS_THRU_REQ(ntvfs, req, setpathinfo, (ntvfs, req, st));
426
427         return status;
428 }
429
430 /*
431   open a file
432 */
433 static NTSTATUS unixuid_open(struct ntvfs_module_context *ntvfs,
434                              struct ntvfs_request *req, union smb_open *io)
435 {
436         NTSTATUS status;
437
438         PASS_THRU_REQ(ntvfs, req, open, (ntvfs, req, io));
439
440         return status;
441 }
442
443 /*
444   create a directory
445 */
446 static NTSTATUS unixuid_mkdir(struct ntvfs_module_context *ntvfs,
447                              struct ntvfs_request *req, union smb_mkdir *md)
448 {
449         NTSTATUS status;
450
451         PASS_THRU_REQ(ntvfs, req, mkdir, (ntvfs, req, md));
452
453         return status;
454 }
455
456 /*
457   remove a directory
458 */
459 static NTSTATUS unixuid_rmdir(struct ntvfs_module_context *ntvfs,
460                              struct ntvfs_request *req, struct smb_rmdir *rd)
461 {
462         NTSTATUS status;
463
464         PASS_THRU_REQ(ntvfs, req, rmdir, (ntvfs, req, rd));
465
466         return status;
467 }
468
469 /*
470   rename a set of files
471 */
472 static NTSTATUS unixuid_rename(struct ntvfs_module_context *ntvfs,
473                               struct ntvfs_request *req, union smb_rename *ren)
474 {
475         NTSTATUS status;
476
477         PASS_THRU_REQ(ntvfs, req, rename, (ntvfs, req, ren));
478
479         return status;
480 }
481
482 /*
483   copy a set of files
484 */
485 static NTSTATUS unixuid_copy(struct ntvfs_module_context *ntvfs,
486                             struct ntvfs_request *req, struct smb_copy *cp)
487 {
488         NTSTATUS status;
489
490         PASS_THRU_REQ(ntvfs, req, copy, (ntvfs, req, cp));
491
492         return status;
493 }
494
495 /*
496   read from a file
497 */
498 static NTSTATUS unixuid_read(struct ntvfs_module_context *ntvfs,
499                             struct ntvfs_request *req, union smb_read *rd)
500 {
501         NTSTATUS status;
502
503         PASS_THRU_REQ(ntvfs, req, read, (ntvfs, req, rd));
504
505         return status;
506 }
507
508 /*
509   write to a file
510 */
511 static NTSTATUS unixuid_write(struct ntvfs_module_context *ntvfs,
512                              struct ntvfs_request *req, union smb_write *wr)
513 {
514         NTSTATUS status;
515
516         PASS_THRU_REQ(ntvfs, req, write, (ntvfs, req, wr));
517
518         return status;
519 }
520
521 /*
522   seek in a file
523 */
524 static NTSTATUS unixuid_seek(struct ntvfs_module_context *ntvfs,
525                              struct ntvfs_request *req,
526                              union smb_seek *io)
527 {
528         NTSTATUS status;
529
530         PASS_THRU_REQ(ntvfs, req, seek, (ntvfs, req, io));
531
532         return status;
533 }
534
535 /*
536   flush a file
537 */
538 static NTSTATUS unixuid_flush(struct ntvfs_module_context *ntvfs,
539                               struct ntvfs_request *req,
540                               union smb_flush *io)
541 {
542         NTSTATUS status;
543
544         PASS_THRU_REQ(ntvfs, req, flush, (ntvfs, req, io));
545
546         return status;
547 }
548
549 /*
550   close a file
551 */
552 static NTSTATUS unixuid_close(struct ntvfs_module_context *ntvfs,
553                              struct ntvfs_request *req, union smb_close *io)
554 {
555         NTSTATUS status;
556
557         PASS_THRU_REQ(ntvfs, req, close, (ntvfs, req, io));
558
559         return status;
560 }
561
562 /*
563   exit - closing files
564 */
565 static NTSTATUS unixuid_exit(struct ntvfs_module_context *ntvfs,
566                             struct ntvfs_request *req)
567 {
568         NTSTATUS status;
569
570         PASS_THRU_REQ(ntvfs, req, exit, (ntvfs, req));
571
572         return status;
573 }
574
575 /*
576   logoff - closing files
577 */
578 static NTSTATUS unixuid_logoff(struct ntvfs_module_context *ntvfs,
579                               struct ntvfs_request *req)
580 {
581         struct unixuid_private *priv = ntvfs->private_data;
582         NTSTATUS status;
583
584         PASS_THRU_REQ(ntvfs, req, logoff, (ntvfs, req));
585
586         priv->last_token = NULL;
587
588         return status;
589 }
590
591 /*
592   async setup
593 */
594 static NTSTATUS unixuid_async_setup(struct ntvfs_module_context *ntvfs,
595                                     struct ntvfs_request *req, 
596                                     void *private_data)
597 {
598         NTSTATUS status;
599
600         PASS_THRU_REQ(ntvfs, req, async_setup, (ntvfs, req, private_data));
601
602         return status;
603 }
604
605 /*
606   cancel an async request
607 */
608 static NTSTATUS unixuid_cancel(struct ntvfs_module_context *ntvfs,
609                                struct ntvfs_request *req)
610 {
611         NTSTATUS status;
612
613         PASS_THRU_REQ(ntvfs, req, cancel, (ntvfs, req));
614
615         return status;
616 }
617
618 /*
619   change notify
620 */
621 static NTSTATUS unixuid_notify(struct ntvfs_module_context *ntvfs,
622                                struct ntvfs_request *req, union smb_notify *info)
623 {
624         NTSTATUS status;
625
626         PASS_THRU_REQ(ntvfs, req, notify, (ntvfs, req, info));
627
628         return status;
629 }
630
631 /*
632   lock a byte range
633 */
634 static NTSTATUS unixuid_lock(struct ntvfs_module_context *ntvfs,
635                             struct ntvfs_request *req, union smb_lock *lck)
636 {
637         NTSTATUS status;
638
639         PASS_THRU_REQ(ntvfs, req, lock, (ntvfs, req, lck));
640
641         return status;
642 }
643
644 /*
645   set info on a open file
646 */
647 static NTSTATUS unixuid_setfileinfo(struct ntvfs_module_context *ntvfs,
648                                    struct ntvfs_request *req, 
649                                    union smb_setfileinfo *info)
650 {
651         NTSTATUS status;
652
653         PASS_THRU_REQ(ntvfs, req, setfileinfo, (ntvfs, req, info));
654
655         return status;
656 }
657
658
659 /*
660   return filesystem space info
661 */
662 static NTSTATUS unixuid_fsinfo(struct ntvfs_module_context *ntvfs,
663                               struct ntvfs_request *req, union smb_fsinfo *fs)
664 {
665         NTSTATUS status;
666
667         PASS_THRU_REQ(ntvfs, req, fsinfo, (ntvfs, req, fs));
668
669         return status;
670 }
671
672 /*
673   return print queue info
674 */
675 static NTSTATUS unixuid_lpq(struct ntvfs_module_context *ntvfs,
676                            struct ntvfs_request *req, union smb_lpq *lpq)
677 {
678         NTSTATUS status;
679
680         PASS_THRU_REQ(ntvfs, req, lpq, (ntvfs, req, lpq));
681
682         return status;
683 }
684
685 /* 
686    list files in a directory matching a wildcard pattern
687 */
688 static NTSTATUS unixuid_search_first(struct ntvfs_module_context *ntvfs,
689                                     struct ntvfs_request *req, union smb_search_first *io, 
690                                     void *search_private, 
691                                     bool (*callback)(void *, const union smb_search_data *))
692 {
693         NTSTATUS status;
694
695         PASS_THRU_REQ(ntvfs, req, search_first, (ntvfs, req, io, search_private, callback));
696
697         return status;
698 }
699
700 /* continue a search */
701 static NTSTATUS unixuid_search_next(struct ntvfs_module_context *ntvfs,
702                                    struct ntvfs_request *req, union smb_search_next *io, 
703                                    void *search_private, 
704                                    bool (*callback)(void *, const union smb_search_data *))
705 {
706         NTSTATUS status;
707
708         PASS_THRU_REQ(ntvfs, req, search_next, (ntvfs, req, io, search_private, callback));
709
710         return status;
711 }
712
713 /* close a search */
714 static NTSTATUS unixuid_search_close(struct ntvfs_module_context *ntvfs,
715                                     struct ntvfs_request *req, union smb_search_close *io)
716 {
717         NTSTATUS status;
718
719         PASS_THRU_REQ(ntvfs, req, search_close, (ntvfs, req, io));
720
721         return status;
722 }
723
724 /* SMBtrans - not used on file shares */
725 static NTSTATUS unixuid_trans(struct ntvfs_module_context *ntvfs,
726                              struct ntvfs_request *req, struct smb_trans2 *trans2)
727 {
728         NTSTATUS status;
729
730         PASS_THRU_REQ(ntvfs, req, trans, (ntvfs, req, trans2));
731
732         return status;
733 }
734
735 /*
736   initialise the unixuid backend, registering ourselves with the ntvfs subsystem
737  */
738 NTSTATUS ntvfs_unixuid_init(void)
739 {
740         NTSTATUS ret;
741         struct ntvfs_ops ops;
742         NTVFS_CURRENT_CRITICAL_SIZES(vers);
743
744         ZERO_STRUCT(ops);
745
746         /* fill in all the operations */
747         ops.connect = unixuid_connect;
748         ops.disconnect = unixuid_disconnect;
749         ops.unlink = unixuid_unlink;
750         ops.chkpath = unixuid_chkpath;
751         ops.qpathinfo = unixuid_qpathinfo;
752         ops.setpathinfo = unixuid_setpathinfo;
753         ops.open = unixuid_open;
754         ops.mkdir = unixuid_mkdir;
755         ops.rmdir = unixuid_rmdir;
756         ops.rename = unixuid_rename;
757         ops.copy = unixuid_copy;
758         ops.ioctl = unixuid_ioctl;
759         ops.read = unixuid_read;
760         ops.write = unixuid_write;
761         ops.seek = unixuid_seek;
762         ops.flush = unixuid_flush;      
763         ops.close = unixuid_close;
764         ops.exit = unixuid_exit;
765         ops.lock = unixuid_lock;
766         ops.setfileinfo = unixuid_setfileinfo;
767         ops.qfileinfo = unixuid_qfileinfo;
768         ops.fsinfo = unixuid_fsinfo;
769         ops.lpq = unixuid_lpq;
770         ops.search_first = unixuid_search_first;
771         ops.search_next = unixuid_search_next;
772         ops.search_close = unixuid_search_close;
773         ops.trans = unixuid_trans;
774         ops.logoff = unixuid_logoff;
775         ops.async_setup = unixuid_async_setup;
776         ops.cancel = unixuid_cancel;
777         ops.notify = unixuid_notify;
778
779         ops.name = "unixuid";
780
781         /* we register under all 3 backend types, as we are not type specific */
782         ops.type = NTVFS_DISK;  
783         ret = ntvfs_register(&ops, &vers);
784         if (!NT_STATUS_IS_OK(ret)) goto failed;
785
786         ops.type = NTVFS_PRINT; 
787         ret = ntvfs_register(&ops, &vers);
788         if (!NT_STATUS_IS_OK(ret)) goto failed;
789
790         ops.type = NTVFS_IPC;   
791         ret = ntvfs_register(&ops, &vers);
792         if (!NT_STATUS_IS_OK(ret)) goto failed;
793         
794 failed:
795         return ret;
796 }