zobie's blog I create software, I like music, and I'm mildly(?) OCD.

11May/09

Changing the default shell on iPhone

I wanted to change the default shell on my iPhone. Unfortunately chsh wasn't available.

[10:40][root@iPhone:~]$ chsh
-bash: chsh: command not found

I next thought to modify /etc/passwd but, according to the file's header, that's not going to help.

[10:41][root@iPhone:~]$ cat /etc/passwd 
#
# 4.3BSD-compatable User Database
#
# Note that this file is not consulted for login.
# It only exisits for compatability with 4.3BSD utilities.
#
# This file is automatically re-written by various system utilities.
# Do not edit this file.  Changes will be lost.
#
nobody:*:-2:-2:Unprivileged User:/var/empty:/usr/bin/false
root:*:0:0:System Administrator:/var/root:/bin/sh
mobile:*:501:501:Mobile User:/var/mobile:/bin/sh
daemon:*:1:1:System Services:/var/root:/usr/bin/false
_securityd:*:64:64:securityd:/var/empty:/usr/bin/false
_mdnsresponder:*:65:65:mDNSResponder:/var/empty:/usr/bin/false
_sshd:*:75:75:sshd Privilege separation:/var/empty:/usr/bin/false
_unknown:*:99:99:Unknown User:/var/empty:/usr/bin/false

Finally I found /etc/master.passwd. I just modified root and mobile to use /bin/bash instead of /bin/sh and on my next login I was using bash!

[10:41][root@iPhone:~]$ cat /etc/master.passwd 
##
# User Database
# 
# This file is the authoritative user database.
##
nobody:*:-2:-2::0:0:Unprivileged User:/var/empty:/usr/bin/false
root:5IS3K.2i/ciLw:0:0::0:0:System Administrator:/var/root:/bin/bash
mobile:NhbBgPU3IOnek:501:501::0:0:Mobile User:/var/mobile:/bin/bash
daemon:*:1:1::0:0:System Services:/var/root:/usr/bin/false
_securityd:*:64:64::0:0:securityd:/var/empty:/usr/bin/false
_mdnsresponder:*:65:65::0:0:mDNSResponder:/var/empty:/usr/bin/false
_sshd:*:75:75::0:0:sshd Privilege separation:/var/empty:/usr/bin/false
_unknown:*:99:99::0:0:Unknown User:/var/empty:/usr/bin/false
Tagged as: , Comments Off
23Mar/09

Strange Crash in OS X: securityd

A few days ago my Mac started having problems. I would be in the middle of some task when it would suddenly refuse to launch any new applications. Whenever I tried to launch any app, it would bounce a few times in the dock then exit.

As far as I could tell, any apps that were running when I got into this problem state would continue working fine. The OS would never completely freeze but I noticed that my CPU started being monopolized by CrashReporter. I tried killing that process but it would just immediately relaunch and peg the CPU again. I looked inside /Library/Logs/CrashReporter/ and saw that a new crash log was being created about every three seconds. The crash logs were for many different applications but none of the stack traces was useful. I had trouble spotting a pattern to what might trigger the problem.

Once my box was in the bad state I tried to ssh in to see if I could gather any useful information. SSH would prompt me for a password but it always denied access saying that I had entered an invalid password.

The only way out of this state was to restart the machine. When I tried to reboot, OS X would successfully log out but then get stuck on a blue screen. I would see the indeterminate NSProgressIndicator for a few seconds then it would disappear for a few seconds then come back again. I was forced to power cycle the machine.

I finally noticed that when this problem occurred, the first crash log was always for securityd. /Library/Logs/CrashReporter/securityd_2009-03-23-204700_macpro.crash:

Process:         securityd [22]
Path:            /usr/sbin/securityd
Identifier:      securityd
Version:         ??? (???)
Code Type:       X86 (Native)
Parent Process:  launchd [1]
 
Date/Time:       2009-03-23 20:47:00.211 -0600
OS Version:      Mac OS X 10.5.6 (9G55)
Report Version:  6
 
Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
Exception Codes: KERN_INVALID_ADDRESS at 0x0000000001000000
Crashed Thread:  0

This information finally led me to the solution.

The problem was that securityd would crash then any app that needed to authenticate was unable to do so. One newsgroup noted that the problem could be temporarily solved by relaunching the process:

$ launchctl load /System/Library/LaunchDaemons/com.apple.securityd.plist

After a bit more searching I found a permanent answer in a mailing list archive: Keychain access crashing on SecKeychainFindGenericPassword. The solution was incredibly simple (and completely unintuitive). I had to remove the file /var/db/CodeEquivalenceDatabase and reboot. That's it!

The thread offers more details but basically, "that file [/var/db/CodeEquivalenceDatabase] has gotten corrupted and runs securityd into an endless memory-eating loop that (usually) ends up running your system out of memory and into the ground."

22Jan/09

Seriously? Microsoft defends return to DRM

When I read "Microsoft defends return to DRM" I honestly thought the article was going to be a parody. As far as I'm concerned there are only two possible outcomes when sticking DRM on music:

  1. Your customers understand DRM and are frustrated because they have to waste time getting around the "protection."
  2. Your customers don't understand DRM and are mad because their music doesn't work the way it should.

But as far as I can tell the article is legit. The answers were given by Hugh Griffiths, Head of Mobile at Microsoft UK. In retrospect he probably wishes that he had referred the interviewer to someone in the PR department.

Most surprisingly, Mr. Griffiths makes absolutely no attempt to spin DRM as being beneficial or to try to justify its use. You might want to read the full article, these are just a few things that jumped out at me.

