From 821c6079634ae728eda7a19e947a2c8f0dd1fdaa Mon Sep 17 00:00:00 2001 From: Chia-chi Yeh Date: Tue, 16 Jun 2009 02:04:56 +0800 Subject: [PATCH] Fix few minor things in pppd. 1. Undo some changes about running scripts. 2. Move android logging from logit() to log_write(). 3. Remove all syslog() related calls. --- pppd/ipcp.c | 17 +---------------- pppd/main.c | 8 ++++++++ pppd/options.c | 3 ++- pppd/utils.c | 40 +++++++++++++++++++--------------------- 4 files changed, 30 insertions(+), 38 deletions(-) diff --git a/pppd/ipcp.c b/pppd/ipcp.c index b5b5c82..09aebe3 100644 --- a/pppd/ipcp.c +++ b/pppd/ipcp.c @@ -55,9 +55,6 @@ #include #include #include -#ifdef ANDROID_CHANGES -#include -#endif #include "pppd.h" #include "fsm.h" @@ -1715,10 +1712,6 @@ ipcp_up(f) } script_setenv("IPLOCAL", ip_ntoa(go->ouraddr), 0); script_setenv("IPREMOTE", ip_ntoa(ho->hisaddr), 1); -#ifdef ANDROID_CHANGES - script_setenv("PATH","/sbin:/system/sbin:/system/bin:/system/xbin", 0); - script_setenv("ANDROID_PROPERTY_WORKSPACE", getenv("ANDROID_PROPERTY_WORKSPACE"), 0); -#endif if (go->dnsaddr[0]) script_setenv("DNS1", ip_ntoa(go->dnsaddr[0]), 0); @@ -1985,13 +1978,6 @@ ipcp_script(script) slprintf(strlocal, sizeof(strlocal), "%I", ipcp_gotoptions[0].ouraddr); slprintf(strremote, sizeof(strremote), "%I", ipcp_hisoptions[0].hisaddr); -#ifdef ANDROID_CHANGES - argv[0] = "sh"; - argv[1] = "-c"; - argv[2] = script; - argv[3] = NULL; - ipcp_script_pid = run_program(_PATH_BSHELL, argv, 0, ipcp_script_done, NULL); -#else argv[0] = script; argv[1] = ifname; argv[2] = devnam; @@ -2001,7 +1987,6 @@ ipcp_script(script) argv[6] = ipparam; argv[7] = NULL; ipcp_script_pid = run_program(script, argv, 0, ipcp_script_done, NULL); -#endif } /* @@ -2011,9 +1996,9 @@ static void create_resolv(peerdns1, peerdns2) u_int32_t peerdns1, peerdns2; { +#ifndef ANDROID_CHANGES FILE *f; -#if 0 /* resolv.conf has no meaning for ANDROIDS */ f = fopen(_PATH_RESOLV, "w"); if (f == NULL) { error("Failed to create %s: %m", _PATH_RESOLV); diff --git a/pppd/main.c b/pppd/main.c index 162208f..8515c1e 100644 --- a/pppd/main.c +++ b/pppd/main.c @@ -812,8 +812,10 @@ detach() void reopen_log() { +#ifndef ANDROID_CHANGES openlog("pppd", LOG_PID | LOG_NDELAY, LOG_PPP); setlogmask(LOG_UPTO(LOG_INFO)); +#endif } /* @@ -1525,7 +1527,9 @@ safe_fork(int infd, int outfd, int errfd) if (errfd != 2) dup2(errfd, 2); +#ifndef ANDROID_CHANGES closelog(); +#endif if (log_to_fd > 2) close(log_to_fd); if (the_channel->close) @@ -1674,11 +1678,15 @@ run_program(prog, args, must_exist, done, arg) /* run the program */ execve(prog, args, script_env); if (must_exist || errno != ENOENT) { +#ifndef ANDROID_CHANGES /* have to reopen the log, there's nowhere else for the message to go. */ reopen_log(); syslog(LOG_ERR, "Can't execute %s: %m", prog); closelog(); +#else + error("Can't execute %s: %m", prog); +#endif } _exit(-1); } diff --git a/pppd/options.c b/pppd/options.c index 5375bf3..f8a836b 100644 --- a/pppd/options.c +++ b/pppd/options.c @@ -1065,8 +1065,9 @@ option_error __V((char *fmt, ...)) va_end(args); if (phase == PHASE_INITIALIZE) fprintf(stderr, "%s: %s\n", progname, buf); +#ifndef ANDROID_CHANGES syslog(LOG_ERR, "%s", buf); -#ifdef ANDROID_CHANGES +#else error("%s", buf); #endif } diff --git a/pppd/utils.c b/pppd/utils.c index 781044f..1ef4b3b 100644 --- a/pppd/utils.c +++ b/pppd/utils.c @@ -649,6 +649,21 @@ print_string(p, len, printer, arg) printer(arg, "\""); } +/* + * logit - does the hard work for fatal et al. + */ +static void +logit(level, fmt, args) + int level; + char *fmt; + va_list args; +{ + int n; + char buf[1024]; + + n = vslprintf(buf, sizeof(buf), fmt, args); + log_write(level, buf); +} #ifdef ANDROID_CHANGES @@ -669,32 +684,12 @@ static int syslog_to_android[] = { #endif -/* - * logit - does the hard work for fatal et al. - */ -static void -logit(level, fmt, args) - int level; - char *fmt; - va_list args; -{ - int n; - char buf[1024]; - - n = vslprintf(buf, sizeof(buf), fmt, args); - -#ifndef ANDROID_CHANGES - log_write(level, buf); -#else - __android_log_write(syslog_to_android[level], LOG_TAG, buf); -#endif -} - static void log_write(level, buf) int level; char *buf; { +#ifndef ANDROID_CHANGES syslog(level, "%s", buf); fprintf(stderr, buf); @@ -708,6 +703,9 @@ log_write(level, buf) || write(log_to_fd, "\n", 1) != 1) log_to_fd = -1; } +#else + __android_log_write(syslog_to_android[level], LOG_TAG, buf); +#endif } /* -- 2.11.0