forked from CyanogenMod/android_system_core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
resolved conflicts for merge of a88c13b to honeycomb-plus-aosp
The Android.mk's LOCAL_SRC_FILES was different from gingerbread. Change-Id: Ie1777a5f449e6b135320e92d0dc1c593869aa266 Signed-off-by: JP Abgrall <jpa@google.com>
- Loading branch information
Showing
3 changed files
with
110 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright (C) 2011 The Android Open Source Project | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
#ifndef __CUTILS_QTAGUID_H | ||
#define __CUTILS_QTAGUID_H | ||
|
||
#include <stdint.h> | ||
#include <sys/types.h> | ||
#include <unistd.h> | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/* | ||
* Set tags (and owning UIDs) for network sockets. | ||
*/ | ||
extern int qtaguid_tagSocket(int sockfd, int tag, uid_t uid); | ||
|
||
/* | ||
* Untag a network socket before closing. | ||
*/ | ||
extern int qtaguid_untagSocket(int sockfd); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif /* __CUTILS_QTAG_UID_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* libcutils/qtaguid.c | ||
** | ||
** Copyright 2011, The Android Open Source Project | ||
** | ||
** Licensed under the Apache License, Version 2.0 (the "License"); | ||
** you may not use this file except in compliance with the License. | ||
** You may obtain a copy of the License at | ||
** | ||
** http://www.apache.org/licenses/LICENSE-2.0 | ||
** | ||
** Unless required by applicable law or agreed to in writing, software | ||
** distributed under the License is distributed on an "AS IS" BASIS, | ||
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
** See the License for the specific language governing permissions and | ||
** limitations under the License. | ||
*/ | ||
|
||
#define LOG_TAG "qtaguid" | ||
|
||
#include <cutils/qtaguid.h> | ||
#include <cutils/log.h> | ||
#include <errno.h> | ||
#include <fcntl.h> | ||
#include <stdio.h> | ||
#include <string.h> | ||
#include <unistd.h> | ||
|
||
extern int qtaguid_tagSocket(int sockfd, int tag, uid_t uid) { | ||
char lineBuf[128]; | ||
int fd, cnt = 0, res = 0; | ||
uint64_t kTag = (uint64_t)tag << 32; | ||
snprintf(lineBuf, sizeof(lineBuf), "t %d %llu %d", sockfd, kTag, uid); | ||
|
||
LOGI("Tagging socket %d with tag %llx(%d) for uid %d", sockfd, kTag, tag, uid); | ||
fd = open("/proc/net/xt_qtaguid/ctrl", O_WRONLY); | ||
if (fd < 0) { | ||
return -errno; | ||
} | ||
|
||
cnt = write(fd, lineBuf, strlen(lineBuf)); | ||
if (cnt < 0) { | ||
res = -errno; | ||
} | ||
|
||
close(fd); | ||
return res; | ||
} | ||
|
||
extern int qtaguid_untagSocket(int sockfd) { | ||
char lineBuf[128]; | ||
int fd, cnt = 0, res = 0; | ||
snprintf(lineBuf, sizeof(lineBuf), "u %d", sockfd); | ||
|
||
LOGI("Untagging socket %d", sockfd); | ||
fd = open("/proc/net/xt_qtaguid/ctrl", O_WRONLY); | ||
if (fd < 0) { | ||
return -errno; | ||
} | ||
|
||
cnt = write(fd, lineBuf, strlen(lineBuf)); | ||
if (cnt < 0) { | ||
res = -errno; | ||
} | ||
|
||
close(fd); | ||
return res; | ||
} |