Friday, September 21, 2012

How to disable Facebook and Twitter integration in Mountain Lion

While for some people this may be a killer feature, I hardly use Facebook or Twitter and have no plans to share content through those services. Email suits me just fine. As such, I didn't want to have those listed in Mountain Lion's Share Sheets. So, I grepped for Facebook and got this: $ find /System -name Facebook -print 2>/dev/null /System/Library/InternetAccounts/Facebook.iaplugin/Contents/MacOS/Facebook /System/Library/PrivateFrameworks/ShareKit.framework/Versions/A/PlugIns/Facebook.sharingservice/ Contents/MacOS/Facebook /System/Library/SocialServices/Facebook.socialplugin/Contents/MacOS/Facebook And for Twitter: $ find /System -name Twitter -print 2>/dev/null /System/Library/PrivateFrameworks/ShareKit.framework/Versions/A/PlugIns/Twitter.sharingservice/ Contents/MacOS/Twitter Preferring to do the least damage possible, I simply renamed Facebook.sharingservice to Facebook.sharingservice.old and Twitter.sharingservice to Twitter.sharingservice.old. After doing this, I quit Safari, reopened it, and gone were the Facebook and Twitter options. No guarantees this won't reenable on updates or break something else, but so far it seems to work. If nothing else, you can always rename the plugins back.
Tuesday, September 18, 2012

The quest for a free dynamic DNS (DDNS) service

Being self-hosted has its perks, but my ISP periodically updates my home IP, and often I don't notice until several days have gone by. I've looked for a while for free dynamic DNS services, as GoDaddy doesn't have this option, but the few I found had major problems I didn't want to deal with (e.g. limitations on the number of zones I could add, or a requirement to allow others to create free subdomains).

