DocScrutinizer05 | IroN900:~# cat /sys/devices/platform/musb_hdrc/charger | 09:49 |
---|---|---|
DocScrutinizer05 | 1 | 09:49 |
KotCzarny | he needs to differentiate between charger and charging via computer | 09:50 |
DocScrutinizer05 | ^^^ | 09:50 |
DocScrutinizer05 | /sys/devices/platform/musb_hdrc/charger == 1 : D+/- short | 09:53 |
DocScrutinizer05 | when you connect a charger that doesn't short D+ and D-, your device won't charge. So... exactly what you asked for | 09:54 |
DocScrutinizer05 | and reading the full backlog, this is actually _not_ what sunshavi is interested in. They want to know if device is connected to a PC USB data connection | 09:58 |
DocScrutinizer05 | and I think the approach is pretty random | 09:59 |
DocScrutinizer05 | sunshavi's question seems to be "can I send a signal from N900 to PC?" and to answer this we need to know which is the exact transport mechanism for the signal. USB networking with ssh? USB node polling? usb-tty? | 10:05 |
DocScrutinizer05 | original question: >>[2018-09-26 16:01:53] <sunshavi> Hi guys. is there a way of knowing if pc suite mode is active?<< Yes there is, but I don't know for sure right now how to check. Possibly lsmod | 10:07 |
DocScrutinizer05 | ask pali | 10:07 |
Maxdamantus | Maybe by seeing if g_nokia appears in /proc/modules, as opposed to g_file_storage? Dunno if that's an accurate determiner though; I always use either g_file_storage or g_ether. | 10:11 |
* Maxdamantus managed to disable that "PC suite" dialogue because it would annoyingly unlock the screen when plugging a USB cord in. | 10:12 | |
DocScrutinizer05 | IroN900:~# cat /sys/devices/platform/musb_hdrc/mode | 10:12 |
DocScrutinizer05 | b_peripheral | 10:12 |
DocScrutinizer05 | PC-Suite Mode | 10:12 |
DocScrutinizer05 | b_idle == unplugged | 10:13 |
DocScrutinizer05 | HTH | 10:13 |
DocScrutinizer05 | UNDEFINED == mass storage mode | 10:14 |
DocScrutinizer05 | until mounted, then b_peripheral | 10:15 |
DocScrutinizer05 | anyway note that [[ "b_peripheral" == `cat /sys/devices/platform/musb_hdrc/mode ` ]] still doesn't assert there's for example a working established network to run a ssh connection to the PC | 10:25 |
DocScrutinizer05 | you know it failed when "ssh $PC mynotifycmd" returns with error | 10:26 |
DocScrutinizer05 | >>... and to answer this we need to know which is the exact transport mechanism for the signal.<< | 10:27 |
DocScrutinizer05 | KotCzarny: sunshavi: ^^^ | 10:30 |
DocScrutinizer05 | >><sunshavi> Wizzup: I have the notification script done<< mind to share via pastebin? | 10:31 |
Vajb | I've noticed that when I charge my n900 and wall charger flag is set absent it means that n900 thinks that it is connected to pc. | 13:10 |
Wizzup | DocScrutinizer05: afaik the /mode in musb_hdrc doesn't help distinguish between wall plug and pc | 13:22 |
Wizzup | DocScrutinizer05: it can also be idle when no gadget it loaded, for example | 13:22 |
DocScrutinizer05 | mode is D+- short | 13:23 |
DocScrutinizer05 | oops sorry nope | 13:23 |
DocScrutinizer05 | mode is what the MUSB state machine is in | 13:23 |
KotCzarny | which might be totally random sometimes | 13:23 |
DocScrutinizer05 | yes | 13:23 |
DocScrutinizer05 | don't tell the father of H.E.N ;-D | 13:24 |
* DocScrutinizer05 feels that headache again | 13:24 | |
DocScrutinizer05 | ~hen | 13:25 |
infobot | well, hen is hostmode-easy-now, or http://talk.maemo.org/showthread.php?t=65232, or see ~hostmode | 13:25 |
DocScrutinizer05 | ~hostmode | 13:25 |
infobot | hmm... hostmode is http://talk.maemo.org/showthread.php?p=652330, or http://www.youtube.com/watch?v=fkCDyUO0sKQ, or see ~hostmode-powered | 13:25 |
sunshavi | DocScrutinizer05: good morning at least for me. the mechanism is this one | 13:28 |
sunshavi | when sms or phone call arrives a python scripts sends a file by bluetooth push notification to workstation. and workstation shown the notification (there a process reading when a new file arrives to a folder). that was in case phone is lost for not having and ssh-key on my workstation (just in case) | 13:30 |
DocScrutinizer05 | Vajb: you mean you connect device to a charger without D+- short (cat /sys/devices/platform/musb_hdrc/charger ->0 )? Yes, that is the same situation like immediately after plugging device to a PC host, before ENUM | 13:31 |
DocScrutinizer05 | afaik device will constantly try to communicate to host to run ENUM | 13:32 |
DocScrutinizer05 | no charging will be done | 13:33 |
sunshavi | this is the script on n900 http://termbin.com/544z | 13:33 |
sunshavi | 13:33 | |
Wizzup | https://github.com/maemo-leste/hildon-status-bar-usb/blob/master/udev-helper.c#L152 | 13:33 |
DocScrutinizer05 | sunshavi: mhm, so how is this related to USB? | 13:34 |
sunshavi | the problem happens when i disconnect|unplug the device from my workstation | 13:34 |
sunshavi | no usb host (workstation). then no no bluetooth host 4 receiving the file | 13:35 |
DocScrutinizer05 | ??? | 13:37 |
sunshavi | if not host an errors happens within the python script and I would need to restart the process. so process should just do his work when connected to my workstation. All of the if on the python script is for avoiding the error | 13:39 |
sunshavi | brb. time for doing some duties here | 13:39 |
Vajb | DocScrutinizer05: maybe. Bnf shows wall charger as absent. It will charge but keeps charge under 500mah. This happanes randomly when i plug charger in | 13:49 |
DocScrutinizer05 | bnf? | 14:05 |
DocScrutinizer05 | I seem to recall this is an app that dhows some system diagnostics, right? No idea what it does in detail | 14:06 |
DocScrutinizer05 | sunshavi: >>if not host an errors happens within the python script and I would need to restart the process<< no, I think you should catch the error within the script and handle it | 14:08 |
Vajb | it shows battery info and charging state, remaining time etc | 14:09 |
Vajb | what it does is it pulls info from system battery related file (can't recall the name) and just shows them with info what they are | 14:10 |
sunshavi | DocScrutinizer05: there is an assert line there (watch the source code) | 14:11 |
sunshavi | the error happens on that line (assert pipe.returncode == 0 and not errout) | 14:11 |
sunshavi | because i am debugging the script. I am still tuning it. But it works. I just need to catch some corner cases | 14:12 |
Vajb | as I said my device randomly pops out the dialog asking wether I want it to massmedia or usb state and if I don't reset the state with usb-host-mode it will charge only slow and wall charger absent flag stays on. | 14:12 |
Vajb | other way to reset this is reboot obviously. | 14:13 |
DocScrutinizer05 | Vajb: no idea what you're doing. Yes there is a race condition introducing randomness into charger detection, but I never seen a deadlock from that. | 14:17 |
DocScrutinizer05 | sunshavi: I completely fail to understand the concept of what you're doing. USB has nothing to do with bluetooth. You don't need to test any arbitrary USB state to find out whether or not a BT transaction succeeds or not | 14:19 |
DocScrutinizer05 | AIUI you want to avoid running the BT command under certain conditions (no PC in vicinity) since >>an errors happens within the python script and I would need to restart the process<< I think you need to catch the error so it does NOT abort the python script and rather tells you that no PC in vicinity | 14:23 |
sunshavi | docscrutinizer05: how should i know if device if plugged to my workstation, and ton to the usb-wall-charger? | 14:26 |
sunshavi | s/ton/not/ | 14:26 |
infobot | sunshavi meant: docscrutinizer05: how should i know if device if plugged to my workstation, and not to the usb-wall-charger? | 14:26 |
DocScrutinizer05 | why do you want to know that? | 14:26 |
DocScrutinizer05 | how is that even relevant? | 14:27 |
sunshavi | when dev is connected to different machine probably that machine that is not my workstation does not have a bluetooth device | 14:27 |
sunshavi | on n900 there is no l2ping utility. that could solve the issue too | 14:27 |
DocScrutinizer05 | hm? | 14:28 |
sunshavi | l2ping is for checking with a device with an specific mac-address in on reach | 14:28 |
sunshavi | s/with/when/ | 14:28 |
infobot | sunshavi meant: l2ping is for checking when a device with an specific mac-address in on reach | 14:28 |
DocScrutinizer05 | why do you need USB? | 14:29 |
sunshavi | for testing n900 is plugged on my workstation (1. check usb-connection; 2. see if my workstation-usb0 has the hardcoded ip needed) | 14:30 |
DocScrutinizer05 | WHY??? | 14:30 |
sunshavi | when you send a file by bluetooth you need to give the device-bluetooth-address | 14:31 |
sunshavi | as a parameter | 14:31 |
DocScrutinizer05 | how's that related to USB? | 14:31 |
sunshavi | the problem is: "how could be identified my machine from other machines?" | 14:32 |
DocScrutinizer05 | err, doesn'tBT do that for you? | 14:32 |
sunshavi | i am using for that a mechanism that involves usb+ip | 14:32 |
DocScrutinizer05 | I always thought that's what BT pairing is meant for | 14:32 |
DocScrutinizer05 | whatever that "mechanism", I don't understand it and think it's nonsense | 14:33 |
sunshavi | n900 is paired with several other devices | 14:34 |
DocScrutinizer05 | this is a classical yet very massive and wird instance of an XY problem | 14:35 |
DocScrutinizer05 | weird* | 14:36 |
DocScrutinizer05 | aiui you do a ping to USB-networked PC host. You as well could do a `ssh notifyuser@PC notify` | 14:38 |
DocScrutinizer05 | or you forget about all USB and send your BT data to the right device and catch any "transmission failed" | 14:39 |
sunshavi | yes that could do the work too but a little insecure. bt is safer | 14:39 |
DocScrutinizer05 | no | 14:39 |
DocScrutinizer05 | this is NOT insecure at all | 14:39 |
DocScrutinizer05 | anyway either BT or USB could do the whole task, you don't need both concurrently | 14:40 |
DocScrutinizer05 | actually THIS is sort of insecure | 14:40 |
sunshavi | i am almost there with my approach. One of your first lines is going to be helpful with the issue. I am going to code that tonight | 14:40 |
DocScrutinizer05 | good luck! I'm not going to help implement a flawed broken-by-design "solution" | 14:41 |
DocScrutinizer05 | USB doesn't provide *any* info about what you can expect to find on BT | 14:43 |
DocScrutinizer05 | why do you think BT is more secure than ssh? | 14:48 |
DocScrutinizer05 | actually uploading arbitrary files to your PC via BT sounds damn dangerous, particularly compared to a ssh login that allows only one particular command to execute (add the allowed command to user "notifyuser"'s ~notifyuser/.ssh/authorized_keys line) and needs a proper keypair to do so | 14:55 |
DocScrutinizer05 | both BT and ssh are virtually equally uncrackable, and when you lose the N900, then the ssh solution only enables the attacker to trigger a notification on your PC while the disclosed BT pairing key allows attacker to upload arbitrary files aiui - something you definitely want to avoid by all means since such arbitrary file might be a virus or whatever and take over your complete PC | 14:59 |
DocScrutinizer05 | even worse, BT allows to do so wireless over the air while the already uncritical exploit of unsolicited SMS notification could only happen when the attacker has physical connection to your PC USB jack (or otherwise log in to your PC), to establish a network and open a ssh session | 15:02 |
DocScrutinizer05 | s/ unsolicited / bogus forged / | 15:08 |
infobot | DocScrutinizer05 meant: even worse, BT allows to do so wireless over the air while the already uncritical exploit of bogus forged SMS notification could only happen when the attacker has physical connection to your PC USB jack (or otherwise log in to your PC), to establish a net... | 15:08 |
DocScrutinizer05 | sunshavi: man sshd|less -j26 +'/command="uptime"' | 15:24 |
DocScrutinizer05 | for your purposes a command="cat >/tmp/notificationtext && popup_notification" prolly will already do the whole trick | 15:27 |
DocScrutinizer05 | or, for added safety (flood protection): instead of `cat >` use `dd bs=1 count=$INT_MAXCHARS of=` | 15:31 |
DocScrutinizer05 | now, on N900, do `cat SMScontent.txt|ssh notifyuser@neo900` and up pops th notification on your PC. Absolutely no risk except a n900 thief could make offensive notifications pop up on your PC | 15:35 |
DocScrutinizer05 | IF they had access to ssh-login to your PC (unlike BT where they need to be nearby, within RF range, only) | 15:36 |
DocScrutinizer05 | I for one never use USB for networking, WLAN is so much more convenient | 15:40 |
DocScrutinizer05 | actually you better bundle all the "dd bs=1 count=$INT_MAXCHARS of=/tmp/notificationtext && popup_notification" into a bash script mynotify.sh and only hava a command="mynotify.sh" in authorized_keys | 16:04 |
DocScrutinizer05 | if you want to implement this, don't hesitate to ask about details | 16:06 |
DocScrutinizer05 | actually not even a dedicated new user "notifyuser" is needed, you can run this under your default user account | 16:08 |
DocScrutinizer05 | all you need is a dedicated pk-pair for this, with pubkey on N900 and privkey on your PC | 16:09 |
sunshavi | docscrutinizer05: on the contrary i almost never wlan on n900. Just usb and also bluetooth when needed. Also for consideration both of my n900 have a broken screen. so I access desktop by vnc over usb|bt | 16:32 |
sunshavi | and fyi my pc priv key is on n900 | 16:33 |
sunshavi | so from home i could access and modify the complete phone from any network connection. | 16:35 |
sunshavi | docscrutinizer05: thanks for your help | 16:36 |
DocScrutinizer05 | >>and fyi my pc priv key is on n900<< irrelevant for this situation | 16:57 |
DocScrutinizer05 | err wait. No. This is what already exactly you need. If you had not swapped the meaning of privkey and pubkey. The provjkey is on the originating side, the pubkey on the "server" you log in to | 16:59 |
DocScrutinizer05 | when you log in to N900 from your PC then the privkey is on PC | 17:00 |
DocScrutinizer05 | for the solution I sketched above, you need a dedicated key pair exclusively for this solution, you place the pubkey on PC so the N900 can log in to PC using the privkey on N900, and you modify the pubkey on PC so it only works for exactly one command: mynotify.sh | 17:02 |
sunshavi | my pc can read my phone or exec any ssh cmd on the phone. phone needs pwd when accesing pc | 17:03 |
DocScrutinizer05 | ^^^ | 17:03 |
DocScrutinizer05 | yes, you generally don't want password-less access from mobile devices to your PC, since you could lose the mobile device | 17:04 |
sunshavi | yes a dedicated key pair could be the answer | 17:04 |
DocScrutinizer05 | in this case however the pubkey gets modified so it works for exactly ONE command only | 17:05 |
DocScrutinizer05 | and doesn't need password for executing this one command | 17:05 |
sunshavi | for giving you the complete picture. i do the phone calls from my desktop-contacts app | 17:06 |
sunshavi | also i send sms's from my desktop-contacts app | 17:06 |
DocScrutinizer05 | you can install this keypair on top of whatever is already there, since you can have multipkle authorized_keys lines | 17:06 |
DocScrutinizer05 | Computrace.LoJack->LoJax :-o | 22:11 |
Generated by irclog2html.py 2.17.0 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!