From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Tim X Newsgroups: gmane.emacs.help Subject: Re: emacs idiom for sudo Date: Wed, 23 May 2007 14:13:56 +1000 Organization: Posted via Supernews, http://www.supernews.com Message-ID: <87odkcch2z.fsf@lion.rapttech.com.au> References: <87k5v4doio.fsf@lion.rapttech.com.au> <87abvxdzwk.fsf@lion.rapttech.com.au> <1179843916.583993.14130@x35g2000prf.googlegroups.com> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: sea.gmane.org 1179895283 32157 80.91.229.12 (23 May 2007 04:41:23 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Wed, 23 May 2007 04:41:23 +0000 (UTC) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Wed May 23 06:41:21 2007 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1Hqif2-0001ET-45 for geh-help-gnu-emacs@m.gmane.org; Wed, 23 May 2007 06:41:20 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Hqif2-0001ug-BD for geh-help-gnu-emacs@m.gmane.org; Wed, 23 May 2007 00:41:20 -0400 Original-Path: shelby.stanford.edu!headwall.stanford.edu!newshub.sdsu.edu!news.astraweb.com!router1.astraweb.com!sn-xt-sjc-04!sn-xt-sjc-09!sn-post-sjc-01!supernews.com!corp.supernews.com!not-for-mail Original-Newsgroups: gnu.emacs.help User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1.50 (gnu/linux) Cancel-Lock: sha1:D5FQ4CyPBcuYYUj+kWbL9IlrlnA= Original-X-Complaints-To: abuse@supernews.com Original-Lines: 33 Original-Xref: shelby.stanford.edu gnu.emacs.help:148716 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.help:44305 Archived-At: "foo@bar.baz" writes: > On May 22, 10:29 am, Tim X wrote: >> You may be able to do something with emacsclient, but you woul dstill need an >> emacs running somewhere as the user you want th e code to run as. >> >> Probably more of a hassle than its worth - but that depends on your >> environment/needs I guess. > > I often use emacsclient to edit files from the terminal. With files > that I have to edit as root I have to switch to emacs, start tramp, > find the file... > Is it possible to use emacsclient with sudo? > No, from your description its not going to work. If you think about processes, shells and permissions, the problems are fairly clear. When you run sudo, you start a new shell process running as the user you have sudo'd to. If you wanted to use emacsclient to edit the file, emacsclient would need an emacs running as that user that it can pass to, but if you have emacs running as that user, why would you bother sudoing to that user to edit the file - you would just edit it within the emacs running as that user. For editing files as another user (such as root), the easiest solution is just to use tramp. Executing a program as another user from within emacs can be done via an emacs term, in which you run sudo. running some elisp as another user is much more difficult because of the seperation of privileges that is the foundation of the security model under *nix systems. Tim -- tcross (at) rapttech dot com dot au