Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Xiph.Org
Icecast-Server
Commits
d0b23fb8
Commit
d0b23fb8
authored
Sep 14, 2018
by
Philipp Schafft
🦁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Feature: Added support to "static" auth to alter the client
parent
0392b4a3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
7 deletions
+25
-7
src/auth_static.c
src/auth_static.c
+25
-7
No files found.
src/auth_static.c
View file @
d0b23fb8
...
...
@@ -20,6 +20,7 @@
#include "auth.h"
#include "cfgfile.h"
#include "client.h"
#include "util.h"
#include "logging.h"
#define CATMODULE "auth_static"
...
...
@@ -27,6 +28,8 @@
typedef
struct
auth_static
{
char
*
username
;
char
*
password
;
auth_alter_t
action
;
char
*
arg
;
}
auth_static_t
;
static
auth_result
static_auth
(
auth_client
*
auth_user
)
...
...
@@ -45,19 +48,25 @@ static auth_result static_auth(auth_client *auth_user)
if
(
!
client
->
password
)
return
AUTH_NOMATCH
;
if
(
strcmp
(
auth_info
->
password
,
client
->
password
)
=
=
0
)
return
AUTH_
OK
;
if
(
strcmp
(
auth_info
->
password
,
client
->
password
)
!
=
0
)
return
AUTH_
FAILED
;
return
AUTH_FAILED
;
if
(
auth_info
->
action
!=
AUTH_ALTER_NOOP
)
{
if
(
auth_alter_client
(
auth
,
auth_user
,
auth_info
->
action
,
auth_info
->
arg
)
!=
0
)
{
ICECAST_LOG_ERROR
(
"Can not alter client."
);
}
}
return
AUTH_OK
;
}
static
void
clear_auth
(
auth_t
*
auth
)
{
auth_static_t
*
auth_info
=
auth
->
state
;
if
(
auth_info
->
username
)
free
(
auth_info
->
username
);
if
(
auth_info
->
password
)
free
(
auth_info
->
password
);
free
(
auth_info
->
username
);
free
(
auth_info
->
password
);
free
(
auth_info
->
arg
);
free
(
auth_info
);
auth
->
state
=
NULL
;
}
...
...
@@ -106,6 +115,15 @@ int auth_get_static_auth (auth_t *authenticator, config_options_t *options)
if
(
auth_info
->
password
)
free
(
auth_info
->
password
);
auth_info
->
password
=
strdup
(
options
->
value
);
}
else
if
(
strcmp
(
options
->
name
,
"action"
)
==
0
)
{
auth_info
->
action
=
auth_str2alter
(
options
->
value
);
if
(
auth_info
->
action
==
AUTH_ALTER_NOOP
)
{
ICECAST_LOG_ERROR
(
"Invalid action given."
);
clear_auth
(
authenticator
);
return
-
1
;
}
}
else
if
(
strcmp
(
options
->
name
,
"argument"
)
==
0
)
{
replace_string
(
&
(
auth_info
->
arg
),
options
->
value
);
}
else
{
ICECAST_LOG_ERROR
(
"Unknown option: %s"
,
options
->
name
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment