Commit Graph

4961 Commits

Author SHA1 Message Date
Jean-Pierre André
043b0e6e73 Allowed using full library API on systems without extended attributes support
A number of functions in libntfs-3g are generally useful, but are tied to
extended attributes support and are not included when the library is
built on platforms without extended attributes support.

This proposal updates libntfs-3g to always include these functions.

The only tricky part is dealing with the XATTR_CREATE and XATTR_REPLACE
flags.  These flags are defined in <sys/xattr.h>, so they must be
redefined on platforms without extended attributes support.

Signed-off-by: Eric Biggers <ebiggers3@gmail.com>
2016-07-28 16:13:59 +02:00
Jean-Pierre André
4264f19acb Cleaned up file name collation code
- Update documentation for COLLATION_RULES
- Document how ntfs_names_full_collate() compares names
- Update comments and DEBUG code to reflect that ntfs_names_full_collate()
  always access 'upcase', even in CASE_SENSITIVE mode
- Remove unneeded assignments to 'c1' and 'c2' in IGNORE_CASE mode

Signed-off-by: Eric Biggers <ebiggers3@gmail.com>
2016-07-28 16:10:14 +02:00
Jean-Pierre André
54b78660d7 Allowed dlopen API to be either in libc or libdl
On Linux, the functions in the dlopen API are in libdl.  However, on
FreeBSD, libdl doesn't exist and the functions are instead in libc.

Signed-off-by: Eric Biggers <ebiggers3@gmail.com>
2016-07-19 11:53:28 +02:00
Jean-Pierre André
0babe3c0db Made plugin.h include all prerequisite declarations
Only <plugin.h> to be included in plugins code.

Signed-off-by: Eric Biggers <ebiggers3@gmail.com>
2016-07-19 11:50:32 +02:00
Jean-Pierre André
68dec8ddbc Renamed include guard for plugin.h to _NTFS_PLUGIN_H
Be consistent with other NTFS-3G headers and use the "_NTFS_" prefix.

Signed-off-by: Eric Biggers <ebiggers3@gmail.com>
2016-07-19 11:49:04 +02:00
Jean-Pierre André
38ff4602a7 Cleared the sparse flags when clearing the bad cluster list
The bad cluster list may be updated in ntfsresize and ntfsfix. Though
technically it is organized as a sparse file, Windows does not set
the sparse flags. Do the same to avoid problems with third-party
packages.
2016-07-19 11:44:59 +02:00
Jean-Pierre André
191e47ff9d Tolerated garbage put by Windows 10 into the last ACE
For some reason, Windows 10 sometimes inserts garbage after the
last ACE of an ACL. The ACL consistency check has to tolerate this.
2016-07-19 11:40:20 +02:00
Jean-Pierre André
b973c0bd3c Compiled out conditionally debug-oriented code
Although ntfs_log_trace() is defined to a no-op in non-DEBUG builds,
ntfs_attr_name_get() is not.  This function performs a string conversion
and a memory allocation, so it is nice to have the call to it compiled
out when not needed.

Signed-off-by: Eric Biggers <ebiggers3@gmail.com>
2016-06-22 12:01:25 +02:00
Jean-Pierre André
5693341f0d Fixed ntfs_delete() failure caused by string conversion error
It was possible for ntfs_attr_name_get() to set errno due to a wide
character string that could not be converted to a multibyte string.  This
caused ntfs_delete() to fail.

Fix by checking for a nonzero return value specifically from
ntfs_attr_lookup(), rather than assuming that nothing else sets errno.

Signed-off-by: Eric Biggers <ebiggers3@gmail.com>
2016-06-22 11:58:20 +02:00
Jean-Pierre André
cf6f265069 Switch to using the standard autoconf AC_HEADER_MAJOR macro
Switch to the standard autoconf AC_HEADER_MAJOR macro which takes care
of the ugly details like when to use mkdev.h and when to use sysmacros.h.
(requires <sys/types.h> to be included)
Also include these in all files that use major/minor/makedev funcs.

