Scroll to navigation

owner.c(3elektra) Elektra owner.c(3elektra)

NAME

owner.c - Obsolete owner methods.

SYNOPSIS

#include <kdb.h>
#include <kdbconfig.h>
#include <kdbmeta.h>
#include <kdbprivate.h>

Functions


const char * keyOwner (const Key *key)

Return a pointer to the real internal key owner. " ssize_t keyGetOwnerSize (const Key *key)

Return the size of the owner of the Key with concluding 0. " ssize_t keyGetOwner (const Key *key, char *returnedOwner, size_t maxSize)
Return the owner of the key. ssize_t keySetOwner (Key *key, const char *newOwner)
Set the owner of a key.

Detailed Description

Obsolete owner methods.

Copyright:

BSD License (see LICENSE.md or https://www.libelektra.org)

Function Documentation

ssize_t keyGetOwner (const Key * key, char * returnedOwner, size_t maxSize)

Return the owner of the key.

  • Given user:someuser/..... return someuser
  • Given user:some.user/.... return some.user
  • Given user/.... return the current user

Only user/... keys have a owner. For system/... keys (that doesn't have a key owner) an empty string ('') is returned.

Although usually the same, the owner of a key is not related to its UID. Owner are related to WHERE the key is stored on disk, while UIDs are related to mode controls of a key.

Parameters:

key the object to work with
returnedOwner a pre-allocated space to store the owner
maxSize maximum number of bytes that fit returned

Returns:

number of bytes written to buffer

Return values:

1 if there is no owner
-1 on NULL pointers
-1 when maxSize is 0, larger than SSIZE_MAX or too small for ownername

See also:

keySetName(), keySetOwner(), keyOwner(), keyGetFullName()

ssize_t keyGetOwnerSize (const Key * key)


Return the size of the owner of the Key with concluding 0. The returned number can be used to allocate a string. 1 will returned on an empty owner to store the concluding 0 on using keyGetOwner().

char * buffer;
buffer = elektraMalloc (keyGetOwnerSize (key));
// use buffer and keyGetOwnerSize (key) for maxSize

Note:

that -1 might be returned on null pointer, so when you directly allocate afterwards its best to check if you will pass a null pointer before.

Parameters:

key the key object to work with

Returns:

number of bytes

Return values:

1 if there is no owner
-1 on NULL pointer

See also:

keyGetOwner()

const char* keyOwner (const Key * key)


Return a pointer to the real internal key owner. This is a much more efficient version of keyGetOwner() and you should use it if you are responsible enough to not mess up things. You are not allowed to modify the returned string in any way. If you need a copy of the string, consider to use keyGetOwner() instead.

keyOwner() returns '' when there is no keyOwner. The reason is

key=keyNew(0);
keySetOwner(key,"");
keyOwner(key); // you would expect "" here
keySetOwner(key,"system");
keyOwner(key); // you would expect "" here

Note:

Note that the Key structure keeps its own size field that is calculated by library internal calls, so to avoid inconsistencies, you must never use the pointer returned by keyOwner() method to set a new value. Use keySetOwner() instead.

Parameters:

key the key object to work with

Returns:

a pointer to internal owner

Return values:

'' when there is no (a empty) owner
0 iff key is a NULL pointer

See also:

keyGetOwnerSize() for the size of the string with concluding 0

keyGetOwner(), keySetOwner()

keyName() for name without owner

keyGetFullName() for name with owner

ssize_t keySetOwner (Key * key, const char * newOwner)

Set the owner of a key. A owner is a name of a system user related to a UID. The owner decides on which location on the disc the key goes.

A private copy is stored, so the passed parameter can be freed after the call.

Parameters:

key the key object to work with
newOwner the string which describes the owner of the key

Returns:

the number of bytes actually saved including final NULL

Return values:

1 when owner is freed (by setting 0 or '')
-1 on null pointer or memory problems

See also:

keySetName(), keyGetOwner(), keyGetFullName()

Author

Generated automatically by Doxygen for Elektra from the source code.

Mon Jan 15 2018 Version 0.8.20