aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Albinus2010-04-28 20:42:20 +0200
committerMichael Albinus2010-04-28 20:42:20 +0200
commit7ba947016008a5fcee64eb8660d688afb4414b96 (patch)
treec042d2a67f5e2c6036d48634b513486017e74f32
parent95c6cc3eff959dd8b107f1c54c1e3507fb4bb24e (diff)
downloademacs-7ba947016008a5fcee64eb8660d688afb4414b96.tar.gz
emacs-7ba947016008a5fcee64eb8660d688afb4414b96.zip
* net/tramp.el (tramp-remote-selinux-p): New defun.
(tramp-handle-file-selinux-context) (tramp-handle-set-file-selinux-context): Use it.
-rw-r--r--lisp/ChangeLog6
-rw-r--r--lisp/net/tramp.el26
2 files changed, 25 insertions, 7 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 3eba70f40af..649fa409ff4 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,9 @@
12010-04-28 Michael Albinus <michael.albinus@gmx.de>
2
3 * net/tramp.el (tramp-remote-selinux-p): New defun.
4 (tramp-handle-file-selinux-context)
5 (tramp-handle-set-file-selinux-context): Use it.
6
12010-04-28 Sam Steingold <sds@gnu.org> 72010-04-28 Sam Steingold <sds@gnu.org>
2 8
3 * progmodes/bug-reference.el (bug-reference-url-format): Mark as 9 * progmodes/bug-reference.el (bug-reference-url-format): Mark as
diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el
index a4442e9b54b..f82ecddc3c4 100644
--- a/lisp/net/tramp.el
+++ b/lisp/net/tramp.el
@@ -3030,6 +3030,17 @@ and gid of the corresponding user is taken. Both parameters must be integers."
3030 "chown" nil nil nil 3030 "chown" nil nil nil
3031 (format "%d:%d" uid gid) (tramp-shell-quote-argument filename)))))) 3031 (format "%d:%d" uid gid) (tramp-shell-quote-argument filename))))))
3032 3032
3033(defun tramp-remote-selinux-p (vec)
3034 "Check, whether SELINUX is enabled on the remote host."
3035 (with-connection-property (tramp-get-connection-process vec) "selinux-p"
3036 (let ((result (tramp-find-executable
3037 vec "getenforce" (tramp-get-remote-path vec) t t)))
3038 (and result
3039 (string-equal
3040 (tramp-send-command-and-read
3041 vec (format "echo \\\"`%S`\\\"" result))
3042 "Enforcing")))))
3043
3033(defun tramp-handle-file-selinux-context (filename) 3044(defun tramp-handle-file-selinux-context (filename)
3034 "Like `file-selinux-context' for Tramp files." 3045 "Like `file-selinux-context' for Tramp files."
3035 (with-parsed-tramp-file-name filename nil 3046 (with-parsed-tramp-file-name filename nil
@@ -3037,11 +3048,12 @@ and gid of the corresponding user is taken. Both parameters must be integers."
3037 (let ((context '(nil nil nil nil)) 3048 (let ((context '(nil nil nil nil))
3038 (regexp (concat "\\([a-z0-9_]+\\):" "\\([a-z0-9_]+\\):" 3049 (regexp (concat "\\([a-z0-9_]+\\):" "\\([a-z0-9_]+\\):"
3039 "\\([a-z0-9_]+\\):" "\\([a-z0-9_]+\\)"))) 3050 "\\([a-z0-9_]+\\):" "\\([a-z0-9_]+\\)")))
3040 (when (zerop (tramp-send-command-and-check 3051 (when (and (tramp-remote-selinux-p v)
3041 v (format 3052 (zerop (tramp-send-command-and-check
3042 "%s -d -Z %s" 3053 v (format
3043 (tramp-get-ls-command v) 3054 "%s -d -Z %s"
3044 (tramp-shell-quote-argument localname)))) 3055 (tramp-get-ls-command v)
3056 (tramp-shell-quote-argument localname)))))
3045 (with-current-buffer (tramp-get-connection-buffer v) 3057 (with-current-buffer (tramp-get-connection-buffer v)
3046 (goto-char (point-min)) 3058 (goto-char (point-min))
3047 (when (re-search-forward regexp (tramp-compat-line-end-position) t) 3059 (when (re-search-forward regexp (tramp-compat-line-end-position) t)
@@ -3054,6 +3066,7 @@ and gid of the corresponding user is taken. Both parameters must be integers."
3054 "Like `set-file-selinux-context' for Tramp files." 3066 "Like `set-file-selinux-context' for Tramp files."
3055 (with-parsed-tramp-file-name filename nil 3067 (with-parsed-tramp-file-name filename nil
3056 (if (and (consp context) 3068 (if (and (consp context)
3069 (tramp-remote-selinux-p v)
3057 (zerop (tramp-send-command-and-check 3070 (zerop (tramp-send-command-and-check
3058 v (format "chcon %s %s %s %s %s" 3071 v (format "chcon %s %s %s %s %s"
3059 (if (stringp (nth 0 context)) 3072 (if (stringp (nth 0 context))
@@ -6924,7 +6937,7 @@ process to set up. VEC specifies the connection."
6924 (tramp-send-command-and-read vec "echo \\\"`uname -sr`\\\"")))) 6937 (tramp-send-command-and-read vec "echo \\\"`uname -sr`\\\""))))
6925 (when (and (stringp old-uname) (not (string-equal old-uname new-uname))) 6938 (when (and (stringp old-uname) (not (string-equal old-uname new-uname)))
6926 (with-current-buffer (tramp-get-debug-buffer vec) 6939 (with-current-buffer (tramp-get-debug-buffer vec)
6927 ;; Keep the debug buffer 6940 ;; Keep the debug buffer.
6928 (rename-buffer 6941 (rename-buffer
6929 (generate-new-buffer-name tramp-temp-buffer-name) 'unique) 6942 (generate-new-buffer-name tramp-temp-buffer-name) 'unique)
6930 (funcall (symbol-function 'tramp-cleanup-connection) vec) 6943 (funcall (symbol-function 'tramp-cleanup-connection) vec)
@@ -8752,7 +8765,6 @@ Only works for Bourne-like shells."
8752;; on remote hosts. 8765;; on remote hosts.
8753;; * Use secrets.el for password handling. 8766;; * Use secrets.el for password handling.
8754;; * Load ~/.emacs_SHELLNAME on the remote host for `shell'. 8767;; * Load ~/.emacs_SHELLNAME on the remote host for `shell'.
8755;; * Implement selinux-context.
8756 8768
8757;; Functions for file-name-handler-alist: 8769;; Functions for file-name-handler-alist:
8758;; diff-latest-backup-file -- in diff.el 8770;; diff-latest-backup-file -- in diff.el