How to fix broken MMConfig on ASUS K8N4-E Deluxe

Remove support for mmconfig config space access in the kernel configuration, it’s broken on Asus boards with recent kernels apparently (I have this board, and nothing that’s connected on PCI works with mmconfig enabled). It’s here in the kernel configuration:

Bus options (PCI etc.) —>
[ ] Support mmconfig PCI config space access

You can also boot with “pci=nommconf” added to the kernel parameters, it should disable mmconfig too.

Udgivet i Knowledge Base, Old Base | Skriv en kommentar

SOURCE: Generic PHP Autoloader

<?
// COPYRIGHT (c) 2007 MC Solutions
/**
* Class to handle autoloading of Php class files
*/
Class AutoLoader
{

private $files;
private $error;

private $use_session_cache = “true”;

/**
* Tells the AutoLoader what to do when duplicate class files are found, I_ALL Include all, I_FIRST Include first, I_LAST Include last, I_FAIL Fail with error message
*
* @var [I_ALL,I_FIRST,I_LAST,I_FAIL]
*/
public $on_duplicate = I_ALL;

/**
* Tells the Autoloader how to cache the directory structure, C_SESSION for each session, C_PAGEVIEW for each pageview, C_NEVER dont cache
*
* @var [C_SESSION,C_PAGEVIEW,C_NEVER]
*/
public $on_cache = C_SESSION;

/**
* Tells AutoLoader which dir to look for class files in
*
* @var string
*/

public $on_classes_dir = ‘./’;

/**
* Used to recurse the directory structure containing the
*
* @param string $dir
* @return array of files in the directory
*/
private function RecurseDir($dir)
{
$dh=opendir($dir);
while ($file=readdir($dh))
{
if (($file != “.”) and ($file != “..”))
{
if (filetype($dir.$file) == ‘dir’)
{
$return[$dir.$file]= $this->RecurseDir($dir.$file.’/’);
}
else
{
$return[]=$file;
if ($this->files[$file])
{
//print “Duplicate detected $dir$file and $this->files[$file]<br>”;

if (!is_array($this->files[$file]))
{
$tmp=$this->files[$file];
$this->files[$file]=array();
$this->files[$file][]=$tmp;
}

$this->files[$file][]=$dir.$file;

} else {
$this->files[$file]=”$dir$file”;
}
}
}
}

closedir($dh);

return $this->files;
}

/**
* Checks if sessions are needed, and tries to initiate them if they are not allready
*
*/
public function __construct()
{
if ($this->on_cache == “C_SESSION”)
{
if (!headers_sent())
{
session_start();
} else {
// Output er sent, se om sessions er startet
if (isset($_SESSION))
{
// Sessions er startet, vi koerer videre
} else {
// Sessions er ikke startet, session-cache deaktiveres
$this->use_session_cache=”false”;
}
}
}
}

/**
* Tries to include a PHP File
*
* @param string $file
* @return boolean true if inclusions succeded
*/
private function try_include($file)
{
if (@include($file))
{
return true;
} else {
return false;
}
}

/**
* This function contains the semantics required to determine what file to load
*
* @param string $classname Name of wanted class
* @return true when file found
*/
private function performloadclass($classname)
{
if ($this->try_include($classname.”.php”)) { return true;}
if ($this->try_include($classname.”.class.php”)) { return true;}

if (($this->use_session_cache==”false”) and ($this->on_cache==”C_SESSION”))
{
print “Defaulting”;
$this->on_cache=C_PAGEVIEW;
}

switch ($this->on_cache)
{
case C_SESSION:

if (!$_SESSION[‘_CLASS_CACHE’])
{
$this->files=”;
$_SESSION[‘_CLASS_CACHE’]=$this->RecurseDir($this->on_classes_dir);
}
$this->files=$_SESSION[‘_CLASS_CACHE’];
break;

case C_PAGEVIEW:
if (!is_array($this->files))
{
$this->files=”;
$this->files=$this->RecurseDir($this->on_classes_dir);
}
break;

case C_NEVER:
$this->files=”;
$this->files=$this->RecurseDir($this->on_classes_dir);
break;
}

if ($this->files[$classname.”.php”])
{
$filename=$classname.”.php”;
}
else if ($this->files[$classname.”.class.php”])
{
$filename=$classname.”.class.php”;
} else {
$this->error=”Not found”;
return false;
}
if (is_array($this->files[$filename]))
{
switch ($this->on_duplicate)
{
case “I_ALL”:
foreach ($this->files[$filename] as $k)
{
print “Include $k<br>”;
include($k);
}
return true;
break;

case “I_FIRST”:
$this->try_include($this->files[$filename][0]);
return true;
break;

case “I_LAST”:
$this->try_include($this->files[$filename][count($this->files[$filename])-1]);
return true;
break;

case “I_FAIL”:
$this->error=”Duplicate files found”;
return false;
break;

default:
$this->error=”Wrong on_duplicate settings”;
return false;
break;
}
}
else
{
$this->try_include($this->files[$filename]);
return true;
}
}

/**
* This method are invoked by __autoload
*
* @param string $classname Name of wanted class
*/
public function loadclass($classname)
{
if (!$this->performloadclass($classname))
{
print “<strong>Klassefejl: $classname</strong><br><br>Kunne ikke findes i:<br>”;
print “<ul>”;
print “<li>$classname.php i php include_path samt i $this->on_classes_dir og dennes undermapper</li>”;
print “<li>$classname.class.php i php include_path samt i $this->on_classes_dir og dennes undermapper</li>”;
print “</ul>”;
if ($this->error)
{
print $this->error;
}
}
}

}

