fcust package

Submodules

fcust.cli module

Console script for fcust.

fcust.fcust module

Main module.

class fcust.fcust.CommonFolder(folder_path: pathlib.PosixPath, common_group: str = '')[source]

Bases: object

Main class regarding management of a folder that is commonly used across many users.

  • The class creates a logfile at /tmp/fcust/$USER.log

  • By default the class assumes that the root of the common folder is configured correctly and then tries to enforce appropriate permissions.

Parameters
  • folder_path – Path where the common folder is located.

  • common_group – Group name regarding the common folder. If not passed the existing group of the folder will be assumed to be the proper folder.

enforce_permissions()[source]

We read the contents of a specified directory and enforce unix permissions.

Files should have 664 permissions Folders should have 2775 permisions (ie also setguid bit) Group should be common golder’s group.

The function only changes permissions if the user is owner of the relevant resource. This is done to avoid the need for root access, but requires the function to be run by all the users sharing the common folder.

fcust.fcust.create_logger(cgroup: str, lpath: str = '/tmp/fcust/')[source]

Function that creates a modified logger to cater fcust functionality.

Parameters

cgroup – group ownership of the main directory

fcust.service module

Utilities for Folder Custodian Service.

fcust.service.activate_service()[source]

After a fcust setup is run we need to activate the service we installed.

fcust.service.create_fcust_service_unit(folder_path: pathlib.PosixPath, unit_path: pathlib.PosixPath)[source]

Create a systemd user unit for folder cutodian. Use predefined template and modify where needed.

We want the service to run when the user logs out so that all the changes they made are fixed if needed. We consult the following sources to create the appropriate systemd service template:

Parameters
  • folder_path – Path where the common folder is located.

  • unit_path – Path where the common folder is located.

fcust.service.create_user_unit_path(create_folder: bool = False)[source]

We want to add a systemd user unit to run fcust on certain times. In order to do this we want to crete a unit at a proper location. According to: https://wiki.archlinux.org/index.php/Systemd/User our options are:

  • /usr/lib/systemd/user/:

    where units provided by installed packages belong.

  • ~/.local/share/systemd/user/

    where units of packages that have been installed in the home directory belong.

  • /etc/systemd/user/

    where system-wide user units are placed by the system administrator.

  • ~/.config/systemd/user/

    where the user puts their own units.

We opt to use the latter choice.

This function constructs the proper systemd user unit path where it will be installed. It also creates the necessary folder if it doesn’t exist.

Parameters

create_folder – If true create the folder that the unit service will be installed.

Returns

Path object for the location the unit service will be installed.

fcust.service.deactivate_service()[source]

Deactivate a running fcust service.

Module contents

Top-level package for Folder Custodian.