diff options
Diffstat (limited to 'ext/vpopmail')
-rw-r--r-- | ext/vpopmail/CREDITS | 2 | ||||
-rw-r--r-- | ext/vpopmail/EXPERIMENTAL | 5 | ||||
-rw-r--r-- | ext/vpopmail/README | 194 | ||||
-rw-r--r-- | ext/vpopmail/config.m4 | 94 | ||||
-rw-r--r-- | ext/vpopmail/php_vpopmail.c | 938 | ||||
-rw-r--r-- | ext/vpopmail/php_vpopmail.h | 97 |
6 files changed, 0 insertions, 1330 deletions
diff --git a/ext/vpopmail/CREDITS b/ext/vpopmail/CREDITS deleted file mode 100644 index ed89afbb5f..0000000000 --- a/ext/vpopmail/CREDITS +++ /dev/null @@ -1,2 +0,0 @@ -Vpopmail -David Croft, Boian Bonev diff --git a/ext/vpopmail/EXPERIMENTAL b/ext/vpopmail/EXPERIMENTAL deleted file mode 100644 index 6443e99646..0000000000 --- a/ext/vpopmail/EXPERIMENTAL +++ /dev/null @@ -1,5 +0,0 @@ -this extension is experimental, -its functions may change their names -or move to extension all together -so do not rely to much on them -you have been warned! diff --git a/ext/vpopmail/README b/ext/vpopmail/README deleted file mode 100644 index a47c9b0f56..0000000000 --- a/ext/vpopmail/README +++ /dev/null @@ -1,194 +0,0 @@ -Minimum Survial Readme - -VPOPMAIL SPECIFIC ISSUES -------------------------------------------------------------------------------- - -assume - qmail is installed in /var/qmail - vpopmail in ~vpopmail - qmail-send runs as qmails - - -different parts of vpopmail require certain user id (uid) and -group id (gid) in order to operate normally. - -brief list with requirements: - -adddomain -deldomain -addaliasdomain - read/write permissions on - /var/qmail/users/ assing, assign.lock, cdb - - read/write permissions on - /var/qmail/control/* - - singnal qmail-send with SIGHUP (uid==qmails or root) - - read/write permissions on - ~vpopmail/domains - - optionally read/write to cdb vpopmail databases - -adduser -deluser - read/write permissions on - ~vpopmail/domains/<givendomain> (or the default domain) - - optionally read/write to cdb vpopmail databases - -passwd - optionally read/write on - ~vpopmail/domains/<givendomain>/<givenuser> - (only when sqwebmail is configured) - -setuserquota - optionally read/write to cdb vpopmail databases - -auth_user - optionally read from cdb vpopmail databases - -POSSIBLE SCENARIOS -------------------------------------------------------------------------------- - -php is in cgi mode - - command line invocation - - web server cgi invocation - -php is web server module - - -in command line mode the php interpreter may be run from vpopmail uid to -administer users, etc. or as root to add/del domains - this is the easiest case - -in cgi mode proper uid may be provided eighter by suid php interpreter or -using cgi exec wrapper. the same restrictions as in command line mode apply - -the web server module mode is the most powerful and works much faster that cgi. -in this mode more restrictions apply because web server's uid at least must -be able to read/write the directories of the manages domains. - -first scenario only allows web scripts to manage certain domains. security -may be compromised if there are user webs under the same web server -with allowed script execution. - -second scenario is to setup web server and vpopmail under the same uid/gid. -thus allowing only user management in all domains. - -third scenario extends second with the ability to manage domains. generally -from security reasons it is not a good idea to run such a system on a server -with shell users - vpopmail's domain admin tools must be suid root to work -properly and most users will be able to add/delete domains. - -it is not considered a good idea to run web servers as root. hence the need -to suid vpopmail domain management tools and exec them insted using native api. -native api for domains is only suitable for cgi/command line mode, when php is -run through suid root wrapper or suid itself. - -almost all scenarios lack secutiry in different ways - eighter powerful tools -get suid root or parts of vpopmail setup become useable by any system user -or web users with cgi/php access may utilize vpopmail api for mail management. - -perhapse the most secure solution is to run a separate apache server under -the vpopmail user and chmod 700 ~vpopmail/bin. - -FREQUENTLY USED CONFIGURATION STEPS -------------------------------------------------------------------------------- - -changing existing vpopmail uid/gid is possible but not easy - -take these into account: - -#1 - backup your setup, mail and configuration! - - stop qmail-send before doing any changes - else your mail in process may get bounced or - deleted or delivered to a default destination or... - - stop pop3/imap remote/local users - while changing uids - users cannot check their mail - - you may leave smtp - qmail-inject will take care - no matter vpopmail setup is broken (if and only - if you have stopped qmail-send) - - in rc.d scripts tcpserver uid/gid may need to be changed - - reconfiguring vpopmail: - ./configure ....your opts plus new uid/gid.... - - remember to - make clean all install - in vpopmail src tree; clean is needed if vpopmail has already been - configured with another uid/gid - vpopmail's dependencies are not - intact after reconfigure - - after these steps change the uid/gid in - /var/qmail/users/assign - compile the assign file. the dummies way is to - vadddomain mydummy.domain aaaa - vdeldomain mydummy.domain - - suid root vadddomain, vdeldomain and vaddaliasdomain - (this is only needed for domain management in web server module) - cd ~vpopmail/bin - chown 0.0 vadddomain vdeldomain vaddaliasdomain - chmod +s vadddomain vdeldomain vaddaliasdomain - - optionally secure ~vpopmail/bin - (beware these programs may be exploitable or at least used) - chmod 700 ~vpopmail/bin - - run qmail-send - /bin/csh -cf '/var/qmail/rc &' - - run pop3 tcpserver or what you are using - - verify your setup - -#2 verify php vpopmail module and configuration - - for web server module and cgi setups create a phpinfo page: - - <?php phpinfo() ?> - - for command line mode run - php -i - - check for vpopmail section in result - - verify that php euid/egid match vpopmail's - - in setups where only certain domain users will be administrated - verify that php euid/egid can access their respective directories - -FUNCTION PROTOTYPES -------------------------------------------------------------------------------- - -bool vpopmail_add_domain(string domain, string dir, int uid, int gid) -bool vpopmail_del_domain(string domain) -bool vpopmail_add_alias_domain(string domain, string aliasdomain) -bool vpopmail_add_domain_ex(string domain, string passwd [, string quota [, string bounce [, bool apop]]]) -bool vpopmail_del_domain_ex(string domain) -bool vpopmail_add_alias_domain_ex(string olddomain, string newdomain) -bool vpopmail_add_user(string user, string domain, string password[, string gecos[, bool apop]]) -bool vpopmail_del_user(string user, string domain) -bool vpopmail_passwd(string user, string domain, string password) -bool vpopmail_set_user_quota(string user, string domain, string quota) -bool vpopmail_auth_user(string user, string domain, string password[, string apop]) -bool vpopmail_alias_add(string user, string domain, string alias) -bool vpopmail_alias_del(string user, string domain) -bool vpopmail_alias_del_domain(string domain) -array vpopmail_alias_get(string alias, string domain) -string vpopmail_error(void) - - -CONTACT INFO -------------------------------------------------------------------------------- - -your comments, fixes and stuff are welcome -Boian Bonev <boian@bonev.com> - -$Id$ - diff --git a/ext/vpopmail/config.m4 b/ext/vpopmail/config.m4 deleted file mode 100644 index 65ff8a85d2..0000000000 --- a/ext/vpopmail/config.m4 +++ /dev/null @@ -1,94 +0,0 @@ -dnl -dnl $Id$ -dnl - -PHP_ARG_WITH(vpopmail, for vpopmail support, -[ --with-vpopmail[=DIR] Include vpopmail support.]) - -if test "$PHP_VPOPMAIL" != "no"; then - AC_MSG_CHECKING(for vpopmail install directory) - for i in /usr/include/vpopmail /usr/include /usr ~vpopmail /home/vpopmail /home/popmail /var/qmail/vpopmail /var/qmail/popmail $PHP_VPOPMAIL; do - if test -r $i/vpopmail.h; then - VPOPMAIL_INC_DIR=$i - VPOPMAIL_DIR=$i - elif test -r $i/include/vpopmail.h; then - VPOPMAIL_INC_DIR=$i/include - VPOPMAIL_DIR=$i - fi - - if test -r $i/libvpopmail.a; then - VPOPMAIL_LIB_DIR=$i - elif test -r $i/lib/libvpopmail.a; then - VPOPMAIL_LIB_DIR=$i/lib - fi - - if test -x $i/vadddomain; then - VPOPMAIL_BIN_DIR=$i - elif test -x $i/bin/vadddomain; then - VPOPMAIL_BIN_DIR=$i/bin - fi - done - - for i in "$VPOPMAIL_INC_DIR/vpopmail.h" "$VPOPMAIL_INC_DIR/vpopmail_config.h" "$VPOPMAIL_LIB_DIR/libvpopmail.a"; do - if test ! -r "$i"; then - AC_MSG_ERROR(Could not find '$i'. Please make sure you have vpopmail installed. Use -./configure --with-vpopmail=<vpopmail-home-dir> if necessary) - fi - done - - for i in "$VPOPMAIL_BIN_DIR/vadddomain" "$VPOPMAIL_BIN_DIR/vaddaliasdomain" "$VPOPMAIL_BIN_DIR/vdeldomain" ; do - if test ! -x "$i"; then - AC_MSG_ERROR(Could not find '$i' or binary not executeable under current user. -Please make sure you have vpopmail properly installed. -Use ./configure --with-vpopmail=<vpopmail-home-dir> if necessary) - fi - done - - AC_MSG_RESULT($VPOPMAIL_DIR) - - dnl newer versions of vpopmail have include/vauth.h defining valias functions - if test -r $VPOPMAIL_INC_DIR/vauth.h; then - AC_DEFINE(HAVE_VPOPMAIL_VAUTH,1,[Whether vpopmail has vauth.h]) - fi - dnl check for valias functions in the -lvpopmail - PHP_CHECK_LIBRARY(vpopmail, valias_select, [ - AC_DEFINE(HAVE_VPOPMAIL_VALIAS,1,[Whether vpopmail has valias support]) - ],[],[ - -L$VPOPMAIL_LIB_DIR - ]) - - PHP_ADD_INCLUDE($VPOPMAIL_INC_DIR) - - PHP_SUBST(VPOPMAIL_SHARED_LIBADD) - PHP_ADD_LIBRARY_WITH_PATH(vpopmail, $VPOPMAIL_LIB_DIR, VPOPMAIL_SHARED_LIBADD) - - AC_DEFINE(HAVE_VPOPMAIL,1,[Whether you have vpopmail]) - AC_DEFINE_UNQUOTED(VPOPMAIL_BIN_DIR,"$VPOPMAIL_BIN_DIR",[vpopmail bin path]) - - dnl Detect if we have vpopmail >= 5.2 to accomodate C-API changes - dnl - dnl The current table is: - dnl - dnl PHP API VPOPMAIL VERSION - dnl 1 < 5.2 - dnl 2 >= 5.2 - vpopmail_internal_api=1 - version=`grep VERSION $VPOPMAIL_INC_DIR/vpopmail_config.h` - if test -n "$version"; then - version_major=`echo "$version" | tr "\"#." " " | awk '{print $3}'` - version_minor=`echo "$version" | tr "\"#." " " | awk '{print $4}'` - if test $version_major -ge 5; then - if test $version_major -eq 5; then - if test $version_minor -ge 2; then - vpopmail_internal_api=2 - fi - fi - if test $version_major -gt 5; then - vpopmail_internal_api=2 - fi - fi - fi - AC_DEFINE_UNQUOTED(HAVE_VPOPMAIL_API,$vpopmail_internal_api,[Interal definition for vpopmail API changes]) - - PHP_NEW_EXTENSION(vpopmail, php_vpopmail.c, $ext_shared) -fi diff --git a/ext/vpopmail/php_vpopmail.c b/ext/vpopmail/php_vpopmail.c deleted file mode 100644 index 83e5b41936..0000000000 --- a/ext/vpopmail/php_vpopmail.c +++ /dev/null @@ -1,938 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 4 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2002 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: David Croft <david@infotrek.co.uk> | - | Boian Bonev <boian@bonev.com> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -/* TODO: move to config.m4 when support for old versions is ready or just - * don't support rather old vpopmail. current version must bail out if - * incompat option is specified and work for minimal params - */ - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#undef VPOPMAIL_IS_REALLY_OLD - -#include <errno.h> -#include <signal.h> -#include "php.h" -#include "php_ini.h" -#include "php_vpopmail.h" - -#if HAVE_VPOPMAIL - -#include "ext/standard/exec.h" -#include "ext/standard/info.h" -#include "ext/standard/php_string.h" - -ZEND_DECLARE_MODULE_GLOBALS(vpopmail) - -/* keep this as the last include in order to destroy VERSION/PACKAGE only for the rest of the code */ - -#undef VERSION -#undef PACKAGE -#include "vpopmail_config.h" -#include "vpopmail.h" -#if HAVE_VPOPMAIL_VAUTH -#include "vauth.h" -#endif - - -/* vpopmail does not export this, argh! */ -#define MAX_BUFF 500 - -/* Function table */ - -function_entry vpopmail_functions[] = { - /* domain management - lib call */ - PHP_FE(vpopmail_add_domain, NULL) - PHP_FE(vpopmail_del_domain, NULL) - PHP_FE(vpopmail_add_alias_domain, NULL) - /* domain management - exec */ - PHP_FE(vpopmail_add_domain_ex, NULL) - PHP_FE(vpopmail_del_domain_ex, NULL) - PHP_FE(vpopmail_add_alias_domain_ex, NULL) - /* user management */ - PHP_FE(vpopmail_add_user, NULL) - PHP_FE(vpopmail_del_user, NULL) - PHP_FE(vpopmail_passwd, NULL) - PHP_FE(vpopmail_set_user_quota, NULL) - PHP_FE(vpopmail_auth_user, NULL) - /* alias management */ -#if HAVE_VPOPMAIL_VALIAS - PHP_FE(vpopmail_alias_add, NULL) - PHP_FE(vpopmail_alias_del, NULL) -#ifdef VALIAS - PHP_FE(vpopmail_alias_del_domain, NULL) -#endif - PHP_FE(vpopmail_alias_get, NULL) - PHP_FE(vpopmail_alias_get_all, NULL) -#endif - /* error handling */ - PHP_FE(vpopmail_error, NULL) - {NULL, NULL, NULL} -}; - -zend_module_entry vpopmail_module_entry = { - STANDARD_MODULE_HEADER, - "vpopmail", - vpopmail_functions, - PHP_MINIT(vpopmail), - PHP_MSHUTDOWN(vpopmail), - PHP_RINIT(vpopmail), - PHP_RSHUTDOWN(vpopmail), - PHP_MINFO(vpopmail), - NO_VERSION_YET, - STANDARD_MODULE_PROPERTIES -}; - -#ifdef COMPILE_DL_VPOPMAIL -ZEND_GET_MODULE(vpopmail) -#endif - - -PHP_INI_BEGIN() - /*STD_PHP_INI_ENTRY("vpopmail.directory", "", PHP_INI_ALL, OnUpdateString, directory, php_vpopmail_globals, vpopmail_globals)*/ -PHP_INI_END() - - -PHP_MINIT_FUNCTION(vpopmail) -{ - REGISTER_INI_ENTRIES(); - return SUCCESS; -} - -PHP_MSHUTDOWN_FUNCTION(vpopmail) -{ - UNREGISTER_INI_ENTRIES(); - return SUCCESS; -} - -PHP_RINIT_FUNCTION(vpopmail) -{ - VPOPMAILG(vpopmail_open) = 0; - VPOPMAILG(vpopmail_errno) = 0; - - return SUCCESS; -} - -/* nasty but... */ -void vclose(); -/* ...we need this */ - -PHP_RSHUTDOWN_FUNCTION(vpopmail) -{ - if (VPOPMAILG(vpopmail_open) != 0) { - vclose(); - } - return SUCCESS; -} - -PHP_MINFO_FUNCTION(vpopmail) -{ - char ids[64]; - - sprintf(ids, "%d/%d %d/%d/%d/%d", VPOPMAILUID, VPOPMAILGID, getuid(), getgid(), geteuid(), getegid()); - - php_info_print_table_start(); - php_info_print_table_header(2, "vpopmail support", "enabled"); - php_info_print_table_row(2, "vpopmail version", VERSION); - php_info_print_table_row(2, "vpopmail uid/gid php uid/gid/euid/egid", ids); - php_info_print_table_row(2, "vpopmail dir", VPOPMAILDIR); - php_info_print_table_row(2, "vpopmail vadddomain", VPOPMAIL_BIN_DIR VPOPMAIL_ADDD); - php_info_print_table_row(2, "vpopmail vdeldomain", VPOPMAIL_BIN_DIR VPOPMAIL_DELD); - php_info_print_table_row(2, "vpopmail vaddaliasdomain", VPOPMAIL_BIN_DIR VPOPMAIL_ADAD); -#if HAVE_VPOPMAIL_VALIAS - php_info_print_table_row(2, "vpopmail valias support", "Enabled"); -#else - php_info_print_table_row(2, "vpopmail valias support", "Not supported by vpopmail"); -#endif - php_info_print_table_end(); - - DISPLAY_INI_ENTRIES(); -} - -/* - * Domain management functions - library call - */ - -/* {{{ proto bool vpopmail_add_domain(string domain, string dir, int uid, int gid) - Adds a new virtual domain */ -PHP_FUNCTION(vpopmail_add_domain) -{ - zval **domain; - zval **dir; - zval **uid; - zval **gid; - int retval; - - if (ZEND_NUM_ARGS() != 4 - || zend_get_parameters_ex(4, &domain, &dir, &uid, &gid) == FAILURE) - WRONG_PARAM_COUNT; - - convert_to_string_ex(domain); - convert_to_string_ex(dir); - convert_to_long_ex(uid); - convert_to_long_ex(gid); - - VPOPMAILG(vpopmail_open) = 1; - - retval = vadddomain(Z_STRVAL_PP(domain), -#ifdef VPOPMAIL_IS_REALLY_OLD - 0 -#else - Z_STRVAL_PP(dir), - Z_LVAL_PP(uid), - Z_LVAL_PP(gid) -#endif - ); - VPOPMAILG(vpopmail_errno)=retval; - - if (retval == VA_SUCCESS) { - RETURN_TRUE; - } else { - php_error(E_WARNING, "vpopmail error: %s", verror(retval)); - RETURN_FALSE; - } -} -/* }}} */ - -/* {{{ proto bool vpopmail_del_domain(string domain) - Deletes a virtual domain */ -PHP_FUNCTION(vpopmail_del_domain) -{ - zval **domain; - int retval; - - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &domain) == FAILURE) - WRONG_PARAM_COUNT; - - convert_to_string_ex(domain); - - VPOPMAILG(vpopmail_open) = 1; - - retval = vdeldomain(Z_STRVAL_PP(domain)); - - VPOPMAILG(vpopmail_errno)=retval; - - if (retval == VA_SUCCESS) { - RETURN_TRUE; - } else { - php_error(E_WARNING, "vpopmail error: %s", verror(retval)); - RETURN_FALSE; - } -} -/* }}} */ - -/* {{{ proto bool vpopmail_add_alias_domain(string domain, string aliasdomain) - Adds an alias for a virtual domain */ -PHP_FUNCTION(vpopmail_add_alias_domain) -{ - zval **domain; - zval **aliasdomain; - char *tmpstr; - char Dir[156]; - char TmpBuf1[300]; - char TmpBuf2[300]; - int uid, gid; - - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &domain, &aliasdomain) == FAILURE) - WRONG_PARAM_COUNT; - - convert_to_string_ex(domain); - convert_to_string_ex(aliasdomain); - - php_strtolower(Z_STRVAL_PP(domain), Z_STRLEN_PP(domain)); - php_strtolower(Z_STRVAL_PP(aliasdomain), Z_STRLEN_PP(aliasdomain)); - - TSRMLS_FETCH(); - VPOPMAILG(vpopmail_open) = 1; - - tmpstr = vget_assign(Z_STRVAL_PP(domain), Dir, 156, &uid, &gid); - - if (tmpstr == NULL) { - php_error(E_WARNING, "vpopmail_add_alias_domain error: existing domain %s was not found", Z_STRVAL_PP(domain)); - VPOPMAILG(vpopmail_errno) = 1; - RETURN_FALSE; - } - - tmpstr = strstr(Dir, "/domains"); - *tmpstr = 0; - - sprintf(TmpBuf1, "%s/domains/%s", Dir, Z_STRVAL_PP(aliasdomain)); - sprintf(TmpBuf2, "%s/domains/%s", Dir, Z_STRVAL_PP(domain)); - - if (symlink(TmpBuf2, TmpBuf1) != 0) { - php_error(E_WARNING, "vpopmail_add_alias_domain error: could not symlink domains: %s", strerror(errno)); - VPOPMAILG(vpopmail_errno) = 1; - RETURN_FALSE; - } - -#if (!defined(HAVE_VPOPMAIL_API) || HAVE_VPOPMAIL_API == 1) - if (add_domain_assign(Z_STRVAL_PP(aliasdomain), Dir, uid, gid) != 1) { -#else - if (add_domain_assign(Z_STRVAL_PP(aliasdomain), Z_STRVAL_PP(domain), Dir, uid, gid) != 1) { -#endif - php_error(E_WARNING, "vpopmail_addaliasdomain could not add domain to control files"); - VPOPMAILG(vpopmail_errno) = 1; - RETURN_FALSE; - } - - signal_process("qmail-send", SIGHUP); - - VPOPMAILG(vpopmail_errno) = 0; - RETURN_TRUE; -} -/* }}} */ - -/* - * Domain management functions - exec - */ - -/* {{{ proto bool vpopmail_add_domain_ex(string domain, string passwd [, string quota [, string bounce [, bool apop]]]) - Adds a new virtual domain */ -PHP_FUNCTION(vpopmail_add_domain_ex) -{ - zval **domain, **passwd, **quota, **bounce, **apop; - int retval,len=0,argc=ZEND_NUM_ARGS(),is_bounce_email; - int fr_bounce=0,fr_quota=0; - char *cmd,*escdomain="",*escpasswd="",*escquota="",*escbounce="",*escapop=""; - - if (argc < 2 || argc > 5 || zend_get_parameters_ex(argc, &domain, &passwd, "a, &bounce, &apop) == FAILURE){ - WRONG_PARAM_COUNT; - } - - switch (argc) { - case 5: - convert_to_long_ex(apop); - escapop=Z_BVAL_PP(apop)?"1":"0"; - /* Fall-through. */ - case 4: - fr_bounce=1; - convert_to_string_ex(bounce); - escbounce=php_escape_shell_cmd(Z_STRVAL_PP(bounce)); - if (!escbounce) { - php_error(E_WARNING,"vpopmail_adddomain error: cannot alloc"); - VPOPMAILG(vpopmail_errno)=1; - RETURN_FALSE; - } - /* Fall-through. */ - case 3: - fr_quota=1; - convert_to_string_ex(quota); - escquota=php_escape_shell_cmd(Z_STRVAL_PP(quota)); - if (!escquota) { - php_error(E_WARNING,"vpopmail_adddomain error: cannot alloc"); - VPOPMAILG(vpopmail_errno)=1; - RETURN_FALSE; - } - /* Fall-through. */ - case 2: - convert_to_string_ex(passwd); - convert_to_string_ex(domain); - break; - } - - escdomain=php_escape_shell_cmd(Z_STRVAL_PP(domain)); - escpasswd=php_escape_shell_cmd(Z_STRVAL_PP(passwd)); - if (!escdomain||!escpasswd) { - if (fr_quota) - efree(escquota); - if (fr_bounce) - efree(escbounce); - php_error(E_WARNING,"vpopmail_adddomain error: cannot alloc"); - VPOPMAILG(vpopmail_errno)=1; - RETURN_FALSE; - } - len+=strlen(VPOPMAIL_BIN_DIR); - len+=strlen(VPOPMAIL_ADDD); - if (*escquota) - len+=strlen("-q ")+strlen(escquota)+strlen(" "); - if (*escbounce) { - if (strchr(Z_STRVAL_PP(bounce),'@')) { - is_bounce_email=1; - len+=strlen("-e ")+strlen(escbounce)+strlen(" "); - } else { - is_bounce_email=0; - len+=strlen("-b "); - } - } - if (*escapop) - len+=strlen("-a "); - len+=strlen(escdomain)+strlen(" "); - len+=strlen(escpasswd)+strlen(" "); - len++; - cmd=emalloc(len); - if (!cmd) { - if (fr_quota) - efree(escquota); - if (fr_bounce) - efree(escbounce); - efree(escdomain); - efree(escpasswd); - php_error(E_WARNING,"vpopmail_adddomain error: cannot alloc"); - VPOPMAILG(vpopmail_errno)=1; - RETURN_FALSE; - } - strcpy(cmd,VPOPMAIL_BIN_DIR VPOPMAIL_ADDD); - if (*escquota) { - strcat(cmd,"-q "); - strcat(cmd,escquota); - strcat(cmd," "); - } - if (*escbounce) { - if (is_bounce_email) { - strcat(cmd,"-e "); - strcat(cmd,escbounce); - strcat(cmd," "); - } else { - strcat(cmd,"-b "); - } - } - if (*escapop) - strcat(cmd,"-a "); - strcat(cmd,escdomain); - strcat(cmd," "); - strcat(cmd,escpasswd); - retval=php_Exec(0,cmd,NULL,return_value TSRMLS_CC); - efree(cmd); - efree(escdomain); - efree(escpasswd); - if (fr_quota) - efree(escquota); - if (fr_bounce) - efree(escbounce); - - if (retval!=VA_SUCCESS) { - php_error(E_WARNING,"vpopmail_add_domain_ex error: %d", retval); - VPOPMAILG(vpopmail_errno)=1; - RETURN_FALSE; - } else { - VPOPMAILG(vpopmail_errno)=0; - RETURN_TRUE; - } -} -/* }}} */ - -/* {{{ proto bool vpopmail_del_domain_ex(string domain) - Deletes a virtual domain */ -PHP_FUNCTION(vpopmail_del_domain_ex) -{ - zval **domain; - int retval=-1; - char *cmd,*escdomain; - - if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &domain) == FAILURE){ - WRONG_PARAM_COUNT; - } - - convert_to_string_ex(domain); - - escdomain=php_escape_shell_cmd(Z_STRVAL_PP(domain)); - if (!escdomain) { - php_error(E_WARNING,"vpopmail_del_domain_ex error: cannot alloc"); - VPOPMAILG(vpopmail_errno)=1; - RETURN_FALSE; - } - cmd=emalloc(strlen(VPOPMAIL_BIN_DIR)+strlen(VPOPMAIL_DELD)+strlen(escdomain)+1); - if (!cmd) { - efree(escdomain); - php_error(E_WARNING,"vpopmail_del_domain_ex error: cannot alloc"); - VPOPMAILG(vpopmail_errno)=1; - RETURN_FALSE; - } - sprintf(cmd,VPOPMAIL_BIN_DIR VPOPMAIL_DELD"%s",escdomain); - retval=php_Exec(0,cmd,NULL,return_value TSRMLS_CC); - efree(escdomain); - efree(cmd); - - if (retval!=VA_SUCCESS) { - php_error(E_WARNING,"vpopmail_del_domain_ex error: %d", retval); - VPOPMAILG(vpopmail_errno)=1; - RETURN_FALSE; - } else { - VPOPMAILG(vpopmail_errno)=0; - RETURN_TRUE; - } -} -/* }}} */ - -/* {{{ proto bool vpopmail_add_alias_domain_ex(string olddomain, string newdomain) - Adds an alias to an existing virtual domain */ -PHP_FUNCTION(vpopmail_add_alias_domain_ex) -{ - zval **olddomain, **newdomain; - int retval; - char *cmd,*escolddomain,*escnewdomain; - - if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &olddomain, &newdomain) == FAILURE){ - WRONG_PARAM_COUNT; - } - - convert_to_string_ex(olddomain); - convert_to_string_ex(newdomain); - escnewdomain=php_escape_shell_cmd(Z_STRVAL_PP(newdomain)); - if (!escnewdomain) { - php_error(E_WARNING,"vpopmail_addaliasdomain error: cannot alloc"); - VPOPMAILG(vpopmail_errno)=1; - RETURN_FALSE; - } - escolddomain=php_escape_shell_cmd(Z_STRVAL_PP(olddomain)); - if (!escolddomain) { - efree(escnewdomain); - php_error(E_WARNING,"vpopmail_addaliasdomain error: cannot alloc"); - VPOPMAILG(vpopmail_errno)=1; - RETURN_FALSE; - } - - cmd=emalloc(strlen(VPOPMAIL_BIN_DIR VPOPMAIL_ADAD)+strlen(escolddomain)+strlen(" ")+strlen(escnewdomain)+1); - if (!cmd) { - efree(escnewdomain); - efree(escolddomain); - php_error(E_WARNING,"vpopmail_addaliasdomain error: cannot alloc"); - VPOPMAILG(vpopmail_errno)=1; - RETURN_FALSE; - } - sprintf(cmd,"%s%s %s",VPOPMAIL_BIN_DIR VPOPMAIL_ADAD,escolddomain,escnewdomain); - retval=php_Exec(0,cmd,NULL,return_value TSRMLS_CC); - efree(cmd); - efree(escnewdomain); - efree(escolddomain); - - if (retval!=VA_SUCCESS) { - php_error(E_WARNING,"vpopmail_addaliasdomain error: %d", retval); - VPOPMAILG(vpopmail_errno)=1; - RETURN_FALSE; - } else { - VPOPMAILG(vpopmail_errno)=0; - RETURN_TRUE; - } -} -/* }}} */ - -/* - * User management functions - */ - -/* {{{ proto bool vpopmail_add_user(string user, string domain, string password[, string gecos[, bool apop]]) - Adds a new user to the specified virtual domain */ -PHP_FUNCTION(vpopmail_add_user) -{ - zval **user; - zval **domain; - zval **password; - zval **gecos; - zval **apop; - int is_apop = 0; - char *the_gecos = ""; - int retval; - - if (ZEND_NUM_ARGS() < 3 || ZEND_NUM_ARGS() > 5 - || zend_get_parameters_ex(ZEND_NUM_ARGS(), &user, &domain, &password, &gecos, &apop) == FAILURE) - WRONG_PARAM_COUNT; - - switch (ZEND_NUM_ARGS()) { - case 5: - convert_to_boolean_ex(apop); - is_apop = (Z_BVAL_PP(apop) ? 1 : 0); - /* fall through */ - - case 4: - convert_to_string_ex(gecos); - the_gecos = Z_STRVAL_PP(gecos); - /* fall through */ - - default: - convert_to_string_ex(user); - convert_to_string_ex(domain); - convert_to_string_ex(password); - } - - VPOPMAILG(vpopmail_open) = 1; - - retval = vadduser(Z_STRVAL_PP(user), - Z_STRVAL_PP(domain), - Z_STRVAL_PP(password), - the_gecos, - is_apop); - - VPOPMAILG(vpopmail_errno)=retval; - - if (retval == VA_SUCCESS) { - RETURN_TRUE; - } else { - php_error(E_WARNING, "vpopmail error: %s", verror(retval)); - RETURN_FALSE; - } -} -/* }}} */ - -/* {{{ proto bool vpopmail_del_user(string user, string domain) - Deletes a user from a virtual domain */ -PHP_FUNCTION(vpopmail_del_user) -{ - zval **user; - zval **domain; - int retval; - - if (ZEND_NUM_ARGS() != 2 - || zend_get_parameters_ex(2, &user, &domain) == FAILURE) - WRONG_PARAM_COUNT; - - convert_to_string_ex(user); - convert_to_string_ex(domain); - - VPOPMAILG(vpopmail_open) = 1; - - retval = vdeluser(Z_STRVAL_PP(user), - Z_STRVAL_PP(domain)); - - VPOPMAILG(vpopmail_errno)=retval; - - if (retval == VA_SUCCESS) { - RETURN_TRUE; - } else { - php_error(E_WARNING, "vpopmail error: %s", verror(retval)); - RETURN_FALSE; - } -} -/* }}} */ - -/* {{{ proto bool vpopmail_passwd(string user, string domain, string password) - Changes user's password */ -PHP_FUNCTION(vpopmail_passwd) -{ - zval **user; - zval **domain; - zval **password; - zval **apop; - int is_apop = 0; - int retval; - - if (ZEND_NUM_ARGS() < 3 || ZEND_NUM_ARGS() > 4 - || zend_get_parameters_ex(ZEND_NUM_ARGS(), &user, &domain, &password, &apop) == FAILURE) - WRONG_PARAM_COUNT; - - if (ZEND_NUM_ARGS() > 3) { - convert_to_boolean_ex(apop); - is_apop = (Z_BVAL_PP(apop) ? 1 : 0); - } - - convert_to_string_ex(user); - convert_to_string_ex(domain); - convert_to_string_ex(password); - - VPOPMAILG(vpopmail_open) = 1; - - retval = vpasswd(Z_STRVAL_PP(user), - Z_STRVAL_PP(domain), - Z_STRVAL_PP(password), - is_apop); - - VPOPMAILG(vpopmail_errno)=retval; - - if (retval == VA_SUCCESS) { - RETURN_TRUE; - } else { - php_error(E_WARNING, "vpopmail error: %s", verror(retval)); - RETURN_FALSE; - } -} -/* }}} */ - -/* {{{ proto bool vpopmail_set_user_quota(string user, string domain, string quota) - Sets user's quota */ -PHP_FUNCTION(vpopmail_set_user_quota) -{ - zval **user; - zval **domain; - zval **quota; - int retval; - - if (ZEND_NUM_ARGS() != 3 - || zend_get_parameters_ex(3, &user, &domain, "a) == FAILURE) - WRONG_PARAM_COUNT; - - convert_to_string_ex(user); - convert_to_string_ex(domain); - convert_to_string_ex(quota); - - VPOPMAILG(vpopmail_open) = 1; - - retval = vsetuserquota(Z_STRVAL_PP(user), - Z_STRVAL_PP(domain), - Z_STRVAL_PP(quota)); - - VPOPMAILG(vpopmail_errno)=retval; - - if (retval == VA_SUCCESS) { - RETURN_TRUE; - } else { - php_error(E_WARNING, "vpopmail error: %s", verror(retval)); - RETURN_FALSE; - } -} -/* }}} */ - -/* {{{ proto bool vpopmail_auth_user(string user, string domain, string password[, string apop]) - Attempts to validate a username/domain/password. Returns true/false */ -PHP_FUNCTION(vpopmail_auth_user) -{ - zval **user; - zval **domain; - zval **password; - zval **apop; - /* indeed we do not care of contents; newer vpopmail versions use struct vpasswd instead passwd */ - void *retval; - int argc=ZEND_NUM_ARGS(); - - if (argc < 3 || argc > 4 - || zend_get_parameters_ex(argc, &user, &domain, &password, &apop) == FAILURE) - WRONG_PARAM_COUNT; - - if (argc > 3) - convert_to_string_ex(apop); - - convert_to_string_ex(user); - convert_to_string_ex(domain); - convert_to_string_ex(password); - - VPOPMAILG(vpopmail_open) = 1; - VPOPMAILG(vpopmail_errno) = 0; - - retval = vauth_user(Z_STRVAL_PP(user), - Z_STRVAL_PP(domain), - Z_STRVAL_PP(password), - (argc>3)?Z_STRVAL_PP(apop):""); - - /* - * we do not set vpopmail_errno here - it is considered auth_user cannot fail; insted it does not auth - * this is a vpopmail's api limitation - there is no error return form vauth_user - */ - - if (retval == NULL) { - RETURN_FALSE; - } else { - RETURN_TRUE; - } -} -/* }}} */ - - -#if HAVE_VPOPMAIL_VALIAS - -/* - * Alias management functions - */ - - -/* {{{ proto bool vpopmail_alias_add(string user, string domain, string alias) - Inserts a virtual alias */ -PHP_FUNCTION(vpopmail_alias_add) -{ - zval **user; - zval **domain; - zval **alias; - int retval; - - if (ZEND_NUM_ARGS() != 3 - || zend_get_parameters_ex(ZEND_NUM_ARGS(), &user, &domain, &alias) == FAILURE) - WRONG_PARAM_COUNT; - - convert_to_string_ex(user); - convert_to_string_ex(domain); - convert_to_string_ex(alias); - - VPOPMAILG(vpopmail_open) = 1; - - retval = valias_insert(Z_STRVAL_PP(user), - Z_STRVAL_PP(domain), - Z_STRVAL_PP(alias)); - - VPOPMAILG(vpopmail_errno)=retval; - - if (retval == VA_SUCCESS) { - RETURN_TRUE; - } else { - php_error(E_WARNING, "vpopmail error: %s", verror(retval)); - RETURN_FALSE; - } -} -/* }}} */ - -/* {{{ proto bool vpopmail_alias_del(string user, string domain) - Deletes all virtual aliases of a given user */ -PHP_FUNCTION(vpopmail_alias_del) -{ - zval **user; - zval **domain; - int retval; - - if (ZEND_NUM_ARGS() != 2 - || zend_get_parameters_ex(ZEND_NUM_ARGS(), &user, &domain) == FAILURE) - WRONG_PARAM_COUNT; - - convert_to_string_ex(user); - convert_to_string_ex(domain); - - VPOPMAILG(vpopmail_open) = 1; - - retval = valias_delete(Z_STRVAL_PP(user), Z_STRVAL_PP(domain)); - - VPOPMAILG(vpopmail_errno)=retval; - - if (retval == VA_SUCCESS) { - RETURN_TRUE; - } else { - php_error(E_WARNING, "vpopmail error: %s", verror(retval)); - RETURN_FALSE; - } -} -/* }}} */ - -#ifdef VALIAS -/* {{{ proto bool vpopmail_alias_del_domain(string domain) - Deletes all virtual aliases of a given domain */ -PHP_FUNCTION(vpopmail_alias_del_domain) -{ - zval **domain; - int retval; - - if (ZEND_NUM_ARGS() != 1 - || zend_get_parameters_ex(ZEND_NUM_ARGS(), &domain) == FAILURE) - WRONG_PARAM_COUNT; - - convert_to_string_ex(domain); - - VPOPMAILG(vpopmail_open) = 1; - - retval = valias_delete_domain(Z_STRVAL_PP(domain)); - - VPOPMAILG(vpopmail_errno)=retval; - - if (retval == VA_SUCCESS) { - RETURN_TRUE; - } else { - php_error(E_WARNING, "vpopmail error: %s", verror(retval)); - RETURN_FALSE; - } -} -/* }}} */ -#endif - -/* {{{ proto array vpopmail_alias_get(string alias, string domain) - Returns all lines of an alias for a given domain */ -PHP_FUNCTION(vpopmail_alias_get) -{ - zval **alias; - zval **domain; - int retval; - char *talias; - - if (ZEND_NUM_ARGS() != 2 - || zend_get_parameters_ex(ZEND_NUM_ARGS(), &alias, &domain) == FAILURE) - WRONG_PARAM_COUNT; - - convert_to_string_ex(alias); - convert_to_string_ex(domain); - - VPOPMAILG(vpopmail_open) = 1; - - if (array_init(return_value)!=SUCCESS) { - zend_error(E_ERROR,"unable to create array"); - RETURN_FALSE; - } - - talias=valias_select(Z_STRVAL_PP(alias), Z_STRVAL_PP(domain)); - while (talias) { - add_next_index_string(return_value,talias,1); - talias=valias_select_next(); - } -} -/* }}} */ - -/* {{{ proto array vpopmail_alias_get_all(string domain) - Returns all lines of all aliases for a given domain */ -PHP_FUNCTION(vpopmail_alias_get_all) -{ - zval **domain; - int retval; - char *talias; - char tpath[1024]; - char ppath[1024]=""; - zval *tarr; - - if (ZEND_NUM_ARGS() != 1 - || zend_get_parameters_ex(ZEND_NUM_ARGS(), &domain) == FAILURE) - WRONG_PARAM_COUNT; - - convert_to_string_ex(domain); - - VPOPMAILG(vpopmail_open) = 1; - - if (array_init(return_value)!=SUCCESS) { - zend_error(E_ERROR,"unable to create array"); - RETURN_FALSE; - } - - talias=valias_select_all(tpath, Z_STRVAL_PP(domain)); - while (talias) { - if (strcmp(ppath,tpath)) { - MAKE_STD_ZVAL(tarr); - if (array_init(tarr)!=SUCCESS) { - zend_error(E_ERROR,"unable to create array"); - RETURN_FALSE; - } - add_assoc_zval(return_value,tpath,tarr); - strcpy(ppath,tpath); - } - add_next_index_string(tarr,talias,1); - talias=valias_select_all_next(tpath); - } -} -/* }}} */ - -#endif - -/* - * Error handling helper - */ - -/* {{{ proto string vpopmail_error(void) - Returns text message for last vpopmail error */ -PHP_FUNCTION(vpopmail_error) -{ - if (ZEND_NUM_ARGS() != 0) - WRONG_PARAM_COUNT; - - RETURN_STRING(verror(VPOPMAILG(vpopmail_errno)),1); -} -/* }}} */ - -#endif - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - * vim600: sw=4 ts=4 fdm=marker - * vim<600: sw=4 ts=4 - */ diff --git a/ext/vpopmail/php_vpopmail.h b/ext/vpopmail/php_vpopmail.h deleted file mode 100644 index 442f84c53a..0000000000 --- a/ext/vpopmail/php_vpopmail.h +++ /dev/null @@ -1,97 +0,0 @@ -/* - +----------------------------------------------------------------------+ - | PHP Version 4 | - +----------------------------------------------------------------------+ - | Copyright (c) 1997-2002 The PHP Group | - +----------------------------------------------------------------------+ - | This source file is subject to version 2.02 of the PHP license, | - | that is bundled with this package in the file LICENSE, and is | - | available at through the world-wide-web at | - | http://www.php.net/license/2_02.txt. | - | If you did not receive a copy of the PHP license and are unable to | - | obtain it through the world-wide-web, please send a note to | - | license@php.net so we can mail you a copy immediately. | - +----------------------------------------------------------------------+ - | Authors: David Croft <david@infotrek.co.uk> | - | Boian Bonev <boian@bonev.com> | - +----------------------------------------------------------------------+ -*/ - -/* $Id$ */ - -#ifndef PHP_VPOPMAIL_H -#define PHP_VPOPMAIL_H - -#if HAVE_VPOPMAIL - -extern zend_module_entry vpopmail_module_entry; -#define phpext_vpopmail_ptr &vpopmail_module_entry - -#ifdef PHP_WIN32 -#define PHP_VPOPMAIL_API __declspec(dllexport) -#else -#define PHP_VPOPMAIL_API -#endif - -PHP_MINIT_FUNCTION(vpopmail); -PHP_MSHUTDOWN_FUNCTION(vpopmail); -PHP_RINIT_FUNCTION(vpopmail); -PHP_RSHUTDOWN_FUNCTION(vpopmail); -PHP_MINFO_FUNCTION(vpopmail); - -/* domain management - lib call */ -PHP_FUNCTION(vpopmail_add_domain); -PHP_FUNCTION(vpopmail_del_domain); -PHP_FUNCTION(vpopmail_add_alias_domain); -/* domain management - exec */ -PHP_FUNCTION(vpopmail_add_domain_ex); -PHP_FUNCTION(vpopmail_del_domain_ex); -PHP_FUNCTION(vpopmail_add_alias_domain_ex); -/* user management */ -PHP_FUNCTION(vpopmail_add_user); -PHP_FUNCTION(vpopmail_del_user); -PHP_FUNCTION(vpopmail_passwd); -PHP_FUNCTION(vpopmail_set_user_quota); -PHP_FUNCTION(vpopmail_auth_user); -/* alias management */ -#if HAVE_VPOPMAIL_VALIAS -PHP_FUNCTION(vpopmail_alias_add); -PHP_FUNCTION(vpopmail_alias_del); -PHP_FUNCTION(vpopmail_alias_del_domain); -PHP_FUNCTION(vpopmail_alias_get); -PHP_FUNCTION(vpopmail_alias_get_all); -#endif -/* error handling */ -PHP_FUNCTION(vpopmail_error); - -/* defines for vpopmail command line tool names */ -#define VPOPMAIL_ADDD "/vadddomain " -#define VPOPMAIL_DELD "/vdeldomain " -#define VPOPMAIL_ADAD "/vaddaliasdomain " - -ZEND_BEGIN_MODULE_GLOBALS(vpopmail) - int vpopmail_open; - int vpopmail_errno; -ZEND_END_MODULE_GLOBALS(vpopmail) - -#ifdef ZTS -#define VPOPMAILG(v) TSRMG(vpopmail_globals_id, zend_vpopmail_globals *, v) -#else -#define VPOPMAILG(v) (vpopmail_globals.v) -#endif - -#else - -#define phpext_vpopmail_ptr NULL - -#endif - -#endif /* PHP_VPOPMAIL_H */ - - -/* - * Local variables: - * tab-width: 4 - * c-basic-offset: 4 - * End: - */ |