Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: How to enable/connect with SSH?

Unfortunately, compared to the older simulator this one is way more secure, even from us in development mode.  (Perhaps too secure...)

 

When we connect via SSH (whether with a login or using scp or sftp, it's all the same) we are logged in as "devuser".  Unfortunately the apps are all installed under the different userid 1000, and devuser has no write access to the appdata folders nor, for that matter, read access, nor almost anything else that's useful.

 

I would think we should at least have access to the shared folders (under /accounts/1000/shared) but even that is restricted at the moment.  Presumably, since I would expect we'll eventually be able to read/write files in there from our PCs through USB (with the PB as a mass storage device), it ought to be safe to let us developers get in there as well for test purposes like you have.

 

The only option I can see at the moment is to copy your files to the /tmp folder, and add a capability in your app to transfer them into your applicationStorageDirectory.  You could do this with a little timer routine so that it happens automatically, maybe polling for the existence of a "semaphore" file (e.g. /tmp/copynow) that you create only when you want it to do that.  (It would copy the files then delete them from /tmp and delete that semaphore file for the next time.)


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Contributor
Posts: 12
Registered: ‎01-12-2011
My Device: Playbook

Re: How to enable/connect with SSH?

thanks for this response Peter ( and thanks for your previous response also )

 

I try to create a folder into the /tmp but it's fail...

 

So the only way we have to add files into the applicationStorageDirectory is to bring them into our app and copy it?

 

 

Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: How to enable/connect with SSH?

@khanou, I also could not create a folder in the /tmp folder, but I could create a file.  Using "md foo" fails for reasons I don't understand yet, but "echo blah >foo" successfully creates the file foo.  Perhaps that's adequate for you.


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
BlackBerry Development Advisor
Posts: 417
Registered: ‎10-27-2010
My Device: PlayBook

Re: How to enable/connect with SSH?

When you connect to device using ssh as devuser you can access sanboxes of the application you installed in development mode (if you use command line -devMode switch in airpackager) and shared folder in /account/1000/appdata.

 

/tmp will not be accessing for applications or for devuser do not rely on it. For app the place to write files is <sandbox>/tmp. For devuser - devuser's home.

Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: How to enable/connect with SSH?

Ah, now we finally know what -devMode was for. Smiley Happy 

 

(Note: it may not be available on airpackager, but it is shown as an option on blackberry-deploy.  Maybe it's also on the packager but just not shown in the help output.)

 

Another option appears to be "chmod o+r" on /accounts/devuser, as that would let any app read files in that folder.  That would work even if an app is not installed in -devMode, though of course it would depend on having development-related code in your app.  Maybe useful in some testing situations.


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: How to enable/connect with SSH?

 


elena_laskavaia wrote:

When you connect to device using ssh as devuser you can access sanboxes of the application you installed in development mode (if you use command line -devMode switch in airpackager) and shared folder in /account/1000/appdata.

 

/tmp will not be accessing for applications or for devuser do not rely on it. For app the place to write files is <sandbox>/tmp. For devuser - devuser's home.


 

Elena, are you sure about all that, and that's it's meant to be working with the 0.9.2 simulator?

 

I've tried making my little snapshot test app write to several folders in there, with no success.

 

 

# trace output from app when it writes file
path is /accounts/1000/appdata/Snapshot.U25hcHNob3QgICAgICAgICAgICA/data/snapshot.png

# devuser cannot look into app's folder even when installed with -devMode
$ ls -la /accounts/1000/appdata/Snapshot.U25hcHNob3QgICAgICAgICAgICA/data
ls: Permission denied (/accounts/1000/appdata/Snapshot.U25hcHNob3QgICAgICAgICAgICA/data)

# Note: devuser can't even get to shared folder, which seems pointless
$ ls /accounts/1000/shared
ls: Permission denied (/accounts/1000/shared)

 

 

I was able to write to /accounts/devuser/snapshot.png after doing "chmod o=rwx" on the folder, so the app is definitely working.

 

Should I file a bug report?  Has anyone else successfully looked at files in any of their app's sandbox folders, as Elena described above?


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
New Contributor
Posts: 8
Registered: ‎01-13-2011
My Device: Not Specified

Re: How to enable/connect with SSH?

Is there anything special to getting sftp to work? I got ssh working, but i cannot use the sftp protocol. I have tried filezilla and winscp. I get errors the sftp isn't installed or an exit error 141.

Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: How to enable/connect with SSH?

@thadude3, I'd noted that only ssh works as well, not (so far) pscp or psftp (those are the PuTTY versions on Windows).

 

I get "Fatal: unable to initialise SFTP: could not connect".  Same (minus the word "Fatal") for pscp.

 

With the same options, plink works fine (that's the PuTTY console equivalent of "ssh").

 

Same on Linux, with ssh working, scp giving "unknown user: 100" (hmm... maybe that points in a useful direction), and sftp just giving "Connection closed".


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: How to enable/connect with SSH?

Using the -v options on scp and sftp (on Linux now), I get this output from the two of them, respectively:

 

From scp:

(earlier stuff skipped... it connects fine)
debug1: Sending command: scp -v -f snapshot.png
unknown user 100
(the rest is just cleanup)

From sftp:

debug1: Sending subsystem: sftp
debug1: client_input_channel_req: channel 0 rtype exit-status reply 0
debug1: client_input_channel_req: channel 0 rtype eow@openssh.com reply 0
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 0 clearing O_NONBLOCK
Transferred: sent 3072, received 2280 bytes, in 0.1 seconds
Bytes per second: sent 30041.7, received 22296.6
debug1: Exit status 141
Connection closed

From "sftp -s /base/usr/libexec/sftp-server -v devuser@192.168.7.172" (because it didn't look like it was even loading the sftp subsystem on the remote end):

debug1: Authentication succeeded (publickey).
debug1: channel 0: new [client-session]
debug1: Requesting no-more-sessions@openssh.com
debug1: Entering interactive session.
debug1: Sending environment.
debug1: Sending env LANG = en_CA.UTF-8
debug1: Sending command: /base/usr/libexec/sftp-server
No user found for uid 100
(remainder skipped...it's just cleanup)

So for whatever reason (something QNX-related?  I know nothing about QNX so I can't debug much), it doesn't recognize the user or something... at least it shows scp and sftp may suffer from the same problem (though sftp may have a different issue first, with the sftp subsystem not being loaded).

 

If they hadn't made /etc/passwd totally invisible to non-root users (who ever does that?  it should be safe to read it!) I might have a clue.

 

 


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Highlighted
New Contributor
Posts: 8
Registered: ‎01-13-2011
My Device: Not Specified

Re: How to enable/connect with SSH?

[ Edited ]

etc/ftpusers is blank, devuser guid is 100. my only guess is that since ftpusers doesn't have any users listed no ones allowed.

 

related... http://www.mail-archive.com/rssh-discuss@lists.sourceforge.net/msg00144.html