From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Platon Pronko Newsgroups: gmane.emacs.bugs Subject: bug#56180: 29.0.50; editing file with tramp's "sudo:" changes file owner Date: Fri, 24 Jun 2022 08:26:05 +0300 Message-ID: <10b15cda-9cd4-1e54-be07-0b2f31ebc244@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="585"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.10.0 To: 56180@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jun 24 07:27:16 2022 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1o4bqe-000Ad1-5g for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 24 Jun 2022 07:27:16 +0200 Original-Received: from localhost ([::1]:34394 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o4bqc-0000wq-61 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 24 Jun 2022 01:27:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52304) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4bqR-0000wP-7g for bug-gnu-emacs@gnu.org; Fri, 24 Jun 2022 01:27:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:46638) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o4bqQ-00009W-Rq for bug-gnu-emacs@gnu.org; Fri, 24 Jun 2022 01:27:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1o4bqQ-00051c-MD for bug-gnu-emacs@gnu.org; Fri, 24 Jun 2022 01:27:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Platon Pronko Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 24 Jun 2022 05:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 56180 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.165604838519267 (code B ref -1); Fri, 24 Jun 2022 05:27:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 24 Jun 2022 05:26:25 +0000 Original-Received: from localhost ([127.0.0.1]:40535 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o4bpo-00050g-Ro for submit@debbugs.gnu.org; Fri, 24 Jun 2022 01:26:25 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:41876) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1o4bpk-00050X-VP for submit@debbugs.gnu.org; Fri, 24 Jun 2022 01:26:23 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52182) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o4bpk-0000pK-PH for bug-gnu-emacs@gnu.org; Fri, 24 Jun 2022 01:26:20 -0400 Original-Received: from mail-lf1-x135.google.com ([2a00:1450:4864:20::135]:39671) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o4bpi-0008PT-IP for bug-gnu-emacs@gnu.org; Fri, 24 Jun 2022 01:26:20 -0400 Original-Received: by mail-lf1-x135.google.com with SMTP id y32so2580024lfa.6 for ; Thu, 23 Jun 2022 22:26:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:date:mime-version:user-agent:content-language:to:from :subject:content-transfer-encoding; bh=WbVi+pSfvjcrj4kNcybKQ5R0VmyAyj1lK3BoACh3au4=; b=qNBJwB4S2aBzVyYejBlBIa3R493Y27A+e695sadNclJs2+Q57qSbUK/hFSlE3SFtqc DOvC8OxeWF/nmCmzY1p4jzvWOX5ND1QdHh1fsFrBn1anLjR9S8I7BFsWHrfev3QWSh5v wek2gt6q4JVH0JewxeqNMNy4Uu3WwotjN/SKKhSyTXSeYMUd3gDBYa7kuzqlswZe+rqY VYZDXzMyF9Q2Eu8iZYzN6fF44kHt9z4uAA3+u6/oW2515GhOSgrV+IcKAtEhpSON8Ep+ dDfMk4+Bog1uzvtB4INm+7g8T+o258QcixD/g3o5RZuQCnf7+hfDSfvuAVjoSXdWyi+/ dNGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent :content-language:to:from:subject:content-transfer-encoding; bh=WbVi+pSfvjcrj4kNcybKQ5R0VmyAyj1lK3BoACh3au4=; b=3eBe8h3kPuaSh0m443KF/aVRqCSjPZM0O4LMQdYCOfB9aBcyUAIcVzTw4Wk24myH6f 2Z++yzEdbnk7lChg1l88J3PfwbYZ+XgYgUyd1QtENj4ZO3uZRrlxbenOLattcjHVC7ke mA0Ar4xVfrDuFAerI/MK3oQpMXXjr8wBcsl33S9G00pKoGQzj/pyKd85tFUTNdhUluy4 AmnNE72lEXmEYblyf6bjcogQ2Fq25sWNCq2TUUQkLoJROw2pz4RdudhXwhKx6cNrfQbg HbeHlcbl5jifTXlHlgEh/YEwlQ62/TgmHQSkbwyX26uLHOHGON1zoXiXeb6pH25IYb08 mrXw== X-Gm-Message-State: AJIora9l9IYNNlySdapKIkiHNVlO2KfVLXdAcDGo3TbIXRmYun6UlcOh EtqrPOEMeKIAD1kF3t3umXFiIL7cVic= X-Google-Smtp-Source: AGRyM1u24GrHSVtA77xRtMzsnSJ4q6ZJQHN6VYcx/xhSN07zrySNc96QJNBH0jbgsyt4OHvyD+LrHw== X-Received: by 2002:a05:6512:31cc:b0:47f:63ca:bfc8 with SMTP id j12-20020a05651231cc00b0047f63cabfc8mr7809452lfe.242.1656048368325; Thu, 23 Jun 2022 22:26:08 -0700 (PDT) Original-Received: from [192.168.1.7] ([46.138.249.39]) by smtp.gmail.com with ESMTPSA id c7-20020ac25f67000000b0047255d2110asm198220lfc.57.2022.06.23.22.26.06 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 23 Jun 2022 22:26:07 -0700 (PDT) Content-Language: en-US Received-SPF: pass client-ip=2a00:1450:4864:20::135; envelope-from=platon7pronko@gmail.com; helo=mail-lf1-x135.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:235147 Archived-At: When I'm editing some root-owned file on the local system with via tramp's "sudo:" file owner and group are changed to my username (the one Emacs is running under). This is unfortunate, both due to security reasons and due to the fact that some programs/daemons refuse to function properly when certain files have incorrect owners (for example cronie won't run the crontab if it is not owned by root). Steps to reproduce: 1. sudo touch /tmp/test.txt 2. Check that owner is root: $ ls -l /tmp/test.txt -rw-r--r-- 1 root root 0 Jun 24 05:17 /tmp/test.txt 3. emacs -Q --eval "(require 'tramp)" 4. Open the test file with sudo. C-x C-f, /sudo:root@your-machine:/tmp/test.txt 5. Type something into the file, save. 6. Observe that file owner is now changed: $ ls -l /tmp/test.txt -rw-r--r-- 1 user user 5 Jun 24 05:19 /tmp/test.txt It seems that this is a regression from a commit 4e7879f8 in May, which tweaked how tramp decides whether to chown the file after it is written. I think that one of the checks needs to be inverted (patch below), because currently it reads "if uid is different, then skip setting the uid, but if it is equal then set it to the same value". diff --git a/lisp/net/tramp.el b/lisp/net/tramp.el index 59a2710e00..c6665c2792 100644 --- a/lisp/net/tramp.el +++ b/lisp/net/tramp.el @@ -3462,8 +3462,8 @@ tramp-skeleton-write-region ;; `file-precious-flag' is set. (or (file-attribute-modification-time file-attr) (current-time))) - (unless (and (= (file-attribute-user-id file-attr) uid) - (= (file-attribute-group-id file-attr) gid)) + (when (and (= (file-attribute-user-id file-attr) uid) + (= (file-attribute-group-id file-attr) gid)) (setq need-chown nil)))) ;; Set the ownership. In GNU Emacs 29.0.50 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.34, cairo version 1.17.6) of 2022-05-29 built on the-big-maker Repository revision: 96d056b3aa7bc689e2550bddd56f51a88c69fe2f Repository branch: makepkg System Description: Arch Linux Configured using: 'configure --prefix=/usr --sysconfdir=/etc --libexecdir=/usr/lib --localstatedir=/var --mandir=/usr/share/man --with-gameuser=:games --with-modules --without-libotf --without-m17n-flt --without-gconf --with-xinput2 --with-pgtk --without-xaw3d --with-sound=no --without-gpm --without-compress-install '--program-transform-name=s/\([ec]tags\)/\1.emacs/' 'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -fuse-ld=gold -fuse-ld=gold' LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now 'CXXFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security -fstack-clash-protection -fcf-protection -Wp,-D_GLIBCXX_ASSERTIONS -fuse-ld=gold -fuse-ld=gold'' Configured features: ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON LCMS2 LIBSYSTEMD LIBXML2 MODULES NOTIFY INOTIFY PDUMPER PGTK PNG RSVG SECCOMP SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS WEBP XIM GTK3 ZLIB Important settings: value of $LC_TIME: en_SE.UTF-8 value of $LANG: en_US.utf8 locale-coding-system: utf-8-unix Major mode: Lisp Interaction Minor modes in effect: bug-reference-prog-mode: t global-so-long-mode: t global-git-commit-mode: t magit-auto-revert-mode: t rainbow-delimiters-mode: t counsel-mode: t ivy-mode: t smartparens-strict-mode: t smartparens-mode: t global-git-gutter-mode: t git-gutter-mode: t shell-dirtrack-mode: t global-auto-revert-mode: t global-whitespace-mode: t global-dvorak-mode: t dvorak-minor-mode: t tooltip-mode: t global-eldoc-mode: t eldoc-mode: t show-paren-mode: t electric-indent-mode: t mouse-wheel-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t column-number-mode: t line-number-mode: t transient-mark-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t Load-path shadows: /home/platon/.emacs.d/elpa/lispy-20220209.1138/elpa hides /home/platon/.emacs.d/elpa/ivy-20220529.1130/elpa /home/platon/.emacs.d/elpa/protobuf-mode-20220303.1716/protobuf-mode hides /usr/share/emacs/site-lisp/protobuf-mode /home/platon/.emacs.d/elpa/transient-20220527.2213/transient hides /usr/share/emacs/29.0.50/lisp/transient /home/platon/.emacs.d/elpa/less-css-mode-20161001.453/less-css-mode hides /usr/share/emacs/29.0.50/lisp/textmodes/less-css-mode Features: (shadow sort emacsbug crontab-mode sh-script smie executable rfc2104 flymake-proc flymake warnings lsp-diagnostics company-oddmuse company-keywords company-etags company-gtags company-dabbrev-code company-dabbrev company-files company-clang company-capf company-cmake company-semantic company-template company-bbdb lsp-modeline lsp-lens view lsp-zig lsp-steep lsp-svelte lsp-sqls lsp-yaml lsp-xml lsp-vimscript lsp-vhdl lsp-volar lsp-vetur lsp-html lsp-verilog lsp-vala lsp-v lsp-typeprof lsp-ttcn3 lsp-toml lsp-terraform lsp-tex lsp-sorbet lsp-solargraph lsp-rust lsp-rf lsp-remark lsp-r lsp-purescript lsp-pylsp lsp-pyls lsp-pwsh lsp-php lsp-perlnavigator lsp-perl lsp-openscad lsp-ocaml lsp-magik lsp-nix lsp-nim lsp-nginx lsp-markdown lsp-lua lsp-kotlin lsp-json lsp-javascript lsp-idris lsp-haxe lsp-groovy lsp-hack lsp-graphql lsp-gleam lsp-go lsp-completion lsp-gdscript lsp-fsharp lsp-fortran lsp-eslint lsp-erlang lsp-emmet lsp-elixir lsp-elm lsp-dockerfile lsp-dhall lsp-d lsp-css lsp-csharp lsp-crystal lsp-cmake lsp-clojure lsp-semantic-tokens lsp-clangd lsp-beancount lsp-bash lsp-ansible lsp-angular lsp-ada lsp-actionscript smartparens-python python vc vc-dispatcher bug-reference magit-extras face-remap mail-extr smartparens-scala scala-mode scala-mode-prettify-symbols scala-mode-imenu scala-mode-map scala-mode-fontlock scala-mode-indent scala-mode-paragraph scala-mode-syntax scala-mode-lib dabbrev smartparens-c cc-mode cc-fonts cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs ace-window misearch multi-isearch bs conf-mode tramp-cmds tramp-sh tramp-cache ffap org-element avl-tree ol-w3m ol-rmail ol-mhe ol-irc ol-info org-habit org-agenda org-refile ol-gnus nnselect gnus-art mm-uu mml2015 mm-view mml-smime smime gnutls dig gnus-sum gnus-group gnus-undo gnus-start gnus-dbus dbus gnus-cloud nnimap nnmail mail-source utf7 netrc nnoo gnus-spec gnus-int gnus-range gnus-win ol-eww eww url-queue shr pixel-fill kinsoku url-file url-dired svg xml dom mm-url gnus nnheader range ol-docview doc-view jka-compr image-mode exif ol-bibtex ol-bbdb so-long lsp lsp-mode lsp-protocol tree-widget spinner network-stream nsm smartparens-markdown markdown-mode inline ht f f-shortdoc shortdoc s ewoc company org-archive magit-submodule magit-obsolete magit-blame magit-stash magit-reflog magit-bisect magit-push magit-pull magit-fetch magit-clone magit-remote magit-commit magit-sequence magit-notes magit-worktree magit-tag magit-merge magit-branch magit-reset magit-files magit-refs magit-status magit magit-repos magit-apply magit-wip magit-log which-func imenu magit-diff smerge-mode diff diff-mode git-commit log-edit message sendmail yank-media rmc puny rfc822 mml mml-sec epa derived epg rfc6068 epg-config gnus-util mm-decode mm-bodies mm-encode mail-parse rfc2231 rfc2047 rfc2045 mm-util ietf-drums mail-prsvr mailabbrev mail-utils gmm-utils mailheader pcvs-util add-log magit-core magit-autorevert magit-margin magit-transient magit-process with-editor server magit-mode transient magit-git magit-base magit-section crm compat-27 compat-26 compat rainbow-delimiters compat-macs lispy lispy-inline avy etags fileloop generator edebug debug backtrace help-fns radix-tree lispy-tags mode-local counsel xdg xref project dired dired-loaddefs swiper ivy delsel ivy-faces ivy-overlay colir color edmacro kmacro smartparens-config smartparens-rust smartparens-org smartparens-text smartparens dash cl-extra git-gutter-fringe fringe-helper git-gutter hydra lv tramp tramp-loaddefs trampver tramp-integration cus-edit pp cus-load wid-edit files-x tramp-compat shell parse-time ls-lisp lpr rust-utils thingatpt rust-mode rust-rustfmt rust-playpen rust-compile compile text-property-search rust-cargo autorevert filenotify disp-table whitespace quail help-mode org ob ob-tangle ob-ref ob-lob ob-table ob-exp org-macro org-footnote org-src ob-comint org-pcomplete pcomplete comint ansi-color ring org-list org-faces org-entities noutline outline easy-mmode org-version ob-emacs-lisp ob-core ob-eval org-table oc-basic bibtex iso8601 time-date ol rx org-keys oc org-compat advice org-macs org-loaddefs format-spec find-func cal-menu calendar cal-loaddefs pcase darcula-theme finder-inf info package browse-url url url-proxy url-privacy url-expand url-methods url-history url-cookie url-domsuf url-util mailcap url-handlers url-parse auth-source cl-seq eieio eieio-core cl-macs eieio-loaddefs password-cache json map url-vars seq gv subr-x byte-opt bytecomp byte-compile cconv cl-loaddefs cl-lib iso-transl tooltip eldoc paren electric uniquify ediff-hook vc-hooks lisp-float-type elisp-mode mwheel term/pgtk-win pgtk-win term/common-win tool-bar dnd fontset image regexp-opt fringe tabulated-list replace newcomment text-mode lisp-mode prog-mode register page tab-bar menu-bar rfn-eshadow isearch easymenu timer select scroll-bar mouse jit-lock font-lock syntax font-core term/tty-colors frame minibuffer nadvice simple cl-generic indonesian philippine cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese eucjp-ms cp51932 hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese composite emoji-zwj charscript charprop case-table epa-hook jka-cmpr-hook help abbrev obarray oclosure cl-preloaded button loaddefs faces cus-face macroexp files window text-properties overlay sha1 md5 base64 format env code-pages mule custom widget keymap hashtable-print-readable backquote threads dbusbind inotify dynamic-setting system-font-setting font-render-setting cairo gtk pgtk lcms2 multi-tty make-network-process emacs) Memory information: ((conses 16 690043 406875) (symbols 48 52930 131) (strings 32 224243 35010) (string-bytes 1 7116190) (vectors 16 110060) (vector-slots 8 2069208 667484) (floats 8 551 1215) (intervals 56 15669 7168) (buffers 992 38))