safe

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.z3bra.org/safe.git
Log | Files | Refs | README | LICENSE

commit 4e2116da7d696a189eee862c570109a0fc4287f8
Author: z3bra <contactatz3bradotorg>
Date:   Wed, 20 Feb 2019 13:04:28 +0100

Initial commit

Diffstat:
LICENSE | 13+++++++++++++
README | 23+++++++++++++++++++++++
arg.h | 50++++++++++++++++++++++++++++++++++++++++++++++++++
mkfile | 35+++++++++++++++++++++++++++++++++++
safe.1 | 22++++++++++++++++++++++
safe.c | 24++++++++++++++++++++++++
6 files changed, 167 insertions(+), 0 deletions(-)

diff --git a/LICENSE b/LICENSE @@ -0,0 +1,13 @@ +Copyright (c) 2015-2016 Willy Goiffon <contact@z3bra.org> + +Permission to use, copy, modify, and/or 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. diff --git a/README b/README @@ -0,0 +1,23 @@ +# safe + +Store your secrets in an encrypted safe, protected by a password. + +## usage + + safe [-la] [secret..] + + # add a secret to your safe + echo 'This is secret!' | safe -a secret + + # retrieve a secret from your safe + safe secret + +## goals + ++ Only require a master password to unlock ++ Provide a way to open/lock the safe (agent?) ++ Store any kind of file ++ Do not expose file hierarchy if locked + +## license +This software is licensed under the ISC license, see the LICENSE file provided. diff --git a/arg.h b/arg.h @@ -0,0 +1,50 @@ +/* + * Copy me if you can. + * by 20h + */ + +#ifndef ARG_H__ +#define ARG_H__ + +extern char *argv0; + +/* use main(int argc, char *argv[]) */ +#define ARGBEGIN for (argv0 = *argv, argv++, argc--;\ + argv[0] && argv[0][0] == '-'\ + && argv[0][1];\ + argc--, argv++) {\ + char argc_;\ + char **argv_;\ + int brk_;\ + if (argv[0][1] == '-' && argv[0][2] == '\0') {\ + argv++;\ + argc--;\ + break;\ + }\ + int i_;\ + for (i_ = 1, brk_ = 0, argv_ = argv;\ + argv[0][i_] && !brk_;\ + i_++) {\ + if (argv_ != argv)\ + break;\ + argc_ = argv[0][i_];\ + switch (argc_) + +#define ARGEND }\ + } + +#define ARGC() argc_ + +#define EARGF(x) ((argv[0][i_+1] == '\0' && argv[1] == NULL)?\ + ((x), abort(), (char *)0) :\ + (brk_ = 1, (argv[0][i_+1] != '\0')?\ + (&argv[0][i_+1]) :\ + (argc--, argv++, argv[0]))) + +#define ARGF() ((argv[0][i_+1] == '\0' && argv[1] == NULL)?\ + (char *)0 :\ + (brk_ = 1, (argv[0][i_+1] != '\0')?\ + (&argv[0][i_+1]) :\ + (argc--, argv++, argv[0]))) + +#endif diff --git a/mkfile b/mkfile @@ -0,0 +1,35 @@ +CC = cc +LD = ${CC} + +PREFIX = /usr/local +MANPREFIX = ${PREFIX}/man + +CPPFLAGS = +CFLAGS = -g -Wall -Wextra -pedantic +LDFLAGS = +LDLIBS = -lcrypto + +BIN = safe +SRC = ${BIN}.c +OBJ = ${SRC:%.c=%.o} + +${BIN}: $OBJ + $LD -o $target $prereq $LDFLAGS $LDLIBS + +%.o: %.c + $CC $CPPFLAGS $CFLAGS -c $stem.c + +clean:V: + rm -f $OBJ ${BIN} + +install:V: ${BIN} + mkdir -p ${DESTDIR}${PREFIX}/bin + cp ${BIN} ${DESTDIR}${PREFIX}/bin/${BIN} + chmod 755 ${DESTDIR}${PREFIX}/bin/${BIN} + mkdir -p ${DESTDIR}${MANPREFIX}/man1 + cp ${BIN}.1 ${DESTDIR}${MANPREFIX}/man1/${BIN}.1 + chmod 644 ${DESTDIR}${MANPREFIX}/man1/${BIN}.1 + +uninstall:V: + rm ${DESTDIR}${PREFIX}/bin/${BIN} + rm ${DESTDIR}${MANPREFIX}/man1/${BIN}.1 diff --git a/safe.1 b/safe.1 @@ -0,0 +1,21 @@ +.Dd 2019-02-20 +.Dt PM 1 +.Os POSIX.1-2008 +.Sh NAME +.Nm safe +.Nd Digital safe for your secrets +.Sh SYNOPSIS +.Nm +.Op Fl h +.Sh DESCRIPTION +.Nm +stores secrets (files) encrypted on your disk, and lets you retrieve them, +given that you have the password. +.Bl -tag -width Ds +.It Fl h +Print a quick usage text. +.El +.Sh SEE ALSO +.Xr openssl 1 , +.Sh AUTHORS +.An Willy Goiffon Aq Mt contact@z3bra.org+ \ No newline at end of file diff --git a/safe.c b/safe.c @@ -0,0 +1,24 @@ +#include <stdio.h> +#include <stdlib.h> + +#include "arg.h" + +char *argv0; + +void +usage(void) +{ + fprintf(stderr, "usage: %s [-h]\n", argv0); + exit(1); +} + +int +main(int argc, char *argv[]) +{ + ARGBEGIN { + default: + usage(); + } ARGEND + + return 0; +}