Age | Commit message (Collapse) | Author | Files | Lines |
|
Two of the new tests re: Uniquefile are not compatible with
windows. (In the ruby source tree, they are skipped on windows.)
This commit confines them to only run on unix.
|
|
This commit adds additional tests for the Uniquefile class. The
new tests are ported from the Ruby 1.9.3 source code for the
built-in `Tempfile` class, since that is what our `Uniquefile`
implementation is based on.
See: https://github.com/ruby/ruby/blob/v1_9_3_547/test/test_tempfile.rb
|
|
Since the new implementation of Puppet::FileSystem::Tempfile is
not trying to manage the deletion of files created through it,
the name was misleading. This commit simply changes the name
to Uniquefile to try to make it a bit more obvious that it is
not responsible for deleting the files.
|
|
This starts the process of creating a Puppet::Environments::Directory
that will find environments from a particular directory. The directory
has sub-directories, where each sub-directory name is the environment
name.
|
|
* pr/2168:
(PUP-1150) Fix race condition in Puppet::Util::Lockfile.
This closes GH-2168.
|
|
Before this commit, Puppet::Util::Lockfile.lock called the locked?
method before opening the @lockfile for write. Checking that the file
doesn't exist and creating the file were not an atomic operation, which
allowed two processes to detect that the file didn't exist and open it
for write simultaneously.
This commit adds and used Puppet::FileSystem::exclusive_create wrapper
that sets the following options:
* File:CREAT - Creates the file if it doesn't exist.
* File:EXCL - Fails if the file does exist.
* File:WRONLY - Opens the file for write only.
File:EXCL is the important option, callers will recieve an Exception if
the file exists, meaning another process has acquired the lock. If the
file doesn't exist it will be created atomically, so other another
caller cannot create the file in the gap.
|
|
|
|
File system changes ensure that Strings get converted to Pathnames; so
the Puppet::Util::Windows::File.stat call needs to expect a Pathname now.
|
|
|
|
|
|
This refactors the file_system/file_spec to comply with the new API.
Several problems found with the implementation.
* Bad include of memory_impl
* facade methods did not relay to _impl
* assert_path did not consider objects coercable to string
(e.g.watched file)
|
|
- Windows symlinks, when targeted at directories, do not get cleaned up
if not unlinked, even when going through the global tmpfile
|
|
Tempfile.open, at least under Ruby 1.8, only does a File#close;
File#unlink is deferred to a lambda that executes in a finalizer when
the file is garbage collected. This can lead to issues, as it did with
Puppet::SSL::AutosignCommand code, where root opens a tempfile, and
the finalizer doesn't happen until after we've dropped
privileges...leading to an almost impossible to find permission failure.
This commit adds a Puppet::FileSystem::Tempfile with an open that
ensures we close and unlink before returning to the caller. And we
update the autosign_command code to use it.
|
|
Previously, when managing a file with a source parameter pointing to a
local file, the file resource and file serving code would try to call
`Puppet::FileSystem::File.lstat`, without knowing if the path referred
to a link or not. In other words, the method can be called on things
other than a link, and shouldn't fail when symlinks aren't supported,
i.e. windows 2003.
We could change all of the callers to check if the path is a link and
then only call `lstat`, but that seemed more risky. This commit just
changes the windows `lstat` method to fall back to stat in the 2003
case.
|
|
- Replace calls to the specific :file provider with the global
Puppet.features call
|
|
- Windows symlink support has been added to exist?, symlink, symlink?,
readlink, stat, and lstat. This overrides any usage of Ruby File or
FileTest classes which are completely borked on Windows.
- :manages_symlinks feature of the file provider is enabled with a
check against Puppet.features.manages_symlinks? which checks for the
existence of the CreateSymbolicLink call in kernel32.dll
- FFI wrappers for Win32 API calls CreateSymbolicLink, CreateFile,
GetFileAttributes, DeviceIoControl and CloseHandle added to
windows/file
NOTE: The DeviceIoControl method of resolving symlinks was used
instead of GetFinalPathNameByHandle, which is known to misbehave
with UNC paths
- Any tests against :manages_symlinks feature are automatically turned
on for Windows, increasing test count by approximately 42 new tests
- Removed a few symlink tests that were confined to any OS other than
Windows since they must now be adjusted to run on Windows versions
that we know support symlinks
- Updated symlink documentation based on ileUtils.symlink behavior
|
|
The previous commit contained bad formatting since I wrote it on a
machine with a stock vim (tabs and wrong indentation). This also removes
a forgotten debugging message in a spec.
|
|
It appears that solaris has different file semantics from OSX and Linux.
* flock() is allowed on the same file from the same process. On linux
this ends up with a block of the second invocation of flock().
* flock() is not allowed on a file that is opened for read-only.
* fopen() with "a" causes a read to occur at the end of the file. On
linux the read is at the beginning of the file.
|
|
It is possible that the process is never able to aquire a lock. In that
case we don't want to block the process forever. There was also a
horrible performance characteristic from doing a busy loop while waiting
for the lock.
|
|
We have to skip these tests on Windows because fork is not supported.
|
|
Ruby 1.8 does not have the same ::File constants as ruby 1.9
(specifically it did not have ::File::BINARY). Instead of using those
constants, the File abstraction will instead use the character-based
file modes (r, r+, w, w+, wb, etc.).
Pathname on ruby 1.8 also does not support binread. To deal with this,
the File now has 2 subclasses File18 and File19 to handle the
differences on the different systems. The File::new method is now a
factory for the appropriate subclass.
|
|
Over time we have accumulated various file manipulation operations that
either deal with platform differences of the standard ruby calls or
introduce more useful abstractions for us on top of the ruby calls.
That code has not had a good place to live. Sometimes it appeared on
certain classes, never to be found for use in other areas of the code.
Other times it has been added to the ever growing Puppet::Util mess.
This introduces Puppet::FileSystem::File, which should be used as our
abstraction over ruby's File. We should strive to have it keep a minimal
interface that is geared towards the operations that puppet performs on
files. Inspiration for how to grow it should come, primarily, from uses
found in the puppet codebase as well as from other FS abstraction
systems (such as EFS from eclipse).
This iteration of Puppet::FileSystem::File grew from the file operations
that were done in the filebucket code.
|
|
Was calling relative with an absolute url. Moved to the absolute
section.
|
|
The PathPattern code was incorrectly flagging paths like /tmp/foo..bar
as being directory traversals. This updates that to exclude those names
by checking each path component separately instead of looking at the
path as a whole.
In addition this fixes up the error reporting about these kinds of
errors in Puppet::Module by creating the absolute PathPattern for the
manifests directory of the module at initialization time, so that any
errors from it are not swallowed by the error handling for the relative
path searching of manifests.
This also removed some duplicate handling of init.pp and init.rb where
in the case of having no pattern to search for the init files were
returned twice and also seemed to be loaded twice. This does not remove
the behavior in which the init.pp and rb files are *always* returned
when they exist, because that seems to be explicit behavior added for
issue #4220.
|
|
Correctly checking that a given string is safe to use for looking for
files on the filesystem is tricky. This adds a class called
Puppet::FileSystem::PathPattern that encapsulates a validated path
pattern free of defects such as directory traversal '..' entries and
zero byte delimeters. This is then used to protect finding manifest
files in modules.
|