diff options
| author | Michael Albinus | 2015-08-15 13:00:01 +0200 |
|---|---|---|
| committer | Michael Albinus | 2015-08-15 13:00:01 +0200 |
| commit | 8b73aab8e14ae05ff9f4f94dfd2ba94f6b3f3696 (patch) | |
| tree | 2afb317ae87d431e94ef0a831cf3f61b6e4653de | |
| parent | fd96e2d9c97fdde96bdab3ef24aa20aa3d8ed3d0 (diff) | |
| download | emacs-8b73aab8e14ae05ff9f4f94dfd2ba94f6b3f3696.tar.gz emacs-8b73aab8e14ae05ff9f4f94dfd2ba94f6b3f3696.zip | |
* lisp/net/tramp-sh.el (tramp-remote-selinux-p): Use "selinuxenabled"
rather than "getenforce".
(tramp-sh-handle-set-file-selinux-context): Do not
cache SELinux context if not all context components are given.
| -rw-r--r-- | lisp/net/tramp-sh.el | 48 |
1 files changed, 21 insertions, 27 deletions
diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el index 7f7558e93b5..49d4c4a8c31 100644 --- a/lisp/net/tramp-sh.el +++ b/lisp/net/tramp-sh.el | |||
| @@ -1492,15 +1492,8 @@ be non-negative integers." | |||
| 1492 | 1492 | ||
| 1493 | (defun tramp-remote-selinux-p (vec) | 1493 | (defun tramp-remote-selinux-p (vec) |
| 1494 | "Check, whether SELINUX is enabled on the remote host." | 1494 | "Check, whether SELINUX is enabled on the remote host." |
| 1495 | (with-tramp-connection-property | 1495 | (with-tramp-connection-property (tramp-get-connection-process vec) "selinux-p" |
| 1496 | (tramp-get-connection-process vec) "selinux-p" | 1496 | (tramp-send-command-and-check vec "selinuxenabled"))) |
| 1497 | (let ((result (tramp-find-executable | ||
| 1498 | vec "getenforce" (tramp-get-remote-path vec) t t))) | ||
| 1499 | (and result | ||
| 1500 | (string-equal | ||
| 1501 | (tramp-send-command-and-read | ||
| 1502 | vec (format "echo \\\"`%S`\\\"" result)) | ||
| 1503 | "Enforcing"))))) | ||
| 1504 | 1497 | ||
| 1505 | (defun tramp-sh-handle-file-selinux-context (filename) | 1498 | (defun tramp-sh-handle-file-selinux-context (filename) |
| 1506 | "Like `file-selinux-context' for Tramp files." | 1499 | "Like `file-selinux-context' for Tramp files." |
| @@ -1526,24 +1519,25 @@ be non-negative integers." | |||
| 1526 | (defun tramp-sh-handle-set-file-selinux-context (filename context) | 1519 | (defun tramp-sh-handle-set-file-selinux-context (filename context) |
| 1527 | "Like `set-file-selinux-context' for Tramp files." | 1520 | "Like `set-file-selinux-context' for Tramp files." |
| 1528 | (with-parsed-tramp-file-name filename nil | 1521 | (with-parsed-tramp-file-name filename nil |
| 1529 | (if (and (consp context) | 1522 | (when (and (consp context) |
| 1530 | (tramp-remote-selinux-p v) | 1523 | (tramp-remote-selinux-p v)) |
| 1531 | (tramp-send-command-and-check | 1524 | (let ((user (and (stringp (nth 0 context)) (nth 0 context))) |
| 1532 | v (format "chcon %s %s %s %s %s" | 1525 | (role (and (stringp (nth 1 context)) (nth 1 context))) |
| 1533 | (if (stringp (nth 0 context)) | 1526 | (type (and (stringp (nth 2 context)) (nth 2 context))) |
| 1534 | (format "--user=%s" (nth 0 context)) "") | 1527 | (range (and (stringp (nth 3 context)) (nth 3 context)))) |
| 1535 | (if (stringp (nth 1 context)) | 1528 | (when (tramp-send-command-and-check |
| 1536 | (format "--role=%s" (nth 1 context)) "") | 1529 | v (format "chcon %s %s %s %s %s" |
| 1537 | (if (stringp (nth 2 context)) | 1530 | (if user (format "--user=%s" user) "") |
| 1538 | (format "--type=%s" (nth 2 context)) "") | 1531 | (if role (format "--role=%s" role) "") |
| 1539 | (if (stringp (nth 3 context)) | 1532 | (if type (format "--type=%s" type) "") |
| 1540 | (format "--range=%s" (nth 3 context)) "") | 1533 | (if range (format "--range=%s" range) "") |
| 1541 | (tramp-shell-quote-argument localname)))) | 1534 | (tramp-shell-quote-argument localname))) |
| 1542 | (progn | 1535 | (if (and user role type range) |
| 1543 | (tramp-set-file-property v localname "file-selinux-context" context) | 1536 | (tramp-set-file-property |
| 1544 | t) | 1537 | v localname "file-selinux-context" context) |
| 1545 | (tramp-set-file-property v localname "file-selinux-context" 'undef) | 1538 | (tramp-set-file-property |
| 1546 | nil))) | 1539 | v localname "file-selinux-context" 'undef)) |
| 1540 | t))))) | ||
| 1547 | 1541 | ||
| 1548 | (defun tramp-remote-acl-p (vec) | 1542 | (defun tramp-remote-acl-p (vec) |
| 1549 | "Check, whether ACL is enabled on the remote host." | 1543 | "Check, whether ACL is enabled on the remote host." |