Просмотр исходного кода

s-s-d: On kFreeBSD do not make kvm_openfiles() open /dev/mem

We do not need that file, as we are not using any kvm_read(3) call,
either explicitly or implicitly. Everything is retrieved through
sysctl(2).

libkvm from FreeBSD allows to pass /dev/null as the memory file to
denote that we do not need it.

This will make s-s-d work again on jails which do not usually have
/dev/mem available.

Reported-by: Steven Chamberlain <steven@pyro.eu.org>
Guillem Jover лет назад: 11
Родитель
Сommit
8fbe533b5b
2 измененных файлов с 9 добавлено и 1 удалено
  1. 3 0
      debian/changelog
  2. 6 1
      utils/start-stop-daemon.c

+ 3 - 0
debian/changelog

@@ -62,6 +62,9 @@ dpkg (1.17.14) UNRELEASED; urgency=low
       Reported by Will Conley <willconley3@gmail.com>. Closes: #760222
     - Do not abort on --stop when only --pid or --ppid options are specified.
       Thanks to Christos Trochalakis <yatiohi@ideopolis.gr>. Closes: #763767
+    - On kFreeBSD systems do not unnecessarily make kvm_openfiles() open
+      /dev/mem. This causes issues on FreeBSD jails for example.
+      Reported by Steven Chamberlain <steven@pyro.eu.org>.
 
   [ Raphaël Hertzog ]
   * Explain better in deb-triggers(5) why interest/activate-noawait should be

+ 6 - 1
utils/start-stop-daemon.c

@@ -103,6 +103,11 @@
 
 #ifdef HAVE_KVM_H
 #include <kvm.h>
+#if defined(OSFreeBSD)
+#define KVM_MEMFILE "/dev/null"
+#else
+#define KVM_MEMFILE NULL
+#endif
 #endif
 
 #ifdef _POSIX_PRIORITY_SCHEDULING
@@ -1229,7 +1234,7 @@ ssd_kvm_open(void)
 	kvm_t *kd;
 	char errbuf[_POSIX2_LINE_MAX];
 
-	kd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, errbuf);
+	kd = kvm_openfiles(NULL, KVM_MEMFILE, NULL, O_RDONLY, errbuf);
 	if (kd == NULL)
 		errx(1, "%s", errbuf);