int send_command( struct tcp_chan *chan, int cmd) { int rc; if((rc = diswsi(chan,cmd)) != DIS_SUCCESS) return (rc); if (cmd == RM_CMD_CONFIG) { if((rc = diswst(chan,ConfigBuf)) != DIS_SUCCESS) return(rc); } DIS_tcp_wflush(chan); if (cmd == RM_CMD_CLOSE) DIS_tcp_close(chan); return(rc); } /* END send_command() */
int PBSD_gpu_put( int c, char *node, char *gpuid, int gpumode, int reset_perm, int reset_vol, char *extend) { int sock; int rc = 0; struct tcp_chan *chan = NULL; sock = connection[c].ch_socket; if ((chan = DIS_tcp_setup(sock)) == NULL) { return PBSE_PROTOCOL; } else if ((rc = encode_DIS_ReqHdr(chan, PBS_BATCH_GpuCtrl, pbs_current_user)) || (rc = encode_DIS_GpuCtrl(chan, node, gpuid, gpumode, reset_perm, reset_vol)) || (rc = encode_DIS_ReqExtend(chan, extend))) { connection[c].ch_errtxt = strdup(dis_emsg[rc]); DIS_tcp_cleanup(chan); return(PBSE_PROTOCOL); } if (DIS_tcp_wflush(chan)) { rc = PBSE_PROTOCOL; } DIS_tcp_cleanup(chan); return(rc); }
int pbs_disconnect( int connect) /* I (socket descriptor) */ { int sock; int rc; /* send close-connection message */ sock = connection[connect].ch_socket; DIS_tcp_setup(sock); rc = encode_DIS_ReqHdr(sock, PBS_BATCH_Disconnect, pbs_current_user); if(rc) { return(rc); } rc = DIS_tcp_wflush(sock); if(rc) { return(rc); } close(sock); if (connection[connect].ch_errtxt != (char *)NULL) free(connection[connect].ch_errtxt); connection[connect].ch_errno = 0; connection[connect].ch_inuse = 0; return(0); } /* END pbs_disconnect() */
static int simplecom( int stream, int *local_errno, int com) { struct out *op; if ((op = findout(local_errno, stream)) == NULL) { return(-1); } op->len = -1; if (startcom(op->chan, local_errno, com,0) != DIS_SUCCESS) { close(op->chan->sock); return(-1); } if (DIS_tcp_wflush(op->chan) == -1) { *local_errno = errno; DBPRT(("simplecom: flush error %d (%s)\n", *local_errno, pbs_strerror(*local_errno))) close(op->chan->sock); return(-1); } return(0); } /* END simplecom() */
int PBSD_QueueJob_hash( int connect, /* I */ char *jobid, /* I */ char *destin, memmgr **mm, job_data *job_attr, job_data *res_attr, char *extend, char **job_id, char **msg) { struct batch_reply *reply; int rc = PBSE_NONE; int sock; int tmp_size = 0; struct tcp_chan *chan = NULL; pthread_mutex_lock(connection[connect].ch_mutex); sock = connection[connect].ch_socket; pthread_mutex_unlock(connection[connect].ch_mutex); if ((chan = DIS_tcp_setup(sock)) == NULL) { return(PBSE_PROTOCOL); } /* first, set up the body of the Queue Job request */ else if ((rc = encode_DIS_ReqHdr(chan, PBS_BATCH_QueueJob, pbs_current_user)) || (rc = encode_DIS_QueueJob_hash(chan, jobid, destin, mm, job_attr, res_attr)) || (rc = encode_DIS_ReqExtend(chan, extend))) { pthread_mutex_lock(connection[connect].ch_mutex); if (connection[connect].ch_errtxt == NULL) { if ((rc >= 0) && (rc <= DIS_INVALID)) connection[connect].ch_errtxt = memmgr_strdup(mm, (char *)dis_emsg[rc], &tmp_size); } *msg = memmgr_strdup(mm, connection[connect].ch_errtxt, &tmp_size); pthread_mutex_unlock(connection[connect].ch_mutex); DIS_tcp_cleanup(chan); return(rc); } if ((rc = DIS_tcp_wflush(chan))) { pthread_mutex_lock(connection[connect].ch_mutex); if (connection[connect].ch_errtxt == NULL) { *msg = memmgr_strdup(mm, connection[connect].ch_errtxt, &tmp_size); } pthread_mutex_unlock(connection[connect].ch_mutex); DIS_tcp_cleanup(chan); return(rc); } DIS_tcp_cleanup(chan); /* read reply from stream into presentation element */ reply = PBSD_rdrpy(&rc, connect); pthread_mutex_lock(connection[connect].ch_mutex); if (reply == NULL) { if (rc == PBSE_TIMEOUT) rc = PBSE_EXPIRED; } else if (reply->brp_choice && reply->brp_choice != BATCH_REPLY_CHOICE_Text && reply->brp_choice != BATCH_REPLY_CHOICE_Queue) { rc = PBSE_PROTOCOL; if (connection[connect].ch_errtxt == NULL) { *msg = memmgr_strdup(mm, connection[connect].ch_errtxt, &tmp_size); } } else if (reply->brp_choice == BATCH_REPLY_CHOICE_Text) { *msg = memmgr_strdup(mm, reply->brp_un.brp_txt.brp_str, &tmp_size); } else if (connection[connect].ch_errno == 0) { *job_id = memmgr_strdup(mm, reply->brp_un.brp_jid, &tmp_size); } pthread_mutex_unlock(connection[connect].ch_mutex); PBSD_FreeReply(reply); return rc; } /* END PBSD_queuejob() */
char *PBSD_queuejob( int connect, /* I */ int *local_errno, /* O */ char *jobid, /* I */ char *destin, struct attropl *attrib, char *extend) { struct batch_reply *reply; char *return_jobid = NULL; int rc; int sock; struct tcp_chan *chan = NULL; pthread_mutex_lock(connection[connect].ch_mutex); sock = connection[connect].ch_socket; connection[connect].ch_errno = 0; pthread_mutex_unlock(connection[connect].ch_mutex); if ((chan = DIS_tcp_setup(sock)) == NULL) { return(NULL); } /* first, set up the body of the Queue Job request */ else if ((rc = encode_DIS_ReqHdr(chan,PBS_BATCH_QueueJob,pbs_current_user)) || (rc = encode_DIS_QueueJob(chan, jobid, destin, attrib)) || (rc = encode_DIS_ReqExtend(chan, extend))) { pthread_mutex_lock(connection[connect].ch_mutex); connection[connect].ch_errtxt = strdup(dis_emsg[rc]); pthread_mutex_unlock(connection[connect].ch_mutex); *local_errno = PBSE_PROTOCOL; DIS_tcp_cleanup(chan); return(NULL); } if (DIS_tcp_wflush(chan)) { *local_errno = PBSE_PROTOCOL; DIS_tcp_cleanup(chan); return(NULL); } DIS_tcp_cleanup(chan); /* read reply from stream into presentation element */ reply = PBSD_rdrpy(local_errno, connect); pthread_mutex_lock(connection[connect].ch_mutex); if (reply == NULL) { } else if (reply->brp_choice && reply->brp_choice != BATCH_REPLY_CHOICE_Text && reply->brp_choice != BATCH_REPLY_CHOICE_Queue) { *local_errno = PBSE_PROTOCOL; } else if (connection[connect].ch_errno == 0) { return_jobid = strdup(reply->brp_un.brp_jid); } pthread_mutex_unlock(connection[connect].ch_mutex); PBSD_FreeReply(reply); return(return_jobid); } /* END PBSD_queuejob() */
/** * @brief * Generate munge key specific to the user and send PBS batch request * (PBS_BATCH_AuthExternal)to PBS server to authenticate user. * * @param[in] sock - socket fd * @param[in] auth_type - Authentication type (Munge/AMS etc) * @param[in] fromsvr - connection initiated from server? * * @return int * @retval 0 on success * @retval -1 on failure * @retval -2 on unsupported auth_type * */ int engage_external_authentication(int sock, int auth_type, int fromsvr, char *ebuf, int ebufsz) { int cred_len = 0, rc = 0, ret = 0; char *cred = NULL; struct batch_reply *reply = NULL; switch (auth_type) { #ifndef WIN32 case AUTH_MUNGE: ebuf[0] = '\0'; cred = pbs_get_munge_auth_data(fromsvr, ebuf, ebufsz); if (!cred) goto err; break; #endif default: snprintf(ebuf, ebufsz, "Authentication type not supported"); ret = -2; } if (cred) { ret = -1; cred_len = strlen(cred); DIS_tcp_setup(sock); if (encode_DIS_ReqHdr(sock, PBS_BATCH_AuthExternal, pbs_current_user) || diswuc(sock, auth_type) || /* authentication_type */ diswsi(sock, cred_len) || /* credential length */ diswcs(sock, cred, cred_len) || /* credential data */ encode_DIS_ReqExtend(sock, NULL)) { pbs_errno = PBSE_SYSTEM; goto err; } if (DIS_tcp_wflush(sock)) { pbs_errno = PBSE_SYSTEM; goto err; } memset(cred, 0, cred_len); reply = PBSD_rdrpy_sock(sock, &rc); if ((reply != NULL) && (reply->brp_code != 0)) { pbs_errno = PBSE_BADCRED; PBSD_FreeReply(reply); goto err; } PBSD_FreeReply(reply); free(cred); return 0; } /* else fall through */ err: if (ebuf[0] != '\0') { fprintf(stderr, "%s\n", ebuf); cs_logerr(-1, __func__, ebuf); } free(cred); return ret; }
int PBSD_munge_authenticate( int psock, /* I */ int handle) /* I */ { int rc = PBSE_NONE; int fd; FILE *munge_pipe; char munge_buf[MUNGE_SIZE]; char munge_command[MUNGE_SIZE]; char *ptr; /* pointer to the current place to copy data into munge_buf */ int bytes_read; int total_bytes_read = 0; int local_errno = 0; /* user id and name stuff */ struct passwd *pwent; uid_t myrealuid; struct batch_reply *reply; unsigned short user_port = 0; struct sockaddr_in sockname; socklen_t socknamelen = sizeof(sockname); struct tcp_chan *chan = NULL; snprintf(munge_command,sizeof(munge_command), "munge -n 2>/dev/null"); memset(munge_buf, 0, MUNGE_SIZE); ptr = munge_buf; if ((munge_pipe = popen(munge_command,"r")) == NULL) { /* FAILURE */ return(-1); } fd = fileno(munge_pipe); while ((bytes_read = read_ac_socket(fd, ptr, MUNGE_SIZE - total_bytes_read)) > 0) { total_bytes_read += bytes_read; ptr += bytes_read; } pclose(munge_pipe); if (bytes_read == -1) { /* read failed */ local_errno = errno; log_err(local_errno, __func__, "error reading pipe in PBSD_munge_authenticate"); return -1; } /* if we got no bytes back then Munge may not be installed etc. */ if (total_bytes_read == 0) { return(PBSE_MUNGE_NOT_FOUND); } /* We got the certificate. Now make the PBS_BATCH_AltAuthenUser request */ myrealuid = getuid(); pwent = getpwuid(myrealuid); rc = getsockname(psock, (struct sockaddr *)&sockname, &socknamelen); if (rc == -1) { fprintf(stderr, "getsockname failed: %d\n", errno); return rc; } user_port = ntohs(sockname.sin_port); if ((chan = DIS_tcp_setup(psock)) == NULL) { rc = PBSE_MEM_MALLOC; } else if ((rc = encode_DIS_ReqHdr(chan,PBS_BATCH_AltAuthenUser,pwent->pw_name)) || (rc = diswui(chan, user_port)) || (rc = diswst(chan, munge_buf)) || (rc = encode_DIS_ReqExtend(chan, NULL)) || (rc = DIS_tcp_wflush(chan))) { /* ERROR */ } else { /* read the reply */ if ((reply = PBSD_rdrpy(&local_errno, handle)) != NULL) free(reply); rc = PBSE_NONE; } if (chan != NULL) DIS_tcp_cleanup(chan); return rc; } /* END PBSD_munge_authenticate() */
int pbs_runjob_err( int c, char *jobid, char *location, char *extend, int *rc) { struct batch_reply *reply; unsigned int resch = 0; int sock; struct tcp_chan *chan = NULL; /* NOTE: set_task sets WORK_Deferred_Child : request remains until child terminates */ if ((jobid == NULL) || (*jobid == '\0')) { *rc = PBSE_IVALREQ; return (*rc) * -1; } if ((c < 0) || (c >= PBS_NET_MAX_CONNECTIONS)) { return(PBSE_IVALREQ * -1); } if (location == NULL) { location = (char *)""; } pthread_mutex_lock(connection[c].ch_mutex); sock = connection[c].ch_socket; /* setup DIS support routines for following DIS calls */ if ((chan = DIS_tcp_setup(sock)) == NULL) { pthread_mutex_unlock(connection[c].ch_mutex); *rc = PBSE_PROTOCOL; return(*rc); } /* send run request */ else if ((*rc = encode_DIS_ReqHdr(chan, PBS_BATCH_RunJob, pbs_current_user)) || (*rc = encode_DIS_RunJob(chan, jobid, location, resch)) || (*rc = encode_DIS_ReqExtend(chan, extend))) { connection[c].ch_errtxt = strdup(dis_emsg[*rc]); pthread_mutex_unlock(connection[c].ch_mutex); DIS_tcp_cleanup(chan); return(PBSE_PROTOCOL); } if ((*rc = DIS_tcp_wflush(chan)) != PBSE_NONE) { pthread_mutex_unlock(connection[c].ch_mutex); DIS_tcp_cleanup(chan); return(PBSE_PROTOCOL); } /* get reply */ reply = PBSD_rdrpy(rc, c); /* *rc = connection[c].ch_errno; */ pthread_mutex_unlock(connection[c].ch_mutex); PBSD_FreeReply(reply); DIS_tcp_cleanup(chan); return(*rc); } /* END pbs_runjob_err() */
/** * @brief * -send async run job batch request. * * @param[in] c - connection handle * @param[in] jobid- job identifier * @param[in] location - string of vnodes/resources to be allocated to the job * @param[in] extend - extend string for encoding req * * @return int * @retval 0 success * @retval !0 error * */ int pbs_asyrunjob(int c, char *jobid, char *location, char *extend) { int rc; struct batch_reply *reply; unsigned long resch = 0; int sock; if ((jobid == (char *)0) || (*jobid == '\0')) return (pbs_errno = PBSE_IVALREQ); if (location == (char *)0) location = ""; sock = connection[c].ch_socket; /* initialize the thread context data, if not already initialized */ if (pbs_client_thread_init_thread_context() != 0) return pbs_errno; /* lock pthread mutex here for this connection */ /* blocking call, waits for mutex release */ if (pbs_client_thread_lock_connection(c) != 0) return pbs_errno; /* setup DIS support routines for following DIS calls */ DIS_tcp_setup(sock); /* send run request */ if ((rc = encode_DIS_ReqHdr(sock, PBS_BATCH_AsyrunJob, pbs_current_user)) || (rc = encode_DIS_Run(sock, jobid, location, resch)) || (rc = encode_DIS_ReqExtend(sock, extend))) { connection[c].ch_errtxt = strdup(dis_emsg[rc]); if (connection[c].ch_errtxt == NULL) { pbs_errno = PBSE_SYSTEM; } else { pbs_errno = PBSE_PROTOCOL; } (void)pbs_client_thread_unlock_connection(c); return pbs_errno; } if (DIS_tcp_wflush(sock)) { pbs_errno = PBSE_PROTOCOL; (void)pbs_client_thread_unlock_connection(c); return pbs_errno; } /* get reply */ reply = PBSD_rdrpy(c); rc = connection[c].ch_errno; PBSD_FreeReply(reply); /* unlock the thread lock and update the thread context data */ if (pbs_client_thread_unlock_connection(c) != 0) return pbs_errno; return rc; }
int pbs_orderjob_err( int c, char *job1, char *job2, char *extend, int *local_errno) { struct batch_reply *reply; int rc; int sock; struct tcp_chan *chan = NULL; if ((job1 == (char *)0) || (*job1 == '\0') || (job2 == (char *)0) || (*job2 == '\0')) return (PBSE_IVALREQ); if ((c < 0) || (c >= PBS_NET_MAX_CONNECTIONS)) { return(PBSE_IVALREQ); } pthread_mutex_lock(connection[c].ch_mutex); sock = connection[c].ch_socket; /* setup DIS support routines for following DIS calls */ if ((chan = DIS_tcp_setup(sock)) == NULL) { pthread_mutex_unlock(connection[c].ch_mutex); rc = PBSE_PROTOCOL; return rc; } else if ((rc = encode_DIS_ReqHdr(chan, PBS_BATCH_OrderJob, pbs_current_user)) || (rc = encode_DIS_MoveJob(chan, job1, job2)) || (rc = encode_DIS_ReqExtend(chan, extend))) { connection[c].ch_errtxt = strdup(dis_emsg[rc]); pthread_mutex_unlock(connection[c].ch_mutex); DIS_tcp_cleanup(chan); return (PBSE_PROTOCOL); } if (DIS_tcp_wflush(chan)) { pthread_mutex_unlock(connection[c].ch_mutex); DIS_tcp_cleanup(chan); return (PBSE_PROTOCOL); } /* read reply */ reply = PBSD_rdrpy(local_errno, c); PBSD_FreeReply(reply); rc = connection[c].ch_errno; pthread_mutex_unlock(connection[c].ch_mutex); DIS_tcp_cleanup(chan); return(rc); } /* END pbs_orderjob_err() */
int pbs_rerunjob_err( int c, char *jobid, char *extend, int *local_errno) { int rc; struct batch_reply *reply; int sock; struct tcp_chan *chan = NULL; if ((jobid == (char *)0) || (*jobid == '\0')) return (PBSE_IVALREQ); pthread_mutex_lock(connection[c].ch_mutex); sock = connection[c].ch_socket; /* setup DIS support routines for following DIS calls */ if ((chan = DIS_tcp_setup(sock)) == NULL) { pthread_mutex_unlock(connection[c].ch_mutex); rc = PBSE_PROTOCOL; return rc; } else if ((rc = encode_DIS_ReqHdr(chan, PBS_BATCH_Rerun, pbs_current_user)) || (rc = encode_DIS_JobId(chan, jobid)) || (rc = encode_DIS_ReqExtend(chan, extend))) { connection[c].ch_errtxt = strdup(dis_emsg[rc]); pthread_mutex_unlock(connection[c].ch_mutex); DIS_tcp_cleanup(chan); return (PBSE_PROTOCOL); } /* write data */ if (DIS_tcp_wflush(chan)) { pthread_mutex_unlock(connection[c].ch_mutex); DIS_tcp_cleanup(chan); return (PBSE_PROTOCOL); } /* read reply from stream into presentation element */ reply = PBSD_rdrpy(local_errno, c); PBSD_FreeReply(reply); rc = connection[c].ch_errno; pthread_mutex_unlock(connection[c].ch_mutex); DIS_tcp_cleanup(chan); return(rc); } /* END pbs_rerunjob_err() */
/** * @brief * Open a connection with a pbs server. * Do not allow TCP to block us if Server host is down * At this point, this does not attempt to find a fail_over Server * * @param[in] server - specifies the server to which to connect * @param[in] tout - timeout value for select * * @return int * @retval >= 0 index to the internal connection table representing the * connection made. * @retval -1 error encountered in getting index */ int pbs_connect_noblk(char *server, int tout) { int out; int i; pbs_socklen_t l; int n; struct timeval tv; fd_set fdset; struct batch_reply *reply; char server_name[PBS_MAXSERVERNAME+1]; unsigned int server_port; struct addrinfo *aip, *pai; struct addrinfo hints; struct sockaddr_in *inp; short int connect_err = 0; struct sockaddr_in sockname; pbs_socklen_t socknamelen; #ifdef WIN32 int non_block = 1; struct sockaddr_in to_sock; struct sockaddr_in from_sock; #endif #ifndef WIN32 int nflg; int oflg; #endif /* initialize the thread context data, if not already initialized */ if (pbs_client_thread_init_thread_context() != 0) return -1; if (pbs_loadconf(0) == 0) return -1; /* get server host and port */ server = PBS_get_server(server, server_name, &server_port); if (server == NULL) { pbs_errno = PBSE_NOSERVER; return -1; } /* Reserve a connection state record */ if (pbs_client_thread_lock_conntable() != 0) return -1; out = -1; for (i=1;i<NCONNECTS;i++) { if (connection[i].ch_inuse) continue; out = i; connection[out].ch_inuse = 1; connection[out].ch_errno = 0; connection[out].ch_socket= -1; connection[out].ch_errtxt = NULL; break; } if (pbs_client_thread_unlock_conntable() != 0) return -1; /* pbs_errno set by the function */ if (out < 0) { pbs_errno = PBSE_NOCONNECTS; return -1; } /* get socket */ #ifdef WIN32 /* the following lousy hack is needed since the socket call needs */ /* SYSTEMROOT env variable properly set! */ if (getenv("SYSTEMROOT") == NULL) { setenv("SYSTEMROOT", "C:\\WINNT", 1); setenv("SystemRoot", "C:\\WINNT", 1); } connection[out].ch_socket = socket(AF_INET, SOCK_STREAM, 0); if (connection[out].ch_socket < 0) { setenv("SYSTEMROOT", "C:\\WINDOWS", 1); setenv("SystemRoot", "C:\\WINDOWS", 1); connection[out].ch_socket = socket(AF_INET, SOCK_STREAM, 0); } #else connection[out].ch_socket = socket(AF_INET, SOCK_STREAM, 0); #endif if (connection[out].ch_socket < 0) { connection[out].ch_inuse = 0; pbs_errno = ERRORNO; return -1; } /* set socket non-blocking */ #ifdef WIN32 if (ioctlsocket(connection[out].ch_socket, FIONBIO, &non_block) == SOCKET_ERROR) #else oflg = fcntl(connection[out].ch_socket, F_GETFL) & ~O_ACCMODE; nflg = oflg | O_NONBLOCK; if (fcntl(connection[out].ch_socket, F_SETFL, nflg) == -1) #endif goto err; /* and connect... */ strcpy(pbs_server, server); /* set for error messages from commands */ memset(&hints, 0, sizeof(struct addrinfo)); /* * Why do we use AF_UNSPEC rather than AF_INET? Some * implementations of getaddrinfo() will take an IPv6 * address and map it to an IPv4 one if we ask for AF_INET * only. We don't want that - we want only the addresses * that are genuinely, natively, IPv4 so we start with * AF_UNSPEC and filter ai_family below. */ hints.ai_family = AF_UNSPEC; hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = IPPROTO_TCP; if (getaddrinfo(server, NULL, &hints, &pai) != 0) { CLOSESOCKET(connection[out].ch_socket); connection[out].ch_inuse = 0; pbs_errno = PBSE_BADHOST; return -1; } for (aip = pai; aip != NULL; aip = aip->ai_next) { /* skip non-IPv4 addresses */ if (aip->ai_family == AF_INET) { inp = (struct sockaddr_in *) aip->ai_addr; break; } } if (aip == NULL) { /* treat no IPv4 addresses as getaddrinfo() failure */ CLOSESOCKET(connection[out].ch_socket); connection[out].ch_inuse = 0; pbs_errno = PBSE_BADHOST; freeaddrinfo(pai); return -1; } else inp->sin_port = htons(server_port); if (connect(connection[out].ch_socket, aip->ai_addr, aip->ai_addrlen) < 0) { connect_err = 1; } if (connect_err == 1) { /* connect attempt failed */ pbs_errno = ERRORNO; switch (pbs_errno) { #ifdef WIN32 case WSAEWOULDBLOCK: #else case EINPROGRESS: case EWOULDBLOCK: #endif while (1) { FD_ZERO(&fdset); FD_SET(connection[out].ch_socket, &fdset); tv.tv_sec = tout; tv.tv_usec = 0; n = select(connection[out].ch_socket+1, NULL, &fdset, NULL, &tv); if (n > 0) { pbs_errno = 0; l = sizeof(pbs_errno); (void)getsockopt(connection[out].ch_socket, SOL_SOCKET, SO_ERROR, &pbs_errno, &l); if (pbs_errno == 0) break; else goto err; } if ((n < 0) && #ifdef WIN32 (ERRORNO == WSAEINTR) #else (ERRORNO == EINTR) #endif ) { continue; } else { goto err; } } break; default: err: CLOSESOCKET(connection[out].ch_socket); connection[out].ch_inuse = 0; freeaddrinfo(pai); return -1; /* cannot connect */ } } freeaddrinfo(pai); /* reset socket blocking */ #ifdef WIN32 non_block = 0; if (ioctlsocket(connection[out].ch_socket, FIONBIO, &non_block) == SOCKET_ERROR) #else if (fcntl(connection[out].ch_socket, F_SETFL, oflg) < 0) #endif goto err; /* * multiple threads cant get the same connection id above, * so no need to lock this piece of code */ /* setup connection level thread context */ if (pbs_client_thread_init_connect_context(out) != 0) { CLOSESOCKET(connection[out].ch_socket); connection[out].ch_inuse = 0; /* pbs_errno set by the pbs_connect_init_context routine */ return -1; } /* * even though the following is communication with server on * a connection handle, it does not need to be lock since * this connection handle has not be returned back yet to the client * so others threads cannot use it */ /* send "dummy" connect message */ DIS_tcp_setup(connection[out].ch_socket); if ((i = encode_DIS_ReqHdr(connection[out].ch_socket, PBS_BATCH_Connect, pbs_current_user)) || (i = encode_DIS_ReqExtend(connection[out].ch_socket, NULL))) { pbs_errno = PBSE_SYSTEM; return -1; } if (DIS_tcp_wflush(connection[out].ch_socket)) { pbs_errno = PBSE_SYSTEM; return -1; } reply = PBSD_rdrpy(out); PBSD_FreeReply(reply); /*do configured authentication (kerberos, pbs_iff, whatever)*/ /*Get the socket port for engage_authentication()*/ socknamelen = sizeof(sockname); if (getsockname(connection[out].ch_socket, (struct sockaddr *)&sockname, &socknamelen)) return -1; if (engage_authentication(connection[out].ch_socket, server, server_port, &sockname) == -1) { CLOSESOCKET(connection[out].ch_socket); connection[out].ch_inuse = 0; pbs_errno = PBSE_PERM; return -1; } /* setup DIS support routines for following pbs_* calls */ DIS_tcp_setup(connection[out].ch_socket); pbs_tcp_timeout = PBS_DIS_TCP_TIMEOUT_VLONG; /* set for 3 hours */ return out; }
/** * @brief * -send close connection batch request * * @param[in] connect - socket descriptor * * @return int * @retval 0 success * @retval -1 error * */ int __pbs_disconnect(int connect) { int sock; char x; if (connect < 0 || NCONNECTS <= connect) return 0; if (!connection[connect].ch_inuse) return 0; /* initialize the thread context data, if not already initialized */ if (pbs_client_thread_init_thread_context() != 0) return -1; /* * Use only connection handle level lock since this is * just communication with server */ if (pbs_client_thread_lock_connection(connect) != 0) return -1; /* * check again to ensure that another racing thread * had not already closed the connection */ if (!connection[connect].ch_inuse) { (void)pbs_client_thread_unlock_connection(connect); return 0; } /* send close-connection message */ sock = connection[connect].ch_socket; DIS_tcp_setup(sock); if ((encode_DIS_ReqHdr(sock, PBS_BATCH_Disconnect, pbs_current_user) == 0) && (DIS_tcp_wflush(sock) == 0)) { for (;;) { /* wait for server to close connection */ #ifdef WIN32 if (recv(sock, &x, 1, 0) < 1) #else if (read(sock, &x, 1) < 1) #endif break; } } CS_close_socket(sock); CLOSESOCKET(sock); if (connection[connect].ch_errtxt != NULL) { free(connection[connect].ch_errtxt); connection[connect].ch_errtxt = NULL; } connection[connect].ch_errno = 0; connection[connect].ch_inuse = 0; /* unlock the connection level lock */ if (pbs_client_thread_unlock_connection(connect) != 0) return -1; /* * this is only a per thread work, so outside lock and unlock * connection needs the thread level connect context so this should be * called after unlocking */ if (pbs_client_thread_destroy_connect_context(connect) != 0) return -1; return 0; }
/** * @brief * Makes a PBS_BATCH_Connect request to 'server'. * * @param[in] server - the hostname of the pbs server to connect to. * @param[in] extend_data - a string to send as "extend" data. * * @return int * @retval >= 0 index to the internal connection table representing the * connection made. * @retval -1 error encountered setting up the connection. */ int __pbs_connect_extend(char *server, char *extend_data) { struct sockaddr_in server_addr; struct sockaddr_in my_sockaddr; int out; int i; int f; char *altservers[2]; int have_alt = 0; struct batch_reply *reply; char server_name[PBS_MAXSERVERNAME+1]; unsigned int server_port; struct sockaddr_in sockname; pbs_socklen_t socknamelen; #ifdef WIN32 struct sockaddr_in to_sock; struct sockaddr_in from_sock; #endif #ifndef WIN32 char pbsrc[_POSIX_PATH_MAX]; struct stat sb; int using_secondary = 0; #endif /* not WIN32 */ /* initialize the thread context data, if not already initialized */ if (pbs_client_thread_init_thread_context() != 0) return -1; if (pbs_loadconf(0) == 0) return -1; /* get server host and port */ server = PBS_get_server(server, server_name, &server_port); if (server == NULL) { pbs_errno = PBSE_NOSERVER; return -1; } if (pbs_conf.pbs_primary && pbs_conf.pbs_secondary) { /* failover configuered ... */ if (hostnmcmp(server, pbs_conf.pbs_primary) == 0) { have_alt = 1; /* We want to try the one last seen as "up" first to not */ /* have connection delays. If the primary was up, there */ /* is no .pbsrc.NAME file. If the last command connected */ /* to the Secondary, then it created the .pbsrc.USER file. */ /* see if already seen Primary down */ #ifdef WIN32 /* due to windows quirks, all try both in same order */ altservers[0] = pbs_conf.pbs_primary; altservers[1] = pbs_conf.pbs_secondary; #else (void)snprintf(pbsrc, _POSIX_PATH_MAX, "%s/.pbsrc.%s", pbs_conf.pbs_tmpdir, pbs_current_user); if (stat(pbsrc, &sb) == -1) { /* try primary first */ altservers[0] = pbs_conf.pbs_primary; altservers[1] = pbs_conf.pbs_secondary; using_secondary = 0; } else { /* try secondary first */ altservers[0] = pbs_conf.pbs_secondary; altservers[1] = pbs_conf.pbs_primary; using_secondary = 1; } #endif } } /* if specific host name declared for the host on which */ /* this client is running, get its address */ if (pbs_conf.pbs_public_host_name) { if (get_hostsockaddr(pbs_conf.pbs_public_host_name, &my_sockaddr) != 0) return -1; /* pbs_errno was set */ } /* Reserve a connection state record */ if (pbs_client_thread_lock_conntable() != 0) return -1; out = -1; for (i=1;i<NCONNECTS;i++) { if (connection[i].ch_inuse) continue; out = i; connection[out].ch_errno = 0; connection[out].ch_socket= -1; connection[out].ch_errtxt = NULL; connection[out].ch_inuse = 1; /* reserve the socket */ break; } if (pbs_client_thread_unlock_conntable() != 0) return -1; /* pbs_errno set by the function */ if (out < 0) { pbs_errno = PBSE_NOCONNECTS; return -1; } /* * connect to server ... * If attempt to connect fails and if Failover configured and * if attempting to connect to Primary, try the Secondary * if attempting to connect to Secondary, try the Primary */ for (i=0; i<(have_alt+1); ++i) { /* get socket */ #ifdef WIN32 /* the following lousy hack is needed since the socket call needs */ /* SYSTEMROOT env variable properly set! */ if (getenv("SYSTEMROOT") == NULL) { setenv("SYSTEMROOT", "C:\\WINNT", 1); setenv("SystemRoot", "C:\\WINNT", 1); } connection[out].ch_socket = socket(AF_INET, SOCK_STREAM, 0); if (connection[out].ch_socket < 0) { setenv("SYSTEMROOT", "C:\\WINDOWS", 1); setenv("SystemRoot", "C:\\WINDOWS", 1); connection[out].ch_socket = socket(AF_INET, SOCK_STREAM, 0); } #else connection[out].ch_socket = socket(AF_INET, SOCK_STREAM, 0); #endif if (connection[out].ch_socket < 0) { connection[out].ch_inuse = 0; pbs_errno = errno; return -1; } /* and connect... */ if (have_alt) { server = altservers[i]; } strcpy(pbs_server, server); /* set for error messages from commands */ /* If a specific host name is defined which the client should use */ if (pbs_conf.pbs_public_host_name) { /* my address will be in my_sockaddr, bind the socket to it */ my_sockaddr.sin_port = 0; if (bind(connection[out].ch_socket, (struct sockaddr *)&my_sockaddr, sizeof(my_sockaddr)) != 0) { return -1; } } if (get_hostsockaddr(server, &server_addr) != 0) return -1; server_addr.sin_port = htons(server_port); if (connect(connection[out].ch_socket, (struct sockaddr *)&server_addr, sizeof(struct sockaddr)) == 0) { break; } else { /* connect attempt failed */ CLOSESOCKET(connection[out].ch_socket); pbs_errno = errno; } } if (i >= (have_alt+1)) { connection[out].ch_inuse = 0; return -1; /* cannot connect */ } #ifndef WIN32 if (have_alt && (i == 1)) { /* had to use the second listed server ... */ if (using_secondary == 1) { /* remove file that causes trying the Secondary first */ unlink(pbsrc); } else { /* create file that causes trying the Primary first */ f = open(pbsrc, O_WRONLY|O_CREAT, 0200); if (f != -1) (void)close(f); } } #endif /* setup connection level thread context */ if (pbs_client_thread_init_connect_context(out) != 0) { CLOSESOCKET(connection[out].ch_socket); connection[out].ch_inuse = 0; /* pbs_errno set by the pbs_connect_init_context routine */ return -1; } /* * No need for global lock now on, since rest of the code * is only communication on a connection handle. * But we dont need to lock the connection handle, since this * connection handle is not yet been returned to the client */ /* The following code was originally put in for HPUX systems to deal * with the issue where returning from the connect() call doesn't * mean the connection is complete. However, this has also been * experienced in some Linux ppc64 systems like js-2. Decision was * made to enable this harmless code for all architectures. * FIX: Need to use the socket to send * a message to complete the process. For IFF authentication there is * no leading authentication message needing to be sent on the client * socket, so will send a "dummy" message and discard the replyback. */ #if !defined(PBS_SECURITY ) || (PBS_SECURITY == STD ) DIS_tcp_setup(connection[out].ch_socket); if ((i = encode_DIS_ReqHdr(connection[out].ch_socket, PBS_BATCH_Connect, pbs_current_user)) || (i = encode_DIS_ReqExtend(connection[out].ch_socket, extend_data))) { pbs_errno = PBSE_SYSTEM; return -1; } if (DIS_tcp_wflush(connection[out].ch_socket)) { pbs_errno = PBSE_SYSTEM; return -1; } reply = PBSD_rdrpy(out); PBSD_FreeReply(reply); #endif /* PBS_SECURITY ... */ /*do configured authentication (kerberos, pbs_iff, whatever)*/ /*Get the socket port for engage_authentication() */ socknamelen = sizeof(sockname); if (getsockname(connection[out].ch_socket, (struct sockaddr *)&sockname, &socknamelen)) return -1; if (engage_authentication(connection[out].ch_socket, server, server_port, &sockname) == -1) { CLOSESOCKET(connection[out].ch_socket); connection[out].ch_inuse = 0; pbs_errno = PBSE_PERM; return -1; } /* setup DIS support routines for following pbs_* calls */ DIS_tcp_setup(connection[out].ch_socket); pbs_tcp_timeout = PBS_DIS_TCP_TIMEOUT_VLONG; /* set for 3 hours */ /* * Disable Nagle's algorithm on the TCP connection to server. * Nagle's algorithm is hurting cmd-server communication. */ if (pbs_connection_set_nodelay(out) == -1) { CLOSESOCKET(connection[out].ch_socket); connection[out].ch_inuse = 0; pbs_errno = PBSE_SYSTEM; return -1; } return out; }
int pbs_stagein( int c, char *jobid, char *location, char *extend) { int rc; int local_errno = 0; struct batch_reply *reply; int sock; struct tcp_chan *chan = NULL; if ((jobid == (char *)0) || (*jobid == '\0')) return (PBSE_IVALREQ); if (location == (char *)0) location = (char *)""; pthread_mutex_lock(connection[c].ch_mutex); sock = connection[c].ch_socket; /* setup DIS support routines for following DIS calls */ if ((chan = DIS_tcp_setup(sock)) == NULL) { pthread_mutex_unlock(connection[c].ch_mutex); rc = PBSE_PROTOCOL; return rc; } /* send stagein request, a run request with a different id */ else if ((rc = encode_DIS_ReqHdr(chan, PBS_BATCH_StageIn, pbs_current_user)) || (rc = encode_DIS_RunJob(chan, jobid, location, 0)) || (rc = encode_DIS_ReqExtend(chan, extend))) { connection[c].ch_errtxt = strdup(dis_emsg[rc]); pthread_mutex_unlock(connection[c].ch_mutex); DIS_tcp_cleanup(chan); return (PBSE_PROTOCOL); } if (DIS_tcp_wflush(chan)) { pthread_mutex_unlock(connection[c].ch_mutex); DIS_tcp_cleanup(chan); return (PBSE_PROTOCOL); } /* get reply */ reply = PBSD_rdrpy(&local_errno, c); rc = connection[c].ch_errno; pthread_mutex_unlock(connection[c].ch_mutex); PBSD_FreeReply(reply); DIS_tcp_cleanup(chan); return(rc); }
char *pbs_locjob_err( int c, char *jobid, char *extend, int *local_errno) { int rc; struct batch_reply *reply; char *ploc = (char *)0; int sock; struct tcp_chan *chan = NULL; if ((jobid == (char *)0) || (*jobid == '\0')) { *local_errno = PBSE_IVALREQ; return(NULL); } if ((c < 0) || (c >= PBS_NET_MAX_CONNECTIONS)) { return(NULL); } pthread_mutex_lock(connection[c].ch_mutex); sock = connection[c].ch_socket; /* setup DIS support routines for following DIS calls */ if ((chan = DIS_tcp_setup(sock)) == NULL) { pthread_mutex_unlock(connection[c].ch_mutex); return NULL; } else if ((rc = encode_DIS_ReqHdr(chan, PBS_BATCH_LocateJob, pbs_current_user)) || (rc = encode_DIS_JobId(chan, jobid)) || (rc = encode_DIS_ReqExtend(chan, extend))) { connection[c].ch_errtxt = strdup(dis_emsg[rc]); pthread_mutex_unlock(connection[c].ch_mutex); *local_errno = PBSE_PROTOCOL; DIS_tcp_cleanup(chan); return(NULL); } /* write data over tcp stream */ if (DIS_tcp_wflush(chan)) { pthread_mutex_unlock(connection[c].ch_mutex); *local_errno = PBSE_PROTOCOL; DIS_tcp_cleanup(chan); return(NULL); } /* read reply from stream */ reply = PBSD_rdrpy(local_errno,c); if (reply == NULL) { *local_errno = PBSE_PROTOCOL; } else if (reply->brp_choice != BATCH_REPLY_CHOICE_NULL && reply->brp_choice != BATCH_REPLY_CHOICE_Text && reply->brp_choice != BATCH_REPLY_CHOICE_Locate) { #ifndef NDEBUG fprintf(stderr, "advise: pbs_locjob\tUnexpected reply choice\n\n"); #endif /* NDEBUG */ *local_errno = PBSE_PROTOCOL; } else if (connection[c].ch_errno == 0) { ploc = strdup(reply->brp_un.brp_locate); } PBSD_FreeReply(reply); pthread_mutex_unlock(connection[c].ch_mutex); DIS_tcp_cleanup(chan); return(ploc); } /* END pbs_locjob_err() */
/** * @brief * encode a Job Credential Batch Request * * @param[in] c - socket descriptor * @param[in] type - credential type * @param[in] buf - credentials * @param[in] len - credential length * @param[in] rpp - indication for whether to use rpp * @param[in] msgid - msg id * * @return int * @retval 0 success * @retval !0(pbse error) error * */ int PBSD_jcred(int c, int type, char *buf, int len, int rpp, char **msgid) { int rc; struct batch_reply *reply = NULL; int sock; if (!rpp) { sock = connection[c].ch_socket; DIS_tcp_setup(sock); } else { sock = c; if ((rc = is_compose_cmd(sock, IS_CMD, msgid)) != DIS_SUCCESS) return rc; } #ifdef PBS_CRED_GRIDPROXY if (type == PBS_CREDTYPE_GRIDPROXY) { OM_uint32 major, minor; gss_buffer_desc input, output; /* OM_uint32 flag = GSS_C_CONF_FLAG|GSS_C_DELEG_FLAG; */ OM_uint32 flag = GSS_C_CONF_FLAG; gss_ctx_id_t context = GSS_C_NO_CONTEXT; OM_uint32 life; int ret; output.length = 0; input.length = 0; for (;;) { major = gss_init_sec_context(&minor, GSS_C_NO_CREDENTIAL, &context, GSS_C_NO_NAME, GSS_C_NO_OID, flag, 0, GSS_C_NO_CHANNEL_BINDINGS, &input, NULL, &output, NULL, NULL); if (reply) PBSD_FreeReply(reply); rc = PBSD_GSS_context(sock, output.value, output.length); if (rc) { connection[c].ch_errtxt = strdup(dis_emsg[rc]); if (connection[c].ch_errtxt == NULL) return (pbs_errno = PBSE_SYSTEM); return (pbs_errno = PBSE_PROTOCOL); } if (GSS_ERROR(major)) { connection[c].ch_errtxt = pbs_gss_error("gss_init_sec_context", major, minor); return (pbs_errno = PBSE_PROTOCOL); } reply = PBSD_rdrpy(c); if (reply == NULL) return (pbs_errno = PBSE_PROTOCOL); if (pbs_errno != PBSE_NONE) { PBSD_FreeReply(reply); return pbs_errno; } if (reply->brp_choice == BATCH_REPLY_CHOICE_Text) { input.length = reply->brp_un.brp_txt.brp_txtlen; input.value = reply->brp_un.brp_txt.brp_str; } else { input.length = 0; input.value = NULL; } if (input.length == 0 && (major & GSS_S_CONTINUE_NEEDED) == 0) break; } if (reply) PBSD_FreeReply(reply); (void)gss_release_buffer(&minor, &output); if (major != GSS_S_COMPLETE || context == GSS_C_NO_CONTEXT) { connection[c].ch_errtxt = strdup("context could not be established"); if (connection[c].ch_errtxt == NULL) return (pbs_errno = PBSE_SYSTEM); return (pbs_errno = PBSE_PROTOCOL); } input.value = buf; input.length = len; output.length = 0; major = gss_seal(&minor, context, 1, GSS_C_QOP_DEFAULT, &input, &ret, &output); if (major != GSS_S_COMPLETE) { connection[c].ch_errtxt = pbs_gss_error("gss_seal", major, minor); return (pbs_errno = PBSE_PROTOCOL); } if (ret == 0) { connection[c].ch_errtxt = strdup("confidentiality not available"); if (connection[c].ch_errtxt == NULL) return (pbs_errno = PBSE_SYSTEM); return (pbs_errno = PBSE_PROTOCOL); } buf = output.value; len = output.length; output.length = 0; major = gss_delete_sec_context(&minor, &context, &output); if (major == GSS_S_COMPLETE && output.length > 0) { (void)gss_process_context_token(&minor, context, &output); (void)gss_release_buffer(&minor, &output); } } #endif if ((rc =encode_DIS_ReqHdr(sock, PBS_BATCH_JobCred, pbs_current_user)) || (rc = encode_DIS_JobCred(sock, type, buf, len)) || (rc = encode_DIS_ReqExtend(sock, (char *)0))) { if (!rpp) { connection[c].ch_errtxt = strdup(dis_emsg[rc]); if (connection[c].ch_errtxt == NULL) return (pbs_errno = PBSE_SYSTEM); } return (pbs_errno = PBSE_PROTOCOL); } if (rpp) { pbs_errno = PBSE_NONE; if (rpp_flush(sock)) pbs_errno = PBSE_PROTOCOL; return (pbs_errno); } if (DIS_tcp_wflush(sock)) { return (pbs_errno = PBSE_PROTOCOL); } reply = PBSD_rdrpy(c); PBSD_FreeReply(reply); return connection[c].ch_errno; }
int __pbs_rerunjob(int c, char *jobid, char *extend) { int rc; struct batch_reply *reply; int sock; time_t old_tcp_timeout; if ((jobid == NULL) || (*jobid == '\0')) return (pbs_errno = PBSE_IVALREQ); sock = connection[c].ch_socket; /* initialize the thread context data, if not already initialized */ if (pbs_client_thread_init_thread_context() != 0) return pbs_errno; /* lock pthread mutex here for this connection */ /* blocking call, waits for mutex release */ if (pbs_client_thread_lock_connection(c) != 0) return pbs_errno; /* setup DIS support routines for following DIS calls */ DIS_tcp_setup(sock); if ((rc = encode_DIS_ReqHdr(sock, PBS_BATCH_Rerun, pbs_current_user)) || (rc = encode_DIS_JobId(sock, jobid)) || (rc = encode_DIS_ReqExtend(sock, extend))) { connection[c].ch_errtxt = strdup(dis_emsg[rc]); if (connection[c].ch_errtxt == NULL) { pbs_errno = PBSE_SYSTEM; } else { pbs_errno = PBSE_PROTOCOL; } (void)pbs_client_thread_unlock_connection(c); return pbs_errno; } /* write data */ if (DIS_tcp_wflush(sock)) { pbs_errno = PBSE_PROTOCOL; (void)pbs_client_thread_unlock_connection(c); return pbs_errno; } /* Set timeout value to very long value as rerun request */ /* goes from Server to Mom and may take a long time */ old_tcp_timeout = pbs_tcp_timeout; pbs_tcp_timeout = PBS_DIS_TCP_TIMEOUT_VLONG; /* read reply from stream into presentation element */ reply = PBSD_rdrpy(c); /* reset timeout */ pbs_tcp_timeout = old_tcp_timeout; PBSD_FreeReply(reply); rc = connection[c].ch_errno; /* unlock the thread lock and update the thread context data */ if (pbs_client_thread_unlock_connection(c) != 0) return pbs_errno; return rc; }
int send_request_to_remote_server( int conn, batch_request *request) { struct attropl *patrl; struct svrattrl *psvratl; int rc = PBSE_NONE; int tmp_rc = PBSE_NONE; int sock = 0; char log_buf[LOCAL_LOG_BUF_SIZE]; struct tcp_chan *chan = NULL; pthread_mutex_lock(connection[conn].ch_mutex); sock = connection[conn].ch_socket; pthread_mutex_unlock(connection[conn].ch_mutex); request->rq_conn = sock; if ((chan = DIS_tcp_setup(sock)) == NULL) { log_err(PBSE_MEM_MALLOC, __func__, "Could not allocate memory for socket buffer"); close_conn(sock, FALSE); return(PBSE_MEM_MALLOC); } /* the request is bound to another server, encode/send the request */ switch (request->rq_type) { case PBS_BATCH_DeleteJob: rc = PBSD_mgr_put( conn, PBS_BATCH_DeleteJob, MGR_CMD_DELETE, MGR_OBJ_JOB, request->rq_ind.rq_delete.rq_objname, NULL, NULL); break; case PBS_BATCH_HoldJob: attrl_fixlink(&request->rq_ind.rq_hold.rq_orig.rq_attr); psvratl = (struct svrattrl *)GET_NEXT(request->rq_ind.rq_hold.rq_orig.rq_attr); patrl = &psvratl->al_atopl; rc = PBSD_mgr_put( conn, PBS_BATCH_HoldJob, MGR_CMD_SET, MGR_OBJ_JOB, request->rq_ind.rq_hold.rq_orig.rq_objname, patrl, NULL); break; case PBS_BATCH_CheckpointJob: rc = PBSD_mgr_put( conn, PBS_BATCH_CheckpointJob, MGR_CMD_SET, MGR_OBJ_JOB, request->rq_ind.rq_hold.rq_orig.rq_objname, NULL, NULL); break; case PBS_BATCH_GpuCtrl: rc = PBSD_gpu_put( conn, request->rq_ind.rq_gpuctrl.rq_momnode, request->rq_ind.rq_gpuctrl.rq_gpuid, request->rq_ind.rq_gpuctrl.rq_gpumode, request->rq_ind.rq_gpuctrl.rq_reset_perm, request->rq_ind.rq_gpuctrl.rq_reset_vol, NULL); break; case PBS_BATCH_MessJob: rc = PBSD_msg_put( conn, request->rq_ind.rq_message.rq_jid, request->rq_ind.rq_message.rq_file, request->rq_ind.rq_message.rq_text, NULL); break; case PBS_BATCH_ModifyJob: case PBS_BATCH_AsyModifyJob: attrl_fixlink(&request->rq_ind.rq_modify.rq_attr); patrl = (struct attropl *) & ((struct svrattrl *)GET_NEXT( request->rq_ind.rq_modify.rq_attr))->al_atopl; rc = PBSD_mgr_put( conn, request->rq_type, MGR_CMD_SET, MGR_OBJ_JOB, request->rq_ind.rq_modify.rq_objname, patrl, NULL); break; case PBS_BATCH_Rerun: if ((rc = encode_DIS_ReqHdr(chan, PBS_BATCH_Rerun, msg_daemonname))) break; if ((rc = encode_DIS_JobId(chan, request->rq_ind.rq_rerun))) break; if ((rc = encode_DIS_ReqExtend(chan, 0))) break; rc = DIS_tcp_wflush(chan); break; case PBS_BATCH_RegistDep: if ((rc = encode_DIS_ReqHdr(chan, PBS_BATCH_RegistDep, msg_daemonname))) break; if ((rc = encode_DIS_Register(chan, request))) break; if ((rc = encode_DIS_ReqExtend(chan, 0))) break; rc = DIS_tcp_wflush(chan); break; case PBS_BATCH_AsySignalJob: case PBS_BATCH_SignalJob: rc = PBSD_sig_put( conn, request->rq_ind.rq_signal.rq_jid, request->rq_ind.rq_signal.rq_signame, request->rq_extra); break; case PBS_BATCH_StatusJob: rc = PBSD_status_put( conn, PBS_BATCH_StatusJob, request->rq_ind.rq_status.rq_id, NULL, NULL); break; case PBS_BATCH_TrackJob: if ((rc = encode_DIS_ReqHdr(chan, PBS_BATCH_TrackJob, msg_daemonname))) break; if ((rc = encode_DIS_TrackJob(chan, request))) break; if ((rc = encode_DIS_ReqExtend(chan, 0))) break; rc = DIS_tcp_wflush(chan); break; case PBS_BATCH_ReturnFiles: if ((rc = encode_DIS_ReqHdr(chan, PBS_BATCH_ReturnFiles, msg_daemonname))) break; if ((rc = encode_DIS_ReturnFiles(chan, request))) break; if ((rc = encode_DIS_ReqExtend(chan, 0))) break; rc = DIS_tcp_wflush(chan); break; case PBS_BATCH_CopyFiles: if ((rc = encode_DIS_ReqHdr(chan, PBS_BATCH_CopyFiles, msg_daemonname))) break; if ((rc = encode_DIS_CopyFiles(chan, request))) break; if ((rc = encode_DIS_ReqExtend(chan, 0))) break; rc = DIS_tcp_wflush(chan); break; case PBS_BATCH_DelFiles: if ((rc = encode_DIS_ReqHdr(chan, PBS_BATCH_DelFiles, msg_daemonname))) break; if ((rc = encode_DIS_CopyFiles(chan, request))) break; if ((rc = encode_DIS_ReqExtend(chan, 0))) break; rc = DIS_tcp_wflush(chan); break; case PBS_BATCH_DeleteReservation: if ((rc = encode_DIS_ReqHdr(chan, PBS_BATCH_DeleteReservation, msg_daemonname))) break; if ((rc = encode_DIS_ReqExtend(chan, request->rq_extend))) break; rc = DIS_tcp_wflush(chan); break; default: sprintf(log_buf, msg_issuebad, request->rq_type); log_err(-1, __func__, log_buf); rc = -1; break; } /* END switch (request->rq_type) */ if ((tmp_rc = DIS_reply_read(chan, &request->rq_reply)) != 0) { sprintf(log_buf, "DIS_reply_read failed: %d", tmp_rc); log_record(PBSEVENT_JOB, PBS_EVENTCLASS_JOB, __func__, log_buf); request->rq_reply.brp_code = tmp_rc; request->rq_reply.brp_choice = BATCH_REPLY_CHOICE_NULL; } DIS_tcp_cleanup(chan); svr_disconnect(conn); return(rc); } /* END send_request_to_remote_server() */
int pbs_asyrunjob_err( int c, char *jobid, /* I */ char *location, char *extend, int *local_errno) { int rc; struct batch_reply *reply; unsigned int resch = 0; int sock; struct tcp_chan *chan = NULL; if ((c < 0) || (jobid == NULL) || (*jobid == '\0')) { return(PBSE_IVALREQ); } if (location == NULL) location = ""; pthread_mutex_lock(connection[c].ch_mutex); sock = connection[c].ch_socket; /* setup DIS support routines for following DIS calls */ if ((chan = DIS_tcp_setup(sock)) == NULL) { rc = PBSE_PROTOCOL; return rc; } else if ((rc = encode_DIS_ReqHdr(chan, PBS_BATCH_AsyrunJob, pbs_current_user)) || (rc = encode_DIS_RunJob(chan, jobid, location, resch)) || (rc = encode_DIS_ReqExtend(chan, extend))) { connection[c].ch_errtxt = strdup(dis_emsg[rc]); pthread_mutex_unlock(connection[c].ch_mutex); DIS_tcp_cleanup(chan); return(PBSE_PROTOCOL); } if (DIS_tcp_wflush(chan)) { pthread_mutex_unlock(connection[c].ch_mutex); DIS_tcp_cleanup(chan); return(PBSE_PROTOCOL); } /* get reply */ reply = PBSD_rdrpy(local_errno, c); rc = connection[c].ch_errno; pthread_mutex_unlock(connection[c].ch_mutex); PBSD_FreeReply(reply); DIS_tcp_cleanup(chan); return(rc); } /* END pbs_asyrunjob_err() */
int PBSD_commit_get_sid( int connect, /* I */ long *sid, /* O */ char *jobid) /* I */ { struct batch_reply *reply; int rc; int sock; int local_errno = 0; struct tcp_chan *chan = NULL; pthread_mutex_lock(connection[connect].ch_mutex); sock = connection[connect].ch_socket; pthread_mutex_unlock(connection[connect].ch_mutex); if ((chan = DIS_tcp_setup(sock)) == NULL) { return(PBSE_MEM_MALLOC); } else if ((rc = encode_DIS_ReqHdr(chan, PBS_BATCH_Commit, pbs_current_user)) || (rc = encode_DIS_JobId(chan, jobid)) || (rc = encode_DIS_ReqExtend(chan, NULL))) { pthread_mutex_lock(connection[connect].ch_mutex); connection[connect].ch_errtxt = strdup(dis_emsg[rc]); pthread_mutex_unlock(connection[connect].ch_mutex); DIS_tcp_cleanup(chan); return(PBSE_PROTOCOL); } if (DIS_tcp_wflush(chan)) { DIS_tcp_cleanup(chan); return(PBSE_PROTOCOL); } DIS_tcp_cleanup(chan); /* PBSD_rdrpy sets connection[connect].ch_errno */ reply = PBSD_rdrpy(&local_errno, connect); pthread_mutex_lock(connection[connect].ch_mutex); rc = connection[connect].ch_errno; pthread_mutex_unlock(connection[connect].ch_mutex); if (reply == NULL) { /* couldn't read a response */ if (rc == PBSE_NONE) rc = PBSE_PROTOCOL; } else { /* read the sid if given and no error */ if (rc == PBSE_NONE) { if (reply->brp_choice == BATCH_REPLY_CHOICE_Text) { if (sid != NULL) *sid = atol(reply->brp_un.brp_txt.brp_str); } else /* (reply->brp_choice == BATCH_REPLY_CHOICE_NULL) */ { *sid = reply->brp_code; } } PBSD_FreeReply(reply); } return(rc); } /* END PBSD_commit_get_sid() */
int pbs_original_connect( char *server) /* I (FORMAT: NULL | '\0' | HOSTNAME | HOSTNAME:PORT )*/ { struct sockaddr_in server_addr; struct hostent *hp; int out; int i; #ifdef GSSAPI int neediff = 0; #endif int auth; struct passwd *pw; int use_unixsock = 0; #ifdef ENABLE_UNIX_SOCKETS struct sockaddr_un unserver_addr; char hnamebuf[256]; #endif char *ptr; /* reserve a connection state record */ out = -1; for (i = 1;i < NCONNECTS;i++) { if (connection[i].ch_inuse) continue; out = i; connection[out].ch_inuse = 1; connection[out].ch_errno = 0; connection[out].ch_socket = -1; connection[out].ch_errtxt = NULL; break; } if (out < 0) { pbs_errno = PBSE_NOCONNECTS; if (getenv("PBSDEBUG")) fprintf(stderr, "ALERT: cannot locate free channel\n"); /* FAILURE */ return(-1); } /* get server host and port */ server = PBS_get_server(server, &server_port); if (server == NULL) { connection[out].ch_inuse = 0; pbs_errno = PBSE_NOSERVER; if (getenv("PBSDEBUG")) fprintf(stderr, "ALERT: PBS_get_server() failed\n"); return(-1); } /* determine who we are */ pbs_current_uid = getuid(); if ((pw = getpwuid(pbs_current_uid)) == NULL) { pbs_errno = PBSE_SYSTEM; if (getenv("PBSDEBUG")) { fprintf(stderr, "ALERT: cannot get password info for uid %ld\n", (long)pbs_current_uid); } return(-1); } strcpy(pbs_current_user, pw->pw_name); pbs_server = server; /* set for error messages from commands */ #ifdef ENABLE_UNIX_SOCKETS /* determine if we want to use unix domain socket */ if (!strcmp(server, "localhost")) use_unixsock = 1; else if ((gethostname(hnamebuf, sizeof(hnamebuf) - 1) == 0) && !strcmp(hnamebuf, server)) use_unixsock = 1; /* NOTE: if any part of using unix domain sockets fails, * we just cleanup and try again with inet sockets */ /* get socket */ if (use_unixsock) { connection[out].ch_socket = socket(AF_UNIX, SOCK_STREAM, 0); if (connection[out].ch_socket < 0) { if (getenv("PBSDEBUG")) { fprintf(stderr, "ERROR: cannot create socket: errno=%d (%s)\n", errno, strerror(errno)); } connection[out].ch_inuse = 0; pbs_errno = PBSE_PROTOCOL; use_unixsock = 0; } } /* and connect... */ if (use_unixsock) { unserver_addr.sun_family = AF_UNIX; strcpy(unserver_addr.sun_path, TSOCK_PATH); if (connect( connection[out].ch_socket, (struct sockaddr *)&unserver_addr, (strlen(unserver_addr.sun_path) + sizeof(unserver_addr.sun_family))) < 0) { close(connection[out].ch_socket); connection[out].ch_inuse = 0; pbs_errno = errno; if (getenv("PBSDEBUG")) { fprintf(stderr, "ERROR: cannot connect to server, errno=%d (%s)\n", errno, strerror(errno)); } use_unixsock = 0; /* will try again with inet socket */ } } if (use_unixsock) { if (!send_unix_creds(connection[out].ch_socket)) { if (getenv("PBSDEBUG")) { fprintf(stderr, "ERROR: cannot send unix creds to pbs_server: errno=%d (%s)\n", errno, strerror(errno)); } close(connection[out].ch_socket); connection[out].ch_inuse = 0; pbs_errno = PBSE_PROTOCOL; use_unixsock = 0; /* will try again with inet socket */ } } #endif /* END ENABLE_UNIX_SOCKETS */ if (!use_unixsock) { /* at this point, either using unix sockets failed, or we determined not to * try */ connection[out].ch_socket = socket(AF_INET, SOCK_STREAM, 0); if (connection[out].ch_socket < 0) { if (getenv("PBSDEBUG")) { fprintf(stderr, "ERROR: cannot connect to server \"%s\", errno=%d (%s)\n", server, errno, strerror(errno)); } connection[out].ch_inuse = 0; pbs_errno = PBSE_PROTOCOL; return(-1); } /* connection succeeded re-mark as used */ connection[out].ch_inuse = 1; server_addr.sin_family = AF_INET; hp = NULL; hp = gethostbyname(server); /* setup DIS support routines for following pbs_* calls */ if (hp == NULL) { close(connection[out].ch_socket); connection[out].ch_inuse = 0; pbs_errno = PBSE_BADHOST; if (getenv("PBSDEBUG")) { fprintf(stderr, "ERROR: cannot get servername (%s) errno=%d (%s)\n", (server != NULL) ? server : "NULL", errno, strerror(errno)); } return(-1); } memcpy((char *)&server_addr.sin_addr, hp->h_addr_list[0], hp->h_length); server_addr.sin_port = htons(server_port); if (connect( connection[out].ch_socket, (struct sockaddr *)&server_addr, sizeof(server_addr)) < 0) { close(connection[out].ch_socket); connection[out].ch_inuse = 0; pbs_errno = errno; if (getenv("PBSDEBUG")) { fprintf(stderr, "ERROR: cannot connect to server, errno=%d (%s)\n", errno, strerror(errno)); } return(-1); } DIS_tcp_setup(connection[out].ch_socket); if ((ptr = getenv("PBSAPITIMEOUT")) != NULL) { pbs_tcp_timeout = strtol(ptr,NULL,0); if (pbs_tcp_timeout <= 0) { pbs_tcp_timeout = 10800; /* set for 3 hour time out */ } } else { pbs_tcp_timeout = 10800; /* set for 3 hour time out */ } /* If we have GSSAPI, then try gssapi authentication first. If that fails, fall back to iff. If there's no GSSAPI, then just use iff. */ #ifdef GSSAPI if (!getenv("TORQUE_IGNORE_KERBEROS") && !ignore_kerberos_for_connection && pbsgss_can_get_creds()) { if (encode_DIS_ReqHdr(connection[out].ch_socket, PBS_BATCH_GSSAuthenUser, pbs_current_user) || encode_DIS_ReqExtend(connection[out].ch_socket,0)) { if (getenv("PBSDEBUG")) { fprintf(stderr,"ERROR: cannot authenticate connection with gssapi, errno=%d (%s)\n", errno, strerror(errno)); } neediff = 1; } else { DIS_tcp_wflush(connection[out].ch_socket); if (pbsgss_client_authenticate(server,connection[out].ch_socket,1,1) != 0) { neediff = 1; if (getenv("PBSDEBUG")) { fprintf(stderr,"ERROR: cannot authenticate connection, errno=%d (%s)\n", errno, strerror(errno)); } } } } else { neediff = 1; } if (neediff) { #endif /* FIXME: is this necessary? Contributed by one user that fixes a problem, but doesn't fix the same problem for another user! */ #if 0 #if defined(__hpux) /*HP-UX : avoiding socket caching */ send(connection[out].ch_socket, '?', 1, MSG_OOB); #endif #endif /* Have pbs_iff authenticate connection */ if ((ENABLE_TRUSTED_AUTH == FALSE) && ((auth = PBSD_authenticate(connection[out].ch_socket)) != 0)) { close(connection[out].ch_socket); connection[out].ch_inuse = 0; if (auth == ENOENT) { pbs_errno = ENOENT; if (getenv("PBSDEBUG")) { fprintf(stderr, "ERROR: cannot find pbs_iif executable\n"); } } else { pbs_errno = PBSE_PERM; if (getenv("PBSDEBUG")) { fprintf(stderr, "ERROR: cannot authenticate connection to server \"%s\", errno=%d (%s)\n", server, errno, strerror(errno)); } } return(-1); } #ifdef GSSAPI } /* END if neediff */ #endif } /* END !useunix */ DIS_tcp_setup(connection[out].ch_socket); if ((ptr = getenv("PBSAPITIMEOUT")) != NULL) { pbs_tcp_timeout = strtol(ptr, NULL, 0); if (pbs_tcp_timeout <= 0) { pbs_tcp_timeout = 10800; /* set for 3 hour time out */ } } else { pbs_tcp_timeout = 10800; /* set for 3 hour time out */ } return(out); } /* END pbs_original_connect() */
static int PBSD_scbuf( int c, /* connection handle */ int reqtype, /* request type */ int seq, /* file chunk sequence number */ char *buf, /* file chunk */ int len, /* length of chunk */ char *jobid, /* job id (for types 1 and 2 only) */ enum job_file which) /* standard file type, see libpbs.h */ { struct batch_reply *reply; int rc; int sock; int local_errno = 0; struct tcp_chan *chan = NULL; pthread_mutex_lock(connection[c].ch_mutex); sock = connection[c].ch_socket; pthread_mutex_unlock(connection[c].ch_mutex); if ((chan = DIS_tcp_setup(sock)) == NULL) { return(PBSE_MEM_MALLOC); } else if (jobid == NULL) jobid = ""; /* use null string for null pointer */ if ((rc = encode_DIS_ReqHdr(chan, reqtype, pbs_current_user)) || (rc = encode_DIS_JobFile(chan, seq, buf, len, jobid, which)) || (rc = encode_DIS_ReqExtend(chan, NULL))) { pthread_mutex_lock(connection[c].ch_mutex); connection[c].ch_errtxt = strdup(dis_emsg[rc]); pthread_mutex_unlock(connection[c].ch_mutex); DIS_tcp_cleanup(chan); return(PBSE_PROTOCOL); } if (DIS_tcp_wflush(chan)) { DIS_tcp_cleanup(chan); return(PBSE_PROTOCOL); } DIS_tcp_cleanup(chan); /* read reply */ reply = PBSD_rdrpy(&local_errno, c); PBSD_FreeReply(reply); pthread_mutex_lock(connection[c].ch_mutex); rc = connection[c].ch_errno; pthread_mutex_unlock(connection[c].ch_mutex); return(rc); }
int PBSD_munge_authenticate( int psock, /* I */ int handle) /* I */ { int rc; munge_ctx_t mctx = NULL; munge_err_t mret = EMUNGE_SNAFU; char *mcred = NULL; /* user id and name stuff */ struct passwd *pwent; uid_t myrealuid; struct batch_reply *reply; unsigned short user_port = 0; struct sockaddr_in sockname; socklen_t socknamelen = sizeof(sockname); struct tcp_chan *chan; if ((mctx = munge_ctx_create()) == NULL) { return(-1); } if ((mret = munge_encode (&mcred, mctx, NULL, 0)) != EMUNGE_SUCCESS) { const char *merrmsg = NULL; if (!(merrmsg = munge_ctx_strerror(mctx))) { merrmsg = munge_strerror(mret); } fprintf(stderr, "munge_encode failed: %s (%d)\n", merrmsg, mret); munge_ctx_destroy(mctx); return(PBSE_MUNGE_NOT_FOUND); /*TODO more fine-grained error codes? */ } munge_ctx_destroy(mctx); /* We got the certificate. Now make the PBS_BATCH_AltAuthenUser request */ myrealuid = getuid(); pwent = getpwuid(myrealuid); rc = getsockname(psock, (struct sockaddr *)&sockname, &socknamelen); if (rc == -1) { fprintf(stderr, "getsockname failed: %d\n", errno); return(-1); } user_port = ntohs(sockname.sin_port); if ((chan = DIS_tcp_setup(psock)) == NULL) { } else if ((rc = encode_DIS_ReqHdr(chan, PBS_BATCH_AltAuthenUser, pwent->pw_name)) || (rc = diswui(chan, user_port)) || (rc = diswst(chan, mcred)) || (rc = encode_DIS_ReqExtend(chan, NULL)) || (rc = DIS_tcp_wflush(chan))) { PBSD_munge_cred_destroy(&mcred); /* ERROR */ return(rc); } else { int local_err = PBSE_NONE; PBSD_munge_cred_destroy(&mcred); /* read the reply */ if ((reply = PBSD_rdrpy(&local_err, handle)) != NULL) free(reply); return(PBSE_NONE); } return(-1); }
int issue_Drequest( int conn, struct batch_request *request, void (*func) (struct work_task *), struct work_task **ppwt) { struct attropl *patrl; struct work_task *ptask; struct svrattrl *psvratl; int rc; int sock = 0; enum work_type wt; char *id = "issue_Drequest"; if (conn == PBS_LOCAL_CONNECTION) { wt = WORK_Deferred_Local; request->rq_conn = PBS_LOCAL_CONNECTION; } else { sock = connection[conn].ch_socket; request->rq_conn = sock; wt = WORK_Deferred_Reply; DIS_tcp_setup(sock); } ptask = set_task(wt, (long)conn, func, (void *)request); if (ptask == NULL) { log_err(errno, id, "could not set_task"); if (ppwt != NULL) *ppwt = 0; return(-1); } if (conn == PBS_LOCAL_CONNECTION) { /* the request should be issued to ourself */ dispatch_request(PBS_LOCAL_CONNECTION, request); if (ppwt != NULL) *ppwt = ptask; return(0); } /* the request is bound to another server, encode/send the request */ switch (request->rq_type) { #ifndef PBS_MOM case PBS_BATCH_DeleteJob: rc = PBSD_mgr_put( conn, PBS_BATCH_DeleteJob, MGR_CMD_DELETE, MGR_OBJ_JOB, request->rq_ind.rq_delete.rq_objname, NULL, NULL); break; case PBS_BATCH_HoldJob: attrl_fixlink(&request->rq_ind.rq_hold.rq_orig.rq_attr); psvratl = (struct svrattrl *)GET_NEXT(request->rq_ind.rq_hold.rq_orig.rq_attr); patrl = &psvratl->al_atopl; rc = PBSD_mgr_put( conn, PBS_BATCH_HoldJob, MGR_CMD_SET, MGR_OBJ_JOB, request->rq_ind.rq_hold.rq_orig.rq_objname, patrl, NULL); break; case PBS_BATCH_CheckpointJob: rc = PBSD_mgr_put( conn, PBS_BATCH_CheckpointJob, MGR_CMD_SET, MGR_OBJ_JOB, request->rq_ind.rq_hold.rq_orig.rq_objname, NULL, NULL); break; case PBS_BATCH_GpuCtrl: rc = PBSD_gpu_put( conn, request->rq_ind.rq_gpuctrl.rq_momnode, request->rq_ind.rq_gpuctrl.rq_gpuid, request->rq_ind.rq_gpuctrl.rq_gpumode, request->rq_ind.rq_gpuctrl.rq_reset_perm, request->rq_ind.rq_gpuctrl.rq_reset_vol, NULL); break; case PBS_BATCH_MessJob: rc = PBSD_msg_put( conn, request->rq_ind.rq_message.rq_jid, request->rq_ind.rq_message.rq_file, request->rq_ind.rq_message.rq_text, NULL); break; case PBS_BATCH_ModifyJob: case PBS_BATCH_AsyModifyJob: attrl_fixlink(&request->rq_ind.rq_modify.rq_attr); patrl = (struct attropl *) & ((struct svrattrl *)GET_NEXT( request->rq_ind.rq_modify.rq_attr))->al_atopl; rc = PBSD_mgr_put( conn, request->rq_type, MGR_CMD_SET, MGR_OBJ_JOB, request->rq_ind.rq_modify.rq_objname, patrl, NULL); break; case PBS_BATCH_Rerun: if ((rc = encode_DIS_ReqHdr(sock, PBS_BATCH_Rerun, msg_daemonname))) break; if ((rc = encode_DIS_JobId(sock, request->rq_ind.rq_rerun))) break; if ((rc = encode_DIS_ReqExtend(sock, 0))) break; rc = DIS_tcp_wflush(sock); break; case PBS_BATCH_RegistDep: if ((rc = encode_DIS_ReqHdr(sock, PBS_BATCH_RegistDep, msg_daemonname))) break; if ((rc = encode_DIS_Register(sock, request))) break; if ((rc = encode_DIS_ReqExtend(sock, 0))) break; rc = DIS_tcp_wflush(sock); break; case PBS_BATCH_AsySignalJob: case PBS_BATCH_SignalJob: rc = PBSD_sig_put( conn, request->rq_ind.rq_signal.rq_jid, request->rq_ind.rq_signal.rq_signame, request->rq_extra); break; case PBS_BATCH_StatusJob: rc = PBSD_status_put( conn, PBS_BATCH_StatusJob, request->rq_ind.rq_status.rq_id, NULL, NULL); break; case PBS_BATCH_TrackJob: if ((rc = encode_DIS_ReqHdr(sock, PBS_BATCH_TrackJob, msg_daemonname))) break; if ((rc = encode_DIS_TrackJob(sock, request))) break; if ((rc = encode_DIS_ReqExtend(sock, 0))) break; rc = DIS_tcp_wflush(sock); break; case PBS_BATCH_ReturnFiles: if ((rc = encode_DIS_ReqHdr(sock, PBS_BATCH_ReturnFiles, msg_daemonname))) break; if ((rc = encode_DIS_ReturnFiles(sock, request))) break; if ((rc = encode_DIS_ReqExtend(sock, 0))) break; rc = DIS_tcp_wflush(sock); break; case PBS_BATCH_CopyFiles: if ((rc = encode_DIS_ReqHdr(sock, PBS_BATCH_CopyFiles, msg_daemonname))) break; if ((rc = encode_DIS_CopyFiles(sock, request))) break; if ((rc = encode_DIS_ReqExtend(sock, 0))) break; rc = DIS_tcp_wflush(sock); break; case PBS_BATCH_DelFiles: if ((rc = encode_DIS_ReqHdr(sock, PBS_BATCH_DelFiles, msg_daemonname))) break; if ((rc = encode_DIS_CopyFiles(sock, request))) break; if ((rc = encode_DIS_ReqExtend(sock, 0))) break; rc = DIS_tcp_wflush(sock); break; #else /* PBS_MOM */ case PBS_BATCH_JobObit: /* who is sending obit request? */ if ((rc = encode_DIS_ReqHdr(sock, PBS_BATCH_JobObit, msg_daemonname))) break; if ((rc = encode_DIS_JobObit(sock, request))) break; if ((rc = encode_DIS_ReqExtend(sock, 0))) break; rc = DIS_tcp_wflush(sock); break; #endif /* PBS_MOM */ default: sprintf(log_buffer, msg_issuebad, request->rq_type); log_err(-1, id, log_buffer); delete_task(ptask); rc = -1; break; } /* END switch (request->rq_type) */ if (ppwt != NULL) *ppwt = ptask; return(rc); } /* END issue_Drequest() */