aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/finder.php
diff options
context:
space:
mode:
authorDan Villiom Podlaski Christiansen <danchr@gmail.com>2016-09-07 03:17:44 +0200
committerDan Villiom Podlaski Christiansen <danchr@gmail.com>2016-09-07 03:17:44 +0200
commitce48b4de57e55ebdb6ee4bbc2eac2f81998cc671 (patch)
tree3ea442e4230126d89aff8d8720ee056e930dae71 /phpBB/phpbb/finder.php
parent65921a78915e0c9bf494e8c780681522644abf7d (diff)
downloadforums-ce48b4de57e55ebdb6ee4bbc2eac2f81998cc671.tar
forums-ce48b4de57e55ebdb6ee4bbc2eac2f81998cc671.tar.gz
forums-ce48b4de57e55ebdb6ee4bbc2eac2f81998cc671.tar.bz2
forums-ce48b4de57e55ebdb6ee4bbc2eac2f81998cc671.tar.xz
forums-ce48b4de57e55ebdb6ee4bbc2eac2f81998cc671.zip
[ticket/12133] fix download file names for WebKit-derived browsers
All browser engines that descend from WebKit declare themselves as Safari in the user agent, including Chrome. Currently, the code assumes that any Safari-like browser cannot handle the RFC-compliant filename syntax. At least for recent versions of Safari, this is no longer the case, and the legacy syntax results in URI-quoted filenames. Using the standard syntax works as expected in both Safari 9 and Chrome 45. The ticket reporting this issue is from January 2014, so we can safely ignore compatibility: any browser still relying on the previous behaviour is unlikely to receive security updates. PHPBB3-12133
Diffstat (limited to 'phpBB/phpbb/finder.php')
0 files changed, 0 insertions, 0 deletions
> 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464
/*
 * Guillaume Cottenceau (gc@mandrakesoft.com)
 *
 * Copyright 2000 Mandrakesoft
 *
 * This software may be freely redistributed under the terms of the GNU
 * public license.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */

/*
 * (1) calculate dependencies
 * (2) unarchive relevant modules
 * (3) insmod them
 */

#include "stage1.h"

#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mount.h>
#include <fcntl.h>
#include <libgen.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
#include <sys/utsname.h>
#include "log.h"
#include "utils.h"
#include "frontend.h"
#include "mount.h"
#include "zlibsupport.h"

#include "modules.h"

static char modules_directory[100];
static struct module_deps_elem * modules_deps = NULL;
static struct module_descr_elem * modules_descr = NULL;

extern long init_module(void *, unsigned long, const char *);


static const char *moderror(int err)
{
	switch (err) {
	case ENOEXEC:
		return "Invalid module format";
	case ENOENT:
		return "Unknown symbol in module";
	case ESRCH:
		return "Module has wrong symbol version";
	case EINVAL:
		return "Invalid parameters";
	default:
		return strerror(err);
	}
}

int insmod_local_file(char * path, char * options)
{
	void *file;
	unsigned long len;
	int rc;
                
	if (IS_TESTING)
		return 0;

	file = grab_file(path, &len);
                
	if (!file) {
		log_perror(asprintf_("\terror reading %s", path));
		return -1;
	}
                
	rc = init_module(file, len, options ? options : "");
	if (rc)
		log_message("\terror: %s", moderror(errno));
	return rc;
}

static char *kernel_module_extension(void)
{
	return ".ko.gz";
}


static char *filename2modname(char * filename) {
	char *modname, *p;

	modname = strdup(basename(filename));
	if (strstr(modname, kernel_module_extension())) {
		modname[strlen(modname)-strlen(kernel_module_extension())] = '\0'; /* remove trailing .ko.gz */
	}

	p = modname;
	while (p && *p) {
		if (*p == '-')
			*p = '_';
		p++;
	}

	return modname;
}

static void find_modules_directory(void)
{
	struct utsname kernel_uname;
	char * prefix = "/lib/modules";
	char * release;
	if (uname(&kernel_uname)) {
		fatal_error("uname failed");
	}
	release = kernel_uname.release;
	sprintf(modules_directory , "%s/%s", prefix, release);
}

