aboutsummaryrefslogtreecommitdiffstats
path: root/init
diff options
context:
space:
mode:
authorNick Kralevich <nnk@google.com>2011-04-27 13:49:59 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2011-04-27 13:49:59 -0700
commit4682abaaa6f714d7bcfcf861af77b1b3c3c64281 (patch)
tree303b6f90d52df7435ac6f629772d83dbb26ace56 /init
parentee07501b25e088b24f87b691bf14756a94d2941e (diff)
parentb0d0e260bd6118959fa0e2d3c84037b3e0178551 (diff)
downloadsystem_core-4682abaaa6f714d7bcfcf861af77b1b3c3c64281.tar.gz
system_core-4682abaaa6f714d7bcfcf861af77b1b3c3c64281.tar.bz2
system_core-4682abaaa6f714d7bcfcf861af77b1b3c3c64281.zip
am b0d0e260: resolved conflicts for merge of 2baeb898 to honeycomb-plus-aosp
* commit 'b0d0e260bd6118959fa0e2d3c84037b3e0178551': Fold uevent message origin checking from init into libcutils.
Diffstat (limited to 'init')
-rw-r--r--init/devices.c34
1 files changed, 5 insertions, 29 deletions
diff --git a/init/devices.c b/init/devices.c
index bc36ac15..a200c95e 100644
--- a/init/devices.c
+++ b/init/devices.c
@@ -34,6 +34,8 @@
#include <asm/page.h>
#include <sys/wait.h>
+#include <cutils/uevent.h>
+
#include "devices.h"
#include "util.h"
#include "log.h"
@@ -770,35 +772,9 @@ static void handle_firmware_event(struct uevent *uevent)
#define UEVENT_MSG_LEN 1024
void handle_device_fd()
{
- for(;;) {
- char msg[UEVENT_MSG_LEN+2];
- char cred_msg[CMSG_SPACE(sizeof(struct ucred))];
- struct iovec iov = {msg, sizeof(msg)};
- struct sockaddr_nl snl;
- struct msghdr hdr = {&snl, sizeof(snl), &iov, 1, cred_msg, sizeof(cred_msg), 0};
-
- ssize_t n = recvmsg(device_fd, &hdr, 0);
- if (n <= 0) {
- break;
- }
-
- if ((snl.nl_groups != 1) || (snl.nl_pid != 0)) {
- /* ignoring non-kernel netlink multicast message */
- continue;
- }
-
- struct cmsghdr * cmsg = CMSG_FIRSTHDR(&hdr);
- if (cmsg == NULL || cmsg->cmsg_type != SCM_CREDENTIALS) {
- /* no sender credentials received, ignore message */
- continue;
- }
-
- struct ucred * cred = (struct ucred *)CMSG_DATA(cmsg);
- if (cred->uid != 0) {
- /* message from non-root user, ignore */
- continue;
- }
-
+ char msg[UEVENT_MSG_LEN+2];
+ int n;
+ while ((n = uevent_checked_recv(device_fd, msg, UEVENT_MSG_LEN)) > 0) {
if(n >= UEVENT_MSG_LEN) /* overflow -- discard */
continue;