Fixed uninitialized 'md5' options-module field in sandbox clients.
[captive.git] / src / libcaptive / sandbox / server-Vfs.c
index 9dd2054..28affd3 100644 (file)
 #include "split.h"
 #include "server-GLogFunc.h"
 #include "client-CaptiveIOChannel.h"
+#include "../client/vfs-slave.h"
 
 
 static void impl_Captive_Vfs_fini(impl_POA_Captive_Vfs *servant,CORBA_Environment *ev);
 static void impl_Captive_Vfs_init
                (impl_POA_Captive_Vfs *servant,const Captive_CaptiveOptions *options_corba,CORBA_Environment *ev);
 static void impl_Captive_Vfs_shutdown(impl_POA_Captive_Vfs *servant,CORBA_Environment *ev);
+static void impl_Captive_Vfs_volume_info_get
+               (impl_POA_Captive_Vfs *servant,Captive_CaptiveVfsVolumeInfo *volume_info_corba,CORBA_Environment *ev);
 
 static PortableServer_ServantBase__epv impl_Captive_Vfs_base_epv={
        NULL,   /* _private data */
@@ -48,6 +51,7 @@ static POA_Captive_Vfs__epv impl_Captive_Vfs_epv={
        (gpointer)&impl_Captive_Vfs_directory_new_make,
        (gpointer)&impl_Captive_Vfs_file_new_open,
        (gpointer)&impl_Captive_Vfs_file_new_create,
+       (gpointer)&impl_Captive_Vfs_volume_info_get,
        };
 static POA_Captive_Vfs__vepv impl_Captive_Vfs_vepv={
        &impl_Captive_Vfs_base_epv,
@@ -110,6 +114,8 @@ static void options_module_corba_to_options_module_captive
                        src_options_module_corba->data._length);
        dest_options_module_captive->u.pe32.length=src_options_module_corba->data._length;
        dest_options_module_captive->u.pe32.mapped=FALSE;
+       /* 'md5' is never used in sandbox client; XML is dumped by the master. */
+       dest_options_module_captive->u.pe32.md5=g_strdup("<sandbox-client:undef>");
 }
 
 
@@ -149,7 +155,9 @@ struct captive_options_module *options_module;
                options_captive.load_module=g_list_append(options_captive.load_module,options_module);
                }
 
+       options_captive.sandbox=TRUE;
        g_assert(options_captive.sandbox_server_argv==NULL);
+       g_assert(options_captive.sandbox_server_ior==NULL);
 
        if (GNOME_VFS_OK!=(errvfsresult=captive_vfs_new(&servant->captive_vfs_object,&options_captive))) {
                CORBA_exception_set(ev,CORBA_USER_EXCEPTION,ex_Captive_GnomeVFSResultException,GINT_TO_POINTER((gint)errvfsresult));
@@ -159,20 +167,24 @@ struct captive_options_module *options_module;
 
        captive_options_free(&options_captive);
 
-       g_assert(servant->captive_vfs_object!=NULL);
+       g_assert(CAPTIVE_VFS_SLAVE_IS_OBJECT(servant->captive_vfs_object));
 }
 
 
+#if 0  /* Currently unused - see impl_Captive_Vfs_shutdown() */
 static gboolean impl_Captive_Vfs_shutdown_idle(gpointer data /* unused */)
 {
        sandbox_child_shutdown();
 
        return FALSE;   /* remove me */
 }
+#endif
 
 static void impl_Captive_Vfs_shutdown(impl_POA_Captive_Vfs *servant,CORBA_Environment *ev)
 {
+#if 0  /* Currently unused - see impl_Captive_Vfs_shutdown() */
 GSource *source;
+#endif
 
        /* Shutdown 'servant->captive_vfs_object' synchronously as it may
         * flush its buffers needed to be transferred to our parent.
@@ -180,6 +192,12 @@ GSource *source;
        impl_Captive_Vfs_fini(servant,&captive_corba_ev);
        g_assert(validate_CORBA_Environment(&captive_corba_ev));
 
+       /* Currently we do not do any sandbox child shutdown here as it sometimes
+        * crashes the parent with COMM_FAILURE without proper finish of this
+        * shutdown() CORBA method call. Parent will kill(2) us soon
+        * from its parent-Vfs.c:captive_sandbox_parent_vfs_close() anyway.
+        */
+#if 0
        sandbox_child_prepare_shutdown();
 
        /* Do not call sandbox_child_shutdown() directly as we would fail
@@ -194,6 +212,25 @@ GSource *source;
                        servant,        /* data */
                        NULL);  /* notify */
   g_source_attach(source,
-                       g_main_loop_get_context(linc_main_get_loop())); /* context; NULL means 'default context' */
+                       captive_corba_get_context());   /* context; NULL means 'default context' */
   g_source_unref(source);
+#endif
+}
+
+
+static void impl_Captive_Vfs_volume_info_get
+               (impl_POA_Captive_Vfs *servant,Captive_CaptiveVfsVolumeInfo *volume_info_corba,CORBA_Environment *ev)
+{
+CaptiveVfsVolumeInfo volume_info_captive;
+GnomeVFSResult errvfsresult;
+
+       if (GNOME_VFS_OK!=(errvfsresult=captive_vfs_volume_info_get(servant->captive_vfs_object,&volume_info_captive))) {
+               captive_sandbox_child_GnomeVFSResultException_throw(ev,errvfsresult);
+               return;
+               }
+
+       volume_info_corba->block_size     =volume_info_captive.block_size;
+       volume_info_corba->bytes          =volume_info_captive.bytes;
+       volume_info_corba->bytes_free     =volume_info_captive.bytes_free;
+       volume_info_corba->bytes_available=volume_info_captive.bytes_available;
 }