From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: Date: Sat, 1 Oct 2005 09:48:48 -0400 From: Russ Cox To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> Subject: Re: [9fans] Acme Editing and Permissions In-Reply-To: <433e49fe.5Vlb4ZhnMlw5qous%yard-ape@telus.net> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <433e49fe.5Vlb4ZhnMlw5qous%yard-ape@telus.net> Topicbox-Message-UUID: 930a99ea-ead0-11e9-9d60-3106f5b1d025 > 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=3Dacme/acme/$winid fn rd { =099p read $dir/$1 || { echo 9p failed >[1=3D2]; exit 9p } } fn wr { =099p write $dir/$1 || { echo 9p failed >[1=3D2]; exit 9p } } switch($#*){ case 0 =09tag=3D`{rd tag} =09file=3D$tag(1) =09if(~ $file '$'*){ =09=09file=3D`{eval echo $file} =09=09file=3D$"file =09} case * =09file=3D$1 } tmp=3D/tmp/put!.$pid echo -n , | wr addr rd data >$tmp if(sudo cp $tmp $file) =09echo -n clean | wr ctl rm -f $tmp --- Russ