Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 38 additions & 3 deletions docs/schema_doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ true

|||
|-|-|
|__Type__|boolean or list of string|
|__Type__|boolean or list of string or dict|
|__Default__|`false`|

If true, run ltrace for entire system starting from init. If names of programs, enable ltrace only for those programs.
If true, run ltrace for entire system starting from init. If names of programs, enable ltrace only for those programs. If dict with 'include' and/or 'exclude' keys, specify programs to trace or exclude.

```yaml
false
Expand All @@ -157,6 +157,24 @@ true
- lighttpd
```

```yaml
include:
- lighttpd
```

```yaml
exclude:
- busybox
- sh
```

```yaml
exclude:
- busybox
include:
- lighttpd
```

### `core.gdbserver` Programs to run through gdbserver

|||
Expand Down Expand Up @@ -275,7 +293,7 @@ my_shared_directory

|||
|-|-|
|__Type__|`"1.0.0"` or `2`|
|__Type__|`"1.0.0"` or `2` or `3`|

Version of the config file format

Expand Down Expand Up @@ -407,6 +425,23 @@ false
true
```

### `core.init` init to run after rehosting starts

|||
|-|-|
|__Type__|string|
|__Default__|`null`|

Path to init you expect to run in the system. This is the last thing executed by penguin during guest startup

```yaml
/sbin/init
```

```yaml
/sbin/preinit
```

## `patches` Patches

|||
Expand Down
40 changes: 34 additions & 6 deletions guest-utils/ltrace/inject_ltrace.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@
#include <string.h>
#include <unistd.h>

int libinject_get_config(const char *key, char *output, unsigned long buf_size);
int libinject_get_config_bool(const char *config_key);

__attribute__((constructor)) void igloo_start_ltrace(void)
{
// Don't do anything if the user doesn't want to ltrace
if (!getenv("IGLOO_LTRACE")) {
if(!libinject_get_config_bool("core.ltrace")) {
return;
}

Expand Down Expand Up @@ -40,19 +43,44 @@ __attribute__((constructor)) void igloo_start_ltrace(void)
}

// Don't do anything if the user doesn't want to ltrace this process
char *excluded_cmds = getenv("IGLOO_LTRACE_EXCLUDED");
if (excluded_cmds) {
bool should_trace = true;

// Check include list first
char included_cmds[1024];
if (libinject_get_config("core.ltrace.include", included_cmds, sizeof(included_cmds)) == 0) {
// If there's an include list, default to false and only trace if included
should_trace = false;
char *included_copy = strdup(included_cmds);
char *tok = strtok(included_copy, ",");
while (tok) {
if (!strcmp(tok, comm)) {
should_trace = true;
break;
}
tok = strtok(NULL, ",");
}
free(included_copy);
}

// If we're not supposed to trace based on include list, return early
if (!should_trace) {
return;
}

// Check exclude list
char excluded_cmds[1024];
if (libinject_get_config("core.ltrace.exclude", excluded_cmds, sizeof(excluded_cmds)) == 0) {
bool excluded = false;
excluded_cmds = strdup(excluded_cmds);
char *tok = strtok(excluded_cmds, ",");
char *excluded_copy = strdup(excluded_cmds);
char *tok = strtok(excluded_copy, ",");
while (tok) {
if (!strcmp(tok, comm)) {
excluded = true;
break;
}
tok = strtok(NULL, ",");
}
free(excluded_cmds);
free(excluded_copy);
if (excluded) {
return;
}
Expand Down
4 changes: 4 additions & 0 deletions guest-utils/native/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ out/%/test_ioctl_interaction: test_ioctl_interaction.c
@mkdir -p $(dir $@)
$(CC_$*) $(CFLAGS_$*) $< -o $@

out/%/get_config: get_config.c
@mkdir -p $(dir $@)
$(CC_$*) $(CFLAGS_$*) $< -o $@

out/%/test_nvram: test_nvram.c
@mkdir -p $(dir $@)
$(CC_$*) $(CFLAGS_DYNAMIC_$*) -Wl,--dynamic-linker=/igloo/dylibs/ld-musl-$*.so.1 $< -o $@
Expand Down
Loading