<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
   <channel>
      <title>Braindump</title>
      <link>http://WWW.MARIOSPINA.COM/braindump/</link>
      <description></description>
      <language>fr</language>
      <copyright>Copyright 2010</copyright>
      <lastBuildDate>Mon, 27 Oct 2008 13:48:56 -0500</lastBuildDate>
      <generator>http://www.sixapart.com/movabletype/?v=3.2</generator>
      <docs>http://blogs.law.harvard.edu/tech/rss</docs> 

            <item>
         <title>sh-agent on Mac OS X 10.5 (Leopard)</title>
         <description><![CDATA[<p>I’ve previously written about <span class="caps">SSH </span>and ssh-agent on Mac OS X where I mentioned a utility named <span class="caps">SSHK</span>eychain that helps manage the agent daemon and your passphrases. Well, Mac OS X 10.5 (Leopard) has been released since that post, and things have changed. The long and the short of it is that ssh-agent is handled much better than before, by default. But its usage can also be a bit confusing (at least it was for me). I’ll try and explain how it all works in Leopard, so you can get the most out of it.</p>

<p>Why Use a Passphrase, Reprisal</p>

<p>I read a rebuttal or two to my previous post, where I mentioned that using a passphrase protects your private key, if someone gains access to your account. Their main argument was that if your system gets hacked, then the bad guy has complete access to your machine and you’re screwed anyways. True, if someone gets root on your machine, the game is pretty much over. As root, they can do really nasty things like steal ssh-agent identities and install key loggers to snoop your passphrase.</p>

<p>The problem is that root exploits are not the only way to get hacked. What if a bug in a web browser’s Javascript exposes local filesystem access? A nasty web page could read your private key file (~/.ssh/id_rsa), and post it to a website, for example. Or what if you accidentally left your laptop unattended (and unlocked) for a few minutes at the coffee shop? Someone could grab the private key file and stick it on a <span class="caps">USB </span>drive. If the attacker was even half way smart, they’d grab ~/.ssh/known_hosts along with your key, since that contains host names you’ve connected to.</p>

<p>Without a passphrase, your private key is completely usable to the bad guy. Using a passphrase encrypts your private key, so that they would have to crack your passphrase to get access to it. In summary, an empty passprhase on your private key is a bad idea. It’s just asking for trouble.</p>

<p>The Über-server</p>

<p>Okay, back to the topic at hand: ssh-agent on Leopard. One of the benefits of <span class="caps">SSHK</span>eychain (or one of the other ssh-agent apps for OS X) is that it starts ssh-agent at login time. It also sets the <span class="caps">SSH</span>_AUTH_SOCK environment variable (which points to a Unix domain socket) to be accessible by all apps (usually by modifying ~/.MacOSX/environment.plist). Leopard gives you the equivalent of this, out of the box. Open up a terminal and see:</p>

<p>% echo $SSH_AUTH_SOCK <br />
/tmp/launch-nZRFjA/Listeners<br />
While this environment variable is automatically set for all processes, this is a little deceiving. ssh-agent does not actually get started when you log in. Go ahead and see for you self, by running this command right after you login:</p>

<p>% ps xa | grep ssh-agent | grep -v grep<br />
You should get nothing back. It turns out that ssh-agent gets started on demand, the first time something tries to connect to the socket:</p>

<p><span>ps xa | grep ssh-agent | grep -v grep</span> ssh-add -l<br />
The agent has no identities.<br />
% ps xa | grep ssh-agent | grep -v grep<br />
10877   ??  S      0:00.02 /usr/bin/ssh-agent -l<br />
The ssh-add -l tried to connect to the socket, and thus caused ssh-agent to launch. Pretty nifty.</p>

<p>But how can the <span class="caps">SSH</span>_AUTH_SOCK be valid without ssh-agent? The magic sauce is launchd. launchd was introduced in Mac OS X 10.4 as a replacement for many traditional Unix daemons such as cron, xinetd, and init. Since (x)inetd is known as a super-server, and launchd replaces xinted plus a few other daemons, I like calling launchd an über-server. In this context, launchd creates the Unix domain socket and listens for connections, on behalf of ssh-agent. When something connects, it automatically launches ssh-agent. Since launchd is always running, it can listen for connections right after you login.</p>

<p>For the curious, this is done with the new SecureSocketWithKey plist key for launchd. From launchd.plist(5):</p>

<p>This optional key is a variant of SockPathName. Instead of binding to a known path, a securely generated socket is created and the path is assigned to the environment variable that is inherited by all jobs spawned by launchd.</p>

<p>Rock! The launchd plist file for ssh-agent is at:</p>

<p>/System/Library/LaunchAgents/org.openbsd.ssh-agent.plist<br />
The benefit of this lazy launching is that ssh-agent is only run if you use ssh. If you never use ssh, the agent never gets launched, and you don’t waste any resources running it.</p>

<p>Keychain Integration</p>

<p>But the awesomeness doesn’t stop there. If you have an <span class="caps">SSH </span>key and try to connect to a server, you’ll get this nifty dialog box asking for your passphrase:</p>



<p>The first benefit of this dialog box is that it uses a secure text field for your passphrase. This field is not copiable and not snoopable via universal access or low-level keyboard routines. The real benefit, though, is the second checkbox: “Remember password in my keychain.” While it does store the passphrase in your keychain, it actually does more than that. It also adds the identity to your ssh-agent for you:</p>

<p><span>ssh-add -l<br /><br />
The agent has no identities.</span> ssh dave@example.com<br />
... Type passphrase and check "Remember in my keychain" ...<br />
example.com&gt; exit<br />
Connection to example.com closed.<br />
% ssh-add -l<br />
2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx /Users/dave/.ssh/id_rsa (RSA)<br />
By adding your identity to the agent, you can now log right back into the same machine, without typing any passphrase. However, ssh does not prompt for you passphrase because it gets it from the agent, not your keychain. Remove your identity from the agent, and try again:</p>

<p><span>ssh-add -D<br /><br />
All identities removed.</span> ssh dave@example.com<br />
You’ll get that same <span class="caps">GUI </span>dialog box again. But it stores your passphrase in your keychain, right? Then why is it asking for your passphrase if it’s in your keychain? And, why would it store the passphrase in your keychain if it’s not going to actually use it? I know I was scratching my head at this point. Well, it does use the keychain, just not how you may think.</p>

<p>It turns at that when ssh-agent is started, it automatically adds all identities that have passphrases stored your keychain. So the normal workflow, where identities are not removed from the agent, just works. Since the <span class="caps">GUI </span>dialog box added your identity to the agent when it added the passphrase to your keychain, you don’t need enter your passphrase again for the rest of that login session. For all future sessions, the identity is automatically added when ssh-agent starts. And remember from above, that ssh-agent starts on demand, only when needed. Thus, you only enter your passphrase once, and from then on it grabs it from the keychain.</p>

<p>Manually Adding Identities</p>

<p>If you do want to remove your identities, you can manually add all the identities from the keychain with the Apple-specific -k option on ssh-add. From ssh-add(1):</p>

<p>Add identities to the agent using any passphrases stored in your keychain.</p>

<p>Sweet! Let’s try it out:</p>

<p><span>ssh-add -D<br /><br />
All identities removed.</span> ssh-add -l<br />
The agent has no identities.<br />
<span>ssh-add -k<br /><br />
Added keychain identities.</span> ssh-add -l<br />
2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx /Users/dave/.ssh/id_rsa (RSA)<br />
Beware, the passphrase dialog box is not a <span class="caps">GUI </span>version of <span class="caps">SSH</span>_ASKPASS, though. Try adding identities without consulting the keychain, and you’ll still get prompted in the terminal:</p>

<p><span>ssh-add -D<br /><br />
All identities removed.</span> ssh-add <br />
Enter passphrase for /Users/dave/.ssh/id_rsa: <br />
And that covers it. I’m a little too paranoid to use this default behavior, though, as I don’t want my passphrase to be stored in my login keychain. Thus, I’ve written a follow-up article that discusses possible ways to beef up security of your passphrase</p>]]></description>
         <link>http://WWW.MARIOSPINA.COM/braindump/archives/2008/10/27/shagent_on_mac_os_x_105_leopard.php</link>
         <guid>http://WWW.MARIOSPINA.COM/braindump/archives/2008/10/27/shagent_on_mac_os_x_105_leopard.php</guid>
         <category>OSX</category>
         <pubDate>Mon, 27 Oct 2008 13:48:56 -0500</pubDate>
      </item>
            <item>
         <title>Netstat digging</title>
         <description><![CDATA[<p>netstat command and shell pipe feature can be used to dig out more information about particular IP address connection. You can find out total established connections, closing connection, <span class="caps">SYN </span>and <span class="caps">FIN </span>bits and much more. You can also display summary statistics for each protocol using netstat.</p>

This is useful to find out if your server is under attack or not. You can also list abusive IP address using this method.<br />
<blockquote># netstat -nat | awk '{print $6}' | sort | uniq -c | sort -n</blockquote>
Output:

<blockquote>      1 <span class="caps">CLOSE</span>_WAIT
      1 established)<br />
      1 Foreign<br />
      3 <span class="caps">FIN</span>_WAIT1<br />
      3 <span class="caps">LAST</span>_ACK<br />
     13 <span class="caps">ESTABLISHED</span><br />
     17 <span class="caps">LISTEN</span><br />
    154 <span class="caps">FIN</span>_WAIT2<br />
    327 <span class="caps">TIME</span>_WAIT<br />
</blockquote>
Dig out more information about a specific ip address:<br />
<blockquote># netstat -nat |grep {IP-address} | awk '{print $6}' | sort | uniq -c | sort -n</blockquote>

<blockquote>      2 <span class="caps">LAST</span>_ACK
      2 <span class="caps">LISTEN</span><br />
      4 <span class="caps">FIN</span>_WAIT1<br />
     14 <span class="caps">ESTABLISHED</span><br />
     91 <span class="caps">TIME</span>_WAIT<br />
    130 <span class="caps">FIN</span>_WAIT2<br />
</blockquote>
Busy server can give out more information:<br />
<blockquote># netstat -nat |grep 202.54.1.10 | awk '{print $6}' | sort | uniq -c | sort -n</blockquote>
Output:

<blockquote>  15 <span class="caps">CLOSE</span>_WAIT
  37 <span class="caps">LAST</span>_ACK<br />
  64 <span class="caps">FIN</span>_WAIT_1<br />
  65 <span class="caps">FIN</span>_WAIT_2<br />
1251 <span class="caps">TIME</span>_WAIT<br />
3597 <span class="caps">SYN</span>_SENT<br />
5124 <span class="caps">ESTABLISHED</span><br />
</blockquote>
Get List Of All Unique IP Address

To print list of all unique IP address connected to server, enter:<br />
<blockquote># netstat -nat | awk '{ print $5}' | cut -d: -f1 | sed -e '/^$/d' | uniq
</blockquote>To print total of all unique IP address, enter:
<blockquote># netstat -nat | awk '{ print $5}' | cut -d: -f1 | sed -e '/^$/d' | uniq | wc -l</blockquote>
Output:

<blockquote>449
</blockquote>
Find Out If Box is Under DoS Attack or Not

If you think your Linux box is under attack, print out a list of open connections on your box and sorts them by according to IP address, enter:<br />
<blockquote># netstat -atun | awk '{print $5}' | cut -d: -f1 | sed -e '/^$/d' |sort | uniq -c | sort -n</blockquote>
Output:

<blockquote>    1 10.0.77.52
      2 10.1.11.3<br />
      4 12.109.42.21<br />
      6 12.191.136.3<br />
.....<br />
...<br />
....<br />
    13 202.155.209.202<br />
     18 208.67.222.222<br />
     28 0.0.0.0<br />
    233 127.0.0.1<br />
</blockquote>
You can simply block all abusive IPs using iptables or just null route them.<br />
Get Live View of <span class="caps">TCP</span> Connections

<p>You can use tcptrack command to display the status of <span class="caps">TCP </span>connections that it sees on a given network interface. tcptrack monitors their state and displays information such as state, source/destination addresses and bandwidth usage in a sorted, updated list very much like the top command.<br />
Display Summary Statistics for Each Protocol</p>

Simply use netstat -s:<br />
<blockquote># netstat -s | less
# netstat -t -s | less<br />
# netstat -u -s | less<br />
# netstat -w -s | less<br />
# netstat -s<br />
</blockquote>Output:

Ip:<br />
<blockquote>    88354557 total packets received
    0 forwarded<br />
    0 incoming packets discarded<br />
    88104061 incoming packets delivered<br />
    96037391 requests sent out<br />
    13 outgoing packets dropped<br />
    66 fragments dropped after timeout<br />
    295 reassemblies required<br />
    106 packets reassembled ok<br />
    66 packet reassembles failed<br />
    34 fragments failed<br />
</blockquote>Icmp:
<blockquote>    18108 <span class="caps">ICMP </span>messages received
    58 input <span class="caps">ICMP </span>message failed.<br />
    <span class="caps">ICMP </span>input histogram:<br />
        destination unreachable: 7173<br />
        timeout in transit: 472<br />
        redirects: 353<br />
        echo requests: 10096<br />
    28977 <span class="caps">ICMP </span>messages sent<br />
    0 <span class="caps">ICMP </span>messages failed<br />
    <span class="caps">ICMP </span>output histogram:<br />
        destination unreachable: 18881<br />
        echo replies: 10096<br />
</blockquote>Tcp:
<blockquote>    1202226 active connections openings
    2706802 passive connection openings<br />
    7394 failed connection attempts<br />
    47018 connection resets received<br />
    23 connections established<br />
    87975383 segments received<br />
    95235730 segments send out<br />
    681174 segments retransmited<br />
    2044 bad segments received.<br />
    80805 resets sent<br />
</blockquote>Udp:
<blockquote>    92689 packets received
    14611 packets to unknown port received.<br />
    0 packet receive errors<br />
    96755 packets sent<br />
</blockquote>TcpExt:
<blockquote>    48452 invalid <span class="caps">SYN </span>cookies received
    7357 resets received for embryonic <span class="caps">SYN</span>_RECV sockets<br />
    43 <span class="caps">ICMP </span>packets dropped because they were out-of-window<br />
    5 <span class="caps">ICMP </span>packets dropped because socket was locked<br />
    2672073 <span class="caps">TCP </span>sockets finished time wait in fast timer<br />
    441 time wait sockets recycled by time stamp<br />
    368562 delayed acks sent<br />
    430 delayed acks further delayed because of locked socket<br />
    Quick ack mode was activated 36127 times<br />
    32318597 packets directly queued to recvmsg prequeue.<br />
    741479256 packets directly received from backlog<br />
    1502338990 packets directly received from prequeue<br />
    18343750 packets header predicted<br />
    10220683 packets header predicted and directly queued to user<br />
    17516622 acknowledgments not containing data received<br />
    36549771 predicted acknowledgments<br />
    102672 times recovered from packet loss due to fast retransmit<br />
    Detected reordering 1596 times using reno fast retransmit<br />
    Detected reordering 1 times using time stamp<br />
    8 congestion windows fully recovered<br />
    32 congestion windows partially recovered using Hoe heuristic<br />
    19 congestion windows recovered after partial ack<br />
    0 <span class="caps">TCP </span>data loss events<br />
    39951 timeouts after reno fast retransmit<br />
    29653 timeouts in loss state<br />
    197005 fast retransmits<br />
    186937 retransmits in slow start<br />
    131433 other <span class="caps">TCP </span>timeouts<br />
    <span class="caps">TCPR</span>enoRecoveryFail: 20217<br />
    147 times receiver scheduled too late for direct processing<br />
    29010 connections reset due to unexpected data<br />
    365 connections reset due to early user close<br />
    6979 connections aborted due to timeout<br />
</blockquote>
Display Interface Table

You can easily display dropped and total transmitted packets with netstat for eth0:<br />
<blockquote># netstat --interfaces=eth0</blockquote>
Output:

<blockquote>Kernel Interface table
Iface       <span class="caps">MTU</span> Met    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg<br />
eth0       1500   0  2040929      0      0      0  3850539      0      0      0 <span class="caps">BMRU</span><br />
</blockquote>]]></description>
         <link>http://WWW.MARIOSPINA.COM/braindump/archives/2008/09/02/netstat_digging.php</link>
         <guid>http://WWW.MARIOSPINA.COM/braindump/archives/2008/09/02/netstat_digging.php</guid>
         <category>Bash</category>
         <pubDate>Tue, 02 Sep 2008 11:59:27 -0500</pubDate>
      </item>
            <item>
         <title>Track network connections with LSOF on Linux</title>
         <description><![CDATA[<p>LiSt Open Files (LSOF) is a Linux utility that allows you to view current network connections and the files associated with them.</p>

<p><span class="caps">LSOF </span>provides verbose output and is useful in tracking down all sorts of information. For example, it allows you to see what program is operating on an open port, which daemons have established connections, and what ports are open on your server.</p>

<p>While similar in many ways to utilities like netstat and fuser, <span class="caps">LSOF </span>has many unique options that let you find specific information on ports, users, processes, and files.</p>

<p>Getting and installing <span class="caps">LSOF</span></p>

<p>On many Linux systems, <span class="caps">LSOF </span>will be installed by default. Try running lsof -v to see whether the program exists on your system. If it doesn't, you will need to download one of the many packages available and install it yourself. Source and binary versions are available here, while distribution-specific packages are available from locations such as Rpmfind.net and are included in databases for apt-get, up2date, and urpmi.</p>

<p>If you are installing from source, download the tarball and perform these commands:</p>

<p>    tar xpfz lsof_4.64.tar.gz<br />
    cd lsof_4.64<br />
    tar xpf lsof_4.64_src.tar<br />
    cd lsof_4.64_src<br />
    ./Configure linux make </p>

<p>During the configuration, you have the option of running an inventory to verify that all the files necessary for compilation are present. You will be asked if you want to customise the installation. This shouldn't be necessary on most Linux platforms, so answering no is fine. If you encounter any problems running <span class="caps">LSOF </span>later, you may want to come back and try some customisation. Customisation may also be needed if you upgrade or modify your kernel.</p>

<p>After running make, the executable lsof should appear in the directory. There is no default make install rule, so you can create your own or just copy lsof to your directory of choice. Keep in mind that you may need to modify its permissions to be setuid-root if you want regular users to be able to see all open files. Not that this is necessarily recommended, but it's good to remember, since the output generated when <span class="caps">LSOF </span>is run as root will be different from the output generated when it's run by a normal user account.</p>

<p>Looking at network connections</p>

<p>As its name indicates, <span class="caps">LSOF </span>deals with open files on a Linux system. An open file can be a regular file, a directory, a library, a stream, or a network socket. You can take advantage of various <span class="caps">LSOF </span>options, depending on what you're looking for.</p>

<p>Running lsof by itself will output all open files corresponding to every active process on the box. This can be quite lengthy, so it's best to know what you are looking for in advance. You can get a quick rundown of the options with lsof -h, and the man page goes into much further detail. Let's take a look at some common switches and what they will show us.</p>

<p>lsof -i</p>

<p>The lsof -i command lists all open files associated with Internet connections. It is similar in format to netstat -a -p and will look something like Listing A.</p>

<p>By default, <span class="caps">LSOF </span>lists detailed information about each connection. In Listing A, we see the command or program involved, the process ID (PID), the user running the command, the file descriptor (FD), the type of connection, the device number, the Internet protocol, and the name of the file or Internet address. The -i option can be useful when you're attempting to secure your Linux box. You can quickly determine what ports are open and listening for incoming connections. <span class="caps">LSOF </span>will also associate them with a program name. Thus, you can quickly identify unnecessary security risks and shut them down.</p>

<p>Ports that are awaiting connections have the keyword <span class="caps">LISTEN </span>appended to them. These are ports that are open and accepting connections. Note that <span class="caps">LSOF </span>will not distinguish between ports that are completely open and ones that have filters applied. The keyword <span class="caps">ESTABLISHED </span>indicates that a connection on the given port has been made. In Listing A, there is an <span class="caps">SSH </span>session from labrat.remote.net to test.com. You can see multiple processes associated with the sshd daemon. The main daemon, <span class="caps">PID</span> 597, handles incoming requests and forks itself as needed. <span class="caps">PID</span> 8545 was spawned by sshd and is responsible for the 8547 process. The only noticeable difference between 8545 and 8547, besides the <span class="caps">PID, </span>is in the user field. Notice that lhutz is the user who has remotely logged in to this box. This is useful information that goes beyond merely presenting network connections.</p>

<p>You can narrow your search by specifying a particular port, service, or host name using techniques such as:</p>

<p>    lsof -i :587<br />
    lsof -i :smtp<br />
    lsof -i @labrat.remote.net </p>

<p><span class="caps">LSOF </span>will then output all matching connections. The above examples will list connections listening or established on port 587, list connections associated with the well-known service <span class="caps">SMTP, </span>and list connections coming from or going to the host labrat.remote.net, respectively. These techniques are handy if you know what you are looking for in advance. You can watch and see whether inbound <span class="caps">SMTP </span>connections are taking too long, possibly causing timeouts. You can verify that the service is in fact running and what port it is listening on. And you can see if anyone from a certain device is connected to your system, whether it is via <span class="caps">SSH,</span> Telnet, <span class="caps">FTP, </span>or just about any other way possible.</p>

<p>lsof -p 409</p>

<p><span class="caps">LSOF </span>will also accept a <span class="caps">PID </span>and output all open files it is using. In this particular instance, we performed an lsof -I to determine what <span class="caps">PID </span>number NameD (BIND <span class="caps">DNS </span>service) was operating under. Once we discovered it was 409, we issued the command lsof -p 409. The output is shown in Listing B.</p>

<p>You'll notice the different FDs, or file descriptors, right away. The cwd variable represents the current working directory of the process; txt defines the program text, which is the executable itself; mem is a file held in memory, in this case a library; the 4 and 21 represent files in use by this particular process; and the u designator defines them as having both read and write access. These all help you determine whether something physically exists on the system, is being used by the process, or is being held in memory.</p>

<p>lsof +d</p>

<p>The command lsof +d /var/log/apache/ is similar to fuser. It basically associates open files with their processes. In this case, we are looking at all regular files in the /var/log/apache/ directory. The output would look something like Listing C. In this example, Apache is keeping track of two sets of log files, an access and an error log for two domains. As you can see, there are some differences between regular files and Internet connections. For one thing, the <span class="caps">TYPE </span>is now <span class="caps">REG, </span>indicating a regular file. Also, a <span class="caps">SIZE </span>variable is present, which indicates the actual size in bits the file takes up. Notice too that the <span class="caps">DEV </span>variable indicates they all use the same device, in this example, a single hard drive. The +d flag that was issued with <span class="caps">LSOF </span>tells the command not to leave the top-level directory, while +D would perform a recursive check on all subdirectories.</p>

<p>lsof -F &lt;...&gt;</p>

<p>The -F switch provides an excellent way to format <span class="caps">LSOF </span>output. This built-in feature allows you to pipe information directly into external programs, such as a Perl script, a C program, or even a monitoring program like <span class="caps">MRTG.</span> You do this by specifying which fields you would like printed. For example, lsof -F pcfn would print the process <span class="caps">ID, </span>the command name, the file descriptor, and the filename. Many options are available, and this can save you time in working with the raw data yourself.</p>

<p>We've covered just a few of the options <span class="caps">LSOF </span>provides, but the man page covers the full spectrum of <span class="caps">LSOF </span>capabilities. Some <span class="caps">LSOF </span>commands may be processor intensive, due to the sheer number of processes on a system, so be as selective as possible when running commands.</p>

<p>Summary</p>

<p><span class="caps">LSOF </span>is an excellent utility for managing and tracking network connections on your Linux system. Although a number of utilities can perform similar functions, none is quite as robust as <span class="caps">LSOF.</span> With <span class="caps">LSOF, </span>you can list open ports, identify connections currently being made to your system, and determine what resources a process is using. Not only that, but you can also determine what processes a particular user has and find detailed information about file and directory usage. </p>]]></description>
         <link>http://WWW.MARIOSPINA.COM/braindump/archives/2008/09/02/track_network_connections_with_lsof_on_linux.php</link>
         <guid>http://WWW.MARIOSPINA.COM/braindump/archives/2008/09/02/track_network_connections_with_lsof_on_linux.php</guid>
         <category>Linux</category>
         <pubDate>Tue, 02 Sep 2008 11:56:21 -0500</pubDate>
      </item>
            <item>
         <title>Plesk 8.3 - Ruby package (gem update)</title>
         <description>The package included with Plesk 8.3 (on linux) does not include RDoc. If you try to update gem using the command: gem update --system... the installation will exit with an error. You need to install ruby-rdoc (using yum install ruby-rdoc) and its dependencies before re-running gem update --system. Then it will update Rails and all the other gem to their latest versions. 


