mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2024-12-04 14:46:30 -05:00
Feature: Report what crypt types are supported on the admin version page
This commit is contained in:
parent
468bd425d5
commit
4105bded13
11
src/admin.c
11
src/admin.c
@ -80,6 +80,7 @@
|
||||
#include "reportxml.h"
|
||||
#include "reportxml_helper.h"
|
||||
#include "xml2json.h"
|
||||
#include "util_crypt.h"
|
||||
|
||||
#include "format.h"
|
||||
|
||||
@ -1922,6 +1923,12 @@ static void command_version (client_t *client, source_t *source, adm
|
||||
#ifdef HAVE_GETADDRINFO
|
||||
"getaddrinfo",
|
||||
#endif
|
||||
#ifdef HAVE_CRYPT
|
||||
"crypt",
|
||||
#endif
|
||||
#ifdef HAVE_CRYPT_R
|
||||
"crypt_r",
|
||||
#endif
|
||||
#ifdef WIN32
|
||||
"win32",
|
||||
#endif
|
||||
@ -2035,6 +2042,10 @@ static void command_version (client_t *client, source_t *source, adm
|
||||
reportxml_helper_add_value_flag(rflags, "bound-inet6", listensocket_container_is_family_included(global.listensockets, SOCK_FAMILY_INET6));
|
||||
global_unlock();
|
||||
|
||||
reportxml_helper_add_value_flag(rflags, "crypt-1", util_crypt_is_supported("$1$"));
|
||||
reportxml_helper_add_value_flag(rflags, "crypt-5", util_crypt_is_supported("$5$"));
|
||||
reportxml_helper_add_value_flag(rflags, "crypt-6", util_crypt_is_supported("$6$"));
|
||||
|
||||
refobject_unref(config);
|
||||
refobject_unref(dependencies);
|
||||
refobject_unref(cflags);
|
||||
|
@ -95,3 +95,38 @@ bool util_crypt_check(const char *plain, const char *crypted)
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool util_crypt_is_supported(const char *prefix)
|
||||
{
|
||||
static const struct {
|
||||
const char *plain;
|
||||
const char *crypted;
|
||||
const bool expected;
|
||||
} vectors[] = {
|
||||
{"abc", "$1$xxxxxxxx$3GbMJKRcRFz50R9Q96xFb.", true},
|
||||
{"abX", "$1$xxxxxxxx$3GbMJKRcRFz50R9Q96xFb.", false},
|
||||
{"abc", "$1$xxxxxxxx$3GbMJKRcRFz50R9Q96xFbY", false},
|
||||
{"abX", "$1$xxxxxxxx$3GbMJKRcRFz50R9Q96xFbY", false},
|
||||
{"abc", "$5$xxxxxxxxxxxxxxxx$zNpAueQbvBleD3aSz0KwnySLaHSedk8ULXPvT1m7DUC", true},
|
||||
{"abX", "$5$xxxxxxxxxxxxxxxx$zNpAueQbvBleD3aSz0KwnySLaHSedk8ULXPvT1m7DUC", false},
|
||||
{"abc", "$5$xxxxxxxxxxxxxxxx$zNpAueQbvBleD3aSz0KwnySLaHSedk8ULXPvT1m7DUY", false},
|
||||
{"abX", "$5$xxxxxxxxxxxxxxxx$zNpAueQbvBleD3aSz0KwnySLaHSedk8ULXPvT1m7DUY", false},
|
||||
{"abc", "$6$xxxxxxxxxxxxxxxx$yNfBmH1zabagyi9HZwRuCgebrSjfr1zXUE6pFhnTG1BcvINxhgU53sjSUJDnQ5s6FPq8NSIntrpmc5ox87wX5.", true},
|
||||
{"abX", "$6$xxxxxxxxxxxxxxxx$yNfBmH1zabagyi9HZwRuCgebrSjfr1zXUE6pFhnTG1BcvINxhgU53sjSUJDnQ5s6FPq8NSIntrpmc5ox87wX5.", false},
|
||||
{"abc", "$6$xxxxxxxxxxxxxxxx$yNfBmH1zabagyi9HZwRuCgebrSjfr1zXUE6pFhnTG1BcvINxhgU53sjSUJDnQ5s6FPq8NSIntrpmc5ox87wX5Y", false},
|
||||
{"abX", "$6$xxxxxxxxxxxxxxxx$yNfBmH1zabagyi9HZwRuCgebrSjfr1zXUE6pFhnTG1BcvINxhgU53sjSUJDnQ5s6FPq8NSIntrpmc5ox87wX5Y", false}
|
||||
};
|
||||
size_t prefixlen = strlen(prefix);
|
||||
bool supported = false;
|
||||
|
||||
for (size_t i = 0; i < (sizeof(vectors)/sizeof(*vectors)); i++) {
|
||||
if (strncmp(vectors[i].crypted, prefix, prefixlen) == 0) {
|
||||
bool res = util_crypt_check(vectors[i].plain, vectors[i].crypted);
|
||||
if (res != vectors[i].expected)
|
||||
return false;
|
||||
supported = true;
|
||||
}
|
||||
}
|
||||
|
||||
return supported;
|
||||
}
|
||||
|
@ -13,5 +13,6 @@
|
||||
|
||||
char * util_crypt_hash(const char *pw);
|
||||
bool util_crypt_check(const char *plain, const char *crypted);
|
||||
bool util_crypt_is_supported(const char *prefix);
|
||||
|
||||
#endif /* __UTIL_CRYPT_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user