The following code runs OK with self-compiled original php-5.1.2 but fails with error "fwrite failed" message using gentoo-emerged stable php-5.1.2 <?php $h=fopen("ftp://user:password@server/tmp/test", "w"); if(!$h) die ("fopen failed"); if(!fwrite($h, "asd")) die ("fwrite failed"); fclose($h); ?> Portage 2.0.54 (default-linux/x86/2005.0, gcc-3.4.5, glibc-2.3.5-r2, 2.6.14-suspend2-r7 i686) ================================================================= System uname: 2.6.14-suspend2-r7 i686 Intel(R) Pentium(R) 4 CPU 2.80GHz Gentoo Base System version 1.6.14 dev-lang/python: 2.4.2 sys-apps/sandbox: 1.2.12 sys-devel/autoconf: 2.13, 2.59-r7 sys-devel/automake: 1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r1 sys-devel/binutils: 2.16.1 sys-devel/libtool: 1.5.22 virtual/os-headers: 2.6.11-r2 ACCEPT_KEYWORDS="x86" AUTOCLEAN="yes" CBUILD="i686-pc-linux-gnu" CFLAGS="-mtune=pentium4 -march=pentium3 -O3 -pipe -fomit-frame-pointer" CHOST="i686-pc-linux-gnu" CONFIG_PROTECT="/etc /usr/kde/2/share/config /usr/kde/3.4/env /usr/kde/3.4/share/config /usr/kde/3.4/shutdown /usr/kde/3/share/config /usr/lib/X11/xkb /usr/share/config /var/qmail/control" CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d" CXXFLAGS="-O2 -mcpu=i686 -pipe" DISTDIR="/usr/portage/distfiles" FEATURES="autoconfig distlocks sandbox sfperms strict" GENTOO_MIRRORS="http://gentoo.mirrors.pair.com/ http://mirror.tucdemonic.org/gentoo/ http://mirror.clarkson.edu/pub/distributions/gentoo/ http://mirrors.acm.cs.rpi.edu/gentoo/ ftp://ftp.ndlug.nd.edu/pub/gentoo/" LANG="ru_RU.cp1251" LINGUAS="" MAKEOPTS="-j4" PKGDIR="/usr/portage/packages" PORTAGE_TMPDIR="/var/tmp" PORTDIR="/usr/portage" PORTDIR_OVERLAY="/mnt/router/usr/local/portage" SYNC="rsync://rsync.gentoo.org/gentoo-portage" USE="x86 X alsa apm arts asf audiofile avi bcmath berkdb bitmap-fonts bzip2 calendar cdparanoia cdr cjk cli crypt ctype cups curl curlwrappers cvs dba dri dts dvd dvdr dvdread eds emboss encode esd evolution exif expat fam ffmpeg flac foomaticdb fortran ftp gd gdbm gif gphoto2 gpm gtk2 gtkhtml i8x0 iconv idn imagemagick imap imlib ipv6 java jpeg junit kde kerberos lcms ldap libg++ libwww mad matroska mhash mikmod mmx mmxext mng mp3 mpeg mplayer mysql ncurses nis nls nptl nsplugin ogg oggvorbis opengl openssl oracle oss pam pcntl pcre pdf pdflib pdo pear perl php png posix python qt quicktime rdesktop readline real samba session slang soap sockets spell sse sse2 ssl subversion svga sysfs sysvipc tcpd tiff truetype truetype-fonts type1-fonts udev unicode usb v4l v4l2 vcd vorbis wifi win32codecs xine xml xml2 xmlrpc xpm xv xvid xvmc zeroconf zip zlib userland_GNU kernel_linux elibc_glibc" Unset: ASFLAGS, CTARGET, LC_ALL, LDFLAGS
In Gentoo we set the allow_url_fopen setting in php.ini to Off by default, for security reasons, I think that is what's causing the problem you're experiencing, try changing that setting to On and reopen the bug if the problem persists. Best regards, CHTEKK.
Please don't expect all users are idiots. Just try to reproduce the bug first. The setting in php.ini is allow_url_fopen = On The error message is "fopen(): URL file-access is disabled in the server configuration" if the setting is off.
FTP upload worked fine with emerged php-4.4.2.ebuild, the same code fragment fails with emerged php-5.0.5-r5.ebuild. "strace php ftp.php" shows that the problem happen because 0 timeout is passed to poll syscall on attempt to read ftp server responce.
You say it works correctly with a self-compiled 5.1.2, but not on an emerged dev-lang/php-5.1.2 ? Could you please post the exact configure-switches you used to compile your self-compiled PHP ? I'd think this is an upstream PHP bug, but I didn't notice any particular fixes applied for this or bugs opened about it, and I can reproduce this with both dev-lang/php-5.1.2 and dev-lang/php-5.1.3_rc1... But otoh you say it works on a self-compiled PHP, so this really is strange, please give more informations about how you created your self-compiled PHP and on how you emerged dev-lang/php (exact USE flags as shown in emerge -pv dev-lang/php). Best regards, CHTEKK.
I did not specify any configure options to self-compiled php. Just cd ~/php-5.1.2 ./configure make sapi/cli/php ~/ftp.php The USE flags are # emerge -pv dev-lang/php These are the packages that I would merge, in order: Calculating dependencies ...done! [ebuild R ] dev-lang/php-5.1.2 -adabas -apache -apache2 +bcmath +berkdb -birdstep +bzip2 +calendar -cdb -cgi +cjk +cli +crypt +ctype +curl +curlwrappers -db2 -dbase -dbmaker -debug -discard-path -doc -empress -empress-bcs -esoob +exif -fastbuild -fdftk -filepro -firebird -flatfile -force-cgi-redirect -frontbase +ftp +gd -gd-external +gdbm -gmp -hardenedphp -hash -hyperwave-api +iconv +imap -informix -inifile -interbase -iodbc +ipv6 -java-external +kerberos +ldap -libedit -mcve -memlimit +mhash -ming -msql -mssql +mysql -mysqli +ncurses +nls -oci8 -oci8-instant-client -odbc +pcntl +pcre +pdo -pdo-external -pic +posix -postgres -qdbm +readline -recode -reflection -sapdb -sasl +session -sharedext -sharedmem -simplexml -snmp +soap +sockets -solid +spell -spl -sqlite +ssl -sybase -sybase-ct +sysvipc -threads -tidy -tokenizer +truetype -vm-goto -vm-switch -wddx +xml -xmlreader +xmlrpc -xmlwriter +xpm -xsl -yaz +zip +zlib 0 kB It would be nice to know which USE flag breakes ftp upload capability, I have multiple php-5.1.2 emerged installations on several boxes (the USE flags could be different a bit), but all installations have this ftp upload problem. The only I know, "sharedext" USE flag do NOT affect the misbehavior, the problem exists in both cli and apache2 module php.
Just reemerged php 5.1.2 with USE="-ftp". The same problem. Is there any way to NOT apply gentoo patches to a package?
You're right, it's an upstream PHP bug. The problem is in curl wrappers. Disabled "curlwrappers" USE flag fixed the problem.
Ok, good to hear that. Is a bug already opened on bugs.php.net about this? (Couldn't find anything relevant at a quick glance) If not, could you open it and post the link here so we may track it, eventually help, and then include the patch in our PHP packages. Thanks and best regards, CHTEKK.
http://bugs.php.net/36882