Initial Commit
- initial default booting image
This commit is contained in:
@@ -0,0 +1 @@
|
||||
source "$BR2_EXTERNAL_CLANG_COMPILER_RT_PATH/package/libfuzzer/Config.in"
|
||||
@@ -0,0 +1 @@
|
||||
name: CLANG_COMPILER_RT
|
||||
@@ -0,0 +1 @@
|
||||
include $(sort $(wildcard $(BR2_EXTERNAL_CLANG_COMPILER_RT_PATH)/package/*/*.mk))
|
||||
@@ -0,0 +1,8 @@
|
||||
config BR2_PACKAGE_LIBFUZZER
|
||||
bool "libfuzzer"
|
||||
help
|
||||
This project aims at hosting tutorials,
|
||||
examples, discussions, research proposals,
|
||||
and other resources related to fuzzing.
|
||||
|
||||
https://github.com/google/fuzzing
|
||||
@@ -0,0 +1,2 @@
|
||||
sha256 c71360c3b1ba1d88b28b0b3cb3a1744d251b87a12f2881224cc53ec26eb7a2db libfuzzer-cec02db916d21baa4db5b8d262d78848b3a35f4b.tar.gz
|
||||
sha256 cfc7749b96f63bd31c3c42b5c471bf756814053e847c10f3eb003417bc523d30 LICENSE
|
||||
@@ -0,0 +1,24 @@
|
||||
################################################################################
|
||||
#
|
||||
# libfuzzer
|
||||
#
|
||||
################################################################################
|
||||
|
||||
LIBFUZZER_VERSION = cec02db916d21baa4db5b8d262d78848b3a35f4b
|
||||
LIBFUZZER_SITE = $(call github,google,fuzzing,$(LIBFUZZER_VERSION))
|
||||
LIBFUZZER_LICENSE = Apache-2.0
|
||||
LIBFUZZER_LICENSE_FILES = LICENSE
|
||||
LIBFUZZER_DEPENDENCIES = compiler-rt
|
||||
|
||||
define LIBFUZZER_BUILD_CMDS
|
||||
$(HOST_DIR)/bin/clang++ --sysroot=$(STAGING_DIR) \
|
||||
-fsanitize=address,fuzzer \
|
||||
$(@D)/tutorial/libFuzzer/fuzz_me.cc \
|
||||
-o $(@D)/fuzz_me
|
||||
endef
|
||||
|
||||
define LIBFUZZER_INSTALL_TARGET_CMDS
|
||||
$(INSTALL) -D -m 755 $(@D)/fuzz_me $(TARGET_DIR)/usr/bin/fuzz_me
|
||||
endef
|
||||
|
||||
$(eval $(generic-package))
|
||||
@@ -0,0 +1 @@
|
||||
source "$BR2_EXTERNAL_GUMBO_PARSER_PATH/package/gumbo-parser-test/Config.in"
|
||||
@@ -0,0 +1 @@
|
||||
name: GUMBO_PARSER
|
||||
@@ -0,0 +1 @@
|
||||
include $(sort $(wildcard $(BR2_EXTERNAL_GUMBO_PARSER_PATH)/package/*/*.mk))
|
||||
@@ -0,0 +1,7 @@
|
||||
config BR2_PACKAGE_GUMBO_PARSER_TEST
|
||||
bool "gumbo-parser-test"
|
||||
depends on BR2_PACKAGE_GUMBO_PARSER
|
||||
help
|
||||
Test program for gumbo-parser library.
|
||||
This package builds a simple test program that demonstrates
|
||||
basic HTML parsing functionality using gumbo-parser.
|
||||
@@ -0,0 +1,19 @@
|
||||
################################################################################
|
||||
#
|
||||
# gumbo-parser-test
|
||||
#
|
||||
################################################################################
|
||||
|
||||
GUMBO_PARSER_TEST_DEPENDENCIES = gumbo-parser
|
||||
|
||||
define GUMBO_PARSER_TEST_BUILD_CMDS
|
||||
$(TARGET_CC) $(TARGET_CFLAGS) -o $(@D)/gumbo_test \
|
||||
$(GUMBO_PARSER_TEST_PKGDIR)/gumbo_test.c \
|
||||
$(TARGET_LDFLAGS) -lgumbo
|
||||
endef
|
||||
|
||||
define GUMBO_PARSER_TEST_INSTALL_TARGET_CMDS
|
||||
$(INSTALL) -D -m 0755 $(@D)/gumbo_test $(TARGET_DIR)/usr/bin/gumbo_test
|
||||
endef
|
||||
|
||||
$(eval $(generic-package))
|
||||
@@ -0,0 +1,40 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <gumbo.h>
|
||||
|
||||
static void search_for_title(GumboNode* node) {
|
||||
if (node->type != GUMBO_NODE_ELEMENT) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (node->v.element.tag == GUMBO_TAG_TITLE) {
|
||||
GumboNode* text = node->v.element.children.data[0];
|
||||
if (text->type == GUMBO_NODE_TEXT) {
|
||||
printf("Found title: %s\n", text->v.text.text);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
GumboVector* children = &node->v.element.children;
|
||||
for (unsigned int i = 0; i < children->length; ++i) {
|
||||
search_for_title(children->data[i]);
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
const char* html = "<html><head><title>Test HTML</title></head><body><p>Hello World</p></body></html>";
|
||||
|
||||
GumboOutput* output = gumbo_parse(html);
|
||||
|
||||
if (output == NULL) {
|
||||
printf("HTML parsing failed\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
printf("HTML parsing successful\n");
|
||||
search_for_title(output->root);
|
||||
|
||||
gumbo_destroy_output(&kGumboDefaultOptions, output);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
source "$BR2_EXTERNAL_OPENJDK_PATH/package/openjdk-hello-world/Config.in"
|
||||
source "$BR2_EXTERNAL_OPENJDK_PATH/package/openjdk-jni-test/Config.in"
|
||||
@@ -0,0 +1 @@
|
||||
name: OPENJDK
|
||||
@@ -0,0 +1 @@
|
||||
include $(sort $(wildcard $(BR2_EXTERNAL_OPENJDK_PATH)/package/*/*.mk))
|
||||
@@ -0,0 +1,5 @@
|
||||
config BR2_PACKAGE_OPENJDK_HELLO_WORLD
|
||||
bool "openjdk hello world"
|
||||
depends on BR2_PACKAGE_OPENJDK
|
||||
help
|
||||
Simple class for testing openjdk
|
||||
@@ -0,0 +1,7 @@
|
||||
public class HelloWorld
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
System.out.println("Hello, World");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
################################################################################
|
||||
#
|
||||
# openjdk hello world
|
||||
#
|
||||
################################################################################
|
||||
|
||||
OPENJDK_HELLO_WORLD_DEPENDENCIES = openjdk
|
||||
|
||||
define OPENJDK_HELLO_WORLD_BUILD_CMDS
|
||||
$(INSTALL) -D $(OPENJDK_HELLO_WORLD_PKGDIR)/HelloWorld.java $(@D)/HelloWorld.java
|
||||
$(JAVAC) $(@D)/HelloWorld.java
|
||||
endef
|
||||
|
||||
define OPENJDK_HELLO_WORLD_INSTALL_TARGET_CMDS
|
||||
$(INSTALL) -D -m 755 $(@D)/HelloWorld.class $(TARGET_DIR)/usr/bin/HelloWorld.class
|
||||
endef
|
||||
|
||||
$(eval $(generic-package))
|
||||
@@ -0,0 +1,5 @@
|
||||
config BR2_PACKAGE_OPENJDK_JNI_TEST
|
||||
bool "openjdk JNI test"
|
||||
depends on BR2_PACKAGE_OPENJDK
|
||||
help
|
||||
Tests openjdk JNI support
|
||||
@@ -0,0 +1,9 @@
|
||||
public class JniHelper
|
||||
{
|
||||
public void HelloManagedWorld()
|
||||
{
|
||||
stringMember = "Hello, Managed World";
|
||||
}
|
||||
|
||||
public String stringMember = "Set from Java";
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
public class JniTest
|
||||
{
|
||||
private static void Test(
|
||||
String name,
|
||||
Object actual,
|
||||
Object expected,
|
||||
String actualAsString,
|
||||
String expectedAsString)
|
||||
{
|
||||
if (!actual.equals(expected))
|
||||
{
|
||||
System.out.println(String.format(
|
||||
"Test: %s failed\nExpected: \"%s\", Actual: \"%s\"",
|
||||
name,
|
||||
expected,
|
||||
actual));
|
||||
JniTest.exitCode = -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println(String.format("Test: %s passed", name));
|
||||
}
|
||||
}
|
||||
|
||||
private static void Test(
|
||||
String name,
|
||||
String actual,
|
||||
String expected)
|
||||
{
|
||||
JniTest.Test(name, actual, expected, actual, expected);
|
||||
}
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
var actualVersion = JniWrapper.get_jni_version();
|
||||
var expectedVersion = 0x00180000;
|
||||
JniTest.Test(
|
||||
"Get JNI Version",
|
||||
actualVersion,
|
||||
expectedVersion,
|
||||
String.format("0x%08X", actualVersion),
|
||||
String.format("0x%08X", expectedVersion));
|
||||
|
||||
JniTest.Test(
|
||||
"Read Native String Constant",
|
||||
JniWrapper.read_constant_string(),
|
||||
"Hello from C");
|
||||
|
||||
JniTest.Test(
|
||||
"Write Java String to Native Library",
|
||||
JniWrapper.write_string("Hello from Java"),
|
||||
"Hello from Java");
|
||||
|
||||
JniTest.Test(
|
||||
"Write Java Char Array to Native Library",
|
||||
JniWrapper.write_char_array("Hello from Java".toCharArray()),
|
||||
"Hello from Java");
|
||||
|
||||
var helper = new JniHelper();
|
||||
JniTest.Test(
|
||||
"Write String Member to Native Library",
|
||||
JniWrapper.write_string_member(helper),
|
||||
"Set from Java");
|
||||
|
||||
JniWrapper.set_string_member(helper);
|
||||
JniTest.Test(
|
||||
"Set String Member from Native Library",
|
||||
helper.stringMember,
|
||||
"Set from C");
|
||||
|
||||
JniWrapper.execute_java_function(helper);
|
||||
JniTest.Test(
|
||||
"Execeute Java Function from Native Library",
|
||||
helper.stringMember,
|
||||
"Hello, Managed World");
|
||||
|
||||
helper = JniWrapper.instantiate_java_class();
|
||||
JniTest.Test(
|
||||
"Instantiate Java Class",
|
||||
helper.stringMember,
|
||||
"Instantiated from C");
|
||||
|
||||
JniTest.Test(
|
||||
"Call Native Library to Set System Time",
|
||||
JniWrapper.set_and_write_time_in_seconds(1000),
|
||||
"1000");
|
||||
|
||||
System.exit(exitCode);
|
||||
}
|
||||
|
||||
public static int exitCode = 0;
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
#include "JniWrapper.h"
|
||||
#include "jni_helper.h"
|
||||
|
||||
// Proxies the generated function calls to the jni_helper
|
||||
|
||||
JNIEXPORT jint JNICALL Java_JniWrapper_get_1jni_1version
|
||||
(JNIEnv* env, jclass class)
|
||||
{
|
||||
return get_jni_version(env);
|
||||
}
|
||||
JNIEXPORT jstring JNICALL Java_JniWrapper_read_1constant_1string
|
||||
(JNIEnv* env, jclass class)
|
||||
{
|
||||
return read_constant_jstring(env);
|
||||
}
|
||||
JNIEXPORT jstring JNICALL Java_JniWrapper_write_1string
|
||||
(JNIEnv* env, jclass class, jstring string)
|
||||
{
|
||||
return write_jstring(env, string);
|
||||
}
|
||||
JNIEXPORT jstring JNICALL Java_JniWrapper_write_1char_1array
|
||||
(JNIEnv* env, jclass class, jcharArray chars)
|
||||
{
|
||||
return write_jchar_array(env, chars);
|
||||
}
|
||||
JNIEXPORT jstring JNICALL Java_JniWrapper_write_1string_1member
|
||||
(JNIEnv* env, jclass class, jobject helper)
|
||||
{
|
||||
return write_string_member(env, helper);
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_JniWrapper_set_1string_1member
|
||||
(JNIEnv* env, jclass class, jobject helper)
|
||||
{
|
||||
set_string_member(env, helper);
|
||||
}
|
||||
JNIEXPORT void JNICALL Java_JniWrapper_execute_1java_1function
|
||||
(JNIEnv* env, jclass class, jobject helper)
|
||||
{
|
||||
execute_java_function(env, helper);
|
||||
}
|
||||
JNIEXPORT jobject JNICALL Java_JniWrapper_instantiate_1java_1class
|
||||
(JNIEnv* env, jclass class)
|
||||
{
|
||||
return instantiate_java_class(env);
|
||||
}
|
||||
JNIEXPORT jstring JNICALL Java_JniWrapper_set_1and_1write_1time_1in_1seconds
|
||||
(JNIEnv* env, jclass class, jint seconds)
|
||||
{
|
||||
return set_and_write_time_in_seconds(env, seconds);
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
public class JniWrapper
|
||||
{
|
||||
static
|
||||
{
|
||||
System.loadLibrary("jni_native");
|
||||
}
|
||||
|
||||
public static native int get_jni_version();
|
||||
public static native String read_constant_string();
|
||||
public static native String write_string(String string);
|
||||
public static native String write_char_array(char[] string);
|
||||
public static native String write_string_member(JniHelper helper);
|
||||
public static native void set_string_member(JniHelper helper);
|
||||
public static native void execute_java_function(JniHelper helper);
|
||||
public static native JniHelper instantiate_java_class();
|
||||
public static native String set_and_write_time_in_seconds(int seconds);
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
#include "jni_helper.h"
|
||||
#include "native.h"
|
||||
|
||||
// Handles Java/C interop
|
||||
|
||||
jint get_jni_version(JNIEnv* env)
|
||||
{
|
||||
return (*env)->GetVersion(env);
|
||||
}
|
||||
jstring read_constant_jstring(JNIEnv* env)
|
||||
{
|
||||
return (*env)->NewStringUTF(env, read_constant_string());
|
||||
}
|
||||
static jstring read_internal_string_as_jstring(JNIEnv* env)
|
||||
{
|
||||
return (*env)->NewStringUTF(env, read_internal_string());
|
||||
}
|
||||
jstring write_jstring(JNIEnv* env, jstring string)
|
||||
{
|
||||
const char* utf8_string = (*env)->GetStringUTFChars(env, string, NULL);
|
||||
write_internal_string(utf8_string);
|
||||
|
||||
(*env)->ReleaseStringUTFChars(env, string, utf8_string);
|
||||
return read_internal_string_as_jstring(env);
|
||||
}
|
||||
jstring write_jchar_array(JNIEnv* env, jcharArray chars)
|
||||
{
|
||||
jsize length = (*env)->GetArrayLength(env, chars);
|
||||
jchar* body = (*env)->GetCharArrayElements(env, chars, NULL);
|
||||
jstring input = (*env)->NewString(env, body, length);
|
||||
jstring output = write_jstring(env, input);
|
||||
|
||||
(*env)->ReleaseCharArrayElements(env, chars, body, JNI_ABORT);
|
||||
return output;
|
||||
}
|
||||
static jfieldID get_string_member_field(JNIEnv* env, jobject helper)
|
||||
{
|
||||
jclass class = (*env)->GetObjectClass(env, helper);
|
||||
return (*env)->GetFieldID(env, class, "stringMember", "Ljava/lang/String;");
|
||||
}
|
||||
jstring write_string_member(JNIEnv* env, jobject helper)
|
||||
{
|
||||
jfieldID fieldID = get_string_member_field(env, helper);
|
||||
jstring string = (*env)->GetObjectField(env, helper, fieldID);
|
||||
|
||||
return write_jstring(env, string);
|
||||
}
|
||||
static void set_string_member_helper(JNIEnv* env, jobject helper, const char* utf8_string)
|
||||
{
|
||||
jfieldID fieldID = get_string_member_field(env, helper);
|
||||
jstring string = (*env)->NewStringUTF(env, utf8_string);
|
||||
(*env)->SetObjectField(env, helper, fieldID, string);
|
||||
}
|
||||
void set_string_member(JNIEnv* env, jobject helper)
|
||||
{
|
||||
char stringBuffer[256];
|
||||
write_external_string(stringBuffer, 256);
|
||||
set_string_member_helper(env, helper, stringBuffer);
|
||||
}
|
||||
|
||||
typedef struct
|
||||
{
|
||||
JNIEnv* env;
|
||||
jobject object;
|
||||
jmethodID methodID;
|
||||
} method_parameters;
|
||||
static void call_void_java_method(void* context)
|
||||
{
|
||||
method_parameters* parameters = (method_parameters*)context;
|
||||
(*parameters->env)->CallVoidMethod(parameters->env, parameters->object, parameters->methodID);
|
||||
}
|
||||
void execute_java_function(JNIEnv* env, jobject helper)
|
||||
{
|
||||
jclass class = (*env)->GetObjectClass(env, helper);
|
||||
jmethodID methodID = (*env)->GetMethodID(env, class, "HelloManagedWorld", "()V");
|
||||
|
||||
method_parameters parameters = {env, helper, methodID};
|
||||
execute_function(call_void_java_method, (void*)¶meters);
|
||||
}
|
||||
jobject instantiate_java_class(JNIEnv* env)
|
||||
{
|
||||
jclass class = (*env)->FindClass(env, "JniHelper");
|
||||
jmethodID methodID = (*env)->GetMethodID(env, class, "<init>", "()V");
|
||||
|
||||
jobject object =(*env)->NewObject(env, class, methodID);
|
||||
set_string_member_helper(env, object, "Instantiated from C");
|
||||
return object;
|
||||
}
|
||||
jstring set_and_write_time_in_seconds(JNIEnv* env, jint seconds)
|
||||
{
|
||||
set_time_in_seconds((int)seconds);
|
||||
write_internal_time_in_seconds();
|
||||
return read_internal_string_as_jstring(env);
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
jint get_jni_version(JNIEnv* env);
|
||||
jstring read_constant_jstring(JNIEnv* env);
|
||||
jstring write_jstring(JNIEnv* env, jstring string);
|
||||
jstring write_jchar_array(JNIEnv* env, jcharArray chars);
|
||||
jstring write_string_member(JNIEnv* env, jobject helper);
|
||||
void set_string_member(JNIEnv* env, jobject helper);
|
||||
void execute_java_function(JNIEnv* env, jobject helper);
|
||||
jobject instantiate_java_class(JNIEnv* env);
|
||||
jstring set_and_write_time_in_seconds(JNIEnv* env, jint seconds);
|
||||
@@ -0,0 +1,41 @@
|
||||
#include "native.h"
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
// Pure native functions
|
||||
|
||||
#define CHAR_BUFFER_SIZE 256
|
||||
static char buffer[CHAR_BUFFER_SIZE];
|
||||
|
||||
const char* read_constant_string()
|
||||
{
|
||||
return "Hello from C";
|
||||
}
|
||||
const char* read_internal_string()
|
||||
{
|
||||
return buffer;
|
||||
}
|
||||
void write_internal_string(const char* string)
|
||||
{
|
||||
snprintf(buffer, CHAR_BUFFER_SIZE, "%s", string);
|
||||
}
|
||||
void write_external_string(char* string, size_t maxLength)
|
||||
{
|
||||
snprintf(string, maxLength, "Set from C");
|
||||
}
|
||||
void execute_function(void(*function)(void*), void* context)
|
||||
{
|
||||
function(context);
|
||||
}
|
||||
void set_time_in_seconds(int seconds)
|
||||
{
|
||||
struct timespec timeToSet = { 0, 0 };
|
||||
|
||||
timeToSet.tv_sec = seconds;
|
||||
clock_settime(CLOCK_REALTIME, &timeToSet);
|
||||
}
|
||||
void write_internal_time_in_seconds()
|
||||
{
|
||||
time_t systemTime = time(NULL);
|
||||
snprintf(buffer, CHAR_BUFFER_SIZE, "%u", systemTime);
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
const char* read_constant_string();
|
||||
const char* read_internal_string();
|
||||
void write_internal_string(const char* string);
|
||||
void write_external_string(char* string, size_t maxLength);
|
||||
void execute_function(void(*function)(void*), void* context);
|
||||
void set_time_in_seconds(int seconds);
|
||||
void write_internal_time_in_seconds();
|
||||
@@ -0,0 +1,34 @@
|
||||
################################################################################
|
||||
#
|
||||
# openjdk jni test
|
||||
#
|
||||
################################################################################
|
||||
|
||||
OPENJDK_JNI_TEST_DEPENDENCIES = openjdk
|
||||
|
||||
JNI_INCLUDE_PATH = $(BUILD_DIR)/openjdk-$(OPENJDK_VERSION)/build/linux-aarch64-server-release/jdk/include
|
||||
|
||||
define OPENJDK_JNI_TEST_BUILD_CMDS
|
||||
# Compile Java classes and generate native headers
|
||||
$(JAVAC) -d $(@D) -h $(@D) \
|
||||
$(OPENJDK_JNI_TEST_PKGDIR)/JniTest.java \
|
||||
$(OPENJDK_JNI_TEST_PKGDIR)/JniWrapper.java \
|
||||
$(OPENJDK_JNI_TEST_PKGDIR)/JniHelper.java
|
||||
|
||||
# Compile shared library
|
||||
$(TARGET_MAKE_ENV) $(TARGET_CC) -shared -fPIC \
|
||||
-I$(JNI_INCLUDE_PATH) -I$(JNI_INCLUDE_PATH)/linux -I$(@D) \
|
||||
-o $(@D)/libjni_native.so \
|
||||
$(OPENJDK_JNI_TEST_PKGDIR)/JniWrapper.c \
|
||||
$(OPENJDK_JNI_TEST_PKGDIR)/jni_helper.c \
|
||||
$(OPENJDK_JNI_TEST_PKGDIR)/native.c
|
||||
endef
|
||||
|
||||
define OPENJDK_JNI_TEST_INSTALL_TARGET_CMDS
|
||||
$(INSTALL) -D -m 755 $(@D)/JniTest.class $(TARGET_DIR)/usr/bin/JniTest.class
|
||||
$(INSTALL) -D -m 755 $(@D)/JniWrapper.class $(TARGET_DIR)/usr/bin/JniWrapper.class
|
||||
$(INSTALL) -D -m 755 $(@D)/JniHelper.class $(TARGET_DIR)/usr/bin/JniHelper.class
|
||||
$(INSTALL) -D -m 755 $(@D)/libjni_native.so $(TARGET_DIR)/usr/lib/libjni_native.so
|
||||
endef
|
||||
|
||||
$(eval $(generic-package))
|
||||
@@ -0,0 +1 @@
|
||||
source "$BR2_EXTERNAL_POLKIT_PATH/package/polkit-rules-test/Config.in"
|
||||
@@ -0,0 +1 @@
|
||||
name: POLKIT
|
||||
@@ -0,0 +1 @@
|
||||
include $(sort $(wildcard $(BR2_EXTERNAL_POLKIT_PATH)/package/*/*.mk))
|
||||
@@ -0,0 +1,6 @@
|
||||
config BR2_PACKAGE_POLKIT_RULES_TEST
|
||||
bool "polkit rules test"
|
||||
depends on BR2_PACKAGE_POLKIT
|
||||
help
|
||||
Simple test to ensure polkit is loading and enforcing rules
|
||||
correctly.
|
||||
@@ -0,0 +1,6 @@
|
||||
#include <stdio.h>
|
||||
|
||||
int main(void){
|
||||
printf("Hello polkit!\n");
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE policyconfig PUBLIC
|
||||
"-//freedesktop//DTD PolicyKit Policy Configuration 1.0//EN"
|
||||
"http://www.freedesktop.org/software/polkit/policyconfig-1.dtd">
|
||||
<policyconfig>
|
||||
<action id="org.freedesktop.policykit.pkexec.hello-polkit">
|
||||
<message>Authentication is required to run the hello world test program</message>
|
||||
<defaults>
|
||||
<allow_inactive>no</allow_inactive>
|
||||
<allow_active>no</allow_active>
|
||||
</defaults>
|
||||
<annotate key="org.freedesktop.policykit.exec.path">/usr/bin/hello-polkit</annotate>
|
||||
</action>
|
||||
</policyconfig>
|
||||
@@ -0,0 +1,6 @@
|
||||
polkit.addRule(function(action, subject) {
|
||||
if (action.id == "org.freedesktop.policykit.pkexec.hello-polkit" &&
|
||||
subject.user == "brtest") {
|
||||
return polkit.Result.YES;
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1,38 @@
|
||||
################################################################################
|
||||
#
|
||||
# polkit-rules-test
|
||||
#
|
||||
################################################################################
|
||||
|
||||
POLKIT_RULES_TEST_DEPENDENCIES = polkit
|
||||
|
||||
define POLKIT_RULES_TEST_USERS
|
||||
brtest -1 brtest -1 =password /home/brtest /bin/sh brtest
|
||||
endef
|
||||
|
||||
define POLKIT_RULES_TEST_BUILD_CMDS
|
||||
$(INSTALL) -D $(POLKIT_RULES_TEST_PKGDIR)/initd/hello-polkit.c $(@D)/hello-polkit.c
|
||||
$(TARGET_CC) $(@D)/hello-polkit.c -o $(@D)/hello-polkit
|
||||
endef
|
||||
|
||||
# Install the rules file to /root. Test_polkit.py first tests that restarting
|
||||
# timesyncd as a user fails, then moves the rules file and confirmes restarting
|
||||
# timesyncd as a user succeeds.
|
||||
define POLKIT_RULES_TEST_INSTALL_INIT_SYSTEMD
|
||||
mkdir -p $(TARGET_DIR)/etc/polkit-1/rules.d
|
||||
$(INSTALL) -D $(POLKIT_RULES_TEST_PKGDIR)/systemd/systemd-timesyncd-restart.rules \
|
||||
$(TARGET_DIR)/root/systemd-timesyncd-restart.rules
|
||||
endef
|
||||
|
||||
define POLKIT_RULES_TEST_INSTALL_INIT_SYSV
|
||||
mkdir -p $(TARGET_DIR)/usr/share/polkit-1/actions/
|
||||
$(INSTALL) -D $(@D)/hello-polkit $(TARGET_DIR)/usr/bin/hello-polkit
|
||||
|
||||
$(INSTALL) -D $(POLKIT_RULES_TEST_PKGDIR)/initd/hello-polkit.policy \
|
||||
$(TARGET_DIR)/usr/share/polkit-1/actions/hello-polkit.policy
|
||||
|
||||
$(INSTALL) -D $(POLKIT_RULES_TEST_PKGDIR)/initd/hello-polkit.rules \
|
||||
$(TARGET_DIR)/root/hello-polkit.rules
|
||||
endef
|
||||
|
||||
$(eval $(generic-package))
|
||||
@@ -0,0 +1,7 @@
|
||||
polkit.addRule(function(action, subject) {
|
||||
if (action.id == "org.freedesktop.systemd1.manage-units" &&
|
||||
action.lookup("unit") == "systemd-timesyncd.service" &&
|
||||
subject.user == "brtest") {
|
||||
return polkit.Result.YES;
|
||||
}
|
||||
});
|
||||
@@ -0,0 +1 @@
|
||||
source "$BR2_EXTERNAL_PYTHON_PYBIND_PATH/package/python-pybind-example/Config.in"
|
||||
@@ -0,0 +1 @@
|
||||
name: PYTHON_PYBIND
|
||||
@@ -0,0 +1 @@
|
||||
include $(sort $(wildcard $(BR2_EXTERNAL_PYTHON_PYBIND_PATH)/package/*/*.mk))
|
||||
@@ -0,0 +1,6 @@
|
||||
config BR2_PACKAGE_PYTHON_PYBIND_EXAMPLE
|
||||
bool "python-pybind-example"
|
||||
depends on BR2_PACKAGE_PYTHON3
|
||||
select BR2_PACKAGE_PYTHON_PYBIND
|
||||
help
|
||||
This test creates a cpp macro later used on target in python
|
||||
@@ -0,0 +1,16 @@
|
||||
#include <pybind11/pybind11.h>
|
||||
namespace py = pybind11;
|
||||
|
||||
int add (int i, int j) {
|
||||
return i + j;
|
||||
}
|
||||
|
||||
PYBIND11_MODULE (example, m) {
|
||||
// optional module description
|
||||
m.doc() = "pybind11 example plugin";
|
||||
// test a module method
|
||||
m.def("add", &add, "example::add adds two integer numbers");
|
||||
// test a module attribute
|
||||
py::object hello = py::cast("Hello World");
|
||||
m.attr("says") = hello;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
################################################################################
|
||||
#
|
||||
# python-pybind-example
|
||||
#
|
||||
################################################################################
|
||||
|
||||
# this builds a C++ macro "add(a,b)"
|
||||
# that we expose to host-python with a custom install
|
||||
# and that the python test script will later use
|
||||
PYTHON_PYBIND_EXAMPLE_DEPENDENCIES = python-pybind
|
||||
|
||||
PYTHON_PYBIND_EXAMPLE_PYBIND_INCLUDE = \
|
||||
$(shell $(HOST_DIR)/bin/python3 -c 'import pybind11; print(pybind11.get_include())')
|
||||
|
||||
PYTHON_PYBIND_EXAMPLE_CXX_FLAGS = \
|
||||
$(TARGET_CXXFLAGS) \
|
||||
-Wall -shared -std=c++11 -fPIC \
|
||||
-I$(PYTHON_PYBIND_EXAMPLE_PYBIND_INCLUDE) \
|
||||
$(shell $(STAGING_DIR)/usr/bin/python3-config --includes --libs --ldflags)
|
||||
|
||||
# .so to be installed must have exact suffix
|
||||
# otherwise import() in python will not work
|
||||
HOST_LIB_BINARY_SUFFIX = \
|
||||
$(shell $(STAGING_DIR)/usr/bin/python3-config --extension-suffix)
|
||||
|
||||
define PYTHON_PYBIND_EXAMPLE_BUILD_CMDS
|
||||
if [ -z "$(PYTHON_PYBIND_EXAMPLE_PYBIND_INCLUDE)" ]; then \
|
||||
echo "pybind11.get_include() returned empty"; \
|
||||
exit 1; \
|
||||
fi
|
||||
$(TARGET_CXX) $(PYTHON_PYBIND_EXAMPLE_CXX_FLAGS) \
|
||||
$(PYTHON_PYBIND_EXAMPLE_PKGDIR)/example.cpp \
|
||||
-o $(@D)/example$(HOST_LIB_BINARY_SUFFIX)
|
||||
endef
|
||||
|
||||
define PYTHON_PYBIND_EXAMPLE_INSTALL_TARGET_CMDS
|
||||
$(INSTALL) -D -m 755 $(@D)/example$(HOST_LIB_BINARY_SUFFIX) \
|
||||
$(TARGET_DIR)/usr/lib/python$(PYTHON3_VERSION_MAJOR)/site-packages/example$(HOST_LIB_BINARY_SUFFIX)
|
||||
endef
|
||||
|
||||
$(eval $(generic-package))
|
||||
Reference in New Issue
Block a user