Excerpt from Las Vegas FSDO:
http://www.awp.faa.gov/new/fsdo/las_vegas/art_pilot.htm
Normally, a safety pilot, required by regulations, who scans for traffic for a pilot flying under simulated instrument conditions is not pilot-in-command and thus logs second-in-command. However, if the two pilots agree that the safety pilot is designated pilot-in-command, the safety pilot/pilot-in-command may log PIC since he is the pilot responsible for the operation and safety of the aircraft. The pilot flying is "sole manipulator of the controls for which the pilot is rated"" and may also log PIC. Therefore, two private pilots may log PIC under these conditions. However, the safety pilot/pilot-in-command must realize that anything that occurs during the flight is his responsibility. Airspace violations, non-compliance with ATC instructions, near mid air collision, and runway incursions on the ground are all now charged to the safety pilot. A recent article in a monthly aviation publications discussed a flight where there was a violation and the two pilots disagreed who was pilot-in-command.
However, two pilots may not simultaneously log PIC when one pilot is sole manipulator of the controls and the other is acting as pilot-in-command if the regulations governing the flight do not require more than one pilot.
"An airline transport pilot may log as PIC time all of the flight time while acting as pilot-in-command of an operation requiring an airline transport certificate." [61.51 (e)(2)] Previous regulations allowed a situation where three pilot (one an ATP) could log PIC simultaneously when conducting an operation which did not require an airline transport pilot. This is no longer allowed under the August 1997 revision.
A flight instructor may log PIC "while acting as a authorized instructor". No change to previous regulations.
A student pilot can now log PIC. That’s new, and since there is no restriction, your logbook can be updated so that all student solo time prior to August 4, 1997 may be logged as PIC. When an instructor is aboard, since the student is not rated in the aircraft, flight instruction is still logged as dual not PIC.
Then there are some unusual situations which occur. A private pilot flying with his friend (a CFI or ATP) aboard as a passenger. What is the status of the CFI or ATP who is obviously a more senior pilot with more experience than the private pilot? The regulations don’t address this situation, but the courts may find that the more senior pilot has some or all the responsibility for the operation or safety of the flight.
In summary, the person who is pilot-in-command may log PIC, others may also log PIC depending in the circumstances