set perms
init.rc: remove duplicated led-related nodes

Change-Id: Ibee7ef9137594fc4c30d3ab6ee7bdf3515836c62
Fix perms on /data/security

installd and zygote need to be able
to search the directory to access
the policy files.

Change-Id: I0679fd2084d2664dfb5a594f493317eff058415d
libsysutils: fix null pointer and memory leak issue

In SocketClient::quoteArg function
1. Fix potential null pointer accessing issue
2. Fix potential memory leak introduced by realloc fail

Change-Id: I1ca0f9089290d43452e9a71428244545f4ed866b
Signed-off-by: Hong-Mei Li <a21834@motorola.com>
Fixed reversed output in netstat Recv-Q Send-Q columns

Change-Id: I2bc7ac6c886808910212432497f05e34596f5e85
init: Safely restart services to avoid race conditions.

Previously, service restarts (either an explicit "restart", or a "stop,
start" pair) exhibited a race condition whereby the new (restarting)
service process was often spawned before the old (stopping) process had
terminated.  This may have resulted in the new service process failing to
acquire a limited resource (file lock, socket bind, etc.) that the old
process had not yet released.

Now, a stopping service remains in the SVC_RUNNING state until its exiting
process has been reaped by waitpid.  This prevents a "stop, start" sequence
from spawning a second service process before resources held by the first
are released.  This enables safe service restarts by stopping the service,
waiting for the old service process to terminate, and (only then) starting
the new service process.  In the event of "restarting" an already stopped
service, the previous behavior is maintained whereby the service is simply
started.

This scenario could be special-cased by the restart command, however, we
have observed instances where services are, unintentionally, stopped and
started "too quickly," and so simultaneous processes for the same service
should never be allowed.

Note that this commit alters the behaviors for explicit restarts of
critical and oneshot services.  Previously these serivces would simply be
restarted, whereas now, an explicit restart of a critical service counts as
a crash (which may result in a recovery reboot) and oneshot services go
into the disabled state.
init: Retain traditional restart behavior for critical and oneshot services.

Adds an SVC_RESTART state that's used for an explicit "restart" of a
running service.  This retains the traditional restart behavior for
critical and oneshot services (previously altered by 7e36edd8), whereby
these services are "simply restarted" instead of counting as a crash (for a
critical serivce) or going into the disabled state (for a oneshot service).
libsparse: Fix null pointer issue

Fix the issue that "out" pointer is dereferenced without checking.

Change-Id: I76a57ad7309841218231346f4807ef2be8628737
Signed-off-by: Hong-Mei Li <a21834@motorola.com>
init: Fix potential null pointer issue

With the old strdup() mechanism, it may return NULL if insufficient memory was
available. So we check the return value or do not use strdup to avoid null
pointer issue.

Change-Id: Id684948d6cb6c2f06327f29a2ba692f9542fce80
Signed-off-by: Hong-Mei Li <a21834@motorola.com>