3535#include <sys/stat.h>
3636#include <sys/types.h>
3737
38- #ifdef USE_MINGW
39-
40- #include <winsock2.h>
41-
42- /* These match the Linux definitions of these flags.
43- L_xx is defined to avoid conflicting with the win32 versions.
44- */
45- #define L_S_IRUSR 00400
46- #define L_S_IWUSR 00200
47- #define L_S_IXUSR 00100
48- #define S_IRWXU (L_S_IRUSR | L_S_IWUSR | L_S_IXUSR)
49- #define S_IRGRP 00040
50- #define S_IWGRP 00020
51- #define S_IXGRP 00010
52- #define S_IRWXG (S_IRGRP | S_IWGRP | S_IXGRP)
53- #define S_IROTH 00004
54- #define S_IWOTH 00002
55- #define S_IXOTH 00001
56- #define S_IRWXO (S_IROTH | S_IWOTH | S_IXOTH)
57- #define S_ISUID 0004000
58- #define S_ISGID 0002000
59- #define S_ISVTX 0001000
60-
61- #else
62-
63- #include <selinux/selinux.h>
64- #include <selinux/label.h>
65- #include <selinux/android.h>
38+ #ifndef USE_MINGW
6639
6740#define O_BINARY 0
6841
@@ -79,8 +52,7 @@ static int filter_dot(const struct dirent *d)
7952 return (strcmp (d -> d_name , ".." ) && strcmp (d -> d_name , "." ));
8053}
8154
82- static u32 build_default_directory_structure (const char * dir_path ,
83- struct selabel_handle * sehnd )
55+ static u32 build_default_directory_structure (const char * dir_path )
8456{
8557 u32 inode ;
8658 u32 root_inode ;
@@ -98,22 +70,6 @@ static u32 build_default_directory_structure(const char *dir_path,
9870 inode_set_permissions (inode , dentries .mode ,
9971 dentries .uid , dentries .gid , dentries .mtime );
10072
101- #ifndef USE_MINGW
102- if (sehnd ) {
103- char * path = NULL ;
104- char * secontext = NULL ;
105-
106- asprintf (& path , "%slost+found" , dir_path );
107- if (selabel_lookup (sehnd , & secontext , path , S_IFDIR ) < 0 ) {
108- error ("cannot lookup security context for %s" , path );
109- } else {
110- inode_set_selinux (inode , secontext );
111- freecon (secontext );
112- }
113- free (path );
114- }
115- #endif
116-
11773 return root_inode ;
11874}
11975
@@ -127,7 +83,7 @@ static u32 build_default_directory_structure(const char *dir_path,
12783 if the image were mounted at the specified mount point */
12884static u32 build_directory_structure (const char * full_path , const char * dir_path ,
12985 u32 dir_inode , fs_config_func_t fs_config_func ,
130- struct selabel_handle * sehnd , int verbose , time_t fixed_time )
86+ int verbose , time_t fixed_time )
13187{
13288 int entries = 0 ;
13389 struct dentry * dentries ;
@@ -212,16 +168,6 @@ static u32 build_directory_structure(const char *full_path, const char *dir_path
212168 error ("can't set android permissions - built without android support" );
213169#endif
214170 }
215- #ifndef USE_MINGW
216- if (sehnd ) {
217- if (selabel_lookup (sehnd , & dentries [i ].secon , dentries [i ].path , stat .st_mode ) < 0 ) {
218- error ("cannot lookup security context for %s" , dentries [i ].path );
219- }
220-
221- if (dentries [i ].secon && verbose )
222- printf ("Labeling %s as %s\n" , dentries [i ].path , dentries [i ].secon );
223- }
224- #endif
225171
226172 if (S_ISREG (stat .st_mode )) {
227173 dentries [i ].file_type = EXT4_FT_REG_FILE ;
@@ -263,10 +209,6 @@ static u32 build_directory_structure(const char *full_path, const char *dir_path
263209 dentries [0 ].file_type = EXT4_FT_DIR ;
264210 dentries [0 ].uid = 0 ;
265211 dentries [0 ].gid = 0 ;
266- if (sehnd ) {
267- if (selabel_lookup (sehnd , & dentries [0 ].secon , dentries [0 ].path , dentries [0 ].mode ) < 0 )
268- error ("cannot lookup security context for %s" , dentries [0 ].path );
269- }
270212 entries ++ ;
271213 dirs ++ ;
272214 }
@@ -288,7 +230,7 @@ static u32 build_directory_structure(const char *full_path, const char *dir_path
288230 if (ret < 0 )
289231 critical_error_errno ("asprintf" );
290232 entry_inode = build_directory_structure (subdir_full_path ,
291- subdir_dir_path , inode , fs_config_func , sehnd , verbose , fixed_time );
233+ subdir_dir_path , inode , fs_config_func , verbose , fixed_time );
292234 free (subdir_full_path );
293235 free (subdir_dir_path );
294236 } else if (dentries [i ].file_type == EXT4_FT_SYMLINK ) {
@@ -401,16 +343,16 @@ void reset_ext4fs_info() {
401343}
402344
403345int make_ext4fs_sparse_fd (int fd , long long len ,
404- const char * mountpoint , struct selabel_handle * sehnd )
346+ const char * mountpoint )
405347{
406348 reset_ext4fs_info ();
407349 info .len = len ;
408350
409- return make_ext4fs_internal (fd , NULL , mountpoint , NULL , 0 , 1 , 0 , 0 , sehnd , 0 , -1 , NULL );
351+ return make_ext4fs_internal (fd , NULL , mountpoint , NULL , 0 , 1 , 0 , 0 , 0 , -1 , NULL );
410352}
411353
412354int make_ext4fs (const char * filename , long long len ,
413- const char * mountpoint , struct selabel_handle * sehnd )
355+ const char * mountpoint )
414356{
415357 int fd ;
416358 int status ;
@@ -424,7 +366,7 @@ int make_ext4fs(const char *filename, long long len,
424366 return EXIT_FAILURE ;
425367 }
426368
427- status = make_ext4fs_internal (fd , NULL , mountpoint , NULL , 0 , 0 , 0 , 1 , sehnd , 0 , -1 , NULL );
369+ status = make_ext4fs_internal (fd , NULL , mountpoint , NULL , 0 , 0 , 0 , 1 , 0 , -1 , NULL );
428370 close (fd );
429371
430372 return status ;
@@ -493,7 +435,7 @@ static char *canonicalize_rel_slashes(const char *str)
493435int make_ext4fs_internal (int fd , const char * _directory ,
494436 const char * _mountpoint , fs_config_func_t fs_config_func , int gzip ,
495437 int sparse , int crc , int wipe ,
496- struct selabel_handle * sehnd , int verbose , time_t fixed_time ,
438+ int verbose , time_t fixed_time ,
497439 FILE * block_list_file )
498440{
499441 u32 root_inode_num ;
@@ -599,35 +541,18 @@ int make_ext4fs_internal(int fd, const char *_directory,
599541#ifdef USE_MINGW
600542 // Windows needs only 'create an empty fs image' functionality
601543 assert (!directory );
602- root_inode_num = build_default_directory_structure (mountpoint , sehnd );
544+ root_inode_num = build_default_directory_structure (mountpoint );
603545#else
604546 if (directory )
605547 root_inode_num = build_directory_structure (directory , mountpoint , 0 ,
606- fs_config_func , sehnd , verbose , fixed_time );
548+ fs_config_func , verbose , fixed_time );
607549 else
608- root_inode_num = build_default_directory_structure (mountpoint , sehnd );
550+ root_inode_num = build_default_directory_structure (mountpoint );
609551#endif
610552
611553 root_mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH ;
612554 inode_set_permissions (root_inode_num , root_mode , 0 , 0 , 0 );
613555
614- #ifndef USE_MINGW
615- if (sehnd ) {
616- char * secontext = NULL ;
617-
618- if (selabel_lookup (sehnd , & secontext , mountpoint , S_IFDIR ) < 0 ) {
619- error ("cannot lookup security context for %s" , mountpoint );
620- }
621- if (secontext ) {
622- if (verbose ) {
623- printf ("Labeling %s as %s\n" , mountpoint , secontext );
624- }
625- inode_set_selinux (root_inode_num , secontext );
626- }
627- freecon (secontext );
628- }
629- #endif
630-
631556 ext4_update_free ();
632557
633558 ext4_queue_sb ();
0 commit comments