1{ lib, stdenv, fetchurl, unzip, fetchpatch }:
2
3stdenv.mkDerivation rec {
4 pname = "chntpw";
5
6 version = "140201";
7
8 src = fetchurl {
9 url = "http://pogostick.net/~pnh/ntpasswd/chntpw-source-${version}.zip";
10 sha256 = "1k1cxsj0221dpsqi5yibq2hr7n8xywnicl8yyaicn91y8h2hkqln";
11 };
12
13 nativeBuildInputs = [ unzip ];
14
15 patches = [
16 ./00-chntpw-build-arch-autodetect.patch
17 ./01-chntpw-install-target.patch
18 # Import various bug fixes from debian
19 (fetchpatch {
20 url = "https://sources.debian.org/data/main/c/chntpw/140201-1/debian/patches/04_get_abs_path";
21 sha256 = "17h0gaczqd5b792481synr1ny72frwslb779lm417pyrz6kh9q8n";
22 })
23 (fetchpatch {
24 url = "https://sources.debian.org/data/main/c/chntpw/140201-1/debian/patches/06_correct_test_open_syscall";
25 sha256 = "00lg83bimbki988n71w54mmhjp9529r0ngm40d7fdmnc2dlpj3hd";
26 })
27 (fetchpatch {
28 url = "https://sources.debian.org/data/main/c/chntpw/140201-1/debian/patches/07_detect_failure_to_write_key";
29 sha256 = "0pk6xnprh2pqyx4n4lw3836z6fqsw3mclkzppl5rhjaahriwxw4l";
30 })
31 (fetchpatch {
32 url = "https://sources.debian.org/data/main/c/chntpw/140201-1/debian/patches/08_no_deref_null";
33 sha256 = "1g7pfmjaj0c2sm64s3api2kglj7jbgddjjd3r4drw6phwdkah0zs";
34 })
35 (fetchpatch {
36 url = "https://sources.debian.org/data/main/c/chntpw/140201-1/debian/patches/09_improve_robustness";
37 sha256 = "1nszkdy01ixnain7cwdmfbhjngphw1300ifagc1wgl9wvghzviaa";
38 })
39 (fetchpatch {
40 url = "https://sources.debian.org/data/main/c/chntpw/140201-1/debian/patches/11_improve_documentation";
41 sha256 = "0yql6hj72q7cq69rrspsjkpiipdhcwb0b9w5j8nhq40cnx9mgqgg";
42 })
43 (fetchpatch {
44 url = "https://sources.debian.org/data/main/c/chntpw/140201-1/debian/patches/12_readonly_filesystem";
45 sha256 = "1kxcy7f2pl6fqgmjg8bnl3pl5wgiw5xnbyx12arinmqkkggp4fa4";
46 })
47 (fetchpatch {
48 url = "https://sources.debian.org/data/main/c/chntpw/140201-1/debian/patches/13_write_to_hive";
49 sha256 = "1638lcyxjkrkmbr3n28byixny0qrxvkciw1xd97x48mj6bnwqrkv";
50 })
51 (fetchpatch {
52 url = "https://sources.debian.org/data/main/c/chntpw/140201-1/debian/patches/14_improve_description";
53 sha256 = "11y5kc4dh4zv24nkb0jw2zwlifx6nzsd4jbizn63l6dbpqgb25rs";
54 })
55 ];
56
57 installPhase = ''
58 make install PREFIX=$out
59 '';
60
61 meta = with lib; {
62 homepage = "http://pogostick.net/~pnh/ntpasswd/";
63 description = "An utility to reset the password of any user that has a valid local account on a Windows system";
64 maintainers = with lib.maintainers; [ deepfire ];
65 license = licenses.gpl2;
66 platforms = lib.platforms.unix;
67 };
68}