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

Native Development

Reply
Developer
Posts: 195
Registered: ‎05-09-2012
My Device: Playbook, Z10 LE

Changing file ownership programmatically?

The playbook has this nasty bug, when a zip file is extracted (created on Mac), the file owner is set to some other then the default user and it is impossible to delete the extracted files. It is possible to rename the folders but not to delete them. People say that it is possible to delete them only by security wipe.

I have tried to delete the files by logging in via SSH but it is neighter possible to delete the files nor to change the owner?

Woud it be possible somehow to programmatically delete such files?

Developer
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: Changing file ownership programmatically?

In what way did you extract this zip file on PB?

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

Re: Changing file ownership programmatically?

In Posix if you have the right permissions on the folder in which the files reside, you can certainly delete them. Check your situation and if you can't figure it out from that, give us more detail on the location of the files, and maybe post the output of both "ls -ld" and "ls -l" on the parent folder where you extracted these files.

As far as programmatic control, you should be able to use https://developer.blackberry.com/native/reference/com.qnx.doc.neutrino.lib_ref/topic/c/chown.html and https://developer.blackberry.com/native/reference/com.qnx.doc.neutrino.lib_ref/topic/c/chmod.html when appropriate.

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: 195
Registered: ‎05-09-2012
My Device: Playbook, Z10 LE

Re: Changing file ownership programmatically?

I think I just clicked on it (it was months ago) and it was automatically unziped. I don't remember exactly, I think it was the default file browser.

Developer
Posts: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: Changing file ownership programmatically?

If you clicked on it to unzip then it is in 'shared' are and you should be able to remove these files without any problem. Please provide what Peter has asked for.

Developer
Posts: 195
Registered: ‎05-09-2012
My Device: Playbook, Z10 LE

Re: Changing file ownership programmatically?

[ Edited ]

Here is the output of the parent directory:

 

/accounts/1000/shared/videos/Edu/OpenCL Course$ ls -ld
drwxrws--- 3 dtm 1000_shared 4096 Sep 11 11:50 .
/accounts/1000/shared/videos/Edu/OpenCL Course$ ls -l
total 1413833
-rwxrw---- 1 dtm 1000_shared 133605080 Dec 03 2011 Episode_1-iPhone.m4v
-rwxrw---- 1 dtm 1000_shared 116978956 Dec 03 2011 Episode_2.m4v
-rwxrw---- 1 dtm 1000_shared 3241926 Dec 03 2011 Episode_2.pdf
-rwxrw---- 1 dtm 1000_shared 126443751 Dec 03 2011 Episode_3.m4v
-rwxrw---- 1 dtm 1000_shared 1581889 Dec 03 2011 Episode_3.pdf
-rwxrw---- 1 dtm 1000_shared 259430 Dec 03 2011 Episode_3_source.zip
-rwxrw---- 1 dtm 1000_shared 130980911 Dec 03 2011 Episode_4.m4v
-rwxrw---- 1 dtm 1000_shared 3010980 Dec 03 2011 Episode_4.pdf
-rwxrw---- 1 dtm 1000_shared 68490591 Dec 03 2011 Episode_5.m4v
-rwxrw---- 1 dtm 1000_shared 1177859 Dec 03 2011 Episode_5.pdf
-rwxrw---- 1 dtm 1000_shared 134479722 Dec 03 2011 Episode_6.m4v
-rwxrw---- 1 dtm 1000_shared 2778170 Dec 03 2011 Episode_6.pdf
-rwxrw---- 1 dtm 1000_shared 18073 Dec 03 2011 Episode_6_source.zip
drwxrwsrwx 3 100291000 1000_shared 4096 Jul 30 23:59 delete


/accounts/1000/shared/videos/Edu/OpenCL Course$ ls -ld
drwxrws--- 3 dtm 1000_shared 4096 Sep 11 11:50 .

 

The directory that cannot be deleted is "delete"

 

/accounts/1000/shared/videos/Edu/OpenCL Course/delete/iis$ ls -l
total 51
drwx--S--- 2 100291000 1000_shared 4096 Oct 08 2009 Episode_6.xcodeproj
-rw------- 1 100291000 1000_shared 3041 Oct 08 2009 Timings.1
-rw------- 1 100291000 1000_shared 16078 Oct 08 2009 main.c
-rw------- 1 100291000 1000_shared 1367 Oct 08 2009 mdh_opt.cl
-rw------- 1 100291000 1000_shared 814 Oct 08 2009 mdh_orig.cl

 

 

That's the ouput incl. the hidden files:

/accounts/1000/shared/videos/Edu/OpenCL Course/delete/iis$ ls -la
total 80
drwxr-sr-x 3 100291000 1000_shared 4096 Oct 08 2009 .
drwxrwsrwx 3 100291000 1000_shared 4096 Jul 30 23:59 ..
-rw------- 1 100291000 1000_shared 6148 Oct 08 2009 .DS_Store
drwx--S--- 2 100291000 1000_shared 4096 Oct 08 2009 Episode_6.xcodeproj
-rw------- 1 100291000 1000_shared 3041 Oct 08 2009 Timings.1
-rw------- 1 100291000 1000_shared 16078 Oct 08 2009 main.c
-rw------- 1 100291000 1000_shared 1367 Oct 08 2009 mdh_opt.cl
-rw------- 1 100291000 1000_shared 814 Oct 08 2009 mdh_orig.cl

 

 

 

Developer
Posts: 195
Registered: ‎05-09-2012
My Device: Playbook, Z10 LE

Re: Changing file ownership programmatically?

Yes, but it was unzipped as user "100291000".  It is possible to rename the parent directories but the files cannot be changed, neither from inside of Playbook, nor from Windows, nor by logging with SSH.

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

Re: Changing file ownership programmatically?

If you have access to the parent folder with the necessary ownership and permissions, you can ultimately do anything to the stuff contained within. Have you tried changing ownership on that folder, or changing its permissions, and then changing ownership or permissions on the contained items?

Worst case, since you can access everything in there, you can definitely make a copy of the tree, which would give you a duplicate tree which you owned (i.e. it would be owned by whatever user made the copy). You could then delete the original, as you should have the necessary permissions via being in the 1000_shared group.

I re-read your original post and am not clear on whether this is a one-time thing you're attempting to resolve, and just want to delete all or some of the files, or whether this is for an app and something you'll want to automate in future and do repeatedly. The quickest approach may be suitable for the former but not the latter.

(Also, since I believe the info you need to resolve the problem in the best way for you is shown above in your output, maybe you're not clear on how posix filesystem ownership and permissions work? You might read http://en.wikipedia.org/wiki/Filesystem_permissions#Traditional_Unix_permissions or similar pages for more on that. Apologies if you already know all that stuff, but then I'm unclear on what else you need to know.)

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: 1,068
Registered: ‎11-24-2011
My Device: PlayBook
My Carrier: x

Re: Changing file ownership programmatically?

Good question for everybody: if I start Web Browser (or any other program) what uid:gid is this process running with? 

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

Re: Changing file ownership programmatically?

Should be same as any app, with a unique uid and gid. Note that the more important question may be what happens when it creates files in the shared area. Since the "group sticky" bit is set (I don't really know what that's called, but it's what you'd get with "chmod g+s" on a folder) the files will have group ownership of 1000_shared. The uid would be whatever the browser is, which isn't really important since it may differ on different devices, and in any case is unique to that app.

If you want to see specifically on your device, I suggest downloading a file, then checking in shared/downloads to see what it comes up with for ownership.

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!