You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by co...@hyperreal.org on 1998/01/25 17:13:13 UTC
cvs commit: apachen/src/ap Makefile.tmpl ap.h ap_execve.c
coar 98/01/25 08:13:13
Modified: src/ap Makefile.tmpl ap.h ap_execve.c
Log:
Fix some indenting issues in ap_execve.c, and fill in the
blanks in ap.h and Makefile.tmpl.
Revision Changes Path
1.8 +1 -1 apachen/src/ap/Makefile.tmpl
Index: Makefile.tmpl
===================================================================
RCS file: /export/home/cvs/apachen/src/ap/Makefile.tmpl,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- Makefile.tmpl 1998/01/25 01:40:55 1.7
+++ Makefile.tmpl 1998/01/25 16:13:11 1.8
@@ -29,4 +29,4 @@
ap_snprintf.o: $(INCDIR)/conf.h
ap_strings.o: $(INCDIR)/httpd.h
ap_cpystrn.o: $(INCDIR)/httpd.h
-ap_execve.o: $(INCDIR)/httpd.h
+ap_execve.o: $(INCDIR)/httpd.h $(INCDIR)/http_log.h
1.4 +3 -2 apachen/src/ap/ap.h
Index: ap.h
===================================================================
RCS file: /export/home/cvs/apachen/src/ap/ap.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ap.h 1998/01/21 19:17:34 1.3
+++ ap.h 1998/01/25 16:13:11 1.4
@@ -1,5 +1,5 @@
/* ====================================================================
- * Copyright (c) 1995-1998 The Apache Group. All rights reserved.
+ * Copyright (c) 1998 The Apache Group. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -62,5 +62,6 @@
API_EXPORT(char *) ap_escape_quotes(pool *, const char *);
API_EXPORT(int) ap_snprintf(char *, size_t, const char *, ...);
API_EXPORT(int) ap_vsnprintf(char *, size_t, const char *, va_list ap);
-
+int ap_execle(const char *, const char *, ...);
+int ap_execve(const char *, const char *argv[], const char *envp[]);
#endif /* !APACHE_AP_H */
1.3 +38 -20 apachen/src/ap/ap_execve.c
Index: ap_execve.c
===================================================================
RCS file: /export/home/cvs/apachen/src/ap/ap_execve.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ap_execve.c 1998/01/25 02:04:30 1.2
+++ ap_execve.c 1998/01/25 16:13:12 1.3
@@ -1,5 +1,5 @@
/* ====================================================================
- * Copyright (c) 1995-1998 The Apache Group. All rights reserved.
+ * Copyright (c) 1998 The Apache Group. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -74,7 +74,7 @@
* local argv[] array. The va_arg logic makes sure we do the right thing.
* XXX: malloc() is used because we expect to be overlaid soon.
*/
-int ap_execle(const char *filename, const char *arg,...)
+int ap_execle(const char *filename, const char *arg, ...)
{
va_list adummy;
char **envp;
@@ -83,16 +83,18 @@
/* First pass: Count arguments on stack */
va_start(adummy, arg);
- for (argc = 0; va_arg(adummy, char *) != NULL; ++argc)
+ for (argc = 0; va_arg(adummy, char *) != NULL; ++argc) {
continue;
+ }
va_end(adummy);
argv = (char **) malloc((argc + 2) * sizeof(*argv));
/* Pass two --- copy the argument strings into the result space */
va_start(adummy, arg);
- for (argc = 0; (argv[argc] = va_arg(adummy, char *)) != NULL; ++argc)
+ for (argc = 0; (argv[argc] = va_arg(adummy, char *)) != NULL; ++argc) {
continue;
+ }
envp = va_arg(adummy, char **);
va_end(adummy);
@@ -103,13 +105,14 @@
}
int ap_execve(const char *filename, const char *argv[],
- const char *envp[])
+ const char *envp[])
{
const char *argv0 = argv[0];
extern char **environ;
- if (envp == NULL)
+ if (envp == NULL) {
envp = (const char **) environ;
+ }
/* Try to execute the file directly first: */
execve(filename, argv, envp);
@@ -120,7 +123,8 @@
* EACCES Execute permission is denied for the file.
* EACCES Search permission is denied on a component of the path prefix.
* EPERM The file system is mounted noexec.
- * EPERM The file system is mounted nosuid and the file has an SUID or SGID bit set.
+ * EPERM The file system is mounted nosuid and the file has an SUID
+ * or SGID bit set.
* E2BIG The argument list is too big.
* ENOEXEC The magic number in the file is incorrect.
* EFAULT filename points outside your accessible address space.
@@ -141,14 +145,16 @@
&& (argv = hashbang(filename, argv)) != NULL) {
aplog_error(APLOG_MARK, APLOG_NOERRNO|APLOG_DEBUG, NULL,
- "Script %s needs interpreter %s to exec", filename, argv[0]);
+ "Script %s needs interpreter %s to exec", filename,
+ argv[0]);
/* new filename is the interpreter to call */
filename = argv[0];
/* Restore argv[0] as on entry */
- if (argv0 != NULL)
+ if (argv0 != NULL) {
argv[0] = argv0;
+ }
execve(filename, argv, envp);
@@ -184,8 +190,9 @@
int first_word = 0;
#endif /* WIN32 */
- if ((fd = open(filename, O_RDONLY)) == -1)
+ if ((fd = open(filename, O_RDONLY)) == -1) {
return NULL;
+ }
if (read(fd, (char *) lbuf, 2) != 2
|| lbuf[0] != '#' || lbuf[1] != '!'
@@ -198,7 +205,7 @@
ws = NULL; /* word started = 0 */
- for (p = lbuf; p < &lbuf[HACKBUFSZ];)
+ for (p = lbuf; p < &lbuf[HACKBUFSZ];) {
switch (*p) {
case ' ':
case '\t':
@@ -208,14 +215,16 @@
if (ws) { /* a blank after a word.. save it */
*p = '\0';
#ifndef WIN32
- if (sargc < HACKVECSZ - 1)
+ if (sargc < HACKVECSZ - 1) {
sargv[sargc++] = ws;
+ }
ws = NULL;
#else /* WIN32 */
if (sargc < HACKVECSZ - 1) {
sargv[sargc] = first_word ? NULL : hb_subst(ws);
- if (sargv[sargc] == NULL)
+ if (sargv[sargc] == NULL) {
sargv[sargc] = ws;
+ }
sargc++;
}
ws = NULL;
@@ -237,24 +246,28 @@
ws) { /* terminate the last word */
*p = '\0';
#ifndef WIN32
- if (sargc < HACKVECSZ - 1)
+ if (sargc < HACKVECSZ - 1) {
sargv[sargc++] = ws;
+ }
#else /* WIN32 */
if (sargc < HACKVECSZ - 1) { /* deal with the 1-word case */
sargv[sargc] = first_word ? NULL : hb_subst(ws);
- if (sargv[sargc] == NULL)
+ if (sargv[sargc] == NULL) {
sargv[sargc] = ws;
+ }
sargc++;
}
#endif /* !WIN32 */
sargv[sargc] = NULL;
}
/* Count number of entries in the old argv vector */
- for (i = 0; argv[i] != NULL; ++i)
+ for (i = 0; argv[i] != NULL; ++i) {
continue;
+ }
++i;
- newargv = (char **) malloc((p - lbuf + 1) + (i + sargc + 1) * sizeof(*newargv));
+ newargv = (char **) malloc((p - lbuf + 1)
+ + (i + sargc + 1) * sizeof(*newargv));
ws = &((char *) newargv)[(i + sargc + 1) * sizeof(*newargv)];
/* Copy entries to allocated memory */
@@ -265,8 +278,11 @@
newargv[sargc] = filename;
/* Append the old array. The old argv[0] is skipped. */
- if (i > 1)
- memcpy(&newargv[sargc + 1], &argv[1], (i - 1) * sizeof(*newargv));
+ if (i > 1) {
+ memcpy(&newargv[sargc + 1], &argv[1],
+ (i - 1) * sizeof(*newargv));
+ }
+
newargv[sargc + i] = NULL;
ws = NULL;
@@ -274,11 +290,13 @@
return newargv;
default:
- if (!ws) /* Start a new word? */
+ if (!ws) { /* Start a new word? */
ws = p;
+ }
p++;
break;
}
+ }
return NULL;
}
#else