</description>
         <link>http://WWW.MARIOSPINA.COM/braindump/archives/2008/02/22/plesk_83_ruby_package_gem_update.php</link>
         <guid>http://WWW.MARIOSPINA.COM/braindump/archives/2008/02/22/plesk_83_ruby_package_gem_update.php</guid>
         <category>WebDev</category>
         <pubDate>Fri, 22 Feb 2008 17:16:11 -0500</pubDate>
      </item>
            <item>
         <title>Plesk 8.3 - ROR app at domain root level</title>
         <description>To make the app show up at the document root, we have to create a vhost.conf file in your domain&apos;s conf directory, and then use the websrvmng application to regenerate your domain&apos;s configuration.

Change directory to the domain&apos;s conf directory:
Code:

cd /var/www/vhosts/{domainname.com}/conf/

Create and begin editing a vhost.com file:
Code:

touch vhost.conf nano vhost.conf

Add the following line, replacing data in brackets:
Code:

DocumentRoot /var/www/vhosts/{domainname.com}/httpdocs/{railsapp}/public

Reconfigure the virtualhost using websrvmng:

Code:

/usr/local/psa/admin/sbin/websrvmng -u --vhost-name={domainname.com}

Verify that the following line is in /var/www/vhosts/{domainname.com}/conf/httpd.include (usually at the bottom):

