Skip to content
This repository was archived by the owner on Jan 6, 2023. It is now read-only.

Commit 97d255f

Browse files
josuedhgphmccarty
authored andcommitted
Add --with-socket-path=... and --with-cache-dir=... to configure
Signed-off-by: Josue David Hernandez Gutierrez <josue.d.hernandez.gutierrez@intel.com>
1 parent 1a36c33 commit 97d255f

7 files changed

Lines changed: 35 additions & 13 deletions

File tree

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,6 @@ test-suite.log
3636
testing_fuse.log
3737
testing_fuse.trs
3838
testing_daemon.log
39-
testing_daemon.trs
39+
testing_daemon.trs
40+
clr_debug_daemon.socket
41+
debuginfo.conf
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
Description=Clear Linux OS debuginfo daemon
33

44
[Socket]
5-
ListenStream=/run/clr-debug-info
5+
ListenStream=@SOCKET_PATH@
66
SocketMode=0600
77

88
[Install]

configure.ac

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ AC_PROG_CC
99
AM_PROG_AR
1010
AC_LANG(C)
1111
AC_CONFIG_HEADERS([config.h])
12+
AC_CONFIG_FILES([clr_debug_daemon.socket])
13+
AC_CONFIG_FILES([debuginfo.conf])
1214
PKG_CHECK_MODULES([curl], [libcurl])
1315
PKG_CHECK_MODULES([fuse], [fuse])
1416
PKG_CHECK_MODULES([SYSTEMD], [systemd])
1517
PKG_CHECK_MODULES([LIBSYSTEMD], [libsystemd])
1618
LT_INIT
1719

18-
AC_DEFINE([SOCKET_PATH], ["/run/clr-debug-info"], [path to communication socket])
19-
2020
dir=""
2121
AC_ARG_WITH([systemdsystemunitdir], AS_HELP_STRING([--with-systemdsystemunitdir=DIR],
2222
[path to systemd system service dir @<:@default=/usr/lib/systemd/system@:>@]), [dir=${withval}],
@@ -38,6 +38,22 @@ else
3838
AC_MSG_WARN([C11 stdatomic support unavailable. Falling back to slow mutex])
3939
fi
4040

41+
SOCKET_PATH=""
42+
AC_ARG_WITH([socket-path], AS_HELP_STRING([--with-socket-path=SOCKET_PATH],
43+
[path to create unix socket @<:@default=/run/clr-debug-info@:>@]), [SOCKET_PATH=${withval}],
44+
[SOCKET_PATH="/run/clr-debug-info"])
45+
test -z "${SOCKET_PATH}" && SOCKET_PATH=/run/clr-debug-info
46+
AC_DEFINE_UNQUOTED([SOCKET_PATH], ["${SOCKET_PATH}"], [path to create unix socket @<:@default=/run/clr-debug-info@:>@])
47+
AC_SUBST(SOCKET_PATH, [${SOCKET_PATH}])
48+
49+
CACHE_DIR=""
50+
AC_ARG_WITH([cache-dir], AS_HELP_STRING([--with-cache-dir=CACHE_DIR],
51+
[path to cache downloaded content @<:@default=/var/cache/debuginfo@:>@]), [CACHE_DIR="${withval}"],
52+
[CACHE_DIR="/var/cache/debuginfo"])
53+
test -z "${CACHE_DIR}" && CACHE_DIR=/var/cache/debuginfo
54+
AC_DEFINE_UNQUOTED([CACHE_DIR], ["${CACHE_DIR}"], [path to cache downloaded content @<:@default=/var/cache/debuginfo@:>@])
55+
AC_SUBST(CACHE_DIR, [${CACHE_DIR}])
56+
4157
AC_CONFIG_FILES([Makefile])
4258
AC_OUTPUT
4359

@@ -57,6 +73,8 @@ AC_MSG_RESULT([
5773
5874
systemd-unit-dir: ${systemdsystemunitdir}
5975
tmpfiles.d: ${tmpfilesdir}
76+
socket_dir: ${SOCKET_PATH}
77+
cache_dir: ${CACHE_DIR}
6078
6179
C11 stdatomic support: ${have_atomics}
6280
])

debuginfo.conf renamed to debuginfo.conf.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
# Clear tmp directories separately, to make them easier to override
1111
# Unfortunatly tmpfiles doesn't change the ownership for things if they
1212
# are not listed.
13-
d /var/cache/debuginfo/lib 755 dbginfo dbginfo 10d
14-
d /var/cache/debuginfo/src 755 dbginfo dbginfo 1d
13+
d @CACHE_DIR@/lib 755 dbginfo dbginfo 10d
14+
d @CACHE_DIR@/src 755 dbginfo dbginfo 1d

src/fuse.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -636,8 +636,8 @@ int main(__nc_unused__ int argc, __nc_unused__ char *argv[])
636636
{
637637
char *fake_argv[20];
638638
char *dir = "/usr/src/debug";
639-
char *shadowdir = "/var/cache/debuginfo/src";
640-
const char *required_paths[] = { "/var/cache/debuginfo/lib", "/var/cache/debuginfo/src" };
639+
char *shadowdir = CACHE_DIR "/src";
640+
const char *required_paths[] = { CACHE_DIR "/lib", CACHE_DIR "/src" };
641641

642642
umask(0);
643643

@@ -663,7 +663,7 @@ int main(__nc_unused__ int argc, __nc_unused__ char *argv[])
663663

664664
if (fork() == 0) {
665665
dir = "/usr/lib/debug";
666-
shadowdir = "/var/cache/debuginfo/lib";
666+
shadowdir = CACHE_DIR "/lib";
667667
prefix = "lib";
668668
}
669669

src/server.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,9 @@ static int curl_get_file(const char *url, const char *prefix, time_t timestamp)
322322

323323
/* test extraction first */
324324
if (asprintf(&command,
325-
"tar -C /var/cache/debuginfo/%s --no-same-owner "
325+
"tar -C %s/%s --no-same-owner "
326326
"--no-same-permissions -tf %s",
327+
CACHE_DIR,
327328
prefix,
328329
filename) < 0) {
329330
ret = 418;
@@ -338,8 +339,9 @@ static int curl_get_file(const char *url, const char *prefix, time_t timestamp)
338339

339340
free(command); /* reuse */
340341
if (asprintf(&command,
341-
"tar -C /var/cache/debuginfo/%s --no-same-owner "
342+
"tar -C %s/%s --no-same-owner "
342343
"--no-same-permissions -xf %s",
344+
CACHE_DIR,
343345
prefix,
344346
filename) < 0) {
345347
ret = 418;
@@ -472,7 +474,7 @@ int main(__nc_unused__ int argc, __nc_unused__ char **argv)
472474
uid_t dbg_user = 0;
473475
gid_t dbg_group = 0;
474476
struct passwd *passwdentry;
475-
const char *required_paths[] = { "/var/cache/debuginfo/lib", "/var/cache/debuginfo/src" };
477+
const char *required_paths[] = { CACHE_DIR "/lib", CACHE_DIR "/src" };
476478

477479
if (configure_urls()) {
478480
fprintf(stderr, "Using urls from environment\n");

tests/testing_daemon.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ int testing_daemon(void)
6767
}
6868

6969
close(sockfd);
70-
return strcmp(buffer, "ok") && access("/var/cache/debuginfo/lib/lib", F_OK) != -1;
70+
return strcmp(buffer, "ok") && access(CACHE_DIR "/lib/lib", F_OK) != -1;
7171
}
7272

7373
int main(void)

0 commit comments

Comments
 (0)