Apple is justifiably puzzled by this apparent incongruity in the grammar rules. Because no grammar books that I know of treat this issue, it remains a mystery to teachers and students alike. The explanation is a bit complex, but I'll try to make it as clear as possible.
The direct question
(1) Who is he?
...has two noun phrases (here, pronouns): one that is known ("he") and one that is unknown ("who"). When the question is converted to a subordinate clause, the word order of the verb and the grammatical subject is statement order:
(2) We cannot tell who he is
The grammatical subject is "he." "Who" is the subject complement. So far, so good. The unknown item is "who" and the known item is "he". 'He" is the person we are referring to.
Now let's look at
(4) In those days, we could not tell who was a friend and who was an enemy.
Here we have the verb before the second noun phrase, in the same order as the direct question. What's different?
In (4) we don't have any "known" item. There is no noun phrase (like "he") to refer to. The "who" is unknown, and the noun phrases "a friend" and "an enemy" are also unknown. "Who" is the grammatical subject of the subordinate clause, not the subject complement as in (2).
"Who"in (4) means "which person among the group of potential friends or enemies." The sentence means
In those days we could not tell which person [among the set of potential friends or enemies] was a friend and which person [among the group of potential friends or enemies] was an enemy
The information "was a friend" and "was an enemy" is "new" information. It is the predication--what is said, or predicated, about the grammatical subject.
All right, I told you it was complex (it took me a long time to work it out some years ago). Is it clear now? If not, I'll make another attempt.
This kind of question is subtle but important, and it's good to have an answer for inquisitive students.