Introduce pid_for_children element from ns

Resolves: #1489611

Signed-off-by: Matej Habrnal <mhabrnal@redhat.com>
This commit is contained in:
Matej Habrnal 2017-09-13 15:13:09 +02:00
parent e84543384f
commit 5bd628274a
3 changed files with 129 additions and 1 deletions

View File

@ -0,0 +1,32 @@
From 60c8ec5f937a28a5ec3d37f5d808c74fc4ef5735 Mon Sep 17 00:00:00 2001
From: Matej Marusak <mmarusak@redhat.com>
Date: Tue, 5 Sep 2017 10:48:31 +0200
Subject: [PATCH 3/4] client-python: Do not try to unlink None
Rhbz: #1416277
https://github.com/abrt/libreport/blob/master/src/client-python/reportclient/dnfdebuginfo.py#L135
returns None when downloading fails.
Signed-off-by: Matej Marusak <mmarusak@redhat.com>
---
src/client-python/reportclient/debuginfo.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/client-python/reportclient/debuginfo.py b/src/client-python/reportclient/debuginfo.py
index 0385f716..4390304e 100644
--- a/src/client-python/reportclient/debuginfo.py
+++ b/src/client-python/reportclient/debuginfo.py
@@ -374,7 +374,8 @@ class DebugInfoDownload(object):
# I observed a zero-length file left on error,
# which prevents cleanup later. Fix it:
try:
- os.unlink(package_full_path)
+ if package_full_path is not None:
+ os.unlink(package_full_path)
except OSError:
pass
print(_("Downloading package {0} failed").format(pkg))
--
2.13.5

View File

@ -0,0 +1,88 @@
From 5fba4820bd501fdaed6c77775808f12166c55399 Mon Sep 17 00:00:00 2001
From: Matej Marusak <mmarusak@redhat.com>
Date: Wed, 13 Sep 2017 08:09:35 +0200
Subject: [PATCH 4/4] lib: Introduce pid_for_children element from ns
From namespaces man pages:
/proc/[pid]/ns/pid_for_children (since Linux 4.12)
This file is a handle for the PID namespace of child processes
created by this process.
Signed-off-by: Matej Marusak <mmarusak@redhat.com>
---
src/include/internal_libreport.h | 2 +-
tests/proc_helpers.at | 39 ++++++++++++++++++++-------------------
2 files changed, 21 insertions(+), 20 deletions(-)
diff --git a/src/include/internal_libreport.h b/src/include/internal_libreport.h
index 3527e0e1..1df4cba3 100644
--- a/src/include/internal_libreport.h
+++ b/src/include/internal_libreport.h
@@ -747,7 +747,7 @@ int get_env_variable(pid_t pid, const char *name, char **value);
#define PROC_NS_ID_USER 4
#define PROC_NS_ID_UTS 5
#define PROC_NS_ID_CGROUP 6
-static const char * libreport_proc_namespaces[] = { "ipc", "mnt", "net", "pid", "uts", "user", "cgroup" };
+static const char * libreport_proc_namespaces[] = { "ipc", "mnt", "net", "pid", "uts", "user", "cgroup", "pid_for_children" };
struct ns_ids {
ino_t nsi_ids[ARRAY_SIZE(libreport_proc_namespaces)];
diff --git a/tests/proc_helpers.at b/tests/proc_helpers.at
index 35e9c7a5..4b118f33 100644
--- a/tests/proc_helpers.at
+++ b/tests/proc_helpers.at
@@ -945,30 +945,31 @@ AT_TESTFUN([dump_namespace_diff], [[
void check_file_contents(const char *filename)
{
- static const char *expected;
+ char *expected;
struct stat st;
- if (stat("/proc/self/ns/cgroup", &st) < 0 && errno == ENOENT) {
- expected = "ipc : default\n"
- "mnt : default\n"
- "net : default\n"
- "pid : default\n"
- "uts : default\n"
- "user : default\n"
- "cgroup : unknown\n";
- }
- else {
- expected = "ipc : default\n"
- "mnt : default\n"
- "net : default\n"
- "pid : default\n"
- "uts : default\n"
- "user : default\n"
- "cgroup : default\n";
- }
+
+ char const *pid_for_children = "default";
+ char const *cgroup = "default";
+
+ if (stat("/proc/self/ns/cgroup", &st) < 0 && errno == ENOENT)
+ cgroup = "unknown";
+
+ if (stat("/proc/self/ns/pid_for_children", &st) < 0 && errno == ENOENT)
+ pid_for_children = "unknown";
+
+ expected = xasprintf("ipc : default\n"
+ "mnt : default\n"
+ "net : default\n"
+ "pid : default\n"
+ "uts : default\n"
+ "user : default\n"
+ "cgroup : %s\n"
+ "pid_for_children : %s\n", cgroup, pid_for_children);
char *file = xmalloc_xopen_read_close(filename, NULL);
TS_ASSERT_STRING_EQ(file, expected, "Namespaces");
free(file);
+ free(expected);
}
TS_MAIN
--
2.13.5

View File

@ -7,7 +7,7 @@
Summary: Generic library for reporting various problems
Name: libreport
Version: 2.9.2
Release: 1%{?dist}
Release: 2%{?dist}
License: GPLv2+
URL: https://abrt.readthedocs.org/
Source: https://github.com/abrt/%{name}/archive/%{version}/%{name}-%{version}.tar.gz
@ -15,6 +15,10 @@ Source1: autogen.sh
# git format-patch %%{Version} -N -M --topo-order
# i=0; for p in `ls 0*.patch`; do printf "Patch%04d: %s\n" $i $p; ((i++)); done
#Patch0001: 0001-Translation-updates.patch
#Patch0002: 0002-spec-rename-Python-binary-packages.patch
Patch0003: 0003-client-python-Do-not-try-to-unlink-None.patch
Patch0004: 0004-lib-Introduce-pid_for_children-element-from-ns.patch
# git is need for '%%autosetup -S git' which automatically applies all the
# patches above. Please, be aware that the patches must be generated
@ -743,6 +747,10 @@ gtk-update-icon-cache %{_datadir}/icons/hicolor &>/dev/null || :
%changelog
* Wed Sep 13 2017 Matej Habrnal <mhabrnal@redhat.com> 2.9.2-2
- Introduce pid_for_children element from ns
- Resolves: #1489611
* Fri Aug 25 2017 Matej Habrnal <mhabrnal@redhat.com> 2.9.2-1
- Translation updates
- logging: rename log() to log_warning()