lede-packages-rs

git clone git://archive.git.mtrnord.blog/MTRNord/lede-packages-rs.git
Log | Files | Refs | README | LICENSE

020-sload.f2fs-allow-to-build-without-libselinux.patch (2854B)


      1 From b0a2386089fd6efade6b89094325ed8a9f8c6fff Mon Sep 17 00:00:00 2001
      2 From: Christian Hesse <mail@eworm.de>
      3 Date: Sat, 22 Oct 2016 22:06:54 +0200
      4 Subject: [PATCH] sload.f2fs: allow to build without libselinux
      5 
      6 Some systems do not have libselinux. Allow to build sload.f2fs without
      7 support for selinux.
      8 
      9 Signed-off-by: Christian Hesse <mail@eworm.de>
     10 Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
     11 ---
     12  configure.ac |  4 +++-
     13  fsck/sload.c | 12 +++++++++++-
     14  2 files changed, 14 insertions(+), 2 deletions(-)
     15 
     16 diff --git a/configure.ac b/configure.ac
     17 index f519790..7a62328 100644
     18 --- a/configure.ac
     19 +++ b/configure.ac
     20 @@ -54,7 +54,9 @@ AC_PATH_PROG([LDCONFIG], [ldconfig],
     21  
     22  # Checks for libraries.
     23  PKG_CHECK_MODULES([libuuid], [uuid])
     24 -PKG_CHECK_MODULES([libselinux], [libselinux])
     25 +PKG_CHECK_MODULES([libselinux], [libselinux],
     26 +	[AC_DEFINE([HAVE_LIBSELINUX], [1], [Use libselinux])],
     27 +	[AC_MSG_NOTICE([libselinux not found])])
     28  
     29  # Checks for header files.
     30  AC_CHECK_HEADERS([linux/fs.h fcntl.h mntent.h stdlib.h string.h \
     31 diff --git a/fsck/sload.c b/fsck/sload.c
     32 index ea072d1..68799c1 100644
     33 --- a/fsck/sload.c
     34 +++ b/fsck/sload.c
     35 @@ -16,8 +16,11 @@
     36  #include <libgen.h>
     37  #include <dirent.h>
     38  #include <mntent.h>
     39 +
     40 +#ifdef HAVE_LIBSELINUX
     41  #include <selinux/selinux.h>
     42  #include <selinux/label.h>
     43 +#endif
     44  
     45  #ifdef WITH_ANDROID
     46  #include <selinux/label.h>
     47 @@ -110,10 +113,12 @@ static int build_directory(struct f2fs_sb_info *sbi, const char *full_path,
     48  		handle_selabel(dentries + i, S_ISDIR(stat.st_mode),
     49  							target_out_dir);
     50  
     51 +#ifdef HAVE_LIBSELINUX
     52  		if (sehnd && selabel_lookup(sehnd, &dentries[i].secon,
     53  					dentries[i].path, stat.st_mode) < 0)
     54  			ERR_MSG("Cannot lookup security context for %s\n",
     55  						dentries[i].path);
     56 +#endif
     57  
     58  		dentries[i].pino = dir_ino;
     59  
     60 @@ -174,6 +179,7 @@ static int build_directory(struct f2fs_sb_info *sbi, const char *full_path,
     61  			MSG(1, "Error unknown file type\n");
     62  		}
     63  
     64 +#ifdef HAVE_LIBSELINUX
     65  		if (dentries[i].secon) {
     66  			inode_set_selinux(sbi, dentries[i].ino, dentries[i].secon);
     67  			MSG(1, "File = %s \n----->SELinux context = %s\n",
     68 @@ -184,10 +190,12 @@ static int build_directory(struct f2fs_sb_info *sbi, const char *full_path,
     69  					dentries[i].gid, dentries[i].capabilities);
     70  		}
     71  
     72 +		free(dentries[i].secon);
     73 +#endif
     74 +
     75  		free(dentries[i].path);
     76  		free(dentries[i].full_path);
     77  		free((void *)dentries[i].name);
     78 -		free(dentries[i].secon);
     79  	}
     80  
     81  	free(dentries);
     82 @@ -218,6 +226,7 @@ int f2fs_sload(struct f2fs_sb_info *sbi, const char *from_dir,
     83  		return ret;
     84  	}
     85  
     86 +#ifdef HAVE_LIBSELINUX
     87  	if (sehnd) {
     88  		char *secontext = NULL;
     89  
     90 @@ -233,6 +242,7 @@ int f2fs_sload(struct f2fs_sb_info *sbi, const char *from_dir,
     91  		}
     92  		free(secontext);
     93  	}
     94 +#endif
     95  
     96  	/* update curseg info; can update sit->types */
     97  	move_curseg_info(sbi, SM_I(sbi)->main_blkaddr);
     98 -- 
     99 2.10.0
    100