diff options
author | Samuel Mendoza-Jonas <sam@mendozajonas.com> | 2018-06-19 16:33:42 +1000 |
---|---|---|
committer | Samuel Mendoza-Jonas <sam@mendozajonas.com> | 2018-12-03 14:39:57 +1100 |
commit | 5d7f93f2ee09de515e1e474fd752d52590b51793 (patch) | |
tree | e125ada614a82edd27269b873d77a66d99420da0 /lib/crypt/crypt.h | |
parent | cfd6bf4f7da1ee71a65f57f28912d43ab757b968 (diff) | |
download | talos-petitboot-5d7f93f2ee09de515e1e474fd752d52590b51793.tar.gz talos-petitboot-5d7f93f2ee09de515e1e474fd752d52590b51793.zip |
lib/crypt: Add helpers for operating on /etc/shadow
Provides helper functions for reading, writing, and checking against
/etc/shadow. The main use case if for authenticating clients against the
"system" password, which is set as the root password.
Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Diffstat (limited to 'lib/crypt/crypt.h')
-rw-r--r-- | lib/crypt/crypt.h | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/lib/crypt/crypt.h b/lib/crypt/crypt.h new file mode 100644 index 0000000..4b242f0 --- /dev/null +++ b/lib/crypt/crypt.h @@ -0,0 +1,49 @@ +/* + * Copyright (C) 2018 IBM Corporation + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + */ +#ifndef CRYPT_H +#define CRYPT_H + +#include "config.h" + +#ifdef CRYPT_SUPPORT + +char *crypt_get_hash(void *ctx); +bool crypt_check_password(const char *password); +int crypt_set_password(void *ctx, const char *password); +int crypt_set_password_hash(void *ctx, const char *hash); + +#else + +static inline char *crypt_get_hash(void *ctx __attribute__((unused))) +{ + return NULL; +} +static inline bool crypt_check_password( + const char *password __attribute__((unused))) +{ + return false; +} +static inline int crypt_set_password(void *ctx __attribute__((unused)), + const char *password __attribute__((unused))) +{ + return -1; +} +static inline int crypt_set_password_hash(void *ctx __attribute__((unused)), + const char *hash __attribute__((unused))) +{ + return -1; +} + +#endif +#endif /* CRYPT_H */ |