Code:

Include /var/www/vhosts/{domainname.com}/conf/vhost.conf

Restart apache:

Code:

apache2ctl graceful

Visit your site:

Code:

http://www.{domainname.com}

</description>
         <link>http://WWW.MARIOSPINA.COM/braindump/archives/2008/02/22/plesk_83_ror_app_at_domain_root_level.php</link>
         <guid>http://WWW.MARIOSPINA.COM/braindump/archives/2008/02/22/plesk_83_ror_app_at_domain_root_level.php</guid>
         <category>WebDev</category>
         <pubDate>Fri, 22 Feb 2008 17:05:00 -0500</pubDate>
      </item>
            <item>
         <title>PLESK 8.3 - RUBY ON RAILS Setup</title>
         <description><![CDATA[<p>Ruby on Rails - <span class="caps">WORKING</span> This is how I got Ruby on Rails (RoR) working on my Plesk machine. I didn't find any major problems with Plesk's implementation, although it took me about 6 hours of trial-and-error to get it working right. <span class="caps">SWS</span>oft - you could seriously use some documentation for each Operating System you support.</p>


<p>First thing's first: In your Plesk control panel, make sure that you have your server updated with Ruby On Rails is installed. To do so, go to Server &gt; Updater and enable "Ruby on Rails Support."</p>

<p>After this, go to your domain, and enable FastCGI, which will allow your site to use RoR.</p>

<p>Change to your httpdocs directory:</p>

<p>Code:</p>

<p><dev>cd /var/www/vhosts/{domainname.com}/httpdocs</dev></p>

<p>Create a basic rails application. To do so, use this command:</p>

<p>Code:</p>

<p><dev>rails {railsapp}</dev></p>

<p>Remember to replace {railsapp} with the name of your application.</p>

<p>Change the file ownership to the domains user/group:</p>

<p>Code:</p>

<p><dev>chown {user}:{group} {railsapp}</dev></p>

<p>Change the permissions on the sessions directory:</p>

<p>Code:</p>

<p><dev>chmod 777 {railsapp}/tmp/sessions</dev></p>

<p>Note: Someone let me know if this is a bad idea ... I don't think it is, but I'm not sure. My system had problems writing to the sessions folder unless I chmod'd 777.</p>

<p>Change directory to your new application and edit your .htaccess file in the public/ directory:</p>

<p>Code:</p>

<p><dev>nano {railsapp}/public/.htaccess</dev></p>

<p>On line 2, change:<br />
Code:</p>

<p><dev>AddHandler fastcgi-script .fcgi</dev></p>

<p>To:<br />
Code:</p>

<p><dev>AddHandler fcgid-script .fcgi</dev></p>

<p>On line 32, change:<br />
Code:</p>

<p><dev>RewriteRule ^(.*)$ dispatch.cgi [QSA,L]</dev></p>

<p>To:<br />
Code:</p>

<p><dev>RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]</dev></p>


<p>Test your installation. Go to http://www.{domainname.com}/{railsapp}/public/</p>

<p>You should see the standard "Welcome Aboard" Rails index page.</p>]]></description>
         <link>http://WWW.MARIOSPINA.COM/braindump/archives/2008/02/22/plesk_83_ruby_on_rails_setup.php</link>
         <guid>http://WWW.MARIOSPINA.COM/braindump/archives/2008/02/22/plesk_83_ruby_on_rails_setup.php</guid>
         <category>WebHosting</category>
         <pubDate>Fri, 22 Feb 2008 16:58:19 -0500</pubDate>
      </item>
            <item>
         <title>Microsoft VPN filtering</title>
         <description>How to control local IP access using IP filtering with Microsoft Server 2003 VPN. 

