Skip to content

Commit

Permalink
Make libselinux android buildable
Browse files Browse the repository at this point in the history
  • Loading branch information
topjohnwu committed Dec 5, 2016
1 parent df7346c commit 91e9179
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 4 deletions.
57 changes: 57 additions & 0 deletions libselinux/Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
LOCAL_PATH:= $(call my-dir)

common_SRC_FILES := \
src/booleans.c \
src/canonicalize_context.c \
src/disable.c \
src/enabled.c \
src/fgetfilecon.c \
src/fsetfilecon.c \
src/getenforce.c \
src/getfilecon.c \
src/getpeercon.c \
src/lgetfilecon.c \
src/load_policy.c \
src/lsetfilecon.c \
src/policyvers.c \
src/procattr.c \
src/setenforce.c \
src/setfilecon.c \
src/context.c \
src/mapping.c \
src/stringrep.c \
src/compute_create.c \
src/compute_av.c \
src/avc.c \
src/avc_internal.c \
src/avc_sidtab.c \
src/get_initial_context.c \
src/checkAccess.c \
src/sestatus.c \
src/deny_unknown.c \
src/freecon.c \
src/setrans_client.c

common_HOST_FILES := \
src/callbacks.c \
src/check_context.c \
src/freecon.c \
src/init.c \
src/label.c \
src/label_file.c \
src/label_android_property.c


common_COPY_HEADERS_TO := selinux
common_COPY_HEADERS := include/selinux/selinux.h include/selinux/label.h include/selinux/context.h include/selinux/avc.h

include $(CLEAR_VARS)
LOCAL_SRC_FILES := $(common_SRC_FILES)
LOCAL_MODULE:= libselinux
LOCAL_MODULE_TAGS := eng
LOCAL_STATIC_LIBRARIES := libmincrypt
LOCAL_C_INCLUDES := jni/selinux/libselinux/include/ jni/selinux/libsepol/include/
LOCAL_WHOLE_STATIC_LIBRARIES := libpcre
# 1003 corresponds to auditd, from system/core/logd/event.logtags
LOCAL_CFLAGS := -DAUDITD_LOG_TAG=1003
include $(BUILD_STATIC_LIBRARY)
54 changes: 54 additions & 0 deletions libselinux/include/stdio_ext.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (C) 2014 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/

#ifndef _STDIO_EXT_H
#define _STDIO_EXT_H

#include <sys/cdefs.h>
#include <stdio.h>

#define FSETLOCKING_QUERY 0
#define FSETLOCKING_INTERNAL 1
#define FSETLOCKING_BYCALLER 2

__BEGIN_DECLS

size_t __fbufsize(FILE*);
int __freading(FILE*);
int __fwriting(FILE*);
int __freadable(FILE*);
int __fwritable(FILE*);
int __flbf(FILE*);
void __fpurge(FILE*);
size_t __fpending(FILE*);
void _flushlbf(void);
int __fsetlocking(FILE*, int);

__END_DECLS

#endif /* _STDIO_EXT_H */
10 changes: 6 additions & 4 deletions libselinux/src/procattr.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ static pthread_key_t destructor_key;
static int destructor_key_initialized = 0;
static __thread char destructor_initialized;

static pid_t gettid(void)
{
return syscall(__NR_gettid);
}
int selinux_page_size = 0;

// static pid_t gettid(void)
// {
// return syscall(__NR_gettid);
// }

static void procattr_thread_destructor(void __attribute__((unused)) *unused)
{
Expand Down

0 comments on commit 91e9179

Please sign in to comment.