(Contributed by Mike Frysinger)
2016-05-31 08:33:10 +02:00
Jean-Pierre André
e7c5950117 Silenced a truncation warning in upper case table
The upper case value for 0x1d79 is 0xa77d, so the difference is 0x8a04,
which overflows in the table which defines the computation of upper case
values. Rewriting this difference as -0x75fc leads to the same result
in an upper case table truncated to two bytes, and this avoid the
compiler warning.
2016-05-31 08:24:23 +02:00
Jean-Pierre André
08d3bcb2bf Ported patches to libfuse from the OpenIndiana variant
A few patches had been found useful to the OpenIndiana variant of libfuse
(2.7.6). Port them to libfuse-lite and restrict them to Solaris/OpenIndiana.
2016-05-04 10:15:35 +02:00
Jean-Pierre André
a7ce195489 383 Fixed masks for major and minor in fuse-lite for OpenIndiana
On Solaris/OpenIndiana, the major and minor fields in st_rdev have to
be represented on 14 bits and 18 bits respectively. They must have
the same representation on 32-bit and 64-bit builds as the kernel
and the library do not know the word size of each other.
2016-05-04 10:08:06 +02:00
Jean-Pierre André
34f7bd7ff0 Used <sys/mkdev.h> instead of <sys/sysmacros.h> on OpenIndiana
On Solaris/OpenIndiana, use the macroes makedev(), major() and minor()
from <sys/mkdev.h>. Those from <sys/sysmacros.h> are inappropriate for
current builds.
2016-05-04 10:03:39 +02:00
Jean-Pierre André
040153adcb Redefined ELIBBAD as ENOEXEC when missing
When a plugin cannot be initialized a ELIBBAD error is returned on Linux
and OpenIndiana. As this is not a Posix error code, use ENOEXEC on
systems which do not define ELIBBAD.
2016-05-04 09:59:18 +02:00
Jean-Pierre André
0ad352b40f Updated information about ntfsprogs to the README file
Added mentions of ntfssecaudit, ntfsusermap and ntfsrecover to the
README file.
2016-05-04 09:55:16 +02:00
Jean-Pierre André
4278fbb7f6 Defined an option to kill the Windows cache and play the log file
The new ntfsrecover option --kill-fast-restart can be used to delete
the Windows fast-restart indication before playing the log. This can
lead to data loss, but is needed before mounting a partition improperly
unmounted from Windows when remounting on Windows is inconvenient.
2016-05-04 09:47:51 +02:00
Jean-Pierre André
ab4bdea00f Rejected implicit mounting read-only when hiberfile option is present
If the remove_hiberfile mount option is present, explicitly disallow
the library from switching to a read-only mount. This is only to avoid
confusion, as the remove_hiberfile is processed before taking the
decision to fall back to read-only.
2016-05-04 09:39:48 +02:00
Jean-Pierre André
0c855fe36b Used Microsoft terminology for SID names
A few SIDs descriptions might be confusing because of a wording different
from Microsoft usage.
2016-05-04 09:33:42 +02:00
Jean-Pierre André
df01bf1b4d Displayed the SID revision as an unsigned number (cosmetic)
Properly display a SID revision if it should ever reach 128.
(suggested by Ulf Zibis)
2016-05-04 09:30:48 +02:00
Jean-Pierre André
1b8b599408 Checked the number of subauthorities before accessing them
Be more crash resistent when analyzing a badly formed SID.
(contributed by Ulf Zibis)
2016-05-04 09:27:32 +02:00
Jean-Pierre André
d587ff54f9 Fixed segmentation fault on empty $LogFile in ntfsrecover
ntfsrecover -f -v <log file> receives a SIGSEGV because of trying to
read memory outside allocated buffer because of no sanity checks on
restart page header values. This happens on an empty $LogFile because
of no basic checks present. Attached patch adds basic checks similar
to those inside logfile library and allows tool to exit with more
suitable message.
(contributed by Rakesh Pandit)
2016-05-04 09:24:51 +02:00
Jean-Pierre André
1840b52d12 Fixed a missing "break" in ntfssecaudit.c
A missing "break" in a case construct could be troublesome.
(suggested by Ulf Zibis)
2016-05-04 09:19:39 +02:00
Jean-Pierre André
df7f3b9151 Fixed indentation in ntfssecaudit.c (cosmetic)
There was an abusive indentation.
2016-05-04 09:15:43 +02:00
Erik Larsson
f0370bfa9c unistr.c: Unify the two defines NOREVBOM and ALLOW_BROKEN_SURROGATES.
In the mailing list discussion we came to the conclusion that there
doesn't seem to be any reason to keep these declarations separate since
they address the same issue, namely libntfs-3g's tolerance for bad
Unicode data in filenames and other UTF-16 strings in the file system,
so merge the two defines into the new define ALLOW_BROKEN_UNICODE.
2016-04-12 17:02:40 +02:00
Erik Larsson
d9c61dd60e unistr.c: Enable encoding broken UTF-16 into broken UTF-8, A.K.A. WTF-8.
Windows filenames may contain invalid UTF-16 sequences (specifically
broken surrogate pairs), which cannot be converted to UTF-8 if we do
strict conversion.

