Thursday, January 2, 2014

hex editing for windows bios update from Acer Aspire V3-551

How to update to 2.x bios from 1.x bios (applicable for Acer\eMachines\Gateway\Packard Bell)

For its recent laptop models; Acer (and its subsidiaries) choose a weird way of delivering bios updates. When a model is sold without Windows 8, then it is delivered with 1.x bios which lacks UEFI booting and Secure Boot support. If the same model is sold with Windows 8, then its is delivered with 2.x bios with the option of UEFI booting and Secure Boot.

Problem is an user can't update from 1.x bios to 2.x bios with the downloaded bios update. Its shows: "Please update to the same type of bios (v.1.x)".

To avoid this detection, we have to hex-edit a bit. ;)

Open the bios update application with your favorite hex editor and locate the following:
DisableSecureCapsuleFlash=1
Change it as follows:
DisableSecureCapsuleFlash=0
Save the changes. You can now update to 2.x using this modded bios. Flash from DOS or Windows.

If you can't find the above string in the bios update application, then we need to take another path.

Extract the application using 7-Zip and try to locate isflash.bin (which is your bios file) & platform.ini. Then open them with hex editor and change like above. Now flash using InsydeFlash.exe.

To overcome all of the checks, we need to edit more:
DisableCompare=0
to
DisableCompare=1
&
SkipSecureBootProtectionCheck=0
to
SkipSecureBootProtectionCheck=1

If you want a SLIC mod, then mod the downloaded bios update using andyp's tool. We have to alter another thing to flash the SLIC modded bios.

Again open the bios update application with your favorite hex editor and locate the following:
[ForceFlash]
ALL=0
Change it as follows:
[ForceFlash]
ALL=1

After updating to 2.x bios, you can safely update to subsequent updates without any modding. Note that you may have to re-install your previous Windows 8 installation after updating from 1.x to 2.x bios. 

Tuesday, May 7, 2013

Fedora 18, Firefox, Chrome, alsa, sound and hdmi

In Fedora 18, or, well, I believe I had this same issue in Fedora 17... I was perplexed by why sound for Firefox would never play through HDMI. Flash works fine, videos play fine... In both Chrome and Firefox. However sound only comes through for Chrome.

This is due to the way the flashplugin for Firefox interacts with the system and the soundcard. So, I needed to install alsa plugin.

Typically I would've
yum install flash-plugin nspluginwrapper alsa-plugins-pulseaudio libcurl
  





Apparently previously I'd installed everything but alsa-plugins-pulseaudio.

Yeah... I dunno why I didn't remember to install the alsa-plugin for pulseaudio. I feel like this probably
plagued me before, but then I switched to Chrome and never had to worry about it again.

Wednesday, October 24, 2012

Fedora/CentOS/Red Hat Linux 5 and 6 OpenVPN server and client setup configuration


copy pasted here on my blog in case that site ever goes down... really thats the only reason I ever put anything on this blog. heh. saved me a time or two in the past though having it all here.

Its important these days to protect yourself on the web, you never know whose lurking and snoopin on your traffic on Wifi these days. I use my openVPN's for my Android devices as well as my laptops whenever I'm on the go.

This guide was very well written. Minor detail was making sure the -FORWARDing table was setup properly in iptables. I'm not really sure why recompiling lzo was necessary, but I followed the guide and everything turned out ok for me. Mine (2 KVM and 1 OpenVZ) were on CentOS 6 from www.hostigation.net - Tim at hostigation sells some really nice VPS's and is always a pleasure to work with.


Also the author of this article sells VPS/s with OpenVPN preconfigured at http://safesrv.net/secure-vps-hosting/

Installing OpenVPN on CentOS 5 and CentOS 6

