From 12f72b25ea06006706eb0cdbbe1c965eb8fc03be Mon Sep 17 00:00:00 2001 From: Chia-chi Yeh Date: Tue, 16 Jun 2009 04:12:02 +0800 Subject: [PATCH] Few changes to pppd for VPN. 1. Remove TARGET_OUT_OPTIONAL_EXECUTABLES from Android.mk since pppd is now required by VPN, no longer optinoal. 2. Avoid creating pid files. 3. Use linkname as a suffix of program names which allows different users to run different set of scripts. E.g. if linkname is "vpn", "/etc/ppp/ip-up-vpn" is executed. --- pppd/Android.mk | 1 - pppd/main.c | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/pppd/Android.mk b/pppd/Android.mk index 4686fea..dcd5f8d 100644 --- a/pppd/Android.mk +++ b/pppd/Android.mk @@ -34,7 +34,6 @@ LOCAL_C_INCLUDES := \ LOCAL_CFLAGS := -DANDROID_CHANGES -DCHAPMS=1 -DMPPE=1 -Iexternal/openssl/include -LOCAL_MODULE_PATH := $(TARGET_OUT_OPTIONAL_EXECUTABLES) LOCAL_MODULE:= pppd include $(BUILD_EXECUTABLE) diff --git a/pppd/main.c b/pppd/main.c index 8515c1e..efcc0e2 100644 --- a/pppd/main.c +++ b/pppd/main.c @@ -825,6 +825,7 @@ static void create_pidfile(pid) int pid; { +#ifndef ANDROID_CHANGES FILE *pidfile; slprintf(pidfilename, sizeof(pidfilename), "%s%s.pid", @@ -836,12 +837,14 @@ create_pidfile(pid) error("Failed to create pid file %s: %m", pidfilename); pidfilename[0] = 0; } +#endif } void create_linkpidfile(pid) int pid; { +#ifndef ANDROID_CHANGES FILE *pidfile; if (linkname[0] == 0) @@ -858,6 +861,7 @@ create_linkpidfile(pid) error("Failed to create pid file %s: %m", linkpidfile); linkpidfile[0] = 0; } +#endif } /* @@ -865,12 +869,14 @@ create_linkpidfile(pid) */ void remove_pidfiles() { +#ifndef ANDROID_CHANGES if (pidfilename[0] != 0 && unlink(pidfilename) < 0 && errno != ENOENT) warn("unable to delete pid file %s: %m", pidfilename); pidfilename[0] = 0; if (linkpidfile[0] != 0 && unlink(linkpidfile) < 0 && errno != ENOENT) warn("unable to delete pid file %s: %m", linkpidfile); linkpidfile[0] = 0; +#endif } /* @@ -1636,6 +1642,21 @@ run_program(prog, args, must_exist, done, arg) int pid; struct stat sbuf; +#ifdef ANDROID_CHANGES + /* Originally linkname is used to create named pid files, which is + * meaningless to android. Here we use it as a suffix of program names, + * so different users can run their own program by specifying it. For + * example, "/etc/ppp/ip-up-vpn" will be executed when IPCP is up and + * linkname is "vpn". Note that "/" is not allowed for security reasons. */ + char file[MAXPATHLEN]; + + if (linkname[0] && !strchr(linkname, '/')) { + snprintf(file, MAXPATHLEN, "%s-%s", prog, linkname); + file[MAXPATHLEN - 1] = '\0'; + prog = file; + } +#endif + /* * First check if the file exists and is executable. * We don't use access() because that would use the -- 2.11.0