From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.help Subject: Re: Emacs client doesn't run by root Date: Sun, 28 Feb 2021 21:09:04 +0100 Message-ID: <87r1l0c5mn.fsf@gnu.org> References: <72ea7a4c-c9e8-3a93-0ed7-aad5b18ee422@akwebsoft.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11145"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.5.8; emacs 28.0.50 To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Sun Feb 28 21:14:13 2021 Return-path: Envelope-to: geh-help-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 1lGSSD-0002oL-De for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 28 Feb 2021 21:14:13 +0100 Original-Received: from localhost ([::1]:36730 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lGSSC-0002DR-Et for geh-help-gnu-emacs@m.gmane-mx.org; Sun, 28 Feb 2021 15:14:12 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34722) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lGSRv-0002DI-5p for help-gnu-emacs@gnu.org; Sun, 28 Feb 2021 15:13:55 -0500 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:59443) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lGSRu-0005NJ-VN for help-gnu-emacs@gnu.org; Sun, 28 Feb 2021 15:13:54 -0500 Original-Received: from auth2-smtp.messagingengine.com ([66.111.4.228]:59833) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.82) (envelope-from ) id 1lGSRu-0003Ka-KR for help-gnu-emacs@gnu.org; Sun, 28 Feb 2021 15:13:54 -0500 Original-Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailauth.nyi.internal (Postfix) with ESMTP id 6BE4027C0054 for ; Sun, 28 Feb 2021 15:13:54 -0500 (EST) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Sun, 28 Feb 2021 15:13:54 -0500 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrleeigddufeehucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpehffgfhvffuffgjkfggtgesthdtre dttdertdenucfhrhhomhepvfgrshhsihhlohcujfhorhhnuceothhsughhsehgnhhurdho rhhgqeenucggtffrrghtthgvrhhnpeevveeikeetkeeviefgfeffiedvteeguddvffeuue duveegtddthedvhfeuveffhfenucfkphepgeeirdektddrjedurdduvdegnecuvehluhhs thgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomhepthhhohhrnhdomhgvsh hmthhprghuthhhphgvrhhsohhnrghlihhthidqkeeijeefkeejkeegqdeifeehvdelkedq thhsughhpeepghhnuhdrohhrghesfhgrshhtmhgrihhlrdhfmh X-ME-Proxy: Original-Received: from thinkpad-t440p (p2e50477c.dip0.t-ipconnect.de [46.80.71.124]) by mail.messagingengine.com (Postfix) with ESMTPA id DEA0E240054 for ; Sun, 28 Feb 2021 15:13:53 -0500 (EST) In-reply-to: <72ea7a4c-c9e8-3a93-0ed7-aad5b18ee422@akwebsoft.com> X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:128322 Archived-At: Tim Johnson writes: > I have been using the emacs daemon as my system editor. > Starting with the following script > ;; code > emacs -q -nw --no-splash --daemon -l ~/.emacs.d/init_term.el > ;; end code > > Works fine as user tim, but if I try it as root, I get the following error > message: > ;; quote > /usr/local/bin/emacsclient: can't find socket; have you started the server? The reason is that this will try to connect to the emacs demon run for the user root which you would need to start as well. I just find files as normal user and use the below snippet to be queried if I want to open a file I have no write permission for using TRAMP's sudo method: --8<---------------cut here---------------start------------->8--- (defun th/find-file-sudo (file) "Opens FILE with root privileges." (interactive "F") (set-buffer (find-file (concat "/sudo::" file)))) (define-advice find-file (:around (ff file &rest more) th/find-file-maybe-sudo) (if (and (file-exists-p file) (not (file-directory-p file)) (not (file-writable-p file)) (not (file-remote-p file)) (y-or-n-p (concat "File " file " is read-only. Sudo? "))) (th/find-file-sudo file) (funcall ff file more))) --8<---------------cut here---------------end--------------->8--- Bye, Tassilo