mirror of
https://github.com/angt/secret
synced 2025-01-18 22:27:01 +01:00
Show version
Signed-off-by: Adrien Gallouët <adrien@gallouet.fr>
This commit is contained in:
parent
25aab11566
commit
a1e93a8702
1 changed files with 26 additions and 9 deletions
23
secret.c
23
secret.c
|
@ -2,6 +2,7 @@
|
|||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <inttypes.h>
|
||||
#include <poll.h>
|
||||
#include <signal.h>
|
||||
#include <stdarg.h>
|
||||
|
@ -18,7 +19,9 @@
|
|||
#include "libhydrogen/hydrogen.c"
|
||||
|
||||
#define S_COUNT(x) (sizeof(x) / sizeof((x)[0]))
|
||||
#define S_ENTRYSIZE 512
|
||||
#define S_VER_MAJOR 0U
|
||||
#define S_VER_MINOR 0U
|
||||
#define S_ENTRYSIZE 512U
|
||||
#define S_ENV_AGENT "SECRET_AGENT"
|
||||
#define S_ENV_STORE "SECRET_STORE"
|
||||
|
||||
|
@ -190,8 +193,8 @@ s_open_secret(int use_tty)
|
|||
if (s_read(fd, s.hdr.buf, sizeof(s.hdr.buf)))
|
||||
s_fatal("Unable to read %s", s.path);
|
||||
|
||||
if (s.hdr.version)
|
||||
s_fatal("Bad version!");
|
||||
if (s.hdr.version != S_VER_MAJOR)
|
||||
s_fatal("Unkown version %" PRIu8, s.hdr.version);
|
||||
|
||||
const char *agent = getenv(S_ENV_AGENT);
|
||||
int wfd = -1, rfd = -1;
|
||||
|
@ -600,6 +603,19 @@ s_set_path(void)
|
|||
}
|
||||
}
|
||||
|
||||
static int
|
||||
s_version(int argc, char **argv, void *data)
|
||||
{
|
||||
if (argz_help(argc, argv))
|
||||
return 0;
|
||||
|
||||
if (argc != 1)
|
||||
return argc;
|
||||
|
||||
printf("%u.%u\n", S_VER_MAJOR, S_VER_MINOR);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
main(int argc, char **argv)
|
||||
{
|
||||
|
@ -620,6 +636,7 @@ main(int argc, char **argv)
|
|||
{"show", "Show an existing secret", &s_show, .alt = alts, .grp = 1},
|
||||
{"change", "Change an existing secret", &s_change, .alt = altc, .grp = 1},
|
||||
{"agent", "Run a process in a trusted zone", &s_agent, .alt = altz, .grp = 1},
|
||||
{"version", "Show version", &s_version, .grp = 1},
|
||||
{NULL}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue