@@ -598,6 +598,7 @@ container_init_setup (void *args, const char *notify_socket,
598598 console_socketpair = entrypoint_args -> terminal_socketpair [1 ];
599599 }
600600
601+ /* sync 1. */
601602 ret = sync_socket_wait_sync (NULL , sync_socket , false, err );
602603 if (UNLIKELY (ret < 0 ))
603604 return ret ;
@@ -614,10 +615,12 @@ container_init_setup (void *args, const char *notify_socket,
614615 if (UNLIKELY (ret < 0 ))
615616 return ret ;
616617
618+ /* sync 2. */
617619 ret = sync_socket_send_sync (sync_socket , false, err );
618620 if (UNLIKELY (ret < 0 ))
619621 return ret ;
620622
623+ /* sync 3. */
621624 ret = sync_socket_wait_sync (NULL , sync_socket , false, err );
622625 if (UNLIKELY (ret < 0 ))
623626 return ret ;
@@ -830,6 +833,7 @@ container_init (void *args, const char *notify_socket, int sync_socket,
830833 if (UNLIKELY (ret < 0 ))
831834 return ret ;
832835
836+ /* sync 4. */
833837 ret = sync_socket_send_sync (sync_socket , false, err );
834838 if (UNLIKELY (ret < 0 ))
835839 return ret ;
@@ -1280,21 +1284,21 @@ wait_for_process (pid_t pid, libcrun_context_t *context, int terminal_fd, int no
12801284 {
12811285 ret = copy_from_fd_to_fd (0 , terminal_fd , 0 , err );
12821286 if (UNLIKELY (ret < 0 ))
1283- return ret ;
1287+ return crun_error_wrap ( err , "copy to terminal fd" ) ;
12841288 }
12851289 else if (events [i ].data .fd == terminal_fd )
12861290 {
12871291 ret = set_blocking_fd (terminal_fd , 0 , err );
12881292 if (UNLIKELY (ret < 0 ))
1289- return ret ;
1293+ return crun_error_wrap ( err , "set terminal fd not blocking" ) ;
12901294
12911295 ret = copy_from_fd_to_fd (terminal_fd , 1 , 1 , err );
12921296 if (UNLIKELY (ret < 0 ))
1293- return ret ;
1297+ return crun_error_wrap ( err , "copy from terminal fd" ) ;
12941298
12951299 ret = set_blocking_fd (terminal_fd , 1 , err );
12961300 if (UNLIKELY (ret < 0 ))
1297- return ret ;
1301+ return crun_error_wrap ( err , "set terminal fd blocking" ) ;
12981302 }
12991303 else if (events [i ].data .fd == notify_socket )
13001304 {
@@ -1545,7 +1549,8 @@ libcrun_container_run_internal (libcrun_container_t *container, libcrun_context_
15451549 container_args .has_terminal_socket_pair = 1 ;
15461550 ret = create_socket_pair (container_args .terminal_socketpair , err );
15471551 if (UNLIKELY (ret < 0 ))
1548- return ret ;
1552+ return crun_error_wrap (err , "create terminal socket" );
1553+
15491554 socket_pair_0 = container_args .terminal_socketpair [0 ];
15501555 socket_pair_1 = container_args .terminal_socketpair [1 ];
15511556 }
@@ -1566,7 +1571,7 @@ libcrun_container_run_internal (libcrun_container_t *container, libcrun_context_
15661571 {
15671572 console_socket_fd = open_unix_domain_client_socket (context -> console_socket , 0 , err );
15681573 if (UNLIKELY (console_socket_fd < 0 ))
1569- return console_socket_fd ;
1574+ return crun_error_wrap ( err , "open console socket" ) ;
15701575 container_args .console_socket_fd = console_socket_fd ;
15711576 }
15721577
@@ -1637,31 +1642,15 @@ libcrun_container_run_internal (libcrun_container_t *container, libcrun_context_
16371642 }
16381643 }
16391644
1640- if (seccomp_fd >= 0 )
1641- {
1642- unsigned int seccomp_gen_options = 0 ;
1643- const char * annotation ;
1644-
1645- annotation = find_annotation (container , "run.oci.seccomp_fail_unknown_syscall" );
1646- if (annotation && strcmp (annotation , "0" ) != 0 )
1647- seccomp_gen_options = LIBCRUN_SECCOMP_FAIL_UNKNOWN_SYSCALL ;
1648-
1649- ret = libcrun_generate_seccomp (container , seccomp_fd , seccomp_gen_options , err );
1650- if (UNLIKELY (ret < 0 ))
1651- {
1652- cleanup_watch (context , pid , def , context -> id , sync_socket , terminal_fd );
1653- return ret ;
1654- }
1655- close_and_reset (& seccomp_fd );
1656- }
1657-
1645+ /* sync 1. */
16581646 ret = sync_socket_send_sync (sync_socket , true, err );
16591647 if (UNLIKELY (ret < 0 ))
16601648 {
16611649 cleanup_watch (context , pid , def , context -> id , sync_socket , terminal_fd );
16621650 return ret ;
16631651 }
16641652
1653+ /* sync 2. */
16651654 ret = sync_socket_wait_sync (context , sync_socket , false, err );
16661655 if (UNLIKELY (ret < 0 ))
16671656 {
@@ -1694,14 +1683,26 @@ libcrun_container_run_internal (libcrun_container_t *container, libcrun_context_
16941683 }
16951684 }
16961685
1697- ret = sync_socket_send_sync (sync_socket , true, err );
1698- if (UNLIKELY (ret < 0 ))
1686+ if (seccomp_fd >= 0 )
16991687 {
1700- cleanup_watch (context , pid , def , context -> id , sync_socket , terminal_fd );
1701- return ret ;
1688+ unsigned int seccomp_gen_options = 0 ;
1689+ const char * annotation ;
1690+
1691+ annotation = find_annotation (container , "run.oci.seccomp_fail_unknown_syscall" );
1692+ if (annotation && strcmp (annotation , "0" ) != 0 )
1693+ seccomp_gen_options = LIBCRUN_SECCOMP_FAIL_UNKNOWN_SYSCALL ;
1694+
1695+ ret = libcrun_generate_seccomp (container , seccomp_fd , seccomp_gen_options , err );
1696+ if (UNLIKELY (ret < 0 ))
1697+ {
1698+ cleanup_watch (context , pid , def , context -> id , sync_socket , terminal_fd );
1699+ return ret ;
1700+ }
1701+ close_and_reset (& seccomp_fd );
17021702 }
17031703
1704- ret = sync_socket_wait_sync (context , sync_socket , false, err );
1704+ /* sync 3. */
1705+ ret = sync_socket_send_sync (sync_socket , true, err );
17051706 if (UNLIKELY (ret < 0 ))
17061707 {
17071708 cleanup_watch (context , pid , def , context -> id , sync_socket , terminal_fd );
@@ -1727,6 +1728,14 @@ libcrun_container_run_internal (libcrun_container_t *container, libcrun_context_
17271728 }
17281729 }
17291730
1731+ /* sync 4. */
1732+ ret = sync_socket_wait_sync (context , sync_socket , false, err );
1733+ if (UNLIKELY (ret < 0 ))
1734+ {
1735+ cleanup_watch (context , pid , def , context -> id , sync_socket , terminal_fd );
1736+ return ret ;
1737+ }
1738+
17301739 ret = close_and_reset (& sync_socket );
17311740 if (UNLIKELY (ret < 0 ))
17321741 {
0 commit comments