I'm trying to improve httpd's mod_userdir so that it knows it
shouldn't serve ~fool when user 'fool' has an administratively
prohibited shell, so:

UserDir DisableShell /bin/badlad

To this end, I need a function to query the user's shell. It seems
sensible to me (though I am new to apr) that it should go into apr.

I've written a patch that does this; it's attached.

What do you think?

-- 
HEBRIDES
VARIABLE 3 OR LESS BECOMING SOUTHEASTERLY 4 OR 5. RAIN OR DRIZZLE.
MODERATE OR GOOD
--- srclib/apr/include/apr_user.h.orig  2004-02-13 09:33:45.000000000 +0000
+++ srclib/apr/include/apr_user.h       2004-07-26 09:45:49.000000000 +0100
@@ -99,6 +99,18 @@
                                          const char *username, apr_pool_t *p);
 
 /**
+ * Get the shell of the specified username
+ * @param shell Returns the shell filename
+ * @param username The username to lookup
+ * @param p The pool from which to allocate the string
+ * @remark This function is available only if APR_HAS_USER is defined.
+ */
+APR_DECLARE(apr_status_t) apr_uid_shell_get(char **shell,
+                                            const char *username,
+                                            apr_pool_t *p);
+
+
+/**
  * Get the home directory for the named user
  * @param dirname Pointer to new string containing directory name (on output)
  * @param username The named user
--- srclib/apr/user/unix/userinfo.c.orig        2004-02-13 09:33:55.000000000 
+0000
+++ srclib/apr/user/unix/userinfo.c     2004-07-27 11:08:27.000000000 +0100
@@ -76,6 +76,21 @@
 }
 
 
+APR_DECLARE(apr_status_t) apr_uid_shell_get(char **shell,
+                                             const char *username,
+                                             apr_pool_t *p)
+{
+    struct passwd pw;
+    char pwbuf[PWBUF_SIZE];
+    apr_status_t rv;
+
+    if ((rv = getpwnam_safe(username, &pw, pwbuf)) != APR_SUCCESS)
+        return rv;
+
+    *shell = apr_pstrdup(p, pw.pw_shell);
+    return APR_SUCCESS;
+}
+ 
 
 APR_DECLARE(apr_status_t) apr_uid_current(apr_uid_t *uid,
                                           apr_gid_t *gid,
--- srclib/apr/user/win32/userinfo.c.orig       2004-02-13 09:33:55.000000000 
+0000
+++ srclib/apr/user/win32/userinfo.c    2004-07-27 16:32:17.000000000 +0100
@@ -160,6 +160,13 @@
 #endif /* _WIN32_WCE */
 }
 
+APR_DECLARE(apr_status_t) apr_uid_shell_get(char **shell,
+                                             const char *username,
+                                             apr_pool_t *p)
+{
+    return APR_ENOTIMPL;
+}
+
 APR_DECLARE(apr_status_t) apr_uid_current(apr_uid_t *uid,
                                           apr_gid_t *gid,
                                           apr_pool_t *p)

Reply via email to