[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#862470: marked as done ((pre-approval) unblock: lxcfs/2.0.7-1)



Your message dated Sat, 20 May 2017 11:11:00 +0000
with message-id <90fa6be3-93b2-63d8-b806-3d4373f5a650@thykier.net>
and subject line Re: Bug#862470: (pre-approval) unblock: lxcfs/2.0.7-1
has caused the Debian Bug report #862470,
regarding (pre-approval) unblock: lxcfs/2.0.7-1
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact owner@bugs.debian.org
immediately.)


-- 
862470: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=862470
Debian Bug Tracking System
Contact owner@bugs.debian.org with problems
--- Begin Message ---
Package: release.debian.org
Severity: normal
User: release.debian.org@packages.debian.org
Usertags: unblock

Dear Release Team,

As with LXC, I wonder if you would be OK with accepting the latest LXCFS
stable release into Stretch at this point in time.
The patch is not as huge (7 files changed, 100 insertions(+), 61
deletions(-)) and the reasoning is very much the same: having the best
possible base for Stretch.

Full debdiff attached.

Thanks for all your work!
Evgeni
diff --git a/bindings.c b/bindings.c
index 3516be6..6387012 100644
--- a/bindings.c
+++ b/bindings.c
@@ -72,8 +72,8 @@ struct file_info {
 	int cached;
 };
 
-/* reserve buffer size, for cpuall in /proc/stat */
-#define BUF_RESERVE_SIZE 256
+/* Reserve buffer size to account for file size changes. */
+#define BUF_RESERVE_SIZE 512
 
 /*
  * A table caching which pid is init for a pid namespace.
@@ -863,11 +863,11 @@ bool cgfs_get_value(const char *controller, const char *cgroup, const char *file
 	fnam = alloca(len);
 	ret = snprintf(fnam, len, "%s%s/%s", *cgroup == '/' ? "." : "", cgroup, file);
 	if (ret < 0 || (size_t)ret >= len)
-		return NULL;
+		return false;
 
 	fd = openat(cfd, fnam, O_RDONLY);
 	if (fd < 0)
-		return NULL;
+		return false;
 
 	*value = slurp_file(fnam, fd);
 	return *value != NULL;
@@ -2908,7 +2908,7 @@ int cg_rmdir(const char *path)
 	if (initpid <= 0)
 		initpid = fc->pid;
 	if (!caller_is_in_ancestor(initpid, controller, cgroup, &next)) {
-		if (!last || strcmp(next, last) == 0)
+		if (!last || (next && (strcmp(next, last) == 0)))
 			ret = -EBUSY;
 		else
 			ret = -ENOENT;
@@ -3086,7 +3086,8 @@ static int proc_meminfo_read(char *buf, size_t size, off_t offset,
 		*memswlimit_str = NULL, *memswusage_str = NULL;
 	unsigned long memlimit = 0, memusage = 0, memswlimit = 0, memswusage = 0,
 		cached = 0, hosttotal = 0, active_anon = 0, inactive_anon = 0,
-		active_file = 0, inactive_file = 0, unevictable = 0;
+		active_file = 0, inactive_file = 0, unevictable = 0,
+		hostswtotal = 0;
 	char *line = NULL;
 	size_t linelen = 0, total_len = 0, rv = 0;
 	char *cache = d->buf;
@@ -3148,7 +3149,7 @@ static int proc_meminfo_read(char *buf, size_t size, off_t offset,
 
 		memset(lbuf, 0, 100);
 		if (startswith(line, "MemTotal:")) {
-			sscanf(line+14, "%lu", &hosttotal);
+			sscanf(line+sizeof("MemTotal:")-1, "%lu", &hosttotal);
 			if (hosttotal < memlimit)
 				memlimit = hosttotal;
 			snprintf(lbuf, 100, "MemTotal:       %8lu kB\n", memlimit);
@@ -3160,6 +3161,9 @@ static int proc_meminfo_read(char *buf, size_t size, off_t offset,
 			snprintf(lbuf, 100, "MemAvailable:   %8lu kB\n", memlimit - memusage);
 			printme = lbuf;
 		} else if (startswith(line, "SwapTotal:") && memswlimit > 0) {
+			sscanf(line+sizeof("SwapTotal:")-1, "%lu", &hostswtotal);
+			if (hostswtotal < memswlimit - memlimit)
+				memswlimit = hostswtotal + memlimit;
 			snprintf(lbuf, 100, "SwapTotal:      %8lu kB\n", memswlimit - memlimit);
 			printme = lbuf;
 		} else if (startswith(line, "SwapFree:") && memswlimit > 0 && memswusage > 0) {
@@ -3450,6 +3454,28 @@ err:
 	return rv;
 }
 
+static long int getreaperctime(pid_t pid)
+{
+	char fnam[100];
+	struct stat sb;
+	int ret;
+	pid_t qpid;
+
+	qpid = lookup_initpid_in_store(pid);
+	if (qpid <= 0)
+		return 0;
+
+	ret = snprintf(fnam, 100, "/proc/%d", qpid);
+	if (ret < 0 || ret >= 100)
+		return 0;
+
+	if (lstat(fnam, &sb) < 0)
+		return 0;
+
+	return sb.st_ctime;
+}
+
+#define CPUALL_MAX_SIZE (BUF_RESERVE_SIZE / 2)
 static int proc_stat_read(char *buf, size_t size, off_t offset,
 		struct fuse_file_info *fi)
 {
@@ -3460,10 +3486,9 @@ static int proc_stat_read(char *buf, size_t size, off_t offset,
 	char *line = NULL;
 	size_t linelen = 0, total_len = 0, rv = 0;
 	int curcpu = -1; /* cpu numbering starts at 0 */