$_AutoLoader = new AutoLoader();
$_AutoLoader->on_classes_dir=’./classes/’;
$_AutoLoader->on_duplicate=I_ALL;

function __autoload($classname)
{
global $_AutoLoader;
$_AutoLoader->loadclass($classname);
}

?>

Udgivet i Knowledge Base, Old Base, Programmering | Skriv en kommentar

Cisco 1760 Config with CyberCity G.SHDSL Config

! To Apply this config, alter the following things:
! * CyberCity DSL Password
! * Telnet Password
! * Enable password
! * Access-list for telnet access.
!
! Then paste the commands into the console terminal,
! after going to terminal config mode
no service pad
service timestamps debug uptime
service timestamps log uptime
service password-encryption
!
hostname bgw.sk.mcn.dk
!
enable secret FooBar
!
ip subnet-zero
no ip finger
no ip source-route
no ip domain-lookup
!
ip dhcp excluded-address 85.82.26.160 85.82.26.179
!
ip dhcp pool 0
import all
origin ipcp
dns-server 212.242.40.3 212.242.40.51
exit
!
!NO IOSFW ENABLED
!
interface FastEthernet0/0
ip address pool 0
no ip route-cache
ip access-group 120 in
!No NAT overload with GlobalIP
!NO IOSFW ENABLED
no shutdown
exit
!
! NO EXTRA INTERFACES
interface Ethernet1/0
no ip address
no ip route-cache
shutdown
exit
!
interface ATM0/0
no ip address
no ip route-cache
no atm ilmi-keepalive
pvc 0/35
encapsulation aal5mux ppp dialer
dialer pool-member 1
exit
!
bundle-enable
dsl equipment-type CPE
dsl operating-mode GSHDSL symmetric annex B
dsl linerate AUTO
hold-queue 224 in
no shutdown
exit
!
interface Dialer0
no ip route-cache
encapsulation ppp
dialer pool 1
dialer-group 1
ppp authentication chap callin optional
ppp chap hostname dsl123456
ppp chap password FooBarPass
ip unnumbered FastEthernet0/0
ppp ipcp mask request
!No NAT overload with GlobalIP
!NO ACL110
no shutdown
exit
!
!No NAT overload with GlobalIP
!
ip classless
ip route 0.0.0.0 0.0.0.0 Dialer0 permanent
!No MPLS enabled
!
no access-list 1
no access-list 5
no access-list 10
no access-list 101
no access-list 110
no access-list 111
no access-list 120
!
! Addresses in RIP update
!NO ACL1
!
! Addresses allowed to access vty (telnet)
!access-list 5 permit 212.242.40.0 0.0.3.255
! LAN is allowed
access-list 5 permit 85.82.26.160 0.0.0.31
! Random host allow
! access-list 5 permit 10.20.30.40
!
! Special Java list
!NO ACL10
!
! Addresses to be NAT’ed.
!No NAT overload with GlobalIP
!
! Packets permited in on dialer0.
!NO ACL110
!
! Packets allowed in on the ethernet.
access-list 120 permit udp any any range bootps bootpc
access-list 120 permit ip 85.82.26.160 0.0.0.31 any
!
! Packets allowed to trigger a call.
dialer-list 1 protocol ip permit
!
line con 0
transport output none
stopbits 1
exit
line vty 0 4
password FooBar
access-class 5 in
login
exit
!
scheduler max-task-time 5000
!
config-register 0x2102
end
! After this, do a wri mem if the config works..

