Tiny Core Linux
Tiny Core Base => Raspberry Pi => Topic started by: tim54 on August 19, 2024, 12:01:27 PM
-
I had it all working under piCore 14 but I can't get wifi.sh to work on piCore 15, this is on a Pi 3B+
onboot.lst has the following
openssh.tcz
firmware-rpi-wifi.tcz
firmware-brcmwifi.tcz
wifi.tcz
When I run sudo wifi.sh it list the available SSIDs but once one selected it does not prompt for the password but gives this error messsage instead, obviousy it then fails to connect.
tcgetattr: Inappropriate ioctl for device
Any thoughts on what I am doing wrong?
Thanks
-
Can you try to setup wpa_supplicant manually?
-
Thanks for your fast reply.
I now have a workaround in that the following works
wpa_passphrase My_SSID My_Password > /etc/wpa_supplicant.conf
wpa_supplicant -i wlan0 -c /etc/wpa_supplicant.conf -B -D nl80211,wext
udhcpc -i wlan0
-
Great, thanks for letting me know, I'll take a look at the script, it hasn't been updated in years.
-
I use wifi.sh script without problems on Pi model 1B and a Realtek USB Wifi. I am still on the first beta release of 15 though.
-
Now that I'm at home looking at whats going on, its more likely related to the tty.
What is your connection to the pi. keyboard, ssh?
-
Hi Paul_123
I don't know if this is of interest to you. Last February someone
reported an issue involving ESSID containing an ampersand:
https://forum.tinycorelinux.net/index.php/topic,26819.0.html
I worked out some changes to handle certain troublesome
characters in reply #18. I don't know if any of them were
incorporated. Maybe they are of some interest?
-
I don’t use wifi.sh, nor do I have time to test every combination of odd characters. Not sure who is the official maintainer, or if it’s in the TC git somewhere, but I would just implement the changes you suggested, and see what shakes out next
-
searched DDG for "tcgetattr: Inappropriate ioctl for device"
and read these:
https://unix.stackexchange.com/questions/417362/concalc-tcsetattr-error-inappropriate-ioctl-for-device
https://unix.stackexchange.com/questions/82658/bash-script-error-stty-standard-input-inappropriate-ioctl-for-device
given TCL14x worked, but TCL15x fails, could this be a change in busybox?
(tcl14=busybox_1.36.0 and tcl15=busybox_1.36.1)
-
The error comes from this line
system("wpa_passphrase " s " < " ptmp " > /etc/wpa_supplicant.conf")
It appears that wpa_passphrase no longer accepts input redirected from a file.
the solution that seems to work is to have the password as a command line argument
system("wpa_passphrase " s " " p " > /etc/wpa_supplicant.conf")
the line creating the temporary file can be deleted
--- /usr/local/bin/wifi.sh
+++ wifi.sh
@@ -106,13 +106,12 @@
}
function associate(t,d,s,p,c) {
- print p > ptmp
keyphrase=" key restricted "
if ( p == "" ) { keyphrase = "" }
selchannel=" channel "
if ( c == "" ) { selchannel = "" }
if (t == "WPA") {
- system("wpa_passphrase " s " < " ptmp " > /etc/wpa_supplicant.conf")
+ system("wpa_passphrase " s " " p " > /etc/wpa_supplicant.conf")
system("wpa_supplicant -i " d " -c /etc/wpa_supplicant.conf -B -D $WPADRV >/dev/null 2>&1")
} else {
system("iwconfig " d " essid " s keyphrase p selchannel c)
Warning this appears to work in my case but it has not had any testing other than my home WPA network.
-
while the wpa_supplicant package was recently updated, the wpa_passphrase code has not changed much. The redirection would be handled by the shell anyway.
tcgetattr is only called if the number of arguments is less than 2. busybox ash and busybox awk are the places to start looking.
-
Here is my test to show that it is wpa_passphrase and redirection that is causing the problem.
tc@box:~$ echo MyPassword > ptmp
tc@box:~$ wpa_passphrase MySSID < ptmp
# reading passphrase from stdin
tcgetattr: Inappropriate ioctl for device
tc@box:~$ wpa_passphrase MySSID MyPassword
network={
ssid="MySSID"
#psk="MyPassword"
psk=a66e97b9a1008a97285c78c2b95082bed3541d3dd01165b0128f7f3c18563797
}
tc@box:~$
-
Hi Paul_123
I don’t use wifi.sh, nor do I have time to test every combination of odd characters. Not sure who is the official maintainer, or if it’s in the TC git somewhere, but I would just implement the changes you suggested, and see what shakes out next
I couldn't find it in the TC git or any of the repo src directories.
Currently, there are 3 versions of wifi.tcz in TC15:
x86 v1.5
x86_64 v1.4
ARM v1.6
Since it's just a script, I'd like to keep it in sync for all architectures.
I took the 1.6 version and added the changes for odd characters.
If there is no objection, I would like to implement the change proposed by timbee:
system("wpa_passphrase " s " " p " > /etc/wpa_supplicant.conf")
It seems a lot simpler and more straightforward than this:
print p > ptmp
----- Snip -----
system("wpa_passphrase " s " < " ptmp " > /etc/wpa_supplicant.conf")
----- Snip -----
I've put together a source tarball containing:
wifi.sh # /usr/local/bin
wifi # Script for /usr/local/tce.installed
wifi.desktop # /usr/local/share/applications
wifi.tcz.info # The .info file for updating version number, comments, and change log.
wifi.png # /usr/local/share/pixmaps
wifi.build # Script that builds and packages the extensions.
wifi.build creates wifi-Arm.tar.gz and wifi-Intel.tar.gz.
Each contains:
wifi.tcz.md5.txt
wifi.tcz
wifi.tcz.dep
wifi.tcz.list
wifi.tcz.info
wifi.tcz.zsync
The only differences are:
ARM 16k squash block size .tcz.dep=wireless_tools.tcz, wpa_supplicant.tcz
Intel 4k squash block size .tcz.dep=wpa_supplicant-dbus.tcz
wifi.build also creates a new source tarball (wifi-source-Ver1.7.tar.gz) and
wifi-Ver1.7.tar.gz.bfe for submitting the extensions and new source package.
wifi.build gets the current version number from wifi.tcz.info.
-
Writing a temp file has less of a chance of squashing a special character by the shell.
I'm pretty sure I see the issue with wpa_passphrase. The change they made (In 2022 after wpa_supoplicant 2.10) expects a real tty for standard input.
-
This is how alpine does the thingy: taken from the file setup-interfaces (https://github.com/alpinelinux/alpine-conf/blob/master/setup-interfaces.in)
config_wpa_supp() {
local iface="$1" essid="$2" auth_type="$3" psk="$4"
local conffile="$ROOT"/etc/wpa_supplicant/wpa_supplicant.conf
mkdir -p "${conffile%/*}"
if [ "$auth_type" = "WPA-PSK" ]; then
(umask 0077 && wpa_passphrase "$essid" "$psk" | sed -e '/^\t#psk=.*/d' >> "$conffile")
else
cat << EOF >> $conffile
network={
ssid="$essid"
key_mgmt=$auth_type
}
EOF
fi
mkdir -p "$ROOT/etc/conf.d"
if grep -q ^wpa_supplicant_args= "$ROOT"/etc/conf.d/wpa_supplicant 2>/dev/null; then
sed -i -e "s/^wpa_supplicant_args=.*/wpa_supplicant_args=\"-i $iface\"/" /etc/conf.d/wpa_supplicant
else
printf 'wpa_supplicant_args="-i%s"\n' "$iface" >> "$ROOT"/etc/conf.d/wpa_supplicant
fi
rc-update --quiet add wpa_supplicant boot
rc-service wpa_supplicant start
}
-
wpa_supplicant extension updated to handle wpa_passphrase redirection as previous.
-
Hi Paul_123
OK, I'll leave the redirect as is.
I'm going to push the updated wifi.tcz to the Intel TC15 repo.
Do you want me to update the ARM repo too?
-
Sounds like a plan.
-
Hi Paul_123
ARM repos updated.
Should I add the source package to the src directories in the
TC repos, or do you want to centralize it?
-
Just add it to the src dir for now.
-
Hi Paul_123
Done. :)