Top | ![]() |
![]() |
![]() |
![]() |
useruser — Functions for initializing the library, looking up information, and making changes to the system information store. |
user.h
contains declarations for functions which start
up and shut down the libuser library, and for functions which perform lookup
queries and modifications of the system information store.
struct lu_context * lu_start (const char *authname
,enum lu_entity_type auth_type
,const char *modules
,const char *create_modules
,lu_prompt_fn *prompter
,gpointer callback_data
,struct lu_error **error
);
Initializes the libuser library.
authname |
Suggested client name to use when connecting to servers, or |
|
auth_type |
Whether auth_name is a user or a group |
|
modules |
A list of modules to use for queries (separated by whitespace or
commas), or |
|
create_modules |
A list of modules to use for entity creation (separated by
whitespace or commas), or |
|
prompter |
A function to use for getting information from the user |
|
callback_data |
Data for |
|
error |
Filled with a lu_error if an error occurs |
void lu_set_prompter (struct lu_context *context
,lu_prompt_fn *prompter
,gpointer callback_data
);
Changes the prompter function in a context
void lu_get_prompter (struct lu_context *context
,lu_prompt_fn **prompter
,gpointer *callback_data
);
Gets current prompter function from a context.
gboolean lu_set_modules (struct lu_context *context
,const char *list
,struct lu_error **error
);
Replaces the current set of modules for queries in context
to list
.
context |
A context |
|
list |
A list of modules (separated by whitespace or commas) |
|
error |
Filled with a lu_error if an error occurs |
const char *
lu_get_modules (struct lu_context *context
);
Returns a list of modules for queries in context
.
A list of modules separated by spaces, or NULL
if the list of
modules is empty. The list should not be freed by the caller.
gboolean
lu_uses_elevated_privileges (struct lu_context *context
);
Checks if any module uses elevated privileges (e.g. modifies files that normal users can't modify).
gboolean lu_user_lookup_name (struct lu_context *context
,const char *name
,struct lu_ent *ent
,struct lu_error **error
);
Looks up an user by name.
context |
A context |
|
name |
User name |
|
ent |
An entity filled with received information |
|
error |
Filled with a lu_error if an error occurs |
gboolean lu_user_lookup_id (struct lu_context *context
,uid_t uid
,struct lu_ent *ent
,struct lu_error **error
);
Looks up an user by UID.
context |
A context |
|
uid |
User ID |
|
ent |
An entity filled with received information |
|
error |
Filled with a lu_error if an error occurs |
gboolean lu_user_default (struct lu_context *ctx
,const char *name
,gboolean system_account
,struct lu_ent *ent
);
Fills out an user entity as specified by the config file and modules to prepare for creation of the user.
gboolean lu_user_add (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
);
Creates an user in all modules specified for entity creation.
context |
A context |
|
ent |
An entity describing the user, on success updated with resulting account |
|
error |
Filled with a lu_error if an error occurs |
gboolean lu_user_modify (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
);
Modifies an user entity.
context |
A context |
|
ent |
An entity with pending modifications, on success updated with current information |
|
error |
Filled with a lu_error if an error occurs |
gboolean lu_user_delete (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
);
Deletes an user.
context |
A context |
|
ent |
An entity describing the user |
|
error |
Filled with a lu_error if an error occurs |
gboolean lu_user_setpass (struct lu_context *context
,struct lu_ent *ent
,const char *newpass
,gboolean crypted
,struct lu_error **error
);
Changes an user's password.
context |
A context |
|
ent |
An entity describing the user, on success updated with current
information and |
|
newpass |
New password |
|
crypted |
Non-zero if |
|
error |
Filled with an lu_error if an error occurs |
gboolean lu_user_removepass (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
);
Changes an user's password to an empty string.
context |
A context |
|
ent |
An entity describing the user, on success updated with current
information and |
|
error |
Filled with an lu_error if an error occurs |
gboolean lu_user_lock (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
);
Locks an user account.
context |
A context |
|
ent |
An entity describing the user, on success updated with current information |
|
error |
Filled with a lu_error if an error occurs |
gboolean lu_user_unlock (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
);
Unlocks an user account.
context |
A context |
|
ent |
An entity describing the user, on success updated with current information |
|
error |
Filled with a lu_error if an error occurs |
gboolean lu_user_unlock_nonempty (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
);
Unlocks an user account. If unlocking the account would result in an empty
password field, it fails with lu_error_unlock_empty
. Note that the
password can still be empty.
context |
A context |
|
ent |
An entity describing the user, on success updated with current information |
|
error |
Filled with a lu_error if an error occurs |
gboolean lu_user_islocked (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
);
Checks if an user account is locked.
context |
A context |
|
ent |
An entity describing the user |
|
error |
Filled with a lu_error if an error occurs |
GValueArray * lu_users_enumerate (struct lu_context *context
,const char *pattern
,struct lu_error **error
);
Returns a list of all users matching a pattern.
context |
A context |
|
pattern |
A glob-like pattern for user name |
|
error |
Filled with a lu_error if an error occurs |
GValueArray * lu_users_enumerate_by_group (struct lu_context *context
,const char *group
,struct lu_error **error
);
Returns a list of all members of a group group
.
GPtrArray * lu_users_enumerate_full (struct lu_context *context
,const char *pattern
,struct lu_error **error
);
Returns a list of entities, one for each user matching a pattern.
context |
A context |
|
pattern |
A glob-like pattern for user name |
|
error |
Filled with a lu_error if an error occurs |
GPtrArray * lu_users_enumerate_by_group_full (struct lu_context *context
,const char *group
,struct lu_error **error
);
Returns a list of entities, one for each member of a group group
.
gboolean lu_group_lookup_name (struct lu_context *context
,const char *name
,struct lu_ent *ent
,struct lu_error **error
);
Looks up a group by name.
context |
A context |
|
name |
Group name |
|
ent |
An entity filled with received information |
|
error |
Filled with a lu_error if an error occurs |
gboolean lu_group_lookup_id (struct lu_context *context
,gid_t gid
,struct lu_ent *ent
,struct lu_error **error
);
Looks up a group by GID.
context |
A context |
|
gid |
Group ID |
|
ent |
An entity filled with received information |
|
error |
Filled with a lu_error if an error occurs |
gboolean lu_group_default (struct lu_context *ctx
,const char *name
,gboolean system_account
,struct lu_ent *ent
);
Fills out a group entity as specified by the config file and modules to prepare for creation of the group.
gboolean lu_group_add (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
);
Creates a group in all modules specified for entity creation.
context |
A context |
|
ent |
An entity describing the group, on success updated with resulting account |
|
error |
Filled with a lu_error if an error occurs |
gboolean lu_group_modify (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
);
Modifies a group entity.
context |
A context |
|
ent |
An entity with pending modifications, on success updated with current information |
|
error |
Filled with a lu_error if an error occurs |
gboolean lu_group_delete (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
);
Deletes a group.
context |
A context |
|
ent |
An entity describing the group |
|
error |
Filled with a lu_error if an error occurs |
gboolean lu_group_setpass (struct lu_context *context
,struct lu_ent *ent
,const char *newpass
,gboolean crypted
,struct lu_error **error
);
Changes a group password.
context |
A context |
|
ent |
An entity describing the group, on success updated with current
information and |
|
newpass |
New password |
|
crypted |
Non-zero if |
|
error |
Filled with an lu_error if an error occurs |
gboolean lu_group_removepass (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
);
Changes a group password to an empty string.
context |
A context |
|
ent |
An entity describing the group, on success udpated with current
information and |
|
error |
Filled with in lu_error if an error occurs |
gboolean lu_group_lock (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
);
Locks a group account
context |
A context |
|
ent |
An entity describing the group, on success updated with current information |
|
error |
Filled with a lu_error if an error occurs |
gboolean lu_group_unlock (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
);
Unlocks a group account.
context |
A context |
|
ent |
An entity describing the group, on success updated with current information |
|
error |
Filled with a lu_error if an error occurs |
gboolean lu_group_unlock_nonempty (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
);
Unlocks a group account. If unlocking the account would result in an empty
password field, it fails with lu_error_unlock_empty
. Note that the
password can still be empty.
context |
A context |
|
ent |
An entity describing the group, on success updated with current information |
|
error |
Filled with a lu_error if an error occurs |
gboolean lu_group_islocked (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
);
Checks if a group account is locked.
context |
A context |
|
ent |
An entity describing the group |
|
error |
Filled with a lu_error if an error occurs |
GValueArray * lu_groups_enumerate (struct lu_context *context
,const char *pattern
,struct lu_error **error
);
Returns a list of all groups matching a pattern.
context |
A context |
|
pattern |
A glob-like pattern for group name |
|
error |
Filled with a lu_error if an error occurs |
GValueArray * lu_groups_enumerate_by_user (struct lu_context *context
,const char *user
,struct lu_error **error
);
Returns a list of all groups containing an user user
.
GPtrArray * lu_groups_enumerate_full (struct lu_context *context
,const char *pattern
,struct lu_error **error
);
Returns a list of entities, one for each group matching a pattern.
context |
A context |
|
pattern |
A glob-like pattern for group name |
|
error |
Filled with a lu_error if an error occurs |
GPtrArray * lu_groups_enumerate_by_user_full (struct lu_context *context
,const char *user
,struct lu_error **error
);
Returns a list of entities, one for each group containing an user user
.
Defines whether we are talking about an user or a group in cases where it is ambiguous.
struct lu_context;
An opaque structure manipulated by the library, containing caller-related state (to allow several independent callers in a single process).
typedef struct lu_context lu_context_t;
lu_context_t
has been deprecated since version 0.57.3 and should not be used in newly-written code.
Use struct lu_context directly.
An alias for struct lu_context.