Moed Katan, Chapter Three, Mishnah One
Generally speaking one may not cut ones hair/shave during the festival. This is not because cutting hair was a lot of work. Rather it was to encourage people to get a hair cut and shave before the festival, so that they would be properly groomed when the festival began. In other words, if you dont prepare before the festival, youre going to look disheveled the whole time.
Our mishnah lists the exceptions to this rulethose people who may get a haircut during the festival because they could not do so during the week before.
When the mishnah speaks of cutting ones hair, it also includes shaving (they would shave with scissors). There is no halakhic difference between the two. I have translated the verb that the mishnah uses as shaving.
1) And these may shave during the festival: one coming back from a trip abroad, or one coming out from a place of captivity, or coming out of prison, or one excommunicated whom the sages have released.
2) And similarly one who asked a sage [to be released from a vow] and was released, and a nazirite or a leper on emerging from his state of impurity to his state of purification.
Section one: The people in this section could not cut their hair the week before the festival for various practical reasons. 1) They came back from a trip abroad, from a place where shaving was not possible. 2) They came out of captivity, and while captives they couldnt shave. 3) They came out of prisonno cutting hair in prison. 4) They were excommunicated. A person excommunicated by the Jewish community may not shave or cut his hair until he is released from his excommunication. If any of these people did not have enough time to cut his hair before the festival, he may do so during the festival. On the other hand, if he had time to prepare for the festival and neglected to do so, then he is penalized for his lack of preparation.
Section two: The people in this section could not shave for religious reasons. 1) The person had taken a vow not to cut his hair. Only a sage can release someone from a vow. If the person could not find a sage who would release his vow before the festival and then found one during the festival, he is allowed to shave during the festival.
When a nazirite completes his term of naziriteship and when a leper becomes pure from his leprosy they both undergo a ritual which includes cutting ones hair and shaving. If the term of naziriteship is over during the festival or a lepers period of impurity is completed during the festival they may shave and cut their hair then.