Skip to content
This repository has been archived by the owner on Aug 3, 2022. It is now read-only.

Commit

Permalink
Remove HAVE_SELINUX guards
Browse files Browse the repository at this point in the history
(cherry picked from commit 254d3a6)

Change-Id: Ib2896c47560906a2cd8203d98887fbfeaf09f8ad
  • Loading branch information
kruton committed Oct 17, 2012
1 parent 9c64cac commit c7e18f4
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 24 deletions.
6 changes: 1 addition & 5 deletions Android.mk
Expand Up @@ -17,11 +17,7 @@ LOCAL_C_INCLUDES += $(LOCAL_PATH)/yaffs2

LOCAL_MODULE := mkyaffs2image

ifeq ($(HAVE_SELINUX), true)
LOCAL_C_INCLUDES += external/libselinux/include
LOCAL_STATIC_LIBRARIES += libselinux
LOCAL_CFLAGS += -DHAVE_SELINUX
endif # HAVE_SELINUX
LOCAL_STATIC_LIBRARIES := libselinux

include $(BUILD_HOST_EXECUTABLE)

Expand Down
19 changes: 0 additions & 19 deletions yaffs2/utils/mkyaffs2image.c
Expand Up @@ -32,15 +32,13 @@
#include <string.h>
#include <unistd.h>

#ifdef HAVE_SELINUX
#define XATTR_NAME_SELINUX "security.selinux"
#include <selinux/selinux.h>
#include <selinux/label.h>

static struct selabel_handle *sehnd;
static unsigned int seprefixlen;
static char *mntpoint;
#endif

#include <private/android_filesystem_config.h>

Expand Down Expand Up @@ -263,7 +261,6 @@ static int write_object_header(int objId, yaffs_ObjectType t, struct stat *s, in


yaffs_ObjectHeader *oh = (yaffs_ObjectHeader *)bytes;
#ifdef HAVE_SELINUX
char *xb = (char *)bytes + sizeof(*oh);
int xnamelen = strlen(XATTR_NAME_SELINUX) + 1;
int xvalsize = 0;
Expand All @@ -273,7 +270,6 @@ static int write_object_header(int objId, yaffs_ObjectType t, struct stat *s, in
xvalsize = strlen(secontext) + 1;
xreclen = sizeof(int) + xnamelen + xvalsize;
}
#endif

memset(bytes,0xff,sizeof(bytes));

Expand All @@ -283,15 +279,13 @@ static int write_object_header(int objId, yaffs_ObjectType t, struct stat *s, in

strncpy(oh->name,name,YAFFS_MAX_NAME_LENGTH);

#ifdef HAVE_SELINUX
if (xreclen) {
memcpy(xb, &xreclen, sizeof(int));
xb += sizeof(int);
strcpy(xb, XATTR_NAME_SELINUX);
xb += xnamelen;
memcpy(xb, secontext, xvalsize);
}
#endif

if(t != YAFFS_OBJECT_TYPE_HARDLINK)
{
Expand Down Expand Up @@ -356,10 +350,8 @@ static int process_directory(int parent, const char *path, int fixstats)
strcmp(entry->d_name,".."))
{
char full_name[500];
#ifdef HAVE_SELINUX
char *suffix, dest_name[500];
int ret;
#endif
struct stat stats;
int equivalentObj;
int newObj;
Expand All @@ -368,7 +360,6 @@ static int process_directory(int parent, const char *path, int fixstats)

lstat(full_name,&stats);

#ifdef HAVE_SELINUX
if (sehnd) {
suffix = full_name + seprefixlen;
ret = snprintf(dest_name,
Expand Down Expand Up @@ -403,7 +394,6 @@ static int process_directory(int parent, const char *path, int fixstats)
}
free(sepath);
}
#endif

if(S_ISLNK(stats.st_mode) ||
S_ISREG(stats.st_mode) ||
Expand Down Expand Up @@ -577,16 +567,13 @@ int main(int argc, char *argv[])
}

dir = argv[optind];
#ifdef HAVE_SELINUX
seprefixlen = strlen(dir);
#endif
image = argv[optind + 1];

if (optind + 2 < argc) {
if (!strncmp(argv[optind + 2], "convert", strlen("convert")))
convert_endian = 1;
else {
#ifdef HAVE_SELINUX
struct selinux_opt seopts[] = {
{ SELABEL_OPT_PATH, argv[optind + 2] }
};
Expand All @@ -605,10 +592,6 @@ int main(int argc, char *argv[])
if (!strncmp(argv[optind + 4], "convert", strlen("convert")))
convert_endian = 1;
}
#else
usage();
exit(1);
#endif
}
}

Expand Down Expand Up @@ -648,7 +631,6 @@ int main(int argc, char *argv[])
}

//printf("Processing directory %s into image file %s\n",dir,image);
#ifdef HAVE_SELINUX
if (sehnd) {

char *sepath = NULL;
Expand All @@ -670,7 +652,6 @@ int main(int argc, char *argv[])

free(sepath);
}
#endif

error = write_object_header(1, YAFFS_OBJECT_TYPE_DIRECTORY, &stats, 1,"", -1, NULL, secontext);
if(error)
Expand Down

0 comments on commit c7e18f4

Please sign in to comment.