It appears that the ebuild in the Gentoo repo downloads the source code from:
https://pogostick.net/~pnh/ntpasswd/chn ... 140201.zip
I downloaded and looked at that source code.
I also noticed this:
https://bugs-devel.debian.org/cgi-bin/b ... g=762508#6
"Fails to read from read-only filesystems; uses buggy read logic and error detection"
Code: Select all
Package: chntpw
Version: 1.0-1
Severity: important
Tags: upstream patch
chntpw fails to read files from read-only filesystems, despite
having some logic to handle this:
# chntpw -e /c/Windows/System32/config/SOFTWARE
chntpw version 1.00 140201, (c) Petter N Hagen
openHive(/c/Windows/System32/config/SOFTWARE) failed: Read-only file system, trying read-only
openHive(): read error: : Read-only file system
chntpw: Unable to open/read a hive, exiting..
#
This is due to using errno as an error checking mechanism; it should
only be used when one knows a function has failed. The attached patch
fixes this problem. It also adds support for the non-fatal EINTR error,
and fixes yet another bug where the last read size is used in a check
instead of the whole file size.
You can find a list of patches that were accepted into Debian chntpw package over the years here:
https://sources.debian.org/patches/chntpw/140201-1/
Specifically, the one discussed above : 12_readonly_filesystem
Here is the direct link to said patch:
https://sources.debian.org/data/main/c/ ... filesystem
I do not see any such patch in my system in the ebuild directory:
/var/db/repos/gentoo/app-crypt/chntpw/files
I also read the downloaded source code (from the Gentoo ebuild), specifically the file that patch would apply to, ntreg.c .
It does not appear to have the fixed (patched) code and still uses the original code.
Here is a text version of the patch:
https://sources.debian.org/data/main/c/ ... filesystem
Maybe you can incorporate that patch into a your own personal chntpw ebuild.
Code: Select all
--- chntpw-1.0.orig/ntreg.c
+++ chntpw-1.0/ntreg.c
@@ -4241,9 +4241,9 @@ struct hive *openHive(char *filename, in
do { /* On some platforms read may not block, and read in chunks. handle that */
r = read(hdesc->filedesc, hdesc->buffer + rt, hdesc->size - rt);
rt += r;
- } while ( !errno && (rt < hdesc->size) );
+ } while ( (r > 0 || (r < 0 && errno == EINTR)) && (rt < hdesc->size) );
- if (errno) {
+ if (r < 0) {
perror("openHive(): read error: ");
closeHive(hdesc);
return(NULL);
@@ -4255,10 +4255,10 @@ struct hive *openHive(char *filename, in
return(NULL);
}
- if (r < sizeof (*hdesc)) {
+ if (rt < sizeof (*hdesc)) {
fprintf(stderr,
"file is too small; got %d bytes while expecting %d or more\n",
- r, sizeof (*hdesc));
+ rt, sizeof (*hdesc));
closeHive(hdesc);
return(NULL);
}
*** Also, I noticed the Gentoo package is looking for a new maintainer. Maybe you would be the perfect person to take it over and incorporate any of those 15 patches that might be deemed suitable for the Gentoo ebuild. ***