emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] /srv/bzr/emacs/trunk r100075: * net/tramp.el (tramp-remote


From: Michael Albinus
Subject: [Emacs-diffs] /srv/bzr/emacs/trunk r100075: * net/tramp.el (tramp-remote-selinux-p): New defun.
Date: Wed, 28 Apr 2010 20:42:20 +0200
User-agent: Bazaar (2.0.3)

------------------------------------------------------------
revno: 100075
committer: Michael Albinus <address@hidden>
branch nick: trunk
timestamp: Wed 2010-04-28 20:42:20 +0200
message:
  * net/tramp.el (tramp-remote-selinux-p): New defun.
  (tramp-handle-file-selinux-context)
  (tramp-handle-set-file-selinux-context): Use it.
modified:
  lisp/ChangeLog
  lisp/net/tramp.el
=== modified file 'lisp/ChangeLog'
--- a/lisp/ChangeLog    2010-04-28 16:14:41 +0000
+++ b/lisp/ChangeLog    2010-04-28 18:42:20 +0000
@@ -1,3 +1,9 @@
+2010-04-28  Michael Albinus  <address@hidden>
+
+       * net/tramp.el (tramp-remote-selinux-p): New defun.
+       (tramp-handle-file-selinux-context)
+       (tramp-handle-set-file-selinux-context): Use it.
+
 2010-04-28  Sam Steingold  <address@hidden>
 
        * progmodes/bug-reference.el (bug-reference-url-format): Mark as

=== modified file 'lisp/net/tramp.el'
--- a/lisp/net/tramp.el 2010-04-23 14:12:05 +0000
+++ b/lisp/net/tramp.el 2010-04-28 18:42:20 +0000
@@ -3030,6 +3030,17 @@
         "chown" nil nil nil
          (format "%d:%d" uid gid) (tramp-shell-quote-argument filename))))))
 
+(defun tramp-remote-selinux-p (vec)
+  "Check, whether SELINUX is enabled on the remote host."
+  (with-connection-property (tramp-get-connection-process vec) "selinux-p"
+    (let ((result (tramp-find-executable
+                  vec "getenforce" (tramp-get-remote-path vec) t t)))
+      (and result
+          (string-equal
+           (tramp-send-command-and-read
+            vec (format "echo \\\"`%S`\\\"" result))
+           "Enforcing")))))
+
 (defun tramp-handle-file-selinux-context (filename)
   "Like `file-selinux-context' for Tramp files."
   (with-parsed-tramp-file-name filename nil
@@ -3037,11 +3048,12 @@
       (let ((context '(nil nil nil nil))
            (regexp (concat "\\([a-z0-9_]+\\):" "\\([a-z0-9_]+\\):"
                            "\\([a-z0-9_]+\\):" "\\([a-z0-9_]+\\)")))
-       (when (zerop (tramp-send-command-and-check
-                     v (format
-                        "%s -d -Z %s"
-                        (tramp-get-ls-command v)
-                        (tramp-shell-quote-argument localname))))
+       (when (and (tramp-remote-selinux-p v)
+                  (zerop (tramp-send-command-and-check
+                          v (format
+                             "%s -d -Z %s"
+                             (tramp-get-ls-command v)
+                             (tramp-shell-quote-argument localname)))))
          (with-current-buffer (tramp-get-connection-buffer v)
            (goto-char (point-min))
            (when (re-search-forward regexp (tramp-compat-line-end-position) t)
@@ -3054,6 +3066,7 @@
   "Like `set-file-selinux-context' for Tramp files."
   (with-parsed-tramp-file-name filename nil
     (if (and (consp context)
+            (tramp-remote-selinux-p v)
             (zerop (tramp-send-command-and-check
                     v (format "chcon %s %s %s %s %s"
                               (if (stringp (nth 0 context))
@@ -6924,7 +6937,7 @@
          (tramp-send-command-and-read vec "echo \\\"`uname -sr`\\\""))))
     (when (and (stringp old-uname) (not (string-equal old-uname new-uname)))
       (with-current-buffer (tramp-get-debug-buffer vec)
-       ;; Keep the debug buffer
+       ;; Keep the debug buffer.
        (rename-buffer
         (generate-new-buffer-name tramp-temp-buffer-name) 'unique)
        (funcall (symbol-function 'tramp-cleanup-connection) vec)
@@ -8752,7 +8765,6 @@
 ;;   on remote hosts.
 ;; * Use secrets.el for password handling.
 ;; * Load ~/.emacs_SHELLNAME on the remote host for `shell'.
-;; * Implement selinux-context.
 
 ;; Functions for file-name-handler-alist:
 ;; diff-latest-backup-file -- in diff.el


reply via email to

[Prev in Thread] Current Thread [Next in Thread]