|
47 | 47 | #include "src/common/libutil/monotime.h" |
48 | 48 | #include "src/common/libutil/fsd.h" |
49 | 49 | #include "src/common/libutil/fdutils.h" |
| 50 | +#include "src/common/libutil/strstrip.h" |
50 | 51 | #include "src/common/libidset/idset.h" |
51 | 52 | #include "src/common/libeventlog/eventlog.h" |
52 | 53 | #include "src/common/libioencode/ioencode.h" |
@@ -1525,7 +1526,7 @@ int cmd_submit (optparse_t *p, int argc, char **argv) |
1525 | 1526 | #if HAVE_FLUX_SECURITY |
1526 | 1527 | flux_security_t *sec = NULL; |
1527 | 1528 | const char *sec_config; |
1528 | | - const char *sign_type; |
| 1529 | + const char *sign_type = NULL; |
1529 | 1530 | #endif |
1530 | 1531 | int flags = 0; |
1531 | 1532 | void *jobspec; |
@@ -1563,27 +1564,38 @@ int cmd_submit (optparse_t *p, int argc, char **argv) |
1563 | 1564 | * context so jobspec can be pre-signed before submission. |
1564 | 1565 | */ |
1565 | 1566 | if (optparse_hasopt (p, "security-config") |
1566 | | - || optparse_hasopt (p, "sign-type")) { |
1567 | | - sec_config = optparse_get_str (p, "security-config", NULL); |
1568 | | - if (!(sec = flux_security_create (0))) |
1569 | | - log_err_exit ("security"); |
1570 | | - if (flux_security_configure (sec, sec_config) < 0) |
1571 | | - log_err_exit ("security config %s", flux_security_last_error (sec)); |
1572 | | - sign_type = optparse_get_str (p, "sign-type", NULL); |
| 1567 | + || optparse_hasopt (p, "sign-type")) { |
| 1568 | + if (flags & FLUX_JOB_PRE_SIGNED) |
| 1569 | + log_msg ("Ignoring security config with --flags=pre-signed"); |
| 1570 | + else { |
| 1571 | + sec_config = optparse_get_str (p, "security-config", NULL); |
| 1572 | + if (!(sec = flux_security_create (0))) |
| 1573 | + log_err_exit ("security"); |
| 1574 | + if (flux_security_configure (sec, sec_config) < 0) |
| 1575 | + log_err_exit ("security config %s", |
| 1576 | + flux_security_last_error (sec)); |
| 1577 | + sign_type = optparse_get_str (p, "sign-type", NULL); |
| 1578 | + } |
1573 | 1579 | } |
1574 | 1580 | #endif |
1575 | 1581 | if (!(h = flux_open (NULL, 0))) |
1576 | 1582 | log_err_exit ("flux_open"); |
1577 | | - jobspecsz = read_jobspec (input, &jobspec); |
1578 | | - assert (((char *)jobspec)[jobspecsz] == '\0'); |
1579 | | - if (jobspecsz == 0) |
| 1583 | + if ((jobspecsz = read_jobspec (input, &jobspec)) == 0) |
1580 | 1584 | log_msg_exit ("required jobspec is empty"); |
| 1585 | + |
| 1586 | + /* If jobspec was pre-signed, then assign J to to jobspec after |
| 1587 | + * stripping surrounding whitespace. |
| 1588 | + */ |
| 1589 | + if (flags & FLUX_JOB_PRE_SIGNED) |
| 1590 | + J = strstrip (jobspec); |
| 1591 | + |
1581 | 1592 | urgency = optparse_get_int (p, "urgency", FLUX_JOB_URGENCY_DEFAULT); |
1582 | 1593 |
|
1583 | 1594 | #if HAVE_FLUX_SECURITY |
1584 | 1595 | if (sec) { |
1585 | 1596 | if (!(J = flux_sign_wrap (sec, jobspec, jobspecsz, sign_type, 0))) |
1586 | | - log_err_exit ("flux_sign_wrap: %s", flux_security_last_error (sec)); |
| 1597 | + log_err_exit ("flux_sign_wrap: %s", |
| 1598 | + flux_security_last_error (sec)); |
1587 | 1599 | flags |= FLUX_JOB_PRE_SIGNED; |
1588 | 1600 | } |
1589 | 1601 | #endif |
|
0 commit comments