Compare commits

...
12 Commits
Author SHA1 Message Date
Patrick McCarty 251b7cfe3b Release v52
- Enable Github Actions for CI test execution.

- Allow runtime configuration of debuginfo URLs by setting the
  CLR_DEBUGINFO_URLS environment variable for the clr_debug_daemon
  service.

- Make the daemon socket path and cache directory configurable at build
  time via the `--with-socket-path` and `--with-cache-dir` options,
  respectively. The default values for those two settings are unchanged.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2021-03-16 01:46:23 +00:00
Josue David Hernandez Gutierrez 97d255f115 Add --with-socket-path=... and --with-cache-dir=... to configure
Signed-off-by: Josue David Hernandez Gutierrez <josue.d.hernandez.gutierrez@intel.com>
2020-01-30 14:11:54 -08:00
Josue David Hernandez Gutierrez 1a36c33e6e Waiting for fuse in testing_fuse test
Signed-off-by: Josue David Hernandez Gutierrez <josue.d.hernandez.gutierrez@intel.com>
2020-01-30 13:35:24 -08:00
Josue David Hernandez Gutierrez b8568a3959 Creating testing binary to test basic behoviour of fuse and daemon binaries
- creating a fake socket check if fuse is sending the request properly to
  the socket service.
- make a request to the server socket while clr_debug_daemon is running
to check that it is responding propertly and also that it is creating cache files
- change makefile.am to compile binaries without add them to the installation process

