I have been developing an app to programmatically enable/disable Wi-Fi interface of my iphone. I have tried to use the Apple 80211( apple's private service) on my jail broken Iphone 4s (iOS 5.1.1) to make it work. However, thing does not work out as I expected.
I can successfully scan and get the status of Wi-Fi connection however, the method Apple80211SetPower to enable/disable WiFi seems does not work on iOS 5.
As I found out from SBsetting's WiFi toggle, It might also require to change the system property of WiFi at "/var/preferences/systemconfiguration/com.apple.wifi.plist". However, my app is failed to change system property in that file, I suspected the problem resulted from file property and ownership. Therefore, I imitated the file property of SBsetting's WiFi toggle, Still, it did not change a thing.
does anyone know how I could change the system property of this file? this is the code that I used. thanks and regards
NSMutableDictionary *plistDict =
[NSMutableDictionary dictionaryWithContentsOfFile:#"/var/preferences/SystemConfiguration/com.apple.wifi.plist"];
BOOL wifiState = [[plistDict objectForKey:#"AllowEnable"] boolValue];
NSLog(wifiState ? #"Yes" : #"No");
if (value == YES)
{
[plistDict setValue:[NSNumber numberWithBool:YES] forKey:#"AllowEnable"];
[plistDict writeToFile:#"/var/preferences/SystemConfiguration/com.apple.wifi.plist"
atomically: YES];
}
else if (value== NO)
{
[plistDict setValue:[NSNumber numberWithBool:NO] forKey:#"AllowEnable"];
[plistDict writeToFile:#"/var/preferences/SystemConfiguration/com.apple.wifi.plist"
atomically: YES];
}
On my phone (iOS 5.0.1, not 5.1.1), I see this in the SystemConfiguration directory:
iPhone4:/var/preferences/SystemConfiguration mobile$ ls -altr
total 144
drwxr-xr-x 3 root wheel 136 Dec 25 2007 ..
-rw-r--r-- 1 root wheel 181 Jul 26 2009 OSThermalStatus.plist
-rw-r--r-- 1 root wheel 79 Jan 10 2012 com.apple.mobilegestalt.plist
-rw-r--r-- 1 root wheel 60 Sep 30 00:47 com.apple.radios.plist
-rw-r--r-- 1 root wheel 1162 Sep 30 15:50 NetworkInterfaces.plist
-rw-r--r-- 1 root wheel 57087 Sep 30 15:51 com.apple.network.identification.plist
-rw-r--r-- 1 root wheel 127 Oct 1 01:04 com.apple.PowerManagement.plist
-rw-r--r-- 1 root wheel 7323 Oct 1 01:18 preferences.plist
-rw-r--r-- 1 root wheel 31648 Oct 1 01:18 com.apple.wifi.plist
-rw-r--r-- 1 root wheel 1223 Oct 1 01:18 com.apple.AutoWake.plist
drwxr-xr-x 2 root wheel 374 Oct 1 01:18 .
So, it looks like the user mobile (which is the user the apps normally run as) would not be able to write that file, with only read privileges.
You can take a look here at how to give your app root privileges.
Related
I am writing Unit Tests in Objective C.
The following is my code:
NSString *testTempDirectory = [NSString stringWithFormat:#"%#%#", NSTemporaryDirectory(), #"DC_Tests"];
NSURL *parentDirURL = [NSURL fileURLWithPath:testTempDirectory];
NSURL *testFolderURL = [NSURL fileURLWithPath:testFolderPath];
Now the path in testFolderURL is returned as
/var/folders/31/2dpztnmx4fzfxb87qtn5_n0wc49pvz/T/DC_Tests/testFolder/
But the original path is
/private/var/folders/31/2dpztnmx4fzfxb87qtn5_n0wc49pvz/T/DC_Tests/testFolder/
The original path is my expected path and since it is different, my assertion is failing.
Any idea as to how do I get the complete path.
Note: I tried absolute string, doesn't help.
Note that in Mac OS, the var folder is actually a linked folder to /private/var
$ ls -l /
total 45
drwxrwxr-x+ 61 root admin 2074 Jun 11 08:58 Applications
drwxr-xr-x+ 63 root wheel 2142 Jul 6 2016 Library
drwxr-xr-x# 2 root wheel 68 Aug 24 2015 Network
drwxr-xr-x# 4 root wheel 136 Jun 9 18:56 System
drwxr-xr-x 6 root admin 204 Apr 22 2016 Users
drwxrwxrwt# 4 root admin 136 Jun 15 09:53 Volumes
drwxr-xr-x# 39 root wheel 1326 Jun 9 18:56 bin
drwxrwxr-t# 2 root admin 68 Aug 24 2015 cores
dr-xr-xr-x 3 root wheel 4312 Jun 9 18:57 dev
lrwxr-xr-x# 1 root wheel 11 Oct 18 2015 etc -> private/etc
dr-xr-xr-x 2 root wheel 1 Jun 9 18:58 home
-rw-r--r--# 1 root wheel 313 Aug 23 2015 installer.failurerequests
dr-xr-xr-x 2 root wheel 1 Jun 9 18:58 net
drwxr-xr-x# 6 root wheel 204 Oct 18 2015 private
drwxr-xr-x# 59 root wheel 2006 Jun 9 18:56 sbin
lrwxr-xr-x# 1 root wheel 11 Oct 18 2015 tmp -> private/tmp
drwxr-xr-x# 13 root wheel 442 Apr 19 2016 usr
lrwxr-xr-x# 1 root wheel 11 Oct 18 2015 var -> private/var
So the simplest way to fix your test is to ignore the /private part from the path. (We had a similar issue with paths that contain the tmp folder on Mac OS as well)
I keep receiving the error SQLite3::ReadOnlyException: attempt to write a readonly database: UPDATE "users" SET "current_sign_in_at" = ?, "sign_in_count" = ?, "updated_at" = ? WHERE "users"."id" = ? when trying to sign into my Rails 4 app which uses the devise gem.
I figured it has something to do with permissions on the dev db so checked out the permissions of the dir first, it has a + tacked onto the end which after some googling still couldn't figure out what it's doing.
-rw-r--r-- 1 a36971 staff 2.1K 24 Jan 20:16 Gemfile
-rw-r--r-- 1 a36971 staff 5.7K 24 Jan 20:16 Gemfile.lock
-rw-r--r-- 1 a36971 staff 47B 7 Jan 22:31 README.md
-rw-r--r--+ 1 root staff 249B 7 Jan 19:57 Rakefile
drwxr-xr-x+ 8 root staff 272B 7 Jan 19:57 app/
drwxr-xr-x+ 7 root staff 238B 7 Jan 19:57 bin/
drwxr-xr-x+ 13 root staff 442B 22 Jan 20:14 config/
-rw-r--r--+ 1 root staff 153B 7 Jan 19:57 config.ru
drwxr-xr-x+ 8 root staff 272B 26 Jan 10:28 db/
drwxr-xr-x+ 4 root staff 136B 7 Jan 19:57 lib/
drwxr-xr-x+ 5 root staff 170B 8 Jan 15:51 log/
drwxr-xr-x+ 7 root staff 238B 7 Jan 19:57 public/
drwxr-xr-x 7 a36971 staff 238B 17 Jan 22:38 spec/
drwxr-xr-x+ 9 root staff 306B 7 Jan 19:57 test/
drwxr-xr-x+ 6 root staff 204B 7 Jan 20:19 tmp/
drwxr-xr-x+ 3 root staff 102B 7 Jan 19:57 vendor/
After cd ing into the db dir you can see there's nothing wrong with the permissions on the db itself:
-rw-r--r-- 1 a36971 staff 44K 26 Jan 09:30 development.sqlite3
drwxr-xr-x 5 a36971 staff 170B 22 Jan 20:14 migrate/
-rw-r--r-- 1 a36971 staff 2.2K 22 Jan 20:14 schema.rb
-rw-r--r-- 1 a36971 staff 1.2K 25 Jan 23:22 seeds.rb
-rw-r--r-- 1 a36971 staff 44K 26 Jan 09:23 test.sqlite3
So my questions are:
a) why is it unable to write to the db when there doesn't appear to be anything wrong with the permissions themselves
b) what does the + mean on mac os?
a) why is it unable to write to the db when there doesn't appear to be anything wrong with the permissions themselves
My best guess is that the db/ directory is owned by the root user, whereas the db/*.sqlite3 files are owned by user a36971. It may be necessary for the db/ directory to also be owned by user a36971.
Try changing the owner from root to a36971 for the db directory:
sudo chown a36971 db
b) what does the + mean on mac os?
+ sign means there are additional permission details not displayed by the default output from ls -l. Try running ls -le to see the details (source: http://tech.enekochan.com/en/2014/05/29/plus-and-at-symbols-listing-file-permissions-in-mac-os-x/).
Got the same error after running rails db:reset
Restarting the local server fixed my problem
Once an iOS device is jailbroken, we can build jailbreak apps (with theos) and it gets installed in the /Applications directory where the preloaded apps run with root privileges. If an app is built with Xcode, once it is installed, it gets into the /private/var/mobile/Applications/ folder, which is supposed to have Apple sandbox enforced (before jailbreak).
So, the questions I have are:
For a jailbroken device, will the apps in /private/var/mobile/Applications/ execute with root privileges or with mobile user privileges?
In case of Android, once rooted, the apps will have to gain root privileges by executing the su command. Is it the case when it comes to iOS as well?
I would like to understand the difference between these two development options (Theos / Xcode) and how it affects what operations my app can perform.
Not disagreeing with anything H2CO3 said, but to add some further clarification ...
Apps installed in /private/var/mobile/Applications/(†) with Xcode will run with user mobile privileges, even on jailbroken phones.
Even on a jailbroken phone, apps installed to /private/var/mobile/Applications/(†) will be sandboxed almost (‡) like apps on a jailed phone. So, no reading other (normal) apps' data, even if those files are owned by user mobile.
For a good description of the process that apps like Cydia use to run as root, see this answer. Or, just ssh into your phone, and take a look inside /Applications/Cydia.app/ yourself.
If you simply copy/install an app (without doing what H2CO3 suggested) to /Applications/, it won't be sandboxed, but it will still run with mobile (UID=501) privileges:
iPhone5:~ root# cd /Applications
iPhone5:/Applications root# ls -altr ./HelloJB.app/
total 220
-rw-r--r-- 1 root wheel 711 Apr 3 20:36 entitlements.xml
-rw-r--r-- 1 root wheel 297 Apr 3 20:36 entitlements-daemon.xml
-rw-r--r-- 1 root wheel 7972 Apr 3 20:36 embedded.mobileprovision
-rw-r--r-- 1 root wheel 58755 Apr 3 20:36 date.zip
-rw-r--r-- 1 root wheel 485 Apr 3 20:36 ResourceRules.plist
-rw-r--r-- 1 root wheel 8 Apr 3 20:36 PkgInfo
-rw-r--r-- 1 root wheel 1226 Apr 3 20:36 Info.plist
-rw-r--r-- 1 root wheel 10960 Apr 3 20:36 Icon\#2x.png
-rw-r--r-- 1 root wheel 8328 Apr 3 20:36 Icon.png
-rw-r--r-- 1 root wheel 451 Apr 3 20:36 HelloJB.plist
-rwxr-xr-x 1 root wheel 61088 Apr 3 20:36 HelloJB*
-rwxr-xr-x 1 root wheel 42688 Apr 3 20:36 HelloDaemon*
drwxr-xr-x 2 root wheel 136 Apr 3 20:36 en.lproj/
drwxr-xr-x 2 root wheel 102 Apr 3 20:36 _CodeSignature/
drwxr-xr-x 4 root wheel 544 Apr 3 20:36 ./
drwxrwxr-x 54 root admin 1904 Apr 5 02:14 ../
iPhone5:/Applications root# ps -Aef | grep HelloJB
501 9412 1 0 0:00.00 ?? 0:00.33 /Applications/HelloJB.app/HelloJB
iPhone5:/Applications root# grep mobile /etc/passwd
mobile:*:501:501:Mobile User:/var/mobile:/bin/sh
(‡) Here's a good discussion, with input from Saurik, about how different jailbreaks may affect the sandbox. Long story short: it depends.
(†) Update: in recent versions of iOS, the location of 3rd-party apps has been moved to /var/mobile/Containers, and later to /var/containers/, but the same basic sandbox issues remain.
Long story short: no.
Jailbreaking is a necessary but not sufficient condition for gaining root. Apps will still be sandboxed by default.
What you can do for making your app run with root privileges is creating a startup shell script that has root:wheel ownership and 755 permissions, then create your actual executable with the same ownership, 7555 as permissions (i. e. set its "setuid" bit), then call setuid(0); from within main(), before calling UIApplicationMain().
I have a Rails 3.2.5 app that is using Twitter Bootstrap. I am trying to use the JQuery UI datepicker. I have Googled this for days looking for a solution and can't find anything. I have a text field in a Rails view that I am trying to use with the JQuery datepicker. However, when I click in the text field, nothing happens.
In my Rails view, I have a simple text_field_tag like so:
<%= text_field_tag 'andrew' %>
In my associated CoffeeScript file:
$ ->
$('#andrew').datepicker
In the Chrome Developer Tools JavaScript Console, I see this error:
Uncaught TypeError: Object [object Object] has no method 'datepicker'
Now I have determined there is a conflict between JQuery-UI and Bootstrap. In that same JavaScript console, I can do this:
jQuery.noConflict();
and I get
function (a,b){return new e.fn.init(a,b,h)}
Then I can type:
$('andrew'.datepicker();
And I get:
[<input id="andrew" name="andrew" type="text" class="hasDatepicker">]
After this, when I go over to the browser window, clicking in the text field brings up the datepicker calendar just like I want it to.
So how do I get this to work in my code? That is, I am manually resolving the conflict in the JavaScript Console but I can't get it to work just through my code.
It looks like I have this one solved after much pain. I created a new project and slowly, methodically moved over pieces of my application to the new app. I finally uncovered a directory that was only in my project with the problem described above.
There was a 'public/assets' directory with the contents below. I don't recall creating this directory or putting these files in that directory. Renaming the directory to something different caused my JQuery-UI datepicker to work properly in conjunction with Twitter Bootstrap.
Here are the contents of public/assets:
-rw-r--r-- 1 andrunix staff 83360 Sep 3 18:01 application 6fc1172d858485077bbecdb82b96399a.css
-rw-r--r-- 1 andrunix staff 13546 Sep 3 18:01 application-6fc1172d858485077bbecdb82b96399a.css.gz
-rw-r--r-- 1 andrunix staff 100616 Sep 3 18:01 application-990a4cf0df42934fcc4c14aaf88b7ced.js
-rw-r--r-- 1 andrunix staff 35448 Sep 3 18:01 application-990a4cf0df42934fcc4c14aaf88b7ced.js.gz
-rw-r--r-- 1 andrunix staff 83294 Sep 3 18:01 application.css
-rw-r--r-- 1 andrunix staff 13484 Sep 3 18:01 application.css.gz
-rw-r--r-- 1 andrunix staff 100618 Sep 6 20:26 application.js
-rw-r--r-- 1 andrunix staff 35448 Sep 3 18:01 application.js.gz
-rw-r--r-- 1 andrunix staff 13826 Aug 30 17:42 glyphicons-halflings-f6675c325532ec11a984d58e172b8e2a.png
-rw-r--r-- 1 andrunix staff 8777 Aug 30 17:42 glyphicons-halflings-white-13553a5bf21ae3cc374006592488ec64.png
-rw-r--r-- 1 andrunix staff 8777 Aug 30 17:42 glyphicons-halflings-white.png
-rw-r--r-- 1 andrunix staff 13826 Aug 30 17:42 glyphicons-halflings.png
-rw-r--r-- 1 andrunix staff 368 Sep 5 15:00 manifest.yml
-rw-r--r-- 1 andrunix staff 6646 Aug 10 19:57 rails-be8732dac73d845ac5b142c8fb5f9fb0.png
-rw-r--r-- 1 andrunix staff 6646 Aug 10 19:57 rails.png
If anyone knows how this got created, that would put my mind at ease. Thanks!
Andrew
I'm sure the .A means something, but searching for it yields nothing but noise. Please enlighten me.
Oh, they're the same.
-rwxr-xr-x 1 root wheel 4969408 Sep 25 16:06 libicucore.A.dylib*
lrwxr-xr-x 1 root wheel 18 Oct 7 2011 libicucore.dylib# -> libicucore.A.dylib