diff options
author | Michael Albinus <michael.albinus@gmx.de> | 2022-09-06 12:33:19 +0200 |
---|---|---|
committer | Michael Albinus <michael.albinus@gmx.de> | 2022-09-06 12:33:19 +0200 |
commit | 106456d01bd9b9ffe82c00c4b09a9094a603438e (patch) | |
tree | d22b880bfe42d350784bccd593e4e8a502435f08 /lisp/net/tramp-sudoedit.el | |
parent | eaca6378d2c4b94bc70a7979642502a80bfacd11 (diff) | |
download | emacs-106456d01bd9b9ffe82c00c4b09a9094a603438e.tar.gz |
Use secondary groups when checking permissions in Tramp (Bug#57044)
* lisp/net/tramp.el (tramp-check-cached-permissions): Check also for
secondary groups. (Bug#57044)
(tramp-get-remote-groups):
* lisp/net/tramp-adb.el (tramp-adb-handle-get-remote-groups):
* lisp/net/tramp-sh.el (tramp-sh-handle-get-remote-groups):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-handle-get-remote-groups):
New defuns.
* lisp/net/tramp.el (tramp-file-name-for-operation):
* lisp/net/tramp-adb.el (tramp-adb-file-name-handler-alist):
* lisp/net/tramp-archive.el (tramp-archive-file-name-handler-alist):
* lisp/net/tramp-crypt.el (tramp-crypt-file-name-handler-alist):
* lisp/net/tramp-gvfs.el (tramp-gvfs-file-name-handler-alist):
* lisp/net/tramp-rclone.el (tramp-rclone-file-name-handler-alist):
* lisp/net/tramp-sh.el (tramp-sh-file-name-handler-alist):
* lisp/net/tramp-smb.el (tramp-smb-file-name-handler-alist):
* lisp/net/tramp-sshfs.el (tramp-sshfs-file-name-handler-alist):
* lisp/net/tramp-sudoedit.el (tramp-sudoedit-file-name-handler-alist):
Add `tramp-get-remote-groups'.
* lisp/net/tramp.el:
* lisp/net/tramp-adb.el:
* lisp/net/tramp-cache.el:
* lisp/net/tramp-crypt.el:
* lisp/net/tramp-fuse.el:
* lisp/net/tramp-gvfs.el:
* lisp/net/tramp-integration.el:
* lisp/net/tramp-rclone.el:
* lisp/net/tramp-sh.el:
* lisp/net/tramp-smb.el:
* lisp/net/tramp-sudoedit.el: Use `blank' in `rx' forms.
* test/lisp/net/tramp-archive-tests.el:
* test/lisp/net/tramp-tests.el: Use `blank' in `rx' forms.
Diffstat (limited to 'lisp/net/tramp-sudoedit.el')
-rw-r--r-- | lisp/net/tramp-sudoedit.el | 36 |
1 files changed, 31 insertions, 5 deletions
diff --git a/lisp/net/tramp-sudoedit.el b/lisp/net/tramp-sudoedit.el index 893afcdbbee..ef0954ab83f 100644 --- a/lisp/net/tramp-sudoedit.el +++ b/lisp/net/tramp-sudoedit.el @@ -143,6 +143,7 @@ See `tramp-actions-before-shell' for more info.") (temporary-file-directory . tramp-handle-temporary-file-directory) (tramp-get-home-directory . tramp-sudoedit-handle-get-home-directory) (tramp-get-remote-gid . tramp-sudoedit-handle-get-remote-gid) + (tramp-get-remote-groups . tramp-sudoedit-handle-get-remote-groups) (tramp-get-remote-uid . tramp-sudoedit-handle-get-remote-uid) (tramp-set-file-uid-gid . tramp-sudoedit-handle-set-file-uid-gid) (unhandled-file-name-directory . ignore) @@ -473,7 +474,7 @@ the result will be a local, non-Tramp, file name." (delq nil (mapcar - (lambda (l) (and (not (string-match-p (rx bol (* space) eol) l)) l)) + (lambda (l) (and (not (string-match-p (rx bol (* blank) eol) l)) l)) (split-string (tramp-get-buffer-string (tramp-get-connection-buffer v)) "\n" 'omit)))))))) @@ -535,9 +536,9 @@ the result will be a local, non-Tramp, file name." (goto-char (point-min)) (forward-line) (when (looking-at - (rx (* space) (group (+ digit)) - (+ space) (group (+ digit)) - (+ space) (group (+ digit)))) + (rx (* blank) (group (+ digit)) + (+ blank) (group (+ digit)) + (+ blank) (group (+ digit)))) (list (string-to-number (match-string 1)) ;; The second value is the used size. We need the ;; free size. @@ -732,6 +733,31 @@ ID-FORMAT valid values are `string' and `integer'." (tramp-sudoedit-send-command-and-read vec "id" "-g") (tramp-sudoedit-send-command-string vec "id" "-gn"))) +(defun tramp-sudoedit-handle-get-remote-groups (vec id-format) + "Like `tramp-get-remote-groups' for Tramp files. +ID-FORMAT valid values are `string' and `integer'." + ;; The result is cached in `tramp-get-remote-groups'. + (tramp-sudoedit-send-command vec "id") + (with-current-buffer (tramp-get-connection-buffer vec) + (let (groups-integer groups-string) + ;; Read the expression. + (goto-char (point-min)) + (when (re-search-forward (rx bol (+ nonl) "groups=") nil 'noerror) + (while (looking-at + (rx (group (+ digit)) "(" (group (+ (any "_" word))) ")")) + (setq groups-integer (cons (string-to-number (match-string 1)) + groups-integer) + groups-string (cons (match-string 2) groups-string)) + (goto-char (match-end 0)) + (skip-chars-forward ","))) + (tramp-set-connection-property + vec "groups-integer" + (setq groups-integer (nreverse groups-integer))) + (tramp-set-connection-property + vec "groups-string" + (setq groups-string (nreverse groups-string))) + (if (eq id-format 'integer) groups-integer groups-string)))) + (defun tramp-sudoedit-handle-set-file-uid-gid (filename &optional uid gid) "Like `tramp-set-file-uid-gid' for Tramp files." (tramp-skeleton-set-file-modes-times-uid-gid filename @@ -846,7 +872,7 @@ In case there is no valid Lisp expression, it raises an error." (condition-case nil (prog1 (read (current-buffer)) ;; Error handling. - (when (re-search-forward (rx (not space)) (line-end-position) t) + (when (re-search-forward (rx (not blank)) (line-end-position) t) (error nil))) (error (tramp-error vec 'file-error |