Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multicaptive portal error #388

Closed
wants to merge 1 commit into from

Conversation

Ahmet-Kaplan
Copy link

For multicaptive portal situations, this code looks only first portal's db, not others.
I changed setting the "status" variable for this purpose.

For multicaptive portal situations, this code looks only first portal's db, not others.
I changed setting the "status" variable for this purpose.
@netgate-git-updates
Copy link

Before this pull request can be accepted you must first sign a CLA as described at https://www.pfsense.org/about-pfsense/#cla. Please read for more details.

@Ahmet-Kaplan
Copy link
Author

Sorry, now I signed the CLA.

@rbgarga
Copy link
Member

rbgarga commented Aug 9, 2017

Instead of doing this change I believe it would be better to change squid_check_ip() and make it return NULL or false when user is not found. It would help to simplify the logic here.

If you have interest, it would be nice to change squid_check_ip() to use PHP functions to access sqlite database instead of running using a shell command

Copy link
Contributor

@jim-p jim-p left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems OK, but the way @rbgarga described changing it would be better.

@doktornotor
Copy link
Contributor

If you have interest, it would be nice to change squid_check_ip() to use PHP functions to access sqlite database instead of running using a shell command

Well it used to be that way, and it got reverted after it got completely broken following some pfSense upgrade. See d6ea469

@doktornotor
Copy link
Contributor

@rbgarga @Ahmet-Kaplan - how about something like this?

#!/usr/local/bin/php-cgi -q
<?php
/*
 * check_ip.php
 *
 * part of pfSense (https://www.pfsense.org)
 * Copyright (c) 2016-2017 Rubicon Communications, LLC (Netgate)
 * Copyright (c) 2013-2016 Marcello Coutinho
 * All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

require_once("config.inc");
require_once("globals.inc");
error_reporting(0);
global $g;
// stdin loop
if (!defined(STDIN)) {
	define("STDIN", fopen("php://stdin", "r"));
}
if (!defined(STDOUT)) {
	define("STDOUT", fopen('php://stdout', 'w'));
}
while (!feof(STDIN)) {
	$check_ip = trim(fgets(STDIN));
	$dbs = glob("{$g['vardb_path']}/captiveportal*.db");

	foreach ($dbs as $db) {
		if (!strpos($db, "_radius")) {
			$status = squid_check_ip($db, $check_ip);
			if (isset($status)) {
				fwrite(STDOUT, "OK user={$status}\n");
				break;
			}
		}
	}
	if (is_null($status)) {
		fwrite(STDOUT, "ERR\n");
	}
}

function squid_check_ip($db, $check_ip) {
	exec("/usr/local/bin/sqlite3 {$db} \"SELECT ip FROM captiveportal WHERE ip='{$check_ip}'\"", $ip);
	if ($check_ip == $ip[0]) {
		exec("/usr/local/bin/sqlite3 {$db} \"SELECT username FROM captiveportal WHERE ip='{$check_ip}'\"", $user);
		return $user[0];
	} else {
		return NULL;
	}
}

?>

@rbgarga rbgarga removed the CLA label Sep 22, 2017
@rbgarga
Copy link
Member

rbgarga commented Dec 5, 2017

@Ahmet-Kaplan do you still have plans to work on this change?

@jim-p
Copy link
Contributor

jim-p commented Dec 11, 2017

In an effort to improve the tracking of changes and bug/feature requests, we have decided to require an entry on the pfSense Redmine issue tracker associated with every pull request, and likewise the Redmine entry should also have a link back to the pull request.

If you could, please associate this PR to a Redmine issue either by locating an existing issue at https://redmine.pfsense.org or by creating a new issue. Add a link to the Redmine issue that points to this PR, and also add a link on the PR to the Redmine issue.

For more information, see https://doc.pfsense.org/index.php/Submitting_a_Pull_Request_via_Github

Thanks!

@rbgarga
Copy link
Member

rbgarga commented Jan 17, 2018

No changes since Aug

@rbgarga rbgarga closed this Jan 17, 2018
netgate-git-updates pushed a commit that referenced this pull request Dec 6, 2019
Original distfile was rerolled by updates Victor Mono version from 1.121 to 1.250
(github issue #388, ryanoasis/nerd-fonts#388)

Pointyhat to:	ehaupt
netgate-git-updates pushed a commit that referenced this pull request Nov 8, 2020
- Fixed apcu_store() with integer keys (#388).
- Made apc.use_request_time=0 the default (#391).
- Made apcu compatible with PHP 8.0.

Approved by:	miwi (maintainer - implicit)
Sponsored by:	Netzkommune GmbH
netgate-git-updates pushed a commit that referenced this pull request Nov 26, 2024
Update the default location of the DB.

Changes since 1.8.1:

v1.8.2

Added

  * More translation strings (#373) (#388)

Changed

  * Enforce git config on startup (#383)
  * Respect file scheme URIs for SQLite. (#387)

Fixed

  * Convert octal notation file names in Git (#380)
  * Git clone on SSH with MySQL (#382)
  * Escaping for embed gists (#381)

Other

  * Update deps Golang & JS deps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants