Merge changes 4101,4102
* changes:
Allow local variables to be declared anywhere in a block.
Support variable initialization.
diff --git a/adb/services.c b/adb/services.c
index b99cca1..0a5edcf 100644
--- a/adb/services.c
+++ b/adb/services.c
@@ -33,10 +33,6 @@
# endif
#endif
-#ifndef HAVE_WIN32_PROC
-#include <sys/poll.h>
-#endif
-
typedef struct stinfo stinfo;
struct stinfo {
@@ -203,8 +199,8 @@
static int create_subprocess(const char *cmd, const char *arg0, const char *arg1)
{
#ifdef HAVE_WIN32_PROC
- fprintf(stderr, "error: create_subprocess not implemented on Win32 (%s %s %s)\n", cmd, arg0, arg1);
- return -1;
+ fprintf(stderr, "error: create_subprocess not implemented on Win32 (%s %s %s)\n", cmd, arg0, arg1);
+ return -1;
#else /* !HAVE_WIN32_PROC */
char *devname;
int ptm;
@@ -271,54 +267,6 @@
#define SHELL_COMMAND "/system/bin/sh"
#endif
-static void shell_service(int s, void *command)
-{
- char buffer[MAX_PAYLOAD];
- int fd, ret = 0;
- unsigned count = 0;
-
- fd = create_subprocess(SHELL_COMMAND, "-c", (char *)command);
-
- while (1) {
- while (count < sizeof(buffer)) {
-#ifndef HAVE_WIN32_PROC
- /* add a 200ms timeout so we don't block indefinitely with our
- buffer partially filled.
- */
- if (count > 0) {
- struct pollfd pollfd;
-
- pollfd.fd = fd;
- pollfd.events = POLLIN;
- ret = poll(&pollfd, 1, 200);
- if (ret <= 0) {
- D("poll returned %d\n", ret);
- // file has closed or we timed out
- // set ret to 1 so we don't exit the outer loop
- ret = 1;
- break;
- }
- }
-#endif
- ret = adb_read(fd, buffer + count, sizeof(buffer) - count);
- D("ret: %d, count: %d\n", ret, count);
- if (ret > 0)
- count += ret;
- else
- break;
- }
-
- D("writing: %d\n", count);
- adb_write(s, buffer, count);
- count = 0;
- if (ret <= 0)
- break;
- }
-
- adb_close(fd);
- adb_close(s);
-}
-
int service_to_fd(const char *name)
{
int ret = -1;
@@ -372,7 +320,7 @@
#endif
} else if(!HOST && !strncmp(name, "shell:", 6)) {
if(name[6]) {
- ret = create_service_thread(shell_service, (void *)(name + 6));
+ ret = create_subprocess(SHELL_COMMAND, "-c", name + 6);
} else {
ret = create_subprocess(SHELL_COMMAND, "-", 0);
}
diff --git a/logcat/event-log-tags b/logcat/event-log-tags
index e13a711..13f7488 100644
--- a/logcat/event-log-tags
+++ b/logcat/event-log-tags
@@ -353,3 +353,6 @@
# aggregation service
70200 aggregation (aggregation time|2|3)
+
+# NOTE - the range 1000000-2000000 is reserved for partners and others who
+# want to define their own log tags without conflicting with the core platform.
diff --git a/rootdir/Android.mk b/rootdir/Android.mk
index b2fe8cf..44e343c 100644
--- a/rootdir/Android.mk
+++ b/rootdir/Android.mk
@@ -6,13 +6,15 @@
copy_from := \
etc/dbus.conf \
etc/init.goldfish.sh \
+ etc/ppp/ip-up \
+ etc/ppp/ip-down \
+ etc/ppp/peers/common \
+ etc/racoon/racoon.conf \
etc/hosts
dont_copy := \
etc/init.gprs-pppd \
- etc/ppp/chap-secrets \
- etc/ppp/ip-down \
- etc/ppp/ip-up
+ etc/ppp/chap-secrets
copy_to := $(addprefix $(TARGET_OUT)/,$(copy_from))
copy_from := $(addprefix $(LOCAL_PATH)/,$(copy_from))
diff --git a/rootdir/etc/ppp/ip-down b/rootdir/etc/ppp/ip-down
index 672fa1e..58d21e5 100755
--- a/rootdir/etc/ppp/ip-down
+++ b/rootdir/etc/ppp/ip-down
@@ -1,14 +1 @@
#!/system/bin/sh
-case $1 in
- ppp1)
- echo 0 > /proc/sys/net/ipv4/ip_forward;
- ;;
-esac
-
-# Use interface name if linkname is not available
-NAME=${LINKNAME:-"$1"}
-
-/system/bin/setprop "net.$NAME.dns1" "$DNS1"
-/system/bin/setprop "net.$NAME.dns2" "$DNS2"
-/system/bin/setprop "net.$NAME.local-ip" "$IPLOCAL"
-/system/bin/setprop "net.$NAME.remote-ip" "$IPREMOTE"
diff --git a/rootdir/etc/ppp/ip-up b/rootdir/etc/ppp/ip-up
index cb2d577..8c8f12c 100755
--- a/rootdir/etc/ppp/ip-up
+++ b/rootdir/etc/ppp/ip-up
@@ -1,24 +1,33 @@
#!/system/bin/sh
-case $1 in
- ppp1)
- /android/bin/iptables --flush;
- /android/bin/iptables --table nat --flush;
- /android/bin/iptables --delete-chain;
- /android/bin/iptables --table nat --append POSTROUTING --out-interface ppp0 -j MASQUERADE;
- /android/bin/iptables --append FORWARD --in-interface ppp1 -j ACCEPT;
- echo 0 > /proc/sys/net/ipv4/ip_forward;
- echo 1 > /proc/sys/net/ipv4/ip_forward;
- ;;
- ppp0)
- /system/bin/setprop "net.interfaces.defaultroute" "gprs"
- ;;
-esac
# Use interface name if linkname is not available
-NAME=${LINKNAME:-"$1"}
-/system/bin/setprop "net.$NAME.dns1" "$DNS1"
-/system/bin/setprop "net.$NAME.dns2" "$DNS2"
-/system/bin/setprop "net.$NAME.local-ip" "$IPLOCAL"
-/system/bin/setprop "net.$NAME.remote-ip" "$IPREMOTE"
+/system/bin/setprop "net.dns1" "$DNS1"
+/system/bin/setprop "net.dns2" "$DNS2"
+
+# Retrieve the default gateway from /proc/net/route
+RTAB=`cat /proc/net/route`
+flag=-1; i=0;
+for l in $RTAB; do
+ if (exp flag==1) then DGW=$l; flag=0; fi;
+ if (exp i%11 == 1) then
+ if (exp $l=="00000000") then flag=1; fi;
+ fi;
+ i=`exp i+1`;
+done
+FH=${DGW%????}
+LH=${DGW#????}
+A=`exp 0x${LH#??}`
+B=`exp 0x${LH%??}`
+C=`exp 0x${FH#??}`
+D=`exp 0x${FH%??}`
+GATEWAY="$A.$B.$C.$D"
+VPNSERVER=`getprop "net.vpn.server_ip"`
+
+# Protect the route to vpn server
+/system/bin/route add -net $VPNSERVER netmask 255.255.255.255 gw $GATEWAY
+
+# Route all traffic to vpn connection
+/system/bin/route add -net 0.0.0.0 netmask 128.0.0.0 gw $IPREMOTE
+/system/bin/route add -net 128.0.0.0 netmask 128.0.0.0 gw $IPREMOTE
diff --git a/rootdir/etc/ppp/peers/common b/rootdir/etc/ppp/peers/common
new file mode 100755
index 0000000..4183841
--- /dev/null
+++ b/rootdir/etc/ppp/peers/common
@@ -0,0 +1,10 @@
+ipcp-accept-local
+ipcp-accept-remote
+refuse-eap
+noccp
+noauth
+idle 1800
+mtu 1400
+mru 1400
+nodefaultroute
+usepeerdns
diff --git a/rootdir/etc/racoon/racoon.conf b/rootdir/etc/racoon/racoon.conf
new file mode 100644
index 0000000..eb50a2d
--- /dev/null
+++ b/rootdir/etc/racoon/racoon.conf
@@ -0,0 +1,35 @@
+#path certificate "";
+path certificate "/";
+
+sainfo anonymous {
+ encryption_algorithm aes, 3des;
+ authentication_algorithm hmac_sha1, hmac_md5;
+ compression_algorithm deflate;
+ lifetime time 3600 sec;
+}
+
+remote anonymous {
+ exchange_mode main;
+ doi ipsec_doi;
+ situation identity_only;
+ ike_frag on;
+ generate_policy on;
+ my_identifier asn1dn;
+ nat_traversal on; # always use NAT-T
+ ca_type x509 "ca.crt";
+ certificate_type x509 "user.crt" "user.key";
+ verify_identifier off;
+ verify_cert on;
+ nonce_size 16;
+ initial_contact on;
+ proposal_check obey;
+
+ proposal {
+ authentication_method rsasig;
+ hash_algorithm sha1;
+ encryption_algorithm 3des;
+ lifetime time 3600 sec;
+ dh_group 2;
+ }
+}
+
diff --git a/vold/format.c b/vold/format.c
index 3383949..a1faf7a 100755
--- a/vold/format.c
+++ b/vold/format.c
@@ -44,7 +44,7 @@
args[3] = "-O android";
args[4] = devpath;
args[5] = NULL;
- rc = logwrap(5, args);
+ rc = logwrap(5, args, 1);
} else {
char *args[7];
args[0] = MKE2FS_PATH;
@@ -54,7 +54,7 @@
args[4] = "-v";
args[5] = devpath;
args[6] = NULL;
- rc = logwrap(6, args);
+ rc = logwrap(6, args, 1);
}
free(devpath);
diff --git a/vold/logwrapper.c b/vold/logwrapper.c
index 2900f2e..46f6ed3 100644
--- a/vold/logwrapper.c
+++ b/vold/logwrapper.c
@@ -100,7 +100,7 @@
}
}
-int logwrap(int argc, char* argv[], pid_t *childPid)
+int logwrap(int argc, char* argv[], pid_t *childPid, int background)
{
pid_t pid;
@@ -138,6 +138,25 @@
dup2(child_ptty, 2);
close(child_ptty);
+ if (background) {
+ int fd = open("/dev/cpuctl/bg_non_interactive/tasks", O_WRONLY);
+
+ if (fd >=0 ) {
+ char text[64];
+
+ sprintf(text, "%d", getpid());
+ if (write(fd, text, strlen(text)) < 0) {
+ LOG(LOG_WARN, "logwrapper",
+ "Unable to background process (%s)", strerror(errno));
+ close(fd);
+ }
+ close(fd);
+ } else {
+ LOG(LOG_WARN, "logwrapper",
+ "Unable to background process (%s)", strerror(errno));
+ }
+ }
+
child(argc, argv);
} else {
return parent(argv[0], parent_ptty);
diff --git a/vold/logwrapper.h b/vold/logwrapper.h
index 602e24c..bf28aae 100644
--- a/vold/logwrapper.h
+++ b/vold/logwrapper.h
@@ -19,5 +19,5 @@
#define _LOGWRAPPER_H
#include <stdlib.h>
-int logwrap(int argc, char* argv[]);
+int logwrap(int argc, char* argv[], int background);
#endif
diff --git a/vold/volmgr_ext3.c b/vold/volmgr_ext3.c
index 680be21..fe3b2bb 100644
--- a/vold/volmgr_ext3.c
+++ b/vold/volmgr_ext3.c
@@ -107,7 +107,7 @@
args[3] = devpath;
args[4] = NULL;
- int rc = logwrap(4, args);
+ int rc = logwrap(4, args, 1);
if (rc == 0) {
LOG_VOL("filesystem '%s' had no errors", devpath);
diff --git a/vold/volmgr_vfat.c b/vold/volmgr_vfat.c
index 2b0e1fa..7833222 100644
--- a/vold/volmgr_vfat.c
+++ b/vold/volmgr_vfat.c
@@ -62,13 +62,13 @@
args[3] = "-p";
args[4] = blkdev_get_devpath(dev);
args[5] = NULL;
- rc = logwrap(5, args);
+ rc = logwrap(5, args, 1);
free(args[4]);
} else {
args[2] = "-n";
args[3] = blkdev_get_devpath(dev);
args[4] = NULL;
- rc = logwrap(4, args);
+ rc = logwrap(4, args, 1);
free(args[3]);
}