diff options
| author | Michael Albinus | 2016-07-08 22:44:11 +0200 |
|---|---|---|
| committer | Michael Albinus | 2016-07-08 22:44:11 +0200 |
| commit | 5deebc3c914c86e84d11661a7877c00b2d7fddd1 (patch) | |
| tree | 3adfc69e9d64a572735af0fb72a4b1fc67bbbc9d | |
| parent | d8a9c450cf4c575d21297885d6823920aec0482f (diff) | |
| download | emacs-5deebc3c914c86e84d11661a7877c00b2d7fddd1.tar.gz emacs-5deebc3c914c86e84d11661a7877c00b2d7fddd1.zip | |
Detect remote uid and gid in tramp-gvfs.el
* lisp/net/tramp-gvfs.el (tramp-gvfs-handle-expand-file-name)
(tramp-gvfs-handler-mounted-unmounted)
(tramp-gvfs-connection-mounted-p):
Make "default-location" a connection property.
(tramp-gvfs-get-remote-uid, tramp-gvfs-get-remote-gid): New defuns.
(tramp-gvfs-maybe-open-connection): Use them.
| -rw-r--r-- | lisp/net/tramp-gvfs.el | 71 |
1 files changed, 53 insertions, 18 deletions
diff --git a/lisp/net/tramp-gvfs.el b/lisp/net/tramp-gvfs.el index 5afd290d35f..038bb533c3e 100644 --- a/lisp/net/tramp-gvfs.el +++ b/lisp/net/tramp-gvfs.el | |||
| @@ -803,7 +803,7 @@ file names." | |||
| 803 | (tramp-gvfs-maybe-open-connection (vector method user host "/" hop))) | 803 | (tramp-gvfs-maybe-open-connection (vector method user host "/" hop))) |
| 804 | (setq localname | 804 | (setq localname |
| 805 | (replace-match | 805 | (replace-match |
| 806 | (tramp-get-file-property v "/" "default-location" "~") | 806 | (tramp-get-connection-property v "default-location" "~") |
| 807 | nil t localname 1))) | 807 | nil t localname 1))) |
| 808 | ;; Tilde expansion is not possible. | 808 | ;; Tilde expansion is not possible. |
| 809 | (when (string-match "\\`\\(~[^/]*\\)\\(.*\\)\\'" localname) | 809 | (when (string-match "\\`\\(~[^/]*\\)\\(.*\\)\\'" localname) |
| @@ -1418,8 +1418,8 @@ ADDRESS can have the form \"xx:xx:xx:xx:xx:xx\" or \"[xx:xx:xx:xx:xx:xx]\"." | |||
| 1418 | (unless (string-equal prefix "/") | 1418 | (unless (string-equal prefix "/") |
| 1419 | (tramp-set-file-property v "/" "prefix" prefix)) | 1419 | (tramp-set-file-property v "/" "prefix" prefix)) |
| 1420 | (tramp-set-file-property v "/" "fuse-mountpoint" fuse-mountpoint) | 1420 | (tramp-set-file-property v "/" "fuse-mountpoint" fuse-mountpoint) |
| 1421 | (tramp-set-file-property | 1421 | (tramp-set-connection-property |
| 1422 | v "/" "default-location" default-location))))))) | 1422 | v "default-location" default-location))))))) |
| 1423 | 1423 | ||
| 1424 | (when tramp-gvfs-enabled | 1424 | (when tramp-gvfs-enabled |
| 1425 | (dbus-register-signal | 1425 | (dbus-register-signal |
| @@ -1505,7 +1505,8 @@ ADDRESS can have the form \"xx:xx:xx:xx:xx:xx\" or \"[xx:xx:xx:xx:xx:xx]\"." | |||
| 1505 | (unless (string-equal prefix "/") | 1505 | (unless (string-equal prefix "/") |
| 1506 | (tramp-set-file-property vec "/" "prefix" prefix)) | 1506 | (tramp-set-file-property vec "/" "prefix" prefix)) |
| 1507 | (tramp-set-file-property vec "/" "fuse-mountpoint" fuse-mountpoint) | 1507 | (tramp-set-file-property vec "/" "fuse-mountpoint" fuse-mountpoint) |
| 1508 | (tramp-set-file-property vec "/" "default-location" default-location) | 1508 | (tramp-set-connection-property |
| 1509 | vec "default-location" default-location) | ||
| 1509 | (throw 'mounted t))))))) | 1510 | (throw 'mounted t))))))) |
| 1510 | 1511 | ||
| 1511 | (defun tramp-gvfs-mount-spec-entry (key value) | 1512 | (defun tramp-gvfs-mount-spec-entry (key value) |
| @@ -1571,6 +1572,41 @@ It was \"a(say)\", but has changed to \"a{sv})\"." | |||
| 1571 | 1572 | ||
| 1572 | ;; Connection functions. | 1573 | ;; Connection functions. |
| 1573 | 1574 | ||
| 1575 | (defun tramp-gvfs-get-remote-uid (vec id-format) | ||
| 1576 | "The uid of the remote connection VEC, in ID-FORMAT. | ||
| 1577 | ID-FORMAT valid values are `string' and `integer'." | ||
| 1578 | (with-tramp-connection-property vec (format "uid-%s" id-format) | ||
| 1579 | (let ((method (tramp-file-name-method vec)) | ||
| 1580 | (user (tramp-file-name-user vec)) | ||
| 1581 | (host (tramp-file-name-host vec)) | ||
| 1582 | (localname | ||
| 1583 | (tramp-get-connection-property vec "default-location" nil))) | ||
| 1584 | (cond | ||
| 1585 | ((and user (equal id-format 'string)) user) | ||
| 1586 | (localname | ||
| 1587 | (nth 2 (file-attributes | ||
| 1588 | (tramp-make-tramp-file-name method user host localname) | ||
| 1589 | id-format))) | ||
| 1590 | ((equal id-format 'integer) tramp-unknown-id-integer) | ||
| 1591 | ((equal id-format 'string) tramp-unknown-id-string))))) | ||
| 1592 | |||
| 1593 | (defun tramp-gvfs-get-remote-gid (vec id-format) | ||
| 1594 | "The gid of the remote connection VEC, in ID-FORMAT. | ||
| 1595 | ID-FORMAT valid values are `string' and `integer'." | ||
| 1596 | (with-tramp-connection-property vec (format "gid-%s" id-format) | ||
| 1597 | (let ((method (tramp-file-name-method vec)) | ||
| 1598 | (user (tramp-file-name-user vec)) | ||
| 1599 | (host (tramp-file-name-host vec)) | ||
| 1600 | (localname | ||
| 1601 | (tramp-get-connection-property vec "default-location" nil))) | ||
| 1602 | (cond | ||
| 1603 | (localname | ||
| 1604 | (nth 3 (file-attributes | ||
| 1605 | (tramp-make-tramp-file-name method user host localname) | ||
| 1606 | id-format))) | ||
| 1607 | ((equal id-format 'integer) tramp-unknown-id-integer) | ||
| 1608 | ((equal id-format 'string) tramp-unknown-id-string))))) | ||
| 1609 | |||
| 1574 | (defun tramp-gvfs-maybe-open-connection (vec) | 1610 | (defun tramp-gvfs-maybe-open-connection (vec) |
| 1575 | "Maybe open a connection VEC. | 1611 | "Maybe open a connection VEC. |
| 1576 | Does not do anything if a connection is already open, but re-opens the | 1612 | Does not do anything if a connection is already open, but re-opens the |
| @@ -1600,14 +1636,14 @@ connection if a previous connection has died for some reason." | |||
| 1600 | (tramp-gvfs-object-path | 1636 | (tramp-gvfs-object-path |
| 1601 | (tramp-make-tramp-file-name method user host "")))) | 1637 | (tramp-make-tramp-file-name method user host "")))) |
| 1602 | 1638 | ||
| 1603 | (when (and (string-equal method "smb") | ||
| 1604 | (string-equal localname "/")) | ||
| 1605 | (tramp-error vec 'file-error "Filename must contain a Windows share")) | ||
| 1606 | |||
| 1607 | (when (and (string-equal method "afp") | 1639 | (when (and (string-equal method "afp") |
| 1608 | (string-equal localname "/")) | 1640 | (string-equal localname "/")) |
| 1609 | (tramp-error vec 'file-error "Filename must contain an AFP volume")) | 1641 | (tramp-error vec 'file-error "Filename must contain an AFP volume")) |
| 1610 | 1642 | ||
| 1643 | (when (and (string-equal method "smb") | ||
| 1644 | (string-equal localname "/")) | ||
| 1645 | (tramp-error vec 'file-error "Filename must contain a Windows share")) | ||
| 1646 | |||
| 1611 | (with-tramp-progress-reporter | 1647 | (with-tramp-progress-reporter |
| 1612 | vec 3 | 1648 | vec 3 |
| 1613 | (if (zerop (length user)) | 1649 | (if (zerop (length user)) |
| @@ -1680,16 +1716,15 @@ connection if a previous connection has died for some reason." | |||
| 1680 | (tramp-get-connection-process vec) "connected" t)))) | 1716 | (tramp-get-connection-process vec) "connected" t)))) |
| 1681 | 1717 | ||
| 1682 | ;; In `tramp-check-cached-permissions', the connection properties | 1718 | ;; In `tramp-check-cached-permissions', the connection properties |
| 1683 | ;; {uig,gid}-{integer,string} are used. We set them to their local | 1719 | ;; {uig,gid}-{integer,string} are used. We set them to proper values. |
| 1684 | ;; counterparts. | 1720 | (unless (tramp-get-connection-property vec "uid-integer" nil) |
| 1685 | (with-tramp-connection-property | 1721 | (tramp-gvfs-get-remote-uid vec 'integer)) |
| 1686 | vec "uid-integer" (tramp-get-local-uid 'integer)) | 1722 | (unless (tramp-get-connection-property vec "gid-integer" nil) |
| 1687 | (with-tramp-connection-property | 1723 | (tramp-gvfs-get-remote-gid vec 'integer)) |
| 1688 | vec "gid-integer" (tramp-get-local-gid 'integer)) | 1724 | (unless (tramp-get-connection-property vec "uid-string" nil) |
| 1689 | (with-tramp-connection-property | 1725 | (tramp-gvfs-get-remote-uid vec 'string)) |
| 1690 | vec "uid-string" (tramp-get-local-uid 'string)) | 1726 | (unless (tramp-get-connection-property vec "gid-string" nil) |
| 1691 | (with-tramp-connection-property | 1727 | (tramp-gvfs-get-remote-gid vec 'string))) |
| 1692 | vec "gid-string" (tramp-get-local-gid 'string))) | ||
| 1693 | 1728 | ||
| 1694 | (defun tramp-gvfs-send-command (vec command &rest args) | 1729 | (defun tramp-gvfs-send-command (vec command &rest args) |
| 1695 | "Send the COMMAND with its ARGS to connection VEC. | 1730 | "Send the COMMAND with its ARGS to connection VEC. |