diff options
author | Thomas "Cakeisalie5" Touhey <thomas@touhey.fr> | 2019-02-07 17:25:14 +0100 |
---|---|---|
committer | Thomas "Cakeisalie5" Touhey <thomas@touhey.fr> | 2019-02-07 17:25:14 +0100 |
commit | 0db67b78f9c89950e4e0430f80012e549e8b4cfd (patch) | |
tree | fc759cdc684e2c897b6a91507a4f70fb93d9e278 | |
parent | 0b1c658563d3733d3342045d923f64334829442f (diff) |
Corrected some packaging mistakes.
-rw-r--r-- | MANIFEST.in | 2 | ||||
-rwxr-xr-x | Makefile | 2 | ||||
-rw-r--r-- | README.rst | 2 | ||||
-rwxr-xr-x | fingerd/__init__.py | 7 | ||||
-rwxr-xr-x | fingerd/_binds.py | 3 | ||||
-rwxr-xr-x | fingerd/control/__init__.py | 142 | ||||
-rw-r--r-- | setup.cfg | 4 |
7 files changed, 150 insertions, 12 deletions
diff --git a/MANIFEST.in b/MANIFEST.in index 45733cb..c62f63e 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -4,4 +4,4 @@ include MANIFEST.in include setup.py include setup.cfg -include fingerd.ini.template +include .env.template @@ -3,6 +3,8 @@ run: @pipenv run python -m fingerd +dist: + $(ST) sdist test tests: $(ST) test install: @@ -245,4 +245,4 @@ For further versions: .. _RFC 742: https://tools.ietf.org/html/rfc742 .. _RFC 1288: https://tools.ietf.org/html/rfc1288 -.. _a blog post of mine: #actually-it-is-still-a-work-in-progress +.. _a blog post of mine: https://thomas.touhey.fr/2018/09/12/finger.en.html diff --git a/fingerd/__init__.py b/fingerd/__init__.py index 7b7c877..c967e8f 100755 --- a/fingerd/__init__.py +++ b/fingerd/__init__.py @@ -75,7 +75,7 @@ def _get_server(): host = _environ.get('FINGER_HOST', 'LOCALHOST') iface = _environ.get('FINGER_TYPE', 'NATIVE').casefold() scpt = _environ.get('FINGER_ACTIONS', 'actions.toml') - src = _environ.get('FINGER_INCOMING', '/var/run/fingerd.ipc') + src = _environ.get('FINGER_INCOMING', 'ipc:///var/run/fingerd.sock') if iface == 'native': iface = _FingerNativeInterface() @@ -97,9 +97,10 @@ def _get_server(): def run(): """ Main function for the module. """ - # Non-interactive command line interface. + # Non-interactive command-line interface. - ap = _ArgumentParser() + ap = _ArgumentParser(prog = 'fingerd', + description = 'Finger (RFC 1288) server-side daemon.') args = ap.parse_args() # Get the server, run it. diff --git a/fingerd/_binds.py b/fingerd/_binds.py index 5d0294b..35d9bc7 100755 --- a/fingerd/_binds.py +++ b/fingerd/_binds.py @@ -207,6 +207,9 @@ class BindsDecoder: scheme, *rest = x.split(':/') if not rest: + # No scheme found, let's just guess the scheme based on + # the situation. + x = scheme scheme = {'finger': 'tcp', 'fingerd-control': 'ipc'}[proto] else: diff --git a/fingerd/control/__init__.py b/fingerd/control/__init__.py index 7354054..83bd37c 100755 --- a/fingerd/control/__init__.py +++ b/fingerd/control/__init__.py @@ -6,9 +6,11 @@ """ The `fingerd.control` submodule is a module for adding actions to the fingerd live interface. """ -__all__ = ["FingerLiveClient", "DELETE"] +from sys import stderr as _stderr +from argparse import ArgumentParser as _ArgumentParser -from .. import FingerUser as _FingerUser, FingerSession as _FingerSession +__all__ = ["run", + "FingerLiveClient", "DELETE"] # --- # The special DELETE value. @@ -29,9 +31,10 @@ class FingerControlClient: def __init__(self, url): # FIXME: open the connection. - raise NotImplementedError + pass - def create_user(self, user): + def create_user(self, login, name = None, home = None, shell = None, + office = None, plan = None): """ Create a user. """ raise NotImplementedError @@ -42,9 +45,138 @@ class FingerControlClient: raise NotImplementedError - def login(self, login, session): + def delete_user(self, login): + """ Delete a user. """ + + raise NotImplementedError + + def login(self, login, session = None, line = None, host = None): """ Login to a finger session. """ raise NotImplementedError + def idle(self, login, session = None): + """ Make the user idle on a finger session. """ + + raise NotImplementedError + + def active(self, login, session = None): + """ Make the user active again on a finger session. """ + + raise NotImplementedError + + def logout(self, login, session = None): + """ Log a user out of a finger session. """ + + raise NotImplementedError + +# --- +# The main function for the module. +# --- + +def run(): + """ Main function for the submodule. """ + + # Non-interactive command-line interface. + + ap = _ArgumentParser(prog = 'fingerd-control', + description = 'Control the fingerd daemon live interface.') + ap.add_argument('-t', '--to', help = 'interface provided by the daemon', + default = 'ipc:///var/run/fingerd.sock') + usap = ap.add_subparsers(metavar = 'any command', dest = 'command', + required = True) + ssap = usap # until i find out how to have “menus”, sorta… + + cap = usap.add_parser('create_user', help = 'create a user') + cap.add_argument('login', help = 'the user\'s login') + cap.add_argument('-n', '--name', help = "the user's name", + default = None) + cap.add_argument('-H', '--home', help = "the user's home directory", + default = None) + cap.add_argument('-s', '--shell', help = "the user's shell", + default = None) + cap.add_argument('-o', '--office', help = "the user's office", + default = None) + cap.add_argument('-p', '--plan', help = "the user's plan", + default = None) + + eap = usap.add_parser('edit_user', help = 'edit a user') + eap.add_argument('login', help = 'the user\'s login') + eap.add_argument('-n', '--name', help = "the user's name", + default = None) + eap.add_argument('-H', '--home', help = "the user's home", + default = None) + eap.add_argument('-s', '--shell', help = "the user's shell", + default = None) + eap.add_argument('-o', '--office', help = "the user's office", + default = None) + eap.add_argument('-p', '--plan', help = "the user's plan", + default = None) + + dap = usap.add_parser('delete_user', help = 'delete a user') + dap.add_argument('login', help = "the user's login") + + lap = ssap.add_parser('login', help = 'log in a user') + lap.add_argument('login', help = "the user's login") + lap.add_argument('session', help = "the session's identifier", + default = None, nargs = '?') + lap.add_argument('-l', '--line', help = "the user's physical line") + lap.add_argument('-H', '--host', help = "the remote host of the line") + + gap = ssap.add_parser('logout', help = 'log out a user') + gap.add_argument('login', help = "the user's login") + gap.add_argument('session', help = "the session's identifier", + default = None, nargs = '?') + + iap = ssap.add_parser('idle', help = "make a user go idle") + iap.add_argument('login', help = "the user's login") + iap.add_argument('session', help = "the session's identifier", + default = None, nargs = '?') + + aap = ssap.add_parser('active', help = "make a user go active") + aap.add_argument('login', help = "the user's login") + aap.add_argument('session', help = "the session's identifier", + default = None, nargs = '?') + + args = ap.parse_args() + args = vars(args) + + # Get the client and execute the command. + + ua = {} + if 'home' in args and args['home'] is not None: + ua['home'] = args['home'] + if 'name' in args and args['name'] is not None: + ua['name'] = args['name'] + if 'office' in args and args['office'] is not None: + ua['office'] = args['office'] + if 'plan' in args and args['plan'] is not None: + ua['plan'] = args['plan'] + if 'shell' in args and args['shell'] is not None: + ua['shell'] = args['shell'] + + sa = {} + if 'session' in args and args['session'] is not None: + sa['session'] = args['session'] + if 'line' in args and args['line'] is not None: + sa['line'] = args['line'] + if 'host' in args and args['host'] is not None: + sa['host'] = args['host'] + + clnt = FingerControlClient(args['to']) + if args['command'] == 'create_user': + clnt.create_user(args['login'], **ua) + elif args['command'] == 'edit_user': + clnt.edit_user(args['login'], **ua) + elif args['command'] == 'delete_user': + clnt.delete_user(args['login']) + elif args['command'] == 'login': + clnt.login(args['login'], **sa) + elif args['command'] == 'logout': + clnt.logout(args['login'], **sa) + elif args['command'] == 'idle': + clnt.idle(args['login'], **sa) + elif args['command'] == 'active': + clnt.active(args['logout'], **sa) + # End of file. @@ -22,8 +22,8 @@ zip_safe = False include_package_data = True packages = fingerd, fingerd.control scripts = - scripts/textout2html - scripts/textout2ls + scripts/fingerd + scripts/fingerd-control install_requires = toml |