Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Icecast-Server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Xiph.Org
Icecast-Server
Commits
4d909409
Commit
4d909409
authored
2 years ago
by
Philipp Schafft
Browse files
Options
Downloads
Patches
Plain Diff
Feature: Report on dashboard if no secure password hashing is supported
See also:
#2010
parent
0ef660bc
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/admin.c
+4
-0
4 additions, 0 deletions
src/admin.c
src/util_crypt.c
+28
-14
28 additions, 14 deletions
src/util_crypt.c
src/util_crypt.h
+1
-0
1 addition, 0 deletions
src/util_crypt.h
with
33 additions
and
14 deletions
src/admin.c
+
4
−
0
View file @
4d909409
...
...
@@ -1840,6 +1840,10 @@ static void command_dashboard (client_t *client, source_t *source, adm
}
}
if
(
!
util_crypt_is_new_secure
())
{
__reportxml_add_maintenance
(
reportnode
,
config
->
reportxml_db
,
"40d134e3-fbbe-46b1-a409-9b2ca8954528"
,
"warning"
,
"No secure password hash support detected."
,
NULL
);
}
reportxml_helper_add_value_health
(
resource
,
"status"
,
health
);
reportxml_node_add_child
(
incident
,
resource
);
...
...
This diff is collapsed.
Click to expand it.
src/util_crypt.c
+
28
−
14
View file @
4d909409
...
...
@@ -38,21 +38,23 @@ static pthread_mutex_t crypt_mutex = PTHREAD_MUTEX_INITIALIZER;
#endif
#if (defined(HAVE_CRYPT_R) || defined(HAVE_CRYPT)) && HAVE_PTHREAD
struct
algo
{
const
char
prefix
[
4
];
const
size_t
saltlen
;
const
bool
secure
;
};
static
pthread_once_t
crypt_detect
=
PTHREAD_ONCE_INIT
;
static
const
char
*
new_prefix
;
static
size_t
new_
s
al
tlen
;
static
const
struct
algo
*
new_algo
;
#define HAVE_
new_al
go
void
crypt_detect_run
(
void
)
{
static
const
struct
{
const
char
prefix
[
4
];
const
size_t
saltlen
;
}
list
[]
=
{{
"$6$"
,
12
},
{
"$5$"
,
12
},
{
"$1$"
,
6
}};
static
const
struct
algo
list
[]
=
{{
"$6$"
,
12
,
true
},
{
"$5$"
,
12
,
true
},
{
"$1$"
,
6
,
false
}};
for
(
size_t
i
=
0
;
i
<
(
sizeof
(
list
)
/
sizeof
(
*
list
));
i
++
)
{
if
(
util_crypt_is_supported
(
list
[
i
].
prefix
))
{
new_prefix
=
list
[
i
].
prefix
;
new_saltlen
=
list
[
i
].
saltlen
;
new_algo
=
&
(
list
[
i
]);
return
;
}
}
...
...
@@ -75,7 +77,7 @@ char * util_crypt_hash(const char *pw)
if
(
pthread_once
(
&
crypt_detect
,
crypt_detect_run
)
!=
0
)
return
NULL
;
if
(
new_
prefix
)
{
if
(
new_
algo
)
{
char
input
[
128
];
char
salt
[
64
];
char
*
salt_base64
;
...
...
@@ -87,18 +89,18 @@ char * util_crypt_hash(const char *pw)
#endif
/* if this is true, we have a bug */
if
(
new_saltlen
>
sizeof
(
salt
))
if
(
new_
algo
->
saltlen
>
sizeof
(
salt
))
return
NULL
;
len
=
igloo_prng_read
(
igloo_instance
,
salt
,
new_saltlen
,
igloo_PRNG_FLAG_NONE
);
if
(
len
!=
(
ssize_t
)
new_saltlen
)
len
=
igloo_prng_read
(
igloo_instance
,
salt
,
new_
algo
->
saltlen
,
igloo_PRNG_FLAG_NONE
);
if
(
len
!=
(
ssize_t
)
new_
algo
->
saltlen
)
return
NULL
;
salt_base64
=
util_base64_encode
(
salt
,
new_saltlen
);
salt_base64
=
util_base64_encode
(
salt
,
new_
algo
->
saltlen
);
if
(
!
salt_base64
)
return
NULL
;
snprintf
(
input
,
sizeof
(
input
),
"%s%s"
,
new_prefix
,
salt_base64
);
snprintf
(
input
,
sizeof
(
input
),
"%s%s"
,
new_
algo
->
prefix
,
salt_base64
);
free
(
salt_base64
);
...
...
@@ -234,3 +236,15 @@ bool util_crypt_is_supported(const char *prefix)
return
supported
;
}
bool
util_crypt_is_new_secure
(
void
)
{
#ifdef HAVE_new_algo
if
(
pthread_once
(
&
crypt_detect
,
crypt_detect_run
)
!=
0
)
return
NULL
;
return
new_algo
->
secure
;
#else
return
false
;
#endif
}
This diff is collapsed.
Click to expand it.
src/util_crypt.h
+
1
−
0
View file @
4d909409
...
...
@@ -14,6 +14,7 @@
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
);
bool
util_crypt_is_new_secure
(
void
);
/* Exported for tests only!: */
char
*
util_crypt_hash_oldstyle
(
const
char
*
pw
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment