Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto mount in Docker containers (#1416) #1440

Merged
merged 30 commits into from
Jun 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
fe0076f
Initial support. Scope all processes in a docker container. Debug and…
iapaddler Apr 11, 2023
9aebf88
Use the defined libdir. Create intermediate dirs before a mount. Writ…
iapaddler Apr 12, 2023
d3828c5
Resolve an issue where subsequent docker run commands did not mount. …
iapaddler Apr 13, 2023
e5bc522
Mount the Edge socket from within a container.
iapaddler Apr 18, 2023
f62f9a9
Merge branch 'release/1.4' into feature/dockerd-mount-1416
iapaddler Apr 18, 2023
c836ad9
Support the case where some Go execs add the interface version, .abi0…
iapaddler Apr 19, 2023
8262c12
Applied review comments.
iapaddler Apr 19, 2023
84f58ef
Use the internal libc for mount.
iapaddler Apr 20, 2023
fd8f445
Merge branch 'release/1.4' into feature/dockerd-mount-1416
iapaddler May 8, 2023
365ab72
Resolved an issue with a unit test.
iapaddler May 8, 2023
add7847
Minor updates intended for clarity.
iapaddler May 8, 2023
20a69f1
WIP: startAutoMount() works, debug needs to be removed and the functi…
iapaddler May 9, 2023
2b62807
WIP: Auto mount from libscope.
iapaddler May 12, 2023
da43893
Added interposition of forkExec in wrap_go.c. Prepping for applying u…
iapaddler May 23, 2023
46625f4
Unit test enablement.
iapaddler May 23, 2023
ff6faff
Add arm64 asm changes
michalbiesek May 26, 2023
36b4f58
Add OCI test
michalbiesek May 29, 2023
59203f3
Add OCI rewrite
michalbiesek May 29, 2023
eff5287
Testing with alternate pclntab location.
iapaddler Jun 5, 2023
cacc545
Tested locating .gopclntab sections in Go 12, 16 & 20.
iapaddler Jun 5, 2023
3779fba
Located the embedded pclntab and update container config from OCI bac…
iapaddler Jun 7, 2023
b131cd9
Merge pull request #1498 from criblio/feat-oci-json-manipulation
iapaddler Jun 7, 2023
0366e69
Merged OCI config. Remove auto mount code from libscope and loader.
iapaddler Jun 7, 2023
aebfe69
Merge with relkease/1.4
iapaddler Jun 7, 2023
9f975a4
Resolved conflicts in start.go
iapaddler Jun 7, 2023
c4f730b
Removed mount from redfine list and a tap entry for forkExec.
iapaddler Jun 7, 2023
f4f5628
Fixed a copy/pasta error getting symbols from pclntab in Go 16/17.
iapaddler Jun 8, 2023
ad7ce02
Missed a free.
iapaddler Jun 14, 2023
79e9881
Merged with release/1.4
iapaddler Jun 14, 2023
6c77ea9
Remove console debug enable and a comment clarfication.
iapaddler Jun 14, 2023
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
35 changes: 18 additions & 17 deletions os/linux/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -106,28 +106,29 @@ libtest: $(LIBRARY_C_FILES) $(LIBRARY_TEST_C_FILES) $(YAML_AR) $(JSON_AR) $(TEST
@echo "$${CI:+::group::}Building Library Tests"
$(CC) -c $(TEST_CFLAGS) $(LIBRARY_C_FILES) $(LIBRARY_INCLUDES) $(LIBRARY_TEST_C_FILES) $(INCLUDES) $(CMOCKA_INCLUDES) $(OS_C_FILES)
$(CC) $(TEST_CFLAGS) -o test/$(OS)/vdsotest vdsotest.o scopestdlib.o dbg.o test.o $(TEST_AR) $(TEST_LD_FLAGS)
$(CC) $(TEST_CFLAGS) -o test/$(OS)/coredumptest coredumptest.o coredump.o scopestdlib.o dbg.o utils.o fn.o plattime.o os.o test.o $(TEST_AR) $(TEST_LD_FLAGS)
$(CC) $(TEST_CFLAGS) -o test/$(OS)/ipctest ipctest.o ipc.o ipc_resp.o cfgutils.o cfg.o mtc.o log.o evtformat.o ctl.o transport.o backoff.o mtcformat.o strset.o com.o scopestdlib.o dbg.o circbuf.o linklist.o fn.o utils.o os.o test.o report.o search.o httpagg.o state.o httpstate.o metriccapture.o plattime.o $(TEST_AR) $(TEST_LD_FLAGS) -Wl,--wrap=jsonConfigurationObject -Wl,--wrap=doAndReplaceConfig
$(CC) $(TEST_CFLAGS) -o test/$(OS)/snapshottest snapshottest.o snapshot.o coredump.o scopestdlib.o dbg.o utils.o fn.o plattime.o os.o test.o $(TEST_AR) $(TEST_LD_FLAGS)
$(CC) $(TEST_CFLAGS) -o test/$(OS)/ostest ostest.o scopestdlib.o dbg.o fn.o utils.o plattime.o os.o test.o $(TEST_AR) $(TEST_LD_FLAGS)
$(CC) $(TEST_CFLAGS) -o test/$(OS)/coredumptest coredumptest.o coredump.o scopestdlib.o dbg.o utils.o fn.o plattime.o os.o scopeelf.o test.o $(TEST_AR) $(TEST_LD_FLAGS)
$(CC) $(TEST_CFLAGS) -o test/$(OS)/ipctest ipctest.o ipc.o ipc_resp.o cfgutils.o cfg.o mtc.o log.o evtformat.o ctl.o transport.o backoff.o mtcformat.o strset.o com.o scopestdlib.o dbg.o circbuf.o linklist.o fn.o utils.o os.o test.o report.o search.o httpagg.o state.o httpstate.o metriccapture.o plattime.o scopeelf.o $(TEST_AR) $(TEST_LD_FLAGS) -Wl,--wrap=jsonConfigurationObject -Wl,--wrap=doAndReplaceConfig
$(CC) $(TEST_CFLAGS) -o test/$(OS)/snapshottest snapshottest.o snapshot.o coredump.o scopestdlib.o dbg.o utils.o fn.o plattime.o os.o scopeelf.o test.o $(TEST_AR) $(TEST_LD_FLAGS)
$(CC) $(TEST_CFLAGS) -o test/$(OS)/ostest ostest.o scopestdlib.o dbg.o fn.o utils.o plattime.o os.o scopeelf.o test.o $(TEST_AR) $(TEST_LD_FLAGS)
$(CC) $(TEST_CFLAGS) -o test/$(OS)/ocitest ocitest.o scopestdlib.o dbg.o test.o $(TEST_AR) $(TEST_LD_FLAGS)
$(CC) $(TEST_CFLAGS) -o test/$(OS)/strsettest strsettest.o strset.o scopestdlib.o dbg.o test.o $(TEST_AR) $(TEST_LD_FLAGS)
$(CC) $(TEST_CFLAGS) -o test/$(OS)/cfgutilstest cfgutilstest.o cfgutils.o cfg.o mtc.o log.o evtformat.o ctl.o transport.o backoff.o mtcformat.o strset.o com.o scopestdlib.o dbg.o circbuf.o linklist.o fn.o utils.o os.o test.o report.o search.o httpagg.o state.o httpstate.o metriccapture.o plattime.o $(TEST_AR) $(TEST_LD_FLAGS)
$(CC) $(TEST_CFLAGS) -o test/$(OS)/cfgutilstest cfgutilstest.o cfgutils.o cfg.o mtc.o log.o evtformat.o ctl.o transport.o backoff.o mtcformat.o strset.o com.o scopestdlib.o dbg.o circbuf.o linklist.o fn.o utils.o os.o test.o report.o search.o httpagg.o state.o httpstate.o metriccapture.o plattime.o scopeelf.o $(TEST_AR) $(TEST_LD_FLAGS)
$(CC) $(TEST_CFLAGS) -o test/$(OS)/cfgtest cfgtest.o cfg.o scopestdlib.o dbg.o test.o $(TEST_AR) $(TEST_LD_FLAGS)
$(CC) $(TEST_CFLAGS) -o test/$(OS)/transporttest transporttest.o transport.o backoff.o scopestdlib.o dbg.o log.o fn.o utils.o plattime.o os.o test.o $(TEST_AR) $(TEST_LD_FLAGS)
$(CC) $(TEST_CFLAGS) -o test/$(OS)/transporttest transporttest.o transport.o backoff.o scopestdlib.o dbg.o log.o fn.o utils.o plattime.o os.o scopeelf.o test.o $(TEST_AR) $(TEST_LD_FLAGS)
$(CC) $(TEST_CFLAGS) -o test/$(OS)/backofftest backofftest.o backoff.o scopestdlib.o dbg.o test.o $(TEST_AR) $(TEST_LD_FLAGS)
$(CC) $(TEST_CFLAGS) -o test/$(OS)/logtest logtest.o log.o transport.o backoff.o scopestdlib.o dbg.o fn.o utils.o plattime.o os.o test.o $(TEST_AR) $(TEST_LD_FLAGS)
$(CC) $(TEST_CFLAGS) -o test/$(OS)/utilstest utilstest.o scopestdlib.o dbg.o fn.o utils.o plattime.o os.o test.o $(TEST_AR) $(TEST_LD_FLAGS)
$(CC) $(TEST_CFLAGS) -o test/$(OS)/mtctest mtctest.o mtc.o log.o transport.o backoff.o mtcformat.o strset.o com.o ctl.o evtformat.o cfg.o cfgutils.o scopestdlib.o dbg.o circbuf.o linklist.o fn.o utils.o os.o test.o report.o search.o httpagg.o state.o httpstate.o metriccapture.o plattime.o $(TEST_AR) $(TEST_LD_FLAGS) -Wl,--wrap=cfgLogStreamEnable
$(CC) $(TEST_CFLAGS) -o test/$(OS)/evtformattest evtformattest.o evtformat.o log.o transport.o backoff.o mtcformat.o strset.o scopestdlib.o dbg.o cfg.o com.o ctl.o mtc.o circbuf.o cfgutils.o linklist.o fn.o utils.o os.o test.o report.o search.o httpagg.o state.o httpstate.o metriccapture.o plattime.o $(TEST_AR) $(TEST_LD_FLAGS)
$(CC) $(TEST_CFLAGS) -o test/$(OS)/ctltest ctltest.o ctl.o log.o transport.o backoff.o scopestdlib.o dbg.o cfgutils.o cfg.o com.o mtc.o evtformat.o mtcformat.o strset.o circbuf.o linklist.o fn.o utils.o os.o test.o report.o search.o httpagg.o state.o httpstate.o metriccapture.o plattime.o $(TEST_AR) $(TEST_LD_FLAGS) -Wl,--wrap=cbufGet
$(CC) $(TEST_CFLAGS) -o test/$(OS)/httpstatetest httpstatetest.o httpstate.o plattime.o search.o fn.o utils.o os.o scopestdlib.o dbg.o test.o com.o cfg.o cfgutils.o mtc.o mtcformat.o strset.o ctl.o transport.o backoff.o linklist.o log.o evtformat.o circbuf.o state.o metriccapture.o report.o httpagg.o $(TEST_AR) $(TEST_LD_FLAGS) -Wl,--wrap=cmdPostEvent -lrt
$(CC) $(TEST_CFLAGS) -o test/$(OS)/httpheadertest httpheadertest.o report.o httpagg.o state.o com.o httpstate.o metriccapture.o plattime.o fn.o utils.o os.o ctl.o log.o transport.o backoff.o scopestdlib.o dbg.o cfgutils.o cfg.o mtc.o evtformat.o mtcformat.o strset.o circbuf.o linklist.o search.o test.o $(TEST_AR) $(TEST_LD_FLAGS) -Wl,--wrap=cmdSendHttp -Wl,--wrap=cmdPostEvent
$(CC) $(TEST_CFLAGS) -o test/$(OS)/httpaggtest httpaggtest.o httpagg.o fn.o utils.o scopestdlib.o dbg.o plattime.o os.o test.o $(TEST_AR) $(TEST_LD_FLAGS)
$(CC) $(TEST_CFLAGS) -o test/$(OS)/reporttest reporttest.o report.o httpagg.o state.o httpstate.o metriccapture.o com.o plattime.o fn.o utils.o os.o ctl.o log.o transport.o backoff.o scopestdlib.o dbg.o cfgutils.o cfg.o mtc.o evtformat.o mtcformat.o strset.o circbuf.o linklist.o search.o test.o $(TEST_AR) $(TEST_LD_FLAGS) -Wl,--wrap=cmdSendEvent -Wl,--wrap=cmdSendMetric
$(CC) $(TEST_CFLAGS) -o test/$(OS)/mtcformattest mtcformattest.o mtcformat.o strset.o scopestdlib.o dbg.o log.o transport.o backoff.o com.o ctl.o mtc.o evtformat.o cfg.o cfgutils.o linklist.o fn.o utils.o circbuf.o os.o test.o report.o search.o httpagg.o state.o httpstate.o metriccapture.o plattime.o $(TEST_AR) $(TEST_LD_FLAGS)
$(CC) $(TEST_CFLAGS) -o test/$(OS)/logtest logtest.o log.o transport.o backoff.o scopestdlib.o dbg.o fn.o utils.o plattime.o os.o scopeelf.o test.o $(TEST_AR) $(TEST_LD_FLAGS)
$(CC) $(TEST_CFLAGS) -o test/$(OS)/utilstest utilstest.o scopestdlib.o dbg.o fn.o utils.o plattime.o os.o scopeelf.o test.o $(TEST_AR) $(TEST_LD_FLAGS)
$(CC) $(TEST_CFLAGS) -o test/$(OS)/mtctest mtctest.o mtc.o log.o transport.o backoff.o mtcformat.o strset.o com.o ctl.o evtformat.o cfg.o cfgutils.o scopestdlib.o dbg.o circbuf.o linklist.o fn.o utils.o os.o test.o report.o search.o httpagg.o state.o httpstate.o metriccapture.o plattime.o scopeelf.o $(TEST_AR) $(TEST_LD_FLAGS) -Wl,--wrap=cfgLogStreamEnable
$(CC) $(TEST_CFLAGS) -o test/$(OS)/evtformattest evtformattest.o evtformat.o log.o transport.o backoff.o mtcformat.o strset.o scopestdlib.o dbg.o cfg.o com.o ctl.o mtc.o circbuf.o cfgutils.o linklist.o fn.o utils.o os.o test.o report.o search.o httpagg.o state.o httpstate.o metriccapture.o plattime.o scopeelf.o $(TEST_AR) $(TEST_LD_FLAGS)
$(CC) $(TEST_CFLAGS) -o test/$(OS)/ctltest ctltest.o ctl.o log.o transport.o backoff.o scopestdlib.o dbg.o cfgutils.o cfg.o com.o mtc.o evtformat.o mtcformat.o strset.o circbuf.o linklist.o fn.o utils.o os.o test.o report.o search.o httpagg.o state.o httpstate.o metriccapture.o plattime.o scopeelf.o $(TEST_AR) $(TEST_LD_FLAGS) -Wl,--wrap=cbufGet
$(CC) $(TEST_CFLAGS) -o test/$(OS)/httpstatetest httpstatetest.o httpstate.o plattime.o search.o fn.o utils.o os.o scopestdlib.o dbg.o test.o com.o cfg.o cfgutils.o mtc.o mtcformat.o strset.o ctl.o transport.o backoff.o linklist.o log.o evtformat.o circbuf.o state.o metriccapture.o report.o httpagg.o scopeelf.o $(TEST_AR) $(TEST_LD_FLAGS) -Wl,--wrap=cmdPostEvent -lrt
$(CC) $(TEST_CFLAGS) -o test/$(OS)/httpheadertest httpheadertest.o report.o httpagg.o state.o com.o httpstate.o metriccapture.o plattime.o fn.o utils.o os.o ctl.o log.o transport.o backoff.o scopestdlib.o dbg.o cfgutils.o cfg.o mtc.o evtformat.o mtcformat.o strset.o circbuf.o linklist.o search.o scopeelf.o test.o $(TEST_AR) $(TEST_LD_FLAGS) -Wl,--wrap=cmdSendHttp -Wl,--wrap=cmdPostEvent
$(CC) $(TEST_CFLAGS) -o test/$(OS)/httpaggtest httpaggtest.o httpagg.o fn.o utils.o scopestdlib.o dbg.o plattime.o os.o scopeelf.o test.o $(TEST_AR) $(TEST_LD_FLAGS)
$(CC) $(TEST_CFLAGS) -o test/$(OS)/reporttest reporttest.o report.o httpagg.o state.o httpstate.o metriccapture.o com.o plattime.o fn.o utils.o os.o ctl.o log.o transport.o backoff.o scopestdlib.o dbg.o cfgutils.o cfg.o mtc.o evtformat.o mtcformat.o strset.o circbuf.o linklist.o search.o scopeelf.o test.o $(TEST_AR) $(TEST_LD_FLAGS) -Wl,--wrap=cmdSendEvent -Wl,--wrap=cmdSendMetric
$(CC) $(TEST_CFLAGS) -o test/$(OS)/mtcformattest mtcformattest.o mtcformat.o strset.o scopestdlib.o dbg.o log.o transport.o backoff.o com.o ctl.o mtc.o evtformat.o cfg.o cfgutils.o linklist.o fn.o utils.o circbuf.o os.o test.o report.o search.o httpagg.o state.o httpstate.o metriccapture.o plattime.o scopeelf.o $(TEST_AR) $(TEST_LD_FLAGS)
$(CC) $(TEST_CFLAGS) -o test/$(OS)/circbuftest circbuftest.o circbuf.o scopestdlib.o dbg.o test.o $(TEST_AR) $(TEST_LD_FLAGS)
$(CC) $(TEST_CFLAGS) -o test/$(OS)/linklisttest linklisttest.o linklist.o scopestdlib.o dbg.o test.o $(TEST_AR) $(TEST_LD_FLAGS)
$(CC) $(TEST_CFLAGS) -o test/$(OS)/comtest comtest.o com.o ctl.o log.o transport.o backoff.o evtformat.o circbuf.o mtcformat.o strset.o cfgutils.o cfg.o mtc.o scopestdlib.o dbg.o linklist.o fn.o utils.o os.o test.o report.o search.o httpagg.o state.o httpstate.o metriccapture.o plattime.o $(TEST_AR) $(TEST_LD_FLAGS)
$(CC) $(TEST_CFLAGS) -o test/$(OS)/comtest comtest.o com.o ctl.o log.o transport.o backoff.o evtformat.o circbuf.o mtcformat.o strset.o cfgutils.o cfg.o mtc.o scopestdlib.o dbg.o linklist.o fn.o utils.o os.o test.o report.o search.o httpagg.o state.o httpstate.o metriccapture.o plattime.o scopeelf.o $(TEST_AR) $(TEST_LD_FLAGS)
$(CC) $(TEST_CFLAGS) -o test/$(OS)/dbgtest dbgtest.o scopestdlib.o dbg.o test.o $(TEST_AR) $(TEST_LD_FLAGS)
$(CC) $(TEST_CFLAGS) -o test/$(OS)/glibcvertest glibcvertest.o $(TEST_AR) $(TEST_LD_FLAGS)
$(CC) $(TEST_CFLAGS) -o test/$(OS)/selfinterposetest selfinterposetest.o $(TEST_AR) $(TEST_LD_FLAGS)
Expand Down
35 changes: 34 additions & 1 deletion os/linux/os.c
Original file line number Diff line number Diff line change
Expand Up @@ -555,17 +555,50 @@ osGetCmdline(pid_t pid, char **cmd)
buf = scope_strdup("none");
} else {
// buf is big; try to scope_strdup what we've used and scope_free the rest
char* tmp = scope_strdup(buf);
char *tmp = scope_strdup(buf);
if (tmp) {
scope_free(buf);
buf = tmp;
}
}

if (fd != -1) scope_close(fd);
*cmd = buf;
return (*cmd != NULL);
}

