Skip to content
Browse files

Merge branch 'master' of github.com:pcbsd/pcbsd

  • Loading branch information...
2 parents 7ba4ea7 + c3ae393 commit 155b055d9ad3df5605ccc95ccaf20f6d89fc66f5 @beanpole135 beanpole135 committed Sep 23, 2013
View
2 src-qt4/libpcbsd/utils/utils.cpp
@@ -277,7 +277,7 @@ QString Utils::getProxyPass() {
QString val = getValFromSHFile("/etc/profile", "HTTP_PROXY_AUTH");
if ( val.isEmpty() )
return QString();
- return val.section(":", 3, 3);
+ return val.section(":", 3, 3).section("'", 1, 1);
}
QString Utils::getProxyType() {
View
2 src-qt4/pc-netmanager/src/NetworkManager/networkman.cpp
@@ -1038,7 +1038,7 @@ void NetworkMan::saveProxyConfig()
else
authLine="digest:*:";
authLine += lineProxyUser->text() + ":";
- authLine += lineProxyPass->text() + "";
+ authLine += "'" + lineProxyPass->text() + "'";
pcbsd::Utils::setProxyAuth(authLine);
}
QMessageBox::warning( this, tr("Proxy enabled"), tr("You may need to re-login for proxy settings to take effect."));
View
30 src-sh/pc-thinclient/pc-thinclient
@@ -252,6 +252,31 @@ rpcbind : ALL : deny|" /etc/hosts.allow
done
}
+# Check if the user wants to install packages for the webui
+check_webui() {
+ echo "PC-ThinClient includes a web-interface for client management."
+ echo "Would you like to install the Apache / PHP packages required?"
+ echo -e "(Y/y)\c";
+ read ans
+ if [ $ans != "y" -o "$ans" != "Y" ] ; then return; fi
+
+ pkg install apache22 php5-hash php5-session
+ if [ $? -ne 0 ] ; then
+ echo "Package install failed!"
+ echo "You may need to manually add apache, php5-hash and php5-session."
+ fi
+
+ # Make sure the config file exists
+ if [ ! -e "${PROGDIR}/resources/webui/config.php" ] ; then
+ cp ${PROGDIR}/resources/webui/config.php.dist ${PROGDIR}/resources/webui/config.php
+ fi
+
+ echo "All the webui files are located in: ${PROGDIR}/resources/webui"
+ echo "You will need to configure your web-server to serve this directory."
+ echo ""
+ echo "Please edit the file ${PROGDIR}/resources/webui/config.php to set the"
+ echo "user passwords / auth tokens for the site."
+}
# Check if we need to install custom config
check_installconfig() {
@@ -411,6 +436,8 @@ check_installdirs() {
touch ${PXEWORLD}/etc/installserver
mkdir ${PXEWORLD}/installscripts
cp ${PROGDIR}/resources/scripts/pc-sysinstall.example ${PXEWORLD}/installscripts/pc-sysinstall.example
+ chown -R www:www ${PXEWORLD}/installscripts
+
echo "zfs_load=\"YES\"" > ${PXEWORLD}/boot/loader.conf
echo "geom_mirror_load=\"YES\"" >> ${PXEWORLD}/boot/loader.conf
echo "geom_eli_load=\"YES\"" >> ${PXEWORLD}/boot/loader.conf
@@ -479,6 +506,9 @@ check_worldports
if [ "$SYSTYPE" != "desktop" ] ; then
# Setup the installation directories
check_installdirs
+
+ # Ask if they want to use the WebUI
+ check_webui
fi
# Install the thinclient configuration files
View
24 src-sh/pc-thinclient/resources/webui/clients.php
@@ -0,0 +1,24 @@
+<?php
+
+ require("config.php");
+ require("functions.php");
+
+ if ( $loggedin != 0 )
+ {
+ require("login.php");
+ exit(1);
+ }
+
+ if ( isset($_GET['add']) )
+ add_mac();
+ else {
+ if ( isset($_GET['doadd']) )
+ doadd_mac();
+ if ( isset($_GET['del']) )
+ rem_mac($_GET['del']);
+
+ // list the mac files
+ list_mac();
+ }
+
+?>
View
16 src-sh/pc-thinclient/resources/webui/config.php.dist
@@ -0,0 +1,16 @@
+<?php
+
+ // Install script directory
+ $sdir="/home/thinclient/installscripts";
+
+ // Users who have access to this site
+ // Multiple users can be defined
+ $AUTHUSERS = array();
+ $AUTHUSERS['admin'] = 'changeme';
+ //$AUTHUSERS['kris'] = 'example';
+
+ // Auth Token, you should make this a unique random string
+ $AUTHTOKEN="as&f09#34lj1?28a<bkf(a*kl09}$#";
+
+
+?>
View
196 src-sh/pc-thinclient/resources/webui/functions.php
@@ -0,0 +1,196 @@
+<?php
+
+require("config.php");
+
+// Remove a mac address sym-link
+function rem_mac($mac)
+{
+ global $sdir;
+ chdir($sdir);
+ unlink($mac);
+}
+
+// Function to do the creation of the mac -> file symlink
+function doadd_mac()
+{
+ global $sdir;
+
+ if ( ! isset($_POST['macaddress']) or ! isset($_POST['cfgfile']) )
+ die("Unset vars! Did you enter a mac address?");
+
+ $mac=$_POST['macaddress'];
+ $cfg=$_POST['cfgfile'];
+ chdir($sdir);
+ symlink($cfg, $mac . ".cfg");
+
+}
+
+// Function to add a mac address sym-link -> config file
+function add_mac()
+{
+ global $sdir;
+
+ echo "<a href=\"?view=clients\">Back</a><br>";
+ echo "<br>";
+ echo "Please enter the MAC address, and select a config to install with:<br>";
+
+ echo "<form method=\"post\" action=\"?view=clients&doadd=true\">\n";
+ echo "Mac Address: <input type=\"text\" name=\"macaddress\" size=\"50\"><br>\n";
+ echo "Config File: <select name=cfgfile>\n";
+
+ chdir($sdir);
+ $dir_handle = @opendir($sdir) or die("Unable to open $sdir");
+
+ //running the while loop
+ while ($file = readdir($dir_handle))
+ {
+ if ( "$file" == ".." or "${file}" == "." or is_dir($file) or is_link($file))
+ continue;
+ echo "<option value=\"$file\">$file</option>";
+ }
+
+ echo "</select><br><br>\n";
+ echo "<input type=\"submit\" name=\"Save\" value=\"Add MAC\">";
+ echo "</form>\n";
+
+}
+
+// Function to list mac address sym-links in the scripts dir
+function list_mac()
+{
+ global $sdir;
+
+ // Display client MAC address scripts
+ chdir($sdir);
+ $dir_handle = @opendir($sdir) or die("Unable to open $sdir");
+
+ $bgcolor = "#BDBDBD";
+
+ echo "<a href=\"?view=clients&add=true\">Add a MAC address</a><br>";
+ echo "<table border=\"0\" cellspacing=\"0\"><tr bgcolor=\"#1A73CC\"><td><b>MAC Address</b></td><td></td><td><b>Config File</b></td><td></td></tr><br>";
+
+ //running the while loop
+ while ($file = readdir($dir_handle))
+ {
+ if ( "$file" == ".." or "${file}" == "." or is_dir($file) or ! is_link($file))
+ continue;
+
+ // Get the file sym-link target
+ $cfg = readlink($file);
+
+ $mac = strstr($file, '.cfg', true);
+
+ echo "<tr bgcolor=\"$bgcolor\" border=0><td>$mac</td><td>&nbsp;<b>></b>&nbsp;</td><td>$cfg</td><td>&nbsp; - <a href=\"?view=clients&del=$file\">Remove</a></td>";
+
+ if ( $bgcolor == "#BDBDBD" )
+ $bgcolor = "#FFFFFF";
+ else
+ $bgcolor = "#BDBDBD";
+ }
+
+ echo "</table>";
+
+} // End of list MAC addreses
+
+// Function to list cfg files
+function list_cfgs()
+{
+ global $sdir;
+
+ // Display cfg files
+ chdir($sdir);
+ $dir_handle = @opendir($sdir) or die("Unable to open $sdir");
+
+ $bgcolor = "#BDBDBD";
+
+ echo "<a href=\"?view=configs&add=true\">Add a Config</a><br>";
+ echo "<table border=\"0\" cellspacing=\"0\"><tr bgcolor=\"#1A73CC\"><td><b>Config File</b></td><td></td><td></td></tr><br>";
+
+ //running the while loop
+ while ($file = readdir($dir_handle))
+ {
+ if ( "$file" == ".." or "${file}" == "." or is_dir($file) or is_link($file))
+ continue;
+
+ // Get the file sym-link target
+ $config = strstr($file, '.cfg', true);
+
+ echo "<tr bgcolor=\"$bgcolor\" border=0><td>$config</td><td><a href=\"?view=configs&edit=$file\">Edit</a></td><td>&nbsp; - <a href=\"?view=configs&del=$file\">Remove</a></td>";
+
+ if ( $bgcolor == "#BDBDBD" )
+ $bgcolor = "#FFFFFF";
+ else
+ $bgcolor = "#BDBDBD";
+ }
+
+ echo "</table>";
+
+} // End of list config files
+
+// Function to add the new config file
+function doadd_cfg()
+{
+ global $sdir;
+
+ chdir($sdir);
+ $uploadfile = $sdir . "/" . basename($_FILES['usercfg']['name']);
+
+ if (! move_uploaded_file($_FILES['usercfg']['tmp_name'], $uploadfile))
+ die("Failed uploading config file");
+}
+
+
+function add_cfg()
+{
+ echo "<form enctype=\"multipart/form-data\" action=\"?view=configs&doadd=true\" method=\"POST\">";
+ echo "<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"30000\" />";
+ echo "Upload this config: <input name=\"usercfg\" type=\"file\" /><br>";
+ echo "<input type=\"submit\" value=\"Upload Config\" /><br>";
+ echo "</form>";
+}
+
+
+// Function to add a config file
+function edit_cfg($cfg)
+{
+ global $sdir;
+
+ // Get the file sym-link target
+ $confignick = strstr($cfg, '.cfg', true);
+
+ echo "<a href=\"?view=configs\">Back</a><br>";
+ echo "<br>";
+ echo "Editing the config: <b>$confignick</b><br>";
+
+ echo "<form method=\"post\" action=\"?view=configs&doedit=$cfg\">\n";
+ echo "<textarea name=\"script\" cols=\"100\" rows=\"25\">";
+ readfile($sdir . "/" . $cfg);
+ echo "</textarea><br>\n";
+ echo "<input type=\"submit\" name=\"Save\" value=\"Save Config\">";
+ echo "</form>";
+
+}
+
+// Remove a mac address sym-link
+function rem_cfg($cfg)
+{
+ global $sdir;
+ chdir($sdir);
+ unlink($cfg);
+}
+
+// Function to edit the config file
+function doedit_cfg($cfg)
+{
+ global $sdir;
+
+ if ( ! isset($_POST['script']) )
+ die("Unset vars! Did you not enter an install script?");
+
+ $contents=$_POST['script'];
+ $contents=str_replace("\r\n", "\n", $contents);
+ $handle = fopen($sdir . "/" . $cfg, "w");
+ fwrite($handle, $contents);
+}
+
+?>
View
40 src-sh/pc-thinclient/resources/webui/index.php
@@ -0,0 +1,40 @@
+<?php
+
+date_default_timezone_set ( "UTC" );
+session_start();
+
+ini_set('display_errors', 'On');
+
+// Load the config
+require("config.php");
+require("logincheck.php");
+
+if ( $loggedin != 0 )
+{
+ require("login.php");
+ exit(1);
+}
+
+?>
+
+<html>
+<head>
+<title>PC-ThinClient PXE Management</title>
+</head>
+<a href="?view=clients">Clients</a> - <a href="?view=configs">Install Configs</a> - <a href="?p=logout">Logout</a>
+<br>
+<hr>
+<?php
+
+ if ( isset($_GET['view']) )
+ $view = $_GET['view'];
+ else
+ $view = "clients";
+
+ if ("$view" == "clients" ) {
+ include("clients.php");
+ } else if ("$view" == "configs" ) {
+ include("scripts.php");
+ }
+?>
+</html>
View
22 src-sh/pc-thinclient/resources/webui/login.php
@@ -0,0 +1,22 @@
+<html>
+<form method="post" action="index.php">
+<center>
+<h2>Login required</h2>
+<table>
+<tr><td>
+Username<br>
+<input type="text" name="username"><br>
+Password<br>
+<input type="password" name="password"><br>
+<center><input type="submit" name="login" value="Login"></center><br>
+
+<?
+if ( $loginfailed == 1 )
+{
+ echo "<h3><font color=\"#990000\">Login failed!</font></h3>";
+}
+?>
+</td></tr>
+</table>
+</form>
+</html>
View
85 src-sh/pc-thinclient/resources/webui/logincheck.php
@@ -0,0 +1,85 @@
+<?
+
+function session_defaults() {
+ $_SESSION['logged'] = false;
+ $_SESSION['uid'] = 0;
+ $_SESSION['username'] = '';
+ $_SESSION['password'] = '';
+ $_SESSION['cookie'] = '';
+ $_SESSION['remember'] = false;
+}
+
+if (!isset($_SESSION['uid']) ) {
+ session_defaults();
+}
+
+if ( isset($_GET['p']) )
+{
+ if ( $_GET['p'] == "logout" )
+ session_defaults();
+}
+
+$loginfailed = 0;
+$loggedin = "1";
+
+function check_my_login() {
+ global $loginfailed;
+ global $loggedin;
+ global $AUTHUSERS;
+ global $AUTHTOKEN;
+ global $username;
+
+ if ( ! empty($_SESSION['username']) ){
+ $cUser = $_SESSION['username'];
+ $cTime = $_SESSION['time'];
+ $cToken = $_SESSION['token'];
+ $lTime = date("YmdHi");
+ // If 2 hours have passed, log them out
+ if ( $lTime - $cTime > 120 )
+ {
+ echo "<center>Session Expired...</center>";
+ session_defaults();
+ return;
+ }
+
+ $cHash = hash("sha256", "$AUTHTOKEN $cTime $cUser");
+ if ( $cHash != $cToken ) {
+ echo "<center>Invalid token...</center>";
+ session_defaults();
+ return;
+ }
+
+ // Update the token / time
+ $username = $cUser;
+ $_SESSION["time"] = $lTime;
+ $_SESSION["token"] = hash("sha256", "$AUTHTOKEN $lTime $username");
+ $loggedin = "0";
+ return;
+ }
+
+ // Not logged in
+ $loggedin = "1";
+ if (isset($_POST['username']) and isset($_POST['password']) ) {
+ $username = $_POST['username'];
+ $pass = $_POST['password'];
+
+ $ADMINPASS = $AUTHUSERS[$username];
+ $ADMINUSER = $username;
+
+ if ( "$pass" == "$ADMINPASS" and $username == $ADMINUSER and ! empty($ADMINPASS) and ! empty($ADMINUSER) )
+ {
+ $_SESSION["username"] = "$username";
+ $lTime = date("YmdHi");
+ $_SESSION["time"] = $lTime;
+ $_SESSION["token"] = hash("sha256", "$AUTHTOKEN $lTime $username");
+ $loggedin = "0";
+ } else {
+ session_defaults();
+ $loginfailed = 1;
+ }
+ }
+}
+
+check_my_login();
+
+?>
View
29 src-sh/pc-thinclient/resources/webui/scripts.php
@@ -0,0 +1,29 @@
+<?php
+
+ require("config.php");
+ require("functions.php");
+
+ if ( $loggedin != 0 )
+ {
+ require("login.php");
+ exit(1);
+ }
+
+
+ if ( isset($_GET['add']) )
+ add_cfg();
+ else if (isset($_GET['edit']) )
+ edit_cfg($_GET['edit']);
+ else {
+ if ( isset($_GET['doadd']) )
+ doadd_cfg();
+ if ( isset($_GET['doedit']) )
+ doedit_cfg($_GET['doedit']);
+ if ( isset($_GET['del']) )
+ rem_cfg($_GET['del']);
+
+ // list the config files
+ list_cfgs();
+ }
+
+?>
View
8 src-sh/port-files/pkg-plist
@@ -536,6 +536,13 @@ share/pcbsd/pc-thinclient/resources/etc/gettytab
share/pcbsd/pc-thinclient/resources/root/dot.login
share/pcbsd/pc-thinclient/resources/dhcpd/dhcpd.conf
share/pcbsd/pc-thinclient/resources/boot/beastie.4th
+share/pcbsd/pc-thinclient/resources/webui/functions.php
+share/pcbsd/pc-thinclient/resources/webui/scripts.php
+share/pcbsd/pc-thinclient/resources/webui/clients.php
+share/pcbsd/pc-thinclient/resources/webui/config.php.dist
+share/pcbsd/pc-thinclient/resources/webui/logincheck.php
+share/pcbsd/pc-thinclient/resources/webui/index.php
+share/pcbsd/pc-thinclient/resources/webui/login.php
share/pcbsd/de-profiles/lxde.profile
share/pcbsd/de-profiles/kde.profile
share/pcbsd/de-profiles/gnome.profile
@@ -733,6 +740,7 @@ share/pbi-manager/pcbsd.rpo
@dirrm share/pcbsd/pc-thinclient/resources/scripts/cardDetect
@dirrm share/pcbsd/pc-thinclient/resources/scripts
@dirrm share/pcbsd/pc-thinclient/resources/gdm
+@dirrm share/pcbsd/pc-thinclient/resources/webui
@dirrm share/pcbsd/pc-thinclient/resources
@dirrm share/pcbsd/pc-thinclient
@dirrm share/pcbsd/de-profiles

0 comments on commit 155b055

Please sign in to comment.
Something went wrong with that request. Please try again.