summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-03-13 12:50:14 +0000
committerNicholas Clark <nick@ccl4.org>2011-03-13 13:04:33 +0000
commita572cf217aac07991cbc820abacc022f4199cbae (patch)
treeb060f891cae3a12b50a90e1220859a5b59b4ec1c /t
parent0f0aa27e84651bcff0f03646d2b397fa9f3ca003 (diff)
downloadperl-a572cf217aac07991cbc820abacc022f4199cbae.tar.gz
C<not> should be C<!> in pwent.t, to fix a precedence bug.
Fortunately the effects are mostly benign. There are two boolean conditions - $where defined, and PerlIO available, making 4 possible combinations. As was, the code was: if (not defined $where && $Config{useperlio} eq 'define') { ... if (-x '/usr/bin/dscl') { ... if (open (PW, '<', \$data)) { $where = ...; would enter the first if block for 3 out of 4 possibilities, skipping only if *both* $where as defined *and* PerlIO was available. This was not the intent. However, if PerlIO is unavailable, then the open will fail, $where won't be set, and the logic continues on below, falling back to /etc/passwd The intended logic is if (!defined $where && $Config{useperlio} eq 'define') { ... ie only enter on 1 of the 4 possibilities - skip unless $where was undefined and PerlIO was available. The net effect was that usually the behaviour was the same. The only difference will be if PerlIO is not available (not the default, and rarely changed), the password data *is* available from one of the services tested earlier, and an /usr/bin/dscl executable is present. In this case, the old code would have reached the open, which would have failed, but would have closed PW as a side effect. However, because $where would be defined, the fallback to /etc/passwd would not have been tried. This would have caused the regression test to fail. Also, the test C<$Config{useperlio} eq 'define'> is not quite correct, as $Config{useperlio} will be undef if PerlIO is disabled, and the eq will warn.
Diffstat (limited to 't')
-rw-r--r--t/op/pwent.t4
1 files changed, 2 insertions, 2 deletions
diff --git a/t/op/pwent.t b/t/op/pwent.t
index 78805823f5..e755cf2422 100644
--- a/t/op/pwent.t
+++ b/t/op/pwent.t
@@ -31,8 +31,8 @@ BEGIN {
# Try NIS+.
$where //= try_prog('NIS+', 'passwd.org_dir', '/bin/niscat');
- if (not defined $where && # Try dscl
- $Config{useperlio} eq 'define') { # need perlio
+ if (!defined $where && # Try dscl
+ $Config{useperlio}) { # need perlio
# Map dscl items to passwd fields, and provide support for
# mucking with the dscl output if we need to (and we do).