From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id SN7SFY4fSmXeNAEAG6o9tA:P1 (envelope-from ) for ; Tue, 07 Nov 2023 12:29:18 +0100 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id SN7SFY4fSmXeNAEAG6o9tA (envelope-from ) for ; Tue, 07 Nov 2023 12:29:18 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 055DB21099 for ; Tue, 7 Nov 2023 12:29:17 +0100 (CET) Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=mvy7sX1r; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1699356558; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=JCTu+sRY1OpRoQA0Nd0+4VJkEecUa7cGA2KsC+a6hmQ=; b=otAyAoIqrMcCIA0EbeDyIgMn7Gz8zriC092cSTYzQUkXVP6SLxcQ/p81fvPm9+lWr5Ys/u BJx3Iq0WNYpetimXtWJUsCa/ftOqz2S7NP33eDHLNgqjDsNZkPF0aC6J3/9g76AYYBs94Q /tAl0YHfIEfVRKR+ZOW6eXsw9QZghcaKbNpwzH0t6Ge0kBX5Qc8YNDsH9lbbGSORcooFJa Oke5somiyQWfiRpnSwbmBNkAI7pdjSGdR3xZgb0SnqyDuzua68zq7tYUkvgsWTsy80TUXW EW8p2iI7Y5VygCikFoTuBWEYZaU6MqKM5M1S2cgc06VlMQI1ehj5hoFOwlgcEA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=posteo.net header.s=2017 header.b=mvy7sX1r; dmarc=pass (policy=none) header.from=posteo.net; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1699356558; a=rsa-sha256; cv=none; b=Gk80FVaUAVswcQIDVG+Hck09U4PmF6ORCrcqPkTJ5O+BjlM0RuBBZaNEF+Iabp3aBOzl+p opiHb1lO7KqsKv0YgYztCNohHy6fCDNA7MMMiL/vDm/h9vO/z6eczEz9XlRDHXlu2bSDfg 31mxOjXviyPgqtbCRDawQe/1ht88oV5AQZaVGnzTbMM9QjzH//j/utKXG+iC9wL7aTqEZI cpeA8YL81xS8zixTvWzQA0gqx9W0weOEj+c6dRLm6v39neQ4E8EddOjT+siRZKt4+59ybY XfJ/Kfkv7u0Pa3EX65vBfzfnvbGhfWeXPSD0hrjurjBNG1OsKhElXj4xo6Zagg== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1r0KFw-0001Uz-7N; Tue, 07 Nov 2023 06:28:28 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0KFt-0001UK-PD for emacs-orgmode@gnu.org; Tue, 07 Nov 2023 06:28:25 -0500 Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1r0KFr-0000ZI-Nj for emacs-orgmode@gnu.org; Tue, 07 Nov 2023 06:28:25 -0500 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id CC810240112 for ; Tue, 7 Nov 2023 12:28:20 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1699356500; bh=eBKRYbZY6nOFt6Ws6alQ/Hfp9xRMQRhXtL6JXXga22A=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:From; b=mvy7sX1rIqSmfZQhn/6XU37i8ND177ho08KFIB6WTL3ElSUg8IZh4kh4CGphgLPQR ZfQX7bM3XWgjgF7ve2mm4E7AbqEC/xmOklRX0pnXk6rlPCrXKG4DJjX/S8ZIO0MweI lTyINoJYaE5lUKfSfVVBhmUuMY6q0mmScaKWRD1mag4RVkndqLOV9i81Ap1GHyTMDi qQ6tqBJaOOJWmmjgapbo/aaKTWJWNMZDObopN8XGGFEqDhCp3Gb4wcYI/WD37ZhIQZ pYEWFKUDsyI5dkP5NRAPltGbHVA9zVRuDYaBKygSm5XyIk2EhiCxwic5TALr2yzX6H jPI5vDK5D/1JA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4SPmDc1ScDz6tn4; Tue, 7 Nov 2023 12:28:15 +0100 (CET) From: Ihor Radchenko To: Max Nikulin Cc: Cletip Cletip , Org Mode List Subject: Re: [BUG] Tangle with symbolic links don't work In-Reply-To: References: <87wmuu3lh7.fsf@localhost> Date: Tue, 07 Nov 2023 11:30:13 +0000 Message-ID: <87leb9243e.fsf@localhost> MIME-Version: 1.0 Content-Type: text/plain Received-SPF: pass client-ip=185.67.36.66; envelope-from=yantar92@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_MED=-2.3, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: emacs-orgmode-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Migadu-Spam-Score: -9.31 X-Spam-Score: -9.31 X-Migadu-Queue-Id: 055DB21099 X-Migadu-Scanner: mx10.migadu.com X-TUID: +S2Ej107AJWb Max Nikulin writes: >> Max, do you see any pitfalls using `file-truename'? > > Sorry, I am not familiar with related code path. That is why I can not > reason what way to deal with file name is safer. > > If there is a world-writable directory in the file path (usually > $TMPDIR) then `file-truename' is less safe, see > https://www.kernel.org/doc/html/latest/admin-guide/sysctl/fs.html#protected-symlinks Thanks! > In general, I am never sure that Org code follows best practices in > respect to security in general and in respect to /tmp in particular. The > following citation is unrelated to /tmp, but the same proposed patch has > an issue with predictable name in /tmp: We have to compromise between usability and safety... but probably not in this case. > Even when /tmp or similar directories are not involved, a proper > strategy to replace file content should be carefully chosen. E.g. cp(1) > preserves inode number while install(1) replaces target file atomically > (create a temporary one and rename). The latter way is more suitable for > shared libraries since it allows running application to continue call > function from the deleted file. What we actually use is Elisp API. For export and tangling, we use `write-region' - it correctly handles TRAMP files with lower-level details taken care of. I can now see that blindly expanding to `file-truename' may not be wise. Without `file-truename', the difference between ox.el (that works for Cletip) and ob-tangle.el is that ob-tangle explicitly deletes the tangle target before tangling: `org-babel-tangle': ;; erase previous file (when (file-exists-p file-name) (delete-file file-name)) (write-region nil nil file-name) (mapc (lambda (mode) (set-file-modes file-name mode)) modes) Rather than using `file-truename', we may instead remove the `delete-file' part. This way, we will not risk changing file modes in the original files and always modify the symlink, if the tangle target is an existing symlink. > I know, it is not an answer you expected from me, but giving a better > one require to much efforts to read the code and to debug it. It is exactly an answer I expected, actually :) -- Ihor Radchenko // yantar92, Org mode contributor, Learn more about Org mode at . Support Org development at , or support my work at