php-general Digest 27 Sep 2010 19:25:44 -0000 Issue 6962

Topics (messages 308323 through 308332):

PHP DNS resolving in chroot-ed environment
        308323 by: Georgi Hristozov
        308324 by: Per Jessen

Re: if/elseif being treated as if/if
        308325 by: Ford, Mike
        308328 by: tedd

Re: Heredocs, print_r() and newline "\n" and fnmatch() -curious failures ...
        308326 by: YAD(YetAnotherDavid)
        308327 by: Peter Lind

Domain Controller Discovery in PHP
        308329 by: Robert Cummings
        308330 by: Jason
        308331 by: Robert Cummings

Php Newsletter script
        308332 by: David Mehler

Administrivia:

To subscribe to the digest, e-mail:
        [email protected]

To unsubscribe from the digest, e-mail:
        [email protected]

To post to the list, e-mail:
        [email protected]


----------------------------------------------------------------------
--- Begin Message ---
Hello,

I'm running a Gentoo-hardened box with PHP 5.2.14-pl0-gentoo (Suhosin
included) and Apache 2.2.16. mod_php is running in a chroot, using
mpm_peruser. Everything works OK, except the PHP DNS resolving, which I
need to access HTTP resources. It fails with both the curl and http
extensions.

With some stracing of the Apache child processes I found that PHP is
trying to access the following files: hosts, nsswitch.conf, resolv.conf
and the libnss libraries. I've copied them to the chroot, but the
resolving still fails. strace showed failed accesses to /dev/urandom
and /dev/log, but mounting /dev in the chroot didn't help.

My php.ini can be found at [1]. I'm setting the following additional
flags in the vhost configuration:
engine on
open_basedir "/htdocs:/sessions:/tmp"
session.save_path "/sessions"
upload_tmp_dir "/tmp"

Does anybody run similar chroot-ed PHP? Any help will be appreciated!
Thanks in advance!

[1] http://forkbomb.nl/temp/php.ini

Attachment: signature.asc
Description: PGP signature


--- End Message ---
--- Begin Message ---
Georgi Hristozov wrote:

> Hello,
> 
> I'm running a Gentoo-hardened box with PHP 5.2.14-pl0-gentoo (Suhosin
> included) and Apache 2.2.16. mod_php is running in a chroot, using
> mpm_peruser. Everything works OK, except the PHP DNS resolving, which
> I need to access HTTP resources. It fails with both the curl and http
> extensions.
> 
> With some stracing of the Apache child processes I found that PHP is
> trying to access the following files: hosts, nsswitch.conf,
> resolv.conf and the libnss libraries. 

Just being pedantic: not actually PHP, but the resolver. 

> I've copied them to the chroot, but the resolving still fails. strace
> showed failed accesses to /dev/urandom and /dev/log, but mounting /dev
> in the chroot didn't help.

What does your strace show when you have mounted /dev in your chroot
(with -o bind) ?



-- 
Per Jessen, Zürich (10.1°C)


--- End Message ---
--- Begin Message ---
> -----Original Message-----
> From: tedd [mailto:[email protected]]
> Sent: 25 September 2010 16:02

 
> One can make the argument that the ELSE IF statement first surfaced
> circa 1977 in FORTRAN 77 and the CASE statement came later in
> FORTRAN
> 90 circa 1991.

Being a fully-fledged member of the pedants' society, I can't let that go 
without comment.

Those dates only hold if you stick to FORTRAN. Algol-68 had if-elif-else-fi, 
and I don't believe it was a pioneer in the structure even then (although the 
syntax may have been novel). It also had a case-esac structure. I'd say both 
elseif and case/switch developed in other languages and were adopted into 
FORTRAN long after they were established as bona fide programming constructs.

Cheers!

Mike

 -- 
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,  
Leeds Metropolitan University, C507 City Campus, 
Woodhouse Lane, LEEDS,  LS1 3HE,  United Kingdom 
Email: [email protected] 
Tel: +44 113 812 4730





To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

--- End Message ---
--- Begin Message ---
At 11:48 AM +0100 9/27/10, Ford, Mike wrote:
 > -----Original Message-----
 From: tedd [mailto:[email protected]]
 Sent: 25 September 2010 16:02


 One can make the argument that the ELSE IF statement first surfaced
 circa 1977 in FORTRAN 77 and the CASE statement came later in
 FORTRAN
 90 circa 1991.

Being a fully-fledged member of the pedants' society, I can't let that go without comment.

Those dates only hold if you stick to FORTRAN. Algol-68 had if-elif-else-fi, and I don't believe it was a pioneer in the structure even then (although the syntax may have been novel). It also had a case-esac structure. I'd say both elseif and case/switch developed in other languages and were adopted into FORTRAN long after they were established as bona fide programming constructs.

Cheers!

Mike

Mike:

And I can't let your statement go without saying that my statement was taken out of context. For example, following the quote you provided was:

"But I know I was using computed GOTOs and GOSUBs long before then."

Which puts forth a situation that you actually support in your rebuttal. In short, you are supporting my argument.

Additionally, I said that "One can make the argument...", which was not the argument that I was making (nor you). If you disagree with what I am disagreeing, then we are in agreement.

So, we are in agreement that constructs found in other languages preceded those finally adopted into FORTRAN.

The main point of my post (not supported by anything other than my logic) was that the CASE construct was more likely derived from the computed GOTO rather than from the ELSEIF construct.

Do you agree with that?

Cheers,

tedd

--
-------
http://sperling.com/

