Skip to content

Commit a6c9bdf

Browse files
committed
Added shred functionality. fixes #26
1 parent 1b2c203 commit a6c9bdf

File tree

5 files changed

+31
-16
lines changed

5 files changed

+31
-16
lines changed

docs/JOURNAL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ a help screen showing the sub-commands available.
77
Journal(1) automatically selects today's date and year to work out which
88
file it should open for editing.
99

10-
10+
Journal will use GNU shred(1) where available for deleting temporary files.
1111

1212
## Sub-command config
1313

docs/RELEASE-NOTES.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
# STANDARD(?) UNIX NOTES
22
# RELEASE NOTES
33

4+
2.3
5+
- Added GNU shred(1) for file deletion where available
6+
- fixed bug #26 (wrong extension for 'edit' -> .asc)
7+
48
2.2
59
- Migrated to ascii encoded notes.
610
- To migrate old files just run 'notes newkey <KEYID>'

docs/ROADMAP.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
44
ROADMAP
55

6+
2.3 Use GNU shred(1) where available
7+
68
2.2 Migrate to ascii encoded GPG files (see RELEASE-NOTES.md)
79

810
2.0 Journal functionality and other fixes
@@ -46,7 +48,6 @@ FUTURE FEATURES
4648
- zsh completion
4749
- FreeBSD .PKG packaging
4850
- FreeBSD ports configuration
49-
- shred functionality
5051
- encrypted backup/restore
5152
- PIV card support
5253
- Issue #17 BUG - import truncates filename if spaces in filename

docs/USING_NOTES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ Any note names specified in either the command line OR when prompted
99
the spaces replaced with underscores. So if you enter *notes add my new
1010
note* you will create 'my_new_note'.
1111

12+
If available *notes* will use GNU shred(1) to delete any temporary
13+
files. If unavailable it will default back to rm(1).
1214

1315
## Sub-command config
1416

journal

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
#!/bin/sh
22
#
3-
# STANDARD(?) UNIX NOTES
3+
# STANDARD(?) UNIX NOTES - Journal application
44
#
55
# This is Unix Notes. An GPG encrypted notes system designed for privacy
66
#
7+
# the journal(1) command manages encrypted journal files in the Journal notebook
8+
#
79
# The idea came from 'pass' the standard Unix password manager
810

911
# VARIABLES
@@ -25,16 +27,22 @@ USE_POINTER="${NOTESDIR}/USE"
2527
GPGKEY=''
2628
GPG_OPTS="--quiet --yes --compress-algo=none --no-encrypt-to"
2729
GPG="gpg"
28-
SHREDCMD="rm"
2930
EDITOR="${EDITOR:-nano}"
3031
PAGER="${PAGER:-more}"
31-
#SHREDCMD="shred"
3232
YEAR="`date "+%Y"`"
3333
JOURNALNAME="`date "+%B_%d"`"
3434
TODAY="${JOURNALDIR}/${YEAR}/${JOURNALNAME}"
35-
ENCRYPTEDTARGET="${TODAY}.gpg"
35+
ENCRYPTEDTARGET="${TODAY}.asc"
3636
TIMESTAMP="`date \"+%B %d, %Y. %H:%M\"`"
3737

38+
# Use shred if available
39+
SHRED="`which shred`"
40+
if [ $? = 0 ]; then
41+
SHREDCMD="${SHRED} --remove=wipe"
42+
else
43+
SHREDCMD="rm"
44+
fi
45+
3846
#
3947
# initialise notes system
4048
#
@@ -78,7 +86,7 @@ validate_gpg_keyid () {
7886
echo Invalid GPG keyid
7987
cat $keyids
8088
echo \n\n Type 'gpg -k <keyid> to find out more about key'
81-
rm $keyids
89+
${SHREDCMD} $keyids
8290
exit 1
8391
else
8492
echo Valid key $testkey
@@ -89,7 +97,7 @@ validate_gpg_keyid () {
8997
echo Valid keys are ...
9098
cat $keyids
9199
echo \n\n Type 'gpg -k <keyid> to find out more about key'
92-
rm $keyids
100+
${SHREDCMD} $keyids
93101
exit 1;;
94102
esac
95103
}
@@ -115,7 +123,7 @@ journal_add () {
115123

116124
$GPG -ear $KEY $GPG_OPTS $TODAY
117125

118-
rm $TODAY
126+
${SHREDCMD} $TODAY
119127
}
120128

121129
journal_import () {
@@ -143,7 +151,7 @@ journal_import () {
143151
exit 1
144152
fi
145153

146-
rm ${TODAY}
154+
${SHREDCMD} ${TODAY}
147155
}
148156

149157
journal_view () {
@@ -177,7 +185,7 @@ journal_edit () {
177185
TARGET="${ENCRYPTEDTARGET}"
178186
fi
179187

180-
BASETARGET="`echo $TARGET | sed s/.gpg//`"
188+
BASETARGET="`echo $TARGET | sed s/.asc//`"
181189

182190
if [ -f "${TARGET}" ]; then
183191
gpg -o ${BASETARGET} -d "${TARGET}"
@@ -192,7 +200,7 @@ journal_edit () {
192200

193201
$GPG -ear $KEY $GPG_OPTS $BASETARGET
194202

195-
rm $BASETARGET
203+
${SHREDCMD} $BASETARGET
196204
}
197205

198206
journal_list () {
@@ -220,7 +228,7 @@ journal_delete () {
220228
TARGET="$@"
221229

222230
if [ -f "${TARGET}" ]; then
223-
rm -i ${TARGET}
231+
${SHREDCMD} ${TARGET}
224232
else
225233
echo ${TARGET} does not exist
226234
exit 1
@@ -320,7 +328,7 @@ journal_tree () {
320328
journal_find () {
321329
searchterm="$@"
322330

323-
for file in `find ${JOURNALDIR} -name \*.gpg -print`
331+
for file in `find ${JOURNALDIR} -name \*.asc -print`
324332
do
325333
gpg -d $file 2>/dev/null | grep -H --label "`basename ${file}`" "$searchterm"
326334

@@ -341,12 +349,12 @@ cmd_newkey () {
341349
get_gpg_keyid $mynewkey
342350

343351
# now recrypt files
344-
find ~/.notes -name \*.gpg | sed s/.gpg// | \
352+
find ~/.notes -name \*.asc | sed s/.asc// | \
345353

346354
while read filen ;
347355
do
348356
echo $filen;
349-
gpg -o "${filen}" --yes -d "${filen}.gpg"
357+
gpg -o "${filen}" --yes -d "${filen}.asc"
350358
gpg -ear ${mynewkey} --yes "${filen}" && ${SHREDCMD} "${filen}"
351359

352360
done

0 commit comments

Comments
 (0)