g_return_if_fail(src_options_module_captive->type==CAPTIVE_OPTIONS_MODULE_TYPE_PE32);
- dest_options_module_corba->pathname_utf8=g_strdup(src_options_module_captive->pathname_utf8);
- dest_options_module_corba->data._buffer=g_memdup(src_options_module_captive->u.pe32.base,
- src_options_module_captive->u.pe32.length);
+ dest_options_module_corba->pathname_utf8=CORBA_string_dup(src_options_module_captive->pathname_utf8);
dest_options_module_corba->data._maximum=src_options_module_captive->u.pe32.length;
dest_options_module_corba->data._length =src_options_module_captive->u.pe32.length;
+ dest_options_module_corba->data._buffer=Captive_Bytes_allocbuf(dest_options_module_corba->data._maximum);
+ memcpy(dest_options_module_corba->data._buffer,src_options_module_captive->u.pe32.base,
+ src_options_module_captive->u.pe32.length);
dest_options_module_corba->data._release=TRUE;
}
static gboolean done=FALSE;
g_log(G_LOG_DOMAIN,G_LOG_LEVEL_DEBUG,"%s; done=%d",G_STRLOC,(int)done);
+
if (done)
return;
done=TRUE;
signal(signum,sigstructp->sighandler_orig);
/* Prevent recursive fatal logging before signal restore: */
- g_log(G_LOG_DOMAIN,G_LOG_LEVEL_DEBUG,"%s: signum=%d,sighandler_orig=%p",G_STRLOC,signum,sigstructp->sighandler_orig);
+ /* Do not: g_log(G_LOG_DOMAIN,G_LOG_LEVEL_DEBUG,"%s: signum=%d,sighandler_orig=%p",G_STRLOC,signum,sigstructp->sighandler_orig);
+ * as it is dangerous to g_log() from sighandler.
+ */
sandbox_parent_own_orbit_dir_cleanup_atexit();
- g_log(G_LOG_DOMAIN,G_LOG_LEVEL_DEBUG,"%s: re-raising...",G_STRLOC);
+ /* Do not: g_log(G_LOG_DOMAIN,G_LOG_LEVEL_DEBUG,"%s: re-raising...",G_STRLOC);
+ * as it is dangerous to g_log() from sighandler.
+ */
raise(signum);
}
/* FIXME: Security: Duplicate giop_tmpdir_init() here. */
if (!sandbox_parent_own_orbit_dir) {
- sandbox_parent_own_orbit_dir=g_strdup_printf("/tmp/captive-orbit-%d",getpid());
+ /* FIXME: Make 'CAPTIVE_SANDBOX_CHROOT' configurable. */
+ sandbox_parent_own_orbit_dir=g_strdup_printf("%s/tmp/captive-orbit-%d",CAPTIVE_SANDBOX_CHROOT,getpid());
if (mkdir(sandbox_parent_own_orbit_dir,0700)) {
g_assert(errno==EEXIST);
sandbox_parent_own_orbit_dir_cleanup_init();
}
if (child_chroot_pid_hashkey_dir) {
+gchar *s;
+
child_chroot_parent_own_orbit_dir=captive_printf_alloca("%s/%s",child_chroot_pid_hashkey_dir,sandbox_parent_own_orbit_dir);
- errint=mkdir(child_chroot_parent_own_orbit_dir,0777);
- g_assert(errint==0);
- /* chmod(2) it to prevent mode limitation by
- * active ulimit(2) of being executed by mount(8).
- */
- errint=chmod(child_chroot_parent_own_orbit_dir,0777);
- g_assert(errint==0);
+ s=(/* de-const */ gchar *)child_chroot_parent_own_orbit_dir;
+ do {
+ s=strchr(s,'/');
+ if (s)
+ *s=0;
+ if (*child_chroot_parent_own_orbit_dir) {
+ errint=mkdir(child_chroot_parent_own_orbit_dir,0777);
+ if (errint)
+ g_assert(errno==EEXIST);
+ else {
+ /* chmod(2) it to prevent mode limitation by
+ * active ulimit(2) of being executed by mount(8).
+ */
+ errint=chmod(child_chroot_parent_own_orbit_dir,0777);
+ g_assert(errint==0);
+ }
+ }
+ if (s)
+ *s++='/';
+ } while (s);
child_chroot_parent_own_orbit_socket=captive_printf_alloca("%s/%s",
child_chroot_pid_hashkey_dir,sandbox_parent_own_orbit_socket);
errint=link(sandbox_parent_own_orbit_socket,child_chroot_parent_own_orbit_socket);
g_assert(errint==0);
}
- options_corba.g_log_func=GLogFunc_object;
+ options_corba.g_log_func=CORBA_Object_duplicate(GLogFunc_object,&captive_corba_ev);
+ g_assert(validate_CORBA_Environment(&captive_corba_ev));
+
options_module_captive_to_options_module_corba(&options_corba.filesystem,&CAPTIVE_VFS_OBJECT(captive_vfs_parent_object)->options.filesystem);
/* Prevent secondary captive_giochannel_blind inside of our sandbox child
* as we already have one captive_giochannel_blind in the parent.
: CAPTIVE_VFS_OBJECT(captive_vfs_parent_object)->options.rwmode);
options_corba.media =CAPTIVE_VFS_OBJECT(captive_vfs_parent_object)->options.media;
options_corba.debug_messages=CAPTIVE_VFS_OBJECT(captive_vfs_parent_object)->options.debug_messages;
- options_corba.image_iochannel=CaptiveIOChannel_object;
+
+ options_corba.image_iochannel=CORBA_Object_duplicate(CaptiveIOChannel_object,&captive_corba_ev);
+ g_assert(validate_CORBA_Environment(&captive_corba_ev));
load_module_length=g_list_length(CAPTIVE_VFS_OBJECT(captive_vfs_parent_object)->options.load_module);
- captive_newn(options_corba.load_module._buffer,load_module_length);
options_corba.load_module._maximum=load_module_length;
options_corba.load_module._length=load_module_length;
+ options_corba.load_module._buffer=Captive_CaptiveOptionsModuleList_allocbuf(options_corba.load_module._maximum);
options_corba.load_module._release=TRUE;
for (load_moduleui=0,load_module_node=CAPTIVE_VFS_OBJECT(captive_vfs_parent_object)->options.load_module;
load_module_node;
Captive_Vfs_init(Vfs_object,&options_corba,&captive_corba_ev);
g_assert(validate_CORBA_Environment(&captive_corba_ev));
- /* FIXME: Free 'options_corba' - LEAK */
+ Captive_CaptiveOptions__freekids(&options_corba,
+ NULL); /* d; unused */
captive_vfs_parent_object->corba_Vfs_object=Vfs_object;
captive_vfs_parent_object->corba_GLogFunc_object=GLogFunc_object;