1 #!/usr/local/plan9/bin/rc
12 secstore -i -g $1 <_password
16 secstore -i -p $1 <_password
21 echo >[1=2] ipso: aescbc requires fully qualified pathname
24 aescbc -i -d < $1 > `{basename $1} <[3] _password
28 aescbc -i -e > $1 < `{basename $1} <[3] _password
34 if(ls -tr | sed '1,/^_timestamp$/d' | grep -s '^'^`{basename $i}^'$')
38 ls -tr | sed '1,/^_timestamp$/d'
54 echo >[2=1] 'usage: ipso [-a -f -e -l] [-s] [file ...]'
60 if(~ $flush no && ~ $edit no && ~ $load no){
68 if(~ $flush yes && ~ $edit no && ~ $load no){
69 echo flushing old keys
70 echo delkey | 9p write factotum/ctl
74 if(~ $get aesget && ~ $#* 0){
75 echo >[2=1] ipso: must specify a fully qualified file name for aescbc '(-a)'
80 cd /tmp || exit $status
81 tmp=`{df | grep -v /lib/init | awk '$1=="tmpfs" {print $NF}'}
83 cd $tmp(1) || exit $status
85 chmod 700 ipso.$user || exit $status
94 if ( ~ $edit yes ) echo '
95 Warning: The editor will display the secret contents of
96 your '$name' files in the clear, and they will
97 be stored temporarily in '^$dir^'
98 in the clear, along with your password.
101 # get password and remember it
102 readcons -s $name^' password' >_password
106 if(! secstore -G . -i < _password > _listing){
107 echo 'secstore read failed - bad password?'
111 files=`{sed 's/[ ]+.*//' _listing}
116 # copy the files to local ramfs
119 echo $name ' read failed - bad password?'
124 sleep 2; date > _timestamp # so we can find which files have been edited.
128 B `{for(i in $files) basename $i}
129 readcons 'type enter when finished editing' >/dev/null
132 echo flushing old keys
133 echo delkey | 9p write factotum/ctl
136 echo loading factotum keys
137 if (~ factotum $files) cat factotum | 9p write -l factotum/ctl
140 # copy the files back
141 for(i in `{editedfiles}){
142 prompt='copy '''^`{basename $i}^''' back? [y/n/x]'
143 switch(`{readcons $prompt}){
146 echo $name ' read failed - bad password?'
150 echo ''''$i'''' copied to $name
151 if(~ $i factotum && ! ~ $load yes){ # do not do it twice
152 cat $i | 9p write -l factotum/ctl
157 echo ''''$i'''' skipped