summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)AuthorFilesLines
2012-05-24Use a condition variable to signal that runaway killer thread is readyDavid Zeuthen1-5/+16
... instead of the unsafe g_thread_yield() busy-wait loop. Signed-off-by: David Zeuthen <davidz@redhat.com>
2012-05-24Terminate runaway scriptsDavid Zeuthen1-25/+175
Signed-off-by: David Zeuthen <davidz@redhat.com>
2012-05-23Use "rules", not "scripts" to refer to files in rules.dDavid Zeuthen1-3/+3
Signed-off-by: David Zeuthen <davidz@redhat.com>
2012-05-23Pass expanded identity list to the AuthenticationSessionDavid Zeuthen1-24/+24
... otherwise it things like admin-identities being set to ["unix-group:session"] won't work. Signed-off-by: David Zeuthen <davidz@redhat.com>
2012-05-23Add default rulesDavid Zeuthen3-10/+16
Signed-off-by: David Zeuthen <davidz@redhat.com>
2012-05-23Store private binaries in /usr/lib/polkit-1 instead of /usr/libexecDavid Zeuthen3-6/+9
Signed-off-by: David Zeuthen <davidz@redhat.com>
2012-05-23Nuke polkitbackend library, localauthority backend and extension systemDavid Zeuthen16-2207/+15
Any backend can now be implemented in JavaScript (if so desired) so we don't need any of this any more. Note that the libpolkitbackend library was never declared stable (the preprocessor symbol POLKIT_BACKEND_I_KNOW_API_IS_SUBJECT_TO_CHANGE had to be defined) so removing it is not an API/ABI break. Signed-off-by: David Zeuthen <davidz@redhat.com>
2012-05-23Fix distcheckDavid Zeuthen1-1/+2
Signed-off-by: David Zeuthen <davidz@redhat.com>
2012-05-23Rename --enable-systemd to --enable-libsystemd-loginDavid Zeuthen2-6/+6
It's useful to be more specific because we also want an option to install a systemd .service file which you may not want even if you are using libsystemd-login... Signed-off-by: David Zeuthen <davidz@redhat.com>
2012-05-23Make polkit_details_insert() remove the key if passed value is NULLDavid Zeuthen1-1/+6
Signed-off-by: David Zeuthen <davidz@redhat.com>
2012-05-22Update docsDavid Zeuthen1-1/+2
Signed-off-by: David Zeuthen <davidz@redhat.com>
2012-05-22Create rules.d directoriesDavid Zeuthen1-0/+4
Signed-off-by: David Zeuthen <davidz@redhat.com>
2012-05-21Add test-cases and 10 second timeout for polkit.spawn()David Zeuthen1-11/+435
Signed-off-by: David Zeuthen <davidz@redhat.com>
2012-05-21Add netgroup supportDavid Zeuthen2-0/+45
Signed-off-by: David Zeuthen <davidz@redhat.com>
2012-05-21Add test cases for evaluation orderDavid Zeuthen1-2/+2
In fact, this test uncovered that we were evaluating the rules in the wrong order. Fix this. Signed-off-by: David Zeuthen <davidz@redhat.com>
2012-05-21Use addRule() and addAdminRule()David Zeuthen2-19/+23
... as the man page already says. Signed-off-by: David Zeuthen <davidz@redhat.com>
2012-05-21Also load rules from /usr/share/polkit/rules.dDavid Zeuthen1-63/+123
... in addition to /etc/polkit/rules.d. Signed-off-by: David Zeuthen <davidz@redhat.com>
2012-05-18Don't include command-line in spawning error messagesDavid Zeuthen1-8/+3
We don't even know it and it's not worth reconstructing it. Signed-off-by: David Zeuthen <davidz@redhat.com>
2012-05-18Make polkit.spawn() take an array of arguments instead of a command-lineDavid Zeuthen2-17/+40
Much safer and easier this way. Signed-off-by: David Zeuthen <davidz@redhat.com>
2012-05-18Add polkit.spawn() to spawn external programsDavid Zeuthen2-0/+123
... and also add polkit.quote() for quoting arguments when constructing the command-line. Signed-off-by: David Zeuthen <davidz@redhat.com>
2012-05-18Make it possible for JS code to change detailsDavid Zeuthen6-54/+87
For example, to set the authentication message, a JS function can simply do details["polkit.message"] = "Hey dude, XYZ, I need your password"; This can also be used to pass data back to the mechanism. To make this work properly, we also introduce a slight change: the a{ss} passed back to the mechanism (part of the AuthorizationResult structure) will be initialized with the a{ss} the app passed itself in the CheckAuthorization() call. Signed-off-by: David Zeuthen <davidz@redhat.com>
2012-05-18Reformat init.js and also avoid quoting non-string properties in toString()David Zeuthen1-43/+51
Otherwise it's hard to tell whether 'true' is a string or a boolean... Signed-off-by: David Zeuthen <davidz@redhat.com>
2012-05-18Emit ::Changed signal after reloading rulesDavid Zeuthen1-0/+2
Signed-off-by: David Zeuthen <davidz@redhat.com>
2012-05-18Collect garbageDavid Zeuthen1-0/+11
Signed-off-by: David Zeuthen <davidz@redhat.com>
2012-05-18Add a couple of more error checksDavid Zeuthen1-10/+19
Signed-off-by: David Zeuthen <davidz@redhat.com>
2012-05-18Clean up code a bitDavid Zeuthen4-108/+154
Also, move init code into init.js instead of using a C string for it... Signed-off-by: David Zeuthen <davidz@redhat.com>
2012-05-18Pass details to JS functions and simplify how Subject instances are constructedDavid Zeuthen1-75/+206
Signed-off-by: David Zeuthen <davidz@redhat.com>
2012-05-18Include seat and session in Subject objectDavid Zeuthen1-24/+61
Signed-off-by: David Zeuthen <davidz@redhat.com>
2012-05-17Add experimental authority backend using JavaScript rule filesDavid Zeuthen6-6/+1147
Signed-off-by: David Zeuthen <davidz@redhat.com>
2012-04-12Make it possible to influence agent registration with an a{sv} parameterDavid Zeuthen8-53/+394
Additionally, add a "fallback" option. Also add support in this in the pkttyagent(1) program. This slightly breaks libpolkit-backend API by adding a GVariant* param to one of the class vfuncs... but that API is already declared unstable so that's fine. Signed-off-by: David Zeuthen <davidz@redhat.com>
2012-04-11Add pkttyagent(1) helperDavid Zeuthen3-1/+257
This came up while working on https://bugzilla.redhat.com/show_bug.cgi?id=804088 and is useful for example if it's not suitable or appropriate to link against the polkit libraries. Signed-off-by: David Zeuthen <davidz@redhat.com>
2012-03-08PolkitAgentSession: Don't leak file descriptorsDavid Zeuthen1-0/+14
This was reported here https://bugzilla.gnome.org/show_bug.cgi?id=671486 Signed-off-by: David Zeuthen <davidz@redhat.com>
2012-02-06PolkitUnixSession: Actually return TRUE if a session existsDavid Zeuthen1-7/+5
Also, don't treat the integer returned by sd_session_get_uid() as a boolean because that's just confusing. Signed-off-by: David Zeuthen <davidz@redhat.com>
2012-02-06PolkitUnixSession: Set error if we cannot find a session for the given pidDavid Zeuthen1-5/+16
Also, don't treat the integer returned by sd_pid_get_session() as a boolean because that's just confusing. Also, don't confuse memory supposed to be freed by g_free() and free(3) with each other. See https://bugzilla.redhat.com/show_bug.cgi?id=787222 for more details. Signed-off-by: David Zeuthen <davidz@redhat.com>
2012-01-10Various builddir != srcdir fixesRyan Lortie2-46/+31
Fix autogen.sh to work when run from the builddir. Also: switch over to using the gobject-introspection Makefile (which is out-of-tree safe) instead of hardcoding our own version. https://bugs.freedesktop.org/show_bug.cgi?id=44599 Signed-off-by: David Zeuthen <davidz@redhat.com>
2012-01-03Add optional systemd supportMatthias Clasen4-2/+915
When configured with --enable-systemd, this patch makes polkit use systemd for session tracking instead of ConsoleKit. Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-12-22Bug 43610 - Add netgroup supportNikki VonHollen10-10/+466
https://bugs.freedesktop.org/show_bug.cgi?id=43610 Added netgroup support and additional unit tests with MockLibc support. Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-12-20Bug 43608 – Add unit testsNikki VonHollen1-24/+86
https://bugs.freedesktop.org/show_bug.cgi?id=43608 Basic unittest support and a few tests. Adds basic unit tests for: PolkitIdentity, PolkitUnixUser, PolkitUnixGroup, PolkitBackendLocalAuthorizationStore, and PolkitBackendLocalAuthority. Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-12-06Default to AdminIdentities=unix-group:wheel for local authorityDavid Zeuthen1-1/+1
Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-10-18Bug 41025 – Add org.freedesktop.policykit.owner annotationDavid Zeuthen1-9/+72
This allows daemons running as a designated uid to check authorizations. Based on a patch from Christopher James Halse Rogers <chalserogers@gmail.com>. https://bugs.freedesktop.org/show_bug.cgi?id=41025 Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-10-18Add --no-debug option and use this for D-Bus activationDavid Zeuthen1-1/+26
Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-09-20Add support for the org.freedesktop.policykit.imply annotationDavid Zeuthen1-0/+67
For example, GNOME control center can now defined e.g. <action id="org.zee.example.meta"> <description>Meta Action</description> <message>Example of a meta action, blabla</message> <defaults> <allow_any>no</allow_any> <allow_inactive>no</allow_inactive> <allow_active>auth_admin_keep</allow_active> </defaults> <annotate key="org.freedesktop.policykit.imply">org.freedesktop.udisks2.ata-smart-selftest org.freedesktop.udisks2.encrypted-lock-others org.freedesktop.udisks2.filesystem-unmount-others</annotate> </action> and set up a single GtkLockButton for a PolkitPermission for action id "org.zee.example.meta". When unlocked the given subject will now be authorized for the actions mentioned in the annotation. Example test program: int main (int argc, char *argv[]) { PolkitSubject *subject; GtkWidget *window; GtkWidget *table; GMainLoop *loop; guint n; gtk_init (&argc, &argv); subject = polkit_unix_process_new (getpid ()); window = gtk_window_new (GTK_WINDOW_TOPLEVEL); table = gtk_table_new (1, 2, FALSE); for (n = 1; n < argc; n++) { const gchar *action_id = argv[n]; GPermission *permission; GtkWidget *label; GtkWidget *lock_button; GError *error = NULL; label = gtk_label_new (action_id); permission = polkit_permission_new_sync (action_id, subject, NULL, &error); if (permission == NULL) { g_error ("Error constructing permission for action_id %s: %s (%s, %d)", action_id, error->message, g_quark_to_string (error->domain), error->code); goto out; } lock_button = gtk_lock_button_new (permission); g_object_unref (permission); gtk_table_attach (GTK_TABLE (table), label, 0, 1, n - 1, n, GTK_FILL, GTK_FILL, 0, 0); gtk_table_attach (GTK_TABLE (table), lock_button, 1, 2, n - 1, n, GTK_FILL, GTK_FILL, 0, 0); } gtk_container_add (GTK_CONTAINER (window), table); gtk_widget_show_all (window); loop = g_main_loop_new (NULL, FALSE); g_main_loop_run (loop); out: ; } Compile with: gcc -o showpolkit showpolkit.c `pkg-config --cflags --libs polkit-gobject-1 gtk+-3.0` -g -O0 Run with: ./showpolkit org.freedesktop.udisks2.ata-smart-selftest org.freedesktop.udisks2.encrypted-lock-others org.freedesktop.udisks2.filesystem-unmount-others org.zee.example.meta Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-08-01Fix multi-line pam prompt handlingMarc Deslauriers2-18/+24
Some pam modules may attempt to display multi-line prompts to the user. In these cases, PolicyKit was failing. This patch fixes the issue by escaping the prompt before passing it and unescaping it again. Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-08-01Specify exported pkg-config files in GIRsEvan Nemerson2-0/+2
https://bugs.freedesktop.org/show_bug.cgi?id=39315 Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-08-01Bug 38769 — pkexec: Support running X11 appsMartin Pitt1-10/+25
Introduce a new annotation flag "org.freedesktop.policykit.exec.allow_gui" which will cause pkexec to preserve $DISPLAY and $XAUTHORITY. With this, the remaining few legacy X11 programs which still need to run as root can finally be migrated away from gksu (or similar) to pkexec, with the help of some .polkit files. This will provide a consistent UI and also help with making the authentication dialogs less spoofable. Relax validate_environment_variable() to allow '/' in $XAUTHORITY, as this variable actually is a full path. Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-06-29Fix backend crash if a .policy file does not specify <message>Martin Pitt1-3/+6
get_localized_data_for_challenge() would call expand_properties() with a NULL "message" argument, causing a segfault.
2011-04-01pkexec: Avoid TOCTTOU problems with parent processDavid Zeuthen1-27/+39
In a nutshell, the parent process may change its uid (either real- or effective uid) after launching pkexec. It can do this by exec()'ing e.g. a setuid root program. To avoid this problem, just use the uid the parent process had when it executed pkexec. This happens to be the same uid of the pkexec process itself. Additionally, remove some dubious code that allowed pkexec to continue when the parent process died as there is no reason to support something like that. Also ensure that the pkexec process is killed if the parent process dies. This problem was pointed out by Neel Mehta <nmehta@google.com>. Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-04-01Use polkit_unix_process_get_uid() to get the owner of a processDavid Zeuthen1-5/+6
This avoids a TOCTTOU problem. Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-04-01Make PolkitUnixProcess also record the uid of the processDavid Zeuthen3-116/+273
This is needed to avoid possible TOCTTOU issues since a process can change both its real uid and effective uid. Signed-off-by: David Zeuthen <davidz@redhat.com>
2011-03-31PolkitUnixProcess: Clarify that the real uid is returned, not the effective oneDavid Zeuthen1-16/+50
On Linux, also switch to parsing /proc/<pid>/status instead of relying on the st_uid returned by stat(2) to be the uid we want. This was pointed out by Neel Mehta <nmehta@google.com>. Thanks! Signed-off-by: David Zeuthen <davidz@redhat.com>