yashsingh1/xdaforums huggingface dataset:
[G1 Android Development] Beast84:
Wow so many versions everywhere in this thread. Maybe the first post should be updated with the current version. It makes no sense having to dig through the whole thread to find a current version. I know the thread isn't that big right now but if it grows, the way its set up now is gonna suck. Just my .02
[G1 Android Development] chevycowboyusa:
New log for 1.12

Here's a new log. I hadn't installed anything new, but ran it anyway.

R/ Chevy
[G1 Android Development] smeat:
Minor fixup:

remove unneeded file checks in the chown/chmod loop
[G1 Android Development] smeat:
Do you really have that many applications that you installed, but then just deleted from the app directory without doing a proper uninstall? If you still have those applications installed could you post your "/data/system/packages.xml"? There might be some weirdness going on here.
[G1 Android Development] smeat:
I can't edit the first post, and this project is probably coming to a close real soon now.
[G1 Android Development] :
I can't update the first post at each new version....
[G1 Android Development] :
I've just installed a fresh Cyanogen on my Magic (with the new compiled kernel :) ) and I've tried to launch the last version on our script (1.14). In attachment you can observ the log. It looks strange that you are going to change the ownership of the .apk file in /system/app/ and /data/app/. Why?! It is not standard.
[G1 Android Development] farmatito:
Did you notice any malfunctioning due to this changes?

It is just enforcing the uids found in packages.xml.

Shouldn't due no harm.

BTW are the new uids of the apks retained after a reboot?

PS:: probably the original ownership is due to the cooking

of the rom with root privileges?

PPS.: Did you try to uninstall/reinstall an app to see if there are some problems?
[G1 Android Development] farmatito:
# v1.15 - Apply correct ownership and permissions to the apks. [by farmatito]

Needs a little more testing.
[G1 Android Development] chevycowboyusa:
I'll give it a go...

I think I can do this, just mount and cp /data/system/packages.xml /sdcard ???

add .txt to it, and should be good. (I'm @ work so it might be a few hours)

Thanks for your help!
[G1 Android Development] smeat:
Yeah, that should work.
[G1 Android Development] smeat:
fix_permissions has always done this. I am not sure why, but it has.
[G1 Android Development] smeat:
This is from the original script that fix_permissions is based on:

Is this what you did with this change?
[G1 Android Development] farmatito:
No, this only does:

chown 0.0 /system/app/*.apk
chmod 644 /system/app/*.apk
chown 1000.1000 /data/app/*.apk
chmod 644 /data/app/*.apk
chown 1000.gid /data/app-private/*.apk
chmod 640 /data/app-private/*.apk

The sharedUserid = 1000 refers to /data/data/package

and is handled correctly as far as i can see as we

extract sharedUserid from packages.xml
[G1 Android Development] smeat:
Interesting, so the previous versions of the fix_permissions script were incorrectly applying ownership to the .apks? In this scheme the only apk that gets assigned anything to do with the UID is /data/app-private having the group ownership changed to UID.
[G1 Android Development] smeat:
Tested the changes farmatito made, seem right to me.

Very minor clean ups:

changed all command subsitutions to be new style
[G1 Android Development] :
I have reinstalled many applications from the old firmware (HoFo) restoring the old settings (data/data/...) without any problem (great!) but the ownership of the apk files should remains to root or 1000 user. The applications do not use the apk file, they are launched by the Launcher. To observe the standard behaviour, just install a fresh apk and look at the ownership. Don't make anything that is non-standard but that is nice for you. IMHO
[G1 Android Development] chevycowboyusa:
ran 1.6

Here's the log and packages xml

Will the packages.xml be rewritten if I wipe and reinstall rom?

Oh, and can you put the version number in the display line.

Starting Fix permissions v1.6. <= that would be great, then I could be sure if the install made it correctly.

Thanks, Chevy
[G1 Android Development] smeat:
The changing ownership of the .apk files to the packages.xml userId was from the original version of the script. The newest version changes the applications to their proper ownership.

Like farmatito lists:

chown 0.0 /system/app/*.apk
chmod 644 /system/app/*.apk
chown 1000.1000 /data/app/*.apk
chmod 644 /data/app/*.apk
chown 1000.gid /data/app-private/*.apk
chmod 640 /data/app-private/*.apk
[G1 Android Development] farmatito:
# v1.17 - Print version [by farmatito]

Trivial changes, but untested.
[G1 Android Development] chevycowboyusa:
Tested....

Here's my log.

Anyone figure out how to rebuild the packages.xml without wiping and reinstalling?

Can I => mv /data/system/packages.xml /data/system/packages.old

and reboot and see if it will rebuild it?

I'll try it, but I'd like some expert advice before I do it.

Thanks,

Chevy

P.S. Thanks for putting the build ver in the run line!
[G1 Android Development] farmatito:
Maybe you can try to:

mv packages.xml packages.xml.old

reboot

Can't say if this has some side effects.

I did it once and it worked for me.
[G1 Android Development] chevycowboyusa:
That was my thought...

That's what I was thinking. I'll nandroid and try it. Run the script again and post my log if you'd like.

New question. If the permissions are changed, and i reflash my current rom, will they be set back to what the were before i ran fix_permissions (if that makes sence)??

Edit: Whoa.... I just looked at the file in word pad and understood whats going on.... Totally shocked! the endif is "FI" thats so cool!

Thanks
[G1 Android Development] farmatito:
They will be set to the value requested by the packages.xml file,

so probably the will be already ok.
[G1 Android Development] chevycowboyusa:
Ahhhhhhh.. oh well

interesting... ok, i had to resign in, but i still have all my apps, so not bad.

I had some bookmarks on the mail page dissappear, but no biggie.

Here's the new log... Whole lotta different stuff this time.

And as an added bonus, i got some text messages that I havent received in days!!!
[G1 Android Development] smeat:
Looking good, you must have had some apps that were installed incorrectly. After the reinstall and the fix_permissions I think you should be set.
[G1 Android Development] smeat:
Minor change to make it so that you know fix_permissions is doing something.

print what app fix_permissions is working on
[G1 Android Development] aryndar:
FCs

ran fix_permissions_1.18.txt

bunches of FCs with reboot...

reboot again, same FCs

here's the logcat

luckily, I nandroid before running, restored and now I am running fine...
[G1 Android Development] AntiNSA:
I would like to try your version of fix permissions. I am having the problem after updating to cy's newest rom that some of my installed programs are missing their icons. I have installed the pimped out recovery rom, and then did the fix_permissions...

Before doing that I could not run the programs with the strange/missing icons... now I can run them, however the icons are missing and I can not access the downloads section of the market... I think this is due to permissions. I have an ext3 partition.

Can you tell be the evact commands for after I download your txt file?

I mean, I download it , copy it to the root dir on my sdcard, then from terminal emulator what are the exact commands to type in stpe by step to get access to your updated fixed_permissions ?

Sorry I am also new to this.

Thanks
[G1 Android Development] aryndar:
From ABD

1. Download the newer fix_permissions script .

2. adb shell mount -o remount,rw /dev/block/mtdblock3 /system

3. adb push fix_permissions_X.X.txt /system/bin/fix_permissions

4. adb shell busybox chmod 755 /system/bin/fix_permissions

5. adb shell mount -o remount,ro /dev/block/mtdblock3 /system

6. adb shell fix_permissions

From Terminal

download the file to the root of your SD card, then enter

$ su

# mount -o remount,rw /dev/block/mtdblock3 /system

# cp /sdcard/fix_permissions_X.X.txt /system/bin/fix_permissions

# chmod 755 /system/bin/fix_permissions (gives root access)

# reboot

To run, open the terminal and enter

$ fix_permissions

the colored is whatever version # you're using
[G1 Android Development] farmatito:
To run, open the terminal and enter

$ su
# fix_permissions
[G1 Android Development] oneyoungjay:
So question, is each txt update individual, so each of the 17 ish updates should be run or is each update txt just continue the previous.
[G1 Android Development] smeat:
They are all just revisions of the same command. So the latest does everything you need. No need to run anything other than the latest.
[G1 Android Development] smeat:
Very weird, the errors you are seeing are exactly what this script is supposed to fix. Could you send me your /sdcard/fix_permissions.log after a fix_permissions run.
[G1 Android Development] onyonees:
help please

Running cyanogen 4.0.2 and it runs great on my mt3g. I get one force close measage for toggle settings everytime i reboot. I run the first set of scripts provided above as an initial command in terminal emulator and it says permission denied. Can someone please help me out?
[G1 Android Development] farmatito:
@ onyonees

Open the terminal and enter

$ su
# fix_permissions
[G1 Android Development] chevycowboyusa:
No log

I just ran 1.18. No errors I guess, and no log was output.

Could you please put the version back in? It didn't say starting or ending, which isn't that big of a deal for me. Once there is a final version I wouldn't mind ver/starting/stopping/log not being there.

You guys are making a great contrubution to the community!

Thanks a bunch!
[G1 Android Development] esskaypee:
It works!

I've just done this, including the bold red edits, which were also pointed out in the thread before. I started fresh with Cyan4.0.2, copied the updated fix_permissions, rebooted and it ran far cleaner than the original version) and everthing is PERFECT. Thanks. :)
[G1 Android Development] smeat:
I don't understand... the 1.18 version still has the starting and ending messages with the version. Just in addition it tells you what application it is checking.
[G1 Android Development] onyonees:
@ farmatito

Thanks for responding. After i entered

$ su

# fix_permissions

Aa wondow pops up asking me to allow

or deny a program so i choose always allow.

After that ## showed after the last line.

What does that mean?
[G1 Android Development] smeat:
Just type:

su

fix_permissions

If it asks you for root permission allow it.
[G1 Android Development] onyonees:
worked like a charm, THANKS i appreciate it.

Ive been including the $ and # in my command lines lol.
[G1 Android Development] aryndar:
re-ran 1.18....

Two items of note.

1. I ran 1.18 from THE CONSOLE, which caused the FCs and does not make a fix_permissions.log

2. Ran again from THE TERMINAL, everything runs good (took forever to run...), no FCs plus a fix_permissions.log WAS created in /sdcard

In the instructions, it should be noted to run this from THE TERMINAL (if possible). Seems to work better there than from the CONSOLE

Thanks

Good work gang!
[G1 Android Development] farmatito:
What exactly do you mean with CONSOLE?
[G1 Android Development] B-man007:
Recovery's terminal
[G1 Android Development] farmatito:
I think that to run in recovery's console you have to change the first line from

#!/system/bin/sh

to

#!/sbin/sh

In version 1.19 I've added a warning about that and improved the debug info a little.
[G1 Android Development] chevycowboyusa:
Duh...

You would think after doing this 18 now 19 times, i would remember to do the chmod.. LOL

ok, here's the log.

Chevy

I should try my hand at a script to automate this!

if I copy the code into a txt file and push it to system bin and run it, would it work?

ima gonna tryit!
[G1 Android Development] smeat:
Looks great, it corrected the .apks being wrongly assigned to the user, and you should be set now.
[G1 Android Development] smeat:
Minor logging:

print what app fix_permissions is working on to the log as well
[G1 Android Development] rikupw:
regarding fix_permissions

I have noticed (though it isn't THAT important really) that the latest (1.19 i believe) script changed permissions on the "one click-root" applications files (asroot, dumpsys, recovery.img)

I attatched the log, just cat/grep flashrec and you'll see what it did :)

I thought this might be something to look for when using the script as it could (maybe) disable some of the rooted applications functionality?
[G1 Android Development] smeat:
It shouldn't affect anything, that application runs as root so it will be able to write to the files and directories properly. Besides, the file and directories it corrected had the wrong permissions, at least from what I have seen from other android applications.
[G1 Android Development] chevycowboyusa:
v1.20 great

1.20 ran great! Only made two changes... I can't post a log right now, but probably same data as usual...

Waiting for 1.21....
[G1 Android Development] igashu:
Is there a good/easy way to replace the fix_permissions script in the recovery console with this one?
[G1 Android Development] innerspace:
adb shell
cd /system/bin
mv fix_permissions fix_permissions.old

then exit and

adb push <whateverpathto>fix_permissionsX.XX.txt /system/bin/fix_permissions
adb shell
chmod 755 /system/bin/fix_permissions

That should do it.
[G1 Android Development] igashu:
Sorry, I was actually referring to the version of the script in /sbin on the recovery partition -- wasn't sure if there was a way I could mount/access it without rebooting into recovery, but I guess I can just drop the script in /system and then reboot into recovery, mount system, and copy it over to /sbin.

Once things get stable we should get Cyanogen to include the updated script in his cm-recovery package.
[G1 Android Development] smeat:
You need a modified version of the script to run in recovery though, here is the 1.20 version with the additions for recovery.
[G1 Android Development] overground:
How do we go about replacing the fix_permissions in recovery? Just place this script in /system/bin, chmod 755, and it will work in recovery? Thanks to you guys for putting in the effort on this...I've been following the progress since post #1.

EDIT: Nevermind, I found this at the beginning of the script: "Warning: if you want to run this script in cm-recovery change the above to #!/sbin/sh"
[G1 Android Development] farmatito:
# v1.21 - Handle filenames with spaces correctly - fix version numbering - echo is a busybox applet [by farmatito]
[G1 Android Development] Afirejar:
I changed that, and it still doesn't work in recovery. The issue seem to be assumptions about the mounted partitions, that aren't true in recovery.

This is the output of mount in recovery.

rootfs on / type rootfs (rw)
tmpfs on /dev type tmpfs (rw,mode=755)
devpts on /dev/pts type devpts (rw,mode=600)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
/dev/block/mtdblock4 on /cache type yaffs2 (rw,nodev,noatime,nodiratime)

Note /data, /system and /system/sd aren't mounted.

This is the mounting code of 1.21:

mount -o remount,rw /dev/block/mtdblock3 /system

This is the mounting code of the script included in the 1.4 recovery:

mount /system > /dev/null 2>&1
mount /data > /dev/null 2>&1

if [ -e /dev/block/mmcblk0p2 ];
then
mount /system/sd > /dev/null 2>&1
fi

Mounting the partitions like the old script does should fix that.
[G1 Android Development] farmatito:
We could add a command line switch for running in recovery:

fix_permissions -r
[G1 Android Development] chevycowboyusa:
ran 1.21

Looks like you have this dialed in pretty good! I ran 1.21 after installing cm 4.0.3.1 and a few apps.

Typical results occured. Then new apps changed their user and group ownership and a few were chmoded 660. Sorry I can't post a log right now, unless either of you would like it emailed. I'm working nights, so I'm going to bed now.

If you get the -r into the next revision I'll try that tonight!

Great job as always! I'm glad to help in any way I can!

Chevy
[G1 Android Development] smeat:
The fix_permissions in this post will work in recovery.
[G1 Android Development] smeat:
Today I might work on trying to detect if we are in recovery or not, however there is no way to change the shell definition on the fly so we have to have different versions for recovery anyway, so maybe it is not worth it.
[G1 Android Development] farmatito:
Post deleted
[G1 Android Development] farmatito:
# v1.22 - [ is a busybox applet when android shell is used, just for compatibility [by farmatito]
[G1 Android Development] smeat:
Continued busyboxification.

chmod, cat, mount and umount are busybox applets as well

make sure drives are mounted

run nearly unchanged in recovery/ROM

I tried to make it so you could run the script unmodified in either recovery or the ROM, but the paths are too different for sh. It looks like there has to be at least a change to the shebang to run.
[G1 Android Development] farmatito:
I think you can change this

$ECHO "Usage $0 $TESTOPTION "

to

$ECHO "Usage $0 [OPTIONS]"

:D
[G1 Android Development] farmatito:
# v1.24 - Minor cosmetic fix.
[G1 Android Development] Copyright5:
This works very well, it solved a problem for me that the other one wouldn't. You should start a Google Project page for this :D.
[G1 Android Development] farmatito:
# v1.25 - Remove debug switch (needs getopt) add switch (-r) to remove stale data dirs of uninstalled apk packages. [by farmatito]

# v1.26 - Autodetect on which device /system is. [by farmatito]
[G1 Android Development] Copyright5:
Thanks for the update.
[G1 Android Development] farmatito:
# v1.27 - Don't complain if we can't remount /system ro and other minor fixes
[G1 Android Development] sactomkiii:
can someone post a edu on the front page of how to run the script? Thanx!
[G1 Android Development] Burag:
adb shell fix_permissions

:)
[G1 Android Development] Chahk:
I installed and executed the latest (v1.27) script in terminal (not recovery console) and for the most part it was able to repair permissions. However, for all system apps it was giving me the following:

Changing user ownership for: /system/app/Browser.apk from '10034' to '0'
chown: /system/app/Browser.apk: Read-only file system
Changing group ownership for: /system/app/Browser.apk from '10034' to '0'
chown: /system/app/Browser.apk: Read-only file system
Unable to chmod /system/app/Browser.apk: Read-only file system

Do I need to mount /system as rw before running fix_permissions? And yes, I did "su" before executing the script.
[G1 Android Development] farmatito:
# v1.28 - Fix mount rw /system and other minor fixes

@Chahk

Can you test if this version fixes the problem for you?
[G1 Android Development] farmatito:
# v1.29 - Fix some broken tests
[G1 Android Development] maybeoneday:
So v1.29 will run from terminal using code from a post I saw a couple pages back?

$ su

# mount -o remount,rw /dev/block/mtdblock3 /system

# cp /sdcard/fix_permissions_X.X.txt /system/bin/fix_permissions

# chmod 755 /system/bin/fix_permissions (gives root access)

# reboot

To run, open the terminal and enter

$ su

$ fix_permissions
[G1 Android Development] farmatito:
$ su
# mount -o remount,rw /dev/block/mtdblock3 /system
# cp /sdcard/fix_permissions_X.X.txt /system/bin/fix_permissions
# chmod 755 /system/bin/fix_permissions
# chown root.shell /system/bin/fix_permissions
# fix_permissions

or

adb remount
adb push fix_permissions_X.X.txt /system/bin/fix_permissions
adb shell
# chmod 755 /system/bin/fix_permissions
# chown root.shell /system/bin/fix_permissions
# fix_permissions
[G1 Android Development] Chahk:
Yep, that fixed it. Thanks!
[G1 Android Development] SladeOfDArk:
great work here guys this thread made me fall in love with the command line again this week

it fixed all the missing icons and stuff i was having. i was wondering does this have to be run each time you install a new rom or what?

here is a better command prompt

http://sourceforge.net/projects/con...l/2.00/Console-2.00b144-Beta_src.zip/download

go grab that if you are on winblows, if anyone knows of something better let me know please
[G1 Android Development] farmatito:
I always run it after flashing a rom and it seems to do no harm.

I think it should be hardcoded in the upgrade routine of recovery.

That way the devs would save a lot of time and reduce the posts in their threads about apps FC.
[G1 Android Development] rikupw:
I believe Cyanogen is working on that, :) but more along the lines of within the framework. but it sounds more difficult to do it as such :(
[G1 Android Development] crypticc:
Brief question. Is it correct to run this from recovery?

i.e. returning to stock, temporarily flashing cm recovery, adb pushing 1.29 and running this, I noticed that it sets ownership permissions of even freshy installed apps to "0". I swear when I've run from running terminal in rooted phone, it used to do these to 10003 or whatever?

Or have I got this wrong?
[G1 Android Development] farmatito:
The original version did it, but we changed it.

You can run it directly from adb, there is no need to go to recovery

unless your phone is not rooted.
[G1 Android Development] crypticc:
so run from adb terminal in recovery = bad?
[G1 Android Development] farmatito:
No, should be fine. :D
[G1 Android Development] crypticc:
Okay thanks. Turned out issue i think was backup system/sd/app i made when reparting ext3 to 4 and restore broke the symlink from data/app to sd/app.
[G1 Android Development] AndroidFiend:
also it doesnt check permissions for apps on sd (apps2sd)
[G1 Android Development] farmatito:
When run from recovery?

What version of fix_permissions?

The latest automatically mounts /dev/block/mmcblk0p2

/system/sd if it is detected.
[G1 Android Development] rikupw:
Modified for two options:

Ok! You'll all probably laugh at my attempt to script :P lol. since the only way I could get it to work was by copying and pasting, but here it is!

I modified the fix_permissiosn script (v.1.29) to allow for a specific package to be checked, as well as to allow for only checking non system packages. *shrugs* neither of which are useful for anyone but me, I think. howver, I 'm always annoyed at how long it takes to run fix_permissions :(

type -h for more info :P

-u only non-system permissions

-f (haen't figured out how to set this properly) --- for now, before you start the script, type: export SPEC="thename.of.package" and then run the script as "fix_permissions -f" it should work :)

change the file extension to .txt... apparently my over-zealousness went over 19.5kb >.>

BTW: renamed the file to .txt, I didn't even think about just zipping it up >.>
[G1 Android Development] farmatito:
@rikupw

Your zip file is corrupted, please repost.

Try:

fix_permissions -f filename

and in the script set:

filename=$2
[G1 Android Development] farmatito:
# v1.30 - Check only non system directories switch (-u) initial idea by rikupw, reimplemented by farmatito

# Improve option parsing [ by farmatito]

# Single package mode (-f) initial idea by rikupw, reimplemented by farmatito
[G1 Android Development] Charrion:
I'm getting 'unknown option' error if I attempt to run fix_permissions without any options.
[G1 Android Development] farmatito:
# v1.31 - Minor fix in option parsing
[G1 Android Development] rikupw:
regarding 1.31

Wow do I feel embarrassed XD Thank you farmatito, :) I hope you didn't go out of your way to do that :)

Actually I'm kind of glad that attatchment was corrupt, as I looked at your addition for the script, and realized how messy it was comparitively, thanks again! :)

-Riku