This file is indexed.

/usr/bin/apache2nwconf is in nanoweb-contrib 2.2.9-0ubuntu1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 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
#!/usr/bin/php -q
<?php ($prev_pwd = getenv("PWD")) and chdir($prev_pwd);

#-- options
$CONVERT_GENERAL_SETTINGS = 0;		# not recommended - edit the
					# nanoweb.conf for fine tuning!

#-- conversion tables
$c_1 = array(
	"documentroot" => "DocumentRoot",
	"servername" => "ServerName",
	"directoryindex" => "DirectoryIndex",
	"alias" => "Alias",
	"languagepriority" => "LanguagePriority",
	"servertype" => "ServerMode",
  //	"timeout" => "RequestTimeout",
  //	"maxservers" => "MaxServers",
  //	"maxkeepaliverequests" => "KeepAlive",
	"serveradmin" => "ServerAdmin",
	"user" => "User",
	"group" => "Group",
	"typesconfig" => "MimeTypes",
	"defaulttype" => "DefaultContentType",
	"addtype" => "AddType"
);
$c_2 = array(
	"serveralias" => "ServerAlias",
	"bindaddress" => "ListenInterface",
	"port" => "ListenPort",
);

#-- help
$fa = @$argv[1];
if (($argc < 2) || eregi('^-+h|/[h?]', $fa)) {
	echo<<<EOT

usage:  apache2nwconf /etc/apache/httpd.conf > /etc/nanoweb/vhosts.conf
        apache2nwconf -a > nw-vhosts.conf

Convertes apache httpd virtual host configuration for use with the nanoweb
http server. Change the program source to tweak some conversion parameters.


EOT
	;

}
else {

	if (eregi('^-+a', $fa)) {
		$fa = "/etc/apache/httpd.conf";
	}
	if (!($ac = file($fa))) {
		die("Could not read »$fa«\n");
	}

	$sect = "global";
	$conf = array();
	$conf["global"]["ServerName"][0]="localhost";

	foreach ($ac as $line) {

		$line = trim($line); if (empty($line) || ($line[0] == "#")) continue;

		if ($line[0] == "<") {
			if ($line[1] == "/") {
				$sect = "global";
			}
			elseif (preg_match('/^<VirtualHost\s+([^>\s]+)/', $line, $uu)) {
				$sect = $uu[1];
			}
		}
		else {
			list($directive, $value) = preg_split('/\s+/', $line, 2);

			$directive = strtolower($directive);

			if ($directive == "servername") {
				if ($sect == "global") continue;
#<off># echo "#'[$sect]'=>'[$value]'\n";
				$conf[$value] = $conf[$sect];
				unset($conf[$sect]);
				$sect = $value;
			}
			if ($newname = @$c_1[$directive]) {
				$conf[$sect][$newname][] = $value;
			}
			elseif ($newname = @$c_2[$directive]) {
				foreach (preg_split('/\s+/', $value) as $v) {
					$conf[$sect][$newname][] = $v;
				}
			}
		}

	}

	#-- print $conf array in nanoweb.conf style
	echo "# autoconverted from $fa by apache2nwconf\n# UTC(" . time() .")\n";
	if ($CONVERT_GENERAL_SETTINGS && (@$conf["global"])) {
		echo "\n[/global]\n# general settings imported from Apache:\n# Note that this can be dangerous!\n";
		foreach ($conf["global"] as $dir => $a) {
			foreach ($a as $value) {
				echo str_pad($dir, 16) . " = $value\n";
			}
		}
		echo "\n";
	}
	if (isset($conf["global"])) unset($conf["global"]);
	echo "\n# VirtualHost sections\n";
	foreach ($conf as $sect => $directives) {
		echo "\n[$sect]\n";
		foreach ($directives as $dir => $a) {
			foreach ($a as $value) {
				echo str_pad($dir, 16) . " = $value\n";
			}
		}
		echo "[/$sect]\n";
	}
	echo "\n";

}

?>