Project

General

Profile

« Previous | Next » 

Revision 8a47c190

Added by Ermal Luçi over 15 years ago

Ticket #413. Hanlde cases when no authentication is specified.

View differences:

etc/inc/openvpn.inc
382 382
				$conf .= "client-cert-not-required\n";
383 383
			case 'server_tls_user':
384 384
				$conf .= "username-as-common-name\n";
385
				$authcfgs = explode(",", $settings['authmode']);
386
				$sed = "\$authmodes=array(";
387
				$firstsed = 0;
388
				foreach ($authcfgs as $authcfg) {
389
					if ($firstsed > 0)
390
						$sed .= ",";
391
					$firstsed = 1;
392
					$sed .= "\"{$authcfg}\"";
385
				if (!empty($settings['authmode'])) {
386
					$authcfgs = explode(",", $settings['authmode']);
387
					$sed = "\$authmodes=array(";
388
					$firstsed = 0;
389
					foreach ($authcfgs as $authcfg) {
390
						if ($firstsed > 0)
391
							$sed .= ",";
392
						$firstsed = 1;
393
						$sed .= "\"{$authcfg}\"";
394
					}
395
					$sed .= ");";
396
					mwexec("/bin/cat /etc/inc/openvpn.auth-user.php | /usr/bin/sed 's/\/\/<template>/{$sed}/g' >  {$g['varetc_path']}/openvpn/{$mode_id}.php");
397
					mwexec("/bin/chmod a+x {$g['varetc_path']}/openvpn/{$mode_id}.php");
398
					$conf .= "auth-user-pass-verify {$g['varetc_path']}/openvpn/{$mode_id}.php via-env\n";
393 399
				}
394
				$sed .= ");";
395
				mwexec("/bin/cat /etc/inc/openvpn.auth-user.php | /usr/bin/sed 's/\/\/<template>/{$sed}/g' >  {$g['varetc_path']}/openvpn/{$mode_id}.php");
396
				mwexec("/bin/chmod a+x {$g['varetc_path']}/openvpn/{$mode_id}.php");
397
				$conf .= "auth-user-pass-verify {$g['varetc_path']}/openvpn/{$mode_id}.php via-env\n";
398 400
				break;
399 401
		}
400 402

  
usr/local/www/vpn_openvpn_server.php
268 268
		if ($_POST['disable'] == "yes")
269 269
			$server['disable'] = true;
270 270
		$server['mode'] = $pconfig['mode'];
271
		$server['authmode'] = implode(",", $pconfig['authmode']);
271
		if (!empty($pconfig['authmode']))
272
			$server['authmode'] = implode(",", $pconfig['authmode']);
272 273
		$server['protocol'] = $pconfig['protocol'];
273 274
		list($server['interface'], $server['ipaddr']) = explode ("|",$pconfig['interface']);
274 275
		$server['local_port'] = $pconfig['local_port'];
......
341 342
		header("Location: vpn_openvpn_server.php");
342 343
		exit;
343 344
	}
344
	$pconfig['authmode'] = implode(",", $pconfig['authmode']);
345
	if (!empty($pconfig['authmode']))
346
		$pconfig['authmode'] = implode(",", $pconfig['authmode']);
345 347
}
346 348

  
347 349
include("head.inc");

Also available in: Unified diff