printerr(1, "doing downcall\n");
- if (WRITE_BYTES(&p, end, uid)) return -1;
+ if (WRITE_BYTES(&p, end, uid)) goto out_err;
/* Not setting any timeout for now: */
- if (WRITE_BYTES(&p, end, timeout)) return -1;
- if (WRITE_BYTES(&p, end, pd->pd_seq_win)) return -1;
- if (write_buffer(&p, end, &pd->pd_ctx_hndl)) return -1;
- if (write_buffer(&p, end, context_token)) return -1;
+ if (WRITE_BYTES(&p, end, timeout)) goto out_err;
+ if (WRITE_BYTES(&p, end, pd->pd_seq_win)) goto out_err;
+ if (write_buffer(&p, end, &pd->pd_ctx_hndl)) goto out_err;
+ if (write_buffer(&p, end, context_token)) goto out_err;
- if (write(k5_fd, buf, p - buf) < p - buf) return -1;
+ if (write(k5_fd, buf, p - buf) < p - buf) goto out_err;
return 0;
+out_err:
+ printerr(0, "Failed to write downcall!\n");
+ return -1;
}
static int
printerr(1, "doing error downcall\n");
- if (WRITE_BYTES(&p, end, uid)) return -1;
- if (WRITE_BYTES(&p, end, timeout)) return -1;
+ if (WRITE_BYTES(&p, end, uid)) goto out_err;
+ if (WRITE_BYTES(&p, end, timeout)) goto out_err;
/* use seq_win = 0 to indicate an error: */
- if (WRITE_BYTES(&p, end, zero)) return -1;
- if (WRITE_BYTES(&p, end, err)) return -1;
+ if (WRITE_BYTES(&p, end, zero)) goto out_err;
+ if (WRITE_BYTES(&p, end, err)) goto out_err;
- if (write(k5_fd, buf, p - buf) < p - buf) return -1;
+ if (write(k5_fd, buf, p - buf) < p - buf) goto out_err;
return 0;
-
+out_err:
+ printerr(0, "Failed to write error downcall!\n");
+ return -1;
}
/*
retval = 0;
out_fail:
+ if ((save_uid != -1) && (seteuid(save_uid) != 0)) {
+ printerr(0, "WARNING: Failed to restore euid"
+ " to uid %d (in error path)\n", save_uid);
+ }
if (sec.cred != GSS_C_NO_CREDENTIAL)
gss_release_cred(&min_stat, &sec.cred);
if (rpc_clnt) clnt_destroy(rpc_clnt);