There is nothing wrong with working as a train driver in a foreign country
Praise be to Allah
There is nothing at all wrong with you working as a train driver in a non-Muslim country, and we do not think that there are any reservations about such work that would require you to refrain from doing this job. Rather it is lawful provision, by Allah’s leave, for several reasons:
The contract between you and the train company only has to do with driving, and not with carrying or transporting prohibited items. What matters with regard to contracts – from a shar‘i ruling perspective – is what is mentioned in specific terms in the contract, which in this case is entirely permissible work, namely driving the trains.
With regard to the curse on the one who carries alcohol, what is meant is one who deliberately carries it and benefits from doing that, to help the one who drinks it. All of these conditions are not applicable in the case of driving trains or flying aeroplanes.
Seeing that the purpose of your work, according to the clauses of your contract, is permissible, you are not responsible for asking passengers about what they may be carrying, or to examine the goods that they are carrying with them. You are not expected to ask them about that, because what is being transported here is people; whatever they are carrying, especially whatever is hidden or concealed of that, is a secondary matter, that is not subject to any shar‘i ruling. Otherwise, people would go through a great deal of hardship if every taxi driver – even in Muslim countries – had to ask anyone who wants to ride with him about everything he is carrying, for fear that he may have with him some cigarettes, for example, or some prohibited material that is commonly found on smart phones nowadays, and other similar scenarios where it could be very difficult if sharee‘ah were to require that. Rather, if we were to require this burdensome duty of train drivers, pilots and taxi drivers, then we would also have to require them to ask everyone about the destination to which he is headed and the purpose for that journey, so that if it was for unlawful purposes he would refuse to drive or fly the plane in that case. We do not believe that anyone would hesitate to regard such requirements as inappropriate, which indicates that this requirement itself is also invalid and there is no need for all that. This confirms that sharee‘ah could not have enjoined any such hardship so long as the nature of the job in question – namely driving – is permissible in principle, praise be to Allah.
You mentioned in your question that you do not know what the train passengers are carrying, the reason being that the driver is usually separated from the passengers in a compartment in the front carriage, which makes it difficult for the driver to know what passengers are carrying, especially when it is in closed bags. Therefore there is no requirement or obligation concerning this issue in particular.
If we reflect upon the fiqhi principle on which there is consensus in general, that “a secondary matter may be overlooked where a primary matter could not be overlooked,” this reinforces what we said about the ruling which says that it is permissible. That is because the issue of prohibited items that some people may carry is a secondary matter and is not intended as part of the job description (of a train driver), and a secondary matter may be overlooked if the primary matter is permissible. The primary matter in this case is the transportation of people and what they may be carrying of personal items.
The fuqaha’ expressed this principle in many ways, some of which are more directly connected to the question in this case, such as the view of Imam as-Sarkhasi (may Allah have mercy on him): It may be permissible to include in a contract that which may not be permissible if it were the main focus of the contract.
End quote from al-Mabsoot (11/179).
And al-Qadoori said: Something may be included as a secondary matter pertaining to a contract that cannot be made the main focus of a contract.
End quote from at-Tajreed (8/3792).
Imam as-Suyooti (may Allah have mercy on him) said: Anything may be overlooked if it is something implicit and secondary that may not be overlooked if it is the main focus of a contract.
End quote from al-Ashbaah wa’n-Nazaa’ir (p. 120). See also: Haashiyat al-‘Attaar ‘ala Sharh al-Jalaal al-Muhalli ‘ala Jam‘ al-Jawaami‘ (2/160); Mu‘allimah Zaayid li’l-Qawaa‘id al-Fiqhiyyah wa’l-Usooliyyah (11/531).
The example mentioned by the fuqaha’ is the permissibility of renting out something to someone who will use it for a permissible purpose, as in the case of a Christian who rents a house from a Muslim to live in it, but he may commit some unlawful deeds in his house as a secondary matter, not as the purpose for renting the house. This may be overlooked, and there is no sin on the one who rents out the house; rather the sin is only on the renter, and the one who rents it to him has the right to stop him doing that if he comes to know of it, as was stated by the Hanbalis.
Imam Muhammad ibn al-Hasan ash-Shaybaani (may Allah have mercy on him) said:
If a dhimmi (non-Muslim living under Muslim rule) rents a house to live in, there is nothing wrong with that. But then if he drinks alcohol in that house, or he worships the cross, or raises pigs there, there is no sin on the Muslim for that, because he did not rent it out for that purpose.
End quote from al-Asl (4/17).
None of the scholars – as far as we know – ever said that it is prohibited to rent out permissible things for permissible purposes, as stated in the contract, for fear that the renter might use the rented thing – occasionally and as a secondary activity, and not as the primary purpose of the rental – for some unlawful purpose. If anyone said that, it would cause a great deal of hardship to people.
What is mentioned in the question comes under this exact category. There is no blame on the driver of any means of transportation; rather the sin is on the one who carries or transports the unlawful item, or commits the unlawful deed.
The scholars are unanimously agreed that whatever could be an indirect means to something unlawful, we are not required to block those means, so that this will not cause hardship in other aspects of life. For example, they said that it is not permissible to say that it is prohibited to cultivate grapes in general, even though cultivating grapes will undoubtedly lead to the making of wine, but that is an indirect outcome, and grapes are usually grown for permissible purposes, namely to supply them to people who want to eat grapes in a permissible way. In such cases the rule of blocking means that may lead to evil is not applicable.
Imam al-Qarraafi (may Allah have mercy on him) said:
The ummah is unanimously agreed that there are cases where the means are not to be blocked if they may indirectly lead to something evil, and he gave examples of that: the cultivation of grapes is a means that leads to producing wine, but no one says that it should be disallowed for fear of producing wine.
End quote from al-Furooq (2/42).
Similarly, in the case under discussion here, forbidding people to drive public transportation for fear of what “some” passengers “may” be carrying of unlawful items – whether that is alcohol and the like – would cause people a great deal of hardship in their daily lives, and would deprive them of permissible means of earning a living, with no clear reason.
There is nothing wrong with working as a train driver in a non-Muslim country, unless there is specific mention in the contract of carrying some unlawful things, in which case it is forbidden to be party to a contract that specifically mentions certain unlawful items to be transported.
And Allah knows best.