| gumd API Reference Manual | ||||
|---|---|---|---|---|
| Top | Description | Object Hierarchy | Properties | ||||
#include <gum/gum-user.h> struct GumUser; void (*GumUserCb) (GumUser *user,const GError *error,gpointer user_data); struct GumUserClass; gboolean gum_user_add (GumUser *self,GumUserCb callback,gpointer user_data); gboolean gum_user_add_sync (GumUser *self); GumUser * gum_user_create (GumUserCb callback,gpointer user_data); GumUser * gum_user_create_sync (); gboolean gum_user_delete (GumUser *self,gboolean rem_home_dir,GumUserCb callback,gpointer user_data); gboolean gum_user_delete_sync (GumUser *self,gboolean rem_home_dir); GumUser * gum_user_get (uid_t uid,GumUserCb callback,gpointer user_data); GumUser * gum_user_get_by_name (const gchar *username,GumUserCb callback,gpointer user_data); GumUser * gum_user_get_by_name_sync (const gchar *username); GumUser * gum_user_get_sync (uid_t uid); gboolean gum_user_update (GumUser *self,GumUserCb callback,gpointer user_data); gboolean gum_user_update_sync (GumUser *self);
"gid" guint : Read "homedir" gchar* : Read / Write "homephone" gchar* : Read / Write "nickname" gchar* : Read / Write "office" gchar* : Read / Write "officephone" gchar* : Read / Write "realname" gchar* : Read / Write "secret" gchar* : Read / Write "shell" gchar* : Read / Write "uid" guint : Read "username" gchar* : Read / Write "usertype" guint : Read / Write
GumUser provides interface for adding, removing and updating user accounts. User's information can also be retrieved using this interface. Only privileged user can access the interface when system-bus is used for communication with the user management daemon.
Following code snippet demonstrates how to create a new remote user object:
GumUser *user = NULL; user = gum_user_create_sync (); // use the object // destroy the object g_object_unref (user);
Similarly, new user can be added as:
GumUser *user = NULL; gboolean rval = FALSE; user = gum_user_create_sync (); // set user properties g_object_set (G_OBJECT (user), "username", "user1", "secret", "123456", "usertype", GUM_USERTYPE_NORMAL, NULL); // add user rval = gum_user_add_sync (user); // destroy the object g_object_unref (user);
For more details, see example implementation here: gum-utils
void (*GumUserCb) (GumUser *user,const GError *error,gpointer user_data);
GumUserCb defines the callback which is used when user object is created, added, deleted or updated.
struct GumUserClass {
GObjectClass parent_class;
};
Opaque structure for the class.
GObjectClass |
parent class object |
gboolean gum_user_add (GumUser *self,GumUserCb callback,gpointer user_data);
This method adds the user over the DBus asynchronously. Callback is used to notify when the user is added.
|
GumUser object to be added; object should have either valid "username" or "nickname" in addition to valid "usertype". |
|
GumUserCb to be invoked when user is added |
|
user data |
Returns : |
returns TRUE if the request has been pushed and is waiting for the response, FALSE otherwise. No callback is triggered, in case the function returns FALSE. |
gboolean gum_user_add_sync (GumUser *self);
This method adds the user over the DBus synchronously.
|
GumUser object to be added; object should have either valid "username" or "nickname" in addition to valid "usertype". |
Returns : |
returns TRUE if successful, FALSE otherwise. |
GumUser * gum_user_create (GumUserCb callback,gpointer user_data);
This method creates a new remote user object over the DBus asynchronously. Callback is used to notify when the remote object is fully created and accessible.
GumUser * gum_user_create_sync ();
This method creates a new remote user object over the DBus synchronously.
Returns : |
GumUser newly created object. [transfer full] |
gboolean gum_user_delete (GumUser *self,gboolean rem_home_dir,GumUserCb callback,gpointer user_data);
This method deletes the user over the DBus asynchronously. Callback is used to notify when the user is deleted.
|
GumUser object to be deleted; object should have valid "uid" property. |
|
deletes home directory of the user if set to TRUE |
|
GumUserCb to be invoked when user is deleted |
|
user data |
Returns : |
returns TRUE if the request has been pushed and is waiting for the response, FALSE otherwise. No callback is triggered, in case the function returns FALSE. |
gboolean gum_user_delete_sync (GumUser *self,gboolean rem_home_dir);
This method deletes the user over the DBus synchronously.
GumUser * gum_user_get (uid_t uid,GumUserCb callback,gpointer user_data);
This method gets the user object attached to uid over the DBus asynchronously. Callback is used to notify when the remote object is fully created and accessible.
GumUser * gum_user_get_by_name (const gchar *username,GumUserCb callback,gpointer user_data);
This method gets the user object attached to username over the DBus asynchronously. Callback is used to notify when the remote object is fully created and accessible.
GumUser * gum_user_get_by_name_sync (const gchar *username);
This method gets the user object attached to username over the DBus synchronously.
|
name of the user |
Returns : |
GumUser object. [transfer full] |
GumUser * gum_user_get_sync (uid_t uid);
This method gets the user object attached to uid over the DBus synchronously.
|
user id for the user |
Returns : |
GumUser object. [transfer full] |
gboolean gum_user_update (GumUser *self,GumUserCb callback,gpointer user_data);
This method updates the user over the DBus asynchronously. Callback is used to notify when the user is updated. The properties which can be updated are: secret, realname, office, officephone, homephone and shell.
|
GumUser object to be updated; object should have valid "uid" property. |
|
GumUserCb to be invoked when user is updated |
|
user data |
Returns : |
returns TRUE if the request has been pushed and is waiting for the response, FALSE otherwise. No callback is triggered, in case the function returns FALSE. |
"gid" property"gid" guint : Read
This property holds a unique group identity for the user as assigned by the underlying framework, which is always be in range [0, MAXUINT].
Default value: 4294967295
"homedir" property"homedir" gchar* : Read / Write
This property holds the location of the home directory of the user. Home directory should not contain any control chars (0x00-0x1F,0x7F), comma (',' 0x2c) or colon (':' 0x3A). For new user, it is recommended to let the underlying framework to set the home directory of the user based on the configuration.
Default value: ""
"homephone" property"homephone" gchar* : Read / Write
This property holds the home phone of the user. Home phone should not contain any control chars (0x00-0x1F,0x7F), comma (',' 0x2c) or colon (':' 0x3A).
Default value: ""
"nickname" property"nickname" gchar* : Read / Write
This property holds the nickname of given to the user. Nickname should not contain any control chars (0x00-0x1F,0x7F), comma (',' 0x2c) or colon (':' 0x3A). If no "username" is specified, nickname is hashed to handle non-ascii characters and then set as "username".
Default value: ""
"office" property"office" gchar* : Read / Write
This property holds the location of the office of the user. Office should not contain any control chars (0x00-0x1F,0x7F), comma (',' 0x2c) or colon (':' 0x3A).
Default value: ""
"officephone" property"officephone" gchar* : Read / Write
This property holds the office phone of the user. Office phone should not contain any control chars (0x00-0x1F,0x7F), comma (',' 0x2c) or colon (':' 0x3A).
Default value: ""
"realname" property"realname" gchar* : Read / Write
This property holds the realname of given to the user. Realname should not contain any control chars (0x00-0x1F,0x7F), comma (',' 0x2c) or colon (':' 0x3A).
Default value: ""
"secret" property"secret" gchar* : Read / Write
This property holds the secret as chosen by the user. Secret should not contain any control chars (0x00-0x1F,0x7F) or colon (':' 0x3A).
Default value: ""
"shell" property"shell" gchar* : Read / Write
This property holds the shell path of the user. Shell path should not contain any control chars (0x00-0x1F,0x7F), comma (',' 0x2c) or colon (':' 0x3A). For new user, it is recommended to let the underlying framework to set the home directory of the user based on the configuration.
Default value: ""
"uid" property"uid" guint : Read
This property holds a unique user identity for the user as assigned by ther underlying framework, which is always be in range [0, MAXUINT].
Default value: 4294967295
"username" property"username" gchar* : Read / Write
This property holds the name of given to the user when the user is added. Allowed pattern for username is: "^[A-Za-z_][A-Za-z0-9_.-]*[A-Za-z0-9_.$-]\\?$". Either "username" or "nickname" must be specified when adding a new user.
Default value: ""
"usertype" property"usertype" guint : Read / Write
This property holds a user type that the object corresponds to. Valid values of user types are as specified in GumUserType. "usertype" must be specified when adding a new user.
Allowed values: <= 65535
Default value: 0