Still cant write to /System/Library/CoreService although my app is root - iphone

As the topic describes, my app is in /Applications folder and it has got root access but still i cant write/Edit a file in /System/Library/CoreServices.
Can anyone advice me on how to do this?
P.S. I m developing for Jailbroken iOS4 (iOS 4 SDK).

Alright, got this working, you got to have root access with admin as group and SetUID flag should be set to write to that specific location. What i did is, i saw the directory structure of Cydia.app and compiled my app according to that(e.g. Cydia and Cydia_).
Rename your app name to YourApp_ and make a new file named YourApp and post the text below into it, set the proper permissions and you are good to go.
#!/bin/bash
C=/${0}
C=${C%/*}
declare -a flags
exec "${C:-.}"/MyApp_"${flags[#]}" -- "$#" 2>>/tmp/MyApp.log`
BTW YourApp binary should have a permission of 4755 to setuid flag as well.

Have you checked the flags for that directory? Maybe it's set as "system immutable". Take a look at the chflags command to learn more about file's flags.

Related

Need help to write a basic Command Line code

I'm using Windows 10 if it matters and I'm trying to feed a file to the "oeminst" app that will convert this file from .EDR to .CCSS. According to the app's website its usage summary is this:
oeminst [-options] [inputfiles]
-v Verbose
-n Don't install, show where files would be installed
-c Don't install, save files to current directory
-S d Specify the install scope u = user (def.), l = local system]
infile Manufacturers setup.exe install file(s) or .dll(s) containing install files
infile.[edr|ccss|ccmx] EDR file(s) to translate and install or CCSS or CCMX files to install
If no file is provided, oeminst will look for the install CD.
more info can be found here https://www.argyllcms.com/doc/oeminst.html
So far I tried this code:
C:\Users\PC>oeminst infile. [C:\Users\PC\testfile.edr]
oeminst: Error - Unable to load file 'infile [C:\Users\PC\testfile]'
I'd appreciate if someone at least could tell me if I'm doing it right or not.
P.S. sorry for the messed up text. Not sure how to fix it. It looks good in editing mode.
Try this : oeminst infile.edr C:\Users\PC\testfile.edr
Nevermind, I got it.
C:\Users\PC>oeminst C:\Users\PC\testfile.edr

File not found error when using cyberduck CLI for OneDrive

I want to upload encrypted backups on OneDrive using cyberduck to avoid local copys. Having a local file called file.txt I want to upload in folder Backups from OneDrive root, I used this command:
duck --username <myUser> --password <myPassword> --upload onedrive://Backups .\file.txt
Transfer incomplete…
File not found. /. Please contact your web hosting service provider for assistance.
It's not even possible to get the directory content using duck --username <myUser> --password <myPassword> --listonedrive://Backups command. This also cause a File not found error.
What I'm doing wrong?
I exactly followed the documentation and have no clue why this is not working. Cyberduck was installed by using chocolately, current version is Cyberduck 6.6.2 (28219)
Just testing this out, it looks like OneDrive sets a unique identifier for the root folder. You can find that by either inspecting the value of the cid parameter in the URL of your OneDrive site or I found it by using the following command
duck --list OneDrive:///
Note, having three slashes is important. It would appear the first two are part of the protocol name and the first specifies you want the root. The result should look like a unique id of some sort like this: 36d25d24238f8242, which you can then use to upload your files like:
duck --upload onedrive://36d25d24238f8242/Backups .\file.txt
Didn't see any of that in the docs... just tinkering with it. So I might recommend opening a bug with duck to update their docs if this works for you.
What happens if you use the full path to the file, it looks like it is just complaining about not finding the file to uploads so could be you are in a different directory or something so it needs the full path to the source file.

Capistrano v3 not able to cleanup old releases

Since I'm running my rails app as root, it creates files that are owned by root in the tmp directory. Because of this
cap production deploy:cleanup
can't remove old releases because it is not run as root.
I've looked at the capistrano v3 code, but I don't see a way to run the cleanup command as root. Is this option missing or is this problem occurring because I'm doing something wrong in another place of the deployment flow.
I start the app as root because I need to bind to port 80.
What you can also do is triggering a task just before cleaning up the old release :
namespace :deploy do
before :cleanup, :cleanup_permissions
desc 'Set permissions on old releases before cleanup'
task :cleanup_permissions do
on release_roles :all do |host|
releases = capture(:ls, '-x', releases_path).split
if releases.count >= fetch(:keep_releases)
info "Cleaning permissions on old releases"
directories = (releases - releases.last(1))
if directories.any?
directories.each do |release|
within releases_path.join(release) do
execute :sudo, :chown, '-R', 'deployuser', 'path/to/your/files/writtend/by/root'
end
end
else
info t(:no_old_releases, host: host.to_s, keep_releases: fetch(:keep_releases))
end
end
end
end
end
Note that you'll need to give your deployment user the right to execute this specific sudo command (with a sudoers definition file.
I've looked at the capistrano v3 code, but I don't see a way to run the cleanup command as root. Is this option missing or is this problem occurring because I'm doing something wrong in another place of the deployment flow.
There is no secret sauce in Capistrano, we rely on you having correctly set up the permissions for your deploy user as documented at http://www.capistranorb.com/
Removing directories requires write permissions on the parent directory, that is to say, given the following directory structure:
/var/www/releases/
\- 20131015180000
\- 20131015181500
\- 20131015183000
You need write permission on the /var/www/releases/ directory, as the list of files and directory in that directory, is stored in the directory.
From a similar StackSverflow question:
In UNIX and Linux, the ability to remove a file is not determined by the access bits of that file. It is determined by the access bits of the directory which contains the file.
From the Wikipedia article on Unix File Permissions:
The write permission grants the ability to modify a file. When set for a directory, this permission grants the ability to modify entries in the directory. This includes creating files, deleting files, and renaming files.
One of the things you may want to do is to create a group called app or web on your linux box and add root and the deploy user to the same group. Then, as part of your deployment, chmod the release_path permissions to g+s which will ensure that any new files created by root user are group writable.
You should then be able to remove the old folders as deploy user.
I was running into similar issues, so, to confirm, logged into my Web server via SSH, and tried rm -rf [directory], which also failed due to the same permissions issues, even logged in as admin. Running chmod -R 755 [directory]/, then rm -rf [directory]/ did work, though.
To fix it, in the project's silverstripe.rake file, I changed the command being run from:
execute :chown, "-R [user]:[group] /path/to/project"
to:
execute :chmod, "-R 755 /path/to/project"
So far, no more issues with deleting the oldest release when running cap [release name] deploy

Is it possible to search though all xcodes logs

XCode now keeps the logs from the previous runs handy which is great.
Is there a way to search though all of the logs.
My use case is I have seen a particular error but cant remember which run it was in. I need to find the error URL from the logs.
Xcode stores debug logs at
~/Library/Developer/Xcode/DerivedData/<YOURAPP>/Logs/Debug/
The .xcactivitylog files are actually just gz archives. Decompress them:
cd ~/Library/Developer/Xcode/DerivedData/<YOURAPP>/Logs/Debug/
EXT=".xcactivitylog"
for LOG in *.xcactivitylog; do
NAME=`basename $LOG $EXT`
gunzip -c -S $EXT "${NAME}${EXT}" > "${NAME}.log"
done
Now you can easily search them using grep or Spotlight or what your prefer.
To add onto #DrummerB answer. Once the files are unziped you can do a search with custom scope from within XCode. I prefer this to grep or spotlight.
The folder where these logs are is
~/Library/Developer/Xcode/DerivedData/[YOURAPPID]/Logs/Debug/
You can open/read/search them for example in TextWrangler.

Delete App (.apk) in emulator?

I know of two ways of deleting an app under development from the emulator:
Using the emulator GUI: Settings >
Applications > Manage Applications >
Uninstall
Using ADB: adb uninstall
I may have discovered a third way, using 'adb shell':
rm /data/app/<package>.apk
It seems, however, that this isn't really a good way to delete apps because there may be additional information associated with it (registration?).
What is that information and where can it be found?
It's interesting you mention this. I ran a quick home made test to shed some light onto your question.
Generally, when you install a .apk file, Android creates an internal storage area for it located at /data/data/< package name of launching activity>. This is mainly used as an internal caching area that cant be accessed by other apps or the phone user. You can read up about that in a little bit more detail in the Internal storage chapter of Androids data storage section. It is an area exclusively used by your app and you can write private data there.
Once you uninstall an app theoretically, this internal storage area is also deleted. The first 2 ways which you outlined indeed does that: the .apk file in /data/app/ is deleted aswell as the internal storage area in /data/data/.
However if you used adb shell and run the rm command, all that is removed is the .apk file in /data/app/. The internal storage area in in /data/data/ is not deleted. So in essence you are correct that additional information with the app is not necessarily deleted. But on the flip side, if you reinstall the app after running the command, then the existing internal storage area gets overwritten as a fresh copy of it is being installed.
adb uninstall com.example.test
com.example.test may vary acording to your app.
I was having a problem with this too. I have Link2SD on my phone, but the ext4 partition on my SD card corrupted, so I reformatted, but all of the linked files were still in the /data/app folder. So I created a script to delete all broken links, and ran into the same problem as you, the app manager said they were still installed! so I made another script to fix that, using the pm program on your phone.
heres my code to remove broken links from the app folder:
fixln.sh
#!/system/bin/sh
#follow and fix symlinks
appfolder="/data/app/"
files=`ls ${appfolder}*`
fix=$1
badstring="No such file or directory"
for i in $files
do
if [ -h $i ]
then
if [ -a `readlink $i` ]
then
echo -e "\e[32m$i is good\033[0m";
else
if [ $fix == "fix" ]
then
`rm $i`
echo -e "\e[31m$i is bad, and was removed\033[0m";
else
echo -e "\e[31m$i is bad\033[0m";
if
fi
else
echo -e "\e[36m$i is not a symlink\033[0m";
fi
done
and heres my code to uninstall apps that have no apk:
fixmissing.sh
#!/system/bin/sh
#searches through a list of installed apps, and removes the ones that have no apk file
appfolder="/data/app/"
fix=$1
installed=`pm list packages -f -u`
for i in $installed
do
usefull=${i#*:}
filename=${usefull%=*}
package=${usefull#*=}
if [ -a $filename ]
then
echo -e "\e[32m$package ($filename) is good\033[0m"
else
if [ "$fix" == "fix" ]
then
uninstall=`pm uninstall $package`
if [ "$uninstall" == "Success" ]
then
echo -e "\e[31m$package ($filename) is bad, and was removed\033[0m"
else
echo -e "\e[31m$package ($filename) is bad, and COULD NOT BE REMOVED\033[0m"
fi
else
echo -e "\e[31m$package ($filename) is bad\033[0m"
fi
fi
done
copy these files to your phone, and run them with no arguments to see what they find, or add fix onto the end (fixmissing.sh fix) to make them fix what they find. Run at your own risk, and back up your files. I am not responsible if this code in any way wrecks anything.
If anyone wants to update/merge these scripts together, thats fine. these were just made to fix my problem, and they have done so, just thought I'd share them.
I believe any files the app has created on the sdcard would not be deleted.
There is another way - using the emulator like a real device -
locate the app in the emulator and drag it up to uninstall it.