Signed-off-by: Josue David Hernandez Gutierrez <josue.d.hernandez.gutierrez@intel.com>
2020-01-29 11:51:14 -08:00
Patrick McCarty 0cc9c4bbf1 Fix up remaining clang-format style issues
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2020-01-21 15:52:13 -08:00
Tan, Yew Wayne da1a6d63ee Enforce clang-format code style 2020-01-21 15:51:12 -08:00
Tan, Yew Wayne 6144b981d4 Replace all tab indents with space indents 2020-01-21 15:51:12 -08:00
Tan, Yew Wayne 5babb4f44f Free configured urls on server exit 2020-01-21 15:51:12 -08:00
Tan, Yew Wayne aa87b16a54 Document CLR_DEBUGINFO_URLS in drop-in config 2020-01-21 15:51:12 -08:00
Tan, Yew Wayne 91c27b1d2e Configure URLs at runtime from environment variable 2020-01-21 15:51:12 -08:00
Josue David Hernandez Gutierrez e6cbc69e1b Add metadata to follow the same tab setup on emacs or vim
Signed-off-by: Josue David Hernandez Gutierrez <josue.d.hernandez.gutierrez@intel.com>
2019-12-09 15:16:27 -08:00
Auke Kok b1c8be24a2 Add github actions. 2019-11-14 10:27:35 -08:00
12 changed files with 462 additions and 19 deletions
+19
View File
@@ -0,0 +1,19 @@
name: C/C++ CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: install dependencies
run: sudo apt-get install libsystemd-dev libcurl4-openssl-dev libfuse-dev
- name: autogen
run: sh autogen.sh
- name: make
run: make
- name: make distcheck
run: make distcheck
+10
View File
@@ -2,6 +2,9 @@
*.o *.o
clr_debug_fuse clr_debug_fuse
clr_debug_daemon clr_debug_daemon
test-driver
testing_fuse
testing_daemon
.deps/ .deps/
.dirstamp .dirstamp
Makefile Makefile
@@ -29,3 +32,10 @@ config.guess
config.sub config.sub
libtool libtool
ltmain.sh ltmain.sh
test-suite.log
testing_fuse.log
testing_fuse.trs
testing_daemon.log
testing_daemon.trs
clr_debug_daemon.socket
debuginfo.conf
+9
View File
@@ -45,3 +45,12 @@ clr_debug_daemon_LDADD = ${curl_LIBS} libnica.la ${LIBSYSTEMD_LIBS}
systemdsystemunit_DATA = clr_debug_fuse.service clr_debug_daemon.service clr_debug_daemon.socket systemdsystemunit_DATA = clr_debug_fuse.service clr_debug_daemon.service clr_debug_daemon.socket
tmpfiles_DATA = debuginfo.conf tmpfiles_DATA = debuginfo.conf
# Functional Testing
noinst_PROGRAMS = testing_fuse testing_daemon
testing_fuse_SOURCES = tests/testing_fuse.c
testing_fuse_CFLAGS = $(AM_CFLAGS)
testing_daemon_SOURCES = tests/testing_daemon.c
testing_daemon_CFLAGS = $(AM_CFLAGS)
@@ -2,7 +2,7 @@
Description=Clear Linux OS debuginfo daemon Description=Clear Linux OS debuginfo daemon
[Socket] [Socket]
ListenStream=/run/clr-debug-info ListenStream=@SOCKET_PATH@
SocketMode=0600 SocketMode=0600
[Install] [Install]
+21 -3
View File
@@ -2,21 +2,21 @@
# Process this file with autoconf to produce a configure script. # Process this file with autoconf to produce a configure script.
AC_PREREQ([2.66]) AC_PREREQ([2.66])
AC_INIT(clr-debug-info, 51, arjan@linux.intel.com) AC_INIT(clr-debug-info, 52, arjan@linux.intel.com)
AM_INIT_AUTOMAKE([foreign -Wall -W subdir-objects]) AM_INIT_AUTOMAKE([foreign -Wall -W subdir-objects])
AM_SILENT_RULES([yes]) AM_SILENT_RULES([yes])
AC_PROG_CC AC_PROG_CC
AM_PROG_AR AM_PROG_AR
AC_LANG(C) AC_LANG(C)
AC_CONFIG_HEADERS([config.h]) AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([clr_debug_daemon.socket])
AC_CONFIG_FILES([debuginfo.conf])
PKG_CHECK_MODULES([curl], [libcurl]) PKG_CHECK_MODULES([curl], [libcurl])
PKG_CHECK_MODULES([fuse], [fuse]) PKG_CHECK_MODULES([fuse], [fuse])
PKG_CHECK_MODULES([SYSTEMD], [systemd]) PKG_CHECK_MODULES([SYSTEMD], [systemd])
PKG_CHECK_MODULES([LIBSYSTEMD], [libsystemd]) PKG_CHECK_MODULES([LIBSYSTEMD], [libsystemd])
LT_INIT LT_INIT
AC_DEFINE([SOCKET_PATH], ["/run/clr-debug-info"], [path to communication socket])
dir="" dir=""
AC_ARG_WITH([systemdsystemunitdir], AS_HELP_STRING([--with-systemdsystemunitdir=DIR], AC_ARG_WITH([systemdsystemunitdir], AS_HELP_STRING([--with-systemdsystemunitdir=DIR],
[path to systemd system service dir @<:@default=/usr/lib/systemd/system@:>@]), [dir=${withval}], [path to systemd system service dir @<:@default=/usr/lib/systemd/system@:>@]), [dir=${withval}],
@@ -38,6 +38,22 @@ else
AC_MSG_WARN([C11 stdatomic support unavailable. Falling back to slow mutex]) AC_MSG_WARN([C11 stdatomic support unavailable. Falling back to slow mutex])
fi fi
SOCKET_PATH=""
AC_ARG_WITH([socket-path], AS_HELP_STRING([--with-socket-path=SOCKET_PATH],
[path to create unix socket @<:@default=/run/clr-debug-info@:>@]), [SOCKET_PATH=${withval}],
[SOCKET_PATH="/run/clr-debug-info"])
test -z "${SOCKET_PATH}" && SOCKET_PATH=/run/clr-debug-info
AC_DEFINE_UNQUOTED([SOCKET_PATH], ["${SOCKET_PATH}"], [path to create unix socket @<:@default=/run/clr-debug-info@:>@])
AC_SUBST(SOCKET_PATH, [${SOCKET_PATH}])
CACHE_DIR=""
AC_ARG_WITH([cache-dir], AS_HELP_STRING([--with-cache-dir=CACHE_DIR],
[path to cache downloaded content @<:@default=/var/cache/debuginfo@:>@]), [CACHE_DIR="${withval}"],
[CACHE_DIR="/var/cache/debuginfo"])
test -z "${CACHE_DIR}" && CACHE_DIR=/var/cache/debuginfo
AC_DEFINE_UNQUOTED([CACHE_DIR], ["${CACHE_DIR}"], [path to cache downloaded content @<:@default=/var/cache/debuginfo@:>@])
AC_SUBST(CACHE_DIR, [${CACHE_DIR}])
AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([Makefile])
AC_OUTPUT AC_OUTPUT
@@ -57,6 +73,8 @@ AC_MSG_RESULT([
systemd-unit-dir: ${systemdsystemunitdir} systemd-unit-dir: ${systemdsystemunitdir}
tmpfiles.d: ${tmpfilesdir} tmpfiles.d: ${tmpfilesdir}
socket_dir: ${SOCKET_PATH}
cache_dir: ${CACHE_DIR}
C11 stdatomic support: ${have_atomics} C11 stdatomic support: ${have_atomics}
]) ])
+2 -2
View File
@@ -10,5 +10,5 @@
# Clear tmp directories separately, to make them easier to override # Clear tmp directories separately, to make them easier to override
# Unfortunatly tmpfiles doesn't change the ownership for things if they # Unfortunatly tmpfiles doesn't change the ownership for things if they
# are not listed. # are not listed.
d /var/cache/debuginfo/lib 755 dbginfo dbginfo 10d d @CACHE_DIR@/lib 755 dbginfo dbginfo 10d
d /var/cache/debuginfo/src 755 dbginfo dbginfo 1d d @CACHE_DIR@/src 755 dbginfo dbginfo 1d
+3
View File
@@ -0,0 +1,3 @@
[Service]
# Uncomment to use custom URLs, space separated
#Environment="CLR_DEBUGINFO_URLS=https://cdn-alt.download.clearlinux.org/debuginfo/ https://cdn.download.clearlinux.org/debuginfo/"
+13
View File
@@ -121,3 +121,16 @@ void try_to_get(const char *path, int pid, time_t timestamp)
close(sockfd); close(sockfd);
} }
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 8
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* vi: set shiftwidth=8 tabstop=8 expandtab:
* :indentSize=8:tabSize=8:noTabs=true:
*/
+16 -3
View File
@@ -636,8 +636,8 @@ int main(__nc_unused__ int argc, __nc_unused__ char *argv[])
{ {
char *fake_argv[20]; char *fake_argv[20];
char *dir = "/usr/src/debug"; char *dir = "/usr/src/debug";
char *shadowdir = "/var/cache/debuginfo/src"; char *shadowdir = CACHE_DIR "/src";
const char *required_paths[] = { "/var/cache/debuginfo/lib", "/var/cache/debuginfo/src" }; const char *required_paths[] = { CACHE_DIR "/lib", CACHE_DIR "/src" };
umask(0); umask(0);
@@ -663,7 +663,7 @@ int main(__nc_unused__ int argc, __nc_unused__ char *argv[])
if (fork() == 0) { if (fork() == 0) {
dir = "/usr/lib/debug"; dir = "/usr/lib/debug";
shadowdir = "/var/cache/debuginfo/lib"; shadowdir = CACHE_DIR "/lib";
prefix = "lib"; prefix = "lib";
} }
@@ -681,3 +681,16 @@ int main(__nc_unused__ int argc, __nc_unused__ char *argv[])
return fuse_main(9, fake_argv, &xmp_oper, NULL); return fuse_main(9, fake_argv, &xmp_oper, NULL);
} }
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 8
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* vi: set shiftwidth=8 tabstop=8 expandtab:
* :indentSize=8:tabSize=8:noTabs=true:
*/
+93 -10
View File
@@ -28,11 +28,11 @@
#include <errno.h> #include <errno.h>
#include <grp.h> #include <grp.h>
#include <libgen.h>
#include <linux/capability.h> #include <linux/capability.h>
#include <malloc.h> #include <malloc.h>
#include <pthread.h> #include <pthread.h>
#include <pwd.h> #include <pwd.h>
#include <libgen.h>
#include <signal.h> #include <signal.h>
#include <stddef.h> #include <stddef.h>
#include <stdio.h> #include <stdio.h>
@@ -62,9 +62,11 @@
static pthread_mutex_t dupes_mutex = PTHREAD_MUTEX_INITIALIZER; static pthread_mutex_t dupes_mutex = PTHREAD_MUTEX_INITIALIZER;
char *urls[2] = { "https://cdn.download.clearlinux.org/debuginfo/", char *urls_default[] = { "https://cdn.download.clearlinux.org/debuginfo/",
"https://cdn-alt.download.clearlinux.org/debuginfo/" }; "https://cdn-alt.download.clearlinux.org/debuginfo/" };
int urls_size = 2;
int urlcounter = 1; int urlcounter = 1;
char **urls = urls_default;
static NcHashmap *hash = NULL; static NcHashmap *hash = NULL;
@@ -97,6 +99,60 @@ static int avoid_dupes(const char *url)
return retval; return retval;
} }
/*
* Read URLs from environment variable, space separated
*/
int configure_urls(void)
{
const char *env_var = getenv("CLR_DEBUGINFO_URLS");
const char *token = env_var;
int count = 0;
char **urls_new = NULL;
if (env_var) {
while (1) {
int token_len = strcspn(token, " \t\n");
if (token_len) {
count++;
urls_new = realloc(urls_new, count * sizeof(char *));
if (!urls_new) {
perror("realloc()");
exit(EXIT_FAILURE);
}
char *url = calloc(token_len + 1, sizeof(char));
if (!url) {
perror("calloc()");
exit(EXIT_FAILURE);
}
urls_new[count - 1] = strncpy(url, token, token_len);
token += token_len;
}
if (*token == '\0') {
break;
}
token++;
}
}
if (count) {
// Abandon defaults
urls = urls_new;
urls_size = count;
urlcounter = 0;
}
return count;
}
void free_urls(void)
{
if (urls != urls_default) {
for (int i = 0; i < urls_size; i++) {
free(urls[i]);
}
free(urls);
}
}
#ifdef HAVE_ATOMIC_SUPPORT #ifdef HAVE_ATOMIC_SUPPORT
static atomic_int current_connection_count = 0; static atomic_int current_connection_count = 0;
@@ -265,8 +321,10 @@ static int curl_get_file(const char *url, const char *prefix, time_t timestamp)
} }
/* test extraction first */ /* test extraction first */
if (asprintf(&command, "tar -C /var/cache/debuginfo/%s --no-same-owner " if (asprintf(&command,
"tar -C %s/%s --no-same-owner "
"--no-same-permissions -tf %s", "--no-same-permissions -tf %s",
CACHE_DIR,
prefix, prefix,
filename) < 0) { filename) < 0) {
ret = 418; ret = 418;
@@ -280,8 +338,10 @@ static int curl_get_file(const char *url, const char *prefix, time_t timestamp)
} }
free(command); /* reuse */ free(command); /* reuse */
if (asprintf(&command, "tar -C /var/cache/debuginfo/%s --no-same-owner " if (asprintf(&command,
"tar -C %s/%s --no-same-owner "
"--no-same-permissions -xf %s", "--no-same-permissions -xf %s",
CACHE_DIR,
prefix, prefix,
filename) < 0) { filename) < 0) {
ret = 418; ret = 418;
@@ -365,7 +425,7 @@ static void *server_thread(void *arg)
goto thread_end; goto thread_end;
} }
url = NULL; url = NULL;
if (asprintf(&url, "%s%s%s.tar", urls[urlcounter % 2], prefix, path) < 0) { if (asprintf(&url, "%s%s%s.tar", urls[urlcounter % urls_size], prefix, path) < 0) {
goto thread_end; goto thread_end;
} }
@@ -414,7 +474,16 @@ int main(__nc_unused__ int argc, __nc_unused__ char **argv)
uid_t dbg_user = 0; uid_t dbg_user = 0;
gid_t dbg_group = 0; gid_t dbg_group = 0;
struct passwd *passwdentry; struct passwd *passwdentry;
const char *required_paths[] = { "/var/cache/debuginfo/lib", "/var/cache/debuginfo/src" }; const char *required_paths[] = { CACHE_DIR "/lib", CACHE_DIR "/src" };
if (configure_urls()) {
fprintf(stderr, "Using urls from environment\n");
} else {
fprintf(stderr, "Using compiled default urls\n");
}
for (int i = 0; i < urls_size; i++) {
fprintf(stderr, "url: %s\n", urls[i]);
}
umask(0); umask(0);
passwdentry = getpwnam("dbginfo"); passwdentry = getpwnam("dbginfo");
@@ -478,8 +547,8 @@ int main(__nc_unused__ int argc, __nc_unused__ char **argv)
strcpy(sun.sun_path, SOCKET_PATH); strcpy(sun.sun_path, SOCKET_PATH);
ret = bind(sockfd, ret = bind(sockfd,
(struct sockaddr *)&sun, (struct sockaddr *)&sun,
offsetof(struct sockaddr_un, sun_path) + strlen(SOCKET_PATH) + 1); offsetof(struct sockaddr_un, sun_path) + strlen(SOCKET_PATH) + 1);
if (ret < 0) { if (ret < 0) {
fprintf(stderr, "Failed to bind:%s \n", strerror(errno)); fprintf(stderr, "Failed to bind:%s \n", strerror(errno));
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
@@ -526,7 +595,6 @@ int main(__nc_unused__ int argc, __nc_unused__ char **argv)
break; break;
} }
clientsock = accept(sockfd, NULL, NULL); clientsock = accept(sockfd, NULL, NULL);
/* Too many connections, wait for the next loop/retry */ /* Too many connections, wait for the next loop/retry */
@@ -551,4 +619,19 @@ int main(__nc_unused__ int argc, __nc_unused__ char **argv)
if (hash) { if (hash) {
nc_hashmap_free(hash); nc_hashmap_free(hash);
} }
free_urls();
} }
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 8
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* vi: set shiftwidth=8 tabstop=8 expandtab:
* :indentSize=8:tabSize=8:noTabs=true:
*/
+104
View File
@@ -0,0 +1,104 @@
#define _GNU_SOURCE
#include <stdio.h>
#include <string.h>
#include <stddef.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <signal.h>
#include <unistd.h>
#include <errno.h>
#include "config.h"
#define BUFFER_LENGTH 16
int get_server_socket(void)
{
int sockfd;
struct sockaddr_un serveraddr;
fputs("Creating socket\n", stderr);
sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
if (sockfd < 0) {
fputs("Fail creating socket\n", stderr);
return -1;
}
memset(&serveraddr, 0, sizeof(serveraddr));
serveraddr.sun_family = AF_UNIX;
strcpy(serveraddr.sun_path, SOCKET_PATH);
fputs("Connecting to server\n", stderr);
if (connect(sockfd, (struct sockaddr*)&serveraddr,
offsetof(struct sockaddr_un, sun_path) + strlen(SOCKET_PATH) + 1) < 0) {
fprintf(stderr, "Fail connecting to server: %s\n", strerror(errno));
close(sockfd);
return -1;
}
return sockfd;
}
int testing_daemon(void)
{
int sockfd;
char buffer[BUFFER_LENGTH];
if((sockfd = get_server_socket()) < 0) {
return -1;
}
fputs("Sending message to server\n", stderr);
memset(buffer, 0, sizeof(buffer));
strcpy(buffer, "0:lib:/lib");
if(send(sockfd, buffer, sizeof(buffer), 0) < 0) {
fputs("Fail sending message to socket service\n", stderr);
close(sockfd);
return -1;
}
fputs("Receiving message from server\n", stderr);
memset(buffer, 0, sizeof(buffer));
if (recv(sockfd, &buffer[0],
BUFFER_LENGTH, 0) < 0) {
fputs("Failing receiving message from socket service\n", stderr);
close(sockfd);
return -1;
}
close(sockfd);
return strcmp(buffer, "ok") && access(CACHE_DIR "/lib/lib", F_OK) != -1;
}
int main(void)
{
int res = 0;
pid_t p;
p = fork();
if (p == 0) {
if (freopen("/dev/null", "w", stderr) == NULL)
return -1;
char *args[] = {"./clr_debug_daemon", NULL};
execvp("./clr_debug_daemon", args);
} else if (p > 0) {
sleep(1);
res = testing_daemon();
kill(p, SIGKILL);
} else {
fputs("error executing fork\n", stderr);
}
unlink(SOCKET_PATH);
return res;
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 8
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* vi: set shiftwidth=8 tabstop=8 expandtab:
* :indentSize=8:tabSize=8:noTabs=true:
*/
+171
View File
@@ -0,0 +1,171 @@
#define _GNU_SOURCE
#include <errno.h>
#include <grp.h>
#include <linux/capability.h>
#include <linux/limits.h>
#include <malloc.h>
#include <pwd.h>
#include <signal.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/prctl.h>
#include <sys/socket.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/un.h>
#include <sys/wait.h>
#include <unistd.h>
#include <fcntl.h>
#include "config.h"
#define TIMEOUT 600
#define MAX_CONNECTIONS 16
int check_file_request(int fd, char *expected_str)
{
char buf[PATH_MAX + 8];
int clientsock;
malloc_trim(0);
fputs("Accepting connection\n", stderr);
clientsock = accept(fd, NULL, NULL);
if (clientsock < 0)
return -1;
memset(buf, 0, sizeof(buf));
fputs("Reading socket content\n", stderr);
if (read(clientsock, buf, PATH_MAX + 8) < 0)
return -1;
close(clientsock);
return strncmp(buf, expected_str, strlen(expected_str));
}
int get_service_socket(void)
{
int sockfd;
struct sockaddr_un sun;
signal(SIGPIPE, SIG_IGN);
fputs("Creating socket\n", stderr);
sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
if (sockfd < 0) {
fputs("Fail creating socket\n", stderr);
return -1;
}
printf("Socket path %s\n", SOCKET_PATH);
sun.sun_family = AF_UNIX;
strcpy(sun.sun_path, SOCKET_PATH);
fputs("Binding socket\n", stderr);
if (bind(sockfd, (struct sockaddr*)&sun,
offsetof(struct sockaddr_un, sun_path) + strlen(SOCKET_PATH) + 1) < 0) {
fprintf(stderr, "fail bind: %s\n", strerror(errno));
close(sockfd);
return -1;
}
if (listen(sockfd, 16) < 0) {
fputs("Fail listening socket \n", stderr);
close(sockfd);
return -1;
}
return sockfd;
}
int testing_fuse(void)
{
int sockfd;
uid_t gdb_user = 0;
gid_t gdb_group = 0;
struct passwd *passwdentry;
pid_t p2;
int test_result = -1;
umask(0);
passwdentry = getpwnam("gdbinfo");
if (passwdentry) {
gdb_user = passwdentry->pw_uid;
gdb_group = passwdentry->pw_gid;
}
endpwent();
if (prctl(PR_SET_DUMPABLE, 0) != 0) {
fputs("fail prctl\n", stderr);
}
if (geteuid() == 0) {
if (prctl(PR_CAPBSET_DROP, CAP_SYS_ADMIN) !=0) {
fprintf(stderr, "fail geteuid: %s\n", strerror(errno));
}
}
if ((sockfd = get_service_socket()) < 0) {
return 1;
}
if (setgid(gdb_group)) {
fputs("fail setgid\n", stderr);
}
if (setgroups(1, &gdb_group)) {
fputs("fail setgroups\n", stderr);
}
if (setuid(gdb_user)) {
fputs("fail setuid\n", stderr);
}
p2 = fork();
if (p2 > 0) {
test_result = check_file_request(sockfd, "0:lib:/tmp");
} else if (p2 == 0) {
if (freopen("/dev/null", "w", stderr) == NULL)
exit(1);
char *args[] = {"/usr/bin/cat", "/usr/lib/debug/tmp", NULL};
execvp("/usr/bin/cat", args);
} else {
fputs("error executing fork\n", stderr);
return 1;
}
wait(NULL);
close(sockfd);
return test_result;
}
int main(void)
{
int res = 0;
pid_t p;
p = fork();
if (p == 0) {
if (freopen("/dev/null", "w", stderr) == NULL)
return -1;
char *args[] = {"./clr_debug_fuse", NULL};
execvp("./clr_debug_fuse", args);
} else if (p > 0) {
sleep(1);
res = testing_fuse();
kill(p, SIGKILL);
} else {
fputs("error executing fork\n", stderr);
return 1;
}
unlink(SOCKET_PATH);
return res;
}
/*
* Editor modelines - https://www.wireshark.org/tools/modelines.html
*
* Local variables:
* c-basic-offset: 8
* tab-width: 8
* indent-tabs-mode: nil
* End:
*
* vi: set shiftwidth=8 tabstop=8 expandtab:
* :indentSize=8:tabSize=8:noTabs=true:
*/