File tree Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Expand file tree Collapse file tree 2 files changed +30
-1
lines changed Original file line number Diff line number Diff line change 11#ifdef RUNC_USE_STDLIB
2+ # include <linux/limits.h>
3+ # include <stdio.h>
4+ # include <string.h>
25# include <unistd.h>
36#else
47# include "xstat.h"
@@ -11,5 +14,14 @@ int main(int argc, char **argv)
1114{
1215 if (argc < 1 )
1316 return 127 ;
14- return execve (argv [0 ], argv , environ );
17+ int ret = execve (argv [0 ], argv , environ );
18+ if (ret ) {
19+ /* NOTE: This error message format MUST match Go's format. */
20+ char err_msg [5 + PATH_MAX + 1 ] = "exec " ; // "exec " + argv[0] + '\0'
21+ strncat (err_msg , argv [0 ], PATH_MAX );
22+ err_msg [sizeof (err_msg ) - 1 ] = '\0' ;
23+
24+ perror (err_msg );
25+ }
26+ return ret ;
1527}
Original file line number Diff line number Diff line change @@ -230,3 +230,20 @@ function teardown() {
230230 grep -E ' ^monotonic\s+7881\s+2718281$' <<< " $output"
231231 grep -E ' ^boottime\s+1337\s+3141519$' <<< " $output"
232232}
233+
234+ @test " runc run [exec error]" {
235+ cat << EOF >rootfs/run.sh
236+ #!/mmnnttbb foo bar
237+ sh
238+ EOF
239+ chmod +x rootfs/run.sh
240+ update_config ' .process.args = [ "/run.sh" ]'
241+ runc run test_hello
242+
243+ # Ensure that the output contains the right error message. For runc-dmz, both
244+ # nolibc and libc have the same formatting string (but libc will print the
245+ # errno description rather than just the number), and for runc_nodmz the error
246+ # message from Go starts with the same string.
247+ [ " $status " -ne 0 ]
248+ [[ " $output " = * " exec /run.sh: " * ]]
249+ }
You can’t perform that action at this time.
0 commit comments