The only solution is to reboot the system from another source, then edit the password file to correct this problem. Invoke sync(1M) several times, then halt the machine by typing Stop-A or by pressing the reset button. Reboot as single-user from CD-ROM, the net, or diskette, such as by typing boot cdrom -s at the prompt.
After the system starts and gives you a # prompt, mount the device corresponding to the original root partition somewhere, such as with a mount(1M) command similar to the one that follows. Then run an editor on the newly mounted system password file (use ed(1) if terminal support is lacking):
# mount /dev/dsk/c0t3d0s0 /mnt # ed /mnt/etc/passwd