]> granicus.if.org Git - apache/commitdiff
Move initgroupgs, ap_uname2id and ap_gname2id from util.c to
authorRyan Bloom <rbb@apache.org>
Sat, 20 Jan 2001 06:05:15 +0000 (06:05 +0000)
committerRyan Bloom <rbb@apache.org>
Sat, 20 Jan 2001 06:05:15 +0000 (06:05 +0000)
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

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@87755 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
include/httpd.h
include/mpm_common.h
os/unix/unixd.c
server/mpm_common.c
server/util.c

diff --git a/CHANGES b/CHANGES
index 74d4447e4fa884f958af803a2f6bde69b1e3f565..a4fc6095e8138ac06a87c8ae2940931a1234f18a 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -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]
 
index 388a5d360117a0a5a8a2130996b86846ede54e9f..5c03a757975797ca031f3af5922910bb3f3e88ef 100644 (file)
@@ -1505,20 +1505,6 @@ AP_DECLARE(int) ap_rind(const char *str, char c);
 AP_DECLARE(char *) ap_escape_quotes(apr_pool_t *p, const char *instring);
 
 /* 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 
index dc96d38f496d8359284ae212edecd31c497c4546..9ac37754f75c4e588fc9b9c75abfc0bec291b850 100644 (file)
@@ -128,6 +128,20 @@ void ap_sock_disable_nagle(apr_socket_t *s);
 #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"
 
index 1db01cddf63c82ad42a28167e0ffac8b2d76fb48..dc2eb2def28e959970dbd80aaeec504e31986d4e 100644 (file)
@@ -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"
index 8708a10c91983ad21ee6e376c34a388fe713d1dd..375eadd7915615d8ee0192b6748f18effde21fc5 100644 (file)
@@ -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 @@ void ap_sock_disable_nagle(apr_socket_t *s)
     }
 }
 #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 */
+
+
index 3c273ca05794b9547f8a7c1004c7e0741c0aeaf4..891e3112edb93d01a49b0447ffeed41993213434 100644 (file)
@@ -1728,37 +1728,6 @@ AP_DECLARE(int) ap_is_url(const char *u)
     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;
@@ -1789,43 +1758,6 @@ AP_DECLARE(void) ap_str_tolower(char *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)
 {
     int x;