summary refs log tree commit diff
path: root/pkgs/tools/security/pcsclite
diff options
context:
space:
mode:
authoraszlig <aszlig@redmoonstudios.org>2016-06-04 12:42:16 +0200
committeraszlig <aszlig@redmoonstudios.org>2016-06-04 16:38:57 +0200
commit70246d7cfa32e3bce1e0488be02a9c238de09b9f (patch)
treedd0b3eaefdd9aef65b9efe5e40056a1e7bbb8e3a /pkgs/tools/security/pcsclite
parent9a154e2838cbb4b830e59eee8ec923a1d1ce3f85 (diff)
downloadnixpkgs-70246d7cfa32e3bce1e0488be02a9c238de09b9f.tar
nixpkgs-70246d7cfa32e3bce1e0488be02a9c238de09b9f.tar.gz
nixpkgs-70246d7cfa32e3bce1e0488be02a9c238de09b9f.tar.bz2
nixpkgs-70246d7cfa32e3bce1e0488be02a9c238de09b9f.tar.lz
nixpkgs-70246d7cfa32e3bce1e0488be02a9c238de09b9f.tar.xz
nixpkgs-70246d7cfa32e3bce1e0488be02a9c238de09b9f.tar.zst
nixpkgs-70246d7cfa32e3bce1e0488be02a9c238de09b9f.zip
pcsclite: Introduce PCSCLITE_HP_DROPDIR env var
This allows to override the directory where PCSC-Lite searches for USB
drivers at runtime and should make our NixOS module much more clean so
that we don't need to imperatively stitch together plugin directories
anymore.

I'm using a GNU extension for the ternary operator to avoid computing
getenv("PCSCLITE_HP_DROPDIR") twice:

https://gcc.gnu.org/onlinedocs/gcc/Conditionals.html#Conditionals

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
Cc: @viric, @wkennington
Diffstat (limited to 'pkgs/tools/security/pcsclite')
-rw-r--r--pkgs/tools/security/pcsclite/default.nix8
-rw-r--r--pkgs/tools/security/pcsclite/no-dropdir-literals.patch73
2 files changed, 81 insertions, 0 deletions
diff --git a/pkgs/tools/security/pcsclite/default.nix b/pkgs/tools/security/pcsclite/default.nix
index e75b6a8372c..a3ce7b90c2b 100644
--- a/pkgs/tools/security/pcsclite/default.nix
+++ b/pkgs/tools/security/pcsclite/default.nix
@@ -8,6 +8,8 @@ stdenv.mkDerivation rec {
     sha256 = "12k8q0ckyy1fqcfh7x0b7kfrlfiscrqaqmidcggnzs4pi2iqml77";
   };
 
+  patches = [ ./no-dropdir-literals.patch ];
+
   configureFlags = [
     # The OS should care on preparing the drivers into this location
     "--enable-usbdropdir=/var/lib/pcsc/drivers"
@@ -15,6 +17,12 @@ stdenv.mkDerivation rec {
   ] ++ stdenv.lib.optional stdenv.isLinux
          "--with-systemdsystemunitdir=\${out}/etc/systemd/system";
 
+  postConfigure = ''
+    sed -i -re '/^#define *PCSCLITE_HP_DROPDIR */ {
+      s/(DROPDIR *)(.*)/\1(getenv("PCSCLITE_HP_DROPDIR") ? : \2)/
+    }' config.h
+  '';
+
   nativeBuildInputs = [ pkgconfig perl python2 ];
   buildInputs = stdenv.lib.optionals stdenv.isLinux [ udev dbus_libs ];
 
