10

When I do this:

sudo wpa_supplicant -D nl80211,wext -i wlp4s0 -c <(wpa_passphrase "some ssid" "password")

I get

Successfully initialized wpa_supplicant
Failed to open config file '/dev/fd/63', error: No such file or directory
Failed to read or parse configuration '/dev/fd/63'

Any ideas?

14

Quoting the ArchLinux wiki:

Note: Because of the process substitution, you cannot run this command with sudo - you will need a root shell.

You should be able to use su -c under sudo like so:

$ sudo su -c 'wpa_supplicant -D nl80211,wext -i wlp4s0 -c \
    <(wpa_passphrase "some ssid" "password")'
10

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 …)'
0

For those coming from a web search engine: make sure your /dev is mounted. An easy mistake to make when chrooting, which can then result in errors such as this one.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.