int
osGetArgv(pid_t pid, char *buf, size_t blen)
{
int i, fd = -1, argc = 0, bytesRead = 0;
char path[64];

if (!buf) return 0;

if (scope_snprintf(path, sizeof(path), "/proc/%d/cmdline", pid) < 0) {
goto out;
}

if ((fd = scope_open(path, O_RDONLY)) == -1) {
DBG(NULL);
goto out;
}

if ((bytesRead = scope_read(fd, buf, blen)) <= 0) {
DBG(NULL);
goto out;
}

// Replace all but the last null with spaces
for (i=0; i < (bytesRead - 1); i++) {
if (buf[i] == '\0') argc++;
}

out:
if (fd != -1) scope_close(fd);
return argc;
}

bool
osTimerStop(void)
{
Expand Down
1 change: 1 addition & 0 deletions os/linux/os.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,6 @@ extern void osCreateSM(proc_id_t *, unsigned long);
extern bool osMemPermAllow(void *, size_t, int, int);
extern bool osMemPermRestore(void *, size_t, int);
extern bool osGetBaseAddr(uint64_t *);
extern int osGetArgv(pid_t, char *, size_t);

#endif //__OS_H__
1 change: 1 addition & 0 deletions src/dbg.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ bool g_ismusl = FALSE;
bool g_isstatic = FALSE;
bool g_isgo = FALSE;
bool g_issighandler = FALSE;
char g_libpath[PATH_MAX] = {};

void
dbgInit()
Expand Down
1 change: 1 addition & 0 deletions src/dbg.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ extern bool g_ismusl;
extern bool g_isstatic;
extern bool g_isgo;
extern bool g_issighandler;
extern char g_libpath[];

void scopeLog(cfg_log_level_t, const char *, ...) PRINTF_FORMAT(2,3);
void scopeLogHex(cfg_log_level_t, const void *, size_t, const char *, ...) PRINTF_FORMAT(4,5);
Expand Down
50 changes: 50 additions & 0 deletions src/scopeelf.c
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,56 @@ getElfEntries(struct link_map *lm, Elf64_Rela **rel, Elf64_Sym **sym, char **str
return 0;
}

void *
getDynSymbol(const char *buf, char *sname)
{
int i, nsyms = 0;
Elf64_Addr symaddr = 0;
Elf64_Ehdr *ehdr;
Elf64_Shdr *sections;
Elf64_Sym *symtab = NULL;
const char *section_strtab = NULL;
const char *strtab = NULL;
const char *sec_name = NULL;

if (!buf || !sname) return NULL;

ehdr = (Elf64_Ehdr *)buf;
sections = (Elf64_Shdr *)((char *)buf + ehdr->e_shoff);
section_strtab = (char *)buf + sections[ehdr->e_shstrndx].sh_offset;

for (i = 0; i < ehdr->e_shnum; i++) {
sec_name = section_strtab + sections[i].sh_name;

if (sections[i].sh_type == SHT_DYNSYM) {
symtab = (Elf64_Sym *)((char *)buf + sections[i].sh_offset);
nsyms = sections[i].sh_size / sections[i].sh_entsize;
} else if (sections[i].sh_type == SHT_STRTAB && scope_strcmp(sec_name, ".dynstr") == 0) {
strtab = (const char *)(buf + sections[i].sh_offset);
}

if ((strtab != NULL) && (symtab != NULL)) break;
scopeLogDebug("section %s type = %d flags = 0x%lx addr = 0x%lx-0x%lx, size = 0x%lx off = 0x%lx\n",
sec_name,
sections[i].sh_type,
sections[i].sh_flags,
sections[i].sh_addr,
sections[i].sh_addr + sections[i].sh_size,
sections[i].sh_size,
sections[i].sh_offset);
}

for (i=0; i < nsyms; i++) {
if (scope_strcmp(sname, strtab + symtab[i].st_name) == 0) {
symaddr = symtab[i].st_value;
sysprint("symbol found %s = 0x%08lx\n", strtab + symtab[i].st_name, symtab[i].st_value);
break;
}
}

return (void *)symaddr;
}

void *
getSymbol(const char *buf, char *sname)
{
Expand Down
1 change: 1 addition & 0 deletions src/scopeelf.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ int doGotcha(struct link_map *, got_list_t *, Elf64_Rela *, Elf64_Sym *, char *,
int getElfEntries(struct link_map *, Elf64_Rela **, Elf64_Sym **, char **, int *rsz);
Elf64_Shdr* getElfSection(char *, const char *);
void * getSymbol(const char *, char *);
void * getDynSymbol(const char *, char *);
bool is_static(char *);
bool is_go(char *);
bool is_musl(char *);
Expand Down
2 changes: 2 additions & 0 deletions src/scopetypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ typedef enum {CFG_MTC_FS,
#define SM_NAME "scope_anon"
#define SCOPE_FILTER_USR_PATH ("/usr/lib/appscope/scope_filter")
#define SCOPE_FILTER_TMP_PATH ("/tmp/appscope/scope_filter")
#define SCOPE_SYS_PATH "/usr/lib/appscope/"
#define SCOPE_TMP_PATH "/tmp/appscope/"

typedef unsigned int bool;
#define TRUE 1
Expand Down
23 changes: 0 additions & 23 deletions src/sysexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
#include "state.h"
#include "gocontext.h"

#define SYSPRINT_CONSOLE 0
#define PRINT_BUF_SIZE 1024
#define HEAP_SIZE (size_t)(500 * 1024)
// 1Mb + an 8kb guard
#define STACK_SIZE (size_t)(1024 * 1024) + (8 * 1024)
Expand All @@ -40,27 +38,6 @@

#define EXPORTON __attribute__((visibility("default")))

void
sysprint(const char* fmt, ...)
{
// Create the string
char str[PRINT_BUF_SIZE];

if (fmt) {
va_list args;
va_start(args, fmt);
int rv = scope_vsnprintf(str, PRINT_BUF_SIZE, fmt, args);
va_end(args);
if (rv == -1) return;
}

// Output the string
#if SYSPRINT_CONSOLE > 0
scope_printf("%s", str);
#endif
scopeLog(CFG_LOG_DEBUG, "%s", str);
}

static int
get_file_size(const char *path)
{
Expand Down
32 changes: 1 addition & 31 deletions src/transport.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "fn.h"
#include "utils.h"
#include "transport.h"
#include "utils.h"

// Yuck. Avoids naming conflict between our src/wrap.c and libssl.a
#define SSL_read SCOPE_SSL_read
Expand Down Expand Up @@ -1019,37 +1020,6 @@ transportConnectFile(transport_t *t)
return 1;
}

#define EDGE_PATH_DOCKER "/var/run/appscope/appscope.sock"
#define EDGE_PATH_DEFAULT "/opt/cribl/state/appscope.sock"
#define READ_AND_WRITE (R_OK|W_OK)
static char*
edgePath(void){
// 1) If EDGE_PATH_DOCKER can be accessed, return that.
if (scope_access(EDGE_PATH_DOCKER, READ_AND_WRITE) == 0) {
return scope_strdup(EDGE_PATH_DOCKER);
}

// 2) If CRIBL_HOME is defined and can be accessed,
// return $CRIBL_HOME/state/appscope.sock
const char *cribl_home = fullGetEnv("CRIBL_HOME");
if (cribl_home) {
char *new_path = NULL;
if (scope_asprintf(&new_path, "%s/%s", cribl_home, "state/appscope.sock") > 0) {
if (scope_access(new_path, READ_AND_WRITE) == 0) {
return new_path;
}
scope_free(new_path);
}
}

// 3) If EDGE_PATH_DEFAULT can be accessed, return it
if (scope_access(EDGE_PATH_DEFAULT, READ_AND_WRITE) == 0) {
return scope_strdup(EDGE_PATH_DEFAULT);
}

return NULL;
}

int
transportConnect(transport_t *trans)
{
Expand Down
Loading