sábado, 23 de agosto de 2014

MAC OS X 10.9.4 configure PostgreSQL PHP module



A few days ago I updated the OS X to the latest in my MacBook Air, I had running there Apache + Php + PostgreSQL. My surprise was that the PHP Module for PostgreSQL has been deleted in this version, so consequently start my odyssey to get back to normal the whole system. Following references from dozens of Websites, I summarized all the key points in order not to lose more time anymore:

First step, download the PHP with the version included in OS X 10.9.4


sudo tar -xzvf php-5.4.24.tar.gz

sudo mkdir -p /usr/include

sudo mv php-5.4.24 /usr/include/php

cd /usr/include/php

./configure --without-iconv

phpize

You will get the following message:

Configuring for:
PHP Api Version: 20100412
Zend Module Api No: 20100525
Zend Extension Api No: 220100525
Cannot find autoconf. Please check your autoconf installation and the
$PHP_AUTOCONF environment variable. Then, rerun this script.

Then execute:

brew install autoconf

Warning: No developer tools installed.
You should install the Command Line Tools.
Run `xcode-select --install` to install them.
Warning: autoconf-2.69 already installed

At this point the most common thing is not to have autoconf installed in your computer. (Additionally the Xcode extension is needed, you can get this from iTunes)

xcode-select --install


sudo tar xzf autoconf-latest.tar.gz
cd autoconf-2.69/

./configure –prefix=/usr/local

make

sudo make install

At this point, we have completed the installation of autoconf.

brew install autoconf

cd /ext/pgsql

Once there:

sudo ./configure –with-pgsql=/Library/PostgreSQL/9.3

Where you set the folder where the local instance of PostgreSQL is currently installed in your system.

make

sudo make install

At this point you can restart your web server:

sudo /usr/sbin/apachectl restart

and check with phpinfo in your php script that pgsql module is enabled.

Remember that the extension must be enabled in your php.ini file:

sudo vi /private/etc/php.ini

Within the file:

extension=pgsql.so

Follow us in twitter: twitter.com/it4up



miércoles, 11 de septiembre de 2013

Execute a C program as root in your Android without a rooted device

The objective is having an APK which contains a call to a C program running as root on the Android operating system.
The first thing to have into account is that your Android device must be rooted at the beginning of the process, it might be changed to a non rooted mode afterwards. Once you have compiled your C routine in the proper architecture mode, you need to copy your files in /system folder. Since the /system folder is a read-only folder, it is necessary to set read-write privileges, additionally this folder is the most suitable to store your application since it is not deleted when you reset the device. For example:

mount -o remount,rw /system
mkdir /system/samplec
/system/samplec

It is assumed that you copy your application samplec in your /sdcard folder. In order to move your files:

/system/bin/busybox cp /sdcard/samplec /system/samplec

Once the file is copied, you need to assign the execution privileges to the folder and the binary file:

chmod 751 /system/samplec
chmod 6751 /system/samplec/samplec_binary

The last step before you deploy your APK is leaving the /system folder back to read-only mode, like this:

mount -o remount,ro /system

After setting the privileges to the file, it is not necessary to call to your C program by enabling “su” privileges in your Android code.

Your code, originally looked like this

Process sh = Runtime.getRuntime().exec("su", null,null);
OutputStream os = sh.getOutputStream();
os.write(("/system/samplec/samplec_binary").getBytes("ASCII")); os.flush();
os.close();

Now, the “su” call is not needed anymore, you can straight call your C program as displayed:

Process sh = Runtime.getRuntime().exec("/system/samplec/samplec_binary", null,null);

At this point, you can unroot your device and the execution of your Native C application will continue being executed as root.