mirror of
https://github.com/clearlinux/clr-debug-info.git
synced 2026-09-06 05:41:43 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6f27d35886 | ||
|
|
286069732b | ||
|
|
15d3176382 | ||
|
|
d33715f6e9 | ||
|
|
a8dbe93c7e | ||
|
|
ac9e0cbefb | ||
|
|
888d469c28 | ||
|
|
e9e16fd560 | ||
|
|
f962d43af2 | ||
|
|
cfacaece11 | ||
|
|
96a1f7cffc | ||
|
|
26c614fbe2 | ||
|
|
7e694a71ab | ||
|
|
c618401317 | ||
|
|
c0321b2872 | ||
|
|
bff72b661b | ||
|
|
4c9b2ee263 | ||
|
|
8cf3382343 | ||
|
|
ccbb7bb31c | ||
|
|
aacde58ece | ||
|
|
a6a25cbfc1 | ||
|
|
a54f328ad7 | ||
|
|
27a9b3923a | ||
|
|
374a17ea95 | ||
|
|
80c2659731 | ||
|
|
6d46f4d404 | ||
|
|
81149b109b | ||
|
|
8d9d392ce5 | ||
|
|
4e8854f491 | ||
|
|
3951a29dcc | ||
|
|
f153d6079a | ||
|
|
95cd32d127 | ||
|
|
5d3868ad29 | ||
|
|
a6952576e6 | ||
|
|
05fd5593e2 | ||
|
|
54918c1c02 | ||
|
|
e715583dc5 | ||
|
|
a3f4a2071c | ||
|
|
7016c88df6 | ||
|
|
c569470df3 | ||
|
|
883a4b0e42 | ||
|
|
a63ceb51b5 | ||
|
|
b16557179c | ||
|
|
4d1ac0e90b | ||
|
|
ff8275f7a1 | ||
|
|
80ae1d110c | ||
|
|
bba42e469e | ||
|
|
13c7727a3a | ||
|
|
4632c932d3 | ||
|
|
7fcebafd08 | ||
|
|
718c01f65b | ||
|
|
584cbb5b4e | ||
|
|
85b8895e15 | ||
|
|
de08f0ebd5 | ||
|
|
b51f835219 | ||
|
|
905e8051b2 | ||
|
|
19652c9c87 | ||
|
|
a524875fd3 | ||
|
|
91efece071 | ||
|
|
37048557ec | ||
|
|
d2192337d0 | ||
|
|
0642cc1835 | ||
|
|
77fc03de73 | ||
|
|
97c6ab80a0 | ||
|
|
aeb73c71d3 | ||
|
|
a64fc31838 | ||
|
|
8d6503ed2f | ||
|
|
6fb3c6f193 | ||
|
|
3124367ce7 | ||
|
|
41e3538eb4 | ||
|
|
b199c54804 | ||
|
|
6009fe08f7 | ||
|
|
2cd799e5ec | ||
|
|
c3701ee088 | ||
|
|
8b995e1a20 | ||
|
|
c4e73a4c9e | ||
|
|
b5ab4c61e8 | ||
|
|
eb6b1b86a3 |
@@ -8,7 +8,6 @@ clr_debug_prepare
|
||||
Makefile
|
||||
Makefile.in
|
||||
aclocal.m4
|
||||
ar-lib
|
||||
autom4te.cache/
|
||||
compile
|
||||
config.h
|
||||
|
||||
+4
-5
@@ -1,4 +1,4 @@
|
||||
EXTRA_DIST = COPYING clr_debug_fuse.service clr_debug_daemon.service clr_debug_daemon.socket debuginfo.conf
|
||||
EXTRA_DIST = COPYING clr_debug_fuse.service clr_debug_daemon.service debuginfo.conf
|
||||
|
||||
DISTCHECK_CONFIGURE_FLAGS = \
|
||||
--with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir) \
|
||||
@@ -33,16 +33,15 @@ clr_debug_fuse_SOURCES = src/fuse.c src/client.c
|
||||
clr_debug_daemon_SOURCES = src/server.c
|
||||
clr_debug_daemon_CFLAGS = \
|
||||
-pthread \
|
||||
$(AM_CFLAGS) \
|
||||
$(LIBSYSTEMD_CFLAGS)
|
||||
$(AM_CFLAGS)
|
||||
|
||||
clr_debug_prepare_SOURCES = src/prepare.c
|
||||
|
||||
|
||||
clr_debug_fuse_LDADD = ${fuse_LIBS} libnica.la
|
||||
clr_debug_daemon_LDADD = ${curl_LIBS} libnica.la ${LIBSYSTEMD_LIBS}
|
||||
clr_debug_daemon_LDADD = ${curl_LIBS} libnica.la
|
||||
clr_debug_prepare_LDADD = libnica.la
|
||||
|
||||
systemdsystemunit_DATA = clr_debug_fuse.service clr_debug_daemon.service clr_debug_daemon.socket
|
||||
systemdsystemunit_DATA = clr_debug_fuse.service clr_debug_daemon.service
|
||||
|
||||
tmpfiles_DATA = debuginfo.conf
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
[Unit]
|
||||
Description=Clear Linux debuginfo daemon
|
||||
DefaultDependencies=no
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/bin/clr_debug_daemon
|
||||
DefaultDependencies=no
|
||||
Nice=10
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
[Unit]
|
||||
Description=Clear Linux OS debuginfo daemon
|
||||
|
||||
[Socket]
|
||||
ListenStream=/run/clr-debug-info
|
||||
SocketMode=0600
|
||||
|
||||
[Install]
|
||||
WantedBy=sockets.target
|
||||
@@ -1,11 +1,12 @@
|
||||
[Unit]
|
||||
Description=Clear Linux debuginfo fuse monitor
|
||||
After=clr_debug_daemon.service
|
||||
DefaultDependencies=no
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
ExecStart=/usr/bin/clr_debug_fuse
|
||||
DefaultDependencies=no
|
||||
Nice=10
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
||||
+1
-3
@@ -2,17 +2,15 @@
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ([2.66])
|
||||
AC_INIT(clr-debug-info, 47, arjan@linux.intel.com)
|
||||
AC_INIT(clr-debug-info, 38, arjan@linux.intel.com)
|
||||
AM_INIT_AUTOMAKE([foreign -Wall -W subdir-objects])
|
||||
AM_SILENT_RULES([yes])
|
||||
AC_PROG_CC
|
||||
AM_PROG_AR
|
||||
AC_LANG(C)
|
||||
AC_CONFIG_HEADERS([config.h])
|
||||
PKG_CHECK_MODULES([curl], [libcurl])
|
||||
PKG_CHECK_MODULES([fuse], [fuse])
|
||||
PKG_CHECK_MODULES([SYSTEMD], [systemd])
|
||||
PKG_CHECK_MODULES([LIBSYSTEMD], [libsystemd])
|
||||
LT_INIT
|
||||
|
||||
dir=""
|
||||
|
||||
+2
-4
@@ -8,7 +8,5 @@
|
||||
# See tmpfiles.d(5) for details
|
||||
|
||||
# Clear tmp directories separately, to make them easier to override
|
||||
# Unfortunatly tmpfiles doesn't change the ownership for things if they
|
||||
# are not listed.
|
||||
d /var/cache/debuginfo/lib 755 dbginfo dbginfo 10d
|
||||
d /var/cache/debuginfo/src 755 dbginfo dbginfo 1d
|
||||
d /var/cache/debuginfo/lib 755 root root 10d
|
||||
d /var/cache/debuginfo/src 755 root root 1d
|
||||
|
||||
+5
-4
@@ -37,8 +37,8 @@
|
||||
#include <unistd.h>
|
||||
|
||||
/* 0.75 seconds timeout */
|
||||
#define TIMEOUT 75000
|
||||
#define TIMEOUT2 1500
|
||||
#define TIMEOUT 750000
|
||||
#define TIMEOUT2 15000
|
||||
#define TIMEOUT3 500
|
||||
|
||||
char *prefix = "src";
|
||||
@@ -66,11 +66,12 @@ void try_to_get(const char *path, int pid, time_t timestamp)
|
||||
}
|
||||
|
||||
sun.sun_family = AF_UNIX;
|
||||
strcpy(sun.sun_path, "/run/clr-debug-info");
|
||||
strcpy(sun.sun_path, ":clr-debug-info");
|
||||
sun.sun_path[0] = 0; /* anonymous unix socket */
|
||||
|
||||
ret = connect(sockfd,
|
||||
(struct sockaddr *)&sun,
|
||||
offsetof(struct sockaddr_un, sun_path) + strlen("/run/clr-debug-info") + 1);
|
||||
offsetof(struct sockaddr_un, sun_path) + strlen(":clr-debug-info") + 1);
|
||||
if (ret < 0) {
|
||||
printf("Cannot connect %s\n", strerror(errno));
|
||||
close(sockfd);
|
||||
|
||||
+20
-85
@@ -27,11 +27,9 @@
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include <errno.h>
|
||||
#include <grp.h>
|
||||
#include <linux/capability.h>
|
||||
#include <malloc.h>
|
||||
#include <pthread.h>
|
||||
#include <pwd.h>
|
||||
#include <signal.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
@@ -49,8 +47,6 @@
|
||||
|
||||
#include <curl/curl.h>
|
||||
|
||||
#include "systemd/sd-daemon.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef HAVE_ATOMIC_SUPPORT
|
||||
@@ -60,7 +56,7 @@
|
||||
static pthread_mutex_t dupes_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
char *urls[2] = { "https://cdn.download.clearlinux.org/debuginfo/",
|
||||
"https://cdn-alt.download.clearlinux.org/debuginfo/" };
|
||||
"https://cdn.download.clearlinux.org/debuginfo/" };
|
||||
int urlcounter = 1;
|
||||
|
||||
static NcHashmap *hash = NULL;
|
||||
@@ -166,7 +162,6 @@ static int curl_get_file(const char *url, const char *prefix, time_t timestamp)
|
||||
{
|
||||
CURLcode code;
|
||||
long ret;
|
||||
long changed;
|
||||
int fd;
|
||||
char filename[PATH_MAX];
|
||||
CURL *curl = NULL;
|
||||
@@ -208,9 +203,6 @@ static int curl_get_file(const char *url, const char *prefix, time_t timestamp)
|
||||
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_TIME, 30);
|
||||
curl_easy_setopt(curl, CURLOPT_LOW_SPEED_LIMIT, 1024);
|
||||
|
||||
/* request timestamp of files from server */
|
||||
curl_easy_setopt(curl, CURLOPT_FILETIME, 1);
|
||||
|
||||
if (timestamp) {
|
||||
curl_easy_setopt(curl, CURLOPT_TIMECONDITION, CURL_TIMECOND_IFMODSINCE);
|
||||
curl_easy_setopt(curl, CURLOPT_TIMEVALUE, timestamp);
|
||||
@@ -238,17 +230,6 @@ static int curl_get_file(const char *url, const char *prefix, time_t timestamp)
|
||||
}
|
||||
|
||||
if (ret == 200) {
|
||||
/* get timestamp, if any */
|
||||
curl_easy_getinfo(curl, CURLINFO_FILETIME, &changed);
|
||||
if (changed >= 0) {
|
||||
struct timespec times[2];
|
||||
times[0].tv_sec = (time_t)changed;
|
||||
times[0].tv_nsec = 0;
|
||||
times[1].tv_sec = (time_t)changed;
|
||||
times[1].tv_nsec = 0;
|
||||
futimens(fd, times);
|
||||
}
|
||||
|
||||
autofree(char) *command = NULL;
|
||||
// printf("Filename is %s\n", filename);
|
||||
|
||||
@@ -256,8 +237,7 @@ static int curl_get_file(const char *url, const char *prefix, time_t timestamp)
|
||||
stat(filename, &statbuf);
|
||||
if (statbuf.st_size > 0 &&
|
||||
asprintf(&command,
|
||||
"tar -C /var/cache/debuginfo/%s --no-same-owner "
|
||||
"--no-same-permissions -xf %s",
|
||||
"tar -C /var/cache/debuginfo/%s --no-same-owner --no-same-permissions -xf %s",
|
||||
prefix,
|
||||
filename) >= 0) {
|
||||
if (system(command) != 0) {
|
||||
@@ -354,7 +334,7 @@ static void *server_thread(void *arg)
|
||||
}
|
||||
|
||||
gettimeofday(&after, NULL);
|
||||
#if 0
|
||||
#if 0
|
||||
if (timedelta(before, after) > 0.6)
|
||||
printf("Request for %s took %5.2f seconds (%i - %i)\n",
|
||||
url,
|
||||
@@ -380,19 +360,8 @@ int main(__nc_unused__ int argc, __nc_unused__ char **argv)
|
||||
struct sockaddr_un sun;
|
||||
int ret;
|
||||
int curl_done = 0;
|
||||
uid_t dbg_user = 0;
|
||||
gid_t dbg_group = 0;
|
||||
struct passwd *passwdentry;
|
||||
const char *required_paths[] = { "/var/cache/debuginfo/lib", "/var/cache/debuginfo/src" };
|
||||
|
||||
umask(0);
|
||||
passwdentry = getpwnam("dbginfo");
|
||||
if (passwdentry) {
|
||||
dbg_user = passwdentry->pw_uid;
|
||||
dbg_group = passwdentry->pw_gid;
|
||||
}
|
||||
endpwent();
|
||||
|
||||
if (prctl(PR_SET_DUMPABLE, 0) != 0) {
|
||||
fprintf(stderr,
|
||||
"Failed to disable PR_SET_DUMPABLE. Do NOT gdb attach this process: %s\n",
|
||||
@@ -407,70 +376,36 @@ int main(__nc_unused__ int argc, __nc_unused__ char **argv)
|
||||
|
||||
for (size_t i = 0; i < ARRAY_SIZE(required_paths); i++) {
|
||||
const char *req_path = required_paths[i];
|
||||
struct stat st = { .st_ino = 0 };
|
||||
if (lstat(req_path, &st) == 0) {
|
||||
/* If the file already exists, check ownership
|
||||
* and delete tree if incorrect. Essentially a
|
||||
* one-off operation to transition from root owned to
|
||||
* dbginfo owned */
|
||||
if (st.st_uid == dbg_user) {
|
||||
continue;
|
||||
}
|
||||
fprintf(stderr, "Removing old debug information %s\n", req_path);
|
||||
nc_rm_rf(req_path);
|
||||
if (nc_file_exists(req_path)) {
|
||||
continue;
|
||||
}
|
||||
if (!nc_mkdir_p(req_path, 00755)) {
|
||||
fprintf(stderr, "Failed to mkdir: %s %s\n", strerror(errno), req_path);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (chown(req_path, dbg_user, dbg_group) != 0) {
|
||||
fprintf(stderr, "Failed to chown: %s %s\n", strerror(errno), req_path);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
|
||||
if (sd_listen_fds(0) == 1) {
|
||||
/* systemd socket activation */
|
||||
printf("Received socket from systemd socket activation\n");
|
||||
sockfd = SD_LISTEN_FDS_START + 0;
|
||||
} else if (sd_listen_fds(0) > 1) {
|
||||
printf("Too many file descriptors received.\n");
|
||||
exit(1);
|
||||
} else {
|
||||
sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (sockfd < 0) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
sun.sun_family = AF_UNIX;
|
||||
strcpy(sun.sun_path, "/run/clr-debug-info");
|
||||
|
||||
ret = bind(sockfd,
|
||||
(struct sockaddr *)&sun,
|
||||
offsetof(struct sockaddr_un, sun_path) + strlen("/run/clr-debug-info") + 1);
|
||||
if (ret < 0) {
|
||||
printf("Failed to bind:%s \n", strerror(errno));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
if (listen(sockfd, 16) < 0) {
|
||||
printf("Failed to listen:%s \n", strerror(errno));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
if (setgid(dbg_group)) {
|
||||
fprintf(stderr, "Unable to drop privileges setgid %s\n", strerror(errno));
|
||||
sockfd = socket(AF_UNIX, SOCK_STREAM, 0);
|
||||
if (sockfd < 0) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (setgroups(1, &dbg_group)) {
|
||||
fprintf(stderr, "Unable to drop privileges setgroups %s\n", strerror(errno));
|
||||
|
||||
sun.sun_family = AF_UNIX;
|
||||
strcpy(sun.sun_path, ":clr-debug-info");
|
||||
sun.sun_path[0] = 0; /* anonymous unix socket */
|
||||
|
||||
ret = bind(sockfd,
|
||||
(struct sockaddr *)&sun,
|
||||
offsetof(struct sockaddr_un, sun_path) + strlen(":clr-debug-info") + 1);
|
||||
if (ret < 0) {
|
||||
printf("Failed to bind:%s \n", strerror(errno));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
if (setuid(dbg_user)) {
|
||||
fprintf(stderr, "Unable to drop privileges setuid %s\n", strerror(errno));
|
||||
|
||||
if (listen(sockfd, 16) < 0) {
|
||||
printf("Failed to listen:%s \n", strerror(errno));
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user