In this guide we will show you how to setup OpenVPN on centos – the guide will give you a fully working OpenVPN installation, NOT TESTED ON OTHER DISTROS..
Looking for an OpenVPN Ready VPS ? We setup OpenVPN for youBuy Bow just select OpenVPN at checkout and we will set it all up for you.
First step is to check if tun/tap is active:
cat /dev/net/tun
If tun is active then you should see this:
cat: /dev/net/tun: File descriptor in bad state
Make sure you have these packages installed:
yum install gcc make rpm-build autoconf.noarch zlib-devel pam-devel openssl-devel -y
Download LZO RPM and Configure RPMForge Repo:
wget http://openvpn.net/release/lzo-1.08-4.rf.src.rpm
32bit Package:
CentOS 5:
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.i386.rpm
CentOS 6:
wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-1.el6.rf.i686.rpm
64bit Package:
CentOS 5:
wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el5.rf.x86_64.rpm
CentOS 6:
wget http://pkgs.repoforge.org/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
Build the rpm packages:
rpmbuild --rebuild lzo-1.08-4.rf.src.rpm
rpm -Uvh lzo-*.rpm
rpm -Uvh rpmforge-release*
Install OpenVPN:
yum install openvpn -y
Copy the easy-rsa folder to /etc/openvpn/:
cp -R /usr/share/doc/openvpn-2.2.2/easy-rsa/ /etc/openvpn/
Please note on CentOS 6 we need to make a small change before you run the commands below, open up /etc/openvpn/easy-rsa/2.0/vars and edit the below line:
Change:
export KEY_CONFIG=`$EASY_RSA/whichopensslcnf $EASY_RSA`
To:
export KEY_CONFIG=/etc/openvpn/easy-rsa/2.0/openssl-1.0.0.cnf
And save..
Now let’s create the certificate:
cd /etc/openvpn/easy-rsa/2.0
chmod 755 *
source ./vars
./vars
./clean-all
Build CA:
./build-ca
Country Name: may be filled or press enter
State or Province Name: may be filled or press enter
City: may be filled or press enter
Org Name: may be filled or press enter
Org Unit Name: may be filled or press enter
Common Name: your server hostname
Email Address: may be filled or press enter
Build key server:
./build-key-server server
Almost the same with ./build.ca but check the changes and additional
Common Name: server
A challenge password: leave
Optional company name: fill or enter
sign the certificate: y
1 out of 1 certificate requests: y
Build Diffie Hellman (wait a moment until the process finish):
./build-dh
Now create your config file:
touch /etc/openvpn/server.conf
And enter the following:
local 123.123.123.123 #- your_server_ip goes here
port 1194 #- port
proto udp #- protocol
dev tun
tun-mtu 1500
tun-mtu-extra 32
mssfix 1450
ca /etc/openvpn/easy-rsa/2.0/keys/ca.crt
cert /etc/openvpn/easy-rsa/2.0/keys/server.crt
key /etc/openvpn/easy-rsa/2.0/keys/server.key
dh /etc/openvpn/easy-rsa/2.0/keys/dh1024.pem
plugin /usr/share/openvpn/plugin/lib/openvpn-auth-pam.so /etc/pam.d/login
client-cert-not-required
username-as-common-name
server 10.8.0.0 255.255.255.0
push "redirect-gateway def1"
push "dhcp-option DNS 8.8.8.8"
push "dhcp-option DNS 8.8.4.4"
keepalive 5 30
comp-lzo
persist-key
persist-tun
status 1194.log
verb 3
Save it and start OpenVPN:
service openvpn start
Now we need to enable IP forwarding. So open the file /etc/sysctl.conf and set ‘net.ipv4.ip_forward’ to 1.
net.ipv4.ip_forward = 1
To make the changes to sysctl.conf take effect, use the following command.
sysctl -p
Route Iptables:
The rule below will work fine on xen and KVM based VPS’s but for OpenVZ use the OpenVZ iptable rule instead:
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
OpenVZ iptable rules:
iptables -t nat -A POSTROUTING -o venet0 -j SNAT --to-source 123.123.123.123
And
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -j SNAT --to-source 123.123.123.123
Make sure you change 123.123.123.123 to your server IP.
IF you have CSF on the same server you need to open your OpenVPN port (Usually 1194) through the firewall and run the below commands for CSF:
iptables -A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -A FORWARD -s 10.8.0.0/24 -j ACCEPT
iptables -A FORWARD -j REJECT
iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE
iptables -t nat -A POSTROUTING -j SNAT --to-source 123.123.123.123
Then run…
service iptables save
Again – make sure you change 123.123.123.123 to your server IP.
This section explains that your vpn will use PAM to auth people to it (on your system, so local users on your system will auth to openvpn via their user/pass that they use for SSH)
If you are using our FreeRADIUS module for WHMCS then you don’t have to do the below step – otherwise you can create a user as follows:
useradd username -s /bin/false
passwd username
If you wanted to delete a user you would use:
userdel username
This section is the client config file, you can name it whatever.you.want.ovpn, but OP has used 'server.ovpn'
Now create a server.ovpn config file and enter the following:
client
dev tun
proto udp
remote 123.123.123.123 1194 # - Your server IP and OpenVPN Port
resolv-retry infinite
nobind
tun-mtu 1500
tun-mtu-extra 32
mssfix 1450
persist-key
persist-tun
ca ca.crt
auth-user-pass
comp-lzo
verb 3
Make sure you change 123.123.123.123 to your server IP.
If using Windows OpenVPN clients, make sure the path to the 'ca ca.crt' is an absolute path with quotes (for spaces), for my Win7 machine I used
ca "c:\Users\tronik\Personal Documents\ca.crt"
And make sure OpenVPN starts at boot:
chkconfig openvpn on
Download ca.crt file in /etc/openvpn/easy-rsa/2.0/keys/ directory and place it in the same directory as your server.ovpn.
Now download a VPN client and import your config file and enter your username and password created above or if you have already configured OpeVPN Source with the FreeRADIUS plugin, use a username and password created in the radius database.
You can now follow the guide to configure OpenVPN source with FreeRADIUS.

