Skip to content
This repository has been archived by the owner on Nov 28, 2018. It is now read-only.

Prior to this, the filemgr did not allow listing of an entire directory. #49

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dblessing
Copy link
Contributor

After applying this patch users will be able to do a basic directory listing
similar to the results obtained by running ls in Linux. Also, users can
receive more stats on each entry by using the -d details flag. The result is
more like ls -la in Linux.

Fixes R.I. suggested plus some optimizations

Add statuscode check

improve code readability

Finalizing changes

Cleanup

Minor conditional modification

Remove .swp

After applying this patch users will be able to do a basic directory listing
similar to the results obtained by running `ls` in Linux. Also, users can
receive more stats on each entry by using the -d details flag. The result is
more like `ls -l` in Linux.

Fixes R.I. suggested plus some optimizations

Add statuscode check

improve code readability

Finalizing changes

Cleanup

Minor conditional modification

Remove .swp
if File.directory?(dir)
begin
Dir.foreach(dir) do |entry|
directory[entry.to_sym] = get_file_status(File.join(dir, entry))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as this uses get_file_status() on each file and get_file_status fails the whole request if it cant get a file it means that trying to get the contents of any dir that is not readable fails.

Usually this is fine cos mcollective runs as root but if selinux for example denies access to the process you will get no results rather than say partial results.

% mco rpc filemgr list dir=/etc

devco.net-0                              Request Aborted
   Could not list directory '/etc': /etc/libaudit.conf - permission denied
   File details: {}

Also not sure if converting the filename to a symbol is needed here, eventually mcollective will switch to JSON and symbols in data like this wont work - safest to just keep those as strings now in the case where its a deep nested structure

@puppetcla
Copy link

Waiting for CLA signature by @bke-drewb

@bke-drewb - We require a Contributor License Agreement (CLA) for people who contribute to Puppet, but we have an easy click-through license with instructions, which is available at https://cla.puppetlabs.com/

Note: if your contribution is trivial and you think it may be exempt from the CLA, please post a short reply to this comment with details. http://docs.puppetlabs.com/community/trivial_patch_exemption.html

@puppetcla
Copy link

CLA signed by all contributors.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants