Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Bug 1121986: Remove user-switching code
Browse files Browse the repository at this point in the history
Rilproxy does not re-create it's own socket file descriptor, and
thus can be executed with user privilegues from the start. This
commit removes the user-switching code.
  • Loading branch information
tdz committed Jan 15, 2015
1 parent dd36d58 commit 4c5ea63
Showing 1 changed file with 0 additions and 30 deletions.
30 changes: 0 additions & 30 deletions src/rilproxy.c
Expand Up @@ -43,13 +43,10 @@
#include <errno.h>
#include <fcntl.h>
#include <poll.h>
#include <pwd.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <linux/capability.h>
#include <linux/prctl.h>
#define LOG_TAG "RILPROXY"
#include <utils/Log.h>
#include <cutils/sockets.h>
Expand All @@ -59,19 +56,6 @@
#define LOGE ALOGE
#endif

void switchUser() {
prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0);
setuid(1001);

struct __user_cap_header_struct header;
struct __user_cap_data_struct cap;
header.version = _LINUX_CAPABILITY_VERSION;
header.pid = 0;
cap.effective = cap.permitted = 1 << CAP_NET_ADMIN;
cap.inheritable = 0;
capset(&header, &cap);
}

static int
writeToSocket(int fd, const void *buffer, size_t len) {
size_t write_offset = 0;
Expand Down Expand Up @@ -158,20 +142,6 @@ int main(int argc, char **argv) {
return -1;
}

switchUser();
struct passwd *pwd = NULL;
pwd = getpwuid(getuid());
if (pwd != NULL) {
if (strcmp(pwd->pw_name, "radio") == 0) {
LOGD("Converted to radio account");
} else {
LOGE("Cannot convert to radio account");
}
} else {
LOGE("Cannot convert to radio account, getpwuid error.");
}


int connected = 0;

while(1)
Expand Down

0 comments on commit 4c5ea63

Please sign in to comment.