]> pkexec May 2009 polkit pkexec 1 pkexec Execute a command as another user pkexec pkexec username PROGRAM ARGUMENTS DESCRIPTION pkexec allows an authorized user to execute PROGRAM as another user. If username is not specified, then the program will be executed as the administrative super user, root. RETURN VALUE Upon successful completion, the return value is the return value of PROGRAM. If the calling process is not authorized or an authorization could not be obtained through authentication or an error occured, pkexec exits with a return value of 127. SECURITY NOTES Executing a program as another user is a privileged operation. By default the required authorization (See ) requires administrator authentication. In addition, the authentication dialog presented to the user will display the full path to the program to be executed so the user is aware of what will happen: The environment that PROGRAM will run it, will be set to a minimal known and safe environment in order to avoid injecting code through LD_LIBRARY_PATH or similar mechanisms. In addition the PKEXEC_UID environment variable is set to the user id of the process invoking pkexec. As a result, pkexec will not allow you to run e.g. X11 applications as another user since the $DISPLAY environment variable is not set. REQUIRED AUTHORIZATIONS By default, the org.freedesktop.policykit.exec authorization is required unless an action definition file is present for the program in question. To require another authorization, it can be specified using the org.freedesktop.policykit.exec.path annotation on an action (See for details). EXAMPLE To specify what kind of authorization is needed to execute the program /usr/bin/pk-example-frobnicate as another user, simply write an action definition file like this FIXME: MISSING XINCLUDE CONTENT and drop it in the /usr/share/polkit-1/actions directory under a suitable name (e.g. matching the namespace of the action). Note that in addition to specifying the program, the authentication message, description, icon and defaults can be specified. For example, for the action defined above, the following authentication dialog will be shown: If the user is using the da_DK locale, the dialog looks like this: Note that pkexec does no validation of the ARGUMENTS passed to PROGRAM. In the normal case (where administrator authentication is required every time pkexec is used), this is not a problem since if the user is an administrator he might as well just run pkexec bash to get root. However, if an action is used for which the user can retain authorization (or if the user is implicitly authorized), such as with pk-example-frobnicate above, this could be a security hole. Therefore, as a rule of thumb, programs for which the default required authorization is changed, should never implicitly trust user input (e.g. like any other well-written suid program). AUTHOR Written by David Zeuthen davidz@redhat.com with a lot of help from many others. BUGS Please send bug reports to either the distribution or the polkit-devel mailing list, see the link on how to subscribe. SEE ALSO polkit8 , pkaction1 , pkcheck1