2019-02-26 11:45:54 +00:00
|
|
|
{ stdenv, fetchurl, makeWrapper, dbus, libxml2, pam, pkgconfig, pmount, pythonPackages, writeScript, runtimeShell }:
|
2010-01-03 11:12:05 +00:00
|
|
|
|
|
|
|
let
|
2016-09-27 12:18:26 +00:00
|
|
|
|
|
|
|
# Search in the environment if the same program exists with a set uid or
|
|
|
|
# set gid bit. If it exists, run the first program found, otherwise run
|
|
|
|
# the default binary.
|
|
|
|
useSetUID = drv: path:
|
|
|
|
let
|
|
|
|
name = baseNameOf path;
|
|
|
|
bin = "${drv}${path}";
|
|
|
|
in assert name != "";
|
|
|
|
writeScript "setUID-${name}" ''
|
2019-02-26 11:45:54 +00:00
|
|
|
#!${runtimeShell}
|
2016-09-27 12:18:26 +00:00
|
|
|
inode=$(stat -Lc %i ${bin})
|
|
|
|
for file in $(type -ap ${name}); do
|
|
|
|
case $(stat -Lc %a $file) in
|
|
|
|
([2-7][0-7][0-7][0-7])
|
|
|
|
if test -r "$file".real; then
|
|
|
|
orig=$(cat "$file".real)
|
|
|
|
if test $inode = $(stat -Lc %i "$orig"); then
|
|
|
|
exec "$file" "$@"
|
|
|
|
fi
|
|
|
|
fi;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
exec ${bin} "$@"
|
|
|
|
'';
|
|
|
|
|
2010-01-03 11:12:05 +00:00
|
|
|
pmountBin = useSetUID pmount "/bin/pmount";
|
|
|
|
pumountBin = useSetUID pmount "/bin/pumount";
|
2016-08-16 20:51:21 +00:00
|
|
|
inherit (pythonPackages) python dbus-python;
|
2010-01-03 11:12:05 +00:00
|
|
|
in
|
|
|
|
|
2012-01-07 19:16:52 +00:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
name = "pam_usb-0.5.0";
|
2010-01-03 11:12:05 +00:00
|
|
|
|
|
|
|
src = fetchurl {
|
2012-01-07 19:16:52 +00:00
|
|
|
url = "mirror://sourceforge/pamusb/${name}.tar.gz";
|
|
|
|
sha256 = "1g1w0s9d8mfld8abrn405ll5grv3xgs0b0hsganrz6qafdq9j7q1";
|
2010-01-03 11:12:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
makeWrapper
|
|
|
|
# pam_usb dependencies
|
2012-03-29 18:02:10 +00:00
|
|
|
dbus libxml2 pam pmount pkgconfig
|
2010-01-03 11:12:05 +00:00
|
|
|
# pam_usb's tools dependencies
|
|
|
|
python
|
|
|
|
# cElementTree is included with python 2.5 and later.
|
|
|
|
];
|
|
|
|
|
|
|
|
preBuild = ''
|
|
|
|
makeFlagsArray=(DESTDIR=$out)
|
|
|
|
substituteInPlace ./src/volume.c \
|
|
|
|
--replace 'pmount' '${pmountBin}' \
|
|
|
|
--replace 'pumount' '${pumountBin}'
|
|
|
|
'';
|
|
|
|
|
|
|
|
# pmount is append to the PATH because pmounts binaries should have a set uid bit.
|
|
|
|
postInstall = ''
|
|
|
|
mv $out/usr/* $out/. # fix color */
|
|
|
|
rm -rf $out/usr
|
|
|
|
for prog in $out/bin/pamusb-conf $out/bin/pamusb-agent; do
|
|
|
|
substituteInPlace $prog --replace '/usr/bin/env python' '/bin/python'
|
|
|
|
wrapProgram $prog \
|
2016-08-16 20:51:21 +00:00
|
|
|
--prefix PYTHONPATH : "$(toPythonPath ${dbus-python})"
|
2010-01-03 11:12:05 +00:00
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = {
|
2020-04-01 01:11:51 +00:00
|
|
|
homepage = "http://pamusb.org/";
|
2010-01-03 11:12:05 +00:00
|
|
|
description = "Authentication using USB Flash Drives";
|
2014-06-19 04:19:00 +00:00
|
|
|
license = stdenv.lib.licenses.gpl2;
|
2016-08-02 17:50:55 +00:00
|
|
|
platforms = stdenv.lib.platforms.linux;
|
2010-01-03 11:12:05 +00:00
|
|
|
};
|
|
|
|
}
|