One thing that isn't crystal clear, is: do rogues get sneak attack damage against their ally if they miss their foe with a ranged weapon within 30'?
Grappled foes (and allies) lose their dex bonus to AC. Ranged attacks against grappled foes roll randomly to determine who is targeted. This *almost* sounds like concealment, which would render sneak attack useless (but it's NOT concealment). I've heard arguments that state that the "target" is the foe, and since the ally is not the target (in relation to the rogue), then sneak attack would not apply. Also, "deadly accuracy" that is mentioned sounds like aiming...and you're aiming at your foe, not your ally.
So, what do you think is the letter of the law here? I think the above reasons are not good enough to rule sneak attack would only apply to your foe, or "intended" target. Personally though, I might house rule that it is concealment, and allow no sneak attack on either foe. Note, that this SHOULD be cover (since it is a physical obstacle), but since they already used a rule that incorporates a concealment-like aspect, I chose to just add to that existing rule. As for what's official, I like the idea that a rogue firing at a foe who is grappling with his buddy, might just tag his friend but good. It SHOULD be dangerous to do something like that. But, I'd like to see what others have to say about this.