PInetd

From OoKoo.org

Jump to: navigation, search

Contents

Status

PInetd is currently used in production on ooKoo.org, as a FTP server and as an email server.

SVN (stable) : http://ookoo.org/svn/pinetd/
SVN (alpha) : http://ookoo.org/svn/pinetd2/ (requires PHP 5.3 to run, uses namespaces)
Bug report : http://pinetd.dns.st/

About

PInetd (Portable INET Daemon) is a server framework & daemon written in PHP, allowing anyone to easily create a TCP server, daemon, etc...

You can either use it as a developper, and build your own applications using pinetd, or use it as a system administrator, and host a ftp server, a mail server or anything provided by pinetd.

PInetd's config is written in XML; it defines which services runs, on which ports, and also contains specific settings for each service.

We currently have two services running on pinetd : SimpleFTPd which is a simple FTP daemon. It can be extended to support different authentification methods, and an extended version using SQL is provided. The other service is pMaild (portable mail daemon), a POP3/SMTP (and soon IMAP too) mail daemon.

Included Daemons

SimpleFTPd (port 21)

Small FTP daemon named SimpleFTPd, and which is able to use a SQL database as backend.

  • pinetd: Stable, named daemon/21.php and requires MySQL - No new features, only bugfix
  • pinetd2: Stable
  • FTPd: requires nothing, uses system logins
  • FTPd_SQL: uses SQL, allow to put a query in config.xml to define how logins are looked up

This FTP daemon was initially written to allow access to websites hosted by a few companies, including the french company Kalyweb when it was still existing.

SimpleFTPd features:

  • LIST always returns all files, even hidden files (those starting with a .). This was made like that to allow people using web hosting to see .htaccess files without telling their FTP client to send LIST -a
  • Supports FXP (and denies it to anonymous clients)
  • Uses chroot() and setuid()/setgid() for improved security. Also able to virtually chroot user (maybe not 100% safe, always use chroot() on UNIX systems)

TODO:

  • LIST just ignores any provided argument (we need to read path and stuff if we want to do this the right way)

Portable Mail Daemon (PMaild)

This mail server listens on ports 25 (smtp) and 110 (pop3) provide the following features:

  • POP boxes
  • POP alias
  • Wildcard alias ("default")
  • Mail forwarding to different mailbox on different domain using internal Mail Transfer Agent
  • Flag "create_account_on_mail" (create a pop account when a mail is being sent to this box, may be useful). NB: Mailboxes will be created even if the mail is detected as spam and refused (TODO: fix that)
  • HTTP mail target, allowing to forward an email to an HTTP address (advanced programming, mail triggers, etc)
  • SpamAssassin
    • A flag "drop_email_on_spam" allows to refuse mails detected as spam by spamassassin
  • ClamAV
  • NULL-password. By setting a password to null, it will be recorded automatically on next login. Coupled with create_account_on_mail, this is a way to migrate a POP-only system without the need to create again all the boxes
  • Mail relaying via SMTP (PMaild on pinetd uses SMTPafterPOP, PMaild on pinetd2 uses SMTP AUTH)
  • DNSBL for less spam:

TODO

The following features are still missing:

  • Support for IMAP4rev1 (RFC 3501) 15%
  • Mailing lists and multi-target aliases (will never work on PMaild provided by pinetd, but will work on PMaild provided by pinetd2)

SQL scripts (for PMaild+pinetd)

CREATE TABLE `domains`( 
  `domainid` int(10) unsigned zerofill NOT NULL auto_increment,
  `domain` varchar(128) NOT NULL default '',
  `adminpass` varchar(40) NOT NULL default '',
  `state` enum('new','active') NOT NULL default 'new',
  `flags` set('create_account_on_mail','fake_domain','drop_email_on_spam') NOT NULL default '',
  `antispam` set('resend','rbl','internal','spamassassin') NOT NULL default '',
  `antivirus` set('clam') NOT NULL default 'clam',
  `protocol` set('pop3','imap4') NOT NULL default '',
  `created` datetime NOT NULL,
  `last_recv` datetime default NULL,
  PRIMARY KEY  (`domainid`),
  UNIQUE KEY `domain` (`domain`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 PACK_KEYS=0;
CREATE TABLE `hosts` (
  `ip` varchar(15) NOT NULL default '',
  `type` enum('trust','spam') NOT NULL default 'trust',
  `regdate` datetime NOT NULL default '0000-00-00 00:00:00',
  `expires` datetime default NULL,
  `user_email` varchar(255) default NULL,
  `spampoints` int(11) NOT NULL default '0',
  `spamupdate` datetime NOT NULL default '0000-00-00 00:00:00',
  PRIMARY KEY  (`ip`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
CREATE TABLE `mailqueue` (
  `mlid` varchar(128) NOT NULL,
  `from` varchar(255) default NULL,
  `to` varchar(255) NOT NULL,
  `queued` datetime NOT NULL,
  `attempt_count` int(11) NOT NULL default '0',
  `last_attempt` datetime default NULL,
  `last_error` varchar(255) NOT NULL,
  `next_attempt` datetime default NULL,
  PRIMARY KEY  (`mlid`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Personal tools
In other languages