The Diet enacted a bill Wednesday that allows security guards to carry rifles aboard Japan-registered vessels to counter piracy off Somalia and elsewhere.