static int load_modules_dependencies(void)
{
	char * deps_file = asprintf_("%s/%s", modules_directory, "modules.dep");
	char * buf, * ptr, * start, * end;
	struct stat s;
	int line, i;

	log_message("loading modules dependencies");
	buf = cat_file(deps_file, &s);
	if (!buf)
		return -1;
	line = line_counts(buf);
	modules_deps = malloc(sizeof(*modules_deps) * (line+1));

	start = buf;
	line = 0;
	while (start < (buf+s.st_size) && *start) {
		char * tmp_deps[50];

		end = strchr(start, '\n');
		*end = '\0';

		ptr = strchr(start, ':');
		if (!ptr) {
			start = end + 1;
			continue;
		}
		*ptr = '\0';
		ptr++;

		while (*ptr && (*ptr == ' ')) ptr++;

		/* sort of a good line */
		modules_deps[line].filename = strdup(start);
		modules_deps[line].modname = filename2modname(start);

		start = ptr;
		i = 0;
		while (start && *start) {
			ptr = strchr(start, ' ');
			if (ptr) *ptr = '\0';
			tmp_deps[i++] = filename2modname(start);
			if (ptr)
				start = ptr + 1;
			else
				start = NULL;
			while (start && *start && *start == ' ')
				start++;
		}
		tmp_deps[i++] = NULL;

		modules_deps[line].deps = memdup(tmp_deps, sizeof(char *) * i);

		line++;
		start = end + 1;
	}
	modules_deps[line].modname = NULL;

	free(buf);

	return 0;
}


static int load_modules_descriptions(void)
{
	char * descr_file = asprintf_("%s/%s", modules_directory, "modules.description");
	char * buf, * ptr, * start, * end;
	struct stat s;
	int line;

	log_message("loading modules descriptions");

	buf = cat_file(descr_file, &s);
	if (!buf)
		return -1;
	line = line_counts(buf);
	modules_descr = malloc(sizeof(*modules_descr) * (line+1));

	start = buf;
	line = 0;
	while (start < (buf+s.st_size) && *start) {
		end = strchr(start, '\n');
		*end = '\0';

		ptr = strchr(start, '\t');
		if (!ptr) {
			start = end + 1;
			continue;
		}
		*ptr = '\0';
		ptr++;

		modules_descr[line].modname = filename2modname(start);
		modules_descr[line].description = strndup(ptr, 50);

		line++;
		start = end + 1;
	}
	modules_descr[line].modname = NULL;

	free(buf);

	return 0;
}


void init_modules_insmoding(void)
{
	find_modules_directory();
	if (load_modules_dependencies()) {
		fatal_error("warning, error initing modules stuff, modules loading disabled");
	}
	if (load_modules_descriptions()) {
		log_message("warning, error initing modules stuff, modules loading disabled");
	}
}


static void add_modules_conf(char * str)
{
	static char data[5000] = "";
	char * target = "/tmp/modules.conf";
	int fd;

	if (strlen(data) + strlen(str) >= sizeof(data))
		return;

	strcat(data, str);
	strcat(data, "\n");

	fd = open(target, O_CREAT|O_WRONLY|O_TRUNC, 00660);
	
	if (fd == -1) {
		log_perror(str);
		return;
	}

	if (write(fd, data, strlen(data) + 1) != (ssize_t) (strlen(data) + 1))
		log_perror(str);

	close(fd);
}


int module_already_present(const char * name)
{
	FILE * f;
	int answ = 0;

	if ((f = fopen("/proc/modules", "rb"))) {
                while (1) {
                        char buf[500];
                        if (!fgets(buf, sizeof(buf), f)) break;
                        if (!strncmp(name, buf, strlen(name)) && buf[strlen(name)] == ' ')
                                answ = 1;
                }
                fclose(f);
        }
	return answ;
}


static enum insmod_return insmod_with_deps(const char * mod_name, char * options, int allow_modules_floppy)
{
	struct module_deps_elem * dep;
	const char * filename;

	dep = modules_deps;
	while (dep && dep->modname && strcmp(dep->modname, mod_name)) dep++;

	if (dep && dep->modname && dep->deps) {
		char ** one_dep;
		one_dep = dep->deps;
		while (*one_dep) {
			/* here, we can fail but we don't care, if the error is
			 * important, the desired module will fail also */
			insmod_with_deps(*one_dep, NULL, allow_modules_floppy);
			one_dep++;
		}
	}
        
	if (dep && dep->filename) {
	       filename = dep->filename;
	} else {
		log_message("warning: unable to get module filename for %s", mod_name);
		filename = mod_name;
	}

	if (module_already_present(mod_name))
		return INSMOD_OK;

	log_message("needs %s", filename);
	{
		return insmod_local_file((char *) filename, options);
	}
}


#ifndef DISABLE_NETWORK
enum insmod_return my_insmod(const char * mod_name, enum driver_type type, char * options, int allow_modules_floppy)
#else
enum insmod_return my_insmod(const char * mod_name, enum driver_type type __attribute__ ((unused)), char * options, int allow_modules_floppy)
#endif
{
	int i;
#ifndef DISABLE_NETWORK
	char ** net_devices = NULL; /* fucking compiler */
#endif

	if (module_already_present(mod_name))
		return INSMOD_OK;