diff --git a/pkgs/tools/security/pcsclite/no-dropdir-literals.patch b/pkgs/tools/security/pcsclite/no-dropdir-literals.patch
new file mode 100644
index 00000000000..6e6734c9543
--- /dev/null
+++ b/pkgs/tools/security/pcsclite/no-dropdir-literals.patch
@@ -0,0 +1,73 @@
+diff --git a/src/hotplug_libudev.c b/src/hotplug_libudev.c
+index a8ba1b8..a53700b 100644
+--- a/src/hotplug_libudev.c
++++ b/src/hotplug_libudev.c
+@@ -119,7 +119,8 @@ static LONG HPReadBundleValues(void)
+ 
+ 	if (NULL == hpDir)
+ 	{
+-		Log1(PCSC_LOG_ERROR, "Cannot open PC/SC drivers directory: " PCSCLITE_HP_DROPDIR);
++		Log2(PCSC_LOG_ERROR, "Cannot open PC/SC drivers directory: %s",
++			PCSCLITE_HP_DROPDIR);
+ 		Log1(PCSC_LOG_ERROR, "Disabling USB support for pcscd.");
+ 		return -1;
+ 	}
+@@ -722,7 +723,7 @@ ULONG HPRegisterForHotplugEvents(void)
+ 
+ 	if (driverSize <= 0)
+ 	{
+-		Log1(PCSC_LOG_INFO, "No bundle files in pcsc drivers directory: "
++		Log2(PCSC_LOG_INFO, "No bundle files in pcsc drivers directory: %s",
+ 			PCSCLITE_HP_DROPDIR);
+ 		Log1(PCSC_LOG_INFO, "Disabling USB support for pcscd");
+ 		return 0;
+diff --git a/src/hotplug_libusb.c b/src/hotplug_libusb.c
+index eff8519..8dd496d 100644
+--- a/src/hotplug_libusb.c
++++ b/src/hotplug_libusb.c
+@@ -138,7 +138,8 @@ static LONG HPReadBundleValues(void)
+ 
+ 	if (hpDir == NULL)
+ 	{
+-		Log1(PCSC_LOG_ERROR, "Cannot open PC/SC drivers directory: " PCSCLITE_HP_DROPDIR);
++		Log2(PCSC_LOG_ERROR, "Cannot open PC/SC drivers directory: %s",
++			PCSCLITE_HP_DROPDIR);
+ 		Log1(PCSC_LOG_ERROR, "Disabling USB support for pcscd.");
+ 		return -1;
+ 	}
+@@ -265,7 +266,8 @@ static LONG HPReadBundleValues(void)
+ 
+ 	if (driverSize == 0)
+ 	{
+-		Log1(PCSC_LOG_INFO, "No bundle files in pcsc drivers directory: " PCSCLITE_HP_DROPDIR);
++		Log2(PCSC_LOG_INFO, "No bundle files in pcsc drivers directory: %s",
++			PCSCLITE_HP_DROPDIR);
+ 		Log1(PCSC_LOG_INFO, "Disabling USB support for pcscd");
+ 	}
+ #ifdef DEBUG_HOTPLUG
+diff --git a/src/hotplug_linux.c b/src/hotplug_linux.c
+index bf69af8..64b0ed7 100644
+--- a/src/hotplug_linux.c
++++ b/src/hotplug_linux.c
+@@ -130,8 +130,8 @@ static LONG HPReadBundleValues(void)
+ 
+ 	if (hpDir == NULL)
+ 	{
+-		Log1(PCSC_LOG_INFO,
+-			"Cannot open PC/SC drivers directory: " PCSCLITE_HP_DROPDIR);
++		Log2(PCSC_LOG_INFO, "Cannot open PC/SC drivers directory: %s",
++			PCSCLITE_HP_DROPDIR);
+ 		Log1(PCSC_LOG_INFO, "Disabling USB support for pcscd.");
+ 		return -1;
+ 	}
+@@ -219,8 +219,8 @@ end:
+ 
+ 	if (bundleSize == 0)
+ 	{
+-		Log1(PCSC_LOG_INFO,
+-			"No bundle files in pcsc drivers directory: " PCSCLITE_HP_DROPDIR);
++		Log2(PCSC_LOG_INFO, "No bundle files in pcsc drivers directory: %s",
++			PCSCLITE_HP_DROPDIR);
+ 		Log1(PCSC_LOG_INFO, "Disabling USB support for pcscd");
+ 	}
+