diff options
| author | Steven Allen | 2024-07-09 13:16:43 +0200 |
|---|---|---|
| committer | Michael Albinus | 2024-07-09 13:16:43 +0200 |
| commit | 551a71c313be26d067e59fa11c79e4ef5c550e92 (patch) | |
| tree | ccb4349e4ddb3de5a0f2e5e77f148a4ceec46a3e /src/dbusbind.c | |
| parent | 24cad0e2e773a6f9cbd4a9721694a44246a7c974 (diff) | |
| download | emacs-551a71c313be26d067e59fa11c79e4ef5c550e92.tar.gz emacs-551a71c313be26d067e59fa11c79e4ef5c550e92.zip | |
Support interactive D-Bus authorization
When invoking D-Bus methods, let the user enable interactive
authorization by passing an :authorizable t parameter. This makes
it possible to D-Bus methods that require polkit authorization.
* configure.ac (HAVE_DBUS_MESSAGE_SET_ALLOW_INTERACTIVE_AUTHORIZATION):
Set a new variable if `dbus_message_set_allow_interactive_authorization'
is available.
* src/dbusbind.c (dbus-message-internal): Allow interactive
authorization by passing :authorizable t.
* doc/misc/dbus.texi (Synchronous Methods, Asynchronous Methods):
* etc/NEWS:
* lisp/net/dbus.el (dbus-call-method-asynchronously): Document the
new parameter.
Diffstat (limited to 'src/dbusbind.c')
| -rw-r--r-- | src/dbusbind.c | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/src/dbusbind.c b/src/dbusbind.c index 35ce03c7911..27b9c190793 100644 --- a/src/dbusbind.c +++ b/src/dbusbind.c | |||
| @@ -1314,7 +1314,7 @@ The following usages are expected: | |||
| 1314 | `dbus-call-method', `dbus-call-method-asynchronously': | 1314 | `dbus-call-method', `dbus-call-method-asynchronously': |
| 1315 | (dbus-message-internal | 1315 | (dbus-message-internal |
| 1316 | dbus-message-type-method-call BUS SERVICE PATH INTERFACE METHOD HANDLER | 1316 | dbus-message-type-method-call BUS SERVICE PATH INTERFACE METHOD HANDLER |
| 1317 | &optional :timeout TIMEOUT &rest ARGS) | 1317 | &optional :timeout TIMEOUT :authorizable AUTH &rest ARGS) |
| 1318 | 1318 | ||
| 1319 | `dbus-send-signal': | 1319 | `dbus-send-signal': |
| 1320 | (dbus-message-internal | 1320 | (dbus-message-internal |
| @@ -1512,12 +1512,38 @@ usage: (dbus-message-internal &rest REST) */) | |||
| 1512 | XD_SIGNAL1 (build_string ("Unable to create an error message")); | 1512 | XD_SIGNAL1 (build_string ("Unable to create an error message")); |
| 1513 | } | 1513 | } |
| 1514 | 1514 | ||
| 1515 | /* Check for timeout parameter. */ | 1515 | while ((count + 2 <= nargs)) |
| 1516 | if ((count + 2 <= nargs) && EQ (args[count], QCtimeout)) | ||
| 1517 | { | 1516 | { |
| 1518 | CHECK_FIXNAT (args[count+1]); | 1517 | /* Check for timeout parameter. */ |
| 1519 | timeout = min (XFIXNAT (args[count+1]), INT_MAX); | 1518 | if (EQ (args[count], QCtimeout)) |
| 1520 | count = count+2; | 1519 | { |
| 1520 | if (mtype != DBUS_MESSAGE_TYPE_METHOD_CALL) | ||
| 1521 | XD_SIGNAL1 | ||
| 1522 | (build_string (":timeout is only supported on method calls")); | ||
| 1523 | |||
| 1524 | CHECK_FIXNAT (args[count+1]); | ||
| 1525 | timeout = min (XFIXNAT (args[count+1]), INT_MAX); | ||
| 1526 | count = count+2; | ||
| 1527 | } | ||
| 1528 | /* Check for authorizable parameter. */ | ||
| 1529 | else if (EQ (args[count], QCauthorizable)) | ||
| 1530 | { | ||
| 1531 | if (mtype != DBUS_MESSAGE_TYPE_METHOD_CALL) | ||
| 1532 | XD_SIGNAL1 | ||
| 1533 | (build_string (":authorizable is only supported on method calls")); | ||
| 1534 | |||
| 1535 | /* Ignore this keyword if unsupported. */ | ||
| 1536 | #ifdef HAVE_DBUS_MESSAGE_SET_ALLOW_INTERACTIVE_AUTHORIZATION | ||
| 1537 | dbus_message_set_allow_interactive_authorization | ||
| 1538 | (dmessage, NILP (args[count+1]) ? FALSE : TRUE); | ||
| 1539 | #else | ||
| 1540 | XD_DEBUG_MESSAGE (":authorizable not supported"); | ||
| 1541 | #endif | ||
| 1542 | |||
| 1543 | count = count+2; | ||
| 1544 | } | ||
| 1545 | else break; | ||
| 1546 | |||
| 1521 | } | 1547 | } |
| 1522 | 1548 | ||
| 1523 | /* Initialize parameter list of message. */ | 1549 | /* Initialize parameter list of message. */ |
| @@ -1895,6 +1921,9 @@ syms_of_dbusbind (void) | |||
| 1895 | /* Lisp symbol for method call timeout. */ | 1921 | /* Lisp symbol for method call timeout. */ |
| 1896 | DEFSYM (QCtimeout, ":timeout"); | 1922 | DEFSYM (QCtimeout, ":timeout"); |
| 1897 | 1923 | ||
| 1924 | /* Lisp symbol for method interactive authorization. */ | ||
| 1925 | DEFSYM (QCauthorizable, ":authorizable"); | ||
| 1926 | |||
| 1898 | /* Lisp symbols of D-Bus types. */ | 1927 | /* Lisp symbols of D-Bus types. */ |
| 1899 | DEFSYM (QCbyte, ":byte"); | 1928 | DEFSYM (QCbyte, ":byte"); |
| 1900 | DEFSYM (QCboolean, ":boolean"); | 1929 | DEFSYM (QCboolean, ":boolean"); |