Skip to content

Commit

Permalink
0.0.2 release
Browse files Browse the repository at this point in the history
  • Loading branch information
s-m-e committed Apr 23, 2019
2 parents 3017deb + 6eef19d commit d91e346
Show file tree
Hide file tree
Showing 16 changed files with 747 additions and 457 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ celerybeat-schedule
# virtualenv
venv/
ENV/
env*/

# Spyder project settings
.spyderproject
Expand Down
10 changes: 10 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
Changes
=======

0.0.2 (2019-04-23)
------------------

* FEATURE: New flag ``-j`` for JSON-formatted log output
* FEATURE: New field ``command`` allowed in XML configuration files for filtering for command strings with regular expressions
* FEATURE: All fields in ``include`` and ``exclude`` tags, e.g. ``extension`` or ``uid``, become optional / implicit and can be omitted.
* FEATURE: (UNTESTED) Mac OS X support. Test framework still relies on Linux.
* FIX: Several implementations of FUSE calls such as truncate did rely on the assumption that the current working directory of the file system process would not change. This was risky. LoggedFS-python does also NOT change the current working directory anymore on its own.
* Code cleanup

0.0.1 (2019-04-11)
------------------

Expand Down
16 changes: 7 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ CAVEATS
UTIME_OMIT WILL NOT BE HONORED. THERE WAS A `PULL REQUEST`_ TO FIX THIS,
WHICH HAS BEEN REJECTED. ALTERNATIVE APPROACHES ARE BEING RESEARCHED.
* THE FILESYSTEM IS CURRENTLY **ONLY** BEING DEVELOPED FOR AND TESTED ON **LINUX**.
ANYONE INTERESTED IN ADDING MAC OS X AND/OR BSD SUPPORT?
ANYONE INTERESTED IN CONFIRMING MAC OS X AND/OR ADDING BSD SUPPORT?

.. _CUSTOM BUG-FIXED VERSION OF FUSEPY: https://github.com/s-m-e/fusepy
.. _PULL REQUEST: https://github.com/fusepy/fusepy/pull/79
Expand All @@ -88,7 +88,7 @@ From GitHub:
**Supports Python 3.{4,5,6,7}.**

**Supports Linux.**
Support for MAC OS X and BSD requires a minor change only, but has yet not been added: Access to the system log is currently being achieved through ``logging.handlers.SysLogHandler(address = '/dev/log')``, a Linux-only solution.
Support for MAC OS X is implemented but has yet not been tested.

.. _Python Package Index: https://pypi.org/

Expand All @@ -112,9 +112,7 @@ To stop recording, just unmount as usual:
Configuration
=============

LoggedFS-python can use an XML configuration file if you want it to log
operations only for certain files, for certain users, or for certain operations.
The format is fully compatible with LoggedFS' original format.
LoggedFS-python can use an XML configuration file if you want it to log operations only for certain files, for certain users, or for certain operations. LoggedFS-python is fully compatible with configuration files in LoggedFS' original format. Yet it can also handle additional fields (e.g. the ``command`` field).

Here is a sample configuration file :

Expand All @@ -124,12 +122,12 @@ Here is a sample configuration file :
<loggedFS logEnabled="true" printProcessName="true">
<includes>
<include extension=".*" uid="*" action=".*" retname=".*"/>
<include extension=".*" uid="*" action=".*" retname=".*" command=".*"/>
</includes>
<excludes>
<exclude extension=".*\.bak$" uid="*" action=".*" retname="SUCCESS"/>
<exclude extension=".*" uid="1000" action=".*" retname="FAILURE"/>
<exclude extension=".*" uid="*" action="getattr" retname=".*"/>
<exclude extension=".*\.bak$" uid="*" action=".*" retname="SUCCESS" command=".*"/>
<exclude extension=".*" uid="1000" action=".*" retname="FAILURE" command=".*"/>
<exclude extension=".*" uid="*" action="getattr" retname=".*" command=".*"/>
</excludes>
</loggedFS>
Expand Down
3 changes: 3 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ destroy_parentfs:
python3 -c 'import tests; tests.lib.quick_cli_destroy_parentfs()'
destroy_childfs:
python3 -c 'import tests; tests.lib.quick_cli_destroy_childfs()'
destroy_force:
-sudo fusermount -u tests/test_mount/test_child
-sudo umount tests/test_mount

