Unix-system-calls-add-key

提供:Dev Guides
移動先:案内検索

[top]#

|http://www.google.com/[Google] | a|

Web This Site
  • 初心者向けのUnix *
  • 高度なUnix *

選択した読書

Copyright©2014 by finddevguides

[cols=",,,,,,,",]

| |  Home   | |  References   | |  Discussion Forums   | |  About TP  

[width="100%",cols="100%",]

a| == add_key()-Unix、Linuxシステムコール

[[File:]] image :http://www.finddevguides.com/images/next.gif [next] image:http://www.finddevguides.com/add- this.gif [AddThisソーシャルブックマークボタン]

広告

NAME

add_key-カーネルのキー管理機能にキーを追加します

概要

#include <keyutils.h> key_serial_t add_key(const char* type, const char *description, const void *payload, size_t plen, key_serial_t keyring);

説明

*add_key* ()は、指定された_type_および_description_のキーを作成または更新し、長さ_plen_の_payload_でインスタンス化し、指定された_keyring_にアタッチし、そのシリアル番号を返すようカーネルに要求します。

キータイプは、データの形式が間違っているか、その他の方法で無効な場合、データを拒否する可能性があります。

宛先_keyring_に指定された_type_および_description_に一致するキーが既に含まれている場合、キータイプがそれをサポートしていれば、新しいキーが作成されるのではなく、そのキーが更新されます。そうでない場合は、新しいキーが作成され、キーリングから既存のキーへのリンクが置き換えられます。

宛先_keyring_シリアル番号は、呼び出し元が書き込み許可を持っている有効なキーリングのシリアル番号、または特別なキーリングIDの場合があります。

Tag Description
KEY_SPEC_THREAD_KEYRING This specifies the caller’s thread-specific keyring.
KEY_SPEC_PROCESS_KEYRING This specifies the caller’s process-specific keyring.
KEY_SPEC_SESSION_KEYRING This specifies the caller’s session-specific keyring.
KEY_SPEC_USER_KEYRING This specifies the caller’s UID-specific keyring.
KEY_SPEC_USER_SESSION_KEYRING This specifies the caller’s UID-session keyring.

キータイプ

コアキー管理コードで使用できるキータイプは多数あり、これらはこの機能に指定できます。

Tag Description
“user” Keys of the user-defined key type may contain a blob of arbitrary data, and thedescription may be any valid string, though it is preferred that the description be prefixed with a string representing the service to which the key is of interest and a colon (for instance “afs:mykey”). The payload may be empty or NULL for keys of this type.
*“keyring” * Keyrings are special key types that may contain links to sequences of other keys of any type. If this interface is used to create a keyring, then a* NULL* payload should be specified, and plen should be zero.

返り値

成功すると、 add_key ()は、作成または更新されたキーのシリアル番号を返します。 エラーの場合、値 -1 が返され、errnoは適切なエラーに設定されます。

エラー

Tag Description
ENOKEY The keyring doesn’t exist.
EKEYEXPIRED The keyring has expired.
EKEYREVOKED The keyring has been revoked.
EINVAL The payload data was invalid.
ENOMEM Insufficient memory to create a key.
EDQUOT The key quota for this user would be exceeded by creating this key or linking it to the keyring.
EACCES The keyring wasn’t available for modification by the user.

リンク

これはLinuxシステムコールですが、_libc_には存在しませんが、_libkeyutils_にあります。 リンクするときは、*-lkeyutils *をリンカーに指定する必要があります。

関連項目

[[File:]] image :http://www.finddevguides.com/images/next.gif [next] [[File:]]

広告

|  

[cols="^",]

|Advertisements