Udgivet i Knowledge Base, Networking, Old Base | Skriv en kommentar

Creating trusted certificate for Java JSSE

First, take the unencrypted file certificate.pfx (used on the server), and chop it up into key and PEM encoded certificate:

# openssl pkcs12 -in certificate.pfx -nodes -out certificate.key -nocerts
# openssl pkcs12 -in certificate.pfx -nodes -out certificate.pem -nokeys

Edit the certificate.key and certificate.pem files, remove the garbage before the actual key and cerfiticate.

Combine the key and certificate to a new encrypted pkcs12 file:

# openssl pkcs12 -export -in certificate.pem -inkey certificate.key -name “friendlyname” -out certificate.p12

Enter the new password.

Using Java Keytool, export the certificate from the pkcs12 file.

# keytool -export -keystore certificate.p12 -storetype pkcs12 -alias friendlyname -file server.cer

Import the certificate into a Java Key Store as a trusted certificate:

# keytool -import -keystore jssecacerts.jks -alias friendlyname -file server.cer

Enter something as keystore password and type “yes” to trust the certificate.

Udgivet i Knowledge Base, Old Base, Programmering | Skriv en kommentar

Configuring cisco catalyst / router

# Cisco configuration:
# Indendted commands are short forms of normal commands

# connect to the catalyst
telnet 192.168.200.250

# or connect console cable and fire up hyperterminal
bps:          9600
Databit:         8
Parity:       none
Stop Bit:        1
Flow control: none
# press enter a couple of times

# log in as 'root'
enable
    ena
# give enable pass

# To configure interfaces, go to terminal config mode:
configure terminal
    conf t

# Then enter interface config mode:
interface FastEthernet0/1
    in Fa0/1
# make changes and go back to general conf mode:
exit
end conf mode with:
end

# To setup passwords go to terminal config:
conf t
enable password <password>
# or
enable password 0 <password>
end

# to enable telnet access configure the VTY line
conf t
line vty 0 4
login
password <password>
end

# to change ip, go to interface config mode on vlan 1:
conf t
in vlan 1
# now enter the designated ip:
ip address 10.0.13.28 255.255.0.0
# exit to general conf and enter the gateway:
exit
ip default-gateway 10.0.0.1
end

# to enable or disable an interface, use the shutdown command

conf t
in Fa0/1
shutdown
no shutdown


# to setup new vlan instances:
# For catalyst:
# enter the vlan database:
vlan database
# add new vlans:
vlan <id> name <name>
# where ID = 2-68 and name = vlan name or VLAN00<ID>
# delete a vlan:
no vlan <id>
end

# to move a port to a vlan:
# enter interface configuration mode:
conf t
in Fa0/1
# define vlan membership for this port, and give static access to vlan id:
# (the port can only access one vlan)
switchport mode access
switchport access vlan <vlanid>
# define vlan membership for this port, and give multi access to vlan ids:
# (the port can access more vlans. conficts with 802.1Q trunks)
#  You cannot have multi-VLAN and trunk ports configured on the same switch
switchport mode multi
switchport multi vlan <vlanid>, <vlanid>
# define a trunk
switchport mode trunk
switchport trunk encapsulation (isl|dot1q)
# dot1q / 802.1Q is useable with linux / bsd
# disable some vlans over the trunk:
switchport trunk allowed vlan remove vlan-list
# setup the non-tagged traffic vlan:
switchport trunk native vlan <vlan id>
# non tagged traffic and tagged traffic can coexist nicely.
# disable a trunk:
no switchport mode
end

# Vlan for routers:
# Create first sub interface for FastEthernet0/0
conf t
interface FastEthernet0/0.1
# set vlan tag id to 10
encapsulation dot1q 10
# set ip address
ip address 10.1.1.1 255.255.255.0
exit
# repeat with fa0/0.2 and so forth...


# how to setup portfast (and disable STP)
# go to interface config mode for the port
# then do:
spanning-tree portfast
    sp portfast

# show spanning tree protocol details:
# all ports:
show spanning-tree
    sh sp

# per port:
show spanning-tree interface FastEthernet0/1
    sh sp in Fa0/1

# per vlan:
show spanning-tree vlan 1
    sh sp vl 1