I finally ran across Namecheap's FreeDNS service, which was exactly what I wanted. This requires that you enable dynamic DNS on Namecheap's side, then have a client (such as ddns, ddclient, or any of the others listed here) running on your computer. To use their service (which does not require domain transfer or the purchase of any services, but is also available to those that have Namecheap accounts) you'll need to do the following:
  1. Sign up for a Namecheap account (or log into your existing account) here.
  2. Go here, type your domain name, then press "Get DNS". On the next page, click "Add DNS for Selected Domains".
  3. Now click on "OK! Go to the Hosted Domains Page". This will take you to your domain manager. Note that your domains will be listed in the "Hosted Domains" category of the FreeDNS section on the left column (it took me a bit to find where they disappeared).
  4. At this point, you should see your domain listed. Click on your domain name, and the current DNS status will be listed as "INACTIVE". That's fine, since we haven't yet set up the DNS zones, and we don't want to point the DNS until we have. Add the DNS zones as desired, and save them when done.
  5. If you want as little downtime as possible, now is the time to activate the DNS on Namecheap's side before pointing the nameservers. At the top, find the "Authorization by Email" paragraph by your DNS status and click "select authorization email". This will give you several email addresses on the domain to choose from, and Namecheap will send an email to confirm that you are indeed the owner of the domain. After you get that email and approve it, the DNS with Namecheap should change to active status.
  6. Once activated (or anytime prior to this if you don't care about downtime) point the nameservers to Namecheap. As per their KB, the nameservers are as follows:
    freedns1.registrar-servers.com
    freedns2.registrar-servers.com
    freedns3.registrar-servers.com
    freedns4.registrar-servers.com
    freedns5.registrar-servers.com
    Note that DNS changes can take up to 24-48 hours to propagate around the world.
  7. Once the nameservers are pointed to Namecheap and propagated, you're ready to set up Dynamic DNS as per the instructions below.
If the domain is completely pointed and the DNS zones are as they should be, you're ready to set up Dynamic DNS. This requires that you enable it on Namecheap's side, then have a client running on your side.
  1. Log into your Namecheap account, go to the "Hosted Domains" category of the domain manager, and pull up your domain's DNS zone editor.
  2. On the left, under "Advanced Options", click on "Dynamic DNS".
  3. Click on Enable Dynamic DNS. Make note of the password given.
  4. Configure the DDNS client of your choice with the settings in that section (unless you use my tool, you'll need to talk to their respective developers). For Mac/Linux/Unix users, feel free to try out my client found here.

ddns: a Dynamic DNS updater for Namecheap

For any Mac/Unix/Linux users out there, I've created an extremely lightweight dynamic DNS client I'm calling ddns. The current version is 0.82.
  • Only works with Namecheap's DDNS service, which is free. For information on how to set that side up, visit my post here
  • Updates the A Record (DNS zone) of your choice with your current IP
  • Written in bash and requires curl and awk, which most distros have. I've tested it on a Mac, but should work on any *nix system
  • Works in a cron job or as a one-time run, and logs successes or failures
  • No known bugs, but please email me at ddns@lotsaoxen.com if you find any!

Download ddns 0.82 here.

Download sample config file here.


If you download the client and use it, please feel free to comment here with suggestions, issues, and such. I can't promise to be able or willing to fix everything, but I'm interested in feedback.
Saturday, May 5, 2012

How to enable the root account login on OS X and other Unix and Linux systems

For security reasons, many Unix and Linux systems, including OS X and Ubuntu, install with a locked or disabled root account by default, with no password (not to be confused with a blank password). As such, it isn't possible to log directly into root shell or use su. Instead, the default user is given administrator access. That being said, below are three ways I found to access the root shell in the rare case it may need to be done.

Note: This presupposes the user already has administrator/superuser rights. Because of this, for most users the root account does not generally need to be enabled.

  • The following will open an sh or bash process with full root privileges: sudo sh sudo bash
  • The following will log you in with full root privileges: sudo su - If one runs su alone, it will prompt for the root password, but with sudo first it instead prompts for the current user's password. The dash at the end loads the root user environment.
  • The following sets a password for the root user, thereby enabling normal login for root: sudo passwd root On some systems, OS X not included, the following will reverse the last command, both disabling the root login and removing its password hash: sudo passwd -dl root
Some systems, including OS X, also have a special command, dsenableroot.
  • To enable root login: dsenableroot
  • To disable root login: dsenableroot -d


For more information:
  • Apple's official instructions for various versions of OS X using the GUI to enable root can be found here.
  • Ubuntu's site has a great article on various uses and misconceptions about sudo and root, as well as a few useful tricks, that can be found here.

How to solve "sudo: cannot get working directory" error

Periodically, you may get the following error:
sudo: cannot get working directory
This error means that the directory you are supposedly in no longer exists. You can fix this by simply moving to a different directory, i.e. your home:
cd

How to install the MySQLdb Python module on OS X Lion

These instructions have been tested on a machine running OS X Lion and Python 2.7.1, but should work for most any Intel setup. Most of the setup is explained in the README file included with the source, and the error at the end was solved per a thread here.
  1. Download MySQL for Python (the MySQLdb module) source from http://sourceforge.net/projects/mysql-python/ and extract the tar.gz file.
  2. Open Terminal and navigate to the source folder.
  3. Type the following to build the module: python setup.py build
  4. Then, install the module by typing the following: sudo python setup.py install
  5. In a perfect world, this would be all you'd need to do. However, if your computer was like mine, when you try to import the newly-installed module, it'll through the following error: >>> import MySQLdb Traceback (most recent call last): File "", line 1, in File "MySQLdb/__init__.py", line 19, in import _mysql File "build/bdist.macosx-10.7-intel/egg/_mysql.py", line 7, in File "build/bdist.macosx-10.7-intel/egg/_mysql.py", line 6, in __bootstrap__ ImportError: dlopen(/Users/username/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg-tmp/_mysql.so, 2): Library not loaded: libmysqlclient.18.dylib Referenced from: /Users/username/.python-eggs/MySQL_python-1.2.3-py2.7-macosx-10.7-intel.egg-tmp/_mysql.so Reason: image not found To fix this error, we'll simply make a symlink where libmysqlclient.18.dylib is expected to be to where it really is: sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib Note: you can also fix this issue by changing your path during install as per this suggestion.