Tiny Core Linux

Tiny Core Base => TCB Bugs => Topic started by: jim on February 17, 2024, 10:58:20 AM

Title: TinyCore64 14.0 wifi.sh failures
Post by: jim on February 17, 2024, 10:58:20 AM
Wifi.sh:
ESSID:"Baymont Inn & Suites"
sh:  Suites: Input/output error
Failed to connect.
Title: Re: TinyCore64 14.0 wifi.sh failures
Post by: jim on February 17, 2024, 11:00:36 AM
Hard to debug.
Laptop reboots if wifi is reconfigured
Posting more gets internal server error.
Title: Re: TinyCore64 14.0 wifi.sh failures
Post by: patrikg on February 17, 2024, 01:46:08 PM
Maybe bad char "&" at ssid or password.

I think you can search about wifi.sh in this forum to investigate to have bad char in the ssid.

Search (https://forum.tinycorelinux.net/index.php?action=search2&search=wifi.sh)
Title: Re: TinyCore64 14.0 wifi.sh failures
Post by: jim on February 17, 2024, 06:32:19 PM
Yes, I expect that it is a problem with '&' not being quoted or escaped correctly.

My search skills have not found much that is close yet.

No password, there is a landing page to click through though.

It appears to not produce much help with set -x, I think it is running in awk when it dies.
Title: Re: TinyCore64 14.0 wifi.sh failures
Post by: Rich on February 17, 2024, 08:40:26 PM
Hi jim
I set the wireless SSID on my router to:
Code: [Select]
Baymont Inn & Suitesand got the same error.

I removed the ampersand and connected. Then I looked
at  wifi.db  in my home directory and the last entry was:
Code: [Select]
Baymont\ Inn\ Suites PASSWORD WPASo the script is escaping the blank spaces. So I set the
first entry in  wifi.db  to:
Code: [Select]
Baymont\ Inn\ \&\ Suites PASSWORD WPABut even with the ampersand escaped I got the following result:
Code: [Select]
tc@box:~$ sudo wifi.sh -a
Found wifi device wlan0
Standby for scan of available networks...
Set to try a few times to obtain a lease.
Attempting auto connection with Baymont\ Inn\ \&\ Suites
Error for wireless request "Set ESSID" (8B1A) :
    too few arguments.
Title: Re: TinyCore64 14.0 wifi.sh failures
Post by: Rich on February 17, 2024, 09:21:45 PM
Hi jim
I did a little more digging. This worked:
Code: [Select]
tc@box:~$ wpa_passphrase "Baymont Inn & Suites" PASSWORD | sudo tee -a /etc/wpa_supplicant.conf
network={
        ssid="Baymont Inn & Suites"
        #psk="PASSWORD"
        psk=66e49fe73d49ee76ac368db3afcdd2b52f0634127b5c257b907f8efaa72e9367
}
tc@box:~$ sudo wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant.conf
Successfully initialized wpa_supplicant
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
nl80211: kernel reports: Match already configured
tc@box:~$ iwconfig
lo        no wireless extensions.

dummy0    no wireless extensions.

tunl0     no wireless extensions.

wlan0     IEEE 802.11  ESSID:"Baymont Inn & Suites" 
          Mode:Managed  Frequency:2.462 GHz  Access Point: 54:B7:BD:DC:32:76   
          Bit Rate=1 Mb/s   Tx-Power=15 dBm   
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Power Management:off
          Link Quality=48/70  Signal level=-62 dBm 
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:1   Missed beacon:0

eth0      no wireless extensions.

tc@box:~$

So my guess is something in wifi.sh is tripping on the ampersand.
Title: Re: TinyCore64 14.0 wifi.sh failures
Post by: Rich on February 18, 2024, 06:58:25 AM
Hi jim
The following 2 changes fix it.

Change this:
Code: [Select]
gsub(" ","\\ ",sid[i])To this:
Code: [Select]
gsub(" ","\\ ",sid[i])
gsub("&","\\\\&",sid[i])

Change this:
Code: [Select]
gsub(" ","\\ ",sid[selection])To this:
Code: [Select]
gsub(" ","\\ ",sid[selection])
gsub("&","\\\\&",sid[selection])

Makes me wonder what other legal characters can cause trouble.

    [Edit]: Fixed typo. Changed sid[ i] to sid[selection] in last line.  Rich
Title: Re: TinyCore64 14.0 wifi.sh failures
Post by: CentralWare on February 18, 2024, 07:28:06 AM
"Illegal" characters for a network ID are: ?  "  $  [  \  ]  + so these should be ignore-able
I would ESTIMATE problems MAY exist with * % @ = / depending on the circumstance, platform and operating system.
Title: Re: TinyCore64 14.0 wifi.sh failures
Post by: CentralWare on February 18, 2024, 07:59:16 AM
ADDN: ...and possibly `ticks and 'single-quotes'??
Title: Re: TinyCore64 14.0 wifi.sh failures
Post by: Rich on February 18, 2024, 08:07:40 AM
Hi CentralWare
So I guess the question is, how many of those should
we allow for?
Space: The average user wants to insert field separators in names.
Ampersand: I get it, Ben & Jerry, Barnes & Noble, Punch & Judy, etc.

Do we want to accommodate every "genius" who wants to deviate
from using 0-9, A-Z, and a-z by using "clever" punctuation?
Title: Re: TinyCore64 14.0 wifi.sh failures
Post by: CentralWare on February 18, 2024, 08:42:47 AM
Theoretically, if we're encapsulating the entire string in quotes, spaces "s h o u l d" be accounted for. (?)
Asterisks -- I've never seen nor used one in an ID, but it's "allowed" and more times than not, escape \* is going to be needed.

: and / are more Win based screw-ups so they're likely able to be disregarded here, but semi/colon is a worthwhile router test "just cuz"
as I think our baby firewalls allow almost any/everything - including illegals...

SSID: asdf\qwer:$5%+[] was permitted on a WatchGard XTM series AND a Cisco 3600 (up-stream from it) didn't bitc... complain about it :o
Okay, add $ and \ to our hit-list; to my dazed look the above SSID is visible on this Win'Nix desktop

* $ \ & and space encapsulation should cover MOST of the bases; those others who just HAVE to create identities which fall within the realm of illegals...  shouldn't be our problem
Title: Re: TinyCore64 14.0 wifi.sh failures
Post by: Rich on February 18, 2024, 08:56:49 AM
Hi CentralWare
... * $ \ & and space encapsulation should cover MOST of the bases; those others who just HAVE to create identities which fall within the realm of illegals...  shouldn't be our problem
Are you saying we should accommodate the illegal  $  and  \  characters?
Title: Re: TinyCore64 14.0 wifi.sh failures
Post by: CentralWare on February 18, 2024, 10:16:34 AM
Yes (I would, simply because I can CREATE an SSID with them on certain hardware and that they actually WORK, even though standards say
they're illegal and the few Tenda, TP-Link, D-Link and EnGenius routers which were tested when I sent that update agree that they're illegal
and have the user "try again" -- but that's not saying everyone else does - or that other models of the same brands do as well.)

$ is a Linux problem regardless -- not as much on Win (used to $HIDE directories, otherwise can be used for most anything else)
* is a Linux problem and a completely different Win problem (Win = Wildcard - just "illegal" period, so SSID="MY*PRECIOUS" choked
    on Win11 test a few minutes ago just responding "Cannot connect to network" and that's it.)
\ is a Linux issue, not as much on Win (mainly batch issues from yester-year)
& is a Linux only thang (that I'm aware of)  SSID="Tom & Jerry" worked out of the box in both directions wunder win10/win11;
   CentOS must have encountered this previously as it's already prepared for it.  Debian...  I think my image is "borked"; doesn't act right.
Title: Re: TinyCore64 14.0 wifi.sh failures
Post by: patrikg on February 18, 2024, 01:05:48 PM
Funny facts.
I have setup my IPhone with the name of :) as emoji.
And when i setup my phone with internet sharing, it shares my phone with ssid :) as emoji.
And when a search a little of this topic on the web, i can find that the standard don't say so much of what chars are correct to use.
So you can even use some chars that are difficult to type in from ordinary keyboard.

Have heard about some have tried to use $s $d, so even leak and break the phones, with seen this ssid's.

I think lots of implenentations have difficult to use chars that are not ascii.


 
Title: Re: TinyCore64 14.0 wifi.sh failures
Post by: CentralWare on February 18, 2024, 01:44:32 PM
I think lots of implenentations have difficult to use chars that are not ascii.
Yes, but the problem lies within the first half of the ASCII table where certain characters "mean something"
to the underlying operating system that's trying to connect to it, especially shells and interpreters.

For example, the ° symbol (Degrees) is easy to implement into a router.  It works in both directions,
but may be a pain to input manually and almost impossible for hardware like printers to connect without
using WPS.  This can be a benefit for security - or a liability for sanity!

The $ (Dollar Sign) on the other hand means Currency to most people...  but to a Linux based computer,
it means Variable in many cases thus why it's considered a Reserved character and must be "Escaped" for
the computer to see it as a normal character.
Title: Re: TinyCore64 14.0 wifi.sh failures
Post by: Rich on February 18, 2024, 07:09:50 PM
Hi jim
There was a typo in the second change listed in reply #6
that has been corrected.
Title: Re: TinyCore64 14.0 wifi.sh failures
Post by: jim on February 19, 2024, 07:02:56 AM
Happily that fixed it.
I am connected at the hotel.
Thank you.
Title: Re: TinyCore64 14.0 wifi.sh failures
Post by: Rich on February 19, 2024, 09:36:58 AM
Hi jim
Thank you for confirming it worked. Sorry about the
typo. Hope it didn't cause you too much trouble.
Title: Re: TinyCore64 14.0 wifi.sh failures
Post by: Rich on February 21, 2024, 09:11:58 PM
Hi CentralWare
I set the ESSID on my router to:
Code: [Select]
I'm a rule breaker & ! ?\$ * = \
And my modified wifi.sh was able to connect:
Code: [Select]
Select Wifi Network

    ESSID                         Enc   Qual    Channel Type           
 1. I'm a rule breaker & ! ?\$ * = \       on    47      11     WPA
 2. ROMY_WIFI                      on    22       9     WPA
 3. Verizon_Z6DL3H                 on    19       6     WPA

Enter selection ( 1 - 3 ) or (q)uit: 1
Enter password for I'm a rule breaker & ! ?\$ * = \ (8 to 63 characters): PASSWORD
Sending credentials to requested access point I'm a rule breaker & ! ?\$ * = \# reading passphrase from stdin
..
deleting routers
adding dns 192.168.1.1
tc@box:~$

The formatted ESSID wifi.sh placed in wifi.db looks like this:
Code: [Select]
I\'m\ a\ rule\ breaker\ \&\ \!\ \?\\\$\ \*\ \=\ \\ PASSWORD WPA
Try as I might, I couldn't get wifi.sh to accept a percent sign.
It responded with  Invalid format specifier.  Probably a printf
command complaining.

The changes involved adding a bunch of gsub() statements.
Some extra surrounding lines are shown for context.
From this:
Code: [Select]
gsub(" ","\\ ",sid[i])To this:
Code: [Select]
if ( mode == "auto" ) {
print("Attempting auto connection with " autoconnect)
for (i in sid) {
gsub("\134\134","\134\134",sid[i]) # Backslash (must come first)
gsub(" ","\\ ",sid[i]) # Space
gsub("\047","\\\047",sid[i]) # Single quote
gsub("&","\\\\&",sid[i]) # Ampersand
gsub("!","\\!",sid[i]) # Exclamation mark
gsub("?","\\?",sid[i]) # Question mark
gsub("\\$","\\$",sid[i]) # Dollar sign
gsub("\\*","\\*",sid[i]) # Asterisk
gsub("\\=","\\=",sid[i]) # Equal sign
if (autoconnect == sid[i] ) {
associate(type[i],wifi,sid[i],mypass,chan[i])
system( "udhcpc " lease "-i " wifi " -x hostname:" currenthostname " 2>/dev/null" )
exit

And this:
Code: [Select]
gsub(" ","\\ ",sid[selection])To this:
Code: [Select]
if ( offset == 1 && selection != "q") {
sid_display = sid[selection]
password = ""
newitem=""
gsub("\134\134","\134\134",sid[selection]) # Backslash (must come first)
gsub(" ","\\ ",sid[selection]) # Space
gsub("\047","\\\047",sid[selection]) # Single quote
gsub("&","\\\\&",sid[selection]) # Ampersand
gsub("!","\\!",sid[selection]) # Exclamation mark
gsub("?","\\?",sid[selection]) # Question mark
gsub("\\$","\\$",sid[selection]) # Dollar sign
gsub("\\*","\\*",sid[selection]) # Asterisk
gsub("\\=","\\=",sid[selection]) # Equal sign
if ( enc[selection] == "on" ) {
while ( getline dbitem < dbfile > 0 ) {
split(dbitem,field,"\t")

Quote
CAUTION: This subsubsection has been reported to cause headaches.
 You might want to skip it upon first reading.
Found here:
https://www.gnu.org/software/gawk/manual/html_node/Gory-Details.html
Title: Re: TinyCore64 14.0 wifi.sh failures
Post by: CentralWare on February 25, 2024, 07:04:51 AM
@Rich, sorry it's been a minute; ran into some computer based technical difficulties (of all things that could become corrupt...  my password bible bit the dust?!)
If wifi.sh has been updated on the repo I can just download and investigate; if not, please email me where you left off -- I should be able to do a pass recovery there later this afternoon :)
Thanks!
Title: Re: TinyCore64 14.0 wifi.sh failures
Post by: Rich on February 25, 2024, 07:27:42 AM
Hi CentralWare
No, I didn't touch the repo version. I posted my changes
here so the smart kids can point out any errors for me.

I've emailed a copy of the modified script for you to try out.