Skip to main content
Warning: You are using the test version of PyPI. This is a pre-production deployment of Warehouse. Changes made here affect the production instance of TestPyPI (testpypi.python.org).
Help us improve Python packaging - Donate today!

Wrapper to use keyctl command in Python

Project Description

python-keyctl

Basic management of keys in the Linux kernel keyring in Python. Also comes with a small gui.

Description

This is a small library to make use of some functions of the kernel keyring in Python. You can read, add and delete keys.

It simply uses the keyctl command (invoking it via subprocess), so this util must be installed.

Available functions:

  • list (list all keys in keyring)
  • describe (retrieve key name/description)
  • read/pipe/print (retrieve key content)
  • update (modify key content)
  • add (add key)
  • revoke/unlink (delete key)
  • search/request (search for a key by name)
  • clear (remove all keys from keyring)

There are many more functions with keys in the kernel keyring (e.g. permissions) that is needed for proper keymanagement. But for my usecase I just needed the given simple functionality.

Requirements

Python 2.7

$ sudo apt-get install python2.7
$ python --version
Python 2.7.3

pip

$ sudo apt-get install python-pip
$ pip --version
pip 9.0.1 from .... (python 2.7)

The ‘keyctl’ command

$ sudo apt-get install keyutils
$ dpkg -s keyutils | grep Version
Version: 1.5.2-2

For the GUI you also need:

Qt4

$ sudo apt-get install qt4-qmake libqt4-core libqt4-dev

PySide

$ sudo apt-get install python-qt4 python-pyside
$ python -c "import PySide; print PySide.__version__"
Version: 1.1.0

Installation

$ pip install keyctl

Ready to use.

Usage

Module

Get all keys:

from keyctl import Key
keylist = Key.list()
for mykey in keylist:
    print mykey.id

Read existing key:

from keyctl import Key
mykey = Key(123)
print mykey.name
print mykey.data
print mykey.data_hex

Find key by name:

from keyctl import Key
mykey = Key.search('test key')
print mykey.id

Add key:

from keyctl import Key
mykey = Key.add('test key', 'test content')
print mykey.id

Delete key:

from keyctl import Key
mykey = Key(123)
mykey.delete()

Update key:

from keyctl import Key
mykey = Key(123)
mykey.update('new content')

GUI

To open the GUI, run the installed command.

$ keyctlgui

Development

Warning

If you run the integrated tests, your user keyring will be cleared. Don’t do this when you have active keys e.g. for encryption.

Similar projects

Similar projects you might want to checkout:

License

GPL-3.0
see LICENSE file
Release History

Release History

History Node

0.15rc3

History Node

0.15rc2

History Node

0.15rc1

This version
History Node

0.4

History Node

0.3

History Node

0.2

History Node

0.1

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting