*/
tty_init();
+ progname = *argv;
+
#ifdef ANDROID_CHANGES
{
extern void pppox_init();
pppox_init();
+ privileged = 1;
+ }
+ {
+ char *envargs = getenv("envargs");
+ if (envargs) {
+ int i;
+ /* Decode the arguments in-place and count the number of them.
+ * They were hex encoded using [A-P] instead of [0-9A-F]. */
+ for (argc = 0, i = 0; envargs[i] && envargs[i + 1]; i += 2) {
+ char c = ((envargs[i] - 'A') << 4) + (envargs[i + 1] - 'A');
+ if (c == 0) {
+ ++argc;
+ }
+ envargs[i / 2 + 1] = c;
+ }
+ if (argc == 0 || (argv = malloc(sizeof(char *) * argc)) == NULL) {
+ fatal("Failed to parse envargs!");
+ }
+ for (envargs[0] = 0, i = 0; i < argc; ++envargs) {
+ if (envargs[0] == 0) {
+ argv[i++] = &envargs[1];
+ }
+ }
+ }
}
#endif
- progname = *argv;
-
/*
* Parse, in order, the system options file, the user's options file,
* and the command line arguments.
if (debug)
setlogmask(LOG_UPTO(LOG_DEBUG));
+#ifndef ANDROID_CHANGES
/*
* Check that we are running as root.
*/
argv[0]);
exit(EXIT_NOT_ROOT);
}
+#endif
if (!ppp_available()) {
option_error("%s", no_ppp_msg);
create_pidfile(pid)
int pid;
{
+#ifndef ANDROID_CHANGES
FILE *pidfile;
slprintf(pidfilename, sizeof(pidfilename), "%s%s.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)
error("Failed to create pid file %s: %m", linkpidfile);
linkpidfile[0] = 0;
}
+#endif
}
/*
*/
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
}
/*
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