]> granicus.if.org Git - php/commitdiff
add imap
authorStanislav Malyshev <stas@php.net>
Sun, 25 Jan 2015 09:21:53 +0000 (01:21 -0800)
committerStanislav Malyshev <stas@php.net>
Wed, 28 Jan 2015 18:15:11 +0000 (10:15 -0800)
.travis.yml
ext/imap/php_imap.c
ext/imap/tests/imap_fetchstructure_basic.phpt
ext/imap/tests/imap_include.inc
travis/compile.sh
travis/ext/imap/dovecot.conf [new file with mode: 0644]
travis/ext/imap/dovecotpass [new file with mode: 0644]
travis/ext/imap/imap.exp [new file with mode: 0644]
travis/ext/imap/setup.sh [new file with mode: 0644]

index 418a4f28b3627e965460f72b8ba05a7da365b1e2..8b40464432d040a24a2954a4d8bd20cc79106714 100644 (file)
@@ -26,7 +26,7 @@ env:
 
 before_install:
     - sudo apt-get update -qq
-    - sudo apt-get install -y libenchant-dev libaspell-dev libpspell-dev librecode-dev
+    - sudo apt-get install -y libenchant-dev libaspell-dev libpspell-dev librecode-dev libsasl2-dev libxpm-dev libt1-dev libc-client2007e-dev
     - sudo cp ./travis/de /var/lib/locales/supported.d/de
     - sudo dpkg-reconfigure locales
     - ./travis/install.sh
@@ -40,6 +40,7 @@ before_script:
     - . ./travis/ext/pdo_mysql/setup.sh
     - . ./travis/ext/pgsql/setup.sh
     - . ./travis/ext/pdo_pgsql/setup.sh
+    - . ./travis/ext/imap/setup.sh
 
 # Run PHPs run-tests.php 
 script:
index 0e3ec533a6a352f0313031ae54bb18734c15d7bf..ceaa53afcf25245cd50d9576243d2cf7616ccdc9 100644 (file)
@@ -1235,7 +1235,7 @@ static void php_imap_do_open(INTERNAL_FUNCTION_PARAMETERS, int persistent)
        imap_stream = mail_open(NIL, mailbox->val, flags);
 
        if (imap_stream == NIL) {
-               php_error_docref(NULL, E_WARNING, "Couldn't open stream %s", mailbox);
+               php_error_docref(NULL, E_WARNING, "Couldn't open stream %s", mailbox->val);
                efree(IMAPG(imap_user)); IMAPG(imap_user) = 0;
                efree(IMAPG(imap_password)); IMAPG(imap_password) = 0;
                RETURN_FALSE;
@@ -1340,6 +1340,7 @@ PHP_FUNCTION(imap_append)
                }
        }
 
+       zend_string_free(regex);
        ZEND_FETCH_RESOURCE(imap_le_struct, pils *, streamind, -1, "imap", le_imap);
 
        INIT (&st, mail_string, (void *) message->val, message->len);
@@ -4045,7 +4046,7 @@ PHP_FUNCTION(imap_search)
        int argc = ZEND_NUM_ARGS();
        SEARCHPGM *pgm = NIL;
 
