Module: Keyutils::SessionKeyring

Defined in:
lib/keyutils/keyring.rb

Overview

This module contains the additional methods included in Keyring::Session.

Instance Method Summary collapse

Instance Method Details

#join(name = nil) ⇒ Keyring

Join a different session keyring

Change the session keyring to which a process is subscribed.

If name is nil then a new anonymous keyring will be created, and the process will be subscribed to that.

If name is provided, then if a keyring of that name is available, the process will attempt to subscribe to that keyring, raising an error if that is not permitted; otherwise a new keyring of that name is created and attached as the session keyring.

To attach to an extant named keyring, the keyring must have search permission available to the calling process.

Parameters:

  • name (String, nil) (defaults to: nil)

    name of the keyring to join

Returns:

  • (Keyring)

    the keyring found or created

Raises:

  • (Errno::ENOMEM)

    insufficient memory to create a key

  • (Errno::EDQUOT)

    the key quota for this user would be exceeded by creating this key or linking it to the keyring

  • (Errno::EACCES)

    the named keyring exists, but is not searchable by the calling process



474
475
476
# File 'lib/keyutils/keyring.rb', line 474

def join name = nil
  Keyring.send :new, Lib.keyctl_join_session_keyring(name), name
end

#to_parentKeyring

Set the parent process’s session keyring.

Changes the session keyring to which the calling process’s parent subscribes to be the that of the calling process.

The keyring must have link permission available to the calling process, the parent process must have the same UIDs/GIDs as the calling process, and the LSM must not reject the replacement. Furthermore, this may not be used to affect init or a kernel thread.

Note that the replacement will not take immediate effect upon the parent process, but will rather be deferred to the next time it returns to userspace from kernel space.

Returns:

Raises:

  • (Errno::ENOMEM)

    insufficient memory to create a key.

  • (Errno::EPERM)

    the credentials of the parent don’t match those of the caller.

  • (Errno::EACCES)

    the named keyring exists, but is not linkable by the calling process.



498
499
500
501
# File 'lib/keyutils/keyring.rb', line 498

def to_parent
  Lib.keyctl_session_to_parent
  self
end