Commit Graph

554 Commits

Author SHA1 Message Date
Jean-Pierre André
688578c1a6 Removed <linux/fs.h> from lowntfs-3g.c
The headers from <linux.fs.h> now conflicts with <sys/uio.h> and are
not needed any more, so remove them.
2020-03-07 11:50:26 +01:00
Jean-Pierre André
32c27a8a4f Defined the request argument of ioctl() as unsigned long
On linux the request argument of ioctl() is defined as an unsigned long,
but the fuse protocol squashes it into a signed int. As a consequence
the value received by ntfs-3g may appear as negative and different from
the value defined by the corresponding macro.
So define the request argument as unsigned long in ntfs-3g. It has
however to be fed as unsigned from fuse until the fuse protocol is
updated.
2020-03-07 10:31:12 +01:00
Jean-Pierre André
3433dd0b3c Updated the copyright notice
Updated the copyright notice to 2019
2020-03-07 10:18:01 +01:00
Jean-Pierre André
facb697303 Fixed reacting to missing plugin
When a plugin is missing, dlopen() does not set errno, which leads
to erratic behavior. Set errno as ELIBACC when this occurs.
2019-01-23 17:33:15 +01:00
Jean-Pierre André
7a3ed93463 Reverted accessing reparse directories through internal plugins
As similar reparse tags are being used for accessing OneDrive files
and directories, a similar policy has to be used for accessing them.
Until giving full access to OneDrive files with a local copy is
mature enough to have it processed internally, it is safer to have
it delegated to an external plugin. This reverts [4f450a]
2019-01-23 17:13:12 +01:00
Jean-Pierre André
da39fbf24a Fixed reporting an error when setxattr is rejected
When permissions are enabled and setxattr() is rejected, an error
must be returned even though the option silent is set. This is needed
for "cp -p" to know it has to try setting the permissions again and use
chmod().
2018-12-19 16:01:53 +01:00
Jean-Pierre André
85c1634a26 Fixed reporting an error when failed to build the mountpoint
The size check was inefficient because getcwd() uses an unsigned int
argument.
2018-12-19 15:57:50 +01:00
Jean-Pierre André
4f450a35f5 Made accessing reparse directories through internal plugins
When the bit 28 of a reparse tag is set on a directory, the reparse
information should be ignored and the directory should be accessed
the usual way (this setting is new to Windows 10). In such a situation
access to the directory through an internal plugin rather than through
an external one.
The same policy applies to REPARSE_TAG_WCI which had been defined
earlier without the bit 28 being set.
2018-06-01 16:08:33 +02:00
Jean-Pierre André
3243e62396 Supported reparse tags for OneDrive cloud storage
Newer versions of Windows 10 use several reparse tags for files which
are synchronized to OneDrive cloud storage (0x9000301a, 0x9000601a,
0x9000701a, ...). identify them as IO_REPARSE_TAG_CLOUD and use a
single plugin to process them.
2018-01-15 11:04:29 +01:00
Jean-Pierre André
d99a376a90 Documented read-only mount when Windows is hibernated
Document an earlier update which forced read-only mode when mounting
a partition which has been left by Windows in an inconsistent state
through hibernation or fast restarting.
2017-12-22 11:26:08 +01:00
Erik Larsson
a0bc659c7f lowntfs-3g.c: Fix compile error when struct stat doesn't have st_*tim.
The struct members for the time fields in struct stat vary depending on
platform, so introduce #ifdefs using the config.h-supplied definitions
for determining which stat time definition is appropriate.
2017-09-20 04:56:06 +02:00
Jean-Pierre André
4128e9da58 Logged falling back to mounting read-only
When the ntfs image is unclean, usually because it was not unmounted
properly from Windows, mounting read-write is denied and falls back
to read-only. Log this situation in the syslog, so that users mounting
through /etc/fstab can more easily know what is going on. Also remove
the "rw" option if it was stated.
2017-08-11 09:56:44 +02:00
Jean-Pierre André
1611b21908 Enabled directory operations in plugins
Windows 10 brought a new type of reparse point for directories (0x80000018),
so add opendir() and readdir() to the plugin interface to take directories
into account. The interface for releasedir() is merged with release() as
the plugins can discriminate them if needed.
2017-08-11 09:42:37 +02:00
Jean-Pierre André
0595f888ae Version 2017.2.15 2017-02-15 17:04:57 +01:00
Jean-Pierre André
a07b7edebd Loaded the fuse kernel module with no environment
Avoided leaking the current environment when loading the fuse kernel
module
2017-02-11 11:03:02 +01:00
Jean-Pierre André
17b56ccfa2 Allowed names with trailing dot or space on conditions
Windows places filenames with a trailing dot or space in the Win32
namespace and allows setting DOS names on such files.  This is true even
though on Windows such filenames can only be created and accessed using
WinNT-style paths and will confuse most Windows software.  Regardless,
because libntfs-3g did not allow setting DOS names on such files, in
some cases it was impossible to correctly restore, using libntfs-3g, a
directory structure that was created under Windows.

Update ntfs_set_ntfs_dos_name() to permit operating on a file that has a
long name with a trailing dot or space.  But continue to forbid creating
such names on a filesystem FUSE-mounted with the windows_name option.
Additionally, continue to forbid a trailing a dot or space in DOS names;
this matches the Windows behavior.

(contributed by Eric Biggers)
2017-02-11 10:54:51 +01:00
Jean-Pierre André
1178a7a801 Fixed setting opening contexts for plugins
The opening context was incorrectly passed to plugins by lowntfs-3g

(contributed by Eric Biggers)
2017-02-11 10:44:02 +01:00
Jean-Pierre André
d69d2d9a1f Got ready for Posix ACL support in fuse kernel
Following a recent patch to the fuse kernel, the Posix ACL checks can
be done within the kernel instead of having to be done in the file
system, provided lowntfs-3g is used.

This mode is still not used by default until the fuse patch is
released by distributions.
2017-02-11 10:21:07 +01:00
Jean-Pierre André
35cb222233 Removed unused argument from ntfs_make_symlink()
Now that the size of the reparse point attribute is no longer used by
the FUSE drivers to populate st_size for symlinks and junctions, it no
longer needs to be returned by ntfs_make_symlink().

(contributed by Eric Biggers)
2017-02-11 10:11:01 +01:00
Jean-Pierre André
051a4b556b Returned the size of locale encoded target as the size of symlinks
Made ntfs-3f conform to the standard POSIX convention of setting st_size
to the length of the symlink target without a terminating null.

(contributed by Eric Biggers)
2017-02-11 10:04:15 +01:00
Jean-Pierre André
b337582d36 Fixed DISABLE_PLUGINS as the condition for not using plugins
The condition for using plugins did not match the definition by
./configure
2017-02-11 09:33:27 +01:00
Jean-Pierre André
c314a8115b Fixed nesting when not using plugins
The logical nesting (defined by {...}) did not match the physical nesting
(defined by #ifdef...#endif)
2017-02-11 09:26:58 +01:00
Jean-Pierre André
fa0a7a5686 Logged more information when a plugin could not be loaded
Put the explanation from dlerr() into the syslog when a plugin could
not be loaded.
2017-02-11 09:15:33 +01:00
Jean-Pierre André
28c479af6a Denied creating/removing files or directories from $Extend
$Extend is a directory reserved for metadata specific to Windows.
Inserting other files or directories there leads to problems with
some Windows versions.
2017-02-11 09:00:49 +01:00
Jean-Pierre André
d4dfa18f7d Corrected code with misleading indentation
GCC 6 reports a warning in ntfs_allowed_dir_access() because the code has
misleading indentation.  Fix by adding braces.  There is no actual change
in behavior because of the '(allowed == 2)' condition.

Signed-off-by: Eric Biggers <ebiggers3@gmail.com>
2016-07-28 16:30:05 +02:00
Jean-Pierre André
2840e84a97 Always opened $Secure when mounting NTFS volume
Currently, applications that wish to access security descriptors have to
explicitly open the volume's security descriptor index ("$Secure") using
ntfs_open_secure().  Applications are also responsible for closing the
index when done with it.  However, the cleanup function for doing,
ntfs_close_secure(), cannot be called easily by all applications because
it requires a SECURITY_CONTEXT argument, not simply the ntfs_volume.
Some applications therefore have to close the inode and index contexts
manually in order to clean up properly.

This proposal updates libntfs-3g to open $Secure unconditonally as part
of ntfs_mount(), so that applications do not have to worry about it.

This proposal updates libntfs-3g to open $Secure unconditonally as part
of ntfs_mount(), so that applications do not have to worry about it.

ntfs_close_secure() is updated to take in a ntfs_volume for internal use,
and ntfs_destroy_security_context() is now the function to call to free
memory associated with a SECURITY_CONTEXT rather than a ntfs_volume.

Some memory leaks in error paths of ntfs_open_secure() are also fixed.

Signed-off-by: Eric Biggers <ebiggers3@gmail.com>
2016-07-28 16:22:16 +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é
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é
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é
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é
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é
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é
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é
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é
da33b0328f Used plugins to process reparse points
The new "system compression" files used by Windows 10 make use of reparse
points to record the compression parameters, and a specific named data
stream is used to store the compressed data. With this patch, processing
of reparse points can be done by an external plugin only loaded as needed.
Junctions and symlinks, which are also based on reparse points, are now
processed by "internal plugins".
2016-04-06 09:10:35 +02:00
Jean-Pierre André
f655192f26 Updated the drivers copyrights
Extend the copyright to 2016
2016-02-12 17:24:27 +01:00
Erik Larsson
f463919310 ntfs-3g_common.h: Fix improper type for 'dmtime' in ntfs_fuse_context_t.
This field is always assigned a signed value, and compared to other
signed values (ntfs_time values are signed little-endian 32-bit
integers).

This fixes two compiler warnings about signed/unsigned comparison.
2016-02-11 14:06:53 +01:00
Erik Larsson
9893ea9ee6 Merge endianness fixes.
Conflicts:
	libntfs-3g/attrib.c
2016-01-28 09:22:42 +01:00
Erik Larsson
02ce4947df ntfs-3g.c: Fix raw usage of inode time fields without byteswapping. 2016-01-26 07:55:45 +01:00
Erik Larsson
9cf04fd2cd Fix incorrect usage of native/little-endian types, signed types, etc.
This is harmless with regard to code generation but if we turn on strict
type checking these type mismatches will result in errors.
2015-12-21 23:55:31 +01:00
Erik Larsson
dfa4a6647f Fix code to use const_cpu_to_X/const_X_to_cpu macros for constants.
This enables the compiler to optimize this code in cases where compiler
support for endianness swapping is not present.
2015-12-21 23:21:00 +01: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é
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é
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
Erik Larsson
9a7bd25181 Skip installing manpages for mount helpers when they aren't available. 2015-06-23 06:27:33 +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é
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é
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