-       if (zend_parse_parameters(argc, "rs|lS", &streamind, &criteria, &flags, &charset) == FAILURE) {
+       if (zend_parse_parameters(argc, "rS|lS", &streamind, &criteria, &flags, &charset) == FAILURE) {
                return;
        }
 
index 7ad4fc56226d124b028f58c540c77560797849d2..dcf6148a1e134116830b189891d991d494bb883d 100644 (file)
@@ -1,5 +1,5 @@
 --TEST--
-imap_fetchstructure() function : basic functionality 
+imap_fetchstructure() function : basic functionality
 --CREDITS--
 Olivier Doucet
 --SKIPIF--
@@ -34,12 +34,13 @@ var_dump($z->type);
 var_dump($z->encoding);
 var_dump($z->bytes);
 var_dump($z->lines);
-var_dump(is_object($z->parameters));
+var_dump($z->ifparameters);
+var_dump(is_object($z->parameters[0]));
 
 imap_close($stream_id);
 ?>
 --CLEAN--
-<?php 
+<?php
 require_once('clean.inc');
 ?>
 --EXPECTF--
@@ -67,4 +68,5 @@ int(%d)
 int(%d)
 int(%d)
 int(%d)
-bool(true)
\ No newline at end of file
+int(1)
+bool(true)
index b33a10e5e85f053571ac828f65f470a8650eaf1d..110a449cd5ed65ebcf8c362197d43a51f86799c8 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 // Change these to make tests run successfully
-$server   = '{localhost/norsh}';
+$server   = '{127.0.0.1/norsh}';
 $default_mailbox = $server . "INBOX";
 $domain = "something.com";
 $admin_user = "webmaster"; // a user with admin access 
index 9add843a2ec4c76a21f29c9de5df292f325e4edf..2a78beeea5a9ecbe911ecc3b07a5ac95cb1a8d30 100755 (executable)
@@ -53,8 +53,13 @@ $TS \
 --enable-calendar \
 --enable-ftp \
 --with-pspell=/usr \
---with-recode=/usr \
 --with-enchant=/usr \
 --enable-wddx \
+--with-imap \
+--with-imap-ssl \
+--with-freetype-dir=/usr \
+--with-t1lib=/usr \
+--with-xpm-dir=/usr \
+--with-kerberos \
 --enable-sysvmsg 
 make --quiet
diff --git a/travis/ext/imap/dovecot.conf b/travis/ext/imap/dovecot.conf
new file mode 100644 (file)
index 0000000..c321cb0
--- /dev/null
@@ -0,0 +1,22 @@
+auth_debug = yes
+auth_mechanisms = login
+auth_verbose = yes
+disable_plaintext_auth = no
+auth_mechanisms = plain login cram-md5
+listen = *
+mail_location = maildir:/home/vmail/mail/%d/%n/Maildir
+mbox_write_locks = fcntl
+passdb  {
+  args = /etc/dovecot/dovecotpass
+  driver = passwd-file
+}
+protocols = imap
+service auth {
+  user = root
+}
+ssl = no
+userdb {
+  args = uid=11459 gid=10002 home=/home/vmail/dovecot/mail/%d/%n
+  driver = static
+}
+log_path = /var/log/dovecot.log
diff --git a/travis/ext/imap/dovecotpass b/travis/ext/imap/dovecotpass
new file mode 100644 (file)
index 0000000..f68e6c3
--- /dev/null
@@ -0,0 +1 @@
+webmaster@something.com:{plain}p4ssw0rd
diff --git a/travis/ext/imap/imap.exp b/travis/ext/imap/imap.exp
new file mode 100644 (file)
index 0000000..de254bb
--- /dev/null
@@ -0,0 +1,29 @@
+send_user "IMAP test start..."
+spawn telnet 127.0.0.1 143
+
+expect "Dovecot ready" {
+                send_user "OK: $expect_out(0,string)\n"
+} "refused" {
+                send_user "connect to POP refused\n"
+                exit 1
+} timeout {
+                send_user "connect to POP timeout\n"
+                exit 1
+}
+
+send "a1 LOGIN webmaster@something.com p4ssw0rd\n"
+
+expect "a1 OK" {
+                send_user "OK, imap works\n"
+} "a1 NO*" {
+                send_user "auth failed: $expect_out(buffer)\n"
+                exit 1
+} "error*" {
+               send_user "ERROR: $expect_out(buffer)\n"
+} timeout {
+                send_user "connect to POP timeout\n"
+                exit 1
+}
+
+exit 0
+
diff --git a/travis/ext/imap/setup.sh b/travis/ext/imap/setup.sh
new file mode 100644 (file)
index 0000000..228fee0
--- /dev/null
@@ -0,0 +1,11 @@
+#!/bin/sh
+sudo groupadd -g 10002 vmail
+sudo useradd -g 10002 -u 11459 vmail
+sudo apt-get -y install expect dovecot-imapd
+sudo cp ./travis/ext/imap/dovecot.conf ./travis/ext/imap/dovecotpass /etc/dovecot
+sudo mkdir -p /home/vmail/mail/something.com
+sudo chown -R vmail:vmail /home/vmail/mail
+sudo chmod -R u+w /home/vmail/mail
+sudo service dovecot stop
+sudo service dovecot start
+expect ./travis/ext/imap/imap.exp