[xiph-cvs] cvs commit: icecast/src config.c config.h connection.c slave.c
Michael Smith
msmith at xiph.org
Fri Aug 16 07:55:56 PDT 2002
msmith 02/08/16 10:55:56
Modified: conf icecast.xml
src config.c config.h connection.c slave.c
Log:
Fix relaying to work with new auth scheme.
Revision Changes Path
1.10 +2 -0 icecast/conf/icecast.xml
Index: icecast.xml
===================================================================
RCS file: /usr/local/cvsroot/icecast/conf/icecast.xml,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- icecast.xml 9 Aug 2002 15:55:01 -0000 1.9
+++ icecast.xml 16 Aug 2002 14:55:56 -0000 1.10
@@ -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>
<p><p>1.18 +11 -0 icecast/src/config.c
Index: config.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/config.c,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- config.c 16 Aug 2002 14:26:47 -0000 1.17
+++ config.c 16 Aug 2002 14:55:56 -0000 1.18
@@ -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 @@
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 @@
_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 @@
_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 @@
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 @@
} 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);
<p><p>1.9 +2 -0 icecast/src/config.h
Index: config.h
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/config.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- config.h 16 Aug 2002 14:26:47 -0000 1.8
+++ config.h 16 Aug 2002 14:55:56 -0000 1.9
@@ -27,6 +27,7 @@
int ice_login;
char *source_password;
+ char *relay_password;
int touch_freq;
ice_config_dir_t *dir_list;
@@ -37,6 +38,7 @@
char *master_server;
int master_server_port;
int master_update_interval;
+ char *master_password;
char *base_dir;
char *log_dir;
<p><p>1.24 +10 -10 icecast/src/connection.c
Index: connection.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/connection.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- connection.c 16 Aug 2002 14:26:48 -0000 1.23
+++ connection.c 16 Aug 2002 14:55:56 -0000 1.24
@@ -337,7 +337,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
*/
/* TODO: add GUID-xxxxxx */
if (strcmp(uri, "/stats.xml") == 0) {
- if (!_check_source_pass(parser)) {
- INFO1("Source (%s) attempted to login with bad password", uri);
+ if (!_check_source_pass(parser, "stats")) {
+ INFO0("Request for stats.xml with incorrect or no password");
client_send_401(client);
return;
}
@@ -548,7 +548,7 @@
}
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 {
<p><p>1.5 +12 -2 icecast/src/slave.c
Index: slave.c
===================================================================
RCS file: /usr/local/cvsroot/icecast/src/slave.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- slave.c 16 Aug 2002 14:26:48 -0000 1.4
+++ slave.c 16 Aug 2002 14:55:56 -0000 1.5
@@ -72,6 +72,9 @@
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 @@
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\nice-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\nAuthorization: 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);
<p><p>--- >8 ----
List archives: http://www.xiph.org/archives/
Ogg project homepage: http://www.xiph.org/ogg/
To unsubscribe from this list, send a message to 'cvs-request at xiph.org'
containing only the word 'unsubscribe' in the body. No subject is needed.
Unsubscribe messages sent to the list will be ignored/filtered.
More information about the commits
mailing list