Our first remote access policy is nearly finished. However, we also want this policy to limit connections to the Exchange server. For an Exchange server whose IP address is 10.42.42.101, follow these steps:

1. Double-click the Grant members of &quot;RemoteExchangeAccess&quot; policy you just created and click Edit profile to display the Edit Dial-in Profile page. The Authentication and Encryption tabs display the settings that you specified in the wizard.

2. At the Edit Dial-in Profile page that Web Figure 3 shows, click the IP tab. You&apos;ll see the Inbound Filters dialog box that Web Figure 4 shows. Select the Permit only the packets listed below radio button and click OK. We&apos;ll disable all traffic except for traffic to and from computers in the extranet that correspond to the 10.42.43.* subnet.

3.Click Input Filters, which displays the Edit IP Filter dialog box. Select the Destination network check box and type 10.42.42.101 for the IP address. Because we&apos;re limiting traffic to a specific address instead of an entire subnet, type 255.255.255.255 for the subnet mask; otherwise, Windows will reject the filter. The Protocol drop-down list lets you limit traffic to specific IP protocols, such as TCP and UDP, then further limit traffic to specific TCP/UDP port numbers.

4.Click OK. Your policy should now look like the one that Web Figure 4 shows.

5.Click OK to close the Inbound Filters window.

6.Back on the IP tab, click Output Filters, then click New. Select Source Network and enter the same IP address and subnet that you used for the inbound filter.

7.Click OK twice to close the policy.