Why has Microsoft gone back to DRM when the vast majority of music services have ditched it?

It's a first step.

Translation: We've always been extremely forthright about our intentions to gain monopoly power over every aspect of your digital life. This plays a small part in that larger initiative.

[Customers] certainly tell us that they like listening to music while they are out and about, on their mobile phones.

Translation: Everyone listens to music on iPods and we're not making any money from that.

What is your message to consumers - why should I come to you instead of Amazon or iTunes? What do you offer that none of your competitors do?

There's a whole bunch of people who are very loyal to MSN on the web...

Translation: Being a monopoly has provided us with a butt-load of customers, most of whom aren't savvy enough to realize that there are options.

The fee for downloading tracks - £1.50 - is relatively high compared to 79p on iTunes and less than that on certain Amazon tracks. Why is that?

We're constantly reviewing our pricing and if we feel this price point is incorrect, we'll look to amend it.

Translation: I just told you, our customers are du-umb! I'm pretty sure that we're going to raise the price to £3.00 after the first couple of weeks. We'll just explain that we need to charge more to cover the cost of... something. Our customers genuinely appreciate the opportunity to pay a premium.

If I buy these songs on your service - and they're locked to my phone - what happens when I upgrade my phone in six months' time?

Well, I think you know the answer to that.

Translation: Yeah, we're screwing our customers. So what? I buy all my music from Amazon so it really doesn't affect me.

Seriously Microsoft? Seriously?

16Jan/09

So, you want to work for a startup?

I recently came across an interesting quote:

The first thing that one needs to know when joining a startup is to understand how they work... make sure you understand what you are getting into. Here are some things to consider

  • startups are not for the faint hearted
  • startups are not a "get rich quick" scheme
  • startups require sacrifices from everyone including you the candidate (pay/effort/etc)
  • if you put your heart & soul and are part of the right team there is good chance you will succeed
  • success is not guaranteed, it has to be achieved!
  • remember its a journey, so if you are thinking about jumping ship often - dont even bother!
  • startups are a small community and if you play dirty the word WILL get around

Taazza newsroom, January 6, 2009

Some time ago I made an important discovery about myself: I love startups. I thrive in these fast paced environments. To me, participating in the design of a new product and creating the first iterations of the software is like a fix to a junkie. Working with new, cutting-edge technologies is exciting to me. It is exhilarating to interact with other intelligent people when we are all passionately fixated on achieving our mutual goal. It's awesome!

All that said, working at a startup company is definitely not for everyone. Be prepared for a few ups and a whole lot of downs. Be prepared to bet against the odds. It's fun to dream about a huge IPO but if that's your sole focus...

I'm not going to deny that a large payout would be great. But in the meantime, I'm content to enjoy the adventure. You should checkout the full article.

14Jan/09

What’s so great about git?

Over the last few days, I have been asked several times why I like git. Many explanations and detailed comparisons exist that discuss how git compares to other version control systems. I'm not going to try and duplicate any of that work. These are just some thoughts about features in git that allow me to work more productively.

I didn't immediately grok git because it is fundamentally different from subversion. Subversion tracks the history of files whereas Git tracks the history of content. That difference may seem minor, but the shift brings a lot of flexibility. You can expect a small learning curve, but don't give up! If git works as well for you as it does for me, you will not want to go back to subversion.

So, what are my favorite things about git?

  • Branching: Coming from a CVS/SVN background, I didn't think git's "cheap branching" would matter to me. I am not exaggerating when I say that it has dramatically changed the way I work. Because branching and merging are so easy, I create a new branch for each feature or bug I'm working on. I am never tempted to check in broken code just because I want a checkpoint.
  • The index: It is really nice to be able to just check in a portion of the changes in my code rather than having to commit the entire file.
  • git stash: If I'm in the middle of some big change and need to fix a small bug, I can hide my outstanding changes, make the fix and restore my changes without a checkin.
  • git rebase: Sometimes it is really handy to be able to rewrite history.
  • Git is a DVCS: My work isn't crippled when I am not connected to the network. I can check code in and out. I can branch and merge. I have a full history of the repository. Awesome!
  • Very flexible workflow: With git I can push/pull to a central server like CVS or SVN. Alternatively, changes can bypass the server and be sent directly between working repositories.
  • Git is fast: Neither CVS nor SVN come close to git's speed.

Is git perfect? No. Off the top of my head, here are some things that I would really like to have in git:

  • git checkout -i: Sometimes I want to rollback a few changes in a file. I imagine this would work very similarly to 'git add -i'.
  • git stash -i: Sometimes I only want to stash some of my changes. This too would work like 'git add -i'.
  • Local tags: Local branches are great; local tagging would be too.
  • Track empty directories: I understand why this doesn't currently happen, but it can be obnoxious.
  • Comments on branches: It is easy to make a lot of branches but unless your branch names are super descriptive (and therefore super long), it is also easy to forget what each of them is for.
  • Better/more documentation: In general I am able to find what I'm looking for, but I still don't know what the "fetch-all" in git svn fetch --fetch-all actually does.
  • Windows support: Not that I've actually tried it, I've just heard that it doesn't work well.
  • GUI options: Most of the time I work in the cli but sometimes a gui is more convienent. I've heard multiple people ask for a tool that would allow them to branch and tag without checking out code. gitk and gitx just don't offer all the flexibility that some other tools do (e.g. WinCVS, SmartSVN, TortoiseSVN, etc.).

Why do you like (or hate) git?