From: danw Date: Tue, 2 Sep 1997 22:23:01 +0000 (+0000) Subject: Do a better job with returning error codes: add ERROR_TABLE_BASE_krb X-Git-Url: http://andersk.mit.edu/gitweb/moira.git/commitdiff_plain/585b298cb1dbef118a736f0b3aacefe65d3090ae Do a better job with returning error codes: add ERROR_TABLE_BASE_krb to error codes returned by krb functions, and use connection_errno(conn) for the error value from send_object and receive_object (not their return value, which is a non-useful GDB error number). --- diff --git a/update/auth_002.c b/update/auth_002.c index ca621350..1d817ab5 100644 --- a/update/auth_002.c +++ b/update/auth_002.c @@ -125,6 +125,10 @@ auth_002(str) if (send_object(conn, (char *)&data, STRING_T)) lose("sending nonce"); code = receive_object(conn, (char *)&data, STRING_T); + if (code) { + code = connection_errno(conn); + goto auth_failed; + } des_key_sched(&ad.session, &sched); des_ecb_encrypt(STRING_DATA(data), nonce2, sched, 0); if (memcmp(nonce, nonce2, sizeof(nonce))) diff --git a/update/exec_002.c b/update/exec_002.c index c9239a51..fcf0d96f 100644 --- a/update/exec_002.c +++ b/update/exec_002.c @@ -54,7 +54,7 @@ exec_002(str) } if (config_lookup("noexec")) { code = EPERM; - code = send_object(conn, (char *)&code, INTEGER_T); + send_object(conn, (char *)&code, INTEGER_T); com_err(whoami, code, "Not allowed to execute"); return(0); } @@ -115,16 +115,16 @@ exec_002(str) #endif #ifdef POSIX if ( (WIFEXITED(waitb) && (WEXITSTATUS(waitb)!=0)) || WIFSIGNALED(waitb) ) { - /* This is not really correct. It will cause teh moira server to - report a bogus error message if the script died on a signal. - However this is the same thing that occurs in the non-POSIX - case, and I don't know how to come up with a useful error based - on the signal recieved. - */ - n = WEXITSTATUS(waitb) + ERROR_TABLE_BASE_sms; log_priority = log_ERROR; - com_err(whoami, n, " child exited with status %d", - WEXITSTATUS(waitb)); + if (WIFSIGNALED(waitb)) { + n = MR_COREDUMP; + com_err(whoami, n, " child exited on signal %d", + WTERMSIG(waitb)); + } else { + n = WEXITSTATUS(waitb) + ERROR_TABLE_BASE_sms; + com_err(whoami, n, " child exited with status %d", + WEXITSTATUS(waitb)); + } #else if (waitb.w_status) { n = waitb.w_retcode + ERROR_TABLE_BASE_sms; diff --git a/update/send_file.c b/update/send_file.c index 317bc2d9..dc269991 100644 --- a/update/send_file.c +++ b/update/send_file.c @@ -79,15 +79,16 @@ int encrypt; checksum_file(pathname), target_path); code = send_object(conn, (char *)&data, STRING_T); if (code) { - com_err(whoami, code, " sending XFER request"); + com_err(whoami, connection_errno(conn), " sending XFER request"); close(fd); - return(code); + return(connection_errno(conn)); } code = receive_object(conn, (char *)&n, INTEGER_T); if (code) { - com_err(whoami, code, " getting reply from XFER request"); + com_err(whoami, connection_errno(conn), + " getting reply from XFER request"); close(fd); - return(code); + return(connection_errno(conn)); } if (n) { com_err(whoami, n, " transfer request (XFER) rejected"); @@ -99,7 +100,7 @@ int encrypt; if (code) { com_err(whoami, connection_errno(conn), ": lost connection"); close(fd); - return(code); + return(connection_errno(conn)); } if (n) { com_err(whoami, n, " from remote server: can't update %s", @@ -154,7 +155,7 @@ int encrypt; com_err(whoami, connection_errno(conn), " transmitting file %s", pathname); close(fd); - return(code); + return(connection_errno(conn)); } n_to_send -= n; code = receive_object(conn, (char *)&n, INTEGER_T); @@ -163,7 +164,7 @@ int encrypt; " awaiting ACK remote server during transmission of %s", pathname); close(fd); - return(code); + return(connection_errno(conn)); } if (n) { com_err(whoami, n, " from remote server during transmission of %s", @@ -179,7 +180,7 @@ int encrypt; " awaiting ACK remote server after transmission of %s", pathname); close(fd); - return(code); + return(connection_errno(conn)); } if (n) { com_err(whoami, n, " from remote server after transmission of %s", diff --git a/update/ticket.c b/update/ticket.c index 6e5f6d1d..29b909e6 100644 --- a/update/ticket.c +++ b/update/ticket.c @@ -68,9 +68,11 @@ get_mr_update_ticket(host, ticket) pass++; goto try_it; } + code += ERROR_TABLE_BASE_krb; com_err(whoami, code, "in krb_mk_req"); } else { code = krb_get_cred(service, phost, realm, &cr); + if (code) code += ERROR_TABLE_BASE_krb; memcpy(session, cr.session, sizeof(session)); } return(code);