Follow the same procedure for the rest of the remote access policies. For the Telecommuters policy, don&apos;t specify any IP filters that will let users access any part of the network. For the BusinessPartners policy, enter 10.42.43.0 as the IP address for both the inbound and outbound filters and 255.255.255.0 as the subnet mask. For the MTGConsultants policy, configure filters to let the consultants access only the Oracle server&apos;s IP address.
</description>
         <link>http://WWW.MARIOSPINA.COM/braindump/archives/2007/10/18/microsoft_vpn_filtering.php</link>
         <guid>http://WWW.MARIOSPINA.COM/braindump/archives/2007/10/18/microsoft_vpn_filtering.php</guid>
         <category></category>
         <pubDate>Thu, 18 Oct 2007 08:34:50 -0500</pubDate>
      </item>
            <item>
         <title>Cloning VM by hand on VMWARE  ESX Server v3.0.1</title>
         <description><![CDATA[<p>I’ve had time this week to get familiar with our test server environment which is a rather old Dell server running <span class="caps">VMW</span>are <span class="caps">ESX</span> Server 3.0.1. After creating a new VM and getting a base linux OS configured, I wanted to clone it for later use. I’ve used <span class="caps">VMW</span>are Workstation and <span class="caps">VMW</span>are Server before and the cloning process there is very simple–just copy. On <span class="caps">ESX</span> Server, there are a couple more steps required and then some other steps that are optional, but make life easier in the long run.</p>]]></description>
         <link>http://WWW.MARIOSPINA.COM/braindump/archives/2007/10/06/cloning_vm_by_hand_on_vmware_esx_server_v301.php</link>
         <guid>http://WWW.MARIOSPINA.COM/braindump/archives/2007/10/06/cloning_vm_by_hand_on_vmware_esx_server_v301.php</guid>
         <category>WebHosting</category>
         <pubDate>Sat, 06 Oct 2007 16:44:07 -0500</pubDate>
      </item>
            <item>
         <title>How to extract a file from Plesk 8.1.1 backup</title>
         <description><![CDATA[<p> Mpack tool is required in this case to work with <span class="caps">MIME </span>files. I have <span class="caps">FC4 </span>and got this package from here:</p>

<p>https://sourceforge.net/project/sho...lease_id=137934</p>

<p>You can find there as <span class="caps">RPM </span>as well as source <span class="caps">RPM </span>packages. So instructions are simple:</p>

<p>Create an empty directory to restore the back up file:</p>


<ol>
<li>mkdir recover</li>
<li>cd recover</li>
</ol>



<p>Create ungzipped copy of the backup in the current directory.<br />
# gunzip &lt; /PATH_TO_BACKUP/BACKUP_FILE &gt; domain-backup.mime</p>

<p>Run munpack to extract content of directories from the backup file<br />
# munpack domain-backup.mime<br />
# ls -al</p>

<p>Untar the needed directory. For example if you need to restore httpdocs:</p>

<p>#mkdir httpdocs/<br />
# tar xvf <span class="caps">DOMAIN.TLD.</span>httpdocs -C httpdocs/</p>

<p>In destination directory - httpdocs you should get all files.</p>]]></description>
         <link>http://WWW.MARIOSPINA.COM/braindump/archives/2007/05/17/how_to_extract_a_file_from_plesk_811_backup.php</link>
         <guid>http://WWW.MARIOSPINA.COM/braindump/archives/2007/05/17/how_to_extract_a_file_from_plesk_811_backup.php</guid>
         <category>WebHosting</category>
         <pubDate>Thu, 17 May 2007 08:52:22 -0500</pubDate>
      </item>
            <item>
         <title>Install GoDaddy Turbo certificate on PLESK 8.0</title>
         <description><![CDATA[<p>Here are some instructions to help you out on your Intermediate certificate install.</p>

<p>1. There is a button in the middle of the page labelled 'Browse'. Click<br />
'Browse' and navigate to the location of the saved site certificate you<br />
received from Starfield. Selecting it, then select 'Send File', this will<br />
upload and install the certificate against the corresponding Private Key.<br />
2. The certificate name will now appear in the list of certificates at the<br />
bottom of the page.<br />
3. Click on the name of the Certificate from the list.<br />
4. The box on the page labelled 'CA Certificate'. You will need to paste<br />
both the Starfield intermediate certificate and ValiCert root certificates<br />
from the .zip file you have received into this box.</p>

<p>They must be pasted this in order, the Starfield intermediate<br />
certificate first, followed by the ValiCert root certificate, the result will<br />
look similar to the example below (Please note: no blank line between<br />
then end of one certificate and the start of the next):</p>

<blockquote><p>-----BEGIN <span class="caps">CERTIFICATE</span>-----<br />
<span class="caps">MIIEQTCCA6</span>qgAwIBAgICAQQwDQYJKoZIhvcNAQEFBQAwgbsxJD<br />
AiBgNVBAcTG1Zh<br />
bGlDZXJ0IFZhbGlkYXRpb24gTmV0d29yazEXMBUGA1UEChMOVm<br />
FsaUNlcnQsIElu<br />
Yy4xNTAzBgNVBAsTLFZhbGlDZXJ0IENsYXNzIDIgUG9saWN5IF<br />
ZhbGlkYXRpb24g<br />
<span class="caps">QXV0</span>aG9yaXR5MSEwHwYDVQQDExhodHRwOi8vd3d3LnZhbGljZX<br />
<span class="caps">J0L</span>mNvbS8xIDAe<br />
BgkqhkiG9w0BCQEWEWluZm9AdmFsaWNlcnQuY29tMB4XDTA0MD<br />
ExNDIxMDUyMVoX<br />
<span class="caps">DTI0MDE</span>wOTIxMDUyMVowgewxCzAJBgNVBAYTAlVTMRAwDgYDVQ<br />
<span class="caps">QIE</span>wdBcml6b25h<br />
<span class="caps">MRM</span>wEQYDVQQHEwpTY290dHNkYWxlMSUwIwYDVQQKExxTdGFyZm<br />
llbGQgVGVjaG5v<br />
bG9naWVzLCBJbmMuMTAwLgYDVQQLEydodHRwOi8vd3d3LnN0YX<br />
JmaWVsZHRlY2gu<br />
<span class="caps">Y29</span>tL3JlcG9zaXRvcnkxMTAvBgNVBAMTKFN0YXJmaWVsZCBTZW<br />
N1cmUgQ2VydGlm<br />
aWNhdGlvbiBBdXRob3JpdHkxKjAoBgkqhkiG9w0BCQEWG3ByYW<br />
N0aWNlc0BzdGFy<br />
ZmllbGR0ZWNoLmNvbTCBnTANBgkqhkiG9w0BAQEFAAOBiwAwgY<br />
cCgYEA2xFDa9zR<br />
aXhZSehudBQIdBFsfrcqqCLYQjx6z59QskaupmcaIyK+D7M0+6<br />
yskKpbKMJw9raK<br />
gCrgm5xS4JGocqAW4cROfREJs5651POyUMRtSAi9vCqXDG2jim<br />
o8ms9KNNwe3upa<br />
JsChooKpSvuGIhKQOrKC1JKRn6lFn8Ok2/sCAQOjggEhMIIBHTAMBgNVHRMEBTAD<br />
<span class="caps">AQH</span>/ MAsGA1UdDwQEAwIBBjBKBgNVHR8EQzBBMD+gPaA7hjlodHRwOi<br />
8vY2VydGlm<br />
aWNhdGVzLnN0YXJmaWVsZHRlY2guY29tL3JlcG9zaXRvcnkvcm<br />
9vdC5jcmwwTwYD<br />
<span class="caps">VR0</span>gBEgwRjBEBgtghkgBhvhFAQcXAzA1MDMGCCsGAQUFBwIBFi<br />
dodHRwOi8vd3d3<br />
LnN0YXJmaWVsZHRlY2guY29tL3JlcG9zaXRvcnkwOQYIKwYBBQ<br />
<span class="caps">UHAQEELTA</span>rMCkG<br />
CCsGAQUFBzABhh1odHRwOi8vb2NzcC5zdGFyZmllbGR0ZWNoLm<br />
NvbTAdBgNVHQ4E<br />
FgQUrFXet+oT6/ yYaOJTYB7xJT6M7ucwCQYDVR0jBAIwADANBgkqhkiG9w0BAQUFAAOBgQB+HJi+rQONJYXufJCIIiv+J/RCsux/tfxyaAWkfZHvKNF9IDk7eQg3aBhS<br />
1Y8D0olPHhHR6aV0S/xfZ2WEcYR4WbfWydfXkzXmE6uUPI6TQImMwNfy5wdS0XCP<br />
mIzroG3RNlOQoI8WMB7ew79/RqWVKvnI3jvbd/TyMrEzYaIwNQ==<br />
-----END <span class="caps">CERTIFICATE</span>-----</p></blockquote>

<blockquote><p>-----BEGIN <span class="caps">CERTIFICATE</span>-----<br />
<span class="caps">MIIC5</span>zCCAlACAQEwDQYJKoZIhvcNAQEFBQAwgbsxJDAiBgNVBA<br />
cTG1ZhbGlDZXJ0<br />
<span class="caps">IFZ</span>hbGlkYXRpb24gTmV0d29yazEXMBUGA1UEChMOVmFsaUNlcn<br />
QsIEluYy4xNTAz<br />
BgNVBAsTLFZhbGlDZXJ0IENsYXNzIDIgUG9saWN5IFZhbGlkYX<br />
Rpb24gQXV0aG9y<br />
aXR5MSEwHwYDVQQDExhodHRwOi8vd3d3LnZhbGljZXJ0LmNvbS<br />
8xIDAeBgkqhkiG<br />
9w0BCQEWEWluZm9AdmFsaWNlcnQuY29tMB4XDTk5MDYyNjAwMT<br />
k1NFoXDTE5MDYy<br />
NjAwMTk1NFowgbsxJDAiBgNVBAcTG1ZhbGlDZXJ0IFZhbGlkYX<br />
Rpb24gTmV0d29y<br />
azEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNTAzBgNVBAsTLF<br />
ZhbGlDZXJ0IENs<br />
<span class="caps">YXN</span>zIDIgUG9saWN5IFZhbGlkYXRpb24gQXV0aG9yaXR5MSEwHw<br />
<span class="caps">YDVQQDE</span>xhodHRw<br />
Oi8vd3d3LnZhbGljZXJ0LmNvbS8xIDAeBgkqhkiG9w0BCQEWEW<br />
luZm9AdmFsaWNl<br />
cnQuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDOOn<br />
<span class="caps">HK5</span>avIWZJV16vY<br />
dA757tn2VUdZZUcOBVXc65g2PFxTXdMwzzjsvUGJ7SVCCSRrCl<br />
6zfN1SLUzm1NZ9<br />
WlmpZdRJEy0kTRxQb7XBhVQ7/nHk01xC+YDgkRoKWzk2Z/M/VXwbP7RfZHM047QS<br />
v4dk+NoS/ zcnwbNDu+97bi5p9wIDAQABMA0GCSqGSIb3DQEBBQUAA4GBADt<br />
/UG9v<br />
<span class="caps">UJSZSWI4OB9L</span>+KXIPqeCgfYrx+jFzug6EILLGACOTb2oWH+heQ<br />
C1u+mNr0HZDzTu<br />
<span class="caps">IYEZ</span>oDJJKPTEjlbVUjP9UNV+mWwD5MlM/Mtsq2azSiGM5bUMMj4QssxsodyamEwC<br />
W/POuZ6lcg5Ktz885hZo+L7tdEy8W9ViH0Pd<br />
-----END <span class="caps">CERTIFICATE</span>-----</p></blockquote>

<p>5. Click the 'Send Text' button.<br />
6. Now click 'Up Level' from the top right of the screen and choose<br />
'Setup'.<br />
7. At the top of the page, change the 'SSL Certificate' drop-down<br />
menu to the certificate you have just installed.<br />
8. Click the 'Server' item from the left hand menu.<br />
9. Click on the 'Service Management' menu item.<br />
10. You now need to Stop and Start the Apache process.</p>

<p><span class="caps">NOTE</span>: Restarting Apache will <span class="caps">NOT </span>work. You must stop the service, then<br />
start it again to complete the installation</p>


<p>Good luck!</p>]]></description>
         <link>http://WWW.MARIOSPINA.COM/braindump/archives/2006/10/02/install_godaddy_turbo_certificate_on_plesk_80.php</link>
         <guid>http://WWW.MARIOSPINA.COM/braindump/archives/2006/10/02/install_godaddy_turbo_certificate_on_plesk_80.php</guid>
         <category>WebHosting</category>
         <pubDate>Mon, 02 Oct 2006 11:44:40 -0500</pubDate>
      </item>
            <item>
         <title>How to Safe Sleep (Hibernate) Your Mac</title>
         <description><![CDATA[<p><b>Hibernation and Sleep</b></p>

<p>Mac users have become quite familiar with using Sleep mode. In Sleep mode, Macs go into a very low-power mode, while saving the current session for later use. Putting a Mac to sleep will continue to power <span class="caps">RAM </span>in sleep mode, so that whatever was in <span class="caps">RAM </span>when the computer went to sleep will still be there when the computer wakes. Sleep mode is almost instantaneous, consumes very low power, and as a PowerBook owner its indispensable to me. Still though, it requires a power-source (however low) and there are times when laptop batteries are completely depleted or a user wants to completely power-off their Mac.</p>

<p>Similar to Sleep, Windows “Hibernates,” while Linux “Software Suspends”. They are not as fast as Sleep mode, but they take it a step further by not using any power. When Hibernating, a PC quickly saves the current session to the hard drive, shuts-down, and completely powers-off the computer. Upon powering-on, the user is quickly returns to the previous session.</p>

<p><b>Safe Sleep</b></p>

<p>Up until recently, Mac users didn’t have a similar Sleep mode which required no power. When Apple announced new PowerBooks in October 2005, it also introduced Safe Sleep to Mac OS X, an extention to Sleep mode that allows for hibernation without power.</p>

<p>According to an Apple article:</p>

<p>Safe Sleep ensures that data stored in main memory will not be lost should the system shut down due to a loss of power during sleep mode. Prior to your system entering sleep, Safe Sleep automatically saves the contents of main memory […] to the hard drive. In the event the battery becomes completely depleted while the system is asleep, the computer will shut down. But when a power adapter is connected or a freshly charged battery is installed, the PowerBook can be restarted and it will automatically return to the desktop state that existed prior to entering sleep.</p>

<p>When restarting a PowerBook from Safe Sleep, a progress bar indicates that the PowerBook is waking from Safe Sleep. The screen is also in gray-scale and slightly blured. </p>


<p><b>How to Enable Safe Sleep</b></p>

<p>Safe Sleep is so-far only officially available on the new PowerBooks. But Safe Sleep is very much software based , not hardware based. With Apple’s release of mac OS 10.4.3, Safe Sleep can be enabled on many Macs thanks to an excellent hack. To do so first insure Mac OS X, is up-to-date to with version 10.4.3 (or above). If not, run Software Update.</p>

<p>Reportedly working laptops include (but not necessarily limited to) iBook G4s, Aluminum PowerBook G4s. You may also try Safe Sleep on desktops. For a much more technical look into enabling it, visit the source information on the hack.</p>

<blockquote><p>Warning: Enabling Safe Sleep is essentially a hack. It is very likely to work on recent Macs, but enabling Safe Sleep may cause your Mac to explode, implode, melt, freeze, have a heart-attack, or develop an inguinal hernia.</p></blockquote>


<p><b>1. Apply Safe Sleep Property</b></p>

<p>To summarize, new PowerBooks have the “has-safe-sleep” property. To apply this property to your Mac, something needs to be run in Open Firmware at boot. In the Terminal enter the folling, hitting return at the end of each line:</p>

<blockquote><p><code>sudo nvram nvramrc='&quot; /&quot; select-dev</code><br />
<code>&quot; msh&quot; encode-string &quot; has-safe-sleep&quot; property</code><br />
<code>unselect</code><br />
@'@</p></blockquote>

<blockquote><p><code>sudo nvram &quot;use-nvramrc?&quot;=true</code></p></blockquote>


<p>In a Terminal shell it should look as follow:</p>

<blockquote><p><code>Last login: Fri Nov 11 11:11:11 on ttyp1</code><br />
<code>Welcome to Darwin!</code><br />
<code>computer:~ User$ sudo nvram nvramrc='&quot; /&quot; select-dev</code><br />
<code>&gt; &quot; msh&quot; encode-string &quot; has-safe-sleep&quot; property</code><br />
<code>&gt; unselect</code><br />
<code>&gt; '</code><br />
<code>computer:~ User$ sudo nvram &quot;use-nvramrc?&quot;=true</code></p></blockquote>

<p>The Mac must be restarted to set the changes.</p>


<p><b>2. Allow Hibernate Mode</b></p>

<p>To continue, you must have at least as much free disk space as physical memory , plus 750MB. To enable Sleep Safe, in the Terminal enter:</p>

<blockquote><p><code>sudo pmset -a hibernatemode 3</code></p></blockquote>

<p>If you have secure virtual memory enabled, use 7 rather than 3 to disable encrypted hibernation. Encrypted hibernation does not work. Do not set it to 7 if you do not have secure virtual memory.</p>

<p>This should create the file <code>/var/vm/sleepimage</code>.</p>

<p>When your Mac is set to sleep, it will now enter regular Sleep mode (consuming minimal power) first. If you prefer to enter Safe Sleep mode directly (note: it takes a few seconds more to sleep and wake-up) then instead enter:</p>

<blockquote><p><code>sudo pmset -a hibernatemode 1</code></p></blockquote>

<p>Use 5 with secure virtual memory.</p>

<p>To disable Safe Sleep:</p>

<blockquote><p><code>sudo pmset -a hibernatemode 0</code></p></blockquote>

<p>The Mac does not need to be restarted to set the changes to hibernate mode.</p>

<p><b>3. Verify Sleeping</b></p>

<p>Put the Mac to sleep and wait for the light to start pulsing. Wait a few more seconds. Wake it normally (by hitting the space bar for example).</p>

<p>Open Console and view system.log, or simply open the file /var/log/system.log. Look for a line indicating that the process worked. It is similar to:</p>

<blockquote><p><code>Nov 11 12:15:33 computername kernel[0]: System SafeSleep</code></p></blockquote>


<p><b>4. Verify Safe Sleep</b></p>

<p>Now attempt to actually Safe Sleep for real. Put the Mac to Sleep, and wait for the light to start pulsing. Remove the power-source plug and the battery. Wait for the light to stop pulsing and turn off, which may take a a couple of minutes. Your Mac should now be in Safe Sleep mode. Plug the power back in and add the battery. Start-up. It should show the previous saved desktop (blurred and in grayscale) along with a progress bar as pictured above. The system should be back to the way you left it.</p>

<p><b>Troubleshooting</b></p>

<p>You may have problems with a bad hibernate images, which may repeatedly kernel panic. Try restarting which will start the image again. It may work. It may not, and repeatedly fail. This can happen if you don’t set hibernatemode properly with secure virtual memory (try alternating between 1+5 or 3+7). If a bad hibernate image keeps booting then crashing reboot the mac holding down Command-Option-O-F to get in to Open Firmware. Type:</p>

<blockquote><p><code>setenv boot-image</code><br />
Hit return, then enter:</p></blockquote>

<blockquote><p><code>boot</code></p></blockquote>



<p><b>Disable Safe Sleep</b></p>

<p>To disable Safe Sleep enter in the Terminal:</p>

<blockquote><p><code>sudo pmset -a hibernatemode 0</code></p></blockquote>

<p>No need to restart.</p>

<p>For a more full undo, disable all nvramrc variables:</p>

<blockquote><p><code>sudo nvram &quot;use-nvramrc?&quot;=false</code><br />
Enter password, then restart.</p></blockquote>


<p><b>Conclusion</b></p>

<p>Now that Safe Sleep is working for me, I have set my PowerBook to use Safe Sleep, instead of just regular Sleep mode that consumes power. It take about 15 seconds to enter Safe Sleep, and about 40 seconds to wake-up from it. That is way longer than the 2 seconds it takes for regular Sleep and wake-up.</p>

<p>Safe Sleep seems very promising though and it will be interesting to see if Apple supports it with older laptops.</p>]]></description>
         <link>http://WWW.MARIOSPINA.COM/braindump/archives/2005/11/13/how_to_safe_sleep_hibernate_your_mac.php</link>
         <guid>http://WWW.MARIOSPINA.COM/braindump/archives/2005/11/13/how_to_safe_sleep_hibernate_your_mac.php</guid>
         <category>OSX</category>
         <pubDate>Sun, 13 Nov 2005 20:10:59 -0500</pubDate>
      </item>
            <item>
         <title>NXClient for OSX</title>
         <description><![CDATA[<p>L'installation du <span class="caps">NXC</span>lient se fait comme suit: <br />
# Désarchiver le package .dmg de <span class="caps">NXC</span>lient<br />
# Copier les programmes ce situant dans le répertoire Application du client NX dans votre répertoire /Application sur votre <span class="caps">MAC.</span><br />
# Copier le contenu du répertoire usr du client NX dans votre répertoire /usr sur votre <span class="caps">MAC.</span> Et le tour est joué ! </p>]]></description>
         <link>http://WWW.MARIOSPINA.COM/braindump/archives/2005/09/30/nxclient_for_osx.php</link>
         <guid>http://WWW.MARIOSPINA.COM/braindump/archives/2005/09/30/nxclient_for_osx.php</guid>
         <category>OSX</category>
         <pubDate>Fri, 30 Sep 2005 08:09:54 -0500</pubDate>
      </item>
            <item>
         <title>Cheatsheet for the .htaccess file</title>
         <description><![CDATA[<p>Here is a simple cheatsheet for the .htaccess file:</p>

<p>Enable Directory Browsing</p>

<p>Options +Indexes<br />
## block a few types of files from showing<br />
IndexIgnore *.wmv *.mp4 *.avi<br />
Disable Directory Browsing</p>

<p>Options All -Indexes<br />
Customize Error Messages</p>

<p>ErrorDocument 403 /forbidden.html<br />
ErrorDocument 404 /notfound.html<br />
ErrorDocument 500 /servererror.html<br />
Get <span class="caps">SSI </span>working with <span class="caps">HTML</span>/SHTML</p>

<p>AddType text/html .html<br />
AddType text/html .shtml<br />
AddHandler server-parsed .html<br />
AddHandler server-parsed .shtml<br />
# AddHandler server-parsed .htm<br />
Change Default Page (order is followed!)</p>

<p>DirectoryIndex myhome.htm index.htm index.php<br />
Block Users from accessing the site</p>

<p><limit GET POST PUT><br />
order deny,allow<br />
deny from 202.54.122.33<br />
deny from 8.70.44.53<br />
deny from .spammers.com<br />
allow from all<br />
</limit><br />
Allow only <span class="caps">LAN </span>users</p>

<p>order deny,allow<br />
deny from all<br />
allow from 192.168.0.0/24<br />
Redirect Visitors to New Page/Directory</p>

<p>Redirect oldpage.html http://www.domainname.com/newpage.html<br />
Redirect /olddir http://www.domainname.com/newdir/<br />
Block site from specific referrers</p>

<p>RewriteEngine on<br />
RewriteCond <span style="HTTP_REFERER">site-to-block\.com [NC]<br /><br />
RewriteCond </span>{HTTP_REFERER} site-to-block-2\.com [NC]<br />
RewriteRule .* - [F]<br />
Block Hot Linking/Bandwidth hogging</p>

<p>RewriteEngine on<br />
RewriteCond %{HTTP_REFERER} <img src="$" alt="" class="top" style="vertical-align:text-top" />^http://(www\.)?mydomain.com/.*$ [NC]<br />
RewriteRule \.(gif|jpg)$ - [F]<br />
Want to show a “Stealing is Bad” message too?</p>

<p>Add this below the Hot Link Blocking code:</p>

<p>RewriteRule \.(gif|jpg)$ http://www.mydomain.com/dontsteal.gif [R,L]<br />
Stop .htaccess (or any other file) from being viewed</p>

<p><files file-name><br />
order allow,deny<br />
deny from all<br />
</files><br />
Avoid the 500 Error</p>


<ol>
<li>Avoid 500 error by passing charset<br />
AddDefaultCharset utf-8<br />
Grant <span class="caps">CGI</span> Access in a directory</li>
</ol>



<p>Options +ExecCGI<br />
AddHandler cgi-script cgi pl<br />
# To enable all scripts in a directory use the following<br />
# SetHandler cgi-script<br />
Save Bandwidth</p>


<ol>
<li>Only if you use <span class="caps">PHP</span><br />
<ifmodule mod_php4.c><br />
php_value zlib.output_compression 16386<br />
</ifmodule><br />
Password Protecting Directories</li>
</ol>



<p>Use the .htaccess Password Generator and follow the brief instructions!</p>

<p>The CheckSpelling Directive</p>

<p>From Jens Meiert: CheckSpelling corrects simple spelling errors (for example, if someone forgets a letter or if any character is just wrong). Just add CheckSpelling On to your htaccess file.</p>

<p>The ContentDigest Directive</p>

<p>As the Apache core features documentation says: “This directive enables the generation of Content-MD5 headers as defined in <span class="caps">RFC1864 </span>respectively <span class="caps">RFC2068.</span> The Content-MD5 header provides an end-to-end message integrity check (MIC) of the entity-body. A proxy or client may check this header for detecting accidental modification of the entity-body in transit.</p>

<p>Note that this can cause performance problems on your server since the message digest is computed on every request (the values are not cached). Content-MD5 is only sent for documents served by the core, and not by any module. For example, <span class="caps">SSI </span>documents, output from <span class="caps">CGI </span>scripts, and byte range responses do not have this header.”</p>

<p>To turn this on, just add ContentDigest On.</p>]]></description>
         <link>http://WWW.MARIOSPINA.COM/braindump/archives/2005/09/20/cheatsheet_for_the_htaccess_file.php</link>
         <guid>http://WWW.MARIOSPINA.COM/braindump/archives/2005/09/20/cheatsheet_for_the_htaccess_file.php</guid>
         <category>WebDev</category>
         <pubDate>Tue, 20 Sep 2005 18:23:01 -0500</pubDate>
      </item>
            <item>
         <title>MT Regex howto</title>
         <description><![CDATA[<p><span class="caps">DESCRIPTION</span></p>

<p>This plugin allows you to define search and replace parameters for<br />
elements you produce from Movable Type templates.</p>

<p>Tags made available through this plugin:</p>

<p>  <MTRegexDefine> - a utility tag to add a Perl regular expression that<br />
  can be used in conjunction with the global 'regex' post processor<br />
  attribute.</p>

<p>  <MTIfMatches> - a tag for including/excluding content compared with<br />
  either a constant value or a regular expression pattern.</p>

<p>  <MTRegex> - Container tag for processing any portion of a template.</p>

<p>  <MTGrep> - Returns matches from the contained text.</p>




=======================================================================



<p><MTRegexDefine></p>

<p>These attributes are allowed:</p>

<p>  * name<br />
    If given, the regular expression can be individually referenced<br />
    by name.</p>

<p>  * no_html<br />
    If specified for a replacement regular expression, it will ignore<br />
    any tags</p>

<p>Perl regular expressions are incredibly powerful constructs that can<br />
be used to manipulate text in a variety of ways.</p>

<p>Here's an example (place at the top of your template):</p>

<p><MTRegexDefine>s|:-D|<img src="/images/smiley.gif" height="32" width="32" />|g</MTRegexDefine></p>

<p>The above will replace all occurrances of :-D with a <IMG> tag that<br />
displays a smiley.gif instead.</p>

<p>In order to activate the search and replace for any given &lt;$MT$&gt;<br />
variable, use the global "regex" modifier:</p>

<p>  &lt;$MTEntryBody regex="1"$&gt;</p>

<p>This will 'turn on' the regex operation for that output.</p>

<p>Sometimes you might want to selectively pick and choose from various<br />
regular expression patterns. To do that, name the expressions like<br />
this:</p>

<p><MTRegexDefine name="patt1">s/Brad/<b>Perl Nut</b>/gi</MTRegexDefine><br />
<MTRegexDefine name="patt2">s|google\(([^\)]+)\)|<a href="http://www.google.com/search?q=$1" title="Google This!">$1</a>|g</MTRegexDefine></p>

<p>Note: "patt2" shown above gives you the ability to write like this<br />
in your blog entry:</p>

<p>  google(some text)</p>

<p>That produces a "Google This" link right in your entry. This kind of<br />
thing is what makes this plugin so useful!</p>

<p>Now, with your &lt;$MT$&gt; vars, you can specify things like this:</p>

<p>  &lt;$MTEntryTitle regex="patt1"$&gt;  (only applies patt1 to this part)<br />
  &lt;$MTEntryBody regex="patt2"$&gt;   (only applies patt2 to this part)<br />
  &lt;$MTEntryBody regex="1"$&gt;       (applies all regex patterns)<br />
  &lt;$MTEntryBody regex="patt1 patt2"$&gt; (applies both patt1 and patt2)</p>

<p>You can also specify an inline regex like this:</p>

<p>  &lt;$MTEntryBody regex="s/this/that/g"$&gt;</p>

<p>You can only specify a single regular expression using that technique.<br />
Also, you cannot currently use the letter '$' inside an inline<br />
expression due to a parsing limitation in the current (2.21) version<br />
of Movable Type. In order to use '$' in your expressions, create a<br />
named expression using the <span class="caps">MTR</span>egexDefine tag.</p>




=======================================================================



<p><MTIfMatches><br />
<MTIfNotMatches></p>

<p>This tag allows you to output content based on whether it matches<br />
a value or regular expression.</p>

<p>These attributes are allowed:</p>

<p>  * var<br />
    If specified, var is evaluated as a Movable Type variable.<br />
    The result is used to compare against the constant 'val'<br />
    attribute value or the regular expression provided with<br />
    the 'pattern' attribute value.</p>

<p>    If unspecified, the tag will use the contained data as the<br />
    value to compare against the constant/pattern.</p>

<p>  * expr<br />
    An alternative to 'var' that allows for any Movable Type<br />
    expression (use [ and ] instead of &lt; and &gt; for the tag<br />
    delimiters).</p>

<p>  * value<br />
    If specified, value is a string constant to compare with.</p>

<p>  * pattern<br />
    If specified, pattern defines a named regular expression<br />
    or a matching pattern to compare against.</p>

<p>Usage examples:</p>

<p>  <MTIfMatches pattern="m/something/"><br />
    .. other tags/values here-- outputs data only if content includes the<br />
    string 'something' somewhere inside ..<br />
  </MTIfMatches></p>

<p>  --</p>

<p>  <MTEntries><br />
    <MTIfMatches var="EntryAuthor" pattern="m/(brad|ben|mena)/i"><br />
      .. output entry data (only outputs data authored by Brad, Ben and<br />
      Mena ..<br />
    </MTIfMatches><br />
  </MTEntries></p>

<p>  --</p>

<p>  <MTIfMatches var="BlogEntryCount" value="1000"><br />
    <blink><span class="caps">WOW</span>! We've reached 1,000 blog entries!</blink><br />
  </MTIfMatches></p>

<p>  --</p>

<p>  <MTRegexDefine name="somematch">m/something/</MTRegexDefine></p>

<p>  <MTIfMatches pattern="somematch"><br />
    .. other tags/values-- outputs data only if content includes<br />
    a match for the named regular expression 'somematch' ..<br />
  </MTIfMatches></p>




=======================================================================



<p><MTRegex></p>

<p>This tag allows you to process a block with previously defined regex<br />
patterns, or an individual regex pattern.</p>

<p>These attributes are allowed:</p>

<p>  * pattern<br />
    Can either be a matching regex which will select named regex<br />
    patterns that are selected using that pattern, or a replacement<br />
    regex pattern which will be applied by itself.</p>

<p>  * no_html<br />
    Forces the regex operations to exclude any tags.A</p>


<p>Please note: Perl regular expressions are very powerful, but if you're<br />
not familiar with them already, it will take some time to learn how to<br />
use them. The links provided below are very helpful. Also, be patient<br />
as you are creating them-- if they aren't working, don't assume that<br />
this plugin is at fault-- more than likely, it is an improperly<br />
constructed expression.</p>




=======================================================================



<p><MTGrep></p>

<p>This tag allows you to search the block contained by the Grep tag.<br />
Lines that match the given pattern(s) are taken and joined together<br />
using the 'glue' attribute given (or the newline character if no glue<br />
attribute is specified).</p>

<p>These attributes are allowed:</p>

<p>  * pattern<br />
    Can either be a matching regex which would be used for matching<br />
    the text block or a space-delimited list of named patterns (specified<br />
    previously using the RegexDefine tag).</p>

<p>  * glue<br />
    Text to be used to piece the matches together.</p>

<p>  * default<br />
    Text to be returned in case no matches are found.</p>




=======================================================================



<p><span class="caps">FOR MORE INFORMATION</span></p>

<p>Documenting Perl regular expressions goes way beyond the scope of this<br />
readme.txt file. For a tutorial on using Perl regular expressions<br />
visit this page:</p>

<p>  http://www.perldoc.com/perl5.6.1/pod/perlretut.html</p>

<p>And for advanced documentation, look here:</p>

<p>  http://www.perldoc.com/perl5.6.1/pod/perlre.html</p>]]></description>
         <link>http://WWW.MARIOSPINA.COM/braindump/archives/2005/09/17/mt_regex_howto.php</link>
         <guid>http://WWW.MARIOSPINA.COM/braindump/archives/2005/09/17/mt_regex_howto.php</guid>
         <category>Movable Type</category>
         <pubDate>Sat, 17 Sep 2005 21:27:15 -0500</pubDate>
      </item>
            <item>
         <title>Rails on Plesk</title>
         <description><![CDATA[<p>Rails on Plesk</p>


<p>Hi, folks! It seems a few of y’all might be interested in hearing how to get Ruby on Rails set up on a Plesk server. I did it last month, and it wasn’t terribly difficult, so I thought I’d write a quick guide to the process.<br />
But first, two quick caveats:<br />
	1.	I did this on a server running <span class="caps">PSA</span> 7.5.2 on Red Hat Enterprise Linux 3. The process is probably the same for other Red Hat/Fedora versions, but it might be a bit different on other distros or FreeBSD.<br />
	2.	I’m assuming that you are comfortable with compiling and installing software from source. If that’s not something you’re familiar with, there is great little howto here that can help you get started.</p>

<p>Step one: Install Ruby</p>

<p>You need Ruby 1.8.2 or later to run rails. If your OS vendor supplies a packaged version for you, use that. Otherwise, you’ll need to download the latest source from ruby-lang.org) and compile it yourself. I didn’t do anything unusual on my ruby installation; just ./configure, make, and make install.</p>


<p>Step two: Install the <span class="caps">FCGI</span> Development Kit</p>

<p>There are three pieces of FastCGI software that must be installed on your server to run rails applications: The FastCGI development kit, the mod_fastcgi Apache module, and the Ruby FastCGI bindings. We’ll do the first one now. You can download it from fastcgi.com. This one is just like the Ruby installation: ./configure, make, and make install.</p>


<p>Step three: Install mod_fastcgi</p>

<p>Mod_fastcgi doesn’t have an automated installation process, so this one is a bit more complicated:<br />
	1.	Download the source code from fastcgi.com and extract it into /usr/local/src.<br />
	2.	cd mod_fastcgi-2.4.2<br />
	3.	cp Makefile.AP2 Makefile (this is required since we’re using apache 2.x, not 1.3)<br />
	4.	Open Makefile in your favorite editor. Change the line that says top_dir = /usr/local/apache2 to top_dir = /usr/lib/httpd<br />
	5.	make<br />
	6.	make install</p>


<p>Step four: Install RubyGems</p>

<p>RubyGems is the ruby package manager (If you’re familiar with Perl’s <span class="caps">CPAN </span>module, RubyGems is basically the same idea). It can be downloaded from rubyforge.<br />
RubyGems doesn’t use <span class="caps">GNU </span>autoconf or automake, so the installation command is a bit different: instead of ./configure, make, and make install, you just do ruby setup.rb all.</p>

<p>Step five: Install Rails, Ruby-FCGI and Ruby-MySQL</p>

<p>Once you have Ruby and RubyGems installed, getting rails is easy: just gem install rails. It will ask you whether it should install some dependencies; say “y” to all of them. When that’s done, gem install fcgi to get the Ruby FastCGI bindings, and gem install mysql to get the Ruby MySQL bindings.</p>


<p>Step six: Configure Apache</p>

<p>To make Apache use the FastCGI module, copy this into /etc/httpd/conf.d/fastcgi.conf:<br />
LoadModule fastcgi_module modules/mod_fastcgi.so<br />
FastCgiWrapper on<br />
FastCgiConfig -idle-timeout 900<br />
Restart apache, and you’re done!</p>


<p>Wait—two more quick notes!</p>

<p>	1.	This guide only covers server-wide configuration; there are a few tricks to setting up individual rails apps in Plesk as well. If an article about setting up an individual rails app would be helpful to you, drop me a line and I’ll see what I can do. (Update: The follow-up article is available here)</p>

<p>	2.	This guide is only based on my own experience. If you use it, and find ways that it could be better or more complete, leave a response, and by all means, I’ll do my best to fix it.</p>]]></description>
         <link>http://WWW.MARIOSPINA.COM/braindump/archives/2005/09/14/rails_on_plesk.php</link>
         <guid>http://WWW.MARIOSPINA.COM/braindump/archives/2005/09/14/rails_on_plesk.php</guid>
         <category>Linux</category>
         <pubDate>Wed, 14 Sep 2005 00:08:19 -0500</pubDate>
      </item>
      
   </channel>
</rss>