-	unsigned long user = 0, nice = 0, system = 0, idle = 0, iowait = 0, irq = 0, softirq = 0, steal = 0, guest = 0;
+	unsigned long user = 0, nice = 0, system = 0, idle = 0, iowait = 0, irq = 0, softirq = 0, steal = 0, guest = 0, guest_nice = 0;
 	unsigned long user_sum = 0, nice_sum = 0, system_sum = 0, idle_sum = 0, iowait_sum = 0,
-					irq_sum = 0, softirq_sum = 0, steal_sum = 0, guest_sum = 0;
-#define CPUALL_MAX_SIZE BUF_RESERVE_SIZE
+					irq_sum = 0, softirq_sum = 0, steal_sum = 0, guest_sum = 0, guest_nice_sum = 0;
 	char cpuall[CPUALL_MAX_SIZE];
 	/* reserve for cpu all */
 	char *cache = d->buf + CPUALL_MAX_SIZE;
@@ -3513,7 +3538,10 @@ static int proc_stat_read(char *buf, size_t size, off_t offset,
 			continue;
 		if (sscanf(line, "cpu%9[^ ]", cpu_char) != 1) {
 			/* not a ^cpuN line containing a number N, just print it */
-			l = snprintf(cache, cache_size, "%s", line);
+			if (strncmp(line, "btime", 5) == 0)
+				l = snprintf(cache, cache_size, "btime %ld\n", getreaperctime(fc->pid));
+			else
+				l = snprintf(cache, cache_size, "%s", line);
 			if (l < 0) {
 				perror("Error writing to cache");
 				rv = 0;
@@ -3556,8 +3584,17 @@ static int proc_stat_read(char *buf, size_t size, off_t offset,
 		cache_size -= l;
 		total_len += l;
 
-		if (sscanf(line, "%*s %lu %lu %lu %lu %lu %lu %lu %lu %lu", &user, &nice, &system, &idle, &iowait, &irq,
-			&softirq, &steal, &guest) != 9)
+		if (sscanf(line, "%*s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu",
+			   &user,
+			   &nice,
+			   &system,
+			   &idle,
+			   &iowait,
+			   &irq,
+			   &softirq,
+			   &steal,
+			   &guest,
+			   &guest_nice) != 10)
 			continue;
 		user_sum += user;
 		nice_sum += nice;
@@ -3568,16 +3605,26 @@ static int proc_stat_read(char *buf, size_t size, off_t offset,
 		softirq_sum += softirq;
 		steal_sum += steal;
 		guest_sum += guest;
+		guest_nice_sum += guest_nice;
 	}
 
 	cache = d->buf;
 
-	int cpuall_len = snprintf(cpuall, CPUALL_MAX_SIZE, "%s %lu %lu %lu %lu %lu %lu %lu %lu %lu\n",
-		"cpu ", user_sum, nice_sum, system_sum, idle_sum, iowait_sum, irq_sum, softirq_sum, steal_sum, guest_sum);
-	if (cpuall_len > 0 && cpuall_len < CPUALL_MAX_SIZE){
+	int cpuall_len = snprintf(cpuall, CPUALL_MAX_SIZE, "cpu  %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n",
+			user_sum,
+			nice_sum,
+			system_sum,
+			idle_sum,
+			iowait_sum,
+			irq_sum,
+			softirq_sum,
+			steal_sum,
+			guest_sum,
+			guest_nice_sum);
+	if (cpuall_len > 0 && cpuall_len < CPUALL_MAX_SIZE) {
 		memcpy(cache, cpuall, cpuall_len);
 		cache += cpuall_len;
-	} else{
+	} else {
 		/* shouldn't happen */
 		lxcfs_error("proc_stat_read copy cpuall failed, cpuall_len=%d.", cpuall_len);
 		cpuall_len = 0;
@@ -3587,7 +3634,8 @@ static int proc_stat_read(char *buf, size_t size, off_t offset,
 	total_len += cpuall_len;
 	d->cached = 1;
 	d->size = total_len;
-	if (total_len > size ) total_len = size;
+	if (total_len > size)
+		total_len = size;
 
 	memcpy(buf, d->buf, total_len);
 	rv = total_len;
@@ -3603,23 +3651,12 @@ err:
 
 static long int getreaperage(pid_t pid)
 {
-	char fnam[100];
-	struct stat sb;
-	int ret;
-	pid_t qpid;
-
-	qpid = lookup_initpid_in_store(pid);
-	if (qpid <= 0)
-		return 0;
-
-	ret = snprintf(fnam, 100, "/proc/%d", qpid);
-	if (ret < 0 || ret >= 100)
-		return 0;
-
-	if (lstat(fnam, &sb) < 0)
-		return 0;
+	long int ctime;
 
-	return time(NULL) - sb.st_ctime;
+	ctime = getreaperctime(pid);
+	if (ctime)
+		return time(NULL) - ctime;
+	return ctime;
 }
 
 static unsigned long get_reaper_busy(pid_t task)
@@ -4450,7 +4487,7 @@ static void __attribute__((constructor)) collect_and_mount_subsystems(void)
 		goto out;
 	}
 
-	fd_hierarchies = malloc(sizeof(int *) * num_hierarchies);
+	fd_hierarchies = malloc(sizeof(int) * num_hierarchies);
 	if (!fd_hierarchies) {
 		lxcfs_error("%s\n", strerror(errno));
 		goto out;
diff --git a/config/init/systemd/Makefile.in b/config/init/systemd/Makefile.in
index 0e65233..fb95e45 100644
--- a/config/init/systemd/Makefile.in
+++ b/config/init/systemd/Makefile.in
@@ -362,8 +362,8 @@ distclean-generic:
 maintainer-clean-generic:
 	@echo "This command is intended for maintainers to use"
 	@echo "it deletes files that may require special tools to rebuild."
-@INIT_SCRIPT_SYSTEMD_FALSE@install-data-local:
 @INIT_SCRIPT_SYSTEMD_FALSE@uninstall-local:
+@INIT_SCRIPT_SYSTEMD_FALSE@install-data-local:
 clean: clean-am
 
 clean-am: clean-generic clean-libtool mostlyclean-am
diff --git a/config/init/upstart/Makefile.in b/config/init/upstart/Makefile.in
index 3314f64..a5e633f 100644
--- a/config/init/upstart/Makefile.in
+++ b/config/init/upstart/Makefile.in
@@ -361,8 +361,8 @@ distclean-generic:
 maintainer-clean-generic:
 	@echo "This command is intended for maintainers to use"
 	@echo "it deletes files that may require special tools to rebuild."
-@INIT_SCRIPT_UPSTART_FALSE@uninstall-local:
 @INIT_SCRIPT_UPSTART_FALSE@install-data-local:
+@INIT_SCRIPT_UPSTART_FALSE@uninstall-local:
 clean: clean-am
 
 clean-am: clean-generic clean-libtool mostlyclean-am
diff --git a/configure b/configure
index 83d6400..c0bfbd3 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for lxcfs 2.0.6.
+# Generated by GNU Autoconf 2.69 for lxcfs 2.0.7.
 #
 # Report bugs to <lxc-devel@lists.linuxcontainers.org>.
 #
@@ -590,8 +590,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='lxcfs'
 PACKAGE_TARNAME='lxcfs'
-PACKAGE_VERSION='2.0.6'
-PACKAGE_STRING='lxcfs 2.0.6'
+PACKAGE_VERSION='2.0.7'
+PACKAGE_STRING='lxcfs 2.0.7'
 PACKAGE_BUGREPORT='lxc-devel@lists.linuxcontainers.org'
 PACKAGE_URL=''
 
@@ -1368,7 +1368,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures lxcfs 2.0.6 to adapt to many kinds of systems.
+\`configure' configures lxcfs 2.0.7 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1439,7 +1439,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of lxcfs 2.0.6:";;
+     short | recursive ) echo "Configuration of lxcfs 2.0.7:";;
    esac
   cat <<\_ACEOF
 
@@ -1569,7 +1569,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-lxcfs configure 2.0.6
+lxcfs configure 2.0.7
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -1938,7 +1938,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by lxcfs $as_me 2.0.6, which was
+It was created by lxcfs $as_me 2.0.7, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -2805,7 +2805,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='lxcfs'
- VERSION='2.0.6'
+ VERSION='2.0.7'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -14519,7 +14519,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by lxcfs $as_me 2.0.6, which was
+This file was extended by lxcfs $as_me 2.0.7, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -14585,7 +14585,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-lxcfs config.status 2.0.6
+lxcfs config.status 2.0.7
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff --git a/configure.ac b/configure.ac
index 4ad8b0b..3bd8cf3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,7 +1,7 @@
 # Process this file with autoconf to produce a configure script.
 
 AC_PREREQ(2.61)
-AC_INIT([lxcfs], [2.0.6], [lxc-devel@lists.linuxcontainers.org])
+AC_INIT([lxcfs], [2.0.7], [lxc-devel@lists.linuxcontainers.org])
 AC_SUBST(ACLOCAL_AMFLAGS, "-I m4")
 AC_CONFIG_MACRO_DIR([m4])
 
diff --git a/debian/changelog b/debian/changelog
index bc234d9..2c07fc8 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,9 @@
+lxcfs (2.0.7-1) UNRELEASED; urgency=medium
+
+  * Imported Upstream version 2.0.7
+
+ -- Evgeni Golov <egolov@redhat.com>  Sat, 13 May 2017 08:39:51 +0100
+
 lxcfs (2.0.6-1) unstable; urgency=medium
 
   * New upstream version 2.0.6
diff --git a/pam/pam_cgfs.c b/pam/pam_cgfs.c
index 6553afa..4c163db 100644
--- a/pam/pam_cgfs.c
+++ b/pam/pam_cgfs.c
@@ -346,7 +346,7 @@ static void trim(char *s)
 {
 	size_t len = strlen(s);
 
-	while (s[len - 1] == '\n')
+	while ((len > 0) && s[len - 1] == '\n')
 		s[--len] = '\0';
 }
 
@@ -1318,11 +1318,11 @@ static int cg_get_version_of_mntpt(const char *path)
 static bool cgv2_init(uid_t uid, gid_t gid)
 {
 	char *mountpoint;
-	bool ret = false;
 	FILE *f = NULL;
 	char *current_cgroup = NULL, *init_cgroup = NULL;
 	char * line = NULL;
 	size_t len = 0;
+	int ret = false;
 
 	current_cgroup = cgv2_get_current_cgroup(getpid());
 	if (!current_cgroup) {
@@ -1366,7 +1366,7 @@ static bool cgv2_init(uid_t uid, gid_t gid)
 
 	f = fopen("/proc/self/mountinfo", "r");
 	if (!f)
-		return false;
+		goto cleanup;
 
 	/* we support simple cgroup mounts and lxcfs mounts */
 	while (getline(&line, &len, f) != -1) {
@@ -1401,7 +1401,7 @@ cleanup:
 		fclose(f);
 	free(line);
 
-	return true;
+	return ret;
 }
 
 /* Detect and store information about mounted cgroupfs v1 hierarchies and the
@@ -1652,11 +1652,14 @@ static char *string_join(const char *sep, const char **parts, bool use_as_prefix
 	size_t sep_len = strlen(sep);
 	size_t result_len = use_as_prefix * sep_len;
 
+	if (!parts)
+		return NULL;
+
 	/* calculate new string length */
 	for (p = (char **)parts; *p; p++)
 		result_len += (p > (char **)parts) * sep_len + strlen(*p);
 
-	result = calloc(result_len + 1, 1);
+	result = calloc(result_len + 1, sizeof(char));
 	if (!result)
 		return NULL;
 
@@ -1712,8 +1715,6 @@ static ssize_t cg_get_max_cpus(char *cpulist)
 
 	if (!c1 && !c2)
 		c1 = maxcpus;
-	else if (c1 > c2)
-		c2 = c1;
 	else if (c1 < c2)
 		c1 = c2;
 
@@ -2100,8 +2101,6 @@ static bool cgv1_create_one(struct cgv1_hierarchy *h, const char *cgroup, uid_t
 	it = h;
 	for (controller = it->controllers; controller && *controller;
 	     controller++) {
-		created = false;
-
 		if (!cgv1_handle_cpuset_hierarchy(it, cgroup))
 			return false;
 
@@ -2159,10 +2158,7 @@ static bool cgv1_create_one(struct cgv1_hierarchy *h, const char *cgroup, uid_t
 		break;
 	}
 
-	if (!created)
-		return false;
-
-	return true;
+	return created;
 }
 
 /* Try to remove @cgroup for all given controllers in a cgroupfs v1 hierarchy

--- End Message ---
--- Begin Message ---
Evgeni Golov:
>>> As with LXC, I wonder if you would be OK with accepting the latest LXCFS
>>> stable release into Stretch at this point in time.
>>> The patch is not as huge (7 files changed, 100 insertions(+), 61
>>> deletions(-)) and the reasoning is very much the same: having the best
>>> possible base for Stretch.
>>
>> Ack, please go ahead.
> 
> Thanks Niels!
> Uploaded and built on all release arches.
> 
> Cheers
> Evgeni
> 

Unblocked, thanks.

~Niels

--- End Message ---

Reply to: