Finished and deployed CORBA sandbox separation
[captive.git] / src / libcaptive / sandbox / parent-Vfs.c
1 /* $Id$
2  * CORBA/ORBit server side of Vfs object of sandbox_parent()
3  * Copyright (C) 2003 Jan Kratochvil <project-captive@jankratochvil.net>
4  * 
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; exactly version 2 of June 1991 is required
8  * 
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  * 
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18
19
20 #include "config.h"
21
22 #include "captive/parent-Vfs.h" /* self */
23 #include <glib/gmessages.h>
24 #include "split.h"
25 #include "../client/vfs.h"
26 #include "sandbox.h"
27 #include <unistd.h>
28
29
30 GnomeVFSResult captive_sandbox_parent_vfs_new(CaptiveVfsObject *captive_vfs_object)
31 {
32 gboolean errbool;
33
34         g_return_val_if_fail(captive_vfs_object!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
35
36         captive_vfs_object->is_sandbox_parent=TRUE;
37
38         errbool=captive_sandbox_spawn(
39                         captive_vfs_object,     /* child_captive_vfs_object */
40                         &captive_vfs_object->corba_Vfs_object,  /* corba_Vfs_object_return */
41                         &captive_vfs_object->corba_GlibLogFunc_object,  /* corba_GlibLogFunc_object_return */
42                         &captive_vfs_object->corba_parentheart_fds_1);  /* parentheart_fds_1_return */
43         g_return_val_if_fail(errbool==TRUE,GNOME_VFS_ERROR_GENERIC);
44
45         return GNOME_VFS_OK;
46 }
47
48
49 gboolean corba_shutdown(CORBA_Environment *evp,CORBA_ORB *orbp,PortableServer_POA *poap);
50
51 GnomeVFSResult captive_sandbox_parent_vfs_close(CaptiveVfsObject *captive_vfs_object)
52 {
53 GnomeVFSResult r;
54 int errint;
55
56         g_return_val_if_fail(captive_vfs_object!=NULL,GNOME_VFS_ERROR_BAD_PARAMETERS);
57
58         Captive_Vfs_shutdown(captive_vfs_object->corba_Vfs_object,&captive_corba_ev);
59         r=captive_sandbox_parent_return_from_CORBA_Environment(&captive_corba_ev);
60
61         CORBA_Object_release(captive_vfs_object->corba_Vfs_object,&captive_corba_ev);
62         g_assert(validate_CORBA_Environment(&captive_corba_ev));
63
64         /* Shutdown 'GlibLogFunc' servant */
65         CORBA_Object_release(captive_vfs_object->corba_GlibLogFunc_object,&captive_corba_ev);
66         g_assert(validate_CORBA_Environment(&captive_corba_ev));
67
68         errint=close(captive_vfs_object->corba_parentheart_fds_1);      /* close parentheart_fd_write */
69         g_return_val_if_fail(errint==0,FALSE);
70
71         return r;
72 }