From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Robert Pluim Newsgroups: gmane.emacs.bugs Subject: bug#37884: 27.0.50; Cannot write to a file in VirtualBox shared directory Date: Mon, 28 Oct 2019 13:32:45 +0100 Message-ID: References: <87h83zeoy1.fsf@pobox.com> <87blu2emi3.fsf@pobox.com> <83lft6rxrs.fsf@gnu.org> <874kztdy0l.fsf@pobox.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="89492"; mail-complaints-to="usenet@blaine.gmane.org" Cc: 37884@debbugs.gnu.org To: Bernardo Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Oct 28 14:10:28 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1iP4my-000NAF-2h for geb-bug-gnu-emacs@m.gmane.org; Mon, 28 Oct 2019 14:10:28 +0100 Original-Received: from localhost ([::1]:53586 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iP4mw-0006Ca-4c for geb-bug-gnu-emacs@m.gmane.org; Mon, 28 Oct 2019 09:10:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52988) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iP4Cm-0001QQ-03 for bug-gnu-emacs@gnu.org; Mon, 28 Oct 2019 08:33:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iP4Ck-0001al-Sz for bug-gnu-emacs@gnu.org; Mon, 28 Oct 2019 08:33:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:35173) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iP4Ck-0001aZ-6f for bug-gnu-emacs@gnu.org; Mon, 28 Oct 2019 08:33:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1iP4Ck-0003s9-1A for bug-gnu-emacs@gnu.org; Mon, 28 Oct 2019 08:33:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Robert Pluim Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 28 Oct 2019 12:33:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 37884 X-GNU-PR-Package: emacs Original-Received: via spool by 37884-submit@debbugs.gnu.org id=B37884.157226597614873 (code B ref 37884); Mon, 28 Oct 2019 12:33:01 +0000 Original-Received: (at 37884) by debbugs.gnu.org; 28 Oct 2019 12:32:56 +0000 Original-Received: from localhost ([127.0.0.1]:43994 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iP4Cd-0003rp-Rz for submit@debbugs.gnu.org; Mon, 28 Oct 2019 08:32:56 -0400 Original-Received: from mail-wm1-f42.google.com ([209.85.128.42]:34957) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1iP4Cb-0003ra-Up for 37884@debbugs.gnu.org; Mon, 28 Oct 2019 08:32:54 -0400 Original-Received: by mail-wm1-f42.google.com with SMTP id x5so1698985wmi.0 for <37884@debbugs.gnu.org>; Mon, 28 Oct 2019 05:32:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:mail-copies-to:gmane-reply-to-list :date:in-reply-to:message-id:mime-version; bh=P/qsAyEiOecc8hPbcEaEHBoP5CdW/bx7hmGXI4y8jiQ=; b=mstzEXLY5JYQ04waeUpUpyeV/EWvscoXcOj4ROFI+tX+X+eojARur6CBCdy9VbWymf hno/bo44NJaWXN5BKzXn9oy77YKHKWBHlsTatbSYurVnFwAlbInFyNqn+ws+2RMkIJpz bctJasu2CUNOR3O86UTK43wGqNPlieqo9EYRMDTrhYJESDsd0kZjqja1uKxnIVZLs+8h 5jPLt5AmbNtjO6X7SZQPegtk8+tI52NbEv4xrRPILlYZ9bad6i7JTHoc26ZLCClobDU2 wYog7c9cxebLWbWQmaiSSo53EUN98SCrewEGIvbTdm7jXgMqOqMmv5AOlgmFyFVxBD/y R5CA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:mail-copies-to :gmane-reply-to-list:date:in-reply-to:message-id:mime-version; bh=P/qsAyEiOecc8hPbcEaEHBoP5CdW/bx7hmGXI4y8jiQ=; b=DyQ2Vy5KjKGPjes+oyZj5LUI5NvUB75Rxk3ZeYncgo1KyjEYqkAPc9hBwpF3wYi7cX HwWFfqwkNzfUAlMBlykc9fHWmkRTX/mV/ZGt+GPKPEid7ARg1EjQe4AOaknIeFijxJlV jxhyVdsmAWWaUjjVIM/IpVEr9OENLvjaHAzsas3B4+kjhCP4Rl2GewNbkFtH1oZzyI90 /xuEX+dhrE99oMPK3g8xsm0j/GaQ8NY/t7iBNBLMsxK0tv5MUs4TYfWAEPlOuMgnOzSv o8nkIWBeriXVjC9DQuSkznEnwL968b+hOqUFIjewJI7gz5WYpk/yxtIeFJLaX9XS0RFS aK7w== X-Gm-Message-State: APjAAAV4h1SXjmRXzZtCUzx9Bzs7dT97BRruDF/jn7Yvw0vsHVnFQNvq FFUj/KZuKKcecBHZ90xy1FM6Sdla X-Google-Smtp-Source: APXvYqxBUmxruRyZ7KuWmTaI/eRotccmasPET2Knt8OsoVi4ruR0cNrWbLbim7bKZ3MC2YByMKNbDw== X-Received: by 2002:a1c:e912:: with SMTP id q18mr15279897wmc.42.1572265967580; Mon, 28 Oct 2019 05:32:47 -0700 (PDT) Original-Received: from rpluim-mac ([2a01:e34:ecfc:a860:100d:44e5:c295:82b2]) by smtp.gmail.com with ESMTPSA id s21sm15512728wrb.31.2019.10.28.05.32.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 05:32:46 -0700 (PDT) Mail-Copies-To: never Gmane-Reply-To-List: yes In-Reply-To: <874kztdy0l.fsf@pobox.com> (Bernardo's message of "Mon, 28 Oct 2019 20:23:22 +1100") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.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" Xref: news.gmane.org gmane.emacs.bugs:170294 Archived-At: >>>>> On Mon, 28 Oct 2019 20:23:22 +1100, Bernardo said: Bernardo> $ git diff src/filelock.c Bernardo> diff --git a/src/filelock.c b/src/filelock.c Bernardo> index ff25d6475d..79eb8fa91e 100644 Bernardo> --- a/src/filelock.c Bernardo> +++ b/src/filelock.c Bernardo> @@ -403,7 +403,7 @@ create_lock_file (char *lfname, char *lock_info_str, bool force) Bernardo> lock_info_len = strlen (lock_info_str); Bernardo> err = 0; Bernardo> if (emacs_write (fd, lock_info_str, lock_info_len) != lock_info_len Bernardo> - || fchmod (fd, S_IRUSR | S_IRGRP | S_IROTH) != 0) Bernardo> + || fchmod (fd, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH) != 0) Bernardo> err = errno; Bernardo> /* There is no need to call fsync here, as the contents of Bernardo> the lock file need not survive system crashes. */ Bernardo> and Emacs is happy again, no problems with writing to files in Bernardo> VirtualBox shared directory. Bernardo> Please let me know if you want me to test anything else. I think Eli's suggestion was more like the below, which only calls fchmod if the unlink fails. diff --git a/src/filelock.c b/src/filelock.c index ff25d6475d..7fb14774b0 100644 --- a/src/filelock.c +++ b/src/filelock.c @@ -732,6 +732,15 @@ unlock_file (Lisp_Object fn) int err = current_lock_owner (0, lfname); if (err == -2 && unlink (lfname) != 0 && errno != ENOENT) err = errno; + /* On certain filesystems the file must be writable for unlink to + succeed (Bug#37784). */ + if (errno == EPERM) + { + fchmod (fd, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); + errno = 0; + if (unlink (lfname) != 0 && errno != ENOENT) + err = errno; + } if (0 < err) report_file_errno ("Unlocking file", filename, err);