move srm to own dir

This commit is contained in:
Kyle Isom 2020-02-14 23:05:21 -08:00
parent 1b4bfe84eb
commit 769de599fc
7 changed files with 258 additions and 4 deletions

View File

@ -760,7 +760,7 @@ editor_find_callback(char *query, int16_t c)
lmatch = -1;
dir = 1;
return;
} else if (c == ARROW_RIGHT || c == ARROW_DOWN) {
} else if (c == ARROW_RIGHT || c == ARROW_DOWN || c == CTRL_KEY('s')) {
dir = 1;
} else if (c == ARROW_LEFT || c == ARROW_UP) {
dir = -1;
@ -1038,6 +1038,9 @@ process_normal(int16_t c)
case CTRL_KEY('l'):
display_refresh();
break;
case CTRL_KEY('s'):
editor_find();
break;
case ESC_KEY:
editor.mode = MODE_ESCAPE;
break;

21
srm/LICENSE Normal file
View File

@ -0,0 +1,21 @@
CODE LICENSE
This code is released under the ISC license.
--------------------------------------------------------------------------------
the ISC license:
Copyright (c) 2011 Kyle Isom <coder@kyleisom.net>
Permission to use, copy, modify, and distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
--------------------------------------------------------------------------------

54
srm/Makefile.in Normal file
View File

@ -0,0 +1,54 @@
VERSION := 1.3.1
CC := gcc
TARGET := srm
OBJS :=
LIBS :=
PREFIX ?= $PREFIX
MANDIR ?= $MANDIR
CFLAGS += -Wall -Wextra -pedantic -Wshadow -Wpointer-arith -Wcast-align
CFLAGS += -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations
CFLAGS += -Wnested-externs -Winline -Wno-long-long -Wunused-variable
CFLAGS += -Wstrict-prototypes -Werror -ansi -static
CFLAGS += -D$(TARGET)_VERSION="\"$(TARGET) version $(VERSION)\""
CFLAGS += OS_CFLAGS
all: $(TARGET)
$(TARGET): $(TARGET).o $(OBJS)
${CC} -o $(TARGET) ${CFLAGS} ${LDFLAGS} $(LIBS) $(OBJS) $(TARGET).o
install: $(TARGET)
install -m 0755 $(TARGET) $(PREFIX)/bin/$(TARGET)
install -m 0755 -d $(MANDIR)/man1
install -m 0444 $(TARGET).1 $(MANDIR)/man1/$(TARGET).1
uninstall:
-rm -f $(PREFIX)/bin/$(TARGET)
-rm -f $(MANDIR)/man1/$(TARGET).1
lint:
-mkdir security
-rats -w 3 $(TARGET).[ch] > security/rats.out
-lint -fhrs $(TARGET).c > security/lint.out
-splint +posixlib $(TARGET).[ch] > security/splint.out
dist: clean
-mkdir $(TARGET)-$(VERSION)
-cp * $(TARGET)-$(VERSION)
-cd $(TARGET)-$(VERSION) && make distclean && cd ..
-tar czf $(TARGET)-$(VERSION).tgz $(TARGET)-$(VERSION)
distclean: clean
-rm -f Makefile
htmldoc:
-mandoc -Thtml $(TARGET).1 > $(TARGET).1.html
tags:
ctags *.[ch]
.c.o:
$(CC) -c ${CFLAGS} $?
.PHONY: clean all install lint uninstall dist distclean htmldoc tags

36
srm/README Normal file
View File

@ -0,0 +1,36 @@
srm - securely wipe files
--------------------------
srm is a utility to overwrite files with random data in one or more passes.
Dependencies
------------
None.
Compatibility
-------------
srm has been tested on the following operating systems:
* OpenBSD (5.1-snap)
* OS X (10.8)
* Linux (Debian 6.0)
Installation
------------
make build install
Usage
-----
srm [-v] [-n number] file list
options:
-n <number of passes>: specify number of passes
(default is 3 passes)
-v: verbose mode. display list of failures and wiped files after wiping
Known bugs / caveats
--------------------
srm can't recursively remove files, i.e. it can't remove directories.

57
srm/config.sh Executable file
View File

@ -0,0 +1,57 @@
#!/bin/sh
TARGET="$(cat Makefile.in | grep 'TARGET :=' | awk -F' ' '{ print $3; }')"
echo "configuring ${TARGET}"
which sed 2>/dev/null 1>/dev/null
if [ $? -ne 0 ]; then
echo "cannot find sed!" 1>&2
fi
OPSYS=$(uname -s)
echo "Configuring for ${OPSYS}..."
if [ "x${OPSYS}" = "xLinux" ]; then
OS_CFLAGS="-D_BSD_SOURCE -D_POSIX_SOURCE -D_XOPEN_SOURCE"
elif [ "x${OPSYS}" = "xDarwin" ]; then
OS_CFLAGS="-D_DARWIN_C_SOURCE"
else
OS_CFLAGS=""
fi
if [ -z "${OS_CFLAGS}" ]; then
echo "${OPSYS} requires no extra build flags."
else
echo "${OPSYS} requires build flags ${OS_CFLAGS}"
fi
if [ -z "${PREFIX}" ]; then
PREFIX="/usr/local"
fi
if [ "${PREFIX}" = "/usr" ]; then
MANDIR="$(PREFIX)/share/man"
elif [ "${PREFIX}" = "/usr/local" ]; then
if [ "${OPSYS}" = "Darwin" ]; then
MANDIR="${PREFIX}/share/man"
else
MANDIR="${PREFIX}/man"
fi
else
MANDIR="${PREFIX}/man"
fi
if [ "$1" = "DEBUG" ]; then
OS_CFLAGS="${OS_CFLAGS} -g -O0"
fi
echo "prefix: ${PREFIX}"
echo "mandir: ${MANDIR}"
echo "writing new Makefile"
cat Makefile.in | sed -e "s|OS_CFLAGS|${OS_CFLAGS}|" | \
sed -e "s|\$PREFIX|${PREFIX}|" | \
sed -e "s|\$MANDIR|${MANDIR}|" > Makefile
echo "done."

84
srm/srm.1 Normal file
View File

@ -0,0 +1,84 @@
.Dd $Mdocdate$
.Dt SRM 1
.Os
.Sh NAME
.Nm srm
.Nd securely delete files
.Sh SYNOPSIS
.Nm
.Op Fl h
.Op Fl n Ar number
.Op Fl r
.Op Fl v
.Op Fl V
.Ar files
.Sh DESCRIPTION
.Nm
is a simple secure file deletion tool. It overwrites the file with several
passes of random data before unlinking it. If no options are specified, Nm
defaults to three passes.
.Nm
supports the following options:
.Bl -tag -width .Ds
.It Fl h
Display a brief help message.
.It Fl n Ar number
Specify the number of times to overwrite each target with random data.
.It Fl r
Recursive mode. Delete any directories and all subdirectories underneath.
.It Fl v
Verbose mode. Displays a list of both files that failed to wipe and files that
were successfully wiped.
.It Fl V
Print version information.
.El
.Sh EXIT STATUS
.Ex -std
The exit values are standard
.Xr sysexits 3
values.
.Sh EXAMPLES
Wipe files
.Pa foo
and
.Pa bar
with three passes:
.Dl $ srm foo bar
Wipe files
.Pa baz
and
.Pa quux
with ten passes:
.Dl $ srm -n 10 baz quux
Wipe all PGP keys, i.e. files with extension
.Pa *.asc :
.Dl $ srm *.asc
Recursive deletes aren't implemented yet. A workaround is to use
.Nm
and
.Xr find 1 ,
for example to delete all
.Pa *.pgp
files:
.Dl $ find . -iname '*.pgp' -exec srm '{}' \;
.Sh DIAGNOSTICS
.Nm
uses the standard
.Xr err 3
facilities to report any errors that occur.
.Sh SEE ALSO
The srm page on
.Lk http://www.tyrfingr.is/projects/srm/ "tyrfinger" .
.Sh STANDARDS
.Nm
conforms to
.St -ansiC .
.Sh AUTHORS
.Nm
was written by
.An "Kyle Isom" Aq Mt kyle@tyrfingr.is .
.Sh BUGS
None known. Report bugs to the author.
.Sh LICENSE
.Nm
is released under an ISC license.

View File

@ -32,7 +32,6 @@
#define DEFAULT_PASSES 3
#define DEV_RANDOM "/dev/urandom"
#define MAX_CHUNK 4096
#define SRM_VERSION "1.3.1"
static int do_wipe(char *, size_t, int);
@ -364,7 +363,7 @@ usage()
void
version()
{
printf("%s\n", SRM_VERSION);
printf("%s\n", srm_VERSION);
}