blogs
Using DJB's daemontools and netcat to bounce an incoming request around the world
Submitted by X-Istence on Sat, 2008-11-29 17:56.Lately I have been moving the data from one server to another server, located halfway across the globe, and I needed some way to forward all incoming requests from the old server to the new server. This had to be done so that DNS could take its time in updating while everything was now already being served from the new location.
What I ended up doing was using daemontools along with netcat to pipe the request around the world. Here are the steps I took in doing so:
mkdir /usr/local/redirect/ cd /usr/local/redirect/ mkdir smtp smtp/env cd smtp
Put the following in a file named run:
#!/bin/sh
exec 2>&1 \
envdir ./env \
sh -c '
case "$REMOTENAME" in h) H=;; p) H=p;; *) H=H;; esac
case "$REMOTEINFO" in r) R=;; [0-9]*) R="t$REMOTEINFO";; *) R=R;; esac
exec \
/usr/local/bin/tcpserver \
-vDU"$H$R" \
${LOCALNAME+"-l$LOCALNAME"} \
${BACKLOG+"-b$BACKLOG"} \
${CONCURRENCY+"-c$CONCURRENCY"} \
-- "${IP-0}" "${PORT}" \
/usr/bin/nc "${REMOTEHOST}" "${REMOTEPORT}"
'
Make it executable:
chmod +x run
Then we need to set up a few environment variables:
cd env echo "example.net" > REMOTEHOST echo "25" > REMOTEPORT echo "25" > PORT echo `hostname` > LOCALNAME echo "200" > CONCURRENCY
I made REMOTEPORT and PORT be separate on purpose, in one case I now had more IP's than before, so instead of having SSL running on a separate port it was running on the default port, and I needed a clean way to forward that.
Now just add it to your services folder as a symlink and it will automatically be started, from there it will do it's job! I also suggest adding some simple logging, or discarding all off the output from tcpserver.
Namespace resolution in PHP has changed from :: to \
Submitted by X-Istence on Sun, 2008-10-26 14:11.That is not a typo. The new way that PHP wants you to use namespaces is as follows:
namespace\class
Yeah, that is retarded, but it seems that it was decided over a length IRC discussion with a followup email to PHP internals.
There is already people blogging in protest of this change, which seems utterly backwards. \ is generally used to denote that the character following it has to be escaped, and as it stands and newcomers already have enough trouble as it is understanding the different escape sequences.
:: as the namespace resolution is engrained in my brain, mostly from C++, and \ would not work at all.
There is a wiki page for the "RFC" at http://wiki.php.net/rfc/namespaceseparator. This is going to slowly cause the death and decline of PHP.
In other news I am now looking for a new web programming language that is much like PHP, is able to do FastCGI, and have the FastCGI backend execute files the server hands it, without having something like the long-term running python processes where it is for one single app only.
How many
Submitted by X-Istence on Thu, 2008-10-23 12:12.How many of the people mentioned on this list from MacDailyNews will eat their words? Not many would be my guess. People already have trouble accepting the fact that that the iPhone is here to stay and that they have sold as many as they have.
Lets see if any people outside of the Apple faithful post articles that make the iPhone the great success that they are.
Why all the fragmentation?
Submitted by X-Istence on Sun, 2008-10-19 23:30.This is something that has bothered me about open source in general for a while now, why is that there is so much fragmentation? So many wheels that are being re-implemented for the sake of being re-implemented? I agree that a new file system that supports all the new features of btrFS and ZFS are required, at the same time I don't understand all of this duplication. ZFS has some features that btrFS does not have, and vice-versa, why not spend the time developing a hybrid of the two, thereby massively increasing the usability and stability of both products, or rather, of just one product since the time and effort would only be but into the hybrid.
If it is possible for Nvidia to use binary blobs for their graphics cards, it should be possible to use CDDL code with a compatibility shim in the Linux kernel. All this duplicated effort could instead be focused on one project, thereby having an all around better file system. btrFS has just recently started coming into fruition, would that time not be better spent improving ZFS?
It seems that license issues are the only thing that is causing all of this trouble in the first place. As a user of a system I don't want to spend valuable time testing all the various file systems, I also don't want to have to support all of the different file systems that are available. With a project as large as Linux, and the amount of file systems that are available, how can it be guaranteed that the file system I ultimately go with has been properly bug tested, has had the proper code review done, and is not going to be shoved aside for the next new shiny file system that is introduced? As an end-user (and I hereby don't mean the home user group) I want stability. FreeBSD gives me UFS2, I know I can depend on it, I know it will still exist tomorrow, and I know that it is still being looked at for performance improvements and improvements in general, ZFS has recently been imported and is will exist for a long time. OpenSolaris gives me UFS, and ZFS, I know it is going to be around, I know it is going to be improved. Linux gives me XFS, JFS, ext2, ext3, ext4, ReiserFS, Reiser4, and now btrFS. Depending on my workload and who I ask I get told to use different file systems on Linux. Individually testing each and everyone would be time consuming and error prone, instead of all of these different file systems make one unified file system.
For that reason, and that reason alone I use FreeBSD 7.0 and Solaris 10 on my servers. Stability is a good thing, I need some way to relay to my clients that there is a reasonable time schedule for new releases, that what they are storing their data on right now is going to be around tomorrow, and that it is stable, that it has been time proven and tested. Linux can not provide that at the moment.
Ballmer is delusional
Submitted by X-Istence on Sat, 2008-10-11 14:17.This article at The Mac Observer proves it. Also, as for your mouse choices, let me the first to say that my Microsoft Laser Mouse 6000 works perfectly fine with Mac OS X and all my other devices. It is one of the only mice I have found so far that does exactly what I need it to do. After I forgot mine on a plane last year I even ordered a brand new one.
If Ballmer instead had said that Apple's mice suck and that they are uncomfortable to use I would have fully agreed with him. They after all decided that a mouse shaped like a hockey puck would be a good idea. The Mighty Mouse is an interesting concept, but that is all it should ever have been. Sure the little ball in the middle is an excellent idea, and sometimes I miss it, it gets dirty fast and then it stops working. Sometimes it refuses to register right clicks (there is no physical button for right click, it is sensitive as to which finger is where), middle clicks would sometimes become just standard left clicks. Ugh, it was a mess.
Ballmer, your own company created mice work on the Mac, go out get a Mac and experience it for yourself, and stop spouting crap! Come back when you have some experience underneath your belt!
Facepalm
Submitted by X-Istence on Fri, 2008-10-03 02:38.The past few days I have been working on some bits and pieces of code, and I facepalmed myself at 0226 in the morning. I opened up an older part of the project, and I had totally forgotten I had written a config parser. It opens up, and it is scrolled half way down the page, so I don't see my Copyright tag on it at the top.
I look it over a few lines, and suddenly I say to myself:
"Wow, that is an interesting way of accomplishing that. I would have never thought of that"
"Interesting trick"
"Written with security in mind"
"Line counting, and even tells the user what error it has encountered!"
Wanting to know who wrote this code, figuring it was someone I was working with at the time, I read the copyright:
* Copyright 2006 Bert JW Regeer. All rights reserved.
Yeah, facepalm. Anyway, luckily I do remember why I was writing it, and I wrote down in the sample config file what the config parser is supposed to parse, so I know that it parses stuff like this:
# <sub-system name> {
# id: <number>; # Any number that is not taken
# program: bin/something; # Full path, or take workingdir/. So /usr/local/bin/something in this example.
# arguments: -user xistence; # Pass an arbitrary amount of arguments to the program to be executed
# env: SPECIALSAUCE=yes,MAYO=no; # Pass environment variables to the executing program.
# } The config system is there to allow different programs to be run by the daemon depending on user input. So for example, this would be a valid sub-system:
adduser {
id: 10
program: bin/specialadduser
arguments: --skel=/usr/local/skel
}Anyway, I was pretty damn impressed with my own code from 2 years ago. Now that I have looked at it again, I remember writing it while I was bored during my summer vacation. That same summer vacation I wrote my own regex library, which sadly I have removed from existence, since it was too complicated to maintain. It was however able to do some of the following:
(a*) to look for a followed by any characters, and store it.
a+ to look for 1 or more occurrences of a.
(.*) { (.*) } would also work, it would store whatever it found before a " {" in an array as position 0, and then whatever was in the curly braces in array position 1. It is probably for the best that the code is gone, but it was an interesting exercise none the less. I even remember sending Geffy a text message asking him to look up function pointers for me since I was away from the Internet!
Maybe later I will post more information. I am heading back to my other code, it is nowhere near finished!
PHP 5.2.6 on FreeBSD with extensions
Submitted by X-Istence on Mon, 2008-09-15 04:30.There seems to be an issue in PHP 5.2.6 with extensions where the extensions have to be loaded in a certain order or the PHP interpreter has a tendency to crash and fail miserably. It is weird, as depending on the system configuration the order of the extensions has to be entirely different.
Certain extensions have a dependency on other extensions and their functionality so it is understandable that they are required to be loaded before the other modules can be loaded, however this has never been an issue before. I am not entirely sure how PHP does it, but I am betting it loads all the modules and then runs an init function of sort, and since all the modules are loaded at the same time, there are no issues.
However, in this case it seems that multiple functions are clashing, or something along those lines.
Running PHP in a gdb session showed the following:
Program received signal SIGSEGV, Segmentation fault. 0x00000000 in ?? () (gdb) bt #0 0x00000000 in ?? () #1 0x29803544 in __do_global_dtors_aux () from /usr/local/lib/php/20060613/simplexml.so #2 0x29807c04 in _fini () from /usr/local/lib/php/20060613/simplexml.so #3 0x2824f558 in tls_dtv_generation () from /libexec/ld-elf.so.1 #4 0x28251558 in ?? () from /libexec/ld-elf.so.1 #5 0xbfbfe9c8 in ?? () #6 0x282327b6 in elf_hash () from /libexec/ld-elf.so.1 #7 0x282350a0 in dlclose () from /libexec/ld-elf.so.1 #8 0x081374e4 in zend_hash_apply_deleter () #9 0x0813757f in zend_hash_graceful_reverse_destroy () #10 0x0812da7c in zend_shutdown () #11 0x080f4f67 in php_module_shutdown () #12 0x081aa892 in main ()
So it seems that simplexml is the culprit here, lets remove it. Once removed from extensions.ini we re-run gdb and give it the same information we gave it before, this time however we see this:
Cannot load module 'SPL' because required module 'simplexml' is not loaded in Unknown on line 0
My gut instinct is to now move simplexml ABOVE the line that says extension=spl.so. After we do this, PHP is able to run without any issues. Now, for the fun:
extension=spl.so extension=xml.so extension=ctype.so extension=zlib.so extension=session.so extension=mbstring.so extension=pdo.so extension=pdo_sqlite.so extension=ftp.so extension=posix.so extension=pcre.so extension=json.so extension=zip.so extension=suhosin.so extension=pdo_mysql.so extension=bz2.so extension=openssl.so extension=gd.so extension=pdf.so extension=hash.so extension=mhash.so extension=curl.so extension=mcrypt.so extension=xmlwriter.so extension=tokenizer.so extension=filter.so extension=simplexml.so extension=iconv.so extension=sqlite.so extension=dom.so extension=xmlreader.so extension=gettext.so extension=tidy.so extension=mysqli.so extension=mysql.so extension=sockets.so extension=pspell.so extension=imap.so extension=ncurses.so extension=xsl.so
Is the extension list on one of the servers I administrate. Notice that spl.so is at the top of the file, and simplexml.so is somewhere in the middle. And this works perfectly, however the same file on a second server causes it to bomb spectacularly. However, I had kept a backup of the original extensions.ini on the second server, put it back, and then experimented with it, and this is what came out:
extension=simplexml.so extension=spl.so extension=suhosin.so extension=json.so extension=zip.so extension=filter.so extension=hash.so extension=session.so extension=sysvmsg.so extension=gd.so extension=pdf.so extension=tidy.so extension=magickwand.so extension=odbc.so extension=calendar.so extension=sysvshm.so extension=soap.so extension=tokenizer.so extension=mcrypt.so extension=iconv.so extension=readline.so extension=sysvsem.so extension=bz2.so extension=zlib.so extension=ftp.so extension=pcntl.so extension=ncurses.so extension=posix.so extension=gettext.so extension=mhash.so extension=pcre.so extension=mbstring.so extension=xmlwriter.so extension=xml.so extension=xmlrpc.so extension=sqlite.so extension=openssl.so extension=ctype.so extension=ming.so extension=dom.so extension=xmlreader.so extension=curl.so extension=mysqli.so extension=mysql.so extension=sockets.so extension=imap.so extension=xsl.so
Now when I tried this on the first system where that first configuration file comes from, it bombs spectacularly leaving a core-dump. I have NO IDEA what is going on. I just know that log messages like the following:
pid 54662 (php-cgi), uid 80: exited on signal 11 (core dumped) pid 54655 (php-cgi), uid 80: exited on signal 11 (core dumped) pid 54658 (php-cgi), uid 80: exited on signal 11 (core dumped) pid 54661 (php-cgi), uid 80: exited on signal 11 (core dumped) pid 54660 (php-cgi), uid 80: exited on signal 11 (core dumped)
are a thing of the past, until next time when I upgrade or re-compile PHP and the order is played with again.
If you have any hints, insights or knowledge of what is going on, and what magic order I have to place the extensions in, please let me know by sending me an email at xistence@gmail. This is going to be a mystery, for now, as I definitely don't have the time to figure out what is going on and why.
One more thing ... Near Space launch went off without a hitch
Submitted by X-Istence on Sat, 2008-09-13 02:01.The near space launch went off without a hitch. We launched it at 0640 in the morning and recovered it a few hours later. To see the path the balloon took, please visit the Near Space CONNERY-1 page.
Yes, we really did name our first balloon flight ever CONNERY-1, read the Wiki page for information as to why :-P.