diff options
Diffstat (limited to 'source3')
-rw-r--r-- | source3/libads/cldap.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/source3/libads/cldap.c b/source3/libads/cldap.c index 6a62f573c9..775d43dc3f 100644 --- a/source3/libads/cldap.c +++ b/source3/libads/cldap.c @@ -165,7 +165,17 @@ static int send_cldap_netlogon(int sock, const char *domain, return 0; } - +static SIG_ATOMIC_T gotalarm; + +/*************************************************************** + Signal function to tell us we timed out. +****************************************************************/ + +static void gotalarm_sig(void) +{ + gotalarm = 1; +} + /* receive a cldap netlogon reply */ @@ -180,8 +190,18 @@ static int recv_cldap_netlogon(int sock, struct cldap_netlogon_reply *reply) blob = data_blob(NULL, 8192); + /* Setup timeout */ + gotalarm = 0; + CatchSignal(SIGALRM, SIGNAL_CAST gotalarm_sig); + alarm(lp_ldap_timeout()); + /* End setup timeout. */ + ret = read(sock, blob.data, blob.length); + /* Teardown timeout. */ + CatchSignal(SIGALRM, SIGNAL_CAST SIG_IGN); + alarm(0); + if (ret <= 0) { d_fprintf(stderr, "no reply received to cldap netlogon\n"); return -1; |