March, 2008
Better iPhone/iPod Touch Automount
This is an update to my article about auto-mounting the iPod Touch. I'd recommend updating your method to the one provided here, if you're an Ubuntu Gutsy user like me. Same method as described here, except the rules are now:
SUBSYSTEM=="usb", ATTR{idProduct}=="1291", ATTR{idVendor}=="05ac", ACTION=="add", NAME="ipod", RUN+="/bin/su greg -c '/usr/bin/ipod-touch-mount'"
SUBSYSTEM=="usb", ACTION=="remove", RUN+="/bin/su greg -c '/usr/bin/ipod-touch-umount'"
Even nicer! Better if it were all bunched into a nice little automated script but thats for later.
Link to This Article |
Comments (0)
Tags:
iPod Touch, iPhone, Linux
Hotplug Your iPod Touch With udev Rules
An updated version of these rules are available here. They have been modified to work with the ipod-convenience package provided for Ubuntuy 7.10 (Gutsy) users.
I've been fiddling around with syncing my iPod Touch in Linux over the past couple of days. Because support is not complete yet, the only way to effectively do this is over WiFi, which is actually a pretty cool solution. Even so, I wanted to make an attempt to mount the iPod's media share over WiFi automatically on connection to the USB plug so that when I set it down to charge it I would be able to, most of the time, sync with it too. Plus, since I've been using Gnome, mounting devices to /media/ causes a nice little icon to popup on the desktop, which seemed cool.
Basically, making the device hot-pluggable all boils down to creating a new rule for udev in /etc/udev/rules.d/. I was following the standard tutorial on udev rules, here. So, if you're following on from the instructions given for mounting your iPod Touch's media share over wifi, this udev rule will automagically create an entry for your ipod in /dev/ipod and try to mount the Media folder using SSHFS to /media/ipod/:
SUBSYSTEM=="usb", ATTR{idProduct}=="1291", ATTR{idVendor}=="05ac", ACTION=="add", NAME="ipod", RUN+="/bin/su greg -c '/usr/bin/sshfs -o workaround=rename root@192.168.1.70:/var/root/Media /media/ipod'"
SUBSYSTEM=="usb", ACTION=="remove", RUN+="/bin/su greg -c '/bin/fusermount -u /media/ipod'"
Obviously this rule applies to me and there is some customisation required. Replacing "greg" with your username and the IP address of the iPod (192.168.1.70, in my case) with the correct one is a must or these won't work. To use this rule, I just created a new file called "10-local.rules" in /etc/udev/rules.d/. I've also added a lovely little iPod touch PNG icon so that when the share is mounted, Gnome will display the iPod touch on my desktop.