--- End Message ---
--- Begin Message ---
Peter Lind wrote:
On 23 September 2010 21:47, YAD(YetAnotherDavid) <[email protected]> wrote:
This code is 95% cut and paste from the PHP manual examples -
the Types/Strings/Heredocs section and the Filesystem/fnmatch pages.
There are actually two questions here - I have combined the code into one
 ...

Question 1 : how to get the newline functioning ....? even print_r() output
is not 'newlined' as it should be. Also note the \n is missing between the "
" in the output text of the second test!


Are you outputting to browser or to command line? Browsers have a
habit of ignoring whitespaces, reducing them to one whitespace
character regardless of their type or how many.

Regards
Peter


Thanks Peter, - output is to browser, I develop in Notepad++ and Firefox, and confirm in IE8. But this stuff used to work - I have been working with PHP for about two years (not pro) and am used to formatting my output for legibility - especially echoing or var_dumping variables when still testing the code. So the failure is recent and I just can't figure what changed.
David

--- End Message ---
--- Begin Message ---
On 24 September 2010 12:49, YAD(YetAnotherDavid) <[email protected]> wrote:
> Peter Lind wrote:
>>
>> On 23 September 2010 21:47, YAD(YetAnotherDavid) <[email protected]> wrote:
>>>
>>> This code is 95% cut and paste from the PHP manual examples -
>>> the Types/Strings/Heredocs section and the Filesystem/fnmatch pages.
>>> There are actually two questions here - I have combined the code into one
>
>  ...
>
>>> Question 1 : how to get the newline functioning ....? even print_r()
>>> output
>>> is not 'newlined' as it should be. Also note the \n is missing between
>>> the "
>>> " in the output text of the second test!
>>>
>>
>> Are you outputting to browser or to command line? Browsers have a
>> habit of ignoring whitespaces, reducing them to one whitespace
>> character regardless of their type or how many.
>>
>> Regards
>> Peter
>>
>
> Thanks Peter, - output is to browser, I develop in Notepad++ and Firefox,
> and confirm in IE8. But this stuff used to work - I have been working with
> PHP for about two years (not pro) and am used to formatting my output for
> legibility - especially echoing or var_dumping variables when still testing
> the code. So the failure is recent and I just can't figure what changed.
> David

Browsers treat newlines as any other whitespace - so print_r and
var_dump will not, on their own, provide you with a linebreak in a
browser. If you've got xdebug installed, var_dump will provide a nicer
output (including line-breaks).
However, by far the easiest way to check if you're actually getting
linebreaks in your output is checking the source.

If you're suddenly experiencing a change in output, then some of your
environment variables have changed - hard to say which one without
knowing more about your system, but you must obviously have
changed/updated something for this to happen.

Regards
Peter

-- 
<hype>
WWW: http://plphp.dk / http://plind.dk
LinkedIn: http://www.linkedin.com/in/plind
BeWelcome/Couchsurfing: Fake51
Twitter: http://twitter.com/kafe15
</hype>

--- End Message ---
--- Begin Message ---
Hello list,

Does anyone know a method in Windows Server 2003 to discover one or more domain controllers to which the machine is connected. I know as an administrator I can use dsquery and various other administrator commands, but I'm unsure how to do so within PHP from an unprivileged vantage point.

Thanks,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

--- End Message ---
--- Begin Message ---
Hi Rob,

I believe you should be able to do this with nothing more than DNS (this is how 
Windows clients do it).

Once you have the DNS domain of the machine you're on 
(_SERVER["USERDNSDOMAIN"]), query for SRV records called the following:

Name: _ldap._tcp.dc._msdcs.<machine domain name>
 
That should return one or more records in the answer, each one will be the FQDN 
of a domain controller.

Additional info from the horses mouth: http://support.microsoft.com/kb/247811

HTH
Jason

-----Original Message-----
From: Robert Cummings [mailto:[email protected]] 
Sent: 27 September 2010 16:05
To: PHP General
Subject: [PHP] Domain Controller Discovery in PHP

Hello list,

Does anyone know a method in Windows Server 2003 to discover one or more 
domain controllers to which the machine is connected. I know as an 
administrator I can use dsquery and various other administrator 
commands, but I'm unsure how to do so within PHP from an unprivileged 
vantage point.

Thanks,
Rob.
-- 
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--- End Message ---
--- Begin Message ---
On 10-09-27 11:26 AM, Jason wrote:
Hi Rob,

I believe you should be able to do this with nothing more than DNS (this is how 
Windows clients do it).

Once you have the DNS domain of the machine you're on 
(_SERVER["USERDNSDOMAIN"]), query for SRV records called the following:

Name: _ldap._tcp.dc._msdcs.<machine domain name>

That should return one or more records in the answer, each one will be the FQDN 
of a domain controller.

Additional info from the horses mouth: http://support.microsoft.com/kb/247811

Hi Jason,

Thanks for the info. I don't actually have that server field (maybe because the article is for windows 2000), but maybe I can use your info to get to the next step anyways.

Cheers,
Rob.
--
E-Mail Disclaimer: Information contained in this message and any
attached documents is considered confidential and legally protected.
This message is intended solely for the addressee(s). Disclosure,
copying, and distribution are prohibited unless authorized.

--- End Message ---
--- Begin Message ---
Hello,
I'm wondering if anyone could recommend a newsletter script they use
and like? Some requirements I have are:

1. Free preferred
2. Can be used via a web browser
3. Can put the newsletter submission on a web page
4. Can use rss to feed that web page
5. Produce Xhtml compliant code and integrate well with a site's existing css
6. can optionally send that newsletter out as plain text or html

Googling has not helped in this matter.
Thanks.
Dave.

--- End Message ---

Reply via email to