9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Russ Cox <rsc@swtch.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu>
Subject: Re: [9fans] Acme Editing and Permissions
Date: Sat,  1 Oct 2005 09:48:48 -0400	[thread overview]
Message-ID: <ee9e417a0510010648w635b2b70t6a44371dd5758795@mail.gmail.com> (raw)
In-Reply-To: <433e49fe.5Vlb4ZhnMlw5qous%yard-ape@telus.net>

> I've searched the archives for this one; I suppose
> it's too simple a question to be found there: how
> does one edit (and then write or "Put") another
> owner's files in Acme? e.g., I have root access,
> but don't want to run my whole acme session
> as root just so that I can make quick edits to
> /etc/hosts, or another user's .exrc or something.
>  I'll use 'sudo ed' inside "win", but sometimes
> I'd rather not.  Is there something like a "SudoPut"?

Acme is blissfully ignorant of such things.
I typically chmod the files so that I'm allowed to
write them directly.  However, it's easy to implement
what you want.  Here is a shell script called Put! that
uses sudo to write the current buffer out.  (Note that
to execute Put! you have to highlight the whole string,
since the autoexpand won't use the !.)

---
#!/usr/local/plan9/bin/rc

# Execute Put! instead of Put to force write via sudo.

. 9.rc
dir=acme/acme/$winid
fn rd {
	9p read $dir/$1 || { echo 9p failed >[1=2]; exit 9p }
}
fn wr {
	9p write $dir/$1 || { echo 9p failed >[1=2]; exit 9p }
}

switch($#*){
case 0
	tag=`{rd tag}
	file=$tag(1)
	if(~ $file '$'*){
		file=`{eval echo $file}
		file=$"file
	}
case *
	file=$1
}

tmp=/tmp/put!.$pid
echo -n , | wr addr
rd data >$tmp
if(sudo cp $tmp $file)
	echo -n clean | wr ctl
rm -f $tmp
---

Russ


  reply	other threads:[~2005-10-01 13:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-01  8:34 yard-ape
2005-10-01 13:48 ` Russ Cox [this message]
2005-10-08  2:21   ` yard-ape

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ee9e417a0510010648w635b2b70t6a44371dd5758795@mail.gmail.com \
    --to=rsc@swtch.com \
    --cc=9fans@cse.psu.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).