Process substitution <(…)
creates a pipe, uses /dev/fd
to give a path that's equivalent to the file descriptor where the pipe is, and passes the file name as an argument to the program. Here the program is sudo
, and it passes that argument (which is just a string, as far as it's concerned) to wpa_supplicant
, which treats it as a file name.
The problem is that sudo closes all file descriptors except for the standard ones (stdin=0, stdout=1 and stderr=2). The pipe of the process substitution is on another descriptor, which gets closed, so when wpa_supplicant
tries to open it, it finds a file that doesn't exist.
If your sudo policy allows it (closefrom_override
option enabled), you can tell it not to close file descriptors. But this is usually not the case.
sudo -C 64 wpa_supplicant … -c <(wpa_passphrase …)
Alternatively, since you aren't using standard input, pass the data there.
wpa_passphrase … | sudo wpa_supplicant … -c /dev/stdin
Alternatively, run a shell from sudo and put the process substitution there. Take care with quoting if the command contains special characters.
sudo bash -c 'wpa_supplication … -c <(wpa_passphrase …)'