Commit Graph

5053 Commits

Author SHA1 Message Date
Jean-Pierre André
1aa9882810 Silenced a compiler warning (cosmetic)
An argument to ntfs_index_remove() is now unused
2015-11-12 15:39:20 +01:00
Jean-Pierre André
59c90f039d Defined the last logfile block as preceding block 4 in ntfsrecover
When block 2 or block 3 points backward to block 4, it is not clear
whether the log file only consists of block 2 or block 3 or the log
file has just wrapped around. The latter is now assumed.
2015-11-12 15:31:24 +01:00
Jean-Pierre André
f7bc5249bc Alleviated constraints relative to reparse points
Some constraints put on reparse points of unknown type (e.g. they cannot
be deleted) are not acceptable to archivers. This patch removes some
constraints.
2015-11-09 16:22:16 +01:00
Jean-Pierre André
fb0afd41c8 Decoded the full list of bad clusters in ntfsclone and ntfsresize
When the bad cluster list required extent, ntfsclone and ntfsresize
did not process the extents, leading to unexpected read errors and
unmatching bitmaps. This fix enables the full list to be taken into
account.
2015-11-09 16:16:39 +01:00
Jean-Pierre André
34d29fe0b0 Fixed reparse data check for non-Microsoft tags
Windows requires non-Microsoft reparse points (identified by having bit
31 of the reparse tag clear) to have a 16-byte GUID following the regular
reparse point header.  This GUID is not, and cannot, be included in the
"reparse data length" field.

(Contributed by Eric Biggers)
2015-11-09 16:14:31 +01:00
Jean-Pierre André
37bd6661d4 Fixed getting space for making an index non resident
Under some rare condition there is no space in an MFT entry to make
an index non-resident, and the index root has to be moved to an extent.
This fix cares for the situation when the attribute list was inserted
beforehand.
2015-11-09 16:09:52 +01:00
Jean-Pierre André
1aaaa8fac1 Wrote as much data as possible in compressed attribute pwrite
When writing to compressed data, the function ntfs_attr_pwrite()
cannot cross a compression block border. This is a problem for archivers
which rely on libntfs-3g, so the function is now wrapped in another one
which restarts the writing as needed.
2015-11-09 16:00:31 +01:00
Jean-Pierre André
cba621e822 Silenced a compiler warning in ntfswipe (cosmetic)
Avoid a signed-to-unsigned compare warning
2015-11-09 15:58:00 +01:00
Jean-Pierre André
e736fea196 Fixed relocating the MFT runlists in ntfsresize
The MFT has two runlists which may be partially stored in extents.
When these runlists have to be relocated, the relocations must be done
after the old runlists are not needed any more to read the data of
standard files, but before the MFT may be needed to extend the runlists
of standard files. Before doing so the MFT runlists have to be refreshed
from device in order to collect the updates which cannot be done in
memory during the first stage.
2015-11-09 15:44:33 +01:00
Jean-Pierre André
0cb0173bbc Implemented recovery of updates committed by Windows
ntfsrecover applies to the metadata the updates which were requested on
Windows but could not be completed because they were interrupted by
some event such as a power failure, a hardware crash, a software crash
or the device being unplugged. Doing so, the file system is restored
to the latest consistent state.

No update to libntfs-3g is required by this implementation.
2015-11-09 13:18:58 +01:00
Erik Larsson
9191d85e28 Use appropriate little-endian/big-endian types in struct definitions.
On-disk struct definitions used native types (u16/u32/u64/s16/s32/s64),
which doesn't say anything about the intended interpretation of the
data. The intention of having little-endian-specific types and
big-endian-specific types must have been to clarify interpretation of
data and intentions in the code. Therefore it seems reasonable to use
these types in struct definitions to clarify what data represention is
used to encode field data.

