Possibly it's an issue with the keyboard?
I'm thinking something like a spilled drink is making a partial connection so the controller thinks the power button is getting hit. This may be something that Ubuntu won't notice (since it's not part of the standard keyboard), but if you tap the power button under OS X it'll pull up the shutdown prompt
The thing is, it's not random. I haven't timed it, but it's got to be about roughly about a minute or two, and it's consistently exactly that amount of time. And, as I've said, it's directly tied to inactivity. Use the touchpad or press a key and it doesn't happen. Why would a partial connection exhibit such regularity? Also, I thought about the scenario you mentioned, so I deliberately hit the power button in Ubuntu. A shutdown dialog came up just fine.
Obviously I can't know that it isn't sort some of strange hardware issue, I just put that disclaimer in the title so people would look at this more closely because it defies all my assumptions.
I have some expertise with broken Macbooks and yours certainly sounds like a hardware issue. Keyboard might be the culprit here as previous poster said. You may need to obtain another for testing and try a swap. OS X is quite picky about hardware on many levels but blatant bugs in code like that are fairly rare so chances are it thinks something is happening that either does not or should not.
Yeah, again I was probably a little extreme. As I said, even the Mac OS DVD does this, so clearly something is wrong with my laptop. Clearly the upper case is the place to start, I was more wondering if anyone had ever seen something like this.
I'll revise my title.