From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eli Barzilay Newsgroups: gmane.emacs.bugs Subject: bug#21699: 24.5; Bug in backup-buffer-copy and/or set-file-extended-attributes etc [set-file-extended-attributes] Date: Mon, 19 Oct 2015 03:50:04 -0400 Message-ID: References: <831tcricrz.fsf@gnu.org> <83zizfgxnl.fsf@gnu.org> <83wpujgwr3.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1445241123 31287 80.91.229.3 (19 Oct 2015 07:52:03 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 19 Oct 2015 07:52:03 +0000 (UTC) Cc: 21699@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Oct 19 09:51:53 2015 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Zo5EW-0008Fd-9X for geb-bug-gnu-emacs@m.gmane.org; Mon, 19 Oct 2015 09:51:52 +0200 Original-Received: from localhost ([::1]:37099 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zo5EV-0006Pa-9L for geb-bug-gnu-emacs@m.gmane.org; Mon, 19 Oct 2015 03:51:51 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:36136) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zo5Dl-0005fB-LQ for bug-gnu-emacs@gnu.org; Mon, 19 Oct 2015 03:51:06 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zo5Di-0000cT-EW for bug-gnu-emacs@gnu.org; Mon, 19 Oct 2015 03:51:05 -0400 Original-Received: from debbugs.gnu.org ([208.118.235.43]:36756) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zo5Di-0000cP-B2 for bug-gnu-emacs@gnu.org; Mon, 19 Oct 2015 03:51:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1Zo5Di-0006Os-4F for bug-gnu-emacs@gnu.org; Mon, 19 Oct 2015 03:51:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Barzilay Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 19 Oct 2015 07:51:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 21699 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 21699-submit@debbugs.gnu.org id=B21699.144524100824521 (code B ref 21699); Mon, 19 Oct 2015 07:51:02 +0000 Original-Received: (at 21699) by debbugs.gnu.org; 19 Oct 2015 07:50:08 +0000 Original-Received: from localhost ([127.0.0.1]:55687 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zo5Cp-0006NO-8H for submit@debbugs.gnu.org; Mon, 19 Oct 2015 03:50:07 -0400 Original-Received: from mail-ig0-f181.google.com ([209.85.213.181]:37507) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Zo5Cn-0006N7-CF for 21699@debbugs.gnu.org; Mon, 19 Oct 2015 03:50:06 -0400 Original-Received: by igbhv6 with SMTP id hv6so51431917igb.0 for <21699@debbugs.gnu.org>; Mon, 19 Oct 2015 00:50:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=gUDCYpkjm3wStcGKRxUBaUcr/z3klt6bGLIHhb2tYs4=; b=QJfiRGe0lWmk6ac4oyo5wu+EG4kgDTohmd+5SqjTh8FU8EEfZc5sR+pogIx8b06y6J Q7ZnPZPmqN5XBOlLhRVu+ZQ0sFAjj2mAOW8f28zM5QFzA5rJVC3PvEE9JqibxAcZgerG +un09mwTC5q8+AJiEIIUBGmsLA+FI/9UEKgTkHjho8ocOGW/foLY+D8S4MU41uBxrU/L 5WlNhD82GALuAPVy18Y8MM8jSJW0ZqvcjuLSjUnUMjz0sgA4/0PoCkjMzNVdL78kocyF Fpu2ywJF9FntTzs7QmP9+VlySzVeoQHy7EUaF9o1om5POfOrJGyEf0kjaFVFChyFtfJo NfUg== X-Gm-Message-State: ALoCoQmxsvNb3Mn0B02bj3mJFlzl38UsiUhNXp7tJ2UyKcpywYtn2oQ3jsz9encwHZz07D6JDZjR X-Received: by 10.51.17.39 with SMTP id gb7mr16860000igd.56.1445241004674; Mon, 19 Oct 2015 00:50:04 -0700 (PDT) Original-Received: by 10.79.28.211 with HTTP; Mon, 19 Oct 2015 00:50:04 -0700 (PDT) In-Reply-To: <83wpujgwr3.fsf@gnu.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 208.118.235.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:107740 Archived-At: [I'm working on the other things that you asked now...] On Mon, Oct 19, 2015 at 3:09 AM, Eli Zaretskii wrote: >> Date: Mon, 19 Oct 2015 09:50:06 +0300 >> From: Eli Zaretskii >> Cc: 21699@debbugs.gnu.org >> >> > Date: Mon, 19 Oct 2015 09:38:08 +0300 >> > From: Eli Zaretskii >> > Cc: 21699@debbugs.gnu.org >> > >> > So after fixing set-file-extended-attributes as you suggest, does the >> > problem still happen for you? >> >> Actually, your suggested variant also returns nil for me. Well, it would return nil since the result of `file-extended-attributes' would include (selinux-context nil nil nil nil) which sould make it try to use `set-file-selinux-context' and that returns nil. (That was my original point #3, addressed below.) >> I need something like this instead: >> [...2nd version...] This one would indeed return t for me, since it stops trying after the first t result from `set-file-acl'. > I installed a slightly different variant of this (which always invokes > the corresponding low-level primitive for each type of extended > attributes, instead of skipping all those after the first success), to > keep the original semantics. Well, you added this in the docstring: Value is t if the function succeeds in setting the attributes. which is a little vague -- I think that it would be better to say Value is t if the function succeeds in setting at least one of the attributes. *BUT* I doubt that this is a good idea, since on a system that supports both acl and selinux-context you probably want a t result to indicate that all of the extended settings worked. So I think that my original suggestion is better if `file-extended-attributes' doesn't produce values that are not supported. So ... moving on to that third problem, I fixed `file-extended-attributes' to do that: it doesn't include an `acl' value if `file-acl' returned nil, and doesn't include `selinux-context' if `file-selinux-context' returned (nil nil nil nil). I used this with my version of `set-file-extended-attributes' (which returns t only when all settings returned non-nil), and that resolved my backup problem. The code for the two functions, with updated docstrings, is below. ------------------------------------------------------------------------------- (defun file-extended-attributes (filename) "Return an alist of extended attributes of file FILENAME. Extended attributes are platform-specific metadata about the file, such as SELinux context, list of ACL entries, etc. Only supported metadata is included." (let ((attrs '()) x) (unless (equal nil (setq x (file-acl filename))) (push `(acl . ,x) attrs)) (unless (equal '(nil nil nil nil) (setq x (file-selinux-context filename))) (push `(selinux-context . ,x) attrs)) attrs)) (defun set-file-extended-attributes (filename attributes) "Set extended attributes of file FILENAME to ATTRIBUTES. ATTRIBUTES must be an alist of file attributes as returned by `file-extended-attributes'. Value is t if the function succeeds in setting all of the given attributes." (let ((result t)) (dolist (elt attributes) (let ((attr (car elt)) (val (cdr elt))) (unless (cond ((eq attr 'acl) (set-file-acl filename val)) ((eq attr 'selinux-context) (set-file-selinux-context filename val))) (setq result nil)))) result)) ------------------------------------------------------------------------------- -- ((x=>x(x))(x=>x(x))) Eli Barzilay: http://barzilay.org/ Maze is Life!