![]() |
![]() |
![]() |
libuser Reference Manual | ![]() |
---|---|---|---|---|
Top | Description |
useruser — Functions for initializing the library, looking up information, and making changes to the system information store. |
#include <libuser/user.h> struct lu_context; typedef lu_context_t; 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
); void lu_end (struct lu_context *context
); void lu_set_prompter (struct lu_context *context
,lu_prompt_fn *prompter
,gpointer callback_data
); void lu_get_prompter (struct lu_context *context
,lu_prompt_fn **prompter
,gpointer *callback_data
); gboolean lu_set_modules (struct lu_context *context
,const char *list
,struct lu_error **error
); const char * lu_get_modules (struct lu_context *context
); gboolean lu_uses_elevated_privileges (struct lu_context *context
); gboolean lu_user_lookup_name (struct lu_context *context
,const char *name
,struct lu_ent *ent
,struct lu_error **error
); gboolean lu_user_lookup_id (struct lu_context *context
,uid_t uid
,struct lu_ent *ent
,struct lu_error **error
); gboolean lu_user_default (struct lu_context *ctx
,const char *name
,gboolean system_account
,struct lu_ent *ent
); gboolean lu_user_add (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
); gboolean lu_user_modify (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
); gboolean lu_user_delete (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
); gboolean lu_user_setpass (struct lu_context *context
,struct lu_ent *ent
,const char *newpass
,gboolean crypted
,struct lu_error **error
); gboolean lu_user_removepass (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
); gboolean lu_user_lock (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
); gboolean lu_user_unlock (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
); gboolean lu_user_unlock_nonempty (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
); gboolean lu_user_islocked (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
); GValueArray * lu_users_enumerate (struct lu_context *context
,const char *pattern
,struct lu_error **error
); GValueArray * lu_users_enumerate_by_group (struct lu_context *context
,const char *group
,struct lu_error **error
); GPtrArray * lu_users_enumerate_full (struct lu_context *context
,const char *pattern
,struct lu_error **error
); GPtrArray * lu_users_enumerate_by_group_full (struct lu_context *context
,const char *group
,struct lu_error **error
); gboolean lu_group_lookup_name (struct lu_context *context
,const char *name
,struct lu_ent *ent
,struct lu_error **error
); gboolean lu_group_lookup_id (struct lu_context *context
,gid_t gid
,struct lu_ent *ent
,struct lu_error **error
); gboolean lu_group_default (struct lu_context *ctx
,const char *name
,gboolean system_account
,struct lu_ent *ent
); gboolean lu_group_add (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
); gboolean lu_group_modify (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
); gboolean lu_group_delete (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
); gboolean lu_group_setpass (struct lu_context *context
,struct lu_ent *ent
,const char *newpass
,gboolean crypted
,struct lu_error **error
); gboolean lu_group_removepass (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
); gboolean lu_group_lock (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
); gboolean lu_group_unlock (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
); gboolean lu_group_unlock_nonempty (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
); gboolean lu_group_islocked (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
); GValueArray * lu_groups_enumerate (struct lu_context *context
,const char *pattern
,struct lu_error **error
); GValueArray * lu_groups_enumerate_by_user (struct lu_context *context
,const char *user
,struct lu_error **error
); GPtrArray * lu_groups_enumerate_full (struct lu_context *context
,const char *pattern
,struct lu_error **error
); GPtrArray * lu_groups_enumerate_by_user_full (struct lu_context *context
,const char *user
,struct lu_error **error
);
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;
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.
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.
|
Suggested client name to use when connecting to servers, or NULL
|
|
Whether auth_name is a user or a group |
|
A list of modules to use for queries (separated by whitespace or
commas), or NULL to use modules specified in the config file |
|
A list of modules to use for entity creation (separated by
whitespace or commas), or NULL to use modules specified in the config file |
|
A function to use for getting information from the user |
|
Data for prompter
|
|
Filled with a lu_error if an error occurs |
Returns : |
a context which should be freed by lu_end() on success, NULL on
failure |
void lu_end (struct lu_context *context
);
Destroys a libuser library context
|
a context |
void lu_set_prompter (struct lu_context *context
,lu_prompt_fn *prompter
,gpointer callback_data
);
Changes the prompter function in a context
|
A context |
|
A new function to user for getting information from the user |
|
Data for prompter
|
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
.
const char * lu_get_modules (struct lu_context *context
);
Returns a list of modules for queries in context
.
|
A context |
Returns : |
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).
|
A context |
Returns : |
TRUE if at least one module uses elevated privileges |
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.
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.
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.
|
A context |
|
New user name |
|
Non-zero if the user is a system user |
|
An entity |
Returns : |
TRUE on success |
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.
gboolean lu_user_modify (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
);
Modifies an user entity.
gboolean lu_user_delete (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
);
Deletes an user.
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.
|
A context |
|
An entity describing the user, on success updated with current
information and LU_SHADOWLASTCHANGE
|
|
New password |
|
Non-zero if newpass is already encrypted |
|
Filled with an lu_error if an error occurs |
Returns : |
TRUE on success |
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.
|
A context |
|
An entity describing the user, on success updated with current
information and LU_SHADOWLASTCHANGE
|
|
Filled with an lu_error if an error occurs |
Returns : |
TRUE on success |
gboolean lu_user_lock (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
);
Locks an user account.
gboolean lu_user_unlock (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
);
Unlocks an user account.
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.
gboolean lu_user_islocked (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
);
Checks if an user account is locked.
GValueArray * lu_users_enumerate (struct lu_context *context
,const char *pattern
,struct lu_error **error
);
Returns a list of all users matching a pattern.
|
A context |
|
A glob-like pattern for user name |
|
Filled with a lu_error if an error occurs |
Returns : |
An array of strings, each representing one user name. The array should be freed by the caller. |
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
.
|
A context |
|
Group name |
|
Filled with a lu_error if an error occurs |
Returns : |
An array of strings, each representing one user name. The array should be freed by the caller. |
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.
|
A context |
|
A glob-like pattern for user name |
|
Filled with a lu_error if an error occurs |
Returns : |
A list of pointers to user entities. The entities and the list should be freed by the caller. |
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
.
|
A context |
|
Group name |
|
Filled with a lu_error if an error occurs |
Returns : |
A list of pointers to user entities. The entities and the list should be freed by the caller. |
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.
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.
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.
|
A context |
|
New group name |
|
Non-zero if the group is a system group |
|
An entity |
Returns : |
TRUE on success |
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.
gboolean lu_group_modify (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
);
Modifies a group entity.
gboolean lu_group_delete (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
);
Deletes a group.
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.
|
A context |
|
An entity describing the group, on success updated with current
information and LU_SHADOWLASTCHANGE
|
|
New password |
|
Non-zero if newpass is already encrypted |
|
Filled with an lu_error if an error occurs |
Returns : |
TRUE on success |
gboolean lu_group_removepass (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
);
Changes a group password to an empty string.
|
A context |
|
An entity describing the group, on success udpated with current
information and LU_SHADOWLASTCHANGE
|
|
Filled with in lu_error if an error occurs |
Returns : |
TRUE on success |
gboolean lu_group_lock (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
);
Locks a group account
gboolean lu_group_unlock (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
);
Unlocks a group account.
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.
gboolean lu_group_islocked (struct lu_context *context
,struct lu_ent *ent
,struct lu_error **error
);
Checks if a group account is locked.
GValueArray * lu_groups_enumerate (struct lu_context *context
,const char *pattern
,struct lu_error **error
);
Returns a list of all groups matching a pattern.
|
A context |
|
A glob-like pattern for group name |
|
Filled with a lu_error if an error occurs |
Returns : |
An array of strings, each representing one group name. The array should be freed by the caller. |
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
.
|
A context |
|
User name |
|
Filled with a lu_error if an error occurs |
Returns : |
An array of strings, each representing one group name. The array should be freed by the caller. |
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.
|
A context |
|
A glob-like pattern for group name |
|
Filled with a lu_error if an error occurs |
Returns : |
a list of pointers to group entities. The entities and the list should be freed by the caller. |
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
.
|
A context |
|
User name |
|
Filled with a lu_error if an error occurs |
Returns : |
a list of pointers to group entities. The entities and the list should be freed by the caller. |