| 1 | # ProFTPD on Cygwin |
| 2 | |
| 3 | Cygwin is a UNIX-like environment framework for Microsoft Windows 98/NT/2000/XP |
| 4 | operating systems. Most programs that you are used to using can compile and |
| 5 | behave exacttly the same way as on your favorite Unix system. However, there |
| 6 | are some minor differences and compatibility issues. |
| 7 | |
| 8 | ## Configuring and Compiling |
| 9 | |
| 10 | In standard Cygwin setup, there's no such username as "root". By default, the |
| 11 | `configure` script assigns 'Administrator' as the installation username. |
| 12 | Should you want to change this, then specify a username in the `install_user` |
| 13 | environment variable: |
| 14 | ```sh |
| 15 | install_user=MyUserHere ./configure ... |
| 16 | ``` |
| 17 | The rest of the installation process is as usual: |
| 18 | ```sh |
| 19 | ./configure |
| 20 | make |
| 21 | make install |
| 22 | ``` |
| 23 | |
| 24 | _Note_ that Cygwin does not currently support large files (_e.g._ files larger |
| 25 | than 2 GB). Also, Cygwin 1.3.22 or later should be installed. Earlier |
| 26 | versions of Cygwin would result in error messages like: |
| 27 | ```text |
| 28 | 426 Transfer aborted. Socket operation on non-socket |
| 29 | ``` |
| 30 | |
| 31 | ## Installing as Windows service |
| 32 | |
| 33 | Create a shell script and put it somewhere, with the following contents: |
| 34 | ```text |
| 35 | #!/bin/sh |
| 36 | # File: proftpd-config.sh |
| 37 | # Purpose: Installs ProFTPD daemon as a Windows service |
| 38 | |
| 39 | cygrunsrv --install proftpd \ |
| 40 | --path /usr/local/sbin/proftpd.exe \ |
| 41 | --args "--nodaemon" \ |
| 42 | --type manual \ |
| 43 | --disp "Cygwin proftpd" \ |
| 44 | --desc "ProFTPD FTP daemon" |
| 45 | ``` |
| 46 | The `--nodaemon` option is important. It prevents the process from detaching. |
| 47 | Thus you can always shut it down with `net stop proftpd` command. |
| 48 | |
| 49 | After running this script, you may run the daemon with `net start proftpd` |
| 50 | command. Or, change the `type` from `manual` to `auto`, and it will run on the |
| 51 | system startup. |
| 52 | |
| 53 | You can remove the service with the command: |
| 54 | ```sh |
| 55 | cygrunsrv --remove proftpd |
| 56 | ``` |
| 57 | |
| 58 | ## Installing as inetd service |
| 59 | |
| 60 | Edit the corresponding line in `/etc/inetd.conf`: |
| 61 | ```text |
| 62 | ftp stream tcp nowait root /usr/local/sbin/in.proftpd in.proftpd |
| 63 | ``` |
| 64 | You can specify an alternative configuration file with `-c` option. |
| 65 | |
| 66 | ## Configuration File |
| 67 | |
| 68 | The default configuration file resides in `/usr/local/etc/proftpd.conf`. |
| 69 | However, the default version of the `proftpd.conf` created by the installation |
| 70 | script is unusable within the Cygwin environment. |
| 71 | |
| 72 | Some configuration directives need to be changed as follows: |
| 73 | ```text |
| 74 | ServerType standalone|inetd |
| 75 | ``` |
| 76 | Needs to be set correctly. Having `standalone` when running from `inetd` |
| 77 | produces daemon processes which are difficult or impossible to kill. |
| 78 | |
| 79 | ```text |
| 80 | User System |
| 81 | Group Administrators |
| 82 | ``` |
| 83 | By default, a Windows service runs as the `SYSTEM` user, and if `User` |
| 84 | directive specifies some other user, ProFTPD fails to change to that user. |
| 85 | Also, if no `User` directive given, the daemon tries to change the UID to the |
| 86 | `SYSTEM` user ID. |
| 87 | |
| 88 | Using a less privileged user and/or group will result in errors when users |
| 89 | attempt to login. |
| 90 | |
| 91 | ```text |
| 92 | <Anonymous directory_name> |
| 93 | ``` |
| 94 | The user specified in `User` directive should exist as a Windows account. In |
| 95 | Windows User Manager, this login can be even disabled. As usual, make sure |
| 96 | you have this entry in the Cygwin `/etc/passwd` file (produced by |
| 97 | `mkpasswd.exe`). |
| 98 | |
| 99 | ```text |
| 100 | UserPassword username encrypted_passwd |
| 101 | ``` |
| 102 | The encrypted password can be produced with the `openssl passwd` command. |
| 103 | |
| 104 | When a user logs in, the following non-fatal warnings will appear in the |
| 105 | ProFTPD logs: |
| 106 | ```text |
| 107 | error setting write fd IP_TOS: Invalid argument |
| 108 | error setting read fd IP_TOS: Invalid argument |
| 109 | error setting write fd TCP_NOPUSH: Protocol not available |
| 110 | error setting read fd TCP_NOPUSH: Protocol not available |
| 111 | ``` |
| 112 | |
| 113 | ## Author |
| 114 | |
| 115 | Stanislav Sinyagin |
| 116 | CCIE #5478 |
| 117 | [email protected] |