...
 
Commits (9)
## Process this file with automake to produce Makefile.in
admindir = $(pkgdatadir)/admin
nobase_dist_admin_DATA = listclients.xsl listmounts.xsl moveclients.xsl response.xsl \
stats.xsl manageauth.xsl updatemetadata.xsl xspf.xsl vclt.xsl includes/footer.xsl \
includes/head.xsl includes/header.xsl includes/page.xsl includes/mountnav.xsl
nobase_dist_admin_DATA = \
listclients.xsl \
listmounts.xsl \
moveclients.xsl \
response.xsl \
stats.xsl \
manageauth.xsl \
updatemetadata.xsl \
error-html.xsl \
error-plaintext.xsl \
xspf.xsl \
vclt.xsl \
includes/footer.xsl \
includes/head.xsl \
includes/header.xsl \
includes/page.xsl \
includes/mountnav.xsl \
includes/web-page.xsl
......@@ -497,6 +497,7 @@ void admin_handle_request(client_t *client, const char *uri)
ICECAST_LOG_DEBUG("Granted right to call COMMAND_RAW_METADATA_UPDATE to "
"client because it is allowed to do SOURCE or PUT.");
} else {
ICECAST_LOG_DEBUG("Client needs to authenticate.");
client_send_error_by_id(client, ICECAST_ERROR_GEN_CLIENT_NEEDS_TO_AUTHENTICATE);
return;
}
......
......@@ -39,24 +39,29 @@
# endif
#endif
/* Make sure we define 64 bit types */
#ifdef _WIN32
# define PATH_SEPARATOR "\\"
#else
# define PATH_SEPARATOR "/"
#endif
/* Make sure we define 64 bit types */
#ifdef HAVE_STDINT_H
# include <stdint.h>
#endif
#ifdef HAVE_INTTYPES_H
# include <inttypes.h>
#endif
#if defined(_WIN32) && !defined(HAVE_STDINT_H) && !defined(HAVE_INTTYPES_H)
# define size_t unsigned int
# define ssize_t int
# define int64_t __int64
# define uint64_t unsigned __int64
# define uint32_t unsigned int
# define int32_t __int32
# define uint32_t unsigned __int32
# define PRIu64 "I64u"
# define PRId64 "I64d"
#else
# define PATH_SEPARATOR "/"
# ifdef HAVE_STDINT_H
# include <stdint.h>
# endif
# ifdef HAVE_INTTYPES_H
# include <inttypes.h>
# endif
#endif
/* some defaults if not provided above */
......
......@@ -16,7 +16,7 @@
#ifdef HAVE_POLL
#include <poll.h>
#else
#elif HAVE_SYS_SELECT_H
#include <sys/select.h>
#endif
......
......@@ -100,8 +100,8 @@ static mutex_t xsltlock;
/* Reference to the original xslt loader func */
static xsltDocLoaderFunc xslt_loader;
/* Admin path cache */
static xmlChar *admin_path = NULL;
/* Admin URI cache */
static xmlChar *admin_URI = NULL;
void xslt_initialize(void)
{
......@@ -121,8 +121,8 @@ void xslt_shutdown(void) {
thread_mutex_destroy (&xsltlock);
xmlCleanupParser();
xsltCleanupGlobals();
if (admin_path)
xmlFree(admin_path);
if (admin_URI)
xmlFree(admin_URI);
}
static void clear_cache_entry(size_t idx) {
......@@ -142,6 +142,11 @@ void xslt_clear_cache(void)
for (i = 0; i < CACHESIZE; i++)
clear_cache_entry(i);
if (admin_URI) {
xmlFree(admin_URI);
admin_URI = NULL;
}
thread_mutex_unlock(&xsltlock);
}
......@@ -220,7 +225,7 @@ static xmlDocPtr custom_loader(const xmlChar *URI,
xsltLoadType type)
{
xmlDocPtr ret;
xmlChar *rel_path, *fn, *final_URI = NULL;
xmlChar *rel_URI, *fn, *final_URI = NULL;
char *path_URI = NULL;
xsltStylesheet *c;
ice_config_t *config;
......@@ -247,44 +252,43 @@ static xmlDocPtr custom_loader(const xmlChar *URI,
break;
/* Construct the right path */
rel_path = xmlBuildRelativeURI(URI, c->doc->URL);
if (rel_path != NULL && admin_path != NULL) {
fn = xmlBuildURI(rel_path, admin_path);
rel_URI = xmlBuildRelativeURI(URI, c->doc->URL);
if (rel_URI != NULL && admin_URI != NULL) {
fn = xmlBuildURI(rel_URI, admin_URI);
final_URI = fn;
xmlFree(rel_path);
xmlFree(rel_URI);
}
/* Fail if there was an error constructing the path */
if (final_URI == NULL) {
if (rel_path)
xmlFree(rel_path);
if (rel_URI)
xmlFree(rel_URI);
return NULL;
}
break;
/* In case a top stylesheet is loaded */
case XSLT_LOAD_START:
config = config_get_config();
/* Admin path is cached, so that we don't need to get it from
* the config every time we load a xsl include.
* Whenever a new top stylesheet is loaded, we check here
* if the path in the config has changed and adjust it, if needed.
*/
if (admin_path != NULL &&
strcmp(config->adminroot_dir, (char *)admin_path) != 0) {
xmlFree(admin_path);
admin_path = NULL;
/* Check if the admin URI is already cached */
if (admin_URI != NULL) {
break;
}
/* Do we need to load the admin path? */
if (!admin_path) {
config = config_get_config();
/* Append path separator to path */
size_t len = strlen(config->adminroot_dir);
xmlChar* admin_path = xmlMalloc(len+2);
xmlStrPrintf(admin_path, len+2, "%s/", XMLSTR(config->adminroot_dir));
admin_path = xmlMalloc(len+2);
if (!admin_path)
return NULL;
/* Convert admin path to URI */
admin_URI = xmlPathToURI(admin_path);
xmlFree(admin_path);
/* Copy over admin path and add a tailing slash. */
xmlStrPrintf(admin_path, len+2, XMLSTR("%s/"), XMLSTR(config->adminroot_dir));
}
if (!admin_URI) {
return NULL;
} else {
ICECAST_LOG_DEBUG("Loaded and cached admin_URI \"%s\"", admin_URI);
}
config_release_config();
break;
......