Because some struct members in layout.h are big-endian, this change also
means moving the duplicated definitions for big-endian byteswapping
macros and big-endian types found in acls.h and security.h to the
appropriate locations in endians.h and types.h respectively in order to
make them available for the struct definitions in layout.h.
2015-10-03 12:58:08 +02:00
Jean-Pierre André
80e500c6ef Protected against opendir reinitialization in lownfs-3g
Under some condition (probably interference with another process), the
directory list gets reinitialized by releasedir() and opendir() at the
beginning of a partial buffer. So in readdir() skip to the requested
offset. This is a step towards implementing seekdir().
2015-09-30 09:35:17 +02:00
Jean-Pierre André
2f373dee56 ntfsprogs Builds on Windows use macroes to translate printing formats,
and these macroes redefined "buf" in a way which causes trouble when
"buf" has another meaning. Use "_b" instead.
2015-09-30 09:08:35 +02:00
Jean-Pierre André
800660f728 Displayed reparse point information in ntfsinfo
Added displaying of reparse point data and decode known formats.
2015-09-30 09:05:47 +02:00
Jean-Pierre André
9f22e17a16 Improved the check for a valid $MFTMirr
The test for a valid $MFTMirr could segfault on a badly damaged partition.
Add safety checks.
2015-09-30 09:02:15 +02:00
Jean-Pierre André
94f8d2128e Fixed a wrong test report in ntfsfix
When used with the "no-action" option, the test for self-located MFT
still reported the partition to have been repaired. Adapt the report to
only tell repairing is possible.
2015-09-30 08:54:27 +02:00
Jean-Pierre André
4a4ec8c1c6 Fixed a bad sanity check in ntfsfix
Fix misordered checks to avoid potential segfaults on badly damaged partitions.
2015-09-30 08:51:20 +02:00
Jean-Pierre André
267357899f Made secaudit to load the library based on its generic name
When compiled autonomously without the automatically generated dynamic
link stubs, use a generic library name instead of a version dependent one.
(obsolete compile mode rarely used).
2015-09-30 08:44:56 +02:00
Jean-Pierre André
9c2657b4ae Made use of fuse module cache on OpenIndiana
The fuse cache does not handle properly hard-linked files, so ntfs-3g
traditionally disables it by using a null time-out. With an upgrade of
the fuse kernel module on OpenIndiana, cacheing of non hard-linked files
is now possible, so use it.
2015-09-30 08:36:37 +02:00
Jean-Pierre André
5ebe36f10a Mentioned the starting sector when it overflows in mkntfs
In an NTFS boot sector, the first sector of the partition is limited to
32 bits and it may overflow on large disks. This field is only used for
booting on the partition and it is ignored by ntfs-3g, but the warning
in mkntfs mislead users, so improve it.
2015-09-30 08:25:25 +02:00
Jean-Pierre André
8a3c3c477c Used incremental offsets when reading a directory in lowntfs-3g
Using incremental offsets avoids misinterpreting readdir() as rewinddir().
It also makes possible to implement seekdir() [not done yet]
2015-09-30 08:18:13 +02:00
Jean-Pierre André
2c11aaa2aa Fixed the range of valid subauthority counts in a SID
ntfs_valid_sid() required that the subauthority count be between 1 and 8
inclusively.  However, Windows permits more than 8 subauthorities as well
as 0 subauthorities:

  - The install.wim file for the latest Windows 10 build contains a file
    whose DACL contains a SID with 10 subauthorities.
    ntfs_set_ntfs_acl() was failing on this file.

  - The IsValidSid() function on Windows returns true for subauthority
    less than or equal to 15, including 0.

There was actually already a another SID validation function that had the
Windows-compatible behavior, so I merged the two together.

Contributed by Eric Biggers
2015-07-14 08:37:01 +02:00
Erik Larsson
c9771d0509 unistr.c: Cleanup of OS X Unicode normalization code.
Normalize coding conventions to fit in with the rest of NTFS-3G,
including line breaks at column 80.
2015-06-23 06:43:17 +02:00
Erik Larsson
9a7bd25181 Skip installing manpages for mount helpers when they aren't available. 2015-06-23 06:27:33 +02:00
Erik Larsson
78ad037c66 Make installing mkntfs /sbin symlinks dependent on ENABLE_MOUNT_HELPER.
We shouldn't install anything into /sbin unless ENABLE_MOUNT_HELPER is
on, which is only true for Linux (these are Linux-specific symlinks).
2015-06-23 06:26:52 +02:00
Jean-Pierre André
99cb156ae5 Ported clearing the environment when starting mount or umount
When starting mount or umount, the environment was not cleared and
could be used for privilege escalation (CVE-2015-3202).
This is a port of the fix to full fuse by using execle(3) instead
of execl(3)
2015-06-01 12:48:43 +02:00
Jean-Pierre André
0d01fcabfc Implemented rewindind a directory in lowntfs-3g
Rewinding a directory is done by freeing the current list of files and
rebuilding it. Only seeking to the beginning of the list is implemented.
2015-04-17 11:38:33 +02:00
Jean-Pierre André
5741f54529 Zeroed uninitialized bytes before writing compressed data
Compressed records may be written as full clusters even though cluster
tails are meaningless. This is to avoid the lower levels doing a read-
modify-write cycle. Be sure to zero the meaningless bytes to avoid
leaking information.