test:
make test_posix
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@


# Bump version HERE!
_version_ = '0.0.1'
_version_ = '0.0.2'


# List all versions of Python which are supported
Expand Down
61 changes: 22 additions & 39 deletions src/loggedfs/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,10 @@
# IMPORT
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

from collections import OrderedDict
import click

from .core import loggedfs_factory

import click
import xmltodict
from .filter import parse_filters


# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Expand Down Expand Up @@ -64,15 +62,19 @@
)
@click.option(
'-l',
# type = click.File(mode = 'a'),
type = click.Path(file_okay = True, dir_okay = False, resolve_path = True),
help = ('Use the "log-file" to write logs to.')
)
@click.option(
'-j', '--json',
is_flag = True,
help = 'Format output as JSON instead of traditional loggedfs format.'
)
@click.argument(
'directory',
type = click.Path(exists = True, file_okay = False, dir_okay = True, resolve_path = True)
)
def cli_entry(f, p, c, s, l, directory):
def cli_entry(f, p, c, s, l, json, directory):
"""LoggedFS-python is a transparent fuse-filesystem which allows to log
every operations that happens in the backend filesystem. Logs can be written
to syslog, to a file, or to the standard output. LoggedFS comes with an XML
Expand All @@ -84,7 +86,7 @@ def cli_entry(f, p, c, s, l, directory):

loggedfs_factory(
directory,
**__process_config__(c, l, s, f, p)
**__process_config__(c, l, s, f, p, json)
)


Expand All @@ -93,48 +95,29 @@ def __process_config__(
log_file,
log_syslog_off,
fuse_foreground_bool,
fuse_allowother_bool
fuse_allowother_bool,
log_json
):

def proc_filter_item(in_item):
return {
'extension': in_item['@extension'],
'uid': in_item['@uid'],
'action': in_item['@action'],
'retname': in_item['@retname']
}

def proc_filter_list(in_list):
if in_list is None:
return []
if not isinstance(in_list, list):
return [proc_filter_item(in_list)]
return [proc_filter_item(item) for item in in_list]

config_dict = OrderedDict({
'@logEnabled': True,
'@printProcessName': True,
'includes': {},
'excludes': {}
})

config_file = None
if config_fh is not None:
config_file = config_fh.name
config_dict.update(xmltodict.parse(config_fh.read())['loggedFS'])
config_xml_str = config_fh.read()
config_fh.close()
config_file = config_fh.name
else:
config_file = '[None]'
config_xml_str = None

for f_type in ['includes', 'excludes']:
config_dict[f_type] = proc_filter_list(config_dict[f_type].get(f_type[:-1], None))
config_dict = parse_filters(config_xml_str)

return {
'log_includes': config_dict['includes'],
'log_excludes': config_dict['excludes'],
'log_includes': config_dict['log_includes'],
'log_excludes': config_dict['log_excludes'],
'log_enabled': config_dict['log_enabled'],
'log_printprocessname': config_dict['log_printprocessname'],
'log_file': log_file,
'log_syslog': not log_syslog_off,
'log_configmsg': 'LoggedFS-python using configuration file %s' % config_file,
'log_enabled': config_dict['@logEnabled'],
'log_printprocessname': config_dict['@printProcessName'],
'log_json': log_json,
'fuse_foreground_bool': fuse_foreground_bool,
'fuse_allowother_bool': fuse_allowother_bool
}
Loading

0 comments on commit d91e346

Please sign in to comment.