summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2015-08-08 13:49:04 -0700
committerRobin H. Johnson <robbat2@gentoo.org>2015-08-08 17:38:18 -0700
commit56bd759df1d0c750a065b8c845e93d5dfa6b549d (patch)
tree3f91093cdb475e565ae857f1c5a7fd339e2d781e /sys-cluster/torque/files
downloadgentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.tar.gz
gentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.tar.bz2
gentoo-56bd759df1d0c750a065b8c845e93d5dfa6b549d.zip
proj/gentoo: Initial commit
This commit represents a new era for Gentoo: Storing the gentoo-x86 tree in Git, as converted from CVS. This commit is the start of the NEW history. Any historical data is intended to be grafted onto this point. Creation process: 1. Take final CVS checkout snapshot 2. Remove ALL ChangeLog* files 3. Transform all Manifests to thin 4. Remove empty Manifests 5. Convert all stale $Header$/$Id$ CVS keywords to non-expanded Git $Id$ 5.1. Do not touch files with -kb/-ko keyword flags. Signed-off-by: Robin H. Johnson <robbat2@gentoo.org> X-Thanks: Alec Warner <antarus@gentoo.org> - did the GSoC 2006 migration tests X-Thanks: Robin H. Johnson <robbat2@gentoo.org> - infra guy, herding this project X-Thanks: Nguyen Thai Ngoc Duy <pclouds@gentoo.org> - Former Gentoo developer, wrote Git features for the migration X-Thanks: Brian Harring <ferringb@gentoo.org> - wrote much python to improve cvs2svn X-Thanks: Rich Freeman <rich0@gentoo.org> - validation scripts X-Thanks: Patrick Lauer <patrick@gentoo.org> - Gentoo dev, running new 2014 work in migration X-Thanks: Michał Górny <mgorny@gentoo.org> - scripts, QA, nagging X-Thanks: All of other Gentoo developers - many ideas and lots of paint on the bikeshed
Diffstat (limited to 'sys-cluster/torque/files')
-rw-r--r--sys-cluster/torque/files/CVE-2013-4319-2.x-root-submit-fix.patch40
-rw-r--r--sys-cluster/torque/files/CVE-2013-4319-4.x-root-submit-fix.patch38
-rw-r--r--sys-cluster/torque/files/CVE-2013-4495.4.1.patch343
-rw-r--r--sys-cluster/torque/files/CVE-2013-4495.patch32
-rw-r--r--sys-cluster/torque/files/CVE-2014-0749.patch32
-rw-r--r--sys-cluster/torque/files/TRQ-2885-limit-tm_adopt-to-only-adopt-a-session-id-t.patch134
-rw-r--r--sys-cluster/torque/files/pbs_mom-init.d48
-rw-r--r--sys-cluster/torque/files/pbs_mom-init.d-munge48
-rw-r--r--sys-cluster/torque/files/pbs_sched-init.d48
-rw-r--r--sys-cluster/torque/files/pbs_server-init.d60
-rw-r--r--sys-cluster/torque/files/pbs_server-init.d-munge61
-rw-r--r--sys-cluster/torque/files/tcl8.6.patch87
-rw-r--r--sys-cluster/torque/files/torque-4.1.5.1-tcl8.6.patch93
-rw-r--r--sys-cluster/torque/files/torque-4.2.9-tcl8.6.patch99
-rw-r--r--sys-cluster/torque/files/torque-conf.d14
-rw-r--r--sys-cluster/torque/files/torque-conf.d-munge18
-rw-r--r--sys-cluster/torque/files/torque-env.d7
-rw-r--r--sys-cluster/torque/files/trqauthd-init.d27
18 files changed, 1229 insertions, 0 deletions
diff --git a/sys-cluster/torque/files/CVE-2013-4319-2.x-root-submit-fix.patch b/sys-cluster/torque/files/CVE-2013-4319-2.x-root-submit-fix.patch
new file mode 100644
index 000000000000..aa53239f157c
--- /dev/null
+++ b/sys-cluster/torque/files/CVE-2013-4319-2.x-root-submit-fix.patch
@@ -0,0 +1,40 @@
+From 5dee0365a56dd2cc4cfd0b182bc843b4f32c086c Mon Sep 17 00:00:00 2001
+From: Justin Bronder <jsbronder@gmail.com>
+Date: Mon, 23 Dec 2013 12:40:27 -0500
+Subject: [PATCH] CVE-2013-4319: 2.x root submit fix
+
+https://bugs.gentoo.org/show_bug.cgi?id=484320
+http://nvd.nist.gov/nvd.cfm?cvename=CVE-2013-4319\
+---
+ src/server/process_request.c | 15 +++++++++++++++
+ 1 file changed, 15 insertions(+)
+
+diff --git a/src/server/process_request.c b/src/server/process_request.c
+index d4a3c92..b06a333 100644
+--- a/src/server/process_request.c
++++ b/src/server/process_request.c
+@@ -640,6 +640,21 @@ void process_request(
+ log_buffer);
+ }
+
++ if (svr_conn[sfds].cn_authen != PBS_NET_CONN_FROM_PRIVIL)
++ {
++ sprintf(log_buffer, "request type %s from host %s rejected (connection not privileged)",
++ reqtype_to_txt(request->rq_type),
++ request->rq_host);
++
++ log_record(PBSEVENT_JOB, PBS_EVENTCLASS_JOB, id, log_buffer);
++
++ req_reject(PBSE_BADHOST, 0, request, NULL, "request not authorized");
++
++ close_client(sfds);
++
++ return;
++ }
++
+ if (!tfind(svr_conn[sfds].cn_addr, &okclients))
+ {
+ sprintf(log_buffer, "request type %s from host %s rejected (host not authorized)",
+--
+1.8.3.2
+
diff --git a/sys-cluster/torque/files/CVE-2013-4319-4.x-root-submit-fix.patch b/sys-cluster/torque/files/CVE-2013-4319-4.x-root-submit-fix.patch
new file mode 100644
index 000000000000..3614e42721de
--- /dev/null
+++ b/sys-cluster/torque/files/CVE-2013-4319-4.x-root-submit-fix.patch
@@ -0,0 +1,38 @@
+From 6424696d7b160c8a9ad806c4a6b0f77f0d359962 Mon Sep 17 00:00:00 2001
+From: Justin Bronder <jsbronder@gmail.com>
+Date: Mon, 23 Dec 2013 12:48:22 -0500
+Subject: [PATCH] CVE-2013-4319: 4.x root submit fix
+
+https://bugs.gentoo.org/show_bug.cgi?id=484320
+http://nvd.nist.gov/nvd.cfm?cvename=CVE-2013-4319
+---
+ src/resmom/mom_process_request.c | 13 +++++++++++++
+ 1 file changed, 13 insertions(+)
+
+diff --git a/src/resmom/mom_process_request.c b/src/resmom/mom_process_request.c
+index 049f63f..813833f 100644
+--- a/src/resmom/mom_process_request.c
++++ b/src/resmom/mom_process_request.c
+@@ -238,6 +238,19 @@ void *mom_process_request(
+ log_record(PBSEVENT_JOB, PBS_EVENTCLASS_JOB, __func__, log_buffer);
+ }
+
++ if (svr_conn[chan->sock].cn_authen != PBS_NET_CONN_FROM_PRIVIL)
++ {
++ sprintf(log_buffer, "request type %s from host %s rejected (connection not privileged)",
++ reqtype_to_txt(request->rq_type),
++ request->rq_host);
++
++ log_record(PBSEVENT_JOB, PBS_EVENTCLASS_JOB, __func__, log_buffer);
++ req_reject(PBSE_BADHOST, 0, request, NULL, "request not authorized");
++ mom_close_client(chan->sock);
++ DIS_tcp_cleanup(chan);
++ return NULL;
++ }
++
+ if (!AVL_is_in_tree_no_port_compare(svr_conn[chan->sock].cn_addr, 0, okclients))
+ {
+ sprintf(log_buffer, "request type %s from host %s rejected (host not authorized)",
+--
+1.8.3.2
+
diff --git a/sys-cluster/torque/files/CVE-2013-4495.4.1.patch b/sys-cluster/torque/files/CVE-2013-4495.4.1.patch
new file mode 100644
index 000000000000..810a4f0944a5
--- /dev/null
+++ b/sys-cluster/torque/files/CVE-2013-4495.4.1.patch
@@ -0,0 +1,343 @@
+From 2aad72c3d2ac612ecbb66828ac6ed5ab51eff5f3 Mon Sep 17 00:00:00 2001
+From: David Beer <dbeer@adaptivecomputing.com>
+Date: Mon, 11 Nov 2013 11:55:58 -0700
+Subject: [PATCH] Fix CVE 2013-4495. Note: this patch has been verified as
+ fixing this security hole but has not received other regression testing.
+ Could not cherry-pick as 2.5 and 4.1 are very different.
+
+---
+ src/server/svr_mail.c | 265 ++++++++++++++++++++++++++++++++------------------
+ 1 file changed, 170 insertions(+), 95 deletions(-)
+
+diff --git a/src/server/svr_mail.c b/src/server/svr_mail.c
+index b269e82..52f2f1f 100644
+--- a/src/server/svr_mail.c
++++ b/src/server/svr_mail.c
+@@ -89,6 +89,7 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
++#include <unistd.h>
+ #include "list_link.h"
+ #include "attribute.h"
+ #include "server_limits.h"
+@@ -136,6 +137,77 @@ void free_mail_info(
+
+
+
++void add_body_info(
++
++ char *bodyfmtbuf /* I */,
++ mail_info *mi /* I */)
++
++ {
++ char *bodyfmt = NULL;
++ bodyfmt = strcpy(bodyfmtbuf, "PBS Job Id: %i\n"
++ "Job Name: %j\n");
++ if (mi->exec_host != NULL)
++ {
++ strcat(bodyfmt, "Exec host: %h\n");
++ }
++
++ strcat(bodyfmt, "%m\n");
++
++ if (mi->text != NULL)
++ {
++ strcat(bodyfmt, "%d\n");
++ }
++ }
++
++
++/*
++ * write_email()
++ *
++ * In emailing, the mail body is written to a pipe connected to
++ * standard input for sendmail. This function supplies the body
++ * of the message.
++ *
++ */
++void write_email(
++
++ FILE *outmail_input,
++ mail_info *mi)
++
++ {
++ char *bodyfmt = NULL;
++ char *subjectfmt = NULL;
++
++ /* Pipe in mail headers: To: and Subject: */
++ fprintf(outmail_input, "To: %s\n", mi->mailto);
++
++ /* mail subject line formating statement */
++ get_svr_attr_str(SRV_ATR_MailSubjectFmt, (char **)&subjectfmt);
++ if (subjectfmt == NULL)
++ {
++ subjectfmt = "PBS JOB %i";
++ }
++
++ fprintf(outmail_input, "Subject: ");
++ svr_format_job(outmail_input, mi, subjectfmt);
++ fprintf(outmail_input, "\n");
++
++ /* Set "Precedence: bulk" to avoid vacation messages, etc */
++ fprintf(outmail_input, "Precedence: bulk\n\n");
++
++ /* mail body formating statement */
++ get_svr_attr_str(SRV_ATR_MailBodyFmt, &bodyfmt);
++ if (bodyfmt == NULL)
++ {
++ char bodyfmtbuf[MAXLINE];
++ add_body_info(bodyfmtbuf, mi);
++ bodyfmt = bodyfmtbuf;
++ }
++
++ /* Now pipe in the email body */
++ svr_format_job(outmail_input, mi, bodyfmt);
++
++ } /* write_email() */
++
+
+
+ void *send_the_mail(
+@@ -143,15 +215,19 @@ void *send_the_mail(
+ void *vp)
+
+ {
+- mail_info *mi = (mail_info *)vp;
+-
+- int i;
+- char *mailfrom = NULL;
+- char *subjectfmt = NULL;
+- char *bodyfmt = NULL;
+- char *cmdbuf = NULL;
+- char bodyfmtbuf[MAXLINE];
+- FILE *outmail;
++ mail_info *mi = (mail_info *)vp;
++
++ int status = 0;
++ int numargs = 0;
++ int pipes[2];
++ int counter;
++ pid_t pid;
++ char *mailptr;
++ char *mailfrom = NULL;
++ char tmpBuf[LOG_BUF_SIZE];
++ // We call sendmail with cmd_name + 2 arguments + # of mailto addresses + 1 for null
++ char *sendmail_args[100];
++ FILE *stream;
+
+ /* Who is mail from, if SRV_ATR_mailfrom not set use default */
+ get_svr_attr_str(SRV_ATR_mailfrom, &mailfrom);
+@@ -173,124 +249,123 @@ void *send_the_mail(
+ mailfrom = PBS_DEFAULT_MAIL;
+ }
+
+- /* mail subject line formating statement */
+- get_svr_attr_str(SRV_ATR_MailSubjectFmt, &subjectfmt);
+- if (subjectfmt == NULL)
+- {
+- subjectfmt = "PBS JOB %i";
+- }
++ sendmail_args[numargs++] = (char *)SENDMAIL_CMD;
++ sendmail_args[numargs++] = (char *)"-f";
++ sendmail_args[numargs++] = (char *)mailfrom;
+
+- /* mail body formating statement */
+- get_svr_attr_str(SRV_ATR_MailBodyFmt, &bodyfmt);
+- if (bodyfmt == NULL)
++ /* Add the e-mail addresses to the command line */
++ mailptr = strdup(mi->mailto);
++ sendmail_args[numargs++] = mailptr;
++ for (counter=0; counter < (int)strlen(mailptr); counter++)
+ {
+- bodyfmt = strcpy(bodyfmtbuf, "PBS Job Id: %i\n"
+- "Job Name: %j\n");
+- if (mi->exec_host != NULL)
++ if (mailptr[counter] == ',')
+ {
+- strcat(bodyfmt, "Exec host: %h\n");
+- }
+-
+- strcat(bodyfmt, "%m\n");
+-
+- if (mi->text != NULL)
+- {
+- strcat(bodyfmt, "%d\n");
++ mailptr[counter] = '\0';
++ sendmail_args[numargs++] = mailptr + counter + 1;
++ if (numargs >= 99)
++ break;
+ }
+ }
+
+- /* setup sendmail command line with -f from_whom */
+- i = strlen(SENDMAIL_CMD) + strlen(mailfrom) + strlen(mi->mailto) + 6;
+-
+- if ((cmdbuf = calloc(1, i + 1)) == NULL)
++ sendmail_args[numargs] = NULL;
++
++ /* Create a pipe to talk to the sendmail process we are about to fork */
++ if (pipe(pipes) == -1)
+ {
+- char tmpBuf[LOG_BUF_SIZE];
+-
+- snprintf(tmpBuf,sizeof(tmpBuf),
+- "Unable to popen() command '%s' for writing: '%s' (error %d)\n",
+- SENDMAIL_CMD,
+- strerror(errno),
+- errno);
++ snprintf(tmpBuf, sizeof(tmpBuf), "Unable to pipes for sending e-mail\n");
+ log_event(PBSEVENT_ERROR | PBSEVENT_ADMIN | PBSEVENT_JOB,
+ PBS_EVENTCLASS_JOB,
+ mi->jobid,
+ tmpBuf);
+-
+- free_mail_info(mi);
+
++ free_mail_info(mi);
++ free(mailptr);
+ return(NULL);
+ }
+
+- sprintf(cmdbuf, "%s -f %s %s",
+- SENDMAIL_CMD,
+- mailfrom,
+- mi->mailto);
+-
+- outmail = popen(cmdbuf, "w");
+-
+- if (outmail == NULL)
++ if ((pid=fork()) == -1)
+ {
+- char tmpBuf[LOG_BUF_SIZE];
+-
+- snprintf(tmpBuf,sizeof(tmpBuf),
+- "Unable to popen() command '%s' for writing: '%s' (error %d)\n",
+- cmdbuf,
+- strerror(errno),
+- errno);
++ snprintf(tmpBuf, sizeof(tmpBuf), "Unable to fork for sending e-mail\n");
+ log_event(PBSEVENT_ERROR | PBSEVENT_ADMIN | PBSEVENT_JOB,
+ PBS_EVENTCLASS_JOB,
+ mi->jobid,
+ tmpBuf);
+
+ free_mail_info(mi);
+- free(cmdbuf);
+-
++ free(mailptr);
++ close(pipes[0]);
++ close(pipes[1]);
+ return(NULL);
+ }
++ else if (pid == 0)
++ {
++ /* CHILD */
+
+- /* Pipe in mail headers: To: and Subject: */
+- fprintf(outmail, "To: %s\n", mi->mailto);
++ /* Make stdin the read end of the pipe */
++ dup2(pipes[0], 0);
+
+- fprintf(outmail, "Subject: ");
+- svr_format_job(outmail, mi, subjectfmt);
+- fprintf(outmail, "\n");
++ /* Close the rest of the open file descriptors */
++ int numfds = sysconf(_SC_OPEN_MAX);
++ while (--numfds > 0)
++ close(numfds);
+
+- /* Set "Precedence: bulk" to avoid vacation messages, etc */
+- fprintf(outmail, "Precedence: bulk\n\n");
++ execv(SENDMAIL_CMD, sendmail_args);
++ /* This never returns, but if the execv fails the child should exit */
++ exit(1);
++ }
++ else
++ {
++ /* This is the parent */
+
+- /* Now pipe in the email body */
+- svr_format_job(outmail, mi, bodyfmt);
++ /* Close the read end of the pipe */
++ close(pipes[0]);
+
+- errno = 0;
+- if ((i = pclose(outmail)) != 0)
+- {
+- char tmpBuf[LOG_BUF_SIZE];
++ /* Write the body to the pipe */
++ stream = fdopen(pipes[1], "w");
++ write_email(stream, mi);
+
+- snprintf(tmpBuf,sizeof(tmpBuf),
+- "Email '%c' to %s failed: Child process '%s' %s %d (errno %d:%s)\n",
+- mi->mail_point,
+- mi->mailto,
+- cmdbuf,
+- ((WIFEXITED(i)) ? ("returned") : ((WIFSIGNALED(i)) ? ("killed by signal") : ("croaked"))),
+- ((WIFEXITED(i)) ? (WEXITSTATUS(i)) : ((WIFSIGNALED(i)) ? (WTERMSIG(i)) : (i))),
+- errno,
+- strerror(errno));
+- log_event(PBSEVENT_ERROR | PBSEVENT_ADMIN | PBSEVENT_JOB,
+- PBS_EVENTCLASS_JOB,
+- mi->jobid,
+- tmpBuf);
+- }
+- else if (LOGLEVEL >= 4)
+- {
+- log_event(PBSEVENT_ERROR | PBSEVENT_ADMIN | PBSEVENT_JOB,
+- PBS_EVENTCLASS_JOB,
+- mi->jobid,
+- "Email sent successfully\n");
+- }
++ fflush(stream);
++
++ /* Close and wait for the command to finish */
++ if (fclose(stream) != 0)
++ {
++ snprintf(tmpBuf,sizeof(tmpBuf),
++ "Piping mail body to sendmail closed: errno %d:%s\n",
++ errno, strerror(errno));
++
++ log_event(PBSEVENT_ERROR | PBSEVENT_ADMIN | PBSEVENT_JOB,
++ PBS_EVENTCLASS_JOB,
++ mi->jobid,
++ tmpBuf);
++ }
++
++ // we aren't going to block in order to find out whether or not sendmail worked
++ if ((waitpid(pid, &status, WNOHANG) != 0) &&
++ (status != 0))
++ {
++ snprintf(tmpBuf,sizeof(tmpBuf),
++ "Sendmail command returned %d. Mail may not have been sent\n",
++ status);
++
++ log_event(PBSEVENT_ERROR | PBSEVENT_ADMIN | PBSEVENT_JOB,
++ PBS_EVENTCLASS_JOB,
++ mi->jobid,
++ tmpBuf);
++ }
+
+- free_mail_info(mi);
+- free(cmdbuf);
++ // don't leave zombies
++ while (waitpid(-1, &status, WNOHANG) != 0)
++ {
++ // zombie reaped, NO-OP
++ }
++
++ free_mail_info(mi);
++ free(mailptr);
++ return(NULL);
++ }
+
++ /* NOT REACHED */
++
+ return(NULL);
+ } /* END send_the_mail() */
+
+--
+1.8.3.2
+
diff --git a/sys-cluster/torque/files/CVE-2013-4495.patch b/sys-cluster/torque/files/CVE-2013-4495.patch
new file mode 100644
index 000000000000..41232c07ec72
--- /dev/null
+++ b/sys-cluster/torque/files/CVE-2013-4495.patch
@@ -0,0 +1,32 @@
+From 8246d967bbcf174482ef01b1bf4920a5944b1011 Mon Sep 17 00:00:00 2001
+From: David Beer <dbeer@adaptivecomputing.com>
+Date: Wed, 13 Nov 2013 10:47:48 -0700
+Subject: [PATCH] Use Michael Jenning's patch for CVE 2013-4495 instead of the
+ original. This one is being used because 2.5 should face the minimal possible
+ change.
+
+---
+ src/server/svr_mail.c | 6 ++----
+ 1 file changed, 2 insertions(+), 4 deletions(-)
+
+diff --git a/src/server/svr_mail.c b/src/server/svr_mail.c
+index 26b6dd7..241bdfc 100644
+--- a/src/server/svr_mail.c
++++ b/src/server/svr_mail.c
+@@ -372,11 +372,9 @@ void svr_mailowner(
+ exit(1);
+ }
+
+- sprintf(cmdbuf, "%s -f %s %s",
+-
++ sprintf(cmdbuf, "%s -t -f %s",
+ SENDMAIL_CMD,
+- mailfrom,
+- mailto);
++ mailfrom);
+
+ outmail = (FILE *)popen(cmdbuf, "w");
+
+--
+1.8.3.2
+
diff --git a/sys-cluster/torque/files/CVE-2014-0749.patch b/sys-cluster/torque/files/CVE-2014-0749.patch
new file mode 100644
index 000000000000..52131edcf7e0
--- /dev/null
+++ b/sys-cluster/torque/files/CVE-2014-0749.patch
@@ -0,0 +1,32 @@
+From 3ed749263abe3d69fa3626d142a5789dcb5a5684 Mon Sep 17 00:00:00 2001
+From: David Beer <dbeer@adaptivecomputing.com>
+Date: Fri, 23 Aug 2013 15:53:09 -0600
+Subject: [PATCH] Merge pull request #171 into 2.5-fixes.
+
+---
+ src/lib/Libdis/disrsi_.c | 9 +++++++++
+ 1 file changed, 9 insertions(+)
+
+diff --git a/src/lib/Libdis/disrsi_.c b/src/lib/Libdis/disrsi_.c
+index 69edd28..154514c 100644
+--- a/src/lib/Libdis/disrsi_.c
++++ b/src/lib/Libdis/disrsi_.c
+@@ -112,6 +112,15 @@ int disrsi_(
+ if (dis_umaxd == 0)
+ disiui_();
+
++ if (count >= dis_umaxd)
++ {
++ if (count > dis_umaxd)
++ goto overflow;
++
++ if (memcmp(scratch, dis_umax, dis_umaxd) > 0)
++ goto overflow;
++ }
++
+ switch (c = (*dis_getc)(stream))
+ {
+
+--
+1.8.3.2
+
diff --git a/sys-cluster/torque/files/TRQ-2885-limit-tm_adopt-to-only-adopt-a-session-id-t.patch b/sys-cluster/torque/files/TRQ-2885-limit-tm_adopt-to-only-adopt-a-session-id-t.patch
new file mode 100644
index 000000000000..63713a0bc16f
--- /dev/null
+++ b/sys-cluster/torque/files/TRQ-2885-limit-tm_adopt-to-only-adopt-a-session-id-t.patch
@@ -0,0 +1,134 @@
+From f2f4c950f3d461a249111c8826da3beaafccace9 Mon Sep 17 00:00:00 2001
+From: Chad Vizino <cvizino@adaptivecomputing.com>
+Date: Tue, 23 Sep 2014 17:40:59 -0600
+Subject: [PATCH 1/2] TRQ-2885 - limit tm_adopt() to only adopt a session id
+ that is owned by the calling user.
+
+---
+ src/cmds/pbs_track.c | 6 ++++++
+ src/include/tm.h | 2 +-
+ src/include/tm_.h | 1 +
+ src/lib/Libifl/tm.c | 37 ++++++++++++++++++++++++++++++++++---
+ 5 files changed, 56 insertions(+), 4 deletions(-)
+
+diff --git a/src/cmds/pbs_track.c b/src/cmds/pbs_track.c
+index 7a90fda..9383ea5 100644
+--- a/src/cmds/pbs_track.c
++++ b/src/cmds/pbs_track.c
+@@ -164,6 +164,12 @@ int main(
+
+ break;
+
++ case TM_EPERM:
++
++ fprintf(stderr, "pbs_track: permission denied: %s (%d)\n",
++ pbse_to_txt(rc),
++ rc);
++
+ default:
+
+ /* Unexpected error occurred */
+diff --git a/src/include/tm.h b/src/include/tm.h
+index 106d3fb..2288828 100644
+--- a/src/include/tm.h
++++ b/src/include/tm.h
+@@ -125,7 +125,7 @@ int tm_register(tm_whattodo_t *what,
+ /*
+ * DJH 15 Nov 2001.
+ * Generic "out-of-band" task adoption call for tasks parented by
+- * another job management system. Minor security hole?
++ * another job management system.
+ * Cannot be called with any other tm call.
+ * 26 Feb 2002. Allows id to be jobid (adoptCmd = TM_ADOPT_JOBID)
+ * or some altid (adoptCmd = TM_ADOPT_ALTID)
+diff --git a/src/include/tm_.h b/src/include/tm_.h
+index c9393b9..8cae7b0 100644
+--- a/src/include/tm_.h
++++ b/src/include/tm_.h
+@@ -136,6 +136,7 @@ typedef unsigned int tm_task_id;
+ #define TM_EBADENVIRONMENT 17005
+ #define TM_ENOTFOUND 17006
+ #define TM_BADINIT 17007
++#define TM_EPERM 17008
+
+ #define TM_TODO_NOP 5000 /* Do nothing (the nodes value may be new) */
+ #define TM_TODO_CKPT 5001 /* Checkpoint <what> and continue it */
+diff --git a/src/lib/Libifl/iff --git a/src/lib/Libifl/tm.c b/src/lib/Libifl/tm.c
+index edb6273..4f38529 100644
+--- a/src/lib/Libifl/tm.c
++++ b/src/lib/Libifl/tm.c
+@@ -94,6 +94,7 @@
+ #include <errno.h>
+ #include <assert.h>
+ #include <sys/types.h>
++#include <sys/stat.h>
+ #include <sys/socket.h>
+ #include <sys/time.h>
+ #include <netinet/in.h>
+@@ -169,6 +170,31 @@ typedef struct event_info
+ static event_info *event_hash[EVENT_HASH];
+
+ /*
++ * check if the owner of this process matches the owner of pid
++ * returns TRUE if so, FALSE otherwise
++ */
++bool ispidowner(pid_t pid)
++ {
++ char path[MAXPATHLEN];
++ struct stat sbuf;
++
++ /* build path to pid */
++ snprintf(path, sizeof(path), "/proc/%d", pid);
++
++ /* do the stat */
++ /* if it fails, assume not owner */
++ if (stat(path, &sbuf) != 0)
++ return(FALSE);
++
++ /* see if caller is the owner of pid */
++ if (getuid() != sbuf.st_uid)
++ return(FALSE);
++
++ /* caller is owner */
++ return(TRUE);
++ }
++
++/*
+ ** Find an event number or return a NULL.
+ */
+ event_info *find_event(
+@@ -1800,8 +1826,8 @@ tm_poll_error:
+ * some mpiruns simply use rsh to start remote processes - no AMS
+ * tracking or management facilities are available.
+ *
+- * This function allows any task (session) to be adopted into a PBS
+- * job. It is used by:
++ * This function allows any task (session) owned by the owner
++ * of the job to be adopted into a PBS job. It is used by:
+ * - "adopter" (which is in turn used by our pvmrun)
+ * - our rmsloader wrapper (a home-brew replacement for RMS'
+ * rmsloader that does some work and then exec()s the real
+@@ -1835,7 +1861,8 @@ tm_poll_error:
+ * the mom. Returns TM_ENOTFOUND if the mom couldn't find a job
+ * with the given RMS resource id. Returns TM_ESYSTEM or
+ * TM_ENOTCONNECTED if there was some sort of comms error talking
+- * to the mom
++ * to the mom. Returns TM_EPERM if an attempt was made to adopt
++ * a session not owned by the owner of the job.
+ *
+ * Side effects:
+ * Sets the tm_* globals to fake values if tm_init() has never
+@@ -1860,6 +1887,10 @@ int tm_adopt(
+
+ sid = getsid(pid);
+
++ /* do not adopt a sid not owned by caller */
++ if (!ispidowner(sid))
++ return(TM_EPERM);
++
+ /* Must be the only call to call to tm and
+ must only be called once */
+
+--
+1.8.3.2
+
diff --git a/sys-cluster/torque/files/pbs_mom-init.d b/sys-cluster/torque/files/pbs_mom-init.d
new file mode 100644
index 000000000000..0bbd899bcf3e
--- /dev/null
+++ b/sys-cluster/torque/files/pbs_mom-init.d
@@ -0,0 +1,48 @@
+#!/sbin/runscript
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the Torque 2.5+ License
+
+. /etc/conf.d/torque
+PBS_SERVER_HOME="$(. /etc/env.d/25torque; echo ${PBS_SERVER_HOME})"
+
+depend() {
+ need net
+ after pbs_server
+ after pbs_sched
+ after logger
+}
+
+checkconfig() {
+ for i in "server_name" "mom_priv/config"; do
+ if [ ! -e ${PBS_SERVER_HOME}/${i} ]; then
+ eerror "Missing config file ${PBS_SERVER_HOME}/${i}"
+ return 1
+ fi
+ done
+}
+
+start() {
+ checkconfig || return 1
+
+ ebegin "Starting Torque pbs_mom"
+ local extra_args=""
+ if [ -n "${PBS_MOM_LOG}" ]; then
+ extra_args="-L ${PBS_MOM_LOG}"
+ fi
+ start-stop-daemon --start -p ${PBS_SERVER_HOME}/mom_priv/mom.lock \
+ --exec /usr/sbin/pbs_mom -- -d ${PBS_SERVER_HOME} ${extra_args}
+ eend ${?}
+}
+
+stop() {
+ ebegin "Stopping Torque pbs_mom"
+ /usr/sbin/momctl -s || start-stop-daemon --stop -p ${PBS_SERVER_HOME}/mom_priv/mom.lock
+ eend ${?}
+}
+
+restart() {
+ svc_stop
+ sleep 3
+ svc_start
+}
+# vim:ts=4
diff --git a/sys-cluster/torque/files/pbs_mom-init.d-munge b/sys-cluster/torque/files/pbs_mom-init.d-munge
new file mode 100644
index 000000000000..6c84dc647807
--- /dev/null
+++ b/sys-cluster/torque/files/pbs_mom-init.d-munge
@@ -0,0 +1,48 @@
+#!/sbin/runscript
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the Torque 2.5+ License
+
+. /etc/conf.d/torque
+PBS_SERVER_HOME="$(. /etc/env.d/25torque; echo ${PBS_SERVER_HOME})"
+
+depend() {
+ local _need="net"
+ after pbs_server pbs_sched logger
+ [ ${PBS_USE_MUNGE} -ne 0 ] && _need="${_need} munged"
+ need ${_need}
+}
+
+checkconfig() {
+ for i in "server_name" "mom_priv/config"; do
+ if [ ! -e ${PBS_SERVER_HOME}/${i} ]; then
+ eerror "Missing config file ${PBS_SERVER_HOME}/${i}"
+ return 1
+ fi
+ done
+}
+
+start() {
+ checkconfig || return 1
+
+ ebegin "Starting Torque pbs_mom"
+ local extra_args=""
+ if [ -n "${PBS_MOM_LOG}" ]; then
+ extra_args="-L ${PBS_MOM_LOG}"
+ fi
+ start-stop-daemon --start -p ${PBS_SERVER_HOME}/mom_priv/mom.lock \
+ --exec /usr/sbin/pbs_mom -- -d ${PBS_SERVER_HOME} ${extra_args}
+ eend ${?}
+}
+
+stop() {
+ ebegin "Stopping Torque pbs_mom"
+ /usr/sbin/momctl -s || start-stop-daemon --stop -p ${PBS_SERVER_HOME}/mom_priv/mom.lock
+ eend ${?}
+}
+
+restart() {
+ svc_stop
+ sleep 3
+ svc_start
+}
+# vim:ts=4
diff --git a/sys-cluster/torque/files/pbs_sched-init.d b/sys-cluster/torque/files/pbs_sched-init.d
new file mode 100644
index 000000000000..72e565a20752
--- /dev/null
+++ b/sys-cluster/torque/files/pbs_sched-init.d
@@ -0,0 +1,48 @@
+#!/sbin/runscript
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the Torque 2.5+ License
+
+. /etc/conf.d/torque
+PBS_SERVER_HOME="$(. /etc/env.d/25torque; echo ${PBS_SERVER_HOME})"
+
+depend() {
+ need net
+ after pbs_server
+ before pbs_mom
+ after logger
+}
+
+checkconfig() {
+ for i in "server_name"; do
+ if [ ! -e ${PBS_SERVER_HOME}/${i} ]; then
+ eerror "Missing config file ${PBS_SERVER_HOME}/${i}"
+ return 1
+ fi
+ done
+
+ if [ -z "$(grep 'queue_type' ${PBS_SERVER_HOME}/server_priv/queues/*)" ]; then
+ eerror "No queues have been defined yet."
+ return 1
+ fi
+}
+
+start() {
+ checkconfig || return 1
+
+ ebegin "Starting Torque pbs_sched"
+ local extra_args=""
+ if [ -n "${PBS_SCHED_LOG}" ]; then
+ extra_args="-L ${PBS_SCHED_LOG}"
+ fi
+
+ start-stop-daemon --start -p ${PBS_SERVER_HOME}/sched_priv/sched.lock \
+ --exec /usr/sbin/pbs_sched -- -d ${PBS_SERVER_HOME} ${extra_args}
+ eend ${?}
+}
+
+stop() {
+ ebegin "Stopping Torque pbs_sched"
+ start-stop-daemon --stop -p ${PBS_SERVER_HOME}/sched_priv/sched.lock
+ eend ${?}
+}
+# vim:ts=4
diff --git a/sys-cluster/torque/files/pbs_server-init.d b/sys-cluster/torque/files/pbs_server-init.d
new file mode 100644
index 000000000000..dd39a97f7159
--- /dev/null
+++ b/sys-cluster/torque/files/pbs_server-init.d
@@ -0,0 +1,60 @@
+#!/sbin/runscript
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the Torque 2.5+ License
+
+. /etc/conf.d/torque
+PBS_SERVER_HOME="$(. /etc/env.d/25torque; echo ${PBS_SERVER_HOME})"
+
+depend() {
+ need net
+ before pbs_sched
+ before pbs_mom
+ after logger
+}
+
+checkconfig() {
+ for i in "server_name" "server_priv/nodes"; do
+ if [ ! -e "${PBS_SERVER_HOME}/${i}" ]; then
+ eerror "Missing config file ${PBS_SERVER_HOME}/${i}"
+ return 1
+ fi
+ done
+
+ if [ ! -e "${PBS_SERVER_HOME}/server_priv/serverdb" ]; then
+ eerror "Torque has not been fully configured to run."
+ eerror "Missing ${PBS_SERVER_HOME}/server_priv/serverdb"
+ return 1
+ fi
+
+ if [ -z "$(grep 'queue_type' ${PBS_SERVER_HOME}/server_priv/queues/*)" ]; then
+ eerror "No queues have been defined yet."
+ return 1
+ fi
+}
+
+start() {
+ checkconfig || return 1
+
+ ebegin "Starting Torque pbs_server"
+ local extra_args=""
+ if [ -n "${PBS_SERVER_LOG}" ]; then
+ extra_args="-L ${PBS_SERVER_LOG}"
+ fi
+
+ start-stop-daemon --start -p ${PBS_SERVER_HOME}/server_priv/server.lock \
+ --exec /usr/sbin/pbs_server -- -d ${PBS_SERVER_HOME} ${extra_args}
+ eend ${?}
+}
+
+stop() {
+ ebegin "Stopping Torque pbs_server"
+ stop_type="${PBS_SERVER_STOP}"
+ if [ -z "${stop_type}" ]; then
+ ewarn "PBS_SERVER_STOP is not defined, defaulting to quick"
+ stop_type=quick
+ fi
+
+ /usr/bin/qterm -t ${stop_type} || start-stop-daemon --stop -p ${PBS_SERVER_HOME}/server_priv/server.lock
+ eend ${?}
+}
+# vim:ts=4
diff --git a/sys-cluster/torque/files/pbs_server-init.d-munge b/sys-cluster/torque/files/pbs_server-init.d-munge
new file mode 100644
index 000000000000..83101a2e2a47
--- /dev/null
+++ b/sys-cluster/torque/files/pbs_server-init.d-munge
@@ -0,0 +1,61 @@
+#!/sbin/runscript
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the Torque 2.5+ License
+
+. /etc/conf.d/torque
+PBS_SERVER_HOME="$(. /etc/env.d/25torque; echo ${PBS_SERVER_HOME})"
+
+depend() {
+ local _need="net"
+ before pbs_sched pbs_mom
+ after logger
+ [ ${PBS_USE_MUNGE} -ne 0 ] && _need="${_need} munged"
+ need ${_need}
+}
+
+checkconfig() {
+ for i in "server_name" "server_priv/nodes"; do
+ if [ ! -e "${PBS_SERVER_HOME}/${i}" ]; then
+ eerror "Missing config file ${PBS_SERVER_HOME}/${i}"
+ return 1
+ fi
+ done
+
+ if [ ! -e "${PBS_SERVER_HOME}/server_priv/serverdb" ]; then
+ eerror "Torque has not been fully configured to run."
+ eerror "Missing ${PBS_SERVER_HOME}/server_priv/serverdb"
+ return 1
+ fi
+
+ if [ -z "$(grep 'queue_type' ${PBS_SERVER_HOME}/server_priv/queues/*)" ]; then
+ eerror "No queues have been defined yet."
+ return 1
+ fi
+}
+
+start() {
+ checkconfig || return 1
+
+ ebegin "Starting Torque pbs_server"
+ local extra_args=""
+ if [ -n "${PBS_SERVER_LOG}" ]; then
+ extra_args="-L ${PBS_SERVER_LOG}"
+ fi
+
+ start-stop-daemon --start -p ${PBS_SERVER_HOME}/server_priv/server.lock \
+ --exec /usr/sbin/pbs_server -- -d ${PBS_SERVER_HOME} ${extra_args}
+ eend ${?}
+}
+
+stop() {
+ ebegin "Stopping Torque pbs_server"
+ stop_type="${PBS_SERVER_STOP}"
+ if [ -z "${stop_type}" ]; then
+ ewarn "PBS_SERVER_STOP is not defined, defaulting to quick"
+ stop_type=quick
+ fi
+
+ /usr/bin/qterm -t ${stop_type} || start-stop-daemon --stop -p ${PBS_SERVER_HOME}/server_priv/server.lock
+ eend ${?}
+}
+# vim:ts=4
diff --git a/sys-cluster/torque/files/tcl8.6.patch b/sys-cluster/torque/files/tcl8.6.patch
new file mode 100644
index 000000000000..0361dbfead0a
--- /dev/null
+++ b/sys-cluster/torque/files/tcl8.6.patch
@@ -0,0 +1,87 @@
+From 061f15e06d6cf85e951cd321360067de5f0b2ce0 Mon Sep 17 00:00:00 2001
+From: Justin Bronder <jsbronder@gmail.com>
+Date: Thu, 7 Mar 2013 22:33:04 -0500
+Subject: [PATCH] support tcl-8.6
+
+---
+ src/cmds/qstat.c | 13 +++++++++----
+ src/scheduler.tcl/pbs_tclWrap.c | 6 +++---
+ 2 files changed, 12 insertions(+), 7 deletions(-)
+
+diff --git a/src/cmds/qstat.c b/src/cmds/qstat.c
+index 5f85de7..7f289ba 100644
+--- a/src/cmds/qstat.c
++++ b/src/cmds/qstat.c
+@@ -88,6 +88,11 @@
+ #if TCL_QSTAT
+ #include <sys/stat.h>
+ #include <tcl.h>
++#if TCL_MAJOR_VERSION <=8 && TCL_MINOR_VERSION < 6
++#define Tcl_GetStringResult(x) x->result
++#define Tcl_GetErrorLine(x) x->errorLine
++#define Tcl_SetResult(x, y, z) x->result = y
++#endif
+ #if TCLX
+ #include <tclExtend.h>
+ #endif
+@@ -1856,7 +1861,7 @@ tcl_init(void)
+ if (Tcl_Init(interp) == TCL_ERROR)
+ {
+ fprintf(stderr, "Tcl_Init error: %s",
+- interp->result);
++ Tcl_GetStringResult(interp));
+ }
+
+ #if TCLX
+@@ -1869,7 +1874,7 @@ tcl_init(void)
+ {
+ #endif
+ fprintf(stderr, "Tclx_Init error: %s",
+- interp->result);
++ Tcl_GetStringResult(interp));
+ }
+
+ #endif /* TCLX */
+@@ -1980,10 +1985,10 @@ void tcl_run(
+ trace = (char *)Tcl_GetVar(interp, "errorInfo", 0);
+
+ if (trace == NULL)
+- trace = interp->result;
++ trace = Tcl_GetStringResult(interp);
+
+ fprintf(stderr, "%s: TCL error @ line %d: %s\n",
+- script, interp->errorLine, trace);
++ script, Tcl_GetErrorLine(interp), trace);
+ }
+
+ Tcl_DeleteInterp(interp);
+diff --git a/src/scheduler.tcl/pbs_tclWrap.c b/src/scheduler.tcl/pbs_tclWrap.c
+index e859ae5..194c24b 100644
+--- a/src/scheduler.tcl/pbs_tclWrap.c
++++ b/src/scheduler.tcl/pbs_tclWrap.c
+@@ -924,7 +924,7 @@ char *argv[];
+
+ if (argc != 2)
+ {
+- sprintf(interp->result,
++ sprintf(Tcl_GetStringResult(interp),
+ "%s: wrong # args: job_id", argv[0]);
+ return TCL_ERROR;
+ }
+@@ -936,11 +936,11 @@ char *argv[];
+ return TCL_OK;
+ }
+
+- interp->result = "0";
++ Tcl_SetResult(interp, "0", TCL_STATIC);
+
+ if (pbs_rerunjob(connector, argv[1], extend))
+ {
+- interp->result = "-1";
++ Tcl_SetResult(interp, "-1", TCL_STATIC);
+ msg = pbs_geterrmsg(connector);
+ sprintf(log_buffer, "%s (%d)", msg ? msg : fail, pbs_errno);
+ log_err(-1, argv[0], log_buffer);
+--
+1.7.12.4
+
diff --git a/sys-cluster/torque/files/torque-4.1.5.1-tcl8.6.patch b/sys-cluster/torque/files/torque-4.1.5.1-tcl8.6.patch
new file mode 100644
index 000000000000..2e8a8ed8f359
--- /dev/null
+++ b/sys-cluster/torque/files/torque-4.1.5.1-tcl8.6.patch
@@ -0,0 +1,93 @@
+ src/cmds/qstat.c | 18 ++++++++++++++++++
+ src/scheduler.tcl/pbs_tclWrap.c | 13 +++++++++++++
+ 2 files changed, 31 insertions(+)
+
+diff --git a/src/cmds/qstat.c b/src/cmds/qstat.c
+index 4e1c6b6..07ed448 100644
+--- a/src/cmds/qstat.c
++++ b/src/cmds/qstat.c
+@@ -1795,8 +1795,13 @@ tcl_init(void)
+
+ if (Tcl_Init(interp) == TCL_ERROR)
+ {
++#if TCL_MAJOR_VERSION <=8 && TCL_MINOR_VERSION < 6
+ fprintf(stderr, "Tcl_Init error: %s",
+ interp->result);
++#else
++ fprintf(stderr, "Tcl_Init error: %s",
++ Tcl_GetStringResult(interp));
++#endif
+ }
+
+ #if TCLX
+@@ -1808,8 +1813,14 @@ tcl_init(void)
+ if (Tclx_Init(interp) == TCL_ERROR)
+ {
+ #endif
++
++#if TCL_MAJOR_VERSION <=8 && TCL_MINOR_VERSION < 6
+ fprintf(stderr, "Tclx_Init error: %s",
+ interp->result);
++#else
++ fprintf(stderr, "Tclx_Init error: %s",
++ Tcl_GetStringResult(interp));
++#endif
+ }
+
+ #endif /* TCLX */
+@@ -1920,10 +1931,17 @@ void tcl_run(
+ trace = (char *)Tcl_GetVar(interp, "errorInfo", 0);
+
+ if (trace == NULL)
++#if TCL_MAJOR_VERSION <=8 && TCL_MINOR_VERSION < 6
+ trace = interp->result;
+
+ fprintf(stderr, "%s: TCL error @ line %d: %s\n",
+ script, interp->errorLine, trace);
++#else
++ trace = Tcl_GetStringResult(interp);
++
++ fprintf(stderr, "%s: TCL error @ line %d: %s\n",
++ script, Tcl_GetErrorLine(interp), trace);
++#endif
+ }
+
+ Tcl_DeleteInterp(interp);
+diff --git a/src/scheduler.tcl/pbs_tclWrap.c b/src/scheduler.tcl/pbs_tclWrap.c
+index a85e8ff..46c1012 100644
+--- a/src/scheduler.tcl/pbs_tclWrap.c
++++ b/src/scheduler.tcl/pbs_tclWrap.c
+@@ -900,8 +900,13 @@ char *argv[];
+
+ if (argc != 2)
+ {
++#if TCL_MAJOR_VERSION <=8 && TCL_MINOR_VERSION < 6
+ sprintf(interp->result,
+ "%s: wrong # args: job_id", argv[0]);
++#else
++ sprintf(Tcl_GetStringResult(interp),
++ "%s: wrong # args: job_id", argv[0]);
++#endif
+ return TCL_ERROR;
+ }
+
+@@ -912,11 +917,19 @@ char *argv[];
+ return TCL_OK;
+ }
+
++#if TCL_MAJOR_VERSION <=8 && TCL_MINOR_VERSION < 6
+ interp->result = "0";
++#else
++ Tcl_SetResult(interp, "0", TCL_STATIC);
++#endif
+
+ if (pbs_rerunjob_err(connector, argv[1], extend, &local_errno))
+ {
++#if TCL_MAJOR_VERSION <=8 && TCL_MINOR_VERSION < 6
+ interp->result = "-1";
++#else
++ Tcl_SetResult(interp, "-1", TCL_STATIC);
++#endif
+ msg = pbs_geterrmsg(connector);
+ sprintf(log_buffer, "%s (%d)", msg ? msg : fail, local_errno);
+ log_err(-1, argv[0], log_buffer);
diff --git a/sys-cluster/torque/files/torque-4.2.9-tcl8.6.patch b/sys-cluster/torque/files/torque-4.2.9-tcl8.6.patch
new file mode 100644
index 000000000000..3a2a28ce4a2b
--- /dev/null
+++ b/sys-cluster/torque/files/torque-4.2.9-tcl8.6.patch
@@ -0,0 +1,99 @@
+ src/cmds/qstat.c | 20 +++++++++++++++++++-
+ src/scheduler.tcl/pbs_tclWrap.c | 13 +++++++++++++
+ 2 files changed, 32 insertions(+), 1 deletion(-)
+
+diff --git a/src/cmds/qstat.c b/src/cmds/qstat.c
+index f275cf8..23414b8 100644
+--- a/src/cmds/qstat.c
++++ b/src/cmds/qstat.c
+@@ -2203,8 +2203,13 @@ tcl_init(void)
+
+ if (Tcl_Init(interp) == TCL_ERROR)
+ {
++#if TCL_MAJOR_VERSION <=8 && TCL_MINOR_VERSION < 6
+ fprintf(stderr, "Tcl_Init error: %s",
+ interp->result);
++#else
++ fprintf(stderr, "Tcl_Init error: %s",
++ Tcl_GetStringResult(interp));
++#endif
+ }
+
+ #if TCLX
+@@ -2216,8 +2221,14 @@ tcl_init(void)
+ if (Tclx_Init(interp) == TCL_ERROR)
+ {
+ #endif
++
++#if TCL_MAJOR_VERSION <=8 && TCL_MINOR_VERSION < 6
+ fprintf(stderr, "Tclx_Init error: %s",
+ interp->result);
++#else
++ fprintf(stderr, "Tclx_Init error: %s",
++ Tcl_GetStringResult(interp));
++#endif
+ }
+
+ #endif /* TCLX */
+@@ -2328,15 +2339,22 @@ void tcl_run(
+
+ if (f_opt && Tcl_EvalFile(interp, script) != TCL_OK)
+ {
+- char *trace;
++ const char *trace;
+
+ trace = (char *)Tcl_GetVar(interp, "errorInfo", 0);
+
+ if (trace == NULL)
++#if TCL_MAJOR_VERSION <=8 && TCL_MINOR_VERSION < 6
+ trace = interp->result;
+
+ fprintf(stderr, "%s: TCL error @ line %d: %s\n",
+ script, interp->errorLine, trace);
++#else
++ trace = Tcl_GetStringResult(interp);
++
++ fprintf(stderr, "%s: TCL error @ line %d: %s\n",
++ script, Tcl_GetErrorLine(interp), trace);
++#endif
+ }
+
+ Tcl_DeleteInterp(interp);
+diff --git a/src/scheduler.tcl/pbs_tclWrap.c b/src/scheduler.tcl/pbs_tclWrap.c
+index 3eea0b0..7d0d610 100644
+--- a/src/scheduler.tcl/pbs_tclWrap.c
++++ b/src/scheduler.tcl/pbs_tclWrap.c
+@@ -935,8 +935,13 @@ int PBS_ReRun(
+
+ if (argc != 2)
+ {
++#if TCL_MAJOR_VERSION <=8 && TCL_MINOR_VERSION < 6
+ sprintf(interp->result,
+ "%s: wrong # args: job_id", argv[0]);
++#else
++ Tcl_SetObjResult(interp, Tcl_ObjPrintf(
++ "%s: wrong # args: job_id", argv[0]));
++#endif
+ return TCL_ERROR;
+ }
+
+@@ -947,11 +952,19 @@ int PBS_ReRun(
+ return TCL_OK;
+ }
+
++#if TCL_MAJOR_VERSION <=8 && TCL_MINOR_VERSION < 6
+ interp->result = strdup("0");
++#else
++ Tcl_SetResult(interp, "0", TCL_STATIC);
++#endif
+
+ if (pbs_rerunjob_err(connector, strdup(argv[1]), extend, &local_errno))
+ {
++#if TCL_MAJOR_VERSION <=8 && TCL_MINOR_VERSION < 6
+ interp->result = strdup("-1");
++#else
++ Tcl_SetResult(interp, "-1", TCL_STATIC);
++#endif
+ msg = pbs_geterrmsg(connector);
+ sprintf(log_buffer, "%s (%d)", msg ? msg : fail, local_errno);
+ log_err(-1, argv[0], log_buffer);
diff --git a/sys-cluster/torque/files/torque-conf.d b/sys-cluster/torque/files/torque-conf.d
new file mode 100644
index 000000000000..a6e6b08beace
--- /dev/null
+++ b/sys-cluster/torque/files/torque-conf.d
@@ -0,0 +1,14 @@
+# The default logging takes place in $PBS_SERVER_HOME/<mom/server/sched>_priv.
+# If you'd like to change that, use the following per service.
+PBS_SERVER_LOG=/var/log/pbs_server.log
+PBS_MOM_LOG=/var/log/pbs_mom.log
+PBS_SCHED_LOG=/var/log/pbs_sched.log
+
+
+# There are a number of ways to stop the pbs server. For more details, man qterm
+# At the time of writing, checkpoint is probably not working.
+# immediate: All jobs are killed.
+# delay: Checkpoint, rerun or wait for jobs to finish before stopping
+# quick: Remember running jobs, and let them run without interaction with pbs_server.
+# This is the default action
+PBS_SERVER_STOP=quick
diff --git a/sys-cluster/torque/files/torque-conf.d-munge b/sys-cluster/torque/files/torque-conf.d-munge
new file mode 100644
index 000000000000..a8456d526d46
--- /dev/null
+++ b/sys-cluster/torque/files/torque-conf.d-munge
@@ -0,0 +1,18 @@
+# The default logging takes place in $PBS_SERVER_HOME/<mom/server/sched>_priv.
+# If you'd like to change that, use the following per service.
+PBS_SERVER_LOG=/var/log/pbs_server.log
+PBS_MOM_LOG=/var/log/pbs_mom.log
+PBS_SCHED_LOG=/var/log/pbs_sched.log
+
+
+# There are a number of ways to stop the pbs server. For more details, man qterm
+# At the time of writing, checkpoint is probably not working.
+# immediate: All jobs are killed.
+# delay: Checkpoint, rerun or wait for jobs to finish before stopping
+# quick: Remember running jobs, and let them run without interaction with pbs_server.
+# This is the default action
+PBS_SERVER_STOP=quick
+
+# Use munge auth by default. This causes all pbs service to require
+# the munge service. Set to non-zero to enable.
+PBS_USE_MUNGE=0
diff --git a/sys-cluster/torque/files/torque-env.d b/sys-cluster/torque/files/torque-env.d
new file mode 100644
index 000000000000..40a08c016dee
--- /dev/null
+++ b/sys-cluster/torque/files/torque-env.d
@@ -0,0 +1,7 @@
+# Copyright 1999-2012 Gentoo Foundation
+# Distributed under the terms of the Torque 2.5+ License
+
+# Configuration files that are included in the initial Torque install
+PBS_SERVER_HOME="/var/spool/torque"
+CONFIG_PROTECT="/var/spool/torque"
+
diff --git a/sys-cluster/torque/files/trqauthd-init.d b/sys-cluster/torque/files/trqauthd-init.d
new file mode 100644
index 000000000000..b7896d6af7ef
--- /dev/null
+++ b/sys-cluster/torque/files/trqauthd-init.d
@@ -0,0 +1,27 @@
+#!/sbin/runscript
+# Copyright 1999-2013 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Id$
+
+depend() {
+ need net
+ after logger
+
+ # 4.0+ only, make sure we run before the other torque services
+ before pbs_mom
+ before pbs_sched
+ before pbs_server
+}
+
+start() {
+ start-stop-daemon \
+ --start \
+ --exec /usr/sbin/trqauthd
+}
+
+stop() {
+ start-stop-daemon \
+ --stop \
+ --exec /usr/sbin/trqauthd
+}
+