From b0f08c83e23e69c7b19b04d38910f90b5f7af51b Mon Sep 17 00:00:00 2001 From: Chris Johns Date: Mon, 1 Aug 2016 11:02:13 +1000 Subject: libmisc/untar: Set the perms to the value in the tar file. This patch parses the mode field in the tar header and sets the directory or file to the mode value in the header. Closes #2768. --- testsuites/libtests/tar01/init.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'testsuites/libtests/tar01/init.c') diff --git a/testsuites/libtests/tar01/init.c b/testsuites/libtests/tar01/init.c index 4bfa29c636..7d4f1b9a2a 100644 --- a/testsuites/libtests/tar01/init.c +++ b/testsuites/libtests/tar01/init.c @@ -46,6 +46,16 @@ void test_cat( int length ); +static void test_untar_check_mode(const char* file, int mode) +{ + struct stat sb; + int fmode; + rtems_test_assert(stat(file, &sb) == 0); + fmode = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); + printf(" %s: mode: %04o want: %04o\n", file, fmode, mode); + rtems_test_assert(fmode == mode); +} + void test_untar_from_memory(void) { rtems_status_code sc; @@ -65,6 +75,11 @@ void test_untar_from_memory(void) printf( "========= /home/test_file =========\n" ); test_cat( "/home/test_file", 0, 0 ); + /******************/ + printf( "========= /home/test_script =========\n" ); + test_cat( "/home/test_script", 0, 0 ); + test_untar_check_mode("/home/test_script", 0755); + /******************/ printf( "========= /symlink =========\n" ); test_cat( "/symlink", 0, 0 ); @@ -106,6 +121,11 @@ void test_untar_from_file(void) printf( "========= /dest/home/test_file =========\n" ); test_cat( "/dest/home/test_file", 0, 0 ); + /******************/ + printf( "========= /dest/home/test_script =========\n" ); + test_cat( "/dest/home/test_script", 0, 0 ); + test_untar_check_mode("/dest/home/test_script", 0755); + /******************/ printf( "========= /dest/symlink =========\n" ); test_cat( "/dest/symlink", 0, 0 ); @@ -143,6 +163,11 @@ void test_untar_chunks_from_memory(void) printf( "========= /dest2/home/test_file =========\n" ); test_cat( "/dest2/home/test_file", 0, 0 ); + /******************/ + printf( "========= /dest2/home/test_script =========\n" ); + test_cat( "/dest2/home/test_script", 0, 0 ); + test_untar_check_mode("/dest2/home/test_script", 0755); + /******************/ printf( "========= /dest2/symlink =========\n" ); test_cat( "/dest2/symlink", 0, 0 ); @@ -183,6 +208,11 @@ void test_untar_unzip_tgz(void) printf( "========= /dest3/home/test_file =========\n" ); test_cat( "/dest3/home/test_file", 0, 0 ); + /******************/ + printf( "========= /dest3/home/test_script =========\n" ); + test_cat( "/dest3/home/test_script", 0, 0 ); + test_untar_check_mode("/dest3/home/test_script", 0755); + /******************/ printf( "========= /dest3/symlink =========\n" ); test_cat( "/dest3/symlink", 0, 0 ); -- cgit v1.2.3