external/ppp
Revision | 12f72b25ea06006706eb0cdbbe1c965eb8fc03be (tree) |
---|---|
Time | 2009-06-19 14:35:23 |
Author | Chia-chi Yeh <chiachi@andr...> |
Commiter | Chia-chi Yeh |
Few changes to pppd for VPN.
1. Remove TARGET_OUT_OPTIONAL_EXECUTABLES from Android.mk
2. Avoid creating pid files.
3. Use linkname as a suffix of program names which allows
@@ -34,7 +34,6 @@ LOCAL_C_INCLUDES := \ | ||
34 | 34 | |
35 | 35 | LOCAL_CFLAGS := -DANDROID_CHANGES -DCHAPMS=1 -DMPPE=1 -Iexternal/openssl/include |
36 | 36 | |
37 | -LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) | |
38 | 37 | LOCAL_MODULE:= pppd |
39 | 38 | |
40 | 39 | include $(BUILD_EXECUTABLE) |
@@ -825,6 +825,7 @@ static void | ||
825 | 825 | create_pidfile(pid) |
826 | 826 | int pid; |
827 | 827 | { |
828 | +#ifndef ANDROID_CHANGES | |
828 | 829 | FILE *pidfile; |
829 | 830 | |
830 | 831 | slprintf(pidfilename, sizeof(pidfilename), "%s%s.pid", |
@@ -836,12 +837,14 @@ create_pidfile(pid) | ||
836 | 837 | error("Failed to create pid file %s: %m", pidfilename); |
837 | 838 | pidfilename[0] = 0; |
838 | 839 | } |
840 | +#endif | |
839 | 841 | } |
840 | 842 | |
841 | 843 | void |
842 | 844 | create_linkpidfile(pid) |
843 | 845 | int pid; |
844 | 846 | { |
847 | +#ifndef ANDROID_CHANGES | |
845 | 848 | FILE *pidfile; |
846 | 849 | |
847 | 850 | if (linkname[0] == 0) |
@@ -858,6 +861,7 @@ create_linkpidfile(pid) | ||
858 | 861 | error("Failed to create pid file %s: %m", linkpidfile); |
859 | 862 | linkpidfile[0] = 0; |
860 | 863 | } |
864 | +#endif | |
861 | 865 | } |
862 | 866 | |
863 | 867 | /* |
@@ -865,12 +869,14 @@ create_linkpidfile(pid) | ||
865 | 869 | */ |
866 | 870 | void remove_pidfiles() |
867 | 871 | { |
872 | +#ifndef ANDROID_CHANGES | |
868 | 873 | if (pidfilename[0] != 0 && unlink(pidfilename) < 0 && errno != ENOENT) |
869 | 874 | warn("unable to delete pid file %s: %m", pidfilename); |
870 | 875 | pidfilename[0] = 0; |
871 | 876 | if (linkpidfile[0] != 0 && unlink(linkpidfile) < 0 && errno != ENOENT) |
872 | 877 | warn("unable to delete pid file %s: %m", linkpidfile); |
873 | 878 | linkpidfile[0] = 0; |
879 | +#endif | |
874 | 880 | } |
875 | 881 | |
876 | 882 | /* |
@@ -1636,6 +1642,21 @@ run_program(prog, args, must_exist, done, arg) | ||
1636 | 1642 | int pid; |
1637 | 1643 | struct stat sbuf; |
1638 | 1644 | |
1645 | +#ifdef ANDROID_CHANGES | |
1646 | + /* Originally linkname is used to create named pid files, which is | |
1647 | + * meaningless to android. Here we use it as a suffix of program names, | |
1648 | + * so different users can run their own program by specifying it. For | |
1649 | + * example, "/etc/ppp/ip-up-vpn" will be executed when IPCP is up and | |
1650 | + * linkname is "vpn". Note that "/" is not allowed for security reasons. */ | |
1651 | + char file[MAXPATHLEN]; | |
1652 | + | |
1653 | + if (linkname[0] && !strchr(linkname, '/')) { | |
1654 | + snprintf(file, MAXPATHLEN, "%s-%s", prog, linkname); | |
1655 | + file[MAXPATHLEN - 1] = '\0'; | |
1656 | + prog = file; | |
1657 | + } | |
1658 | +#endif | |
1659 | + | |
1639 | 1660 | /* |
1640 | 1661 | * First check if the file exists and is executable. |
1641 | 1662 | * We don't use access() because that would use the |