├── tests ├── data │ ├── hosts │ ├── group │ ├── passwd │ ├── netgroup │ ├── rpc │ ├── protocols │ └── services ├── 001-yp_get_default_domain.phpt ├── 003-yp_order.phpt ├── 005-yp_master.phpt ├── 004-yp_cat.phpt ├── 006-yp_match.phpt ├── 002-yp_all.phpt ├── bootstrap.sh ├── patch-Makefile_global.sh ├── 007-yp_first-and-yp_next.phpt ├── 010-yp_err_string.phpt └── 009-yp_errno.phpt ├── TODO ├── RELEASE-1.0.1 ├── RELEASE-1.0.0RC1 ├── CREDITS ├── RELEASE-1.0.0 ├── README.md ├── Vagrantfile ├── .travis.yml ├── config.m4 ├── .gitignore ├── php_yp.h ├── API-1.0.0 ├── LICENSE ├── package.xml └── yp.c /tests/data/hosts: -------------------------------------------------------------------------------- 1 | 127.0.0.1 localhost 2 | 127.0.1.1 precise32 3 | -------------------------------------------------------------------------------- /tests/data/group: -------------------------------------------------------------------------------- 1 | vagrant:x:1000: 2 | puppet:x:1001: 3 | vboxsf:x:1002: 4 | -------------------------------------------------------------------------------- /tests/data/passwd: -------------------------------------------------------------------------------- 1 | vagrant:x:1000:1000:vagrant,,,:/home/vagrant:/bin/bash 2 | -------------------------------------------------------------------------------- /TODO: -------------------------------------------------------------------------------- 1 | - Add OO interface to yp 2 | - Integrate with travis-ci.org or drone.io to run tests automatically 3 | -------------------------------------------------------------------------------- /RELEASE-1.0.1: -------------------------------------------------------------------------------- 1 | 1.0.1 release 2 | 3 | - trivial update to fix wrong version display in php_info page [gasolwu] 4 | -------------------------------------------------------------------------------- /RELEASE-1.0.0RC1: -------------------------------------------------------------------------------- 1 | Initial beta release 2 | 3 | - Fix build with modern PHP including PHP 5.3, 5.4 and 5.5 [gasolwu] 4 | - Build testing environment with vagrants [gasolwu] 5 | - Add tests for all public funcctions [gasolwu] 6 | -------------------------------------------------------------------------------- /CREDITS: -------------------------------------------------------------------------------- 1 | ;; Yellow Pages 2 | Gasol Wu [gasolwu] (lead) 3 | Pierre Joye [pajoye] (lead) 4 | Stephanie Wehner [atrak] <_@r4k.net> (lead/inactive) 5 | Fredrik Ohrn [ohrn] (lead/inactive) 6 | -------------------------------------------------------------------------------- /tests/001-yp_get_default_domain.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | yp_get_default_domain() function test 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 9 | --EXPECT-- 10 | string(9) "precise32" 11 | -------------------------------------------------------------------------------- /RELEASE-1.0.0: -------------------------------------------------------------------------------- 1 | Initial stable release 2 | 3 | - Fix build with modern PHP including PHP 5.3, 5.4 and 5.5 [gasolwu] 4 | - Build testing environment with vagrants [gasolwu] 5 | - Add tests for all public functions [gasolwu] 6 | - Fix bugs #59537 [gasolwu] 7 | - Correct constant value of YPERR_ACCESS [gasolwu] 8 | -------------------------------------------------------------------------------- /tests/003-yp_order.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | yp_order() function test 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 10 | --EXPECTF-- 11 | int(%d) 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | YP/NIS functions 2 | =============== 3 | 4 | [![Build Status](https://travis-ci.org/Gasol/pecl-networking-yp.png?branch=develop)](https://travis-ci.org/Gasol/pecl-networking-yp) 5 | 6 | NIS (formerly called Yellow Pages) allows network management 7 | of important administrative files (e.g. the password file). 8 | -------------------------------------------------------------------------------- /tests/005-yp_master.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | yp_master() function test 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 10 | --EXPECTF-- 11 | string(%d) "%s" 12 | 13 | -------------------------------------------------------------------------------- /Vagrantfile: -------------------------------------------------------------------------------- 1 | # -*- mode: ruby -*- 2 | # vi: set ft=ruby : 3 | 4 | VAGRANTFILE_API_VERSION = "2" 5 | 6 | Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| 7 | config.vm.box = "precise32" 8 | config.vm.box_url = "http://files.vagrantup.com/precise32.box" 9 | config.vm.provision "shell", path: "tests/bootstrap.sh" 10 | end 11 | -------------------------------------------------------------------------------- /tests/004-yp_cat.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | yp_cat() function test 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 10 | --EXPECT-- 11 | array(2) { 12 | ["localhost"]=> 13 | string(19) "127.0.0.1 localhost" 14 | ["precise32"]=> 15 | string(19) "127.0.1.1 precise32" 16 | } 17 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | php: 3 | - 5.6 4 | - 5.5 5 | - 5.4 6 | - 5.3 7 | 8 | env: 9 | - REPORT_EXIT_STATUS=1 TESTS="-q --show-diff" TEST_PHP_EXECUTABLE=php 10 | 11 | before_script: 12 | - sudo -E bash tests/bootstrap.sh 13 | 14 | install: 15 | - phpize 16 | - sh tests/patch-Makefile_global.sh 17 | - ./configure 18 | - make 19 | 20 | script: make test 21 | 22 | notifications: 23 | email: 24 | - gasol.wu+travis@gmail.com 25 | -------------------------------------------------------------------------------- /tests/006-yp_match.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | yp_match() function test 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 11 | --EXPECTF-- 12 | string(19) "127.0.0.1 localhost" 13 | 14 | Warning: yp_match(): No such key in map in %s/tests/006-yp_match.php on line 4 15 | bool(false) 16 | -------------------------------------------------------------------------------- /tests/002-yp_all.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | yp_all() function test 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 13 | --EXPECT-- 14 | Array 15 | ( 16 | [0] => 1 17 | [1] => vagrant 18 | [2] => vagrant:x:1000:1000:vagrant,,,:/home/vagrant:/bin/bash 19 | ) 20 | bool(false) 21 | -------------------------------------------------------------------------------- /tests/bootstrap.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | if [ -z "$TRAVIS_BUILD_DIR" ]; then 4 | YPSRCDIR="/vagrant/tests/data" 5 | else 6 | YPSRCDIR="$TRAVIS_BUILD_DIR/tests/data" 7 | fi 8 | 9 | apt-get update 10 | debconf-set-selections <<< 'nis nis/domain string precise32' 11 | DEBIAN_FRONTEND=noninteractive apt-get install -y expect php5-cli php5-dev nis valgrind 12 | sed -i -re 's/NISSERVER=(.*)/NISSERVER=true/' /etc/default/nis 13 | sed -i -re "s|(YPSRCDIR = ).*|\\1$YPSRCDIR|" /var/yp/Makefile 14 | sed -i -re "s|(YPPWDDIR = ).*|\\1$YPSRCDIR|" /var/yp/Makefile 15 | service ypserv start 16 | expect -c ' 17 | spawn /usr/lib/yp/ypinit -m 18 | expect "" 19 | send "precise32\n" 20 | send "" 21 | expect "Is this correct?" 22 | send "\n" 23 | expect eof 24 | ' 25 | -------------------------------------------------------------------------------- /tests/data/netgroup: -------------------------------------------------------------------------------- 1 | # 2 | # netgroup The netgroup file. Entries look like this: 3 | # 4 | # netgroup (host,user,domain) (host,user,domain) .. 5 | # 6 | # So for example a netgroup for powerusers could be: 7 | # 8 | # powerusers (,miquels,) (,torvalds,) (,fubar,) 9 | # 10 | # And an entry in the password file like 11 | # 12 | # +@powerusers:::::: 13 | # +:*:::::/etc/NoShell 14 | # 15 | # would give access only to the users in "powerusers", while the 16 | # other users would be known to the system but have an invalid 17 | # shell AND an invalid password (with Linux, you can also 18 | # override the password field). 19 | # 20 | 21 | # powerusers (,miquels,) (,torvalds,) (,fubar,) 22 | # ourhosts (picard,,) (enterprise,,) (laforge,,) (Q,,) 23 | -------------------------------------------------------------------------------- /config.m4: -------------------------------------------------------------------------------- 1 | dnl 2 | dnl $Id$ 3 | dnl 4 | 5 | PHP_ARG_ENABLE(yp,whether to include YP support, 6 | [ --enable-yp Include YP support.]) 7 | 8 | if test "$PHP_YP" != "no"; then 9 | 10 | AC_CHECK_LIB(nsl, yp_match, [ 11 | YP_LIBS=nsl 12 | YP_CHECK_IN_LIB=nsl 13 | ], 14 | AC_CHECK_LIB(c, yp_match, [ 15 | YP_LIBS= 16 | YP_CHECK_IN_LIB=c 17 | ],[ 18 | AC_MSG_ERROR(Unable to find required yp/nis library) 19 | ]) 20 | ) 21 | 22 | 23 | AC_DEFINE(HAVE_YP,1,[ ]) 24 | PHP_NEW_EXTENSION(yp, yp.c, $ext_shared) 25 | 26 | PHP_SUBST(YP_SHARED_LIBADD) 27 | 28 | if test -n "$YP_LIBS"; then 29 | PHP_ADD_LIBRARY_WITH_PATH($YP_LIBS, $YP_LIBDIR, YP_SHARED_LIBADD) 30 | fi 31 | 32 | 33 | 34 | case $host_alias in 35 | *solaris*) 36 | AC_DEFINE(SOLARIS_YP,1,[ ]) ;; 37 | esac 38 | fi 39 | -------------------------------------------------------------------------------- /tests/patch-Makefile_global.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Sould source this file after phpize (Copied Makefile.global) 3 | # See https://bugs.php.net/bug.php?id=60285 4 | 5 | realpath() { 6 | file=$1 7 | cd $(dirname $file) 8 | file=$(basename $file) 9 | if [ -h "$file" ]; then 10 | echo $file 11 | readlink $(readlink $file) 12 | else 13 | dir=$(pwd -P) 14 | echo "$dir/$file" 15 | fi 16 | } 17 | 18 | BASEDIR=$(dirname $(dirname $(realpath $0))) 19 | MAKEFILE="$BASEDIR/Makefile.global" 20 | 21 | if ! grep -q 'TEST_RESULT_EXIT_CODE' $MAKEFILE; then 22 | echo "Applying patch to fix PHP Bug #60285" 23 | sed -i -re 's|-(@if test ! -z "\$\(PHP_EXECUTABLE\)")|\1|' $MAKEFILE 24 | sed -i -re '/TESTS/a \\t\tTEST_RESULT_EXIT_CODE=$$?; \\' $MAKEFILE 25 | sed -i -re '/rm \$\(top_builddir\)\/tmp-php\.ini; \\/a \\t\texit $$TEST_RESULT_EXIT_CODE; \\' $MAKEFILE 26 | fi 27 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | *.ko 4 | 5 | # Libraries 6 | *.lib 7 | *.a 8 | 9 | # Shared objects (inc. Windows DLLs) 10 | *.dll 11 | *.so 12 | *.so.* 13 | *.dylib 14 | 15 | # Executables 16 | *.exe 17 | *.out 18 | *.app 19 | 20 | # http://www.gnu.org/software/automake 21 | 22 | Makefile 23 | Makefile.fragments 24 | Makefile.global 25 | Makefile.objects 26 | Makefile.in 27 | 28 | # http://www.gnu.org/software/autoconf 29 | 30 | /autom4te.cache 31 | /aclocal.m4 32 | /acinclude.m4 33 | /compile 34 | /configure 35 | /depcomp 36 | /install-sh 37 | /missing 38 | /config.guess 39 | /config.sub 40 | /config.h 41 | /config.h.in 42 | /config.log 43 | /config.nice 44 | /config.status 45 | /configure.in 46 | /ltmain.sh 47 | /libtool 48 | /mkinstalldirs 49 | /run-tests.php 50 | 51 | /.deps 52 | /.libs 53 | /.vagrant 54 | /build 55 | /modules 56 | /tmp-php.ini 57 | /yp.la 58 | /yp.lo 59 | -------------------------------------------------------------------------------- /tests/007-yp_first-and-yp_next.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | yp_first() and yp_order() function test 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 25 | --EXPECTF-- 26 | bool(true) 27 | 28 | Warning: yp_next(): No more records in map database in %s/tests/007-yp_first-and-yp_next.php on line 10 29 | bool(false) 30 | bool(true) 31 | array(3) { 32 | [0]=> 33 | string(14) "puppet:x:1001:" 34 | [1]=> 35 | string(15) "vagrant:x:1000:" 36 | [2]=> 37 | string(14) "vboxsf:x:1002:" 38 | } 39 | -------------------------------------------------------------------------------- /tests/010-yp_err_string.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | yp_err_string() function test 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 11 | --EXPECT-- 12 | string(7) "Success" 13 | string(21) "Request arguments bad" 14 | string(28) "RPC failure on NIS operation" 15 | string(45) "Can't bind to server which serves this domain" 16 | string(30) "No such map in server's domain" 17 | string(18) "No such key in map" 18 | string(18) "Internal NIS error" 19 | string(33) "Local resource allocation failure" 20 | string(31) "No more records in map database" 21 | string(33) "Can't communicate with portmapper" 22 | string(29) "Can't communicate with ypbind" 23 | string(29) "Can't communicate with ypserv" 24 | string(25) "Local domain name not set" 25 | string(23) "NIS map database is bad" 26 | string(57) "NIS client/server version mismatch - can't supply service" 27 | string(17) "Permission denied" 28 | string(16) "Database is busy" 29 | -------------------------------------------------------------------------------- /tests/data/rpc: -------------------------------------------------------------------------------- 1 | # This file contains user readable names that can be used in place of rpc 2 | # program numbers. 3 | 4 | portmapper 100000 portmap sunrpc 5 | rstatd 100001 rstat rstat_svc rup perfmeter 6 | rusersd 100002 rusers 7 | nfs 100003 nfsprog 8 | ypserv 100004 ypprog 9 | mountd 100005 mount showmount 10 | ypbind 100007 11 | walld 100008 rwall shutdown 12 | yppasswdd 100009 yppasswd 13 | etherstatd 100010 etherstat 14 | rquotad 100011 rquotaprog quota rquota 15 | sprayd 100012 spray 16 | 3270_mapper 100013 17 | rje_mapper 100014 18 | selection_svc 100015 selnsvc 19 | database_svc 100016 20 | rexd 100017 rex 21 | alis 100018 22 | sched 100019 23 | llockmgr 100020 24 | nlockmgr 100021 25 | x25.inr 100022 26 | statmon 100023 27 | status 100024 28 | bootparam 100026 29 | ypupdated 100028 ypupdate 30 | keyserv 100029 keyserver 31 | tfsd 100037 32 | nsed 100038 33 | nsemntd 100039 34 | ypxfrd 100069 35 | pcnfsd 150001 36 | amd 300019 amq 37 | sgi_fam 391002 38 | ugidd 545580417 39 | fypxfrd 600100069 freebsd-ypxfrd 40 | bwnfsd 788585389 41 | -------------------------------------------------------------------------------- /tests/009-yp_errno.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | yp_errno() function test 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 16 | --EXPECTF-- 17 | Array 18 | ( 19 | [YPERR_BADARGS] => 1 20 | [YPERR_RPC] => 2 21 | [YPERR_DOMAIN] => 3 22 | [YPERR_MAP] => 4 23 | [YPERR_KEY] => 5 24 | [YPERR_YPERR] => 6 25 | [YPERR_RESRC] => 7 26 | [YPERR_NOMORE] => 8 27 | [YPERR_PMAP] => 9 28 | [YPERR_YPBIND] => 10 29 | [YPERR_YPSERV] => 11 30 | [YPERR_NODOM] => 12 31 | [YPERR_BADDB] => 13 32 | [YPERR_VERS] => 14 33 | [YPERR_ACCESS] => 15 34 | [YPERR_BUSY] => 16 35 | ) 36 | int(0) 37 | 38 | Warning: yp_next(): No more records in map database in %s/tests/009-yp_errno.php on line 8 39 | bool(false) 40 | int(8) 41 | 42 | -------------------------------------------------------------------------------- /php_yp.h: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | PHP Version 5 | 4 | +----------------------------------------------------------------------+ 5 | | Copyright (c) 1997-2014 The PHP Group | 6 | +----------------------------------------------------------------------+ 7 | | This source file is subject to version 3.01 of the PHP license, | 8 | | that is bundled with this package in the file LICENSE, and is | 9 | | available through the world-wide-web at the following url: | 10 | | http://www.php.net/license/3_01.txt | 11 | | If you did not receive a copy of the PHP license and are unable to | 12 | | obtain it through the world-wide-web, please send a note to | 13 | | license@php.net so we can mail you a copy immediately. | 14 | +----------------------------------------------------------------------+ 15 | | Authors: Stephanie Wehner <_@r4k.net> | 16 | | Fredrik Ohrn | 17 | +----------------------------------------------------------------------+ 18 | */ 19 | 20 | /* $Id$ */ 21 | 22 | #ifndef PHP_YP_H 23 | #define PHP_YP_H 24 | 25 | #if HAVE_YP 26 | 27 | #ifdef PHP_WIN32 28 | #define PHP_YP_API __declspec(dllexport) 29 | #else 30 | #define PHP_YP_API 31 | #endif 32 | 33 | extern zend_module_entry yp_module_entry; 34 | #define yp_module_ptr &yp_module_entry 35 | 36 | #define PHP_YP_VERSION "1.0.1" 37 | 38 | /* yp.c functions */ 39 | PHP_FUNCTION(yp_get_default_domain); 40 | PHP_FUNCTION(yp_order); 41 | PHP_FUNCTION(yp_master); 42 | PHP_FUNCTION(yp_match); 43 | PHP_FUNCTION(yp_first); 44 | PHP_FUNCTION(yp_next); 45 | PHP_FUNCTION(yp_all); 46 | PHP_FUNCTION(yp_cat); 47 | PHP_FUNCTION(yp_errno); 48 | PHP_FUNCTION(yp_err_string); 49 | PHP_MINIT_FUNCTION(yp); 50 | PHP_RINIT_FUNCTION(yp); 51 | PHP_MINFO_FUNCTION(yp); 52 | 53 | typedef struct { 54 | int error; 55 | } php_yp_globals; 56 | 57 | typedef struct { 58 | zend_fcall_info fci; 59 | zend_fcall_info_cache fcc; 60 | } php_yp_all_callback; 61 | 62 | 63 | #ifdef ZTS 64 | #define YP(v) TSRMG(yp_globals_id, php_yp_globals *, v) 65 | #else 66 | #define YP(v) (yp_globals.v) 67 | #endif 68 | 69 | #else 70 | 71 | #define yp_module_ptr NULL 72 | 73 | #endif /* HAVE_YP */ 74 | 75 | #define phpext_yp_ptr yp_module_ptr 76 | 77 | #endif /* PHP_YP_H */ 78 | -------------------------------------------------------------------------------- /API-1.0.0: -------------------------------------------------------------------------------- 1 | ". 43 | 44 | THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND 45 | ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 46 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 47 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP 48 | DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 49 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 50 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 51 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 52 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 53 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 54 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 55 | OF THE POSSIBILITY OF SUCH DAMAGE. 56 | 57 | -------------------------------------------------------------------- 58 | 59 | This software consists of voluntary contributions made by many 60 | individuals on behalf of the PHP Group. 61 | 62 | The PHP Group can be contacted via Email at group@php.net. 63 | 64 | For more information on the PHP Group and the PHP project, 65 | please see . 66 | 67 | PHP includes the Zend Engine, freely available at 68 | . 69 | -------------------------------------------------------------------------------- /package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | yp 4 | pecl.php.net 5 | YP/NIS functions 6 | NIS (formerly called Yellow Pages) allows network management 7 | of important administrative files (e.g. the password file). 8 | 9 | 10 | 11 | Gasol Wu 12 | gasolwu 13 | gasolwu@php.net 14 | yes 15 | 16 | 17 | Pierre Joye 18 | pajoye 19 | pajoye@php.net 20 | yes 21 | 22 | 2014-05-12 23 | 24 | 25 | 1.0.1 26 | 1.0.0 27 | 28 | 29 | stable 30 | stable 31 | 32 | PHP 3.01 33 | 1.0.1 release 34 | 35 | - trivial update to fix wrong version dispaly in php_info page [gasolwu] 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 5.3.0 76 | 77 | 78 | 1.4.0b1 79 | 80 | 81 | windows 82 | 83 | 84 | 85 | 86 | yp 87 | 88 | 89 | 90 | 2014-02-22 91 | 92 | 93 | 1.0.0RC1 94 | 1.0.0 95 | 96 | 97 | beta 98 | stable 99 | 100 | PHP 101 | Initial beta release 102 | 103 | - Fix build with modern PHP including PHP 5.3, 5.4 and 5.5 [gasolwu] 104 | - Build testing environment with vagrants [gasolwu] 105 | - Add tests for all public functions [gasolwu] 106 | 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /yp.c: -------------------------------------------------------------------------------- 1 | /* 2 | +----------------------------------------------------------------------+ 3 | | PHP Version 5 | 4 | +----------------------------------------------------------------------+ 5 | | Copyright (c) 1997-2014 The PHP Group | 6 | +----------------------------------------------------------------------+ 7 | | This source file is subject to version 3.01 of the PHP license, | 8 | | that is bundled with this package in the file LICENSE, and is | 9 | | available through the world-wide-web at the following url: | 10 | | http://www.php.net/license/3_01.txt | 11 | | If you did not receive a copy of the PHP license and are unable to | 12 | | obtain it through the world-wide-web, please send a note to | 13 | | license@php.net so we can mail you a copy immediately. | 14 | +----------------------------------------------------------------------+ 15 | | Authors: Stephanie Wehner <_@r4k.net> | 16 | | Fredrik Ohrn | 17 | +----------------------------------------------------------------------+ 18 | */ 19 | /* $Id$ */ 20 | 21 | #ifdef HAVE_CONFIG_H 22 | #include "config.h" 23 | #endif 24 | 25 | #include "php.h" 26 | #include "ext/standard/info.h" 27 | 28 | #if HAVE_YP 29 | 30 | #include "php_yp.h" 31 | 32 | #include 33 | 34 | /* {{{ thread safety stuff */ 35 | 36 | #ifdef ZTS 37 | int yp_globals_id; 38 | #else 39 | PHP_YP_API php_yp_globals yp_globals; 40 | #endif 41 | 42 | /* }}} */ 43 | 44 | ZEND_BEGIN_ARG_INFO_EX(arginfo_yp_none, 0, 0, 0) 45 | ZEND_END_ARG_INFO() 46 | 47 | ZEND_BEGIN_ARG_INFO_EX(arginfo_yp_domain_map, 0, 0, 2) 48 | ZEND_ARG_INFO(0, domain) 49 | ZEND_ARG_INFO(0, map) 50 | ZEND_END_ARG_INFO() 51 | 52 | ZEND_BEGIN_ARG_INFO_EX(arginfo_yp_domain_map_key, 0, 0, 3) 53 | ZEND_ARG_INFO(0, domain) 54 | ZEND_ARG_INFO(0, map) 55 | ZEND_ARG_INFO(0, key) 56 | ZEND_END_ARG_INFO() 57 | 58 | ZEND_BEGIN_ARG_INFO_EX(arginfo_yp_domain_map_cb, 0, 0, 3) 59 | ZEND_ARG_INFO(0, domain) 60 | ZEND_ARG_INFO(0, map) 61 | ZEND_ARG_INFO(0, callback) 62 | ZEND_END_ARG_INFO() 63 | 64 | ZEND_BEGIN_ARG_INFO_EX(arginfo_yp_errorcode, 0, 0, 1) 65 | ZEND_ARG_INFO(0, errorcode) 66 | ZEND_END_ARG_INFO() 67 | 68 | zend_function_entry yp_functions[] = { 69 | PHP_FE(yp_get_default_domain, arginfo_yp_none) 70 | PHP_FE(yp_order, arginfo_yp_domain_map) 71 | PHP_FE(yp_master, arginfo_yp_domain_map) 72 | PHP_FE(yp_match, arginfo_yp_domain_map_key) 73 | PHP_FE(yp_first, arginfo_yp_domain_map) 74 | PHP_FE(yp_next, arginfo_yp_domain_map_key) 75 | PHP_FE(yp_all, arginfo_yp_domain_map_cb) 76 | PHP_FE(yp_cat, arginfo_yp_domain_map) 77 | PHP_FE(yp_errno, arginfo_yp_none) 78 | PHP_FE(yp_err_string, arginfo_yp_errorcode) 79 | #ifdef PHP_FE_END 80 | PHP_FE_END 81 | #else 82 | {NULL, NULL, NULL} 83 | #endif 84 | }; 85 | 86 | zend_module_entry yp_module_entry = { 87 | STANDARD_MODULE_HEADER, 88 | "yp", 89 | yp_functions, 90 | PHP_MINIT(yp), 91 | NULL, 92 | PHP_RINIT(yp), 93 | NULL, 94 | PHP_MINFO(yp), 95 | PHP_YP_VERSION, 96 | STANDARD_MODULE_PROPERTIES 97 | }; 98 | 99 | #ifdef COMPILE_DL_YP 100 | ZEND_GET_MODULE(yp) 101 | #endif 102 | 103 | /* {{{ proto string yp_get_default_domain(void) 104 | Returns the domain or false */ 105 | PHP_FUNCTION(yp_get_default_domain) 106 | { 107 | char *outdomain; 108 | 109 | if (ZEND_NUM_ARGS()) { 110 | WRONG_PARAM_COUNT; 111 | } 112 | 113 | if((YP(error) = yp_get_default_domain(&outdomain))) { 114 | php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", yperr_string (YP(error))); 115 | RETURN_FALSE; 116 | } 117 | RETVAL_STRING(outdomain,1); 118 | } 119 | /* }}} */ 120 | 121 | /* {{{ proto int yp_order(string domain, string map) 122 | Returns the order number or false */ 123 | PHP_FUNCTION(yp_order) 124 | { 125 | char *domain = NULL, *map = NULL; 126 | int domain_len = 0, map_len = 0; 127 | 128 | #if SOLARIS_YP 129 | unsigned long outval = 0; 130 | #else 131 | unsigned int outval = 0; 132 | #endif 133 | 134 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", 135 | &domain, &domain_len, &map, &map_len) == FAILURE) { 136 | return; 137 | } 138 | 139 | if((YP(error) = yp_order(domain, map, &outval))) { 140 | php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", yperr_string (YP(error))); 141 | RETURN_FALSE; 142 | } 143 | 144 | RETVAL_LONG(outval); 145 | } 146 | /* }}} */ 147 | 148 | /* {{{ proto string yp_master(string domain, string map) 149 | Returns the machine name of the master */ 150 | PHP_FUNCTION(yp_master) 151 | { 152 | char *domain = NULL, *map = NULL, *outname = NULL; 153 | int domain_len = 0, map_len = 0; 154 | 155 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", 156 | &domain, &domain_len, &map, &map_len) == FAILURE) { 157 | return; 158 | } 159 | 160 | if((YP(error) = yp_master(domain, map, &outname))) { 161 | php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", yperr_string (YP(error))); 162 | RETURN_FALSE; 163 | } 164 | 165 | RETVAL_STRING(outname, 1); 166 | } 167 | /* }}} */ 168 | 169 | /* {{{ proto string yp_match(string domain, string map, string key) 170 | Returns the matched line or false */ 171 | PHP_FUNCTION(yp_match) 172 | { 173 | char *domain = NULL, *map = NULL, *key = NULL, *outval = NULL; 174 | int domain_len = 0, map_len = 0, key_len = 0, outvallen = 0; 175 | 176 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss", &domain, 177 | &domain_len, &map, &map_len, &key, &key_len) == FAILURE) { 178 | return; 179 | } 180 | 181 | if((YP(error) = yp_match(domain, map, key, key_len, &outval, &outvallen))) { 182 | php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", yperr_string (YP(error))); 183 | RETVAL_FALSE; 184 | } else { 185 | RETVAL_STRINGL(outval, outvallen, 1); 186 | } 187 | 188 | if (outval) { 189 | free(outval); 190 | } 191 | } 192 | /* }}} */ 193 | 194 | /* {{{ proto array yp_first(string domain, string map) 195 | Returns the first key as array with $var[$key] and the the line as the value */ 196 | PHP_FUNCTION(yp_first) 197 | { 198 | char *domain = NULL, *map = NULL, *outkey = NULL, *outval = NULL; 199 | int domain_len = 0, map_len = 0, outkey_len, outval_len; 200 | 201 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", 202 | &domain, &domain_len, &map, &map_len) == FAILURE) { 203 | return; 204 | } 205 | 206 | if((YP(error) = yp_first(domain, map, &outkey, &outkey_len, &outval, &outval_len))) { 207 | php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", yperr_string (YP(error))); 208 | RETVAL_FALSE; 209 | } else { 210 | array_init(return_value); 211 | add_assoc_stringl_ex(return_value, outkey, outkey_len + 1, outval, outval_len, 1); 212 | } 213 | 214 | if (outval) { 215 | free(outval); 216 | } 217 | } 218 | /* }}} */ 219 | 220 | /* {{{ proto array yp_next(string domain, string map, string key) 221 | Returns an array with $var[$key] and the the line as the value */ 222 | PHP_FUNCTION(yp_next) 223 | { 224 | char *domain = NULL, *map = NULL, *key = NULL; 225 | int domain_len = 0, map_len = 0, key_len = 0; 226 | char *outkey = NULL, *outval = NULL; 227 | int outkey_len = 0, outval_len = 0; 228 | 229 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sss", &domain, 230 | &domain_len, &map, &map_len, &key, &key_len) == FAILURE) { 231 | return; 232 | } 233 | 234 | if((YP(error) = yp_next(domain, map, key, key_len, &outkey, &outkey_len, &outval, &outval_len))) { 235 | php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", yperr_string (YP(error))); 236 | RETVAL_FALSE; 237 | } else { 238 | array_init(return_value); 239 | add_assoc_stringl_ex(return_value, outkey, outkey_len + 1, outval, outval_len, 1); 240 | } 241 | 242 | if (outval) { 243 | free(outval); 244 | } 245 | } 246 | /* }}} */ 247 | 248 | /* {{{ php_foreach_all 249 | */ 250 | static int php_foreach_all (int instatus, char *inkey, int inkeylen, char *inval, int invallen, char *indata) 251 | { 252 | int is_stop = 0; 253 | zval *args; 254 | zval *retval; 255 | TSRMLS_FETCH(); 256 | 257 | MAKE_STD_ZVAL(args); 258 | array_init(args); 259 | add_index_long(args, 0, instatus); 260 | add_index_stringl(args, 1, inkey, inkeylen, 1); 261 | add_index_stringl(args, 2, inval, invallen, 1); 262 | 263 | php_yp_all_callback *cb = (php_yp_all_callback *) indata; 264 | zend_fcall_info_args(&cb->fci, args TSRMLS_CC); 265 | zend_fcall_info_call(&cb->fci, &cb->fcc, &retval, args TSRMLS_CC); 266 | zend_fcall_info_args_clear(&cb->fci, 1); 267 | 268 | if (retval) { 269 | is_stop = zval_is_true(retval); 270 | zval_ptr_dtor(&retval); 271 | } 272 | 273 | return is_stop; 274 | } 275 | /* }}} */ 276 | 277 | /* {{{ proto bool yp_all(string domain, string map, string callback) 278 | Traverse the map and call a function on each entry */ 279 | PHP_FUNCTION(yp_all) 280 | { 281 | char *domain = NULL, *map = NULL; 282 | int domain_len = 0, map_len = 0; 283 | php_yp_all_callback *foreach_cb = emalloc(sizeof(php_yp_all_callback)); 284 | 285 | struct ypall_callback callback; 286 | 287 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ssf", 288 | &domain, &domain_len, &map, &map_len, 289 | &foreach_cb->fci, &foreach_cb->fcc) == FAILURE) { 290 | return; 291 | } 292 | 293 | callback.foreach = php_foreach_all; 294 | callback.data = (void *)foreach_cb; 295 | 296 | yp_all(domain, map, &callback); 297 | 298 | efree(foreach_cb); 299 | RETURN_FALSE; 300 | } 301 | /* }}} */ 302 | 303 | /* {{{ php_foreach_cat 304 | */ 305 | static int php_foreach_cat (int instatus, char *inkey, int inkeylen, char *inval, int invallen, char *indata) 306 | { 307 | int err; 308 | 309 | err = ypprot_err (instatus); 310 | 311 | if (!err) 312 | { 313 | if (inkeylen) { 314 | char *key = emalloc(inkeylen+1); 315 | strlcpy(key, inkey, inkeylen+1); 316 | add_assoc_stringl_ex((zval *) indata, key, inkeylen+1, inval, invallen, 1); 317 | efree(key); 318 | } 319 | 320 | return 0; 321 | } 322 | 323 | if (err != YPERR_NOMORE) 324 | { 325 | TSRMLS_FETCH(); 326 | 327 | YP(error) = err; 328 | php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s", yperr_string (err)); 329 | } 330 | 331 | return 0; 332 | } 333 | /* }}} */ 334 | 335 | /* {{{ proto array yp_cat(string domain, string map) 336 | Return an array containing the entire map */ 337 | PHP_FUNCTION(yp_cat) 338 | { 339 | char *domain = NULL, *map = NULL; 340 | int domain_len = 0, map_len = 0; 341 | struct ypall_callback callback; 342 | 343 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", 344 | &domain, &domain_len, &map, &map_len) == FAILURE) { 345 | return; 346 | } 347 | 348 | array_init(return_value); 349 | 350 | callback.foreach = php_foreach_cat; 351 | callback.data = (char *) return_value; 352 | 353 | yp_all(domain, map, &callback); 354 | } 355 | /* }}} */ 356 | 357 | /* {{{ proto int yp_errno() 358 | Returns the error code from the last call or 0 if no error occured */ 359 | PHP_FUNCTION(yp_errno) 360 | { 361 | if((ZEND_NUM_ARGS() != 0)) { 362 | WRONG_PARAM_COUNT; 363 | } 364 | 365 | RETURN_LONG (YP(error)); 366 | } 367 | /* }}} */ 368 | 369 | /* {{{ proto string yp_err_string(int errorcode) 370 | Returns the corresponding error string for the given error code */ 371 | PHP_FUNCTION(yp_err_string) 372 | { 373 | long errcode = 0; 374 | const char *string = NULL; 375 | 376 | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &errcode) == FAILURE) { 377 | return; 378 | } 379 | 380 | if((string = yperr_string(errcode)) == NULL) { 381 | RETURN_FALSE; 382 | } 383 | 384 | RETVAL_STRING(string, 1); 385 | } 386 | /* }}} */ 387 | 388 | /* {{{ PHP_MINIT_FUNCTION 389 | */ 390 | PHP_MINIT_FUNCTION(yp) 391 | { 392 | #ifdef ZTS 393 | ts_allocate_id(&yp_globals_id, sizeof(php_yp_globals), NULL, NULL); 394 | #endif 395 | 396 | REGISTER_LONG_CONSTANT("YPERR_ACCESS", YPERR_ACCESS, CONST_CS | CONST_PERSISTENT); 397 | REGISTER_LONG_CONSTANT("YPERR_BADARGS", YPERR_BADARGS, CONST_CS | CONST_PERSISTENT); 398 | REGISTER_LONG_CONSTANT("YPERR_BADDB", YPERR_BADDB, CONST_CS | CONST_PERSISTENT); 399 | REGISTER_LONG_CONSTANT("YPERR_BUSY", YPERR_BUSY, CONST_CS | CONST_PERSISTENT); 400 | REGISTER_LONG_CONSTANT("YPERR_DOMAIN", YPERR_DOMAIN, CONST_CS | CONST_PERSISTENT); 401 | REGISTER_LONG_CONSTANT("YPERR_KEY", YPERR_KEY, CONST_CS | CONST_PERSISTENT); 402 | REGISTER_LONG_CONSTANT("YPERR_MAP", YPERR_MAP, CONST_CS | CONST_PERSISTENT); 403 | REGISTER_LONG_CONSTANT("YPERR_NODOM", YPERR_NODOM, CONST_CS | CONST_PERSISTENT); 404 | REGISTER_LONG_CONSTANT("YPERR_NOMORE", YPERR_NOMORE, CONST_CS | CONST_PERSISTENT); 405 | REGISTER_LONG_CONSTANT("YPERR_PMAP", YPERR_PMAP, CONST_CS | CONST_PERSISTENT); 406 | REGISTER_LONG_CONSTANT("YPERR_RESRC", YPERR_RESRC, CONST_CS | CONST_PERSISTENT); 407 | REGISTER_LONG_CONSTANT("YPERR_RPC", YPERR_RPC, CONST_CS | CONST_PERSISTENT); 408 | REGISTER_LONG_CONSTANT("YPERR_YPBIND", YPERR_YPBIND, CONST_CS | CONST_PERSISTENT); 409 | REGISTER_LONG_CONSTANT("YPERR_YPERR", YPERR_YPERR, CONST_CS | CONST_PERSISTENT); 410 | REGISTER_LONG_CONSTANT("YPERR_YPSERV", YPERR_YPSERV, CONST_CS | CONST_PERSISTENT); 411 | REGISTER_LONG_CONSTANT("YPERR_VERS", YPERR_VERS, CONST_CS | CONST_PERSISTENT); 412 | 413 | return SUCCESS; 414 | } 415 | /* }}} */ 416 | 417 | PHP_RINIT_FUNCTION(yp) 418 | { 419 | YP(error) = 0; 420 | 421 | return SUCCESS; 422 | } 423 | 424 | PHP_MINFO_FUNCTION(yp) 425 | { 426 | php_info_print_table_start(); 427 | php_info_print_table_header(2, "YP Support", "enabled"); 428 | php_info_print_table_row(2, "Version", PHP_YP_VERSION); 429 | php_info_print_table_end(); 430 | } 431 | #endif /* HAVE_YP */ 432 | 433 | /* 434 | * Local variables: 435 | * tab-width: 4 436 | * c-basic-offset: 4 437 | * End: 438 | * vim600: sw=4 ts=4 fdm=marker 439 | * vim<600: sw=4 ts=4 440 | */ 441 | -------------------------------------------------------------------------------- /tests/data/services: -------------------------------------------------------------------------------- 1 | # Network services, Internet style 2 | # 3 | # Note that it is presently the policy of IANA to assign a single well-known 4 | # port number for both TCP and UDP; hence, officially ports have two entries 5 | # even if the protocol doesn't support UDP operations. 6 | # 7 | # Updated from http://www.iana.org/assignments/port-numbers and other 8 | # sources like http://www.freebsd.org/cgi/cvsweb.cgi/src/etc/services . 9 | # New ports will be added on request if they have been officially assigned 10 | # by IANA and used in the real-world or are needed by a debian package. 11 | # If you need a huge list of used numbers please install the nmap package. 12 | 13 | tcpmux 1/tcp # TCP port service multiplexer 14 | echo 7/tcp 15 | echo 7/udp 16 | discard 9/tcp sink null 17 | discard 9/udp sink null 18 | systat 11/tcp users 19 | daytime 13/tcp 20 | daytime 13/udp 21 | netstat 15/tcp 22 | qotd 17/tcp quote 23 | msp 18/tcp # message send protocol 24 | msp 18/udp 25 | chargen 19/tcp ttytst source 26 | chargen 19/udp ttytst source 27 | ftp-data 20/tcp 28 | ftp 21/tcp 29 | fsp 21/udp fspd 30 | ssh 22/tcp # SSH Remote Login Protocol 31 | ssh 22/udp 32 | telnet 23/tcp 33 | smtp 25/tcp mail 34 | time 37/tcp timserver 35 | time 37/udp timserver 36 | rlp 39/udp resource # resource location 37 | nameserver 42/tcp name # IEN 116 38 | whois 43/tcp nicname 39 | tacacs 49/tcp # Login Host Protocol (TACACS) 40 | tacacs 49/udp 41 | re-mail-ck 50/tcp # Remote Mail Checking Protocol 42 | re-mail-ck 50/udp 43 | domain 53/tcp # Domain Name Server 44 | domain 53/udp 45 | mtp 57/tcp # deprecated 46 | tacacs-ds 65/tcp # TACACS-Database Service 47 | tacacs-ds 65/udp 48 | bootps 67/tcp # BOOTP server 49 | bootps 67/udp 50 | bootpc 68/tcp # BOOTP client 51 | bootpc 68/udp 52 | tftp 69/udp 53 | gopher 70/tcp # Internet Gopher 54 | gopher 70/udp 55 | rje 77/tcp netrjs 56 | finger 79/tcp 57 | http 80/tcp www # WorldWideWeb HTTP 58 | http 80/udp # HyperText Transfer Protocol 59 | link 87/tcp ttylink 60 | kerberos 88/tcp kerberos5 krb5 kerberos-sec # Kerberos v5 61 | kerberos 88/udp kerberos5 krb5 kerberos-sec # Kerberos v5 62 | supdup 95/tcp 63 | hostnames 101/tcp hostname # usually from sri-nic 64 | iso-tsap 102/tcp tsap # part of ISODE 65 | acr-nema 104/tcp dicom # Digital Imag. & Comm. 300 66 | acr-nema 104/udp dicom 67 | csnet-ns 105/tcp cso-ns # also used by CSO name server 68 | csnet-ns 105/udp cso-ns 69 | rtelnet 107/tcp # Remote Telnet 70 | rtelnet 107/udp 71 | pop2 109/tcp postoffice pop-2 # POP version 2 72 | pop2 109/udp pop-2 73 | pop3 110/tcp pop-3 # POP version 3 74 | pop3 110/udp pop-3 75 | sunrpc 111/tcp portmapper # RPC 4.0 portmapper 76 | sunrpc 111/udp portmapper 77 | auth 113/tcp authentication tap ident 78 | sftp 115/tcp 79 | uucp-path 117/tcp 80 | nntp 119/tcp readnews untp # USENET News Transfer Protocol 81 | ntp 123/tcp 82 | ntp 123/udp # Network Time Protocol 83 | pwdgen 129/tcp # PWDGEN service 84 | pwdgen 129/udp 85 | loc-srv 135/tcp epmap # Location Service 86 | loc-srv 135/udp epmap 87 | netbios-ns 137/tcp # NETBIOS Name Service 88 | netbios-ns 137/udp 89 | netbios-dgm 138/tcp # NETBIOS Datagram Service 90 | netbios-dgm 138/udp 91 | netbios-ssn 139/tcp # NETBIOS session service 92 | netbios-ssn 139/udp 93 | imap2 143/tcp imap # Interim Mail Access P 2 and 4 94 | imap2 143/udp imap 95 | snmp 161/tcp # Simple Net Mgmt Protocol 96 | snmp 161/udp 97 | snmp-trap 162/tcp snmptrap # Traps for SNMP 98 | snmp-trap 162/udp snmptrap 99 | cmip-man 163/tcp # ISO mgmt over IP (CMOT) 100 | cmip-man 163/udp 101 | cmip-agent 164/tcp 102 | cmip-agent 164/udp 103 | mailq 174/tcp # Mailer transport queue for Zmailer 104 | mailq 174/udp 105 | xdmcp 177/tcp # X Display Mgr. Control Proto 106 | xdmcp 177/udp 107 | nextstep 178/tcp NeXTStep NextStep # NeXTStep window 108 | nextstep 178/udp NeXTStep NextStep # server 109 | bgp 179/tcp # Border Gateway Protocol 110 | bgp 179/udp 111 | prospero 191/tcp # Cliff Neuman's Prospero 112 | prospero 191/udp 113 | irc 194/tcp # Internet Relay Chat 114 | irc 194/udp 115 | smux 199/tcp # SNMP Unix Multiplexer 116 | smux 199/udp 117 | at-rtmp 201/tcp # AppleTalk routing 118 | at-rtmp 201/udp 119 | at-nbp 202/tcp # AppleTalk name binding 120 | at-nbp 202/udp 121 | at-echo 204/tcp # AppleTalk echo 122 | at-echo 204/udp 123 | at-zis 206/tcp # AppleTalk zone information 124 | at-zis 206/udp 125 | qmtp 209/tcp # Quick Mail Transfer Protocol 126 | qmtp 209/udp 127 | z3950 210/tcp wais # NISO Z39.50 database 128 | z3950 210/udp wais 129 | ipx 213/tcp # IPX 130 | ipx 213/udp 131 | imap3 220/tcp # Interactive Mail Access 132 | imap3 220/udp # Protocol v3 133 | pawserv 345/tcp # Perf Analysis Workbench 134 | pawserv 345/udp 135 | zserv 346/tcp # Zebra server 136 | zserv 346/udp 137 | fatserv 347/tcp # Fatmen Server 138 | fatserv 347/udp 139 | rpc2portmap 369/tcp 140 | rpc2portmap 369/udp # Coda portmapper 141 | codaauth2 370/tcp 142 | codaauth2 370/udp # Coda authentication server 143 | clearcase 371/tcp Clearcase 144 | clearcase 371/udp Clearcase 145 | ulistserv 372/tcp # UNIX Listserv 146 | ulistserv 372/udp 147 | ldap 389/tcp # Lightweight Directory Access Protocol 148 | ldap 389/udp 149 | imsp 406/tcp # Interactive Mail Support Protocol 150 | imsp 406/udp 151 | svrloc 427/tcp # Server Location 152 | svrloc 427/udp 153 | https 443/tcp # http protocol over TLS/SSL 154 | https 443/udp 155 | snpp 444/tcp # Simple Network Paging Protocol 156 | snpp 444/udp 157 | microsoft-ds 445/tcp # Microsoft Naked CIFS 158 | microsoft-ds 445/udp 159 | kpasswd 464/tcp 160 | kpasswd 464/udp 161 | saft 487/tcp # Simple Asynchronous File Transfer 162 | saft 487/udp 163 | isakmp 500/tcp # IPsec - Internet Security Association 164 | isakmp 500/udp # and Key Management Protocol 165 | rtsp 554/tcp # Real Time Stream Control Protocol 166 | rtsp 554/udp 167 | nqs 607/tcp # Network Queuing system 168 | nqs 607/udp 169 | npmp-local 610/tcp dqs313_qmaster # npmp-local / DQS 170 | npmp-local 610/udp dqs313_qmaster 171 | npmp-gui 611/tcp dqs313_execd # npmp-gui / DQS 172 | npmp-gui 611/udp dqs313_execd 173 | hmmp-ind 612/tcp dqs313_intercell # HMMP Indication / DQS 174 | hmmp-ind 612/udp dqs313_intercell 175 | qmqp 628/tcp 176 | qmqp 628/udp 177 | ipp 631/tcp # Internet Printing Protocol 178 | ipp 631/udp 179 | # 180 | # UNIX specific services 181 | # 182 | exec 512/tcp 183 | biff 512/udp comsat 184 | login 513/tcp 185 | who 513/udp whod 186 | shell 514/tcp cmd # no passwords used 187 | syslog 514/udp 188 | printer 515/tcp spooler # line printer spooler 189 | talk 517/udp 190 | ntalk 518/udp 191 | route 520/udp router routed # RIP 192 | timed 525/udp timeserver 193 | tempo 526/tcp newdate 194 | courier 530/tcp rpc 195 | conference 531/tcp chat 196 | netnews 532/tcp readnews 197 | netwall 533/udp # for emergency broadcasts 198 | gdomap 538/tcp # GNUstep distributed objects 199 | gdomap 538/udp 200 | uucp 540/tcp uucpd # uucp daemon 201 | klogin 543/tcp # Kerberized `rlogin' (v5) 202 | kshell 544/tcp krcmd # Kerberized `rsh' (v5) 203 | dhcpv6-client 546/tcp 204 | dhcpv6-client 546/udp 205 | dhcpv6-server 547/tcp 206 | dhcpv6-server 547/udp 207 | afpovertcp 548/tcp # AFP over TCP 208 | afpovertcp 548/udp 209 | idfp 549/tcp 210 | idfp 549/udp 211 | remotefs 556/tcp rfs_server rfs # Brunhoff remote filesystem 212 | nntps 563/tcp snntp # NNTP over SSL 213 | nntps 563/udp snntp 214 | submission 587/tcp # Submission [RFC4409] 215 | submission 587/udp 216 | ldaps 636/tcp # LDAP over SSL 217 | ldaps 636/udp 218 | tinc 655/tcp # tinc control port 219 | tinc 655/udp 220 | silc 706/tcp 221 | silc 706/udp 222 | kerberos-adm 749/tcp # Kerberos `kadmin' (v5) 223 | # 224 | webster 765/tcp # Network dictionary 225 | webster 765/udp 226 | rsync 873/tcp 227 | rsync 873/udp 228 | ftps-data 989/tcp # FTP over SSL (data) 229 | ftps 990/tcp 230 | telnets 992/tcp # Telnet over SSL 231 | telnets 992/udp 232 | imaps 993/tcp # IMAP over SSL 233 | imaps 993/udp 234 | ircs 994/tcp # IRC over SSL 235 | ircs 994/udp 236 | pop3s 995/tcp # POP-3 over SSL 237 | pop3s 995/udp 238 | # 239 | # From ``Assigned Numbers'': 240 | # 241 | #> The Registered Ports are not controlled by the IANA and on most systems 242 | #> can be used by ordinary user processes or programs executed by ordinary 243 | #> users. 244 | # 245 | #> Ports are used in the TCP [45,106] to name the ends of logical 246 | #> connections which carry long term conversations. For the purpose of 247 | #> providing services to unknown callers, a service contact port is 248 | #> defined. This list specifies the port used by the server process as its 249 | #> contact port. While the IANA can not control uses of these ports it 250 | #> does register or list uses of these ports as a convienence to the 251 | #> community. 252 | # 253 | socks 1080/tcp # socks proxy server 254 | socks 1080/udp 255 | proofd 1093/tcp 256 | proofd 1093/udp 257 | rootd 1094/tcp 258 | rootd 1094/udp 259 | openvpn 1194/tcp 260 | openvpn 1194/udp 261 | rmiregistry 1099/tcp # Java RMI Registry 262 | rmiregistry 1099/udp 263 | kazaa 1214/tcp 264 | kazaa 1214/udp 265 | nessus 1241/tcp # Nessus vulnerability 266 | nessus 1241/udp # assessment scanner 267 | lotusnote 1352/tcp lotusnotes # Lotus Note 268 | lotusnote 1352/udp lotusnotes 269 | ms-sql-s 1433/tcp # Microsoft SQL Server 270 | ms-sql-s 1433/udp 271 | ms-sql-m 1434/tcp # Microsoft SQL Monitor 272 | ms-sql-m 1434/udp 273 | ingreslock 1524/tcp 274 | ingreslock 1524/udp 275 | prospero-np 1525/tcp # Prospero non-privileged 276 | prospero-np 1525/udp 277 | datametrics 1645/tcp old-radius 278 | datametrics 1645/udp old-radius 279 | sa-msg-port 1646/tcp old-radacct 280 | sa-msg-port 1646/udp old-radacct 281 | kermit 1649/tcp 282 | kermit 1649/udp 283 | groupwise 1677/tcp 284 | groupwise 1677/udp 285 | l2f 1701/tcp l2tp 286 | l2f 1701/udp l2tp 287 | radius 1812/tcp 288 | radius 1812/udp 289 | radius-acct 1813/tcp radacct # Radius Accounting 290 | radius-acct 1813/udp radacct 291 | msnp 1863/tcp # MSN Messenger 292 | msnp 1863/udp 293 | unix-status 1957/tcp # remstats unix-status server 294 | log-server 1958/tcp # remstats log server 295 | remoteping 1959/tcp # remstats remoteping server 296 | cisco-sccp 2000/tcp # Cisco SCCP 297 | cisco-sccp 2000/udp 298 | search 2010/tcp ndtp 299 | pipe-server 2010/tcp pipe_server 300 | nfs 2049/tcp # Network File System 301 | nfs 2049/udp # Network File System 302 | gnunet 2086/tcp 303 | gnunet 2086/udp 304 | rtcm-sc104 2101/tcp # RTCM SC-104 IANA 1/29/99 305 | rtcm-sc104 2101/udp 306 | gsigatekeeper 2119/tcp 307 | gsigatekeeper 2119/udp 308 | gris 2135/tcp # Grid Resource Information Server 309 | gris 2135/udp 310 | cvspserver 2401/tcp # CVS client/server operations 311 | cvspserver 2401/udp 312 | venus 2430/tcp # codacon port 313 | venus 2430/udp # Venus callback/wbc interface 314 | venus-se 2431/tcp # tcp side effects 315 | venus-se 2431/udp # udp sftp side effect 316 | codasrv 2432/tcp # not used 317 | codasrv 2432/udp # server port 318 | codasrv-se 2433/tcp # tcp side effects 319 | codasrv-se 2433/udp # udp sftp side effect 320 | mon 2583/tcp # MON traps 321 | mon 2583/udp 322 | dict 2628/tcp # Dictionary server 323 | dict 2628/udp 324 | f5-globalsite 2792/tcp 325 | f5-globalsite 2792/udp 326 | gsiftp 2811/tcp 327 | gsiftp 2811/udp 328 | gpsd 2947/tcp 329 | gpsd 2947/udp 330 | gds-db 3050/tcp gds_db # InterBase server 331 | gds-db 3050/udp gds_db 332 | icpv2 3130/tcp icp # Internet Cache Protocol 333 | icpv2 3130/udp icp 334 | mysql 3306/tcp 335 | mysql 3306/udp 336 | nut 3493/tcp # Network UPS Tools 337 | nut 3493/udp 338 | distcc 3632/tcp # distributed compiler 339 | distcc 3632/udp 340 | daap 3689/tcp # Digital Audio Access Protocol 341 | daap 3689/udp 342 | svn 3690/tcp subversion # Subversion protocol 343 | svn 3690/udp subversion 344 | suucp 4031/tcp # UUCP over SSL 345 | suucp 4031/udp 346 | sysrqd 4094/tcp # sysrq daemon 347 | sysrqd 4094/udp 348 | sieve 4190/tcp # ManageSieve Protocol 349 | epmd 4369/tcp # Erlang Port Mapper Daemon 350 | epmd 4369/udp 351 | remctl 4373/tcp # Remote Authenticated Command Service 352 | remctl 4373/udp 353 | f5-iquery 4353/tcp # F5 iQuery 354 | f5-iquery 4353/udp 355 | iax 4569/tcp # Inter-Asterisk eXchange 356 | iax 4569/udp 357 | mtn 4691/tcp # monotone Netsync Protocol 358 | mtn 4691/udp 359 | radmin-port 4899/tcp # RAdmin Port 360 | radmin-port 4899/udp 361 | rfe 5002/udp # Radio Free Ethernet 362 | rfe 5002/tcp 363 | mmcc 5050/tcp # multimedia conference control tool (Yahoo IM) 364 | mmcc 5050/udp 365 | sip 5060/tcp # Session Initiation Protocol 366 | sip 5060/udp 367 | sip-tls 5061/tcp 368 | sip-tls 5061/udp 369 | aol 5190/tcp # AIM 370 | aol 5190/udp 371 | xmpp-client 5222/tcp jabber-client # Jabber Client Connection 372 | xmpp-client 5222/udp jabber-client 373 | xmpp-server 5269/tcp jabber-server # Jabber Server Connection 374 | xmpp-server 5269/udp jabber-server 375 | cfengine 5308/tcp 376 | cfengine 5308/udp 377 | mdns 5353/tcp # Multicast DNS 378 | mdns 5353/udp 379 | postgresql 5432/tcp postgres # PostgreSQL Database 380 | postgresql 5432/udp postgres 381 | freeciv 5556/tcp rptp # Freeciv gameplay 382 | freeciv 5556/udp 383 | amqp 5672/tcp 384 | amqp 5672/udp 385 | amqp 5672/sctp 386 | ggz 5688/tcp # GGZ Gaming Zone 387 | ggz 5688/udp 388 | x11 6000/tcp x11-0 # X Window System 389 | x11 6000/udp x11-0 390 | x11-1 6001/tcp 391 | x11-1 6001/udp 392 | x11-2 6002/tcp 393 | x11-2 6002/udp 394 | x11-3 6003/tcp 395 | x11-3 6003/udp 396 | x11-4 6004/tcp 397 | x11-4 6004/udp 398 | x11-5 6005/tcp 399 | x11-5 6005/udp 400 | x11-6 6006/tcp 401 | x11-6 6006/udp 402 | x11-7 6007/tcp 403 | x11-7 6007/udp 404 | gnutella-svc 6346/tcp # gnutella 405 | gnutella-svc 6346/udp 406 | gnutella-rtr 6347/tcp # gnutella 407 | gnutella-rtr 6347/udp 408 | sge-qmaster 6444/tcp sge_qmaster # Grid Engine Qmaster Service 409 | sge-qmaster 6444/udp sge_qmaster 410 | sge-execd 6445/tcp sge_execd # Grid Engine Execution Service 411 | sge-execd 6445/udp sge_execd 412 | mysql-proxy 6446/tcp # MySQL Proxy 413 | mysql-proxy 6446/udp 414 | afs3-fileserver 7000/tcp bbs # file server itself 415 | afs3-fileserver 7000/udp bbs 416 | afs3-callback 7001/tcp # callbacks to cache managers 417 | afs3-callback 7001/udp 418 | afs3-prserver 7002/tcp # users & groups database 419 | afs3-prserver 7002/udp 420 | afs3-vlserver 7003/tcp # volume location database 421 | afs3-vlserver 7003/udp 422 | afs3-kaserver 7004/tcp # AFS/Kerberos authentication 423 | afs3-kaserver 7004/udp 424 | afs3-volser 7005/tcp # volume managment server 425 | afs3-volser 7005/udp 426 | afs3-errors 7006/tcp # error interpretation service 427 | afs3-errors 7006/udp 428 | afs3-bos 7007/tcp # basic overseer process 429 | afs3-bos 7007/udp 430 | afs3-update 7008/tcp # server-to-server updater 431 | afs3-update 7008/udp 432 | afs3-rmtsys 7009/tcp # remote cache manager service 433 | afs3-rmtsys 7009/udp 434 | font-service 7100/tcp xfs # X Font Service 435 | font-service 7100/udp xfs 436 | http-alt 8080/tcp webcache # WWW caching service 437 | http-alt 8080/udp 438 | bacula-dir 9101/tcp # Bacula Director 439 | bacula-dir 9101/udp 440 | bacula-fd 9102/tcp # Bacula File Daemon 441 | bacula-fd 9102/udp 442 | bacula-sd 9103/tcp # Bacula Storage Daemon 443 | bacula-sd 9103/udp 444 | xmms2 9667/tcp # Cross-platform Music Multiplexing System 445 | xmms2 9667/udp 446 | nbd 10809/tcp # Linux Network Block Device 447 | zabbix-agent 10050/tcp # Zabbix Agent 448 | zabbix-agent 10050/udp 449 | zabbix-trapper 10051/tcp # Zabbix Trapper 450 | zabbix-trapper 10051/udp 451 | amanda 10080/tcp # amanda backup services 452 | amanda 10080/udp 453 | hkp 11371/tcp # OpenPGP HTTP Keyserver 454 | hkp 11371/udp 455 | bprd 13720/tcp # VERITAS NetBackup 456 | bprd 13720/udp 457 | bpdbm 13721/tcp # VERITAS NetBackup 458 | bpdbm 13721/udp 459 | bpjava-msvc 13722/tcp # BP Java MSVC Protocol 460 | bpjava-msvc 13722/udp 461 | vnetd 13724/tcp # Veritas Network Utility 462 | vnetd 13724/udp 463 | bpcd 13782/tcp # VERITAS NetBackup 464 | bpcd 13782/udp 465 | vopied 13783/tcp # VERITAS NetBackup 466 | vopied 13783/udp 467 | dcap 22125/tcp # dCache Access Protocol 468 | gsidcap 22128/tcp # GSI dCache Access Protocol 469 | wnn6 22273/tcp # wnn6 470 | wnn6 22273/udp 471 | 472 | # 473 | # Datagram Delivery Protocol services 474 | # 475 | rtmp 1/ddp # Routing Table Maintenance Protocol 476 | nbp 2/ddp # Name Binding Protocol 477 | echo 4/ddp # AppleTalk Echo Protocol 478 | zip 6/ddp # Zone Information Protocol 479 | 480 | #========================================================================= 481 | # The remaining port numbers are not as allocated by IANA. 482 | #========================================================================= 483 | 484 | # Kerberos (Project Athena/MIT) services 485 | # Note that these are for Kerberos v4, and are unofficial. Sites running 486 | # v4 should uncomment these and comment out the v5 entries above. 487 | # 488 | kerberos4 750/udp kerberos-iv kdc # Kerberos (server) 489 | kerberos4 750/tcp kerberos-iv kdc 490 | kerberos-master 751/udp kerberos_master # Kerberos authentication 491 | kerberos-master 751/tcp 492 | passwd-server 752/udp passwd_server # Kerberos passwd server 493 | krb-prop 754/tcp krb_prop krb5_prop hprop # Kerberos slave propagation 494 | krbupdate 760/tcp kreg # Kerberos registration 495 | swat 901/tcp # swat 496 | kpop 1109/tcp # Pop with Kerberos 497 | knetd 2053/tcp # Kerberos de-multiplexor 498 | zephyr-srv 2102/udp # Zephyr server 499 | zephyr-clt 2103/udp # Zephyr serv-hm connection 500 | zephyr-hm 2104/udp # Zephyr hostmanager 501 | eklogin 2105/tcp # Kerberos encrypted rlogin 502 | # Hmmm. Are we using Kv4 or Kv5 now? Worrying. 503 | # The following is probably Kerberos v5 --- ajt@debian.org (11/02/2000) 504 | kx 2111/tcp # X over Kerberos 505 | iprop 2121/tcp # incremental propagation 506 | # 507 | # Unofficial but necessary (for NetBSD) services 508 | # 509 | supfilesrv 871/tcp # SUP server 510 | supfiledbg 1127/tcp # SUP debugging 511 | 512 | # 513 | # Services added for the Debian GNU/Linux distribution 514 | # 515 | linuxconf 98/tcp # LinuxConf 516 | poppassd 106/tcp # Eudora 517 | poppassd 106/udp 518 | ssmtp 465/tcp smtps # SMTP over SSL 519 | moira-db 775/tcp moira_db # Moira database 520 | moira-update 777/tcp moira_update # Moira update protocol 521 | moira-ureg 779/udp moira_ureg # Moira user registration 522 | spamd 783/tcp # spamassassin daemon 523 | omirr 808/tcp omirrd # online mirror 524 | omirr 808/udp omirrd 525 | customs 1001/tcp # pmake customs server 526 | customs 1001/udp 527 | skkserv 1178/tcp # skk jisho server port 528 | predict 1210/udp # predict -- satellite tracking 529 | rmtcfg 1236/tcp # Gracilis Packeten remote config server 530 | wipld 1300/tcp # Wipl network monitor 531 | xtel 1313/tcp # french minitel 532 | xtelw 1314/tcp # french minitel 533 | support 1529/tcp # GNATS 534 | cfinger 2003/tcp # GNU Finger 535 | frox 2121/tcp # frox: caching ftp proxy 536 | ninstall 2150/tcp # ninstall service 537 | ninstall 2150/udp 538 | zebrasrv 2600/tcp # zebra service 539 | zebra 2601/tcp # zebra vty 540 | ripd 2602/tcp # ripd vty (zebra) 541 | ripngd 2603/tcp # ripngd vty (zebra) 542 | ospfd 2604/tcp # ospfd vty (zebra) 543 | bgpd 2605/tcp # bgpd vty (zebra) 544 | ospf6d 2606/tcp # ospf6d vty (zebra) 545 | ospfapi 2607/tcp # OSPF-API 546 | isisd 2608/tcp # ISISd vty (zebra) 547 | afbackup 2988/tcp # Afbackup system 548 | afbackup 2988/udp 549 | afmbackup 2989/tcp # Afmbackup system 550 | afmbackup 2989/udp 551 | xtell 4224/tcp # xtell server 552 | fax 4557/tcp # FAX transmission service (old) 553 | hylafax 4559/tcp # HylaFAX client-server protocol (new) 554 | distmp3 4600/tcp # distmp3host daemon 555 | munin 4949/tcp lrrd # Munin 556 | enbd-cstatd 5051/tcp # ENBD client statd 557 | enbd-sstatd 5052/tcp # ENBD server statd 558 | pcrd 5151/tcp # PCR-1000 Daemon 559 | noclog 5354/tcp # noclogd with TCP (nocol) 560 | noclog 5354/udp # noclogd with UDP (nocol) 561 | hostmon 5355/tcp # hostmon uses TCP (nocol) 562 | hostmon 5355/udp # hostmon uses UDP (nocol) 563 | rplay 5555/udp # RPlay audio service 564 | nrpe 5666/tcp # Nagios Remote Plugin Executor 565 | nsca 5667/tcp # Nagios Agent - NSCA 566 | mrtd 5674/tcp # MRT Routing Daemon 567 | bgpsim 5675/tcp # MRT Routing Simulator 568 | canna 5680/tcp # cannaserver 569 | sane-port 6566/tcp sane saned # SANE network scanner daemon 570 | ircd 6667/tcp # Internet Relay Chat 571 | zope-ftp 8021/tcp # zope management by ftp 572 | tproxy 8081/tcp # Transparent Proxy 573 | omniorb 8088/tcp # OmniORB 574 | omniorb 8088/udp 575 | clc-build-daemon 8990/tcp # Common lisp build daemon 576 | xinetd 9098/tcp 577 | mandelspawn 9359/udp mandelbrot # network mandelbrot 578 | git 9418/tcp # Git Version Control System 579 | zope 9673/tcp # zope server 580 | webmin 10000/tcp 581 | kamanda 10081/tcp # amanda backup services (Kerberos) 582 | kamanda 10081/udp 583 | amandaidx 10082/tcp # amanda backup services 584 | amidxtape 10083/tcp # amanda backup services 585 | smsqp 11201/tcp # Alamin SMS gateway 586 | smsqp 11201/udp 587 | xpilot 15345/tcp # XPilot Contact Port 588 | xpilot 15345/udp 589 | sgi-cmsd 17001/udp # Cluster membership services daemon 590 | sgi-crsd 17002/udp 591 | sgi-gcd 17003/udp # SGI Group membership daemon 592 | sgi-cad 17004/tcp # Cluster Admin daemon 593 | isdnlog 20011/tcp # isdn logging system 594 | isdnlog 20011/udp 595 | vboxd 20012/tcp # voice box system 596 | vboxd 20012/udp 597 | binkp 24554/tcp # binkp fidonet protocol 598 | asp 27374/tcp # Address Search Protocol 599 | asp 27374/udp 600 | csync2 30865/tcp # cluster synchronization tool 601 | dircproxy 57000/tcp # Detachable IRC Proxy 602 | tfido 60177/tcp # fidonet EMSI over telnet 603 | fido 60179/tcp # fidonet EMSI over TCP 604 | 605 | # Local services 606 | --------------------------------------------------------------------------------