Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Xiph.Org
Icecast-Server
Commits
121720a4
Commit
121720a4
authored
Aug 16, 2002
by
Michael Smith
Browse files
Fix relaying to work with new auth scheme.
svn path=/trunk/icecast/; revision=3838
parent
913ec348
Changes
5
Hide whitespace changes
Inline
Side-by-side
conf/icecast.xml
View file @
121720a4
...
...
@@ -12,6 +12,7 @@
</limits>
<source-password>
hackme
</source-password>
<relay-password>
hackme
</relay-password>
<directory>
<touch-freq>
5
</touch-freq>
...
...
@@ -28,6 +29,7 @@
<!--<master-server>127.0.0.1</master-server>-->
<!--<master-server-port>8001</master-server-port>-->
<!--<master-update-interval>120</master-update-interval>-->
<!--<master-password>hackme/master-password>-->
<paths>
<basedir>
/usr/local/icecast
</basedir>
...
...
src/config.c
View file @
121720a4
...
...
@@ -14,6 +14,7 @@
#define CONFIG_DEFAULT_HEADER_TIMEOUT 15
#define CONFIG_DEFAULT_SOURCE_TIMEOUT 10
#define CONFIG_DEFAULT_SOURCE_PASSWORD "changeme"
#define CONFIG_DEFAULT_RELAY_PASSWORD "changeme"
#define CONFIG_DEFAULT_ICE_LOGIN 0
#define CONFIG_DEFAULT_TOUCH_FREQ 5
#define CONFIG_DEFAULT_HOSTNAME "localhost"
...
...
@@ -69,6 +70,8 @@ void config_shutdown(void)
xmlFree
(
c
->
admin
);
if
(
c
->
source_password
&&
c
->
source_password
!=
CONFIG_DEFAULT_SOURCE_PASSWORD
)
xmlFree
(
c
->
source_password
);
if
(
c
->
relay_password
&&
c
->
relay_password
!=
CONFIG_DEFAULT_SOURCE_PASSWORD
)
xmlFree
(
c
->
relay_password
);
if
(
c
->
hostname
&&
c
->
hostname
!=
CONFIG_DEFAULT_HOSTNAME
)
xmlFree
(
c
->
hostname
);
if
(
c
->
base_dir
&&
c
->
base_dir
!=
CONFIG_DEFAULT_BASE_DIR
)
...
...
@@ -157,6 +160,7 @@ static void _set_defaults(void)
_configuration
.
header_timeout
=
CONFIG_DEFAULT_HEADER_TIMEOUT
;
_configuration
.
source_timeout
=
CONFIG_DEFAULT_SOURCE_TIMEOUT
;
_configuration
.
source_password
=
CONFIG_DEFAULT_SOURCE_PASSWORD
;
_configuration
.
relay_password
=
CONFIG_DEFAULT_RELAY_PASSWORD
;
_configuration
.
ice_login
=
CONFIG_DEFAULT_ICE_LOGIN
;
_configuration
.
touch_freq
=
CONFIG_DEFAULT_TOUCH_FREQ
;
_configuration
.
dir_list
=
NULL
;
...
...
@@ -166,6 +170,7 @@ static void _set_defaults(void)
_configuration
.
master_server
=
NULL
;
_configuration
.
master_server_port
=
CONFIG_DEFAULT_PORT
;
_configuration
.
master_update_interval
=
CONFIG_MASTER_UPDATE_INTERVAL
;
_configuration
.
master_password
=
NULL
;
_configuration
.
base_dir
=
CONFIG_DEFAULT_BASE_DIR
;
_configuration
.
log_dir
=
CONFIG_DEFAULT_LOG_DIR
;
_configuration
.
webroot_dir
=
CONFIG_DEFAULT_WEBROOT_DIR
;
...
...
@@ -202,6 +207,9 @@ static void _parse_root(xmlDocPtr doc, xmlNodePtr node)
if
(
_configuration
.
source_password
&&
_configuration
.
source_password
!=
CONFIG_DEFAULT_SOURCE_PASSWORD
)
xmlFree
(
_configuration
.
source_password
);
_configuration
.
source_password
=
(
char
*
)
xmlNodeListGetString
(
doc
,
node
->
xmlChildrenNode
,
1
);
}
}
else
if
(
strcmp
(
node
->
name
,
"relay-password"
)
==
0
)
{
if
(
_configuration
.
relay_password
&&
_configuration
.
relay_password
!=
CONFIG_DEFAULT_RELAY_PASSWORD
)
xmlFree
(
_configuration
.
relay_password
);
_configuration
.
relay_password
=
(
char
*
)
xmlNodeListGetString
(
doc
,
node
->
xmlChildrenNode
,
1
);
}
else
if
(
strcmp
(
node
->
name
,
"icelogin"
)
==
0
)
{
tmp
=
(
char
*
)
xmlNodeListGetString
(
doc
,
node
->
xmlChildrenNode
,
1
);
_configuration
.
ice_login
=
atoi
(
tmp
);
...
...
@@ -219,6 +227,9 @@ static void _parse_root(xmlDocPtr doc, xmlNodePtr node)
}
else
if
(
strcmp
(
node
->
name
,
"master-server"
)
==
0
)
{
if
(
_configuration
.
master_server
)
xmlFree
(
_configuration
.
master_server
);
_configuration
.
master_server
=
(
char
*
)
xmlNodeListGetString
(
doc
,
node
->
xmlChildrenNode
,
1
);
}
else
if
(
strcmp
(
node
->
name
,
"master-password"
)
==
0
)
{
if
(
_configuration
.
master_password
)
xmlFree
(
_configuration
.
master_password
);
_configuration
.
master_password
=
(
char
*
)
xmlNodeListGetString
(
doc
,
node
->
xmlChildrenNode
,
1
);
}
else
if
(
strcmp
(
node
->
name
,
"master-server-port"
)
==
0
)
{
tmp
=
(
char
*
)
xmlNodeListGetString
(
doc
,
node
->
xmlChildrenNode
,
1
);
_configuration
.
master_server_port
=
atoi
(
tmp
);
...
...
src/config.h
View file @
121720a4
...
...
@@ -27,6 +27,7 @@ typedef struct ice_config_tag
int
ice_login
;
char
*
source_password
;
char
*
relay_password
;
int
touch_freq
;
ice_config_dir_t
*
dir_list
;
...
...
@@ -37,6 +38,7 @@ typedef struct ice_config_tag
char
*
master_server
;
int
master_server_port
;
int
master_update_interval
;
char
*
master_password
;
char
*
base_dir
;
char
*
log_dir
;
...
...
src/connection.c
View file @
121720a4
...
...
@@ -337,7 +337,7 @@ fail:
return
0
;
}
static
int
_check_source_pass_http
(
http_parser_t
*
parser
)
static
int
_check_source_pass_http
(
http_parser_t
*
parser
,
char
*
correctuser
)
{
/* This will look something like "Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==" */
char
*
header
=
httpp_getvar
(
parser
,
"authorization"
);
...
...
@@ -368,7 +368,7 @@ static int _check_source_pass_http(http_parser_t *parser)
username
=
userpass
;
password
=
tmp
+
1
;
if
(
strcmp
(
username
,
"source"
)
||
strcmp
(
password
,
correctpass
))
{
if
(
strcmp
(
username
,
correctuser
)
||
strcmp
(
password
,
correctpass
))
{
free
(
userpass
);
return
0
;
}
...
...
@@ -393,12 +393,12 @@ static int _check_source_pass_ice(http_parser_t *parser)
return
1
;
}
static
int
_check_source_pass
(
http_parser_t
*
parser
)
static
int
_check_source_pass
(
http_parser_t
*
parser
,
char
*
user
)
{
if
(
config_get_config
()
->
ice_login
)
return
_check_source_pass_ice
(
parser
);
else
return
_check_source_pass_http
(
parser
);
return
_check_source_pass_http
(
parser
,
user
);
}
static
void
_handle_source_request
(
connection_t
*
con
,
...
...
@@ -411,8 +411,8 @@ static void _handle_source_request(connection_t *con,
INFO1
(
"Source logging in at mountpoint
\"
%s
\"
"
,
uri
);
stats_event_inc
(
NULL
,
"source_connections"
);
if
(
!
_check_source_pass
(
parser
))
{
INFO1
(
"Source (%s) attempted to login with
bad
password"
,
uri
);
if
(
!
_check_source_pass
(
parser
,
"source"
))
{
INFO1
(
"Source (%s) attempted to login with
invalid or missing
password"
,
uri
);
client_send_401
(
client
);
return
;
}
...
...
@@ -442,7 +442,7 @@ static void _handle_stats_request(connection_t *con,
stats_event_inc
(
NULL
,
"stats_connections"
);
if
(
!
_check_source_pass
(
parser
))
{
if
(
!
_check_source_pass
(
parser
,
"stats"
))
{
ERROR0
(
"Bad password for stats connection"
);
connection_close
(
con
);
httpp_destroy
(
parser
);
...
...
@@ -486,8 +486,8 @@ static void _handle_get_request(connection_t *con,
*/
/* TODO: add GUID-xxxxxx */
if
(
strcmp
(
uri
,
"/stats.xml"
)
==
0
)
{
if
(
!
_check_source_pass
(
parser
))
{
INFO
1
(
"
Source (%s) attempted to login with bad
password"
,
uri
);
if
(
!
_check_source_pass
(
parser
,
"stats"
))
{
INFO
0
(
"
Request for stats.xml with incorrect or no
password"
);
client_send_401
(
client
);
return
;
}
...
...
@@ -548,7 +548,7 @@ static void _handle_get_request(connection_t *con,
}
if
(
strcmp
(
uri
,
"/allstreams.txt"
)
==
0
)
{
if
(
!
_check_source_pass
(
parser
))
{
if
(
!
_check_source_pass
(
parser
,
"relay"
))
{
INFO0
(
"Client attempted to fetch allstreams.txt with bad password"
);
client_send_401
(
client
);
}
else
{
...
...
src/slave.c
View file @
121720a4
...
...
@@ -72,6 +72,9 @@ static void *_slave_thread(void *arg) {
http_parser_t
*
parser
;
client_t
*
client
;
int
interval
=
config_get_config
()
->
master_update_interval
;
char
*
authheader
,
*
data
;
int
len
;
char
*
username
=
"relay"
;
while
(
_initialized
)
{
if
(
config_get_config
()
->
master_update_interval
>
++
interval
)
{
...
...
@@ -86,8 +89,15 @@ static void *_slave_thread(void *arg) {
WARN0
(
"Relay slave failed to contact master server to fetch stream list"
);
continue
;
}
// FIXME: This is now broken...
sock_write
(
mastersock
,
"GET /allstreams.txt HTTP/1.0
\r\n
ice-password: %s
\r\n\r\n
"
,
config_get_config
()
->
source_password
);
len
=
strlen
(
username
)
+
strlen
(
config_get_config
()
->
master_password
)
+
1
;
authheader
=
malloc
(
len
+
1
);
strcpy
(
authheader
,
username
);
strcat
(
authheader
,
":"
);
strcat
(
authheader
,
config_get_config
()
->
master_password
);
data
=
util_base64_encode
(
authheader
);
sock_write
(
mastersock
,
"GET /allstreams.txt HTTP/1.0
\r\n
Authorization: Basic %s
\r\n\r\n
"
,
data
);
free
(
data
);
while
(
sock_read_line
(
mastersock
,
buf
,
sizeof
(
buf
)))
{
buf
[
strlen
(
buf
)]
=
0
;
avl_tree_rlock
(
global
.
source_tree
);
...
...
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