copy db file with adb pull results in 'permission denied' error

前端 未结 15 775
执笔经年
执笔经年 2020-12-13 17:13

I just rooted my Nexus 5 using this method: http://www.phonearena.com/news/How-to-root-Google-Nexus-5_id49014

I also enabled USB debugging in the developer options.<

相关标签:
15条回答
  • 2020-12-13 17:41

    When executing adb commands, by default, a limited privileges user is used, the same kind of limited privilege user that is assigned to an app, and you have requested for all privelages to use all features of the device.

    This kind of limited user helps protect your phone from malware, by restricting the access between apps, and the system. This is the reason you are unable to access app data and system data on an unrooted phone. The act of rooting means becoming user 0, the super user of the system, capable of any action, and is the highest privilege. Your apps however, are still secure in that they can not talk to eachother.

    Now when accessing secure files, note that you do not want to change the permissions of the file when you access it, which may allow for vulnerabilities.

    An option that you could use instead, is to make a copy of the file on the sdcard as root, modify that as a standard user, and then move it back into the filesystem as root, while preserving the file permissions of the original file.

    0 讨论(0)
  • 2020-12-13 17:43

    This answer ended up working for me: https://stackoverflow.com/a/15559278/53001

    Backup to a file, pull the backup, and then convert it to a tarball and extract it.

    adb backup  -f myAndroidBackup.ab  com.corp.appName
    
    dd if=myAndroidBackup.ab bs=1 skip=24 | python -c "import zlib,sys;sys.stdout.write(zlib.decompress(sys.stdin.read()))" | tar -xvf - 
    
    0 讨论(0)
  • 2020-12-13 17:44

    I had just the same problem, here's how to deal with it:

    1. adb shell to the device
    2. su
    3. ls -l and check current access rights on the file you need. You'll need that later.
    4. go to the file needed and: chmod 777 file.ext. Note: now you have a temporary security issue. You've just allowed all the rights to everyone! Consider adding just R for users.
    5. open another console and: adb pull /path/to/file.ext c:\pc\path\to\file.exe
    6. Important: after you're done, revert the access rights back to the previous value (point 3)

    Someone mentioned something similar earlier.

    Thanks for the comments below.

    0 讨论(0)
  • 2020-12-13 17:45

    If you get could not copy and permissions are right disable selinux.

    Check if selinux is enabled.

    $ adb shell
    $su
    # getenforce
    Enforcing
    

    Selinux is enabled and blocking/enforcing. Disable selinux

    # setenforce 0
    

    do your stuff and set selinux to enforcing.

    # setenforce 1
    
    0 讨论(0)
  • 2020-12-13 17:45
    1. Create a folder in sdcard :
    adb shell "su 0 mkdir /sdcard/com.test"
    
    1. Move your files to the new folder :
    adb shell "su 0 mv -F /data/data/com.test/files/ /sdcard/com.test/"
    
    1. You can now use adb pull :
    adb pull /sdcard/com.test
    
    0 讨论(0)
  • 2020-12-13 17:47

    The pull command is:

    adb pull source dest
    

    When you write:

    adb pull /data/data/path.to.package/databases/data /sdcard/test
    

    It means that you'll pull from /data/data/path.to.package/databases/data and you'll copy it to /sdcard/test, but the destination MUST be a local directory. You may write C:\Users\YourName\temp instead.

    For example:

    adb pull /data/data/path.to.package/databases/data c:\Users\YourName\temp
    
    0 讨论(0)
提交回复
热议问题