libera/#maemo/ Thursday, 2018-09-27

DocScrutinizer05IroN900:~# cat /sys/devices/platform/musb_hdrc/charger09:49
DocScrutinizer05109:49
KotCzarnyhe needs to differentiate between charger and charging via computer09:50
DocScrutinizer05^^^09:50
DocScrutinizer05/sys/devices/platform/musb_hdrc/charger == 1 : D+/- short09:53
DocScrutinizer05when you connect a charger that doesn't short D+ and D-, your device won't charge. So... exactly what you asked for09:54
DocScrutinizer05and 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 connection09:58
DocScrutinizer05and I think the approach is pretty random09:59
DocScrutinizer05sunshavi'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
DocScrutinizer05original 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 lsmod10:07
DocScrutinizer05ask pali10:07
MaxdamantusMaybe 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
DocScrutinizer05IroN900:~# cat /sys/devices/platform/musb_hdrc/mode10:12
DocScrutinizer05b_peripheral10:12
DocScrutinizer05PC-Suite Mode10:12
DocScrutinizer05b_idle == unplugged10:13
DocScrutinizer05HTH10:13
DocScrutinizer05UNDEFINED == mass storage mode10:14
DocScrutinizer05until mounted, then b_peripheral10:15
DocScrutinizer05anyway 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 PC10:25
DocScrutinizer05you know it failed when "ssh $PC mynotifycmd" returns with error10:26
DocScrutinizer05>>... and to answer this we need to know which is the exact transport mechanism for the signal.<<10:27
DocScrutinizer05KotCzarny: sunshavi: ^^^10:30
DocScrutinizer05>><sunshavi> Wizzup: I have the notification script done<< mind to share via pastebin?10:31
VajbI'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
WizzupDocScrutinizer05: afaik the /mode in musb_hdrc doesn't help distinguish between wall plug and pc13:22
WizzupDocScrutinizer05: it can also be idle when no gadget it loaded, for example13:22
DocScrutinizer05mode is D+- short13:23
DocScrutinizer05oops sorry nope13:23
DocScrutinizer05mode is what the MUSB state machine is in13:23
KotCzarnywhich might be totally random sometimes13:23
DocScrutinizer05yes13:23
DocScrutinizer05don't tell the father of H.E.N ;-D13:24
* DocScrutinizer05 feels that headache again13:24
DocScrutinizer05~hen13:25
infobotwell, hen is hostmode-easy-now, or http://talk.maemo.org/showthread.php?t=65232, or see ~hostmode13:25
DocScrutinizer05~hostmode13:25
infobothmm... hostmode is http://talk.maemo.org/showthread.php?p=652330, or http://www.youtube.com/watch?v=fkCDyUO0sKQ, or see ~hostmode-powered13:25
sunshaviDocScrutinizer05: good morning at least for me. the mechanism is this one13:28
sunshaviwhen 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
DocScrutinizer05Vajb: 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 ENUM13:31
DocScrutinizer05afaik device will constantly try to communicate to host to run ENUM13:32
DocScrutinizer05no charging will be done13:33
sunshavithis is the script on n900 http://termbin.com/544z13:33
sunshavi13:33
Wizzuphttps://github.com/maemo-leste/hildon-status-bar-usb/blob/master/udev-helper.c#L15213:33
DocScrutinizer05sunshavi: mhm, so how is this related to USB?13:34
sunshavithe problem happens when i disconnect|unplug the device from my workstation13:34
sunshavino usb host (workstation). then no no bluetooth host 4 receiving the file13:35
DocScrutinizer05???13:37
sunshaviif 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 error13:39
sunshavibrb. time for doing some duties here13:39
VajbDocScrutinizer05: maybe. Bnf shows wall charger as absent. It will charge but keeps charge under 500mah. This happanes randomly when i plug charger in13:49
DocScrutinizer05bnf?14:05
DocScrutinizer05I seem to recall this is an app that dhows some system diagnostics, right? No idea what it does in detail14:06
DocScrutinizer05sunshavi: >>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 it14:08
Vajbit shows battery info and charging state, remaining time etc14:09
Vajbwhat it does is it pulls info from system battery related file (can't recall the name) and just shows them with info what they are14:10
sunshaviDocScrutinizer05: there is an assert line there (watch the source code)14:11
sunshavithe error happens on that line (assert pipe.returncode == 0 and not errout)14:11
sunshavibecause i am debugging the script. I am still tuning it. But it works. I just need to catch some corner cases14:12
Vajbas 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
Vajbother way to reset this is reboot obviously.14:13
DocScrutinizer05Vajb: 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
DocScrutinizer05sunshavi: 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 not14:19
DocScrutinizer05AIUI 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 vicinity14:23
sunshavidocscrutinizer05: how should i know if device if plugged to my workstation, and ton to the usb-wall-charger?14:26
sunshavis/ton/not/14:26
infobotsunshavi meant: docscrutinizer05: how should i know if device if plugged to my workstation, and not to the usb-wall-charger?14:26
DocScrutinizer05why do you want to know that?14:26
DocScrutinizer05how is that even relevant?14:27
sunshaviwhen dev is connected to different machine probably that machine that is not my workstation does not have a bluetooth device14:27
sunshavion n900 there is no l2ping utility. that could solve the issue too14:27
DocScrutinizer05hm?14:28
sunshavil2ping is for checking with a device with an specific mac-address in on reach14:28
sunshavis/with/when/14:28
infobotsunshavi meant: l2ping is for checking when a device with an specific mac-address in on reach14:28
DocScrutinizer05why do you need USB?14:29
sunshavifor testing n900 is plugged on my workstation (1. check usb-connection; 2. see if my workstation-usb0 has the hardcoded ip needed)14:30
DocScrutinizer05WHY???14:30
sunshaviwhen you send a file by bluetooth you need to give the device-bluetooth-address14:31
sunshavias a parameter14:31
DocScrutinizer05how's that related to USB?14:31
sunshavithe problem is: "how could be identified my machine from other machines?"14:32
DocScrutinizer05err, doesn'tBT do that for you?14:32
sunshavii am using for that a mechanism that involves usb+ip14:32
DocScrutinizer05I always thought that's what BT pairing is meant for14:32
DocScrutinizer05whatever that "mechanism", I don't understand it and think it's nonsense14:33
sunshavin900 is paired with several other devices14:34
DocScrutinizer05this is a classical yet very massive and wird instance of an XY problem14:35
DocScrutinizer05weird*14:36
DocScrutinizer05aiui you do a ping to USB-networked PC host. You as well could do a `ssh notifyuser@PC notify`14:38
DocScrutinizer05or you forget about all USB and send your BT data to the right device and catch any "transmission failed"14:39
sunshaviyes that could do the work too but a little insecure. bt is safer14:39
DocScrutinizer05no14:39
DocScrutinizer05this is NOT insecure at all14:39
DocScrutinizer05anyway either BT or USB could do the whole task, you don't need both concurrently14:40
DocScrutinizer05actually THIS is sort of insecure14:40
sunshavii 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 tonight14:40
DocScrutinizer05good luck! I'm not going to help implement a flawed broken-by-design "solution"14:41
DocScrutinizer05USB doesn't provide *any* info about what you can expect to find on BT14:43
DocScrutinizer05why do you think BT is more secure than ssh?14:48
DocScrutinizer05actually 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 so14:55
DocScrutinizer05both 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 PC14:59
DocScrutinizer05even 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 session15:02
DocScrutinizer05s/ unsolicited / bogus forged /15:08
infobotDocScrutinizer05 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
DocScrutinizer05sunshavi:   man sshd|less -j26 +'/command="uptime"'15:24
DocScrutinizer05for your purposes a command="cat >/tmp/notificationtext && popup_notification" prolly will already do the whole trick15:27
DocScrutinizer05or, for added safety (flood protection): instead of `cat >` use `dd bs=1 count=$INT_MAXCHARS of=`15:31
DocScrutinizer05now, 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 PC15:35
DocScrutinizer05IF they had access to ssh-login to your PC (unlike BT where they need to be nearby, within RF range, only)15:36
DocScrutinizer05I for one never use USB for networking, WLAN is so much more convenient15:40
DocScrutinizer05actually 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_keys16:04
DocScrutinizer05if you want to implement this, don't hesitate to ask about details16:06
DocScrutinizer05actually not even a dedicated new user "notifyuser" is needed, you can run this under your default user account16:08
DocScrutinizer05all you need is a dedicated pk-pair for this, with pubkey on N900 and privkey on your PC16:09
sunshavidocscrutinizer05: 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|bt16:32
sunshaviand fyi my pc priv key is on n90016:33
sunshaviso from home i could access and modify the complete phone from any network connection.16:35
sunshavidocscrutinizer05: thanks for your help16:36
DocScrutinizer05>>and fyi my pc priv key is on n900<< irrelevant for this situation16:57
DocScrutinizer05err 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 to16:59
DocScrutinizer05when you log in to N900 from your PC then the privkey is on PC17:00
DocScrutinizer05for 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.sh17:02
sunshavimy pc can read my phone or exec any ssh cmd on the phone. phone needs pwd when accesing pc17:03
DocScrutinizer05^^^17:03
DocScrutinizer05yes, you generally don't want password-less access from mobile devices to your PC, since you could lose the mobile device17:04
sunshaviyes a dedicated key pair could be the answer17:04
DocScrutinizer05in this case however the pubkey gets modified so it works for exactly ONE command only17:05
DocScrutinizer05and doesn't need password for executing this one command17:05
sunshavifor giving you the complete picture. i do the phone calls from my desktop-contacts app17:06
sunshavialso i send sms's from my desktop-contacts app17:06
DocScrutinizer05you can install this keypair on top of whatever is already there, since you can have multipkle authorized_keys lines17:06
DocScrutinizer05Computrace.LoJack->LoJax  :-o22:11

Generated by irclog2html.py 2.17.0 by Marius Gedminas - find it at https://mg.pov.lt/irclog2html/!