Functions | |
ssize_t | keySetOwner (Key *key, const char *userDomain) |
Set the user domain of a key. | |
ssize_t | keyGetOwnerSize (const Key *key) |
Return the size of the user domain of the Key. | |
ssize_t | keyGetOwner (const Key *key, char *returned, size_t maxSize) |
Return the user domain of the key. | |
char * | keyStealOwner (const Key *key) |
Return a pointer to the real internal key owner or user domain. | |
ssize_t | keySetComment (Key *key, const char *newComment) |
Set a comment for a key. | |
ssize_t | keyGetCommentSize (const Key *key) |
Calculates number of bytes needed to store a key comment, including final NULL. | |
ssize_t | keyGetComment (const Key *key, char *returnedDesc, size_t maxSize) |
Get the key comment. | |
char * | keyStealComment (const Key *key) |
Return a pointer to the real internal key comment. | |
uid_t | keyGetUID (const Key *key) |
Get the user ID of a key. | |
int | keySetUID (Key *key, uid_t uid) |
Set the user ID of a key. | |
gid_t | keyGetGID (const Key *key) |
Get the system's group ID of a key. | |
int | keySetGID (Key *key, gid_t gid) |
Set the system's group ID of a key. | |
mode_t | keyGetAccess (const Key *key) |
Return the key filesystem-like access permissions. | |
int | keySetAccess (Key *key, mode_t mode) |
Set the key filesystem-like access permissions. | |
int | keySetUAccess (Key *key, mode_t umask) |
Set the key filesystem-like access permissions based on umask. | |
time_t | keyGetMTime (const Key *key) |
Get last modification time of the key on disk. | |
time_t | keyGetATime (const Key *key) |
Get last time the key data was read from disk. | |
time_t | keyGetCTime (const Key *key) |
Get last time the key was stated from disk. | |
int | keySetFlag (Key *key) |
Set a general flag in the Key. | |
int | keyClearFlag (Key *key) |
Clear the general flag in the Key. | |
int | keyGetFlag (const Key *key) |
Get the general flag from the Key. |
To use them:
#include <kdb.h>
Key metainfo are:
The comment can contain userdata which directly belong to that key.
User domain is the user that owns the key. It only works for the user/ hierachy.
Every user and group of your System has a uniqe ID. These values are used in the keys too. They are very important for the access. See man 2 chown.
With the access mode you can choose if a user, group or the world can access your key. See man 2 chmod.
ssize_t keySetOwner | ( | Key * | key, | |
const char * | userDomain | |||
) |
Set the user domain of a key.
A user domain is a user name.
A private copy is stored, so the passed parameter can be freed after the call.
userDomain | the user domain (or user name) |
Definition at line 2141 of file key.c.
References _Key::flags, KDB_RET_NOMEM, KEY_SWITCH_DOMAIN, KEY_SWITCH_NEEDSYNC, strblen(), and _Key::userDomain.
Referenced by keyDup(), keyNew(), and keySetName().
ssize_t keyGetOwnerSize | ( | const Key * | key | ) |
Return the size of the user domain of the Key.
Definition at line 2187 of file key.c.
References KDB_RET_NODOMAIN, strblen(), and _Key::userDomain.
ssize_t keyGetOwner | ( | const Key * | key, | |
char * | returned, | |||
size_t | maxSize | |||
) |
Return the user domain of the key.
user:someuser/
..... return someuser
user:some.user/
.... return some.user
user/
.... return the current user
Only user/
... keys have user domains. For system/
... keys (that doesn't have user domains) nothing is returned.
Although usually the same, the user domain of a key is not related to its UID. User domains are related to WHERE the key is stored on disk, while UIDs are related to access controls of a key.
key | the object to work with | |
returned | a pre-allocated space to store the owner | |
maxSize | maximum number of bytes that fit returned |
Definition at line 2218 of file key.c.
References KDB_RET_NODOMAIN, KDB_RET_TRUNC, strblen(), and _Key::userDomain.
char* keyStealOwner | ( | const Key * | key | ) |
Return a pointer to the real internal key
owner or user domain.
This is a much more efficient version of keyGetOwner() and you should use it if you are responsible enough to not mess up things.
key | the key object to work with |
Definition at line 2245 of file key.c.
References _Key::userDomain.
ssize_t keySetComment | ( | Key * | key, | |
const char * | newComment | |||
) |
Set a comment for a key.
A key comment is like a configuration file comment. It has no size limit. A private copy will be stored.
newComment | the comment, that can be freed after this call. |
Definition at line 2271 of file key.c.
References _Key::comment, _Key::commentSize, _Key::flags, KDB_RET_NOMEM, KEY_SWITCH_COMMENT, KEY_SWITCH_NEEDSYNC, and strblen().
Referenced by commandSet(), keyDup(), and keyNew().
ssize_t keyGetCommentSize | ( | const Key * | key | ) |
Calculates number of bytes needed to store a key comment, including final NULL.
Use this method to allocate memory to retrieve a key comment.
Definition at line 2311 of file key.c.
References _Key::comment, KDB_RET_NODESC, and strblen().
Referenced by commandGet().
ssize_t keyGetComment | ( | const Key * | key, | |
char * | returnedDesc, | |||
size_t | maxSize | |||
) |
Get the key comment.
A Key comment is pretty much as a comment in a text configuration file.
returnedDesc | pre-allocated memory to copy the comments to | |
maxSize | number of bytes that will fit returnedDesc |
Definition at line 2333 of file key.c.
References _Key::comment, KDB_RET_NODESC, KDB_RET_TRUNC, and strblen().
Referenced by commandGet().
char* keyStealComment | ( | const Key * | key | ) |
Return a pointer to the real internal key
comment.
This is a much more efficient version of keyGetComment() and you should use it if you are responsible enough to not mess up things.
key | the key object to work with |
keyStealValue() for and example
Definition at line 2360 of file key.c.
References _Key::comment.
uid_t keyGetUID | ( | const Key * | key | ) |
Get the user ID of a key.
Although usually the same, the UID of a key is not related to its user domain.
Definition at line 2383 of file key.c.
References _Key::uid.
int keySetUID | ( | Key * | key, | |
uid_t | uid | |||
) |
Set the user ID of a key.
Although usually the same, the UID of a key is not related to its user domain.
Definition at line 2399 of file key.c.
References _Key::flags, KEY_SWITCH_NEEDSYNC, KEY_SWITCH_UID, and _Key::uid.
Referenced by commandSet(), and keyNew().
gid_t keyGetGID | ( | const Key * | key | ) |
Get the system's group ID of a key.
Definition at line 2415 of file key.c.
References _Key::gid.
int keySetGID | ( | Key * | key, | |
gid_t | gid | |||
) |
Set the system's group ID of a key.
Definition at line 2428 of file key.c.
References _Key::flags, _Key::gid, KEY_SWITCH_GID, and KEY_SWITCH_NEEDSYNC.
Referenced by commandSet(), and keyNew().
mode_t keyGetAccess | ( | const Key * | key | ) |
Return the key filesystem-like access permissions.
Definition at line 2442 of file key.c.
References _Key::access.
int keySetAccess | ( | Key * | key, | |
mode_t | mode | |||
) |
Set the key filesystem-like access permissions.
Use this method before calling keySetDir().
key | the key to set access permissions | |
mode | the access permissions as for chmod(2) |
Definition at line 2458 of file key.c.
References _Key::access, _Key::flags, KEY_SWITCH_MODE, and KEY_SWITCH_NEEDSYNC.
Referenced by commandSet(), and keyNew().
int keySetUAccess | ( | Key * | key, | |
mode_t | umask | |||
) |
Set the key filesystem-like access permissions based on umask.
Use this method before calling keySetDir().
key | the key to set access permissions | |
umask | the umask for file/key creation as returned by umask(3) |
Definition at line 2479 of file key.c.
References _Key::access, _Key::flags, KEY_SWITCH_MODE, and KEY_SWITCH_NEEDSYNC.
int keySetFlag | ( | Key * | key | ) |
Set a general flag in the Key.
The flag has no semantics to the library, only to your application. It is just a simple marker that you may use to put the key on a special state that makes sense to your application.
Definition at line 3085 of file key.c.
References _Key::flags, and KEY_SWITCH_FLAG.
int keyClearFlag | ( | Key * | key | ) |
Clear the general flag in the Key.
The flag has no semantics to the library, only to your application. It is just a simple marker that you may use to put the key on a special state that makes sense to your application.
Definition at line 3104 of file key.c.
References _Key::flags, and KEY_SWITCH_FLAG.
int keyGetFlag | ( | const Key * | key | ) |
Get the general flag from the Key.
The flag has no semantics to the library, only to your application. It is just a simple marker that you may use to put the key on a special state that makes sense to your application.
Definition at line 3124 of file key.c.
References _Key::flags, and KEY_SWITCH_FLAG.