9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] Acme Editing and Permissions
@ 2005-10-01  8:34 yard-ape
  2005-10-01 13:48 ` Russ Cox
  0 siblings, 1 reply; 3+ messages in thread
From: yard-ape @ 2005-10-01  8:34 UTC (permalink / raw)
  To: 9fans

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"?

(I'm using p9p under Linux.)

Thanks in advance.

-Derek


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [9fans] Acme Editing and Permissions
  2005-10-01  8:34 [9fans] Acme Editing and Permissions yard-ape
@ 2005-10-01 13:48 ` Russ Cox
  2005-10-08  2:21   ` yard-ape
  0 siblings, 1 reply; 3+ messages in thread
From: Russ Cox @ 2005-10-01 13:48 UTC (permalink / raw)
  To: Fans of the OS Plan 9 from Bell Labs

> 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [9fans] Acme Editing and Permissions
  2005-10-01 13:48 ` Russ Cox
@ 2005-10-08  2:21   ` yard-ape
  0 siblings, 0 replies; 3+ messages in thread
From: yard-ape @ 2005-10-08  2:21 UTC (permalink / raw)
  To: rsc, 9fans

Russ Cox <rsc@swtch.com> wrote:

> Here is a shell script called Put! that
> uses sudo to write the current buffer out.
...
> Russ

Thanks alot, that points me in the right direction.

-Derek


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-10-08  2:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-10-01  8:34 [9fans] Acme Editing and Permissions yard-ape
2005-10-01 13:48 ` Russ Cox
2005-10-08  2:21   ` yard-ape

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).