And there you have it: hot-plugging your iPod under Linux. As an extension to this project, I'm looking into using HAL's rules instead to provide a frendlier device name, but I'm not sure how well this will work. The place to look for this is: /etc/hal/fdi/policy/, but more on that later.
Link to This Article |
Comments (0)
Tags:
iPod Touch, iPhone, Linux, Ubuntu
Google Watches You Shower
I was a little disturbed to see ads for recipes appearing next to emails to my girlfriend while replying to one of her emails through G-Mail. The reason it disturbed me was that we had not discussed food or recipes at all in the email and the only relation to the types of recipes I was being shown is through my Google Bookmarks, where I have a category labelled by her name, containing a bunch of different recipe bookmarks. Is there currently an algorithm for finding links between my bookmarks and the types of ads I am shown in my G-Mail account? Surely the use of my personal information in this way is just a little out of order.
I'm so happy with G-Mail and the other Google apps that I don't really feel this is a big enough problem to stop using them, but it does certainly weaken my opinion of Google as an organisation, which was not particularly positive in the first place. It should serve as a warning to those who think they can trust Google to log their search history, bookmarks and emails and respect their privacy at the same time.
Link to This Article |
Comments (0)
Tags:
Google, Privacy, Rant
Passwordless SSH On Your iPhone or iPod Touch
Since I've been spending more time in Linux, I've found it necessary to be able to sync my iPod Touch within Linux. Amarok has some fantastic configurability for devices you want to sync with, but since iPod Touch support is not complete at the moment, there's a little work to fill in.
If you've tried following Fred Emmotts handy tutorial for syncing an iPod Touch with Amarok, you may have run into the same issue that I did with trying to enable passwordless SSH authentication. So ignore what everyone else says, here's the quick and dirty way to get your iPhone/iPod Touch working with passwordless SSH. Please note that this will make your iPhone/iPod very insecure, since you're using SSH with a widely known username/password combo and ignoring some of the critical security checks.
Oh yeah, you're going to need a Unix-like environment with OpenSSH installed for this to make sense and actually work.
1. Jailbreak your iPod Touch. This step is easy and there are tonnes of other guides around so I'll assume you can do this. I'm running 1.1.1 jailbroken, but it really doesn't matter.
2. Install the OpenSSH package in AppTapp and its dependencies. Once its installed, try connecting from your client machine (throughout this article when I say "client machine" I mean the computer you are accessing the iPod from) with the following:
ssh root@[your ipod's ip address]
You can find the IP address in the WiFi settings by selecting the arrow next to your connected AP. When requested for a password, enter "alpine". This may take a while to connect for the first time while your iPod (very slowly) generates RSA keys.
3. Once you are logged in over SSH you will need t configure SSH for using RSA authentication, so type the following:
vim /etc/sshd_config
You will see the configuration file appear. From here, you need to change two settings so that your config file looks something like:
PubkeyAuthentication yes
StrictModes no
It is vital that you set StrictModes to "no". This option is not in the config file shipped with OpenSSH, so you'll need to add it. This is where I got stuck and where most of the tutorials around will not help you out. StrictModes on "no" is a far less secure option, but remember: you have just enabled SSH over WiFi with root access and a root password that every man and his dog knows. You are not concerned with security at this stage. If you're worried, grab BossPrefs in AppTapp and turn of SSH when you don't need it.
6. At this stage, its a good idea to restart sshd to enable the configuration file's changes to kick in. There are a dozen ways to do this, but if you're into GUIs (I am), BossPrefs or uictl (both available through AppTapp) will do the job nicely. If you don't have these, just turn the iPod off and on again.
5. Now log out of SSH on your iPod (or maybe you got dropped when your restarted SSH; that doesn't matter). We're going to generate a public RSA key to give to your iPod so that it will authenticate you in the future. On your client machine type the following command:
ssh-keygen -t rsa
This will generate some key files in the home directory of the current user, under .ssh. Just press enter for every prompt that ssh-keygen throws up and you'll be fine - the defaults are what we want here (indicated by brackets after the prompt).
6. Still on the client machine here, you want to type the following command:
ssh-copy-id -i ~/.ssh/id_rsa.pub root@[your ipod's ip address]
Again, obviously you want to replace with your iPod's IP address, which you of course found out earlier. The password here is the same as before: "alpine".
7. And that's it! ssh-copy-id has copied the key for you to /var/root/.ssh/authorized_keys on your iPod and now when you try to SSH in (from the same machine you used ssh-keygen on, that is) using the same command from step 2, you will no longer be asked for a password. If you want to enable passwordless authentication on multiple machines, you just need to repeat steps 5 and 6 on the machines in question.
I hope that fills in the blanks for some of you. I'm not a total Linux newbie, but I find it very difficult to follow tutorials which assume you have experience with something like SSH configuration and the like, when you don't. If everything went well in this tutorial, you're now free to keep following Fred Emmotts iPod and Amarok sync tutorial and you now have passwordless SSH, not to mention being able to wirelesly sync with your iPod - ask your Windows and MacOS-using friends if they can do that.
Link to This Article |
Comments (0)
Tags:
iPod Touch, iPhone, Linux, SSH
PHP and Plesk "Access Denied" Error With Exec()
I've finally come to the end of days of torture trying to get my PHP executable to work on a Plesk-based VPS. Every call to exec would produce "Access Dendied" errors to be dumped, while the permissions seemed perfectly ok (effective permissions showed no sign of trouble). Ultimately - and this is a plesk-specific solution, although parts are relevant to any Windows Server-based PHP environment - the problem was that the C:\ drive's permissions had the "psacln" user group set to "Deny" for "Special Permissions", which was overriding any permissions set elsewhere. This was not indicated when trying to show "effective permissions" so it was hard to track down. Here is the checklist I have developed for making sure everything will go well:
1. Make sure that the Plesk IIS user as permission on the executable and its parent directory. Unlike normal IIS settings, plesk makes a new user for each internal "domain". The template is: IUSR_. Make sure that this user has "execute" permissions on the file and its parent directory. Adding IUSR_ will not work for Plesk-based systems.
2. Make sure to check the directories all the way up your directory tree to see if their permissions are overriding your permissions lower down. This is what got me. Right click "C:\" drive (or whatever your root drive is) and click Security and make sure that there are no "Deny" settings (under "Advanced") for your plesk IUSR or any of its groups ("psacln" was the main one on mine).
3. Make sure to check under "Start > Administrative Tools > Local Security Policy > Local Policies > User Rights Assignment" that the IUSR or its group is in the "Log on as batch job"policy.
After doing all these things - and hours upon hours of pain - I have finally managed to get this working. Thanks to Zack / Nog on the "exec" comments for the suggestion to check permissions on the root drive (but makes sure to check for your user's groups as well).
Link to This Article |
Comments (0)
Tags:
PHP, Plesk, Errors
iTunes Files Mysteriously Disappearing
Over the past month or so, I've been extremenly frustrated to find around 200 songs in my carefully assembled MP3 library go missing from iTunes. This happened after I tried to rebuild my library from scratch trying to fix a problem my iPod seems to have developed - but that's another story. While, fortunately, I had a backup of the missing files, I suddenly found that I couldn't add them to iTunes. Add through the menu? nothing happens. Drag and drop? Nothing happens. Thanks to the fact that Apple programs "don't get those cryptic error messages" I had absolutely no idea why this was happening (thanks, Apple, really helpful). It could just be me, but honestly I think that users would light a slight inkling of what went wrong rather than a stoney silence (thats not user friendliness, Steve).
Anyway, after wracking my brains and Google, I decided there must be a problem with the structure of the file. Windows Media Player was playing the files back fine, as was everything else, so apparently there was something going on with iTunes and the file structure So now that I've re-written the tags (using a little ruby script I put together with id3lib) and compared the files, I've found out the problem: Windows Media Player seems to have added a second ID3 section a short distance after the first one in the structure of the file. I have no idea why this is - maybe they're trying to break itunes deliberately - but removing the second ID3 section (which, by the way, won't result in a loss of any of your precious ID3 tags) from the file seems to fix the problem.
The easiest way to fix all this mess is to re-write the ID3 tags on the corrupted files using a program which won't try to preserve the Media Player section. By reading the tags in with Ruby's id3lib and simply re-writing them (no change required) you can easily fix the files and get your MP3 library back on track. Another option is to use a batch tagging program to do the re-writing, but I was feeling adventurous and I don't trust batch programs to not mess things up even more.
So I guess this has two lessons. The first is that iTunes and Windows Media Player should not be both allowed to manage your music collection. I had Media Player on the job for a short time so that I could stream to my X-Box 360 (I now use TVersity) and I don't reccomend it. Media Player's even worse than iTunes as a music library manager, so stay away! The other less ons it always back up. My music library is huge and has taken years to assemble. It contains vast numbers of CDs from my own collection that I've ripped as well as friends CDs and iTunes music store purchases. I'm very glad I don't have to rebuild that.
If you've had the same problem as me and are hungry for a fix, try dropping me an email and I'll give you the script I wrote to fix my problem. I don't want to post it up here due to its specific nature and because I don't want to be responsible for deleting your music library by accident.
Link to This Article |
Comments (0)
Tags:
iTunes, Apple, Bugs
PHP system() calls result in CGI Error on IIS
Writing a custom executable for a client earlier this month, I encountered an issue with calling it from within a PHP script on IIS running PHP 5.2. Every time the page was accessed, we would get an error page saying something along the lines of "The CGI application did not return a complete set of headers". This is of no help to anyone and since it was coming up on a remotely hosted server I had no real way to check the logs or investigate easily. While trolling along on Google, I managed to locate references to the exact problem in the PHP bug list. In a series of comments, the problem is eventually solved by piecing together bits of information from a couple of users. To clarify: this is not a PHP bug, it is an IIS bug. The knowledgebase article for IIS is here. It is suggested that a patch to fix the issue has been released but for those of us who share hosting, the luxury of applying patches does not exist (and nor should it). Fortunately, there is a simple workaround, kindly hinted at but not completely correctly stated by dan at hostway dot nl in the bug's comment posts.
He's right - returning a MIME header will fix the problem - but not completely right. You can return any header or none at all if you like, since PHP automatically generates most of the headers for you. What you actually need to do is make sure that before you make the call to "system", "shell_exec" or "`" (backtick operator) you must flush at least some of the final output of the page. The problem seems to be that executing an external command takes too long and since PHP has not yet returned anything to IIS, IIS assumes that it is broken and cuts off its execution, displaying the error I mentioned. Another user on the bug discussion also suggests that it only becomes an issue when the execution of the command fails (i.e. access denied, invalid command), but I have found that this is not the case. So, to fix the probem, all you really need to do is call flush before issuing the system command, as shown in this example:
header("Content-Type: text/html");
flush();
// Any system calls can be made below this point without problems
// (these are just examples)
system(`tasklist | find "IIS"`);
`tasklist | find "PHP"`;
shell_exec("dir");
?>
Its as simple as that. Just make sure that some output has been recieved by IIS before you start an intensive process like a system call and there should be no issues. You can then execute the program and show its output later. The only thing you can't do is redirect after this, since the headers will have already been sent. Rememer: just making a call to header won't always work, since PHPs internal buffering may result in the headers being held onto. To be sure, always explicitly call flush.
Link to This Article |
Comments (0)
Tags:
IIS, Windows Server, WIMP, PHP, Errors, Bugs, Hacks