# For each VLAN, the switch with the highest switch priority (the lowest
# numerical priority value) is elected as the root switch. If all switches are
# configured with the default priority (32768), the switch with the lowest MAC
# address in the VLAN becomes the root switch.

# show list of interfaces:
show interface
    sh in

# show list of vlans
show vlan
    sh vl

# save settings
copy runnin-config startup-config

#
# Important links:
#

Configuring STP (Spanning Tree Protocol):
http://www.cisco.com/univercd/cc/td/doc/product/lan/cat2950/1216ea2b/scg/swgstp.htm

Understanding and Tuning Spanning Tree Protocol Timers:
http://www.cisco.com/warp/public/473/122.html
Udgivet i Cisco, Knowledge Base, Networking | Skriv en kommentar

Tooltip javascript function

tooltip.js:
// position of the tooltip relative to the mouse in pixel //
var offsetx = 12;
var offsety = 8;

function newelement(newid)
{
if(document.createElement)
{
var el = document.createElement(‘div’);
el.id = newid;
with(el.style)
{
display = ‘none’;
position = ‘absolute’;
}
el.innerHTML = ‘ ‘;
document.body.appendChild(el);
}
}
var ie5 = (document.getElementById && document.all);
var ns6 = (document.getElementById && !document.all);
var ua = navigator.userAgent.toLowerCase();
var isapple = (ua.indexOf(‘applewebkit’) != -1 ? 1 : 0);
function getmouseposition(e)
{
if(document.getElementById)
{
var iebody=(document.compatMode &&
document.compatMode != ‘BackCompat’) ?
document.documentElement : document.body;
pagex = (isapple == 1 ? 0:(ie5)?iebody.scrollLeft:window.pageXOffset);
pagey = (isapple == 1 ? 0:(ie5)?iebody.scrollTop:window.pageYOffset);
mousex = (ie5)?event.x:(ns6)?clientX = e.clientX:false;
mousey = (ie5)?event.y:(ns6)?clientY = e.clientY:false;

var lixlpixel_tooltip = document.getElementById(‘tooltip’);
lixlpixel_tooltip.style.left = (mousex+pagex+offsetx) + ‘px’;
lixlpixel_tooltip.style.top = (mousey+pagey+offsety) + ‘px’;
}
}
function tooltip(tip)
{
if(!document.getElementById(‘tooltip’)) newelement(‘tooltip’);
var lixlpixel_tooltip = document.getElementById(‘tooltip’);
lixlpixel_tooltip.innerHTML = tip;
lixlpixel_tooltip.style.display = ‘block’;
document.onmousemove = getmouseposition;
}
function exit()
{
document.getElementById(‘tooltip’).style.display = ‘none’;
}

Usage:
onmouseover=”tooltip(‘I am a tooltip !’);” onmouseout=”exit();”

Udgivet i Knowledge Base, Old Base, Programmering | Skriv en kommentar

Simple tunneling across weird networks

web01:~# ssh zennet.dk -p 2222 -L 8080:192.168.1.252:80 -g -f -N
root@zennet.dk’s password:
web01:~#

-f and -N make the process fork into background once loaded

-L 8080:192.168.1.252:80 , means that local port 8080 should be tunneled to remote ip 192.168.1.252 port 80

-g gives remote hosts access to connect to web01 port 8080

Udgivet i Knowledge Base, Networking, Old Base | Skriv en kommentar

Cisco Portforwarding (nat)

enable
conf t
ip nat inside source static tcp 192.168.1.254 22 10.1.0.128 22

Sends incomming connection on ip 10.1.0.128(the router) port 22 go to 192.168.1.254(the desired server to receive the connection) port 22

Udgivet i Knowledge Base, Networking, Old Base | Skriv en kommentar

Installing Nagios 2 on Debian 4

# apt-get install nagios2

# htpasswd -c /etc/nagios2/htpasswd.users mike
New password:
Re-type new password:
Adding password for user mike

Udgivet i Knowledge Base, Networking, Old Base | Skriv en kommentar

PCI Bus limitations

backup ~ # hdparm -tT /dev/md1

/dev/md1:
Timing cached reads: 2232 MB in 2.00 seconds = 1115.98 MB/sec
Timing buffered disk reads: 404 MB in 3.02 seconds = 133.93 MB/sec

backup ~ # df -H | grep md1
/dev/md1 2,0T 206M 2,0T 1% /store1

Udgivet i Knowledge Base, Linux, Old Base | Skriv en kommentar