![]() |
![]() |
LibGKSu Reference Manual | ||
---|---|---|---|---|
Top | Description |
API ReferenceAPI Reference — This API provides functions to provide su and sudo functionality to its users. |
enum GksuError; GksuContext* gksu_context_new (void); void gksu_context_set_user (GksuContext *context, gchar *username); const gchar * gksu_context_get_user (GksuContext *context); void gksu_context_set_command (GksuContext *context, gchar *command); const gchar * gksu_context_get_command (GksuContext *context); void gksu_context_set_keep_env (GksuContext *context, gboolean value); gboolean gksu_context_get_keep_env (GksuContext *context); gchar * gksu_context_get_description (GksuContext *context); void gksu_context_set_description (GksuContext *context, gchar *description); void gksu_context_set_message (GksuContext *context, gchar *message); gchar * gksu_context_get_message (GksuContext *context); void gksu_context_set_login_shell (GksuContext *context, gboolean value); gboolean gksu_context_get_login_shell (GksuContext *context); void gksu_context_set_grab (GksuContext *context, gboolean value); gboolean gksu_context_get_grab (GksuContext *context); void gksu_context_set_debug (GksuContext *context, gboolean value); gboolean gksu_context_get_debug (GksuContext *context); void gksu_context_free (GksuContext *context); gboolean gksu_run (gchar *command_line, GError **error); gboolean gksu_run_full (GksuContext *context, GksuAskPassFunc ask_pass, gpointer ask_pass_data, GksuPassNotNeededFunc pass_not_needed, gpointer pass_not_needed_data, GError **error); gboolean gksu_su (gchar *command_line, GError **error); gboolean gksu_su_full (GksuContext *context, GksuAskPassFunc ask_pass, gpointer ask_pass_data, GksuPassNotNeededFunc pass_not_needed, gpointer pass_not_needed_data, GError **error); gboolean gksu_sudo (gchar *command_line, GError **error); gboolean gksu_sudo_full (GksuContext *context, GksuAskPassFunc ask_pass, gpointer ask_pass_data, GksuPassNotNeededFunc pass_not_needed, gpointer pass_not_needed_data, GError **error); gchar * gksu_ask_password (GError **error); gchar * gksu_ask_password_full (GksuContext *context, gchar *prompt, GError **error);
typedef enum { GKSU_ERROR_XAUTH, GKSU_ERROR_HELPER, GKSU_ERROR_NOCOMMAND, GKSU_ERROR_NOPASSWORD, GKSU_ERROR_FORK, GKSU_ERROR_EXEC, GKSU_ERROR_PIPE, GKSU_ERROR_PIPEREAD, GKSU_ERROR_WRONGPASS, GKSU_ERROR_CHILDFAILED, GKSU_ERROR_NOT_ALLOWED, GKSU_ERROR_CANCELED, GKSU_ERROR_WRONGAUTOPASS } GksuError;
GksuContext* gksu_context_new (void);
This function should be used when creating a new GksuContext to pass to gksu_su_full or gksu_sudo_full. The GksuContext must be freed with gksu_context_free.
Returns : |
a newly allocated GksuContext |
void gksu_context_set_user (GksuContext *context, gchar *username);
Sets up what user the command will be run as. The default is root, but you can run the command as any user.
|
the GksuContext you want to modify |
|
the target username |
const gchar * gksu_context_get_user (GksuContext *context);
Gets the user the command will be run as, as set by gksu_context_set_user.
|
the GksuContext from which to grab the information |
Returns : |
a string with the user or NULL if not set. |
void gksu_context_set_command (GksuContext *context, gchar *command);
Sets up what command will run with the target user.
|
the GksuContext you want to modify |
|
the command that shall be ran |
const gchar * gksu_context_get_command (GksuContext *context);
Gets the command that will be run, as set by gksu_context_set_command.
|
the GksuContext from which to grab the information |
Returns : |
a string with the command or NULL if not set. |
void gksu_context_set_keep_env (GksuContext *context, gboolean value);
Should the environment be kept as it is? Defaults to TRUE. Notice that setting this to FALSE may cause the X authorization stuff to fail.
|
the GksuContext you want to modify |
|
TRUE or FALSE |
gboolean gksu_context_get_keep_env (GksuContext *context);
Finds out if the environment in which the program will be run will be reset.
|
the GksuContext from which to grab the information |
Returns : |
TRUE if the environment is going to be kept, FALSE otherwise. |
gchar * gksu_context_get_description (GksuContext *context);
Get the description that the window will have when the default function for requesting the password is called.
|
the GksuContext you want to get the description from. |
Returns : |
a string with the description or NULL if not set. |
void gksu_context_set_description (GksuContext *context, gchar *description);
Set the nice name for the action that is being run that the window that asks for the password will have. This is only meant to be used if the default window is used, of course.
|
the GksuContext you want to modify |
|
a string to set the description for |
void gksu_context_set_message (GksuContext *context, gchar *message);
Set the message that the window that asks for the password will have. This is only meant to be used if the default window is used, of course.
|
the GksuContext you want to modify |
|
a string to set the message for |
gchar * gksu_context_get_message (GksuContext *context);
Get the message that the window will have when the default function for requesting the password is called.
|
the GksuContext you want to get the message from. |
Returns : |
a string with the message or NULL if not set. |
void gksu_context_set_login_shell (GksuContext *context, gboolean value);
Should the shell in which the command will be run be a login shell?
|
the GksuContext you want to modify |
|
TRUE or FALSE |
gboolean gksu_context_get_login_shell (GksuContext *context);
Finds out if the shell created by the underlying su process will be a login shell.
|
the GksuContext from which to grab the information |
Returns : |
TRUE if the shell will be a login shell, FALSE otherwise. |
void gksu_context_set_grab (GksuContext *context, gboolean value);
|
|
|
gboolean gksu_context_get_grab (GksuContext *context);
Returns TRUE if gksu has been asked to do a grab on keyboard and mouse when asking for the password.
|
the GksuContext you want to ask whether a grab will be done. |
Returns : |
TRUE if yes, FALSE otherwise. |
void gksu_context_set_debug (GksuContext *context, gboolean value);
Set up if debuging information should be printed.
|
the GksuContext you want to modify |
|
TRUE or FALSE |
gboolean gksu_context_get_debug (GksuContext *context);
Finds out if the library is configured to print debuging information.
|
the GksuContext from which to grab the information |
Returns : |
TRUE if it is, FALSE otherwise. |
void gksu_context_free (GksuContext *context);
Frees the given GksuContext.
|
the GksuContext to be freed. |
gboolean gksu_run (gchar *command_line, GError **error);
This function is a wrapper for gksu_sudo/gksu_su. It will call one of them, depending on the GConf key that defines whether the default behavior for gksu is su or sudo mode. This is the recommended way of using the library functionality.
|
the command line that will be executed as other user |
|
a GError to be set with the error condition, if an error happens |
Returns : |
FALSE if all went well, TRUE if an error happend. |
gboolean gksu_run_full (GksuContext *context, GksuAskPassFunc ask_pass, gpointer ask_pass_data, GksuPassNotNeededFunc pass_not_needed, gpointer pass_not_needed_data, GError **error);
This is a compatibility shim over gksu_run_fuller, which, for compatibility reasons, lacks the 'exit_status' argument.
|
a GksuContext |
|
a GksuAskPassFunc to be called when the lib determines requesting a password is necessary; it may be NULL, in which case the standard password request dialog will be used |
|
a gpointer with user data to be passed to the GksuAskPasswordFunc |
|
a GksuPassNotNeededFunc that will be called when the command is being run without the need for requesting a password; it will only be called if the display-no-pass-info gconf key is enabled; NULL will have the standard dialog be shown |
|
a gpointer with the user data to be passed to the GksuPasswordNotNeededFunc |
|
a GError object to be filled with the error code or NULL |
Returns : |
TRUE if all went fine, FALSE if failed |
gboolean gksu_su (gchar *command_line, GError **error);
This function is a wrapper for gksu_su_run_full. It will call it without giving the callback functions, which leads to the standard ones being called. A simple GksuContext is created to hold the user name and the command.
|
the command line that will be executed as other user |
|
a GError to be set with the error condition, if an error happens |
Returns : |
TRUE if all went well, FALSE if an error happend. |
gboolean gksu_su_full (GksuContext *context, GksuAskPassFunc ask_pass, gpointer ask_pass_data, GksuPassNotNeededFunc pass_not_needed, gpointer pass_not_needed_data, GError **error);
This is a compatibility shim over gksu_su_fuller, which, for compatibility reasons, lacks the 'exit_status' argument. You should check the documentation for gksu_su_fuller for information about the arguments.
|
a GksuContext |
|
a GksuAskPassFunc to be called when the lib determines requesting a password is necessary; it may be NULL, in which case the standard password request dialog will be used |
|
a gpointer with user data to be passed to the GksuAskPasswordFunc |
|
a GksuPassNotNeededFunc that will be called when the command is being run without the need for requesting a password; it will only be called if the display-no-pass-info gconf key is enabled; NULL will have the standard dialog be shown |
|
a gpointer with the user data to be passed to the GksuPasswordNotNeededFunc |
|
a GError object to be filled with the error code or NULL |
Returns : |
TRUE if all went fine, FALSE if failed |
gboolean gksu_sudo (gchar *command_line, GError **error);
This function is a wrapper for gksu_sudo_run_full. It will call it without giving the callback functions, which leads to the standard ones being called. A simple GksuContext is created to hold the user name and the command.
|
the command line that will be executed as other user |
|
a GError to be set with the error condition, if an error happens |
Returns : |
TRUE if all went well, FALSE if an error happend. |
gboolean gksu_sudo_full (GksuContext *context, GksuAskPassFunc ask_pass, gpointer ask_pass_data, GksuPassNotNeededFunc pass_not_needed, gpointer pass_not_needed_data, GError **error);
This is a compatibility shim over gksu_sudo_fuller, which, for compatibility reasons, lacks the 'exit_status' argument. You should check the documentation for gksu_sudo_fuller for information about the arguments.
|
a GksuContext |
|
a GksuAskPassFunc to be called when the lib determines requesting a password is necessary; it may be NULL, in which case the standard password request dialog will be used |
|
a gpointer with user data to be passed to the GksuAskPasswordFunc |
|
a GksuPassNotNeededFunc that will be called when the command is being run without the need for requesting a password; it will only be called if the display-no-pass-info gconf key is enabled; NULL will have the standard dialog be shown |
|
a gpointer with the user data to be passed to the GksuPasswordNotNeededFunc |
|
a GError object to be filled with the error code or NULL |
Returns : |
TRUE if all went fine, FALSE if failed |
gchar * gksu_ask_password (GError **error);
This function uses the gksu infra-structure to request for a password, but instead of passing it to su or sudo to run a command it simply returns the password. This is just a convenience wrapper for gksu_ask_password_full.
|
a GError to be set with the error condition, if an error happens |
Returns : |
a newly allocated string with the password; |
gchar * gksu_ask_password_full (GksuContext *context, gchar *prompt, GError **error);
This function uses the gksu infra-structure to request for a password, but instead of passing it to su or sudo to run a command it simply returns the password.
|
a GksuContext |
|
a prompt different from Password: |
|
a GError object to be filled with the error code or NULL |
Returns : |
a newly allocated string with the password; |