| GKSu Developers Manual |
|---|
gksu.c — GKSu - Authorization library with a UI
struct GkConf;
gboolean gksu_init (gint argc,
gchar **argv);
void gksu_set_title (gchar *title);
const gchar* gksu_get_title (void);
void gksu_set_keep_env (gboolean value);
gboolean gksu_get_keep_env ();
void gksu_set_icon (gchar *icon);
const gchar* gksu_get_icon (void);
void gksu_set_message (gchar *message);
const gchar* gksu_get_message ();
void gksu_set_user (gchar *username);
const gchar* gksu_get_user (void);
void gksu_set_grab (gboolean value);
gboolean gksu_get_grab ();
void gksu_set_login_shell (gboolean value);
gboolean gksu_get_login_shell ();
void gksu_set_ssh_fwd (gboolean value);
gboolean gksu_get_ssh_fwd ();
void gksu_set_debug (gboolean value);
gboolean gksu_get_debug ();
void gksu_secure_free (gchar *string);
gchar* gksu_ask_password ();
gboolean gksu_run (gchar *command);
This is a library to help with authorization to run priviledged applications from within graphical programs.
struct GkConf {
gchar *xauth;
gchar *display;
gchar *title;
gchar *message;
gchar *icon;
gchar *user;
gchar *command;
gboolean login_shell;
gboolean keep_env;
gboolean grab;
gboolean debug;
gboolean ssh_fwd;
};
Structure to hold all configuration information, some important environment variables and some meta-information about mainly x authentication.
This is the structure that holds most GKSu configuration settings but should not be accessed directly, use the getter/setter functions instead.
| gchar *xauth | the X authorization token |
| gchar *display | storage for the DISPLAY environment variable |
| gchar *title | the title of the window which asks for password |
| gchar *message | the label to be put at the window which asks for password |
| gchar *icon | path for the icon the window will use |
| gchar *user | user gksu will switch to |
| gchar *command | which command to run with su |
| gboolean login_shell | should run a login shell? |
| gboolean keep_env | should the current environment be kept? |
| gboolean grab | should gksu try to gra X keyboard and mouse? |
| gboolean debug | show debug information? |
| gboolean ssh_fwd | are we running inside a ssh X11 forwarding tunnel? |
gboolean gksu_init (gint argc,
gchar **argv);Inits the main configuration struct, a GkConf, and also inits the Gtk+ engine. You need to call this before doing anything.
| argc: | argc to be passed to gtk_init, mainly - or zero |
| argv: | argv to be passed to gtk_init, or NULL |
| Returns : | 0 if it suceeds. |
const gchar* gksu_get_title (void);
Gets what is the current title that the windows that asks for the password will show.
| Returns : | a string with the current title |
void gksu_set_user (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.
| username: | the target username |
const gchar* gksu_get_user (void);
Gets the user the command will be run as, as set by gksu_set_user.
| Returns : | a pointer to the string containing the username. |
gboolean gksu_get_login_shell ();
Finds out if the shell created by the underlying su process will be a login shell.
| Returns : | TRUE if the shell will be a login shell, FALSE otherwise. |
void gksu_secure_free (gchar *string);
Clears variables filling them with 0's previously
| string: | string to be freed securely |
gchar* gksu_ask_password ();
This is one of the main functions in gksu. It asks the user for the password of the target user.
| Returns : | a newly allocated gchar containing the password or NULL if an error happens or the user cancels the action |
gboolean gksu_run (gchar *command);
This could be considered one of the main functions in GKSu. it is responsible for doing the 'user changing' magic by calling ask_password() if it needs the target user's password
| command: | string containing the command to be run |
| Returns : | TRUE(1) if failed, FALSE(0) if succeeded. |
| << Authorization with GKSu | GKSu Hackers Internals Guide >> |