9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* Re: [9fans] key management
@ 2003-01-28 14:35 rog
  2003-01-28 14:42 ` Russ Cox
  0 siblings, 1 reply; 4+ messages in thread
From: rog @ 2003-01-28 14:35 UTC (permalink / raw)
  To: 9fans

> cat /mnt/factotum/ctl | tail -1 | sed 's/ !.*//;s/^/del/' >/mnt/factotum/ctl

presumably this should actually be:
cat /mnt/factotum/ctl | tail -1 | sed 's/ !.*//;s/^/del/' | read -m >/mnt/factotum/ctl

for those with large numbers of keys?



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

* Re: [9fans] key management
  2003-01-28 14:35 [9fans] key management rog
@ 2003-01-28 14:42 ` Russ Cox
  0 siblings, 0 replies; 4+ messages in thread
From: Russ Cox @ 2003-01-28 14:42 UTC (permalink / raw)
  To: 9fans

> presumably this should actually be:
> cat /mnt/factotum/ctl | tail -1 | sed 's/ !.*//;s/^/del/' | read -m >/mnt/factotum/ctl
> 
> for those with large numbers of keys?

i think you missed the tail -1.



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

* Re: [9fans] key management
  2003-01-27 19:44 Rob 'Commander' Pike
@ 2003-01-28  3:00 ` Russ Cox
  0 siblings, 0 replies; 4+ messages in thread
From: Russ Cox @ 2003-01-28  3:00 UTC (permalink / raw)
  To: 9fans

To delete the most recently added key (likely the common
result of your loop):

cat /mnt/factotum/ctl | tail -1 | sed 's/ !.*//;s/^/del/' >/mnt/factotum/ctl

Russ



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

* [9fans] key management
@ 2003-01-27 19:44 Rob 'Commander' Pike
  2003-01-28  3:00 ` Russ Cox
  0 siblings, 1 reply; 4+ messages in thread
From: Rob 'Commander' Pike @ 2003-01-27 19:44 UTC (permalink / raw)
  To: 9fans

[-- Attachment #1: Type: text/plain, Size: 385 bytes --]

Another shell script for dealing with keys.  I got tired
of fixing factotum by hand when I type a bad password.
Attached is delkey.  It interactively scans factotum/ctl
and deletes keys that match the specified pattern. If no
pattern is given, it scans all keys.  With the -f (force)
flag, it deletes without asking first.

It's new and not thoroughly tested, so beware.

-rob

[-- Attachment #2: delkey --]
[-- Type: text/plain, Size: 693 bytes --]

#!/bin/rc

rfork e

ctl = /mnt/factotum/ctl
if(test -r /mnt/term/mnt/factotum/ctl)
	ctl = /mnt/term/mnt/factotum/ctl

fn forceit {
	switch($force){
	case no
		echo -n $* '? [y/n]' > /dev/cons
		ok = `{read}
		switch($ok){
		case y* Y*
			echo yes
		case q* Q*
			exit ''
		case *
			echo no
		}
	case *
		echo yes
	}
}

fn deleteit {
	key = `{echo $* | sed 's/ ![0-9a-zA-Z_]+\??/ /g' | sed 's/ +$//'}
	if(~ `{forceit del$key} yes)
		if(! echo del$key > $ctl)
			exit bad
}

force = no

if(~ $1 '-f'){
	force = yes
	shift
}

ifs='
'

if(~ $#* 0){
	for(i in `{cat $ctl})
		deleteit $i
	exit ''
}

for(i in `{grep $"* $ctl})
	deleteit $i
exit ''

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

end of thread, other threads:[~2003-01-28 14:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-28 14:35 [9fans] key management rog
2003-01-28 14:42 ` Russ Cox
  -- strict thread matches above, loose matches on Subject: below --
2003-01-27 19:44 Rob 'Commander' Pike
2003-01-28  3:00 ` Russ Cox

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