Friday, October 5, 2012

Rebooting quickly in Fedora with kexec

If you're like me and you want to reboot quickly and avoid bios POST or other startup routines, kexec can be used to achieve this by skipping everything before the bootloader.

Install kexec-tools , regenerate your initramfs with dracut (so you can pull in the new bits, if you've never had kexec installed before), and then make a shortcut like this:


[root@tronik-laptop ~]# more readykexec.sh
cmdline=`cat /proc/cmdline` ; krnl=`uname -r` ; kexec -l /boot/vmlinuz-$krnl --i
nitrd=/boot/initramfs-"$krnl".img --reuse-cmdline

You can then run readykexec.sh and reboot to reload your current kernel (or any other kernel you happen to want to use.)

If you don't regenerate with dracut before trying to use kexec you will receive an error in the shell that kexec cannot be found.

Tested this in Fedora 17 and Fedora 18.

Thursday, July 26, 2012

yum couldn't connect to mirrors fedora 17

I couldn't update my Fedora 17 (gnome3) today - luckily it was my own stupid mistake... Oddly enough somehow after a network manager update the toggle to use SOCKS proxy was enabled...
I discovered that by using setting URLGRABBER_DEBUG=1 and running 'yum update' and examining the output there.

I saw yum was trying to use my socks proxy to do its work... which I didn't currently have available on this network. Disabling it for this network did the trick. It'd be nice to have some sort of 'per network' control in network-manager.

Thursday, June 14, 2012

Install Spotify in Fedora (FC17) w/alien from a .deb


In addition to adding 'phonon and qt-x11' the below tutorial worked for me on Fedora Core 17 (fc17)
Glad someone made it easy. Spotify, let me give you my money...but make an RPM/yum repo, thanks:
Steps needed: If you would like to convert the package yourself you can download the latest Spotify version from http://repository.spotify.com/pool/non-free/s/spotify/ and convert it with the alien -r command
There is no installation for Spotify on CentOS, and there are some whacked dependencies which are cumbersome to get around. I tried this on CentOS 6.2

First install Alien (and git):

yum install git make
git clone git://git.kitenet.net/alien
cd alien/
perl Makefile.PL; make; make install

Now download spotify .deb files from:

http://repository.spotify.com/pool/non-free/s/spotify/


Convert and install the Debian/Ubuntu packages:

alien --to-rpm spotify-client-qt*.deb
rpm -Uvh --nodeps spotify-client-qt*.rpm
alien --to-rpm spotify-client*.deb
rpm -Uvh --nodeps spotify-client*.rpm

You're almost done! Now download my magical package of required libraries:
http://dl.dropbox.com/u/17435887/CentOS6/andersx/spotify_libs.tar.gz

Extract these in your home folder. It'll create a directory and a file named (in my case):

/home/andersx/spotify_libs
/home/andersx/spotify.sh

Edit the .sh file so it points to your home directory. In my case:
export LD_LIBRARY_PATH=/home/andersx/spotify_libs

The libraries in spotify_libs were carefully taken from a Ubuntu 10.04 LTS, and in order to NOT mess up your CentOS, use the supplied script to start Spotify without exporting it to your $LD_LIBRARY_PATH when you don't need it.

Of course feel free to put the libraries and launcher script somewhere else.

Happy listening!
:wq

Wednesday, April 6, 2011

Port 88 open on Mac OS X - KDC monitoring daemon

If you enable either File Sharing (AFP or SMB), Mac OS X 10.5.6 will have not only the AFP or SMB ports, but also port TCP/88 open. The daemon on this port is kdcmond(8), which is described as “KDC monitoring daemon – Open Directory Single Sign On”. Most people who are not connected to a Mac OS X Server-based network probably don't need this service.

If you would like to disable this daemon, you need to change the launchd(8) configuration, which is accomplished by this one-liner:

Disable:
sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.kdcmond.plist
Enable:
sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.kdcmond.plist
Note that these commands edit the above files, implying that the effects may be undone by future updates from Apple.

Tuesday, April 5, 2011

Mac OS X VPN and L2TP for Android / iPhone and iPad devices (or others l2tp)

From: http://blog.theilluminatedengineer.com/?p=136
--- Ugh. The link to the original is good, I'll use it as long as its there, but I put this here to keep it just in case the other guys site goes down. Good article, props to the author... I got mine working.

-


Step 1: An Introduction

There are lots and lots of different types of VPN setup and I honestly don’t understand how most of them work. I do know that we will be using the L2TP protocol.

The phone will need 3 things to connect to the VPN server on the mac; a user name, password and a shared secret. The user name and password correspond to an account on the local computer. The shared secret is a code known only to the server and client and is used to secure the connection.

Were going to do a lot of tasks on the command line as the root user so start up the OSX terminal and enter the command:

1
$ sudo -s
and give it your password when it asks.

Step 2: Store a secret key in the OSX Key Chain

The shared key will be stored in the OSX Key Chain, this puts it some place secure rather than storing it in plain text where it can be seen by anyone with access to the box.

Ideally the shared key should be complex and hard to guess. Personally I use a 64 character random hexadecimal key from https://www.grc.com/passwords.htm but you may want to use something a little less awkward to type in.

To store this run the command:
$ sudo security add-generic-password -a com.apple.ppp.l2tp \
-s com.apple.net.racoon -T /usr/sbin/racoon -p "shared key" \
/Library/Keychains/System.keychain
Replace “shared key” with whatever shared key you picked above.

The VPN server is two part. The actual server is called vpnd but there is a second task called racoon. Racoon is, I believe, responsible for setting up the initial connection and handling the security. The “-T” option in the above command gives racoon permission to access the keychain and read the value

Step 3: Configure the VPND service

VPND takes it configuration from a standard plist configuration file. Start up vi (or the editor of your choice) and edit the file:

/Library/Preferences/SystemConfiguration/com.apple.RemoteAccessServers.plist
The file content should be:

{
ActiveServers = ("com.apple.ppp.l2tp");
Servers = {
"com.apple.ppp.l2tp" = {
Addresses = ("XXX.XXX.XXX.XXX");
DNS = {OfferedSearchDomains = (); OfferedServerAddresses = (); };
IPv4 = {
ConfigMethod = Manual;
DestAddressRanges = ("YYY.YYY.YYY.YYY", "ZZZ.ZZZ.ZZZ.ZZZ");
OfferedRouteAddresses = ();
OfferedRouteMasks = ();
OfferedRouteTypes = ();
};
Interface = {SubType = L2TP; Type = PPP; };
L2TP = {
IPSecSharedSecret = "com.apple.ppp.l2tp";
IPSecSharedSecretEncryption = Keychain;
Transport = IPSec;
};
PPP = {
AuthenticatorPlugins = (DSAuth);
AuthenticatorProtocol = (MSCHAP2);
IPCPCompressionVJ = 0;
LCPEchoEnabled = 1;
LCPEchoFailure = 5;
LCPEchoInterval = 60;
VerboseLogging = 1;
DSACLEnabled = 1;
Logfile = "/var/log/ppp/vpnd.log";
};
Server = {
Logfile = "/var/log/ppp/vpnd.log";
MaximumSessions = 128;
VerboseLogging = 1;
};
};
};
}
There are three values above that you need to set for your own network:

Set the value marked XXX.XXX.XXX.XXX to the IP address of the server. If you have more than 1 network interface set it to the one you want the server to listen on (e.g 192.168.2.10).
The values YYY.YYY.YYY.YYY and ZZZ.ZZZ.ZZZ.ZZZ indicate the range of IP addresses the VPN server should assign to clients when they connect. Make sure this range isn’t in use by any other computers or DHCP servers and its big enough for the number of clients you want to connect. (e.g 192.168.2.100 and 192.168.2.120).
It’s important the file has the correct permisions:

chown root:admin \
/Library/Preferences/SystemConfiguration/com.apple.RemoteAccessServers.plist
chmod u+w,a+r,a-x \
/Library/Preferences/SystemConfiguration/com.apple.RemoteAccessServers.plist
Step 4: Set up launchd to start the vpnd service at startup

We need to make sure the vpnd server starts up each time we restart the computer, doing it manually would get boring quickly.

Starting boot tasks is handled on OSX by the launchd service. Create a new plist file using vi (or your editor of choice) at:

/System/Library/LaunchDaemons/com.apple.ppp.l2tp.plist
Put in the following content:




Label
com.apple.ppp.l2tp
ProgramArguments

/usr/sbin/vpnd
-x
-i
com.apple.ppp.l2tp

OnDemand



It’s important the file has the correct permisions:

1
2
chown wheel /System/Library/LaunchDaemons/com.apple.ppp.l2tp.plist
chmod u+w,a+r,a-x /System/Library/LaunchDaemons/com.apple.ppp.l2tp.plist
There is two ways to get this file to read in and the server to start. You can reboot your computer or you can issue the following command:

1
launchctl load /System/Library/LaunchDaemons/com.apple.ppp.l2tp.plist
You should now have a running vpnd fully configured and ready to connect to. We can check this by examining the log files:

1
tail -f /var/log/ppp/vpnd.log
This file should contain lines of the form:

1
2010-05-26 01:38:10 BST Listening for connections...
If it doesn’t your going to need to start doing some debuging. Check the contents of the /var/log/ppp/vpnd.log or /var/log/system.log for useful messages. The comments on the Mac OSX Hints page have a lot of usefull information on things that could go wrong.

Step 5: Configure the Firewall

Make sure that your firewall / router is configured to forward UDP on ports 500, 1701 and 4500 to the server box.

There are so many different routers out there that you’ll need to go read the manual or search online for how to setup your specific brand.

Step 6: Configure the iPhone

If everything above went well you should now have a fully running and secured VPN server that can be accessed from any place on the internet.

To set your iPhone up to use the server go through the following steps:

Open the settings app
Select “General” > “Network” > “VPN”
Add a new VPN configuration
Set the VPN type to L2TP
Configure the following settings:
Description: Anything you want
Server: The IP Address of your server (This is the public address given to you by your internet provider. Depending on your provider this address may change frequently. I recommend setting up a dns alias account with http://www.dyndns.com/ to make this step easier and more robust)
Account: The user name of an account on the server (this can be the one you normally log in as)
RSA SecureID: Off
Password: The password for the account you set above
Secret: The shared secret you picked above (enjoy typing in the 64 character hex key if you used it. It’s worth it!)
Send All Traffic: Yes
Turn the VPN connection on via the switch at the top of the “General” > “Network” > “VPN” page. A switch also appears near the top of the launch screen of the settings application
Once your connected you should see a blue “VPN” icon in the bar at the top of the iPhone screen
Some of these settings could use going over in more detail. The VPN connection uses two levels of protection. The first is a user name and password that can be used to log on to the server machine, you can use your normal user account or create a new one with less permissions. The second is the shared key, which wraps up the entire communication. The longer and more complex your shared key is the harder it will be to break.

The “Send All Traffic” option tells the iPhone to send all traffic over the VPN connection, not just traffic directed at the VPN server. You want this on as it protects all of your traffic to any site by encrypting it and sending it to your VPN server before it then makes it out on to the internet. This makes it almost impossible for someone to monitor what your doing when your on a public WIFI or using 3G. It also has the effect of making your public IP address appear to be that of your home internet connection, in theory this lets you use UK restricted web sites when you’re out of the county (iPlayer etc.), but it may not work if the site uses more than just IP to determine where you are.

If you have any problems check the /var/log/ppp/vpnd.log or /var/log/system.log files for useful messages. The comments on the Mac OSX Hints page have a lot of useful information on things that could go wrong (keep an eye out for the dreaded MD5CHAP error that seemed to plague people on older versions of OSX, though I didn’t see it on 10.6).

Hopefully that’s you now up and running.

Thursday, March 3, 2011

grep, od, and dos2unix - Need to fix some crappy files that won't grep?

Recently I had to write a program to extract about 2500 passwords from a Novell eDirectory. That was all well and good, until I sent said output of file to a user who mangled the format on a Windows Machine. The user opened it in Excel or Notepad (or something...who knows...) and then worked with it, and send it back to me to pull the users they'd left in the file out of the Novell eDirectory.

Well that file wasn't in a format grep liked. How long did it take me to figure that out...quite a while, because there's nothing that looks different about the file to the naked eye (or naked editor.)

After googling and feeling very greptarded, I came upon the solution. I identified that the file I previously had and the file I receieved back had different octal values (man od) - I then used dos2unix to reconvert the file to a format grep would work with... grep really didn't like grepping on the improperly formatted file. Very strange... Simple magic... it worked, and the day was saved.

Aside from that, Novell, Netware, and eDirectory are crap. Unfortunately the place I work is still utilizing several servers that run it. Everything else is switched to Microsoft Windows and Active Directory (and my division which runs UNIX (HP-UX and RHEL))

Friday, November 5, 2010

default SSL enabled in Oracle Internet Application Server 10gr2 ias10gr2

So, if you dont have a directive for "data id="start-mode" value="ssl-enabled"" in your opmn.xml file then any directives in your ssl.conf don't get loaded due to the IfDefine SSL thats in by default the httpd.conf and ssl.conf files.

Thursday, October 21, 2010

Idiots in the industry.


"You can buy 10 idiots to perform the tasks of what 2-3 highly qualified individuals can, IF customers don't care."

Thursday, June 24, 2010

SELinux, Oracle, and RedHat Enterprise Linux revisited...

Ran into some more issues with SELinux and Oracle. We have some libraries stored in another location that are compiled with -fpic -shared (CFLAGS) and the program linking to it wasn't, and neither are any of the other libraries it links to (provided by Oracle... 10gr2 DB software)

SELinux is set to enforcing, but targeted.

So whats the fix...Well you either set all the libraries to a textrelocatable context ala chcon -t texrel_shlib_t /u01/app/oracle/product/10.2/client/lib/*.so

for 64bit. Then, like I ran into with using an external php as it tries to call oracle libraries, you  must set the exec stack... execstack -c /path/to/library.so

Ok, thats one way to do it..
The other is to `setsebool -P allow_execmod=1` to allow execmods across relocatable text...

Thats how I did it...because Oracle can't compile their libraries right, and my DBA was tired of waiting...I'd prefer to not have to do this at all though eh?

Thursday, December 3, 2009

SELinux, Apache and PHP 5.

Recently at work we hired a contractor to come in and do some work.  The department that hired him requested a machine for him. Instead of giving the guy admin access on a CentOS machine, I decided he could run everything in user space.  Thats fine...and I figured I'd duplicate the environment he'd use just so I could make sure it would work.  I don't like to provision machines and give anyone but myself or my system administrators admin access.

The guy wanted PHP5, Apache 2 (I used 2.2), Moodle (Some Courseware php program), and PostgreSQL.

Everything compiled without a hitch (mostly, since I had to look up what all php modules he needed compiled in...also added Suhosin for good measure since who knows what this guy will be doing.)

After fighting a bit with PHP modules I then discovered that SELinux was denying access to libphp5.so in the apache httpd/modules directory.

This was an error : "cannot restore segment prot after reloc: Permission denied" - Of course, disabling SELinux fixed this...but I dont always want to disable SELinux...

Someone suggested running execstack against libphp5.so to enable a flag on the file so SELinux would let Apache load the module...That didn't work.

I'll update this post later with some answers...I hope. For now, I'm leaving the office.

Friday, November 27, 2009

yum rollback feature / rpm rollback feature

Doing some upgrades this week on a production system and don't want anything to break...So, I looked into this.

One of the least-known secrets about rpm is that it can rollback (undo) package changes. It can take a fair bit of storage space to track the information necessary for rollback, but since storage is cheap, it’s worthwhile enabling this feature on most systems.
Here are cut-to-the-chase directions on using this feature:
  1. To configure yum to save rollback information, add the line tsflags=repackage to /etc/yum.conf.
  2. To configure command-line rpm to do the same thing, add the line %_repackage_all_erasures 1 to /etc/rpm/macros.
  3. Install, erase, and update packages to your heart’s content, using pup, pirut, yumex, yum, rpm, and the yum automatic update service.
If/when you want to rollback to a previous state, perform an rpm update with the –rollback option followed by a date/time specification. Some examples: rpm -Uhv –rollback ‘9:00 am’, rpm -Uhv –rollback ‘4 hours ago’, rpm -Uhv –rollback ‘december 25′.

Friday, November 13, 2009

php5 / suhosin extension (not patch) on CentOS or RHEL

Red Hat / CentOS Linux Install Suhosin PHP 5 Protection Security Patch


Q. Wordpress and many other open source application developers asks users to protect PHP apps using Suhosin patch to get protection from the full exploit. Suhosin is an advanced protection system for PHP installations. It was designed to protect your servers from various attacks. How do I install Suhosin under RHEL / CentOS / Fedora Linux?

A. Suhosin was designed to protect your servers against a number of well known problems in PHP applications and on the other hand against potential unknown vulnerabilities within these applications or the PHP core itself including wordpress and many other open source php based apps.

Install Suhosin as extension

Download latest version of Suhosin, enter:
# cd /opt
# wget http://download.suhosin.org/suhosin-0.9.27.tgz

Make sure you have php-devel installed:
# yum install php-devel

Compile Suhosin under PHP 5 and RHEL / CentOS Linux

Type the following commands:
# cd suhosin-0.9.27
# phpize
#./configure
# make
# make install

Configure Suhosin

Type the following command to create Suhosin configuration file:
# echo 'extension=suhosin.so' > /etc/php.d/suhosin.ini

Restart web server

Type the following command to restart httpd:
# service httpd restart
If you are using lighttpd, enter:
# service lighttpd restart

Verify Suhosin installation

Type the following command:
$ php -v
Sample output:
PHP 5.1.6 (cli) (built: Jun 12 2008 05:02:36)
Copyright (c) 1997-2006 The PHP Group
Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies
    with XCache v1.2.2, Copyright (c) 2005-2007, by mOo
    with Suhosin v0.9.27, Copyright (c) 2007, by SektionEins GmbH
You can find more information by running phpinfo():

phpinfo();
?>
Sample output:

Fig.01: Suhosin information and settings displayed by phpinfo().
Fig.01: Suhosin information and settings displayed by phpinfo()

Click here to find out more!

Tuesday, November 3, 2009

setup bridging br0 eth0 on Centos or RHEL for KVM virtual machines

There were several places online I could've visited to help me get bridging going on my system...They all seemed to be written for a home user though.

I recently setup a new CentOS 5.4 workstation on a machine here at work, and have been planning on moving everything over to that from my Mac Management station. Currently using a Macbook Pro as a management station but I'd like to free it up to do other things...

Also I wanted to do some KVM virtualizing because thats how RedHat does it, and thats our vendor...so...

For starters, I needed to let any VM's I created have bridged access to the network... This was probably the most difficult part, because it was just a mixed-bag when it came to how other people had done it. Here's how I did it, and it works for me.

The interface is an Intel gigabit card (wasn't supported until 5.3 out of the box!), so 1 physical interface formerly known as eth0.

`yum install bridge-utils` will install the proper utilities to enable bridging, and should also enable the kernel module on most distros.

I guess the tricky thing is, when you use bridging, you're actually kind of saying "ok bye eth0, we're going to replace you with br0 and then let br0 hand out access to any other interfaces" - This is hard for some people to grasp...

So goto /etc/sysconfig/network-scripts and `cp ifcfg-eth0 ifcfg-br0`

Then edit ifcfg-br0 to contain the following information:
DEVICE=br0
BOOTPROTO=static
ONBOOT=yes
NETMASK=255.255.255.0
IPADDR=x.x.x.x
GATEWAY= x.x.x.1
TYPE=Bridge
USERCTL=no
IPV6INIT=no
PEERDNS=yes



Then edit ifcfg-eth0, it should just have
DEVICE=eth0
ONBOOT=yes
BRIDGE=br0

-
You should then reboot. your main interface will have become br0, and eth0 will just be sitting there...waiting...for something.

Anyway,
You can use brctl show to show the current bridges on your system, and it gets more complicated from there on out.

You can then assign eth0 to virtual machines in the Virt Manager and the vm will use that as its bridge access. ;)

Monday, November 2, 2009

pidgin, otr, and random number generation

on a new centos plus workstation (5.4) i was trying to IM with pidgin and otr with my friends. we use OTR for private communication.

the key generation was failing, hanging actually, strace showed some problem with timeouts and /dev/urandom.

On the advice of someone who ran into the same problem, I used rngd to feed /dev/urandom into /dev/random

rngd -o /dev/urandom -r /dev/random

This worked and key generation completed successfully. Joy.

Wednesday, October 14, 2009

Pam Update, security pam_limits and 64 bit libs

ok, so, you have an x64 server and you updated pam, and you want to use pam_limits - cool story. until you try to login...and you're like, why isn't it working? because you added the line:

session required /lib/security/pam_limits.so

to /etc/pam.d/login

but you CAN login remotely and you check your log files and see 'Module unknown' when someone tries to login locally. This is because you're a 64bit server using a 32bit library...from /lib...so change that line to

session required /lib64/security/pam_limits.so

Then local logins work. =)

Tuesday, October 13, 2009

Updated on SSH Key authentication.

Public key authentication is great, as most of us have known for years, but I'm still in the middle of converting everyone to it who use the systems where I work.  Its actually a pretty big task since so many people do have to connect into our servers in order to get information...and if those accounts cannot connect then...well, stuff starts breaking.

We've done really well and our systems are really stable, of course they're still running HP Unix, but the new systems that are on their way into production are RedHat Linux (RHEL 5), so we have our work cut out for us. No problem -- They seem to be quite resilient and stable.  I wish we could get some Oracle on BSD. Grr.

Anyway, a lot of interesting changes going on in the workplace right now, so, I'll leave those for another time. Just wanted to give a quick update to all the readers out there... I'm still alive. Thanks for your emails.

Friday, September 18, 2009

SSH and SSH Key Pair Authentication instead of Passwords

Well, some of the users where I work were wanting to know what makes key authentication better than password authentication... Its a difficult thing to explain when people are unaware of the advantages of key auth, and the risks of password authentication. I suppose I try to explain it away with "this will actually make it simpler in the case of a compromise" ... So I may post more about this later, but a general reasoning behind this is described well by some PuTTY documentation.

Public key authentication - an introduction

Public key authentication is an alternative means of identifying yourself to a login server, instead of typing a password. It is more secure and more flexible, but more difficult to set up.
In conventional password authentication, you prove you are who you claim to be by proving that you know the correct password. The only way to prove you know the password is to tell the server what you think the password is. This means that if the server has been hacked, or spoofed (see section 2.2), an attacker can learn your password.
Public key authentication solves this problem. You generate a key pair, consisting of a public key (which everybody is allowed to know) and a private key (which you keep secret and do not give to anybody). The private key is able to generate signatures. A signature created using your private key cannot be forged by anybody who does not have that key; but anybody who has your public key can verify that a particular signature is genuine.
So you generate a key pair on your own computer, and you copy the public key to the server. Then, when the server asks you to prove who you are, PuTTY can generate a signature using your private key. The server can verify that signature (since it has your public key) and allow you to log in. Now if the server is hacked or spoofed, the attacker does not gain your private key or password; they only gain one signature. And signatures cannot be re-used, so they have gained nothing.
There is a problem with this: if your private key is stored unprotected on your own computer, then anybody who gains access to that will be able to generate signatures as if they were you. So they will be able to log in to your server under your account. For this reason, your private key is usually encrypted when it is stored on your local machine, using a passphrase of your choice. In order to generate a signature, PuTTY must decrypt the key, so you have to type your passphrase.
This can make public-key authentication less convenient than password authentication: every time you log in to the server, instead of typing a short password, you have to type a longer passphrase. One solution to this is to use an authentication agent, a separate program which holds decrypted private keys and generates signatures on request. PuTTY's authentication agent is called Pageant. When you begin a Windows session, you start Pageant and load your private key into it (typing your passphrase once). For the rest of your session, you can start PuTTY any number of times and Pageant will automatically generate signatures without you having to do anything. When you close your Windows session, Pageant shuts down, without ever having stored your decrypted private key on disk. Many people feel this is a good compromise between security and convenience. See chapter 9 for further details.
There is more than one public-key algorithm available. The most common is RSA, but others exist, notably DSA (otherwise known as DSS), the USA's federal Digital Signature Standard. The key types supported by PuTTY are described in section 8.2.2.