This patch enables encoding broken UTF-16 into similarly broken UTF-8 by
encoding any surrogate character that don't have a match into a separate
3-byte UTF-8 sequence.

This is "sort of" valid UTF-8, but not valid Unicode since the code
points used for surrogate pair encoding are not supposed to occur in a
valid Unicode string... but on the other hand the source UTF-16 data is
also broken, so we aren't really making things any worse.

This format is sometimes referred to as WTF-8 (Wobbly Translation
Format, 8-bit encoding) and is a common solution to represent broken
UTF-16 as UTF-8.

It is a lossless round-trip conversion, i.e converting from broken
UTF-16 to "WTF-8" and back to UTF-16 yields the same broken UTF-16
sequence. Because of this property it enables accessing these files
by filename through ntfs-3g and the ntfsprogs (e.g. ls -la works as
expected).

To disable this behaviour you can pass the preprocessor/compiler flag
'-DALLOW_BROKEN_SURROGATES=0' when building ntfs-3g.
2016-04-08 05:39:48 +02:00
Jean-Pierre André
ebdff7d4ee Deleted file secaudit.h
The declarations for compiling secaudit on Windows are not used any more
and can be dropped.
2016-04-07 09:36:01 +02:00
Jean-Pierre André
48e1c132c7 Removed declarations for using acls.c outside ntfs-3g
The declarations for using acls.c within secaudit on Windows are not used
any more and can be dropped.
2016-04-07 09:32:26 +02:00
Jean-Pierre André
3d7a28bfa5 Adapted secaudit and usermap (now ntfssecaudit and ntfsusermap) to ntfsprogs
These tools were originally developed for running on Windows and later
ported to libntfs-3g. This patch makes them similar to other ntfsprogs
tools, dropping the native Windows interfaces and using libntfs-3g on
all platforms.

There is no change in usage or supported features, only the command
names have changed.
2016-04-07 09:20:23 +02:00
Jean-Pierre André
0ded128808 Moved secaudit and usermap to directory ntfsprogs
These tools were developped before the ntfsprogs were merged into ntfs-3g,
redesigning them like the ntfsprogs make the code simpler.

