(a) Except as provided in subsection (d), whoever knowingly possesses or causes to be present a firearm or other dangerous weapon in a Federal facility (other than a Federal court facility), or attempts to do so, shall be fined under this title or imprisoned not more than 1 year, or both.
(b) Whoever, with intent that a firearm or other dangerous weapon be used in the commission of a crime, knowingly possesses or causes to be present such firearm or dangerous weapon in a Federal facility, or attempts to do so, shall be fined under this title or imprisoned not more than 5 years, or both.
(c) A person who kills any person in the course of a violation of subsection (a) or (b), or in the course of an attack on a Federal facility involving the use of a firearm or other dangerous weapon, or attempts or conspires to do such an act, shall be punished as provided in sections 1111, 1112, 1113, and 1117.
(d) Subsection (a) shall not apply to—
(1) the lawful performance of official duties by an officer, agent, or employee of the United States, a State, or a political subdivision thereof, who is authorized by law to engage in or supervise the prevention, detection, investigation, or prosecution of any violation of law;
(2) the possession of a firearm or other dangerous weapon by a Federal official or a member of the Armed Forces if such possession is authorized by law; or
(3) the lawful carrying of firearms or other dangerous weapons in a Federal facility incident to hunting or other lawful purposes.
(e)
(1) Except as provided in paragraph (2), whoever knowingly possesses or causes to be present a firearm or other dangerous weapon in a Federal court facility, or attempts to do so, shall be fined under this title, imprisoned not more than 2 years, or both.
(2) Paragraph (1) shall not apply to conduct which is described in paragraph (1) or (2) of subsection (d).
(f) Nothing in this section limits the power of a court of the United States to punish for contempt or to promulgate rules or orders regulating, restricting, or prohibiting the possession of weapons within any building housing such court or any of its proceedings, or upon any grounds appurtenant to such building.
(g) As used in this section:
(1) The term "Federal facility" means a building or part thereof owned or leased by the Federal Government, where Federal employees are regularly present for the purpose of performing their official duties.
(2) The term "dangerous weapon" means a weapon, device, instrument, material, or substance, animate or inanimate, that is used for, or is readily capable of, causing death or serious bodily injury, except that such term does not include a pocket knife with a blade of less than 21/2 inches in length.
(3) The term "Federal court facility" means the courtroom, judges’ chambers, witness rooms, jury deliberation rooms, attorney conference rooms, prisoner holding cells, offices of the court clerks, the United States attorney, and the United States marshal, probation and parole offices, and adjoining corridors of any court of the United States.
(h) Notice of the provisions of subsections (a) and (b) shall be posted conspicuously at each public entrance to each Federal facility, and notice of subsection (e) shall be posted conspicuously at each public entrance to each Federal court facility, and no person shall be convicted of an offense under subsection (a) or (e) with respect to a Federal facility if such notice is not so posted at such facility, unless such person had actual notice of subsection (a) or (e), as the case may be.