You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by rb...@apache.org on 2001/01/20 07:05:15 UTC
cvs commit: httpd-2.0/server mpm_common.c util.c
rbb 01/01/19 22:05:15
Modified: . CHANGES
include httpd.h mpm_common.h
os/unix unixd.c
server mpm_common.c util.c
Log:
Move initgroupgs, ap_uname2id and ap_gname2id from util.c to
mpm_common.c. These functions are only valid on some platforms,
so they should not be in the main-line code.
These functions are also not portable to non-unix platforms, so they don't
really belong in APR. Since they are only used in MPMs, for right now,
I am moving them to mpm_common.c
Revision Changes Path
1.48 +4 -0 httpd-2.0/CHANGES
Index: CHANGES
===================================================================
RCS file: /home/cvs/httpd-2.0/CHANGES,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- CHANGES 2001/01/20 05:18:02 1.47
+++ CHANGES 2001/01/20 06:05:14 1.48
@@ -1,5 +1,9 @@
Changes with Apache 2.0b1
+ *) Move initgroupgs, ap_uname2id and ap_gname2id from util.c to
+ mpm_common.c. These functions are only valid on some platforms,
+ so they should not be in the main-line code. [Ryan Bloom]
+
*) Remove ap_chdir_file(). This function is not thread-safe,
and nobody is currently using it. [Ryan Bloom]
1.131 +0 -14 httpd-2.0/include/httpd.h
Index: httpd.h
===================================================================
RCS file: /home/cvs/httpd-2.0/include/httpd.h,v
retrieving revision 1.130
retrieving revision 1.131
diff -u -r1.130 -r1.131
--- httpd.h 2001/01/20 05:18:03 1.130
+++ httpd.h 2001/01/20 06:05:14 1.131
@@ -1506,20 +1506,6 @@
/* Misc system hackery */
/**
- * Convert a username to a numeric ID
- * @param name The name to convert
- * @return The user id corresponding to a name
- * @deffunc uid_t ap_uname2id(const char *name)
- */
-AP_DECLARE(uid_t) ap_uname2id(const char *name);
-/**
- * Convert a group name to a numeric ID
- * @param name The name to convert
- * @return The group id corresponding to a name
- * @deffunc gid_t ap_gname2id(const char *name)
- */
-AP_DECLARE(gid_t) ap_gname2id(const char *name);
-/**
* Given the name of an object in the file system determine if it is a directory
* @param p The pool to allocate out of
* @param name The name of the object to check
1.11 +14 -0 httpd-2.0/include/mpm_common.h
Index: mpm_common.h
===================================================================
RCS file: /home/cvs/httpd-2.0/include/mpm_common.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- mpm_common.h 2000/08/22 15:09:17 1.10
+++ mpm_common.h 2001/01/20 06:05:15 1.11
@@ -128,6 +128,20 @@
#define ap_sock_disable_nagle(s) /* NOOP */
#endif
+/**
+ * Convert a username to a numeric ID
+ * @param name The name to convert
+ * @return The user id corresponding to a name
+ * @deffunc uid_t ap_uname2id(const char *name)
+ */
+AP_DECLARE(uid_t) ap_uname2id(const char *name);
+/**
+ * Convert a group name to a numeric ID
+ * @param name The name to convert
+ * @return The group id corresponding to a name
+ * @deffunc gid_t ap_gname2id(const char *name)
+ */
+AP_DECLARE(gid_t) ap_gname2id(const char *name);
#define AP_MPM_HARD_LIMITS_FILE "src/" APACHE_MPM_DIR "/mpm_default.h"
1.32 +1 -0 httpd-2.0/os/unix/unixd.c
Index: unixd.c
===================================================================
RCS file: /home/cvs/httpd-2.0/os/unix/unixd.c,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- unixd.c 2001/01/19 07:04:26 1.31
+++ unixd.c 2001/01/20 06:05:15 1.32
@@ -63,6 +63,7 @@
#include "http_main.h"
#include "http_log.h"
#include "unixd.h"
+#include "mpm_common.h"
#include "os.h"
#include "ap_mpm.h"
#include "apr_thread_proc.h"
1.36 +60 -0 httpd-2.0/server/mpm_common.c
Index: mpm_common.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/mpm_common.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- mpm_common.c 2000/11/26 04:47:30 1.35
+++ mpm_common.c 2001/01/20 06:05:15 1.36
@@ -74,6 +74,7 @@
#include "httpd.h"
#include "http_config.h"
#include "http_log.h"
+#include "http_main.h"
#include "mpm.h"
#include "mpm_common.h"
@@ -276,3 +277,62 @@
}
}
#endif
+
+AP_DECLARE(uid_t) ap_uname2id(const char *name)
+{
+ struct passwd *ent;
+
+ if (name[0] == '#')
+ return (atoi(&name[1]));
+
+ if (!(ent = getpwnam(name))) { ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "%s: bad user name %s", ap_server_argv0, name);
+ exit(1);
+ }
+ return (ent->pw_uid);
+}
+
+AP_DECLARE(gid_t) ap_gname2id(const char *name)
+{
+ struct group *ent;
+
+ if (name[0] == '#')
+ return (atoi(&name[1]));
+
+ if (!(ent = getgrnam(name))) {
+ ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "%s: bad group name %s", ap_server_argv0, name); exit(1);
+ }
+ return (ent->gr_gid);
+}
+
+#ifndef HAVE_INITGROUPS
+int initgroups(const char *name, gid_t basegid)
+{
+#if defined(QNX) || defined(MPE) || defined(BEOS) || defined(_OSD_POSIX) || defined(TPF) || defined(__TANDEM) || defined(OS2) || defined(WIN32)
+/* QNX, MPE and BeOS do not appear to support supplementary groups. */
+ return 0;
+#else /* ndef QNX */
+ gid_t groups[NGROUPS_MAX];
+ struct group *g;
+ int index = 0;
+
+ setgrent();
+
+ groups[index++] = basegid;
+
+ while (index < NGROUPS_MAX && ((g = getgrent()) != NULL))
+ if (g->gr_gid != basegid) {
+ char **names;
+
+ for (names = g->gr_mem; *names != NULL; ++names)
+ if (!strcmp(*names, name))
+ groups[index++] = g->gr_gid;
+ }
+
+ endgrent();
+
+ return setgroups(index, groups);
+#endif /* def QNX */
+}
+#endif /* def NEED_INITGROUPS */
+
+
1.93 +0 -68 httpd-2.0/server/util.c
Index: util.c
===================================================================
RCS file: /home/cvs/httpd-2.0/server/util.c,v
retrieving revision 1.92
retrieving revision 1.93
diff -u -r1.92 -r1.93
--- util.c 2001/01/20 05:18:06 1.92
+++ util.c 2001/01/20 06:05:15 1.93
@@ -1728,37 +1728,6 @@
return (x ? 1 : 0); /* If the first character is ':', it's broken, too */
}
-#ifndef HAVE_INITGROUPS
-int initgroups(const char *name, gid_t basegid)
-{
-#if defined(QNX) || defined(MPE) || defined(BEOS) || defined(_OSD_POSIX) || defined(TPF) || defined(__TANDEM) || defined(OS2) || defined(WIN32)
-/* QNX, MPE and BeOS do not appear to support supplementary groups. */
- return 0;
-#else /* ndef QNX */
- gid_t groups[NGROUPS_MAX];
- struct group *g;
- int index = 0;
-
- setgrent();
-
- groups[index++] = basegid;
-
- while (index < NGROUPS_MAX && ((g = getgrent()) != NULL))
- if (g->gr_gid != basegid) {
- char **names;
-
- for (names = g->gr_mem; *names != NULL; ++names)
- if (!strcmp(*names, name))
- groups[index++] = g->gr_gid;
- }
-
- endgrent();
-
- return setgroups(index, groups);
-#endif /* def QNX */
-}
-#endif /* def NEED_INITGROUPS */
-
AP_DECLARE(int) ap_ind(const char *s, char c)
{
register int x;
@@ -1788,43 +1757,6 @@
++str;
}
}
-
-AP_DECLARE(uid_t) ap_uname2id(const char *name)
-{
-#ifdef WIN32
- return (1);
-#else
- struct passwd *ent;
-
- if (name[0] == '#')
- return (atoi(&name[1]));
-
- if (!(ent = getpwnam(name))) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "%s: bad user name %s", ap_server_argv0, name);
- exit(1);
- }
- return (ent->pw_uid);
-#endif
-}
-
-AP_DECLARE(gid_t) ap_gname2id(const char *name)
-{
-#ifdef WIN32
- return (1);
-#else
- struct group *ent;
-
- if (name[0] == '#')
- return (atoi(&name[1]));
-
- if (!(ent = getgrnam(name))) {
- ap_log_error(APLOG_MARK, APLOG_STARTUP | APLOG_NOERRNO, 0, NULL, "%s: bad group name %s", ap_server_argv0, name);
- exit(1);
- }
- return (ent->gr_gid);
-#endif
-}
-
static char *find_fqdn(apr_pool_t *a, struct hostent *p)
{