diff options
author | Lennart Poettering <lennart@poettering.net> | 2019-11-13 23:28:05 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2020-01-15 15:26:51 +0100 |
commit | 64aa2622a3baea1f62732f136230543c9d669cd1 (patch) | |
tree | cbec7d7ecbeb2cea2fc8b4de9442cd6b2fb502ba /src/shared/libcrypt-util.c | |
parent | shared: split out crypt() specific helpers into its own .c/.h in src/shared/ (diff) | |
download | systemd-64aa2622a3baea1f62732f136230543c9d669cd1.tar.xz systemd-64aa2622a3baea1f62732f136230543c9d669cd1.zip |
libcrypt-util: add superficial validator for UNIX hashed password strings
Diffstat (limited to 'src/shared/libcrypt-util.c')
-rw-r--r-- | src/shared/libcrypt-util.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/shared/libcrypt-util.c b/src/shared/libcrypt-util.c index b1a8168030..f41685ae45 100644 --- a/src/shared/libcrypt-util.c +++ b/src/shared/libcrypt-util.c @@ -73,3 +73,14 @@ int make_salt(char **ret) { return 0; #endif } + +bool hashed_password_valid(const char *s) { + + /* Returns true if the specified string is a 'valid' hashed UNIX password, i.e. if starts with '$' or + * with '!$' (the latter being a valid, yet locked password). */ + + if (isempty(s)) + return false; + + return STARTSWITH_SET(s, "$", "!$"); +} |