Subject: proftpd (was: Re: inetutils ftpd fcntl(F_SETOWN) failure message suppression patch)
From: "Gerrit P. Haase" <[email-masked]>
To: [email-masked]
Date: Mon, 21 Apr 2003 22:55:41 +0200

Hallo Jason,

>> Oh btw... wouldn't you better like to maintain ProFTPd for Cygwin?
>> ;-)

> I would consider the above, if I could get Cygwin ProFTPd to work!  I
> spent *way* too much time about a month or two ago attempting to get
> Cygwin ProFTPd to work.  Unfortunately, I was not successful and put the
> port on the back burner.  I will post my patch and findings if someone
> is interested or I get motivated.

Yes, I'm interested.
It seems that there is a problem with the login.
I could compile the current cvs source, the server runs, but ...
I cannot login.

$ ftp localhost
Connected to loreley.antigone.familiehaase.de.
220 ProFTPD 1.2.9rc1 Server (ProFTPD Default Installation) [loreley.antigone.familiehaase.de]
Name (localhost:Gerrit): gerrit
331 Password required for gerrit.
Password:
530 Login incorrect.
ftp: Login failed.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> quit
221 Goodbye.

I applied the following patch to the current source, but it seems
that it is still all wrong...

--- modules/mod_auth.c~ 2003-04-21 22:18:26.000000000 +0200
+++ modules/mod_auth.c  2003-04-21 22:22:18.000000000 +0200
@@ -29,14 +29,15 @@
  * $Id: mod_auth.c,v 1.145 2003/04/15 06:22:24 castaglia Exp $
  */
 
-#ifdef __CYGWIN__
-#include <windows.h>
-#include <sys/cygwin.h>
-#endif /* __CYGWIN__ */
-
 #include "conf.h"
 #include "privs.h"
 
+#ifdef __CYGWIN__
+# include <windows.h>
+# include <sys/cygwin.h>
+# define is_winnt       (GetVersion() < 0x80000000)
+#endif /* __CYGWIN__ */
+
 #ifdef HAVE_REGEX_H
 #include <regex.h>
 #endif
@@ -762,9 +762,22 @@
   /* security: other functions perform pw lookups, thus we need to make
    * a local copy of the user just looked up
    */
-
   pw = passwd_dup(p,pw);
 
+#ifdef __CYGWIN__
+  /* We have to do special Windows NT voodoo with Cygwin in order to be
+   * able to switch UID/GID. More info at
+   * http://cygwin.com/cygwin-ug-net/ntsec.html#NTSEC-SETUID
+   */
+       if (is_winnt) {
+               HANDLE hToken = cygwin_logon_user(pw, pass);
+
+               if (hToken == INVALID_HANDLE_VALUE)
+          goto auth_failure;
+               cygwin_set_impersonation_token(hToken);
+       }
+#endif /* __CYGWIN__ */
+
   if (pw->pw_uid == 0) {
     unsigned char *root_allow = NULL;
 
@@ -1774,21 +1788,6 @@
     }
   }
 
-#ifdef __CYGWIN__
-  /* We have to do special Windows NT voodoo with Cygwin in order to be
-   * able to switch UID/GID. More info at
-   * http://cygwin.com/cygwin-ug-net/ntsec.html#NTSEC-SETUID
-   */
-  if (GetVersion() < 0x80000000) {
-    HANDLE token;
-
-    if ((token = cygwin_logon_user(user, user->pw_passwd)))
-      goto auth_failure;
-
-    cygwin_set_impersonation_token(token);      
-  }
-#endif /* __CYGWIN__ */
-
   if (c)
     anon_require_passwd = get_param_ptr(c->subset, "AnonRequirePassword",
       FALSE);

#END OF PATCH

Gerrit
-- 
=^..^=

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/