Note : at this stage secaudit and usermap cannot be built any more.
2016-04-07 09:07:13 +02:00
Jean-Pierre André
7917a0a6cc Fixed indentation in ntfsclone help text (cosmetic)
The tabs in source code appear differently in actual output.
2016-04-06 11:09:35 +02:00
Jean-Pierre André
18a66b7a9a Fixed a spelling error in ntfsresize manual (cosmetic)
an other -> another
2016-04-06 11:07:30 +02:00
Jean-Pierre André
3cc22ba329 Moved general declarations from ntfsrecover.h to logfile.h
The declarations related to the log file structure are now grouped
in logfile.h, those specific to the recovery process are kept in
ntfsrecover.h
2016-04-06 11:03:31 +02:00
Jean-Pierre André
9693dd2fc1 Added a usn field to RESTART_PAGE_HEADER
Prepare merging ntfsrecover.h into logfile.h by adding a usn field to
RESTART_PAGE_HEADER. As this changes the record size, ignore the new
field in existing code.
2016-04-06 10:58:25 +02:00
Jean-Pierre André
60ba821ece Renamed reserved fields in ntfsrecover the same way as in logfile.h
Prepare merging ntfsrecover.h into logfile.h by naming reserved fields
the same way.
2016-04-06 10:54:51 +02:00
Jean-Pierre André
234cae2a1b Renamed record_length as log_record_header_length in ntfsrecover.h
Prepare merging ntfsrecover.h into logfile.h by naming the record
header length the same way.
2016-04-06 10:52:18 +02:00
Jean-Pierre André
b977f18c6e Renamed restart_offset as restart_area_offset in ntfsrecover.h
Prepare merging ntfsrecover.h into logfile.h by renaming the restart
offset the same way.
2016-04-06 10:50:31 +02:00
Jean-Pierre André
ad59ecec3f Redefined target_vcn on 64 bits in ntfsrecover.h
In a log record, the target vcn has to be stored on 64 bits
2016-04-06 10:45:30 +02:00
Jean-Pierre André
044f2104f9 Redefined file_offset on 64 bits in ntfsrecover.h
The log file offsets are apparently stored on 64 bits, though the file
size is unlikely to reach 2MB.
2016-04-06 10:40:28 +02:00
Jean-Pierre André
d947ffa834 Unfolded record headers in ntfsrecover the same way as in logfile.h
Prepare merging ntfsrecover.h into logfile.h by unfolding the record
headers the same way.
2016-04-06 10:38:06 +02:00
Jean-Pierre André
a6f4bae6d5 Typedef'ed new structs in ntfsrecover the same way as in logfile.h
Prepare merging ntfsrecover.h into logfile.h by declaring new structs
the same was as in logfile.h
2016-04-06 10:34:46 +02:00
Jean-Pierre André
2ab8bb509a Typedef'ed old structs in ntfsrecover the same way as in logfile.h
Prepare merging ntfsrecover.h into logfile.h by declaring duplicated
structs the same way
2016-04-06 10:32:39 +02:00
Jean-Pierre André
71b03fbd16 Redefined ntfsrecover enums as little-endian values
Rather than cpu-endian values, use little-endian ones in ntfsrecover
for similarity with layout.h
2016-04-06 10:26:46 +02:00
Jean-Pierre André
88451c8069 Made a full check for whether a user extended attribute is allowed
User extended attributes should only be set on files and directories,
not on symlinks, sockets, devices, etc. For safety they are also
forbidden on metadata files, but should be allowed on the root
directory. For files based on reparse points, requests are made
to the plugin to determine the type.
2016-04-06 10:17:27 +02:00
Jean-Pierre André
6cb8913967 Translated directory separators when running ntfscluster on Windows
Use \ as a directory separator when running on Windows.
2016-04-06 10:11:08 +02:00
Jean-Pierre André
31430ae01a Returned an error code for an exclusive access violation on Windows
Translate to Windows error code STATUS_SHARING_VIOLATION to Unix error
code EBUSY.
2016-04-06 10:08:01 +02:00
Jean-Pierre André
e8170f588f Fixed the maximum size of an ACL
Define the maximum size of an ACL as results from the maximum number of
sub-authorities defined in layout.h
2016-04-06 10:02:23 +02:00
Jean-Pierre André
6c768f215d Used a more portable way to force alignment in security.h
Defining an array of zero elements does not force alignment on some CPUs,
insert a filler.
2016-04-06 09:57:59 +02:00
Jean-Pierre André
8a1358fff4 Enabled fallback to read-only mount when volume is hibernated
When a volume is found hibernated (or prepared for fast restarting),
it is force-mounted as read-only.
2016-04-06 09:51:47 +02:00
Jean-Pierre André
887d8f8294 Allowed kernel cacheing by lowntfs-3g when not using Posix ACLs
Kernel cacheing of file attributes is usually not used by ntfs-3g,
because it has defects when dealing with hard linked files and directory
permission checks. Kernel cacheing is however possible when using
lowntfs-3g and not using Posix ACLs.
2016-04-06 09:44:59 +02:00