Greetings,
I am currently designing a commandline ldap tool for our local use, but
have run into a small problem. We have a bind timeout of an hour, and
after that time, the server hangs up on the bind. If the commandline
tool is open and inactive for an hour or longer it crashes complaining
of 'Broken pipe'. I've tried invoking child processes which monitor the
time between most recent action and current time (once a minute) and
unbind if the time is less than a minute to the hour limit. But after
the unbind is issued, the next call that is made causes the same 'broken
pipe' error.
At this point, any help would be greatly appreciated. Thanks in advance.
relevant code snippets:
<binding>
$ldap = Net::LDAPS->new($ldap_serv, port=>636, version=>3);
$secure = 1;
$res = $ldap->start_tls() if($secure);
$mesg = $ldap->bind("$connect_as", password=>$pass, version=>3);
if($mesg->done){
$bind = 1;
&start_countdown;
}
</binding>
<countdown>
sub start_countdown{
system("touch", "$lock_file");
@stat = stat($lock_file);
$countdown = $stat[8];
$curr_time = time();
$fval = fork();
if(!$fval){
while(($curr_time - $countdown) < ($TIMEOUT - $SLEEP)){
print(($curr_time - $countdown) . " $TIMEOUT $SLEEP\n");
sleep($SLEEP);
@stat = stat($lock_file);
$countdown = $stat[8];
$curr_time = time();
}
print("\n\n*** Auto-unbinding due to timeout! ***\n\n");
&unbind;
exit;
}else{
return(1);
}
}
</countdown>
<unbind>
sub unbind{
if(!$bind){
print("Not currently bound to an LDAP server.\n");
return(0);
}
kill(9, $fval) if($fval);
$ldap->unbind;
$bind = 0;
}
</unbind>
*********************************************************************
| Brian Emord | System Administrator |
| ISD Enterprise Infrastructure | Office: JEF242 |
| University of Southern California | Phone: 213.740.2146 |
*********************************************************************