Contributed by Eric Biggers
2015-04-17 11:31:47 +02:00
Jean-Pierre André
bd2c91d4a3 Packed/unpacked st_rdev transported as 32-bits on OpenIndiana 64-bits
On OpenIndiana 64-bits, st_rdev has major and minor as 32-bits wide each,
but the fuse protocol (common to 32-bit and 64-bit) has an st_rdev field
limited to 32-bit. For now, pack major and minor the same way as in the
32-bit variant (14 and 18 bits).
2015-04-17 11:22:49 +02:00
Jean-Pierre André
46716df541 Simplified NTFS ACLs when group same as owner and same permission as all
When the owner and the group of a file have the same SID, and permissions
for the group is the same as permissions for other, no ACE is needed for
the group.
2015-04-17 11:17:51 +02:00
Jean-Pierre André
3d1c87d0d9 Fixed setting SIG_DFL on fuse session exit
This is a backport of a fix applied to the (external) fuse library
2015-04-17 11:14:36 +02:00
Jean-Pierre André
e40b86a86c Upgraded the upper-case table as defined by Windows 7
Newer versions of Windows use more recent definitions of upper-case
table defined by the Unicode consortium. Now using the same table as
Windows 7, windows 8 and Windows 10. This only has an effect on file
systems newly created by mkntfs.
2015-04-17 11:03:58 +02:00
Jean-Pierre André
6a1c32e538 Fixed the DESX encryption/decryption in ntfsdecrypt
The DESX encryption/decryption algorithm was different from the Windows one.
2015-04-17 11:00:00 +02:00
Jean-Pierre André
e24ea68632 Removed a temporary debug comment (cosmetic)
The comment was a left over from some debugging action.
2015-04-17 10:56:34 +02:00
Jean-Pierre André
baab4c287e Added a sanity check to ntfswipe
Unused entries in the MFT may have a bad length leading to fetch fixups
from unallocated memory. Check the condition, but do not wipe, leave it
to chkdsk to decide what should be fixed.
2015-04-17 10:49:23 +02:00
Jean-Pierre André
b249246e9f Defended against reusing data from an invalid MFT record
An unused MFT record may show a bad length, leading to fetch fixups from
unallocated memory when allocating the record to a new file. So check
the length before applying the fixups. Such records have been found after
the MFT has been reallocated by a defragmenter, and they are not cleaned
by chkdsk.
2015-04-17 10:41:04 +02:00
Jean-Pierre André
8fb58de762 Updated the read-only flag even when the security attribute was cached
When chmod'ing a file, no new ACL has to be created if the one needed
is already present in the cache. However the read-only flag may have
to be updated, so that it is kept as the opposite of S_IWUSR.
2015-04-17 10:35:26 +02:00
Jean-Pierre André
d96ae8d7da Removed the double try to unmount partition in ntfsfix
When the unmounting of the partition fails after running ntfsfix, a
second try was attempted. This cannot be done and leads to more errors
because some essential records have been freed, so better quit without
making a second try.
2015-04-17 10:27:24 +02:00
Jean-Pierre André
9fc3730a9b Fixed displaying "UserMapping" as a file name
Fix the capitalization of the user mapping file name to be filled with
the output of secaudit with option -u.
2015-04-17 10:21:02 +02:00
Jean-Pierre André
1e8ae121fc Rephrased a misleading report message in ntfswipe
When using the "--no-action" option, ntfswipe should display a count
of would-be wiped bytes without suggesting any has been wiped.
2015-04-17 09:42:19 +02:00
Jean-Pierre André
e43f58e0e4 Avoided logging meaningless fixup errors in ntfswipe
As ntfswipe examines all MFT entries, it may find uninitialized ones.
They should not be considered as erroneous ones even if the fixups
are wrong.
2015-04-17 09:37:11 +02:00
Jean-Pierre André
e7b71bb78d Avoided mentioning deleted inodes in non-verbose output of ntfswipe
In non-verbose ntfswipe, avoid displaying deleted inodes as erroneous
ones.
2015-04-17 09:33:04 +02:00
Jean-Pierre André
25eb7a710b Added clarifications about several options to the ntfswipe manual
Clarified the usage of fast wiping, info and verbose options.
2015-04-17 09:26:59 +02:00
Jean-Pierre André
3fb1deb13b Fixed getting sector size from a partition image (Windows variant)
On Windows, when processing a partition image, get the sector size
from the boot sector instead of the containing partition.
2015-04-17 09:21:58 +02:00
Jean-Pierre André
4340df770e Supported the directory separator on Windows in ntfsprogs (cosmetic)
On Windows, when an ntfsprogs utility requests a path translation,
translate the '\'s to '/'s so that only '/' have to be interpreted
in libntfs.
2015-04-17 09:15:25 +02:00
Jean-Pierre André
bbeebd5a15 Rephrased the warning for trimming not supported (cosmetic)
The initial text looked like an error message
2015-04-17 09:06:22 +02:00
Jean-Pierre André
274b89cec9 Avoided truncation in a debug message in secaudit
When compiled for Windows 64-bit, pointers have to be displayed as
"long long" instead of "long" which is 32-bit
2015-04-17 09:03:08 +02:00
Erik Larsson
deeb0ad584 Version 2015.3.14. 2015-03-14 12:49:43 +01:00
Erik Larsson
807ee0f26c Enable ioctl in ntfs-3g unconditionally when building with fuse-lite.
fuse-lite announces a FUSE_VERSION which may not always match the exact
capabilities of the library. Hence we add a special case for 'ioctl',
which we know exists in fuse-lite regardless of the version number
published.
2015-03-14 11:11:43 +01:00
Erik Larsson
1ebf77f769 Fix improper #ifdef conditions around FUSE_CAP_IOCTL_DIR.
The capability actually appeared in FUSE 2.9, not 2.8. However in order
to maintain similarity to earlier #ifdef:s, we simpy check if
FUSE_CAP_IOCTL_DIR is defined rather than checking the FUSE version.
2015-03-14 06:53:31 +01:00