本文整理汇总了C++中PLOGE函数的典型用法代码示例。如果您正苦于以下问题:C++ PLOGE函数的具体用法?C++ PLOGE怎么用?C++ PLOGE使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PLOGE函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: mount_emulated_storage
static void mount_emulated_storage(int user_id) {
const char *emulated_source = getenv("EMULATED_STORAGE_SOURCE");
const char *emulated_target = getenv("EMULATED_STORAGE_TARGET");
const char* legacy = getenv("EXTERNAL_STORAGE");
if (!emulated_source || !emulated_target) {
// No emulated storage is present
return;
}
// Create a second private mount namespace for our process
if (unshare(CLONE_NEWNS) < 0) {
PLOGE("unshare");
return;
}
if (mount("rootfs", "/", NULL, MS_SLAVE | MS_REC, NULL) < 0) {
PLOGE("mount rootfs as slave");
return;
}
// /mnt/shell/emulated -> /storage/emulated
if (mount(emulated_source, emulated_target, NULL, MS_BIND, NULL) < 0) {
PLOGE("mount emulated storage");
}
char target_user[PATH_MAX];
snprintf(target_user, PATH_MAX, "%s/%d", emulated_target, user_id);
// /mnt/shell/emulated/<user> -> /storage/emulated/legacy
if (mount(target_user, legacy, NULL, MS_BIND | MS_REC, NULL) < 0) {
PLOGE("mount legacy path");
}
}
开发者ID:vince06fr,项目名称:Superuser,代码行数:34,代码来源:daemon.c
示例2: socket_accept
static int socket_accept(int serv_fd) {
struct timeval tv;
fd_set fds;
int fd, rc;
/* Wait 20 seconds for a connection, then give up. */
tv.tv_sec = 20;
tv.tv_usec = 0;
FD_ZERO(&fds);
FD_SET(serv_fd, &fds);
do {
rc = select(serv_fd + 1, &fds, NULL, NULL, &tv);
} while (rc < 0 && errno == EINTR);
if (rc < 1) {
PLOGE("select");
return -1;
}
fd = accept(serv_fd, NULL, NULL);
if (fd < 0) {
PLOGE("accept");
return -1;
}
return fd;
}
开发者ID:phhusson,项目名称:Superuser,代码行数:26,代码来源:su.c
示例3: write_int
static void write_int(int fd, int val) {
int written = write(fd, &val, sizeof(int));
if (written != sizeof(int)) {
PLOGE("unable to write int");
exit(-1);
}
}
开发者ID:Lekensteyn,项目名称:Superuser,代码行数:7,代码来源:daemon.c
示例4: allow
static void allow(char *shell, mode_t mask)
{
struct su_initiator *from = &su_from;
struct su_request *to = &su_to;
char *exe = NULL;
umask(mask);
send_intent(&su_from, &su_to, "", 1, 1);
if (!strcmp(shell, "")) {
strcpy(shell , "/system/bin/sh");
}
exe = strrchr (shell, '/') + 1;
setresgid(to->uid, to->uid, to->uid);
setresuid(to->uid, to->uid, to->uid);
LOGD("%u %s executing %u %s using shell %s : %s", from->uid, from->bin,
to->uid, to->command, shell, exe);
if (strcmp(to->command, DEFAULT_COMMAND)) {
execl(shell, exe, "-c", to->command, (char*)NULL);
} else {
execl(shell, exe, "-", (char*)NULL);
}
PLOGE("exec");
exit(EXIT_SUCCESS);
}
开发者ID:javroch,项目名称:android_system_su,代码行数:25,代码来源:su.c
示例5: populate_environment
static void populate_environment(const struct su_context *ctx)
{
struct passwd *pw;
char *val;
if (ctx->to.keepenv)
return;
pw = getpwuid(ctx->to.uid);
if (pw) {
setenv("HOME", pw->pw_dir, 1);
setenv("SHELL", ctx->to.shell, 1);
if (ctx->to.login || ctx->to.uid) {
setenv("USER", pw->pw_name, 1);
setenv("LOGNAME", pw->pw_name, 1);
}
}
if (ctx->sdk_version >= 14) {
val = get_parent_env(&ctx->from, "LD_LIBRARY_PATH", sizeof("LD_LIBRARY_PATH") - 1);
if (val)
if (setenv("LD_LIBRARY_PATH", val, 1))
PLOGE("setenv(LD_LIBRARY_PATH)");
}
}
开发者ID:Wonfee,项目名称:su-binary,代码行数:25,代码来源:su.c
示例6: prepare_bind
static void prepare_bind() {
int ret = 0;
//Check if there is a use to mount bind
if(access("/system/xbin/su", R_OK) != 0)
return;
ret = mkdir("/dev/su", 0700);
ret = copy_file("/sbin/su", "/dev/su/su", 0755);
if(ret) {
PLOGE("Failed to copy su");
return;
}
chmod("/dev/su/su", 0755);
ret = setfilecon("/dev/su/su", "u:object_r:system_file:s0");
if(ret) {
LOGE("Failed to set file context");
return;
}
ret = mount("/dev/su/su", "/system/xbin/su", "", MS_BIND, NULL);
if(ret) {
LOGE("Failed to mount bind");
return;
}
}
开发者ID:vince06fr,项目名称:Superuser,代码行数:27,代码来源:daemon.c
示例7: socket_cleanup
static void socket_cleanup(struct su_context *ctx) {
if (ctx && ctx->sock_path[0]) {
if (unlink(ctx->sock_path))
PLOGE("unlink (%s)", ctx->sock_path);
ctx->sock_path[0] = 0;
}
}
开发者ID:phhusson,项目名称:Superuser,代码行数:7,代码来源:su.c
示例8: sighandler
static void sighandler(int sig) {
(void)sig;
restore_stdin();
// Assume we'll only be called before death
// See note before sigaction() in set_stdin_raw()
//
// Now, close all standard I/O to cause the pumps
// to exit so we can continue and retrieve the exit
// code
close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);
// Put back all the default handlers
struct sigaction act;
int i;
memset(&act, '\0', sizeof(act));
act.sa_handler = SIG_DFL;
for (i = 0; quit_signals[i]; i++) {
if (sigaction(quit_signals[i], &act, NULL) < 0) {
PLOGE("Error removing signal handler");
continue;
}
}
}
开发者ID:vince06fr,项目名称:Superuser,代码行数:27,代码来源:daemon.c
示例9: socket_cleanup
static void socket_cleanup(void)
{
if (socket_path[0]) {
if (unlink(socket_path))
PLOGE("unlink (%s)", socket_path);
socket_path[0] = 0;
}
}
开发者ID:Wonfee,项目名称:su-binary,代码行数:8,代码来源:su.c
示例10: snprintf
static char *get_parent_env(const struct su_initiator *from, const char *var, size_t varlen)
{
char path[PATH_MAX];
char env[8129];
char *val = NULL;
char *p;
int fd = -1;
int len, rest, i, l;
snprintf(path, sizeof(path), "/proc/%u/environ", from->pid);
fd = open(path, O_RDONLY);
if (fd < 0) {
PLOGE("Opening environment");
return NULL;
}
rest = 0;
do {
len = read(fd, env + rest, sizeof(env) - rest);
if (len < 0)
PLOGE("Reading environment");
if (len <= 0)
break;
len += rest;
for (i = 0; i < len; i += l) {
l = strnlen(env + i, len - i) + 1;
if (i + l > len)
break;
if (!strncmp(var, env + i, varlen) && env[i + varlen] == '=') {
p = env + i + varlen + 1;
val = malloc(l - varlen - 1);
if (val)
strncpy(val, p, l - varlen - 1);
goto out;
}
}
rest = len - i;
memmove(env, env + i, rest);
} while (1);
out:
close(fd);
return val;
}
开发者ID:Wonfee,项目名称:su-binary,代码行数:46,代码来源:su.c
示例11: set_identity
void set_identity(unsigned int uid) {
/*
* Set effective uid back to root, otherwise setres[ug]id will fail
* if uid isn't root.
*/
if (seteuid(0)) {
PLOGE("seteuid (root)");
exit(EXIT_FAILURE);
}
if (setresgid(uid, uid, uid)) {
PLOGE("setresgid (%u)", uid);
exit(EXIT_FAILURE);
}
if (setresuid(uid, uid, uid)) {
PLOGE("setresuid (%u)", uid);
exit(EXIT_FAILURE);
}
}
开发者ID:phhusson,项目名称:Superuser,代码行数:18,代码来源:su.c
示例12: write_string
static void write_string(int fd, char* val) {
int len = strlen(val);
write_int(fd, len);
int written = write(fd, val, len);
if (written != len) {
PLOGE("unable to write string");
exit(-1);
}
}
开发者ID:Lekensteyn,项目名称:Superuser,代码行数:9,代码来源:daemon.c
示例13: socket_create_temp
static int socket_create_temp(char *path, size_t len) {
int fd;
struct sockaddr_un sun;
fd = socket(AF_LOCAL, SOCK_STREAM, 0);
if (fd < 0) {
PLOGE("socket");
return -1;
}
if (fcntl(fd, F_SETFD, FD_CLOEXEC)) {
PLOGE("fcntl FD_CLOEXEC");
goto err;
}
memset(&sun, 0, sizeof(sun));
sun.sun_family = AF_LOCAL;
snprintf(path, len, "%s/.socket%d", REQUESTOR_CACHE_PATH, getpid());
memset(sun.sun_path, 0, sizeof(sun.sun_path));
snprintf(sun.sun_path, sizeof(sun.sun_path), "%s", path);
/*
* Delete the socket to protect from situations when
* something bad occured previously and the kernel reused pid from that process.
* Small probability, isn't it.
*/
unlink(sun.sun_path);
if (bind(fd, (struct sockaddr*)&sun, sizeof(sun)) < 0) {
PLOGE("bind");
goto err;
}
if (listen(fd, 1) < 0) {
PLOGE("listen");
goto err;
}
return fd;
err:
close(fd);
return -1;
}
开发者ID:phhusson,项目名称:Superuser,代码行数:42,代码来源:su.c
示例14: run_daemon_child
static int run_daemon_child(int infd, int outfd, int errfd, int argc, char** argv) {
if (-1 == dup2(outfd, STDOUT_FILENO)) {
PLOGE("dup2 child outfd");
exit(-1);
}
if (-1 == dup2(errfd, STDERR_FILENO)) {
PLOGE("dup2 child errfd");
exit(-1);
}
if (-1 == dup2(infd, STDIN_FILENO)) {
PLOGE("dup2 child infd");
exit(-1);
}
close(infd);
close(outfd);
close(errfd);
return su_main_nodaemon(argc, argv);
}
开发者ID:vince06fr,项目名称:Superuser,代码行数:22,代码来源:daemon.c
示例15: socket_send_request
static int socket_send_request(int fd, const struct su_context *ctx)
{
size_t len;
size_t bin_size, cmd_size;
char *cmd;
#define write_token(fd, data) \
do { \
uint32_t __data = htonl(data); \
size_t __count = sizeof(__data); \
size_t __len = write((fd), &__data, __count); \
if (__len != __count) { \
PLOGE("write(" #data ")"); \
return -1; \
} \
} while (0)
write_token(fd, PROTO_VERSION);
write_token(fd, PATH_MAX);
write_token(fd, ARG_MAX);
write_token(fd, ctx->from.uid);
write_token(fd, ctx->to.uid);
bin_size = strlen(ctx->from.bin) + 1;
write_token(fd, bin_size);
len = write(fd, ctx->from.bin, bin_size);
if (len != bin_size) {
PLOGE("write(bin)");
return -1;
}
cmd = get_command(&ctx->to);
cmd_size = strlen(cmd) + 1;
write_token(fd, cmd_size);
len = write(fd, cmd, cmd_size);
if (len != cmd_size) {
PLOGE("write(cmd)");
return -1;
}
return 0;
}
开发者ID:Wonfee,项目名称:su-binary,代码行数:39,代码来源:su.c
示例16: socket_receive_result
static int socket_receive_result(int fd, char *result, ssize_t result_len) {
ssize_t len;
LOGD("waiting for user");
len = read(fd, result, result_len-1);
if (len < 0) {
PLOGE("read(result)");
return -1;
}
result[len] = '\0';
return 0;
}
开发者ID:phhusson,项目名称:Superuser,代码行数:13,代码来源:su.c
示例17: silent_run
// TODO: leverage this with exec_log?
static int silent_run(char* command) {
char *args[] = { "sh", "-c", command, NULL, };
set_identity(0);
pid_t pid;
pid = fork();
/* Parent */
if (pid < 0) {
PLOGE("fork");
return -1;
}
else if (pid > 0) {
return 0;
}
int zero = open("/dev/zero", O_RDONLY | O_CLOEXEC);
dup2(zero, 0);
int null = open("/dev/null", O_WRONLY | O_CLOEXEC);
dup2(null, 1);
dup2(null, 2);
execv(_PATH_BSHELL, args);
PLOGE("exec am");
_exit(EXIT_FAILURE);
return -1;
}
开发者ID:AlfSimen,项目名称:Superuser,代码行数:24,代码来源:activity.c
示例18: socket_create_temp
static int socket_create_temp(void)
{
static char buf[PATH_MAX];
int fd;
struct sockaddr_un sun;
fd = socket(AF_LOCAL, SOCK_STREAM, 0);
if (fd < 0) {
PLOGE("socket");
return -1;
}
for (;;) {
memset(&sun, 0, sizeof(sun));
sun.sun_family = AF_LOCAL;
strcpy(buf, SOCKET_PATH_TEMPLATE);
socket_path = mktemp(buf);
snprintf(sun.sun_path, sizeof(sun.sun_path), "%s", socket_path);
if (bind(fd, (struct sockaddr*)&sun, sizeof(sun)) < 0) {
if (errno != EADDRINUSE) {
PLOGE("bind");
return -1;
}
} else {
break;
}
}
if (listen(fd, 1) < 0) {
PLOGE("listen");
return -1;
}
return fd;
}
开发者ID:javroch,项目名称:android_system_su,代码行数:37,代码来源:su.c
示例19: __attribute__
static __attribute__ ((noreturn)) void allow(struct su_context *ctx) {
char *arg0;
int argc, err;
umask(ctx->umask);
// No send to UI accepted requests for shell and root users (they are in the log)
// if( ctx->from.uid != AID_SHELL && ctx->from.uid != AID_ROOT ) {
send_result(ctx, ALLOW);
// }
arg0 = strrchr (ctx->to.shell, '/');
arg0 = (arg0) ? arg0 + 1 : ctx->to.shell;
if (ctx->to.login) {
int s = strlen(arg0) + 2;
char *p = malloc(s);
if (!p)
exit(EXIT_FAILURE);
*p = '-';
strcpy(p + 1, arg0);
arg0 = p;
}
populate_environment(ctx);
set_identity(ctx->to.uid);
#define PARG(arg) \
(ctx->to.optind + (arg) < ctx->to.argc) ? " " : "", \
(ctx->to.optind + (arg) < ctx->to.argc) ? ctx->to.argv[ctx->to.optind + (arg)] : ""
LOGD("%u %s executing %u %s using shell %s : %s%s%s%s%s%s%s%s%s%s%s%s%s%s",
ctx->from.uid, ctx->from.bin,
ctx->to.uid, get_command(&ctx->to), ctx->to.shell,
arg0, PARG(0), PARG(1), PARG(2), PARG(3), PARG(4), PARG(5),
(ctx->to.optind + 6 < ctx->to.argc) ? " ..." : "");
argc = ctx->to.optind;
if (ctx->to.command) {
ctx->to.argv[--argc] = ctx->to.command;
ctx->to.argv[--argc] = "-c";
}
ctx->to.argv[--argc] = arg0;
execv(ctx->to.shell, ctx->to.argv + argc);
err = errno;
PLOGE("exec");
fprintf(stderr, "Cannot execute %s: %s\n", ctx->to.shell, strerror(err));
exit(EXIT_FAILURE);
}
开发者ID:htchoi1995,项目名称:Superuser,代码行数:49,代码来源:su.c
示例20: setup_sighandlers
/**
* Setup signal handlers trap signals which should result in program termination
* so that we can restore the terminal to its normal state and retrieve the
* return code.
*/
static void setup_sighandlers(void) {
struct sigaction act;
int i;
// Install the termination handlers
// Note: we're assuming that none of these signal handlers are already trapped.
// If they are, we'll need to modify this code to save the previous handler and
// call it after we restore stdin to its previous state.
memset(&act, '\0', sizeof(act));
act.sa_handler = &sighandler;
for (i = 0; quit_signals[i]; i++) {
if (sigaction(quit_signals[i], &act, NULL) < 0) {
PLOGE("Error installing signal handler");
continue;
}
}
}
开发者ID:vince06fr,项目名称:Superuser,代码行数:22,代码来源:daemon.c
注:本文中的PLOGE函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论