external/ppp
Revision | 821c6079634ae728eda7a19e947a2c8f0dd1fdaa (tree) |
---|---|
Zeit | 2009-06-16 19:19:44 |
Autor | Chia-chi Yeh <chiachi@andr...> |
Commiter | Chia-chi Yeh |
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.
@@ -55,9 +55,6 @@ | ||
55 | 55 | #include <sys/socket.h> |
56 | 56 | #include <netinet/in.h> |
57 | 57 | #include <arpa/inet.h> |
58 | -#ifdef ANDROID_CHANGES | |
59 | -#include <paths.h> | |
60 | -#endif | |
61 | 58 | |
62 | 59 | #include "pppd.h" |
63 | 60 | #include "fsm.h" |
@@ -1715,10 +1712,6 @@ ipcp_up(f) | ||
1715 | 1712 | } |
1716 | 1713 | script_setenv("IPLOCAL", ip_ntoa(go->ouraddr), 0); |
1717 | 1714 | script_setenv("IPREMOTE", ip_ntoa(ho->hisaddr), 1); |
1718 | -#ifdef ANDROID_CHANGES | |
1719 | - script_setenv("PATH","/sbin:/system/sbin:/system/bin:/system/xbin", 0); | |
1720 | - script_setenv("ANDROID_PROPERTY_WORKSPACE", getenv("ANDROID_PROPERTY_WORKSPACE"), 0); | |
1721 | -#endif | |
1722 | 1715 | |
1723 | 1716 | if (go->dnsaddr[0]) |
1724 | 1717 | script_setenv("DNS1", ip_ntoa(go->dnsaddr[0]), 0); |
@@ -1985,13 +1978,6 @@ ipcp_script(script) | ||
1985 | 1978 | slprintf(strlocal, sizeof(strlocal), "%I", ipcp_gotoptions[0].ouraddr); |
1986 | 1979 | slprintf(strremote, sizeof(strremote), "%I", ipcp_hisoptions[0].hisaddr); |
1987 | 1980 | |
1988 | -#ifdef ANDROID_CHANGES | |
1989 | - argv[0] = "sh"; | |
1990 | - argv[1] = "-c"; | |
1991 | - argv[2] = script; | |
1992 | - argv[3] = NULL; | |
1993 | - ipcp_script_pid = run_program(_PATH_BSHELL, argv, 0, ipcp_script_done, NULL); | |
1994 | -#else | |
1995 | 1981 | argv[0] = script; |
1996 | 1982 | argv[1] = ifname; |
1997 | 1983 | argv[2] = devnam; |
@@ -2001,7 +1987,6 @@ ipcp_script(script) | ||
2001 | 1987 | argv[6] = ipparam; |
2002 | 1988 | argv[7] = NULL; |
2003 | 1989 | ipcp_script_pid = run_program(script, argv, 0, ipcp_script_done, NULL); |
2004 | -#endif | |
2005 | 1990 | } |
2006 | 1991 | |
2007 | 1992 | /* |
@@ -2011,9 +1996,9 @@ static void | ||
2011 | 1996 | create_resolv(peerdns1, peerdns2) |
2012 | 1997 | u_int32_t peerdns1, peerdns2; |
2013 | 1998 | { |
1999 | +#ifndef ANDROID_CHANGES | |
2014 | 2000 | FILE *f; |
2015 | 2001 | |
2016 | -#if 0 /* resolv.conf has no meaning for ANDROIDS */ | |
2017 | 2002 | f = fopen(_PATH_RESOLV, "w"); |
2018 | 2003 | if (f == NULL) { |
2019 | 2004 | error("Failed to create %s: %m", _PATH_RESOLV); |
@@ -812,8 +812,10 @@ detach() | ||
812 | 812 | void |
813 | 813 | reopen_log() |
814 | 814 | { |
815 | +#ifndef ANDROID_CHANGES | |
815 | 816 | openlog("pppd", LOG_PID | LOG_NDELAY, LOG_PPP); |
816 | 817 | setlogmask(LOG_UPTO(LOG_INFO)); |
818 | +#endif | |
817 | 819 | } |
818 | 820 | |
819 | 821 | /* |
@@ -1525,7 +1527,9 @@ safe_fork(int infd, int outfd, int errfd) | ||
1525 | 1527 | if (errfd != 2) |
1526 | 1528 | dup2(errfd, 2); |
1527 | 1529 | |
1530 | +#ifndef ANDROID_CHANGES | |
1528 | 1531 | closelog(); |
1532 | +#endif | |
1529 | 1533 | if (log_to_fd > 2) |
1530 | 1534 | close(log_to_fd); |
1531 | 1535 | if (the_channel->close) |
@@ -1674,11 +1678,15 @@ run_program(prog, args, must_exist, done, arg) | ||
1674 | 1678 | /* run the program */ |
1675 | 1679 | execve(prog, args, script_env); |
1676 | 1680 | if (must_exist || errno != ENOENT) { |
1681 | +#ifndef ANDROID_CHANGES | |
1677 | 1682 | /* have to reopen the log, there's nowhere else |
1678 | 1683 | for the message to go. */ |
1679 | 1684 | reopen_log(); |
1680 | 1685 | syslog(LOG_ERR, "Can't execute %s: %m", prog); |
1681 | 1686 | closelog(); |
1687 | +#else | |
1688 | + error("Can't execute %s: %m", prog); | |
1689 | +#endif | |
1682 | 1690 | } |
1683 | 1691 | _exit(-1); |
1684 | 1692 | } |
@@ -1065,8 +1065,9 @@ option_error __V((char *fmt, ...)) | ||
1065 | 1065 | va_end(args); |
1066 | 1066 | if (phase == PHASE_INITIALIZE) |
1067 | 1067 | fprintf(stderr, "%s: %s\n", progname, buf); |
1068 | +#ifndef ANDROID_CHANGES | |
1068 | 1069 | syslog(LOG_ERR, "%s", buf); |
1069 | -#ifdef ANDROID_CHANGES | |
1070 | +#else | |
1070 | 1071 | error("%s", buf); |
1071 | 1072 | #endif |
1072 | 1073 | } |
@@ -649,6 +649,21 @@ print_string(p, len, printer, arg) | ||
649 | 649 | printer(arg, "\""); |
650 | 650 | } |
651 | 651 | |
652 | +/* | |
653 | + * logit - does the hard work for fatal et al. | |
654 | + */ | |
655 | +static void | |
656 | +logit(level, fmt, args) | |
657 | + int level; | |
658 | + char *fmt; | |
659 | + va_list args; | |
660 | +{ | |
661 | + int n; | |
662 | + char buf[1024]; | |
663 | + | |
664 | + n = vslprintf(buf, sizeof(buf), fmt, args); | |
665 | + log_write(level, buf); | |
666 | +} | |
652 | 667 | |
653 | 668 | #ifdef ANDROID_CHANGES |
654 | 669 |
@@ -669,32 +684,12 @@ static int syslog_to_android[] = { | ||
669 | 684 | |
670 | 685 | #endif |
671 | 686 | |
672 | -/* | |
673 | - * logit - does the hard work for fatal et al. | |
674 | - */ | |
675 | -static void | |
676 | -logit(level, fmt, args) | |
677 | - int level; | |
678 | - char *fmt; | |
679 | - va_list args; | |
680 | -{ | |
681 | - int n; | |
682 | - char buf[1024]; | |
683 | - | |
684 | - n = vslprintf(buf, sizeof(buf), fmt, args); | |
685 | - | |
686 | -#ifndef ANDROID_CHANGES | |
687 | - log_write(level, buf); | |
688 | -#else | |
689 | - __android_log_write(syslog_to_android[level], LOG_TAG, buf); | |
690 | -#endif | |
691 | -} | |
692 | - | |
693 | 687 | static void |
694 | 688 | log_write(level, buf) |
695 | 689 | int level; |
696 | 690 | char *buf; |
697 | 691 | { |
692 | +#ifndef ANDROID_CHANGES | |
698 | 693 | syslog(level, "%s", buf); |
699 | 694 | |
700 | 695 | fprintf(stderr, buf); |
@@ -708,6 +703,9 @@ log_write(level, buf) | ||
708 | 703 | || write(log_to_fd, "\n", 1) != 1) |
709 | 704 | log_to_fd = -1; |
710 | 705 | } |
706 | +#else | |
707 | + __android_log_write(syslog_to_android[level], LOG_TAG, buf); | |
708 | +#endif | |
711 | 709 | } |
712 | 710 | |
713 | 711 | /* |