Commit 7d4b52c4 authored by Matt Turner's avatar Matt Turner Committed by Jan Rybar
Browse files

pkexec: Allow --version and --help even if not setuid root

parent 22ff3e52
Pipeline #576040 passed with stage
in 3 minutes and 38 seconds
......@@ -514,27 +514,6 @@ main (int argc, char *argv[])
/* Disable remote file access from GIO. */
setenv ("GIO_USE_VFS", "local", 1);
/* check for correct invocation */
if (geteuid () != 0)
{
g_printerr ("pkexec must be setuid root\n");
goto out;
}
original_user_name = g_strdup (g_get_user_name ());
if (original_user_name == NULL)
{
g_printerr ("Error getting user name.\n");
goto out;
}
if ((original_cwd = g_get_current_dir ()) == NULL)
{
g_printerr ("Error getting cwd: %s\n",
g_strerror (errno));
goto out;
}
/* First process options and find the command-line to invoke. Avoid using fancy library routines
* that depend on environtment variables since we haven't cleared the environment just yet.
*/
......@@ -595,6 +574,27 @@ main (int argc, char *argv[])
goto out;
}
/* check for correct invocation */
if (geteuid () != 0)
{
g_printerr ("pkexec must be setuid root\n");
goto out;
}
original_user_name = g_strdup (g_get_user_name ());
if (original_user_name == NULL)
{
g_printerr ("Error getting user name.\n");
goto out;
}
if ((original_cwd = g_get_current_dir ()) == NULL)
{
g_printerr ("Error getting cwd: %s\n",
g_strerror (errno));
goto out;
}
if (opt_user == NULL)
opt_user = g_strdup ("root");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment