No Love From Google
From 5dollarwhitebox.org Media Wiki
PHP
Reading output from ssh2_exec
I had an issue figuring the best way to read the output of a command run by ssh2_exec:
$stream = ssh2_exec($connection, "ps -aux"); stream_set_blocking( $stream, true ); $cmd_output = fread($stream,4096); fclose($stream);
Function 'parse_str' SegFaults
If you find the function 'parse_str' providing a Segmentation Fault, you may need to disable 'register_globals'. This appears to be a bug in 'parse_str' (Tested for php-4.1.2 on Rhel2.1).
Can't upgrade PEAR
You may have found that when trying to install a PEAR package you receive a dependency error requiring a newer version of PEAR itself OR you can't use simple PEAR commands because as of 1.4.0 PEAR no longer supports the XMLRPC interface. To resolve this, simply give direct URL locations and version/package numbers:
[root@linuxbox ~]# pear upgrade http://pear.php.net/get/PEAR-1.4.3.tar downloading PEAR-1.4.3.tar ... Starting to download PEAR-1.4.3.tar (-1 bytes) .................................done: 1,745,408 bytes requires package `PEAR' >= 1.3.3 PEAR: Dependencies failed
So you have to do the 1.3.3 version first:
[root@ linuxbox ~]# pear upgrade http://pear.php.net/get/PEAR-1.3.3.tar downloading PEAR-1.3.3.tar ... Starting to download PEAR-1.3.3.tar (-1 bytes) .....................................done: 529,408 bytes upgrade ok: PEAR 1.3.3
Then you need to resolve a few deps:
[root@linuxbox ~]# pear upgrade http://pear.php.net/get/Archive_Tar-1.3.1 downloading Archive_Tar-1.3.1.tgz ... Starting to download Archive_Tar-1.3.1.tgz (15,102 bytes) .....done: 15,102 bytes upgrade ok: Archive_Tar 1.3.1
Then upgrading 1.4.3 works:
[root@linuxbox ~]# pear upgrade http://pear.php.net/get/PEAR-1.4.3.tar downloading PEAR-1.4.3.tar ... Starting to download PEAR-1.4.3.tar (-1 bytes) ................................................................................................................................................................done: 1,745,408 bytes Optional dependencies: package `XML_RPC' version >= 1.4.0 is recommended to utilize some features. Installed version is 1.1.0 package `PEAR_Frontend_Web' version >= 0.5.0 is recommended to utilize some features. package `PEAR_Frontend_Gtk' version >= 0.4.0 is recommended to utilize some features. upgrade ok: PEAR 1.4.3
This says PEAR-1.4.3 which is what I use cause its easy to remember ... But that isn’t the latest version... At this point you should be able to do ‘pear upgrade pear’ or even better ‘pear upgrade-all’.
[root@linuxbox ~]# pear upgrade-all Will upgrade db Will upgrade http Will upgrade mail Will upgrade net_smtp Will upgrade net_socket Will upgrade pear Will upgrade xml_parser Will upgrade xml_rpc Did not download optional dependencies: pear/Auth_SASL, use --alldeps to download automatically pear/Net_SMTP can optionally use package "pear/Auth_SASL" downloading DB-1.7.13.tgz ... Starting to download DB-1.7.13.tgz (132,246 bytes) .............................done: 132,246 bytes downloading HTTP-1.4.0.tgz ... Starting to download HTTP-1.4.0.tgz (4,593 bytes) ...done: 4,593 bytes downloading Mail-1.1.14.tgz ... Starting to download Mail-1.1.14.tgz (17,537 bytes) ...done: 17,537 bytes downloading Net_SMTP-1.2.11.tgz ... Starting to download Net_SMTP-1.2.11.tgz (10,385 bytes) ...done: 10,385 bytes downloading Net_Socket-1.0.8.tgz ... Starting to download Net_Socket-1.0.8.tgz (5,441 bytes) ...done: 5,441 bytes downloading PEAR-1.7.1.tgz ... Starting to download PEAR-1.7.1.tgz (302,377 bytes) ...done: 302,377 bytes downloading XML_Parser-1.2.8.tgz ... Starting to download XML_Parser-1.2.8.tgz (13,476 bytes) ...done: 13,476 bytes downloading XML_RPC-1.5.1.tgz ... Starting to download XML_RPC-1.5.1.tgz (32,215 bytes) ...done: 32,215 bytes upgrade-all ok: channel://pear.php.net/PEAR-1.7.1 PEAR: Optional feature webinstaller available (PEAR's web-based installer) PEAR: Optional feature gtkinstaller available (PEAR's PHP-GTK-based installer) PEAR: Optional feature gtk2installer available (PEAR's PHP-GTK2-based installer) upgrade-all ok: channel://pear.php.net/XML_Parser-1.2.8 upgrade-all ok: channel://pear.php.net/XML_RPC-1.5.1 upgrade-all ok: channel://pear.php.net/Net_Socket-1.0.8 upgrade-all ok: channel://pear.php.net/Net_SMTP-1.2.11 upgrade-all ok: channel://pear.php.net/HTTP-1.4.0 upgrade-all ok: channel://pear.php.net/Mail-1.1.14 upgrade-all ok: channel://pear.php.net/DB-1.7.13
Done.
Linux
Bash: Compare Float Variables
Bash isn't the greatest for comparing arithmetic. I found this out when I needed to compare version of software. The fix is to use Awk for the operation:
curVersion='4.1'
newVersion='5.0'
curIsLessThanNew=$(echo "$curVersion $newVersion" | awk '{if ($1 < $2) print "true"}')
echo "'$curIsLessThanNew'"
if [ $curIsLessThanNew ]; then
echo "The current version of the software is older than the newest version.
fi
MySQL: Can't Run Make Test
You might have found that running 'make test' in recent versions of MySQL may fail unexpectedly. For example, in my case the test 'rpl_rotate_logs' would fail for some unknown reason. I found the issue to be that MySQL doesn't want you running 'make test' as the root user.
Resolution? Run 'make test' as a non-root user.
VMWare Server: Can't Start Virtual Machine
Ran into an issue on RedHat Enterprise Linux 4 (though not related) where after installing VMWare Server I was unable to start any Virtual Machines. The error is as follows:
could not mmap 57334 bytes of memory from file offset 0 at (nil): Operation not permitted. Failed to allocate shared memory.
The issue was due to the fact that '/tmp' was mounted with the 'noexec' flag for security reasons. You can either set 'tmpDirectory = /something/not/tmp' or remount '/tmp' with the 'exec' flag.
Reference: http://www.vmware.com/community/thread.jspa?messageID=426725񨋥
Tomcat: LifecycleException: No UserDatabase component found under key UserDatabase
The main error message in $CATALINA_HOME/log/catalina.out was:
LifecycleException: No UserDatabase component found under key UserDatabase
However, the *key* message before that is:
Starting service Tomcat-Standalone
Apache Tomcat/4.1.31
javax.naming.NamingException: /opt/tomcat4-4.1.31/conf/tomcat-users.xml.new (Permission denied)
at org.apache.naming.NamingContext.lookup(NamingContext.java:797)
at org.apache.naming.NamingContext.lookup(NamingContext.java:147)
at org.apache.catalina.realm.UserDatabaseRealm.start(UserDatabaseRealm.java:250)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1126)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:316)
at org.apache.catalina.core.StandardService.start(StandardService.java:450)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:2143)
at org.apache.catalina.startup.Catalina.start(Catalina.java:463)
at org.apache.catalina.startup.Catalina.execute(Catalina.java:350)
at org.apache.catalina.startup.Catalina.process(Catalina.java:129)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:156)
Apparently Tomcat is doing some funny business by creating the file 'tomcat-users.xml.new' upon startup. So obviously, if the user running tomcat doesn't have permissions to the '$CATALINA_HOME/conf' directory, the startup will bork!
Assuming that 'tomcat' is the user running tomcat, do the following:
chown tomcat /path/to/tomcat/conf
Sendmail: Resend messages from /var/spool/clientmqueue
So I had a Postfix box, that somehow got messages into the '/var/spool/clientmqueue' directory (likely because alternatives was jacked). So, this is how to pull the messages from the queue and process them:
/usr/sbin/sendmail.sendmail -L sm-msp-queue -Ac -q30m
RedHat: GCC Errors
Get the following error when doing 'php -v' or other apps the hit gcc libraries
/lib/ssa/libgcc_s.so.1: version `GCC_4.2.0' not found (required by /usr/lib/libstdc++.so.5)
Fix was to move '/lib/ssa/libgcc_s.so.1' out of the way (or what ever the file is that is complaining:
linuxbox /]# mv /lib/ssa/libgcc_s.so.1 /home/user/backup/
Debian: Can not start networking
If you receive the error '/etc/network/run/ifstate' file does not exist, you might be running devfs:
Remove the symlink /etc/network/run -> /dev/network or whatever it links to:
rm /etc/network/run
Create the dir to replace it:
mkdir /etc/network/run
REFERENCE: http://lists.debian.org/debian-devel-changes/2005/04/msg00320.html
ifupdown (0.6.4-4.11) unstable; urgency=low
.
* Non-maintainer upload
* postinst:
+ Do not make /etc/network/run a symlink to /dev/shm/network/
if devfs is in use. (Closes: #266479)
I Have No Name
Came across an interesting problem where a customer couldn't receive mail, and had issues when logging in. The following are the errors:
WHEN LOGGING IN: id: cannot find name for user ID 501 [I have no name!@linuxbox ~]$ SENDMAIL/POSTFIX: And when trying to receive mail: "unknown user:", even though the user did exist in '/etc/passwd'
THE FIX: '/etc/passwd' must be 644 (at least on RedHat, and probably most Linux distros)
MAC
MAC X11 Forwarding Over SSH
This was a pain in my ass, and simple as hell which made it worse:
Install X11.app via the Installation CD (Choose "Other installations") Start X11.app The key is (and I missed this) that you need to initiate the SSH connection from the X11 xterm console and not the Terminal.app SSH -Y user@domain.com
Note: The '-Y' used to be '-X' but has changed recently. Once you start a remote X11 App, it should show up on your local X11.app..
Mac OSX: Re-Read '/etc/hosts'
So I could never figure out how to re-read /etc/hosts. Like, if I changed a value in the file it wouldn't take... due to caching. So, you just run:
lookupd -flushcache
Cisco VPN Client on MAC OSX
I often receive the following error when trying to startup the Cisco VPN on MAC:
Error 51: IPC socket allocation failed with error fffffffffffffffch. This is most likely due to the Cisco Systems, Inc. VPN Service not being started. Please start this service and try again.
I couldn't figure out how to actually start the VPN service.... and now that I finally did, it goes here.
MACBOX]$ sudo /System/Library/StartupItems/CiscoVPN/CiscoVPN stop MACBOX]$ sudo /System/Library/StartupItems/CiscoVPN/CiscoVPN start
