diff options
author | sonam gupta - Sun Microsystems - Bangalore India <Sonam.Gupta@Sun.COM> | 2009-03-23 23:26:09 -0700 |
---|---|---|
committer | sonam gupta - Sun Microsystems - Bangalore India <Sonam.Gupta@Sun.COM> | 2009-03-23 23:26:09 -0700 |
commit | 3d09a4fec6be19a6f09e277d5d5d17942bb4abf4 (patch) | |
tree | e494bd339b4d362c20d064d041407385b34066e0 /usr/src | |
parent | 546a399722fe82dc300c308a8fb86a11d2ca3ba3 (diff) | |
download | illumos-gate-3d09a4fec6be19a6f09e277d5d5d17942bb4abf4.tar.gz |
6789790 'lpstat -o' doesnot display the host-info along with the owner of the request with ipp service
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/cmd/lp/lib/papi/job.c | 16 | ||||
-rw-r--r-- | usr/src/cmd/lp/lib/papi/lpsched-jobs.c | 164 | ||||
-rw-r--r-- | usr/src/cmd/print/bsd-sysv-commands/lpstat.c | 74 | ||||
-rw-r--r-- | usr/src/lib/print/libipp-listener/Makefile.com | 5 | ||||
-rw-r--r-- | usr/src/lib/print/libipp-listener/common/print-job.c | 66 | ||||
-rw-r--r-- | usr/src/lib/print/libpapi-ipp/common/job.c | 17 |
6 files changed, 243 insertions, 99 deletions
diff --git a/usr/src/cmd/lp/lib/papi/job.c b/usr/src/cmd/lp/lib/papi/job.c index 718d929a66..4f5ac84f65 100644 --- a/usr/src/cmd/lp/lib/papi/job.c +++ b/usr/src/cmd/lp/lib/papi/job.c @@ -118,8 +118,24 @@ create_request(papi_service_t svc, char *printer, papi_attribute_t **attributes) REQUEST *r; if ((r = calloc(1, sizeof (*r))) != NULL) { + char *hostname = NULL; + r->priority = -1; r->destination = printer_name_from_uri_id(printer, -1); + + papiAttributeListGetString(attributes, NULL, + "job-originating-host-name", &hostname); + + if (hostname == NULL) { + char host[BUFSIZ]; + + if (gethostname(host, sizeof (host)) == 0) + papiAttributeListAddString(&attributes, + PAPI_ATTR_REPLACE, + "job-originating-host-name", + host); + } + job_attributes_to_lpsched_request(svc, r, attributes); } diff --git a/usr/src/cmd/lp/lib/papi/lpsched-jobs.c b/usr/src/cmd/lp/lib/papi/lpsched-jobs.c index 460a9e10da..fea9caf573 100644 --- a/usr/src/cmd/lp/lib/papi/lpsched-jobs.c +++ b/usr/src/cmd/lp/lib/papi/lpsched-jobs.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2008 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -76,7 +76,7 @@ job_attributes_to_lpsched_request(papi_service_t svc, REQUEST *r, /* replace the current destination */ papiAttributeListGetLPString(attributes, - "job-printer", &r->destination); + "job-printer", &r->destination); /* set the copies. We need at least 1 */ i = r->copies; @@ -90,7 +90,7 @@ job_attributes_to_lpsched_request(papi_service_t svc, REQUEST *r, * have to convert it. */ if (papiAttributeListGetInteger(attributes, NULL, "job-priority", &i) - == PAPI_OK) { + == PAPI_OK) { if ((i < 1) || (i > 100)) i = 50; i = 40 - (i / 2.5); @@ -136,20 +136,18 @@ job_attributes_to_lpsched_request(papi_service_t svc, REQUEST *r, if ((pw = getpwuid(uid)) != NULL) user = pw->pw_name; /* default to the process owner */ - if ((uid == 0) || (uid == 71)) { /* root/lp can forge this */ - papiAttributeListGetString(attributes, NULL, - "job-originating-host-name", &host); - papiAttributeListGetString(attributes, NULL, - "job-host", &host); - papiAttributeListGetString(attributes, NULL, - "job-originating-user-name", &user); - papiAttributeListGetString(attributes, NULL, - "requesting-user-name", &user); - - snprintf(buf, sizeof (buf), "%s%s%s", user, - (host ? "@" : ""), (host ? host : "")); - user = buf; - } + papiAttributeListGetString(attributes, NULL, + "job-originating-host-name", &host); + papiAttributeListGetString(attributes, NULL, + "job-host", &host); + papiAttributeListGetString(attributes, NULL, + "job-originating-user-name", &user); + papiAttributeListGetString(attributes, NULL, + "requesting-user-name", &user); + + snprintf(buf, sizeof (buf), "%s%s%s", user, + (host ? "@" : ""), (host ? host : "")); + user = buf; r->user = strdup(user); } @@ -162,10 +160,10 @@ job_attributes_to_lpsched_request(papi_service_t svc, REQUEST *r, if (strcmp(s, "resume") == 0) r->actions |= ACT_RESUME; else if ((strcmp(s, "immediate") == 0) || - (strcmp(s, "no-hold") == 0)) + (strcmp(s, "no-hold") == 0)) r->actions |= ACT_IMMEDIATE; else if ((strcmp(s, "indefinite") == 0) || - (strcmp(s, "hold") == 0)) + (strcmp(s, "hold") == 0)) r->actions |= ACT_HOLD; } @@ -212,9 +210,9 @@ job_attributes_to_lpsched_request(papi_service_t svc, REQUEST *r, /* burst page is enabled by default, add the title */ snprintf(buf, sizeof (buf), "%s%s%s", - (job_name ? job_name : ""), - (job_name && class ? "\\n#####\\n#####\\t\\t " : ""), - (class ? class : "")); + (job_name ? job_name : ""), + (job_name && class ? "\\n#####\\n#####\\t\\t " : ""), + (class ? class : "")); if (buf[0] != '\0') { if (r->title != NULL) free(r->title); @@ -237,7 +235,7 @@ job_attributes_to_lpsched_request(papi_service_t svc, REQUEST *r, * 'landscape', 'portrait', etc. */ papiAttributeListGetInteger(attributes, NULL, - "orientation-requested", &orientation); + "orientation-requested", &orientation); if ((orientation >= 3) && (orientation <= 6)) { switch (orientation) { case 4: /* landscape */ @@ -276,7 +274,7 @@ job_attributes_to_lpsched_request(papi_service_t svc, REQUEST *r, ssize_t size = 1024; while (papiAttributeListToString(unmapped, " ", buf, size) - != PAPI_OK) { + != PAPI_OK) { size += 1024; buf = realloc(buf, size); } @@ -308,43 +306,43 @@ lpsched_request_outcome_to_attributes(papi_attribute_t ***attributes, if (state & (RS_HELD|RS_ADMINHELD)) { papiAttributeListAddInteger(attributes, PAPI_ATTR_REPLACE, - "job-state", 0x04); /* held */ + "job-state", 0x04); /* held */ papiAttributeListAddString(attributes, PAPI_ATTR_REPLACE, - "job-state-reasons", "job-hold-until-specified"); + "job-state-reasons", "job-hold-until-specified"); } else if (state & RS_ACTIVE) { papiAttributeListAddInteger(attributes, PAPI_ATTR_REPLACE, - "job-state", 0x05); + "job-state", 0x05); if (state & RS_FILTERING) papiAttributeListAddString(attributes, - PAPI_ATTR_REPLACE, - "job-state-reasons", "job-transforming"); + PAPI_ATTR_REPLACE, + "job-state-reasons", "job-transforming"); else if (state & RS_PRINTING) papiAttributeListAddString(attributes, - PAPI_ATTR_REPLACE, - "job-state-reasons", "job-printing"); + PAPI_ATTR_REPLACE, + "job-state-reasons", "job-printing"); else papiAttributeListAddString(attributes, - PAPI_ATTR_REPLACE, - "job-state-reasons", "job-processing"); + PAPI_ATTR_REPLACE, + "job-state-reasons", "job-processing"); } else if (state & RS_CANCELLED) { papiAttributeListAddInteger(attributes, PAPI_ATTR_REPLACE, - "job-state", 0x07); + "job-state", 0x07); papiAttributeListAddString(attributes, PAPI_ATTR_REPLACE, - "job-state-reasons", "job-canceled-by-user"); + "job-state-reasons", "job-canceled-by-user"); } else if (state & RS_PRINTED) { papiAttributeListAddInteger(attributes, PAPI_ATTR_REPLACE, - "job-state", 0x09); + "job-state", 0x09); papiAttributeListAddString(attributes, PAPI_ATTR_REPLACE, - "job-state-reasons", "job-complete"); + "job-state-reasons", "job-complete"); } else { papiAttributeListAddInteger(attributes, PAPI_ATTR_REPLACE, - "job-state", 0x03); + "job-state", 0x03); papiAttributeListAddString(attributes, PAPI_ATTR_REPLACE, - "job-state-reasons", "job-queued"); + "job-state-reasons", "job-queued"); } papiAttributeListAddString(attributes, PAPI_ATTR_REPLACE, - "job-hold-until", - ((state & RS_HELD) ? "indefinite" : "no-hold")); + "job-hold-until", + ((state & RS_HELD) ? "indefinite" : "no-hold")); } /* @@ -359,13 +357,13 @@ lpsched_user_to_job_attributes(papi_attribute_t ***list, char *user) if (host != NULL) { *host = NULL; papiAttributeListAddString(list, PAPI_ATTR_REPLACE, - "job-originating-user-name", user); + "job-originating-user-name", user); papiAttributeListAddString(list, PAPI_ATTR_REPLACE, - "job-originating-host-name", host + 1); + "job-originating-host-name", host + 1); *host = '@'; } else papiAttributeListAddString(list, PAPI_ATTR_REPLACE, - "job-originating-user-name", user); + "job-originating-user-name", user); } } @@ -380,55 +378,55 @@ lpsched_request_to_job_attributes(REQUEST *r, job_t *j) /* copies */ papiAttributeListAddInteger(&j->attributes, PAPI_ATTR_REPLACE, - "copies", r->copies); + "copies", r->copies); /* destination */ papiAttributeListAddLPString(&j->attributes, PAPI_ATTR_REPLACE, - "printer-name", r->destination); + "printer-name", r->destination); /* form */ papiAttributeListAddLPString(&j->attributes, PAPI_ATTR_REPLACE, - "form", r->form); + "form", r->form); /* options */ papiAttributeListFromString(&j->attributes, PAPI_ATTR_APPEND, - r->options); + r->options); tmp = (((r->options != NULL) && (strstr(r->options, "nobanner") - != NULL)) ? "none" : "standard"); + != NULL)) ? "none" : "standard"); papiAttributeListAddString(&j->attributes, PAPI_ATTR_REPLACE, - "job-sheets", tmp); + "job-sheets", tmp); tmp = (((r->options != NULL) && (strstr(r->options, "duplex") - != NULL)) ? "two-sized" : "one-sided"); + != NULL)) ? "two-sized" : "one-sided"); papiAttributeListAddString(&j->attributes, PAPI_ATTR_REPLACE, - "sides", tmp); + "sides", tmp); i = (((r->options != NULL) && (strstr(r->options, "landscape") - != NULL)) ? 4 : 3); + != NULL)) ? 4 : 3); papiAttributeListAddInteger(&j->attributes, PAPI_ATTR_REPLACE, - "orientation-requested", i); + "orientation-requested", i); /* priority (map 0-39 to 1-100) */ papiAttributeListAddInteger(&j->attributes, PAPI_ATTR_REPLACE, - "job-priority", - (int)(100 - (r->priority * 2.5))); + "job-priority", + (int)(100 - (r->priority * 2.5))); /* pages */ papiAttributeListAddLPString(&j->attributes, PAPI_ATTR_REPLACE, - "page-ranges", r->pages); + "page-ranges", r->pages); /* charset */ papiAttributeListAddLPString(&j->attributes, PAPI_ATTR_REPLACE, - "lp-charset", r->charset); + "lp-charset", r->charset); /* modes */ papiAttributeListAddLPString(&j->attributes, PAPI_ATTR_REPLACE, - "lp-modes", r->modes); + "lp-modes", r->modes); /* title */ papiAttributeListAddLPString(&j->attributes, PAPI_ATTR_REPLACE, - "job-name", r->title); + "job-name", r->title); /* input_type */ @@ -440,11 +438,11 @@ lpsched_request_to_job_attributes(REQUEST *r, job_t *j) /* constants, (should be derived from options) */ papiAttributeListAddInteger(&j->attributes, PAPI_ATTR_REPLACE, - "number-up", 1); + "number-up", 1); papiAttributeListAddString(&j->attributes, PAPI_ATTR_REPLACE, - "multiple-document-handling", - "seperate-documents-collated-copies"); + "multiple-document-handling", + "seperate-documents-collated-copies"); } /* @@ -460,48 +458,48 @@ job_status_to_attributes(job_t *job, char *req_id, char *user, char *slabel, lpsched_user_to_job_attributes(&job->attributes, user); papiAttributeListAddInteger(&job->attributes, PAPI_ATTR_REPLACE, - "job-k-octets", size/1024); + "job-k-octets", size/1024); papiAttributeListAddInteger(&job->attributes, PAPI_ATTR_REPLACE, - "job-octets", size); + "job-octets", size); if ((p = strrchr(req_id, '-')) != NULL) { papiAttributeListAddInteger(&job->attributes, PAPI_ATTR_REPLACE, - "job-id", atoi(++p)); + "job-id", atoi(++p)); } snprintf(buf, sizeof (buf), "lpsched://localhost/printers/%s/%d", - destination, atoi(p)); + destination, atoi(p)); papiAttributeListAddString(&job->attributes, PAPI_ATTR_REPLACE, - "job-uri", buf); + "job-uri", buf); snprintf(buf, sizeof (buf), "lpsched://localhost/printers/%s", - destination); + destination); papiAttributeListAddString(&job->attributes, PAPI_ATTR_REPLACE, - "job-printer-uri", buf); + "job-printer-uri", buf); papiAttributeListAddInteger(&job->attributes, PAPI_ATTR_REPLACE, - "job-printer-up-time", time(NULL)); + "job-printer-up-time", time(NULL)); papiAttributeListAddString(&job->attributes, PAPI_ATTR_REPLACE, - "output-device-assigned", destination); + "output-device-assigned", destination); papiAttributeListAddString(&job->attributes, PAPI_ATTR_REPLACE, - "printer-name", destination); + "printer-name", destination); papiAttributeListAddLPString(&job->attributes, PAPI_ATTR_REPLACE, - "form", form); + "form", form); lpsched_request_outcome_to_attributes(&job->attributes, state); papiAttributeListAddInteger(&job->attributes, PAPI_ATTR_REPLACE, - "time-at-creation", date); + "time-at-creation", date); papiAttributeListAddLPString(&job->attributes, PAPI_ATTR_REPLACE, - "lpsched-request-id", req_id); + "lpsched-request-id", req_id); papiAttributeListAddLPString(&job->attributes, PAPI_ATTR_REPLACE, - "lp-charset", charset); + "lp-charset", charset); papiAttributeListAddInteger(&job->attributes, PAPI_ATTR_REPLACE, - "lpsched-job-state", state); + "lpsched-job-state", state); papiAttributeListAddInteger(&job->attributes, PAPI_ATTR_REPLACE, - "number-of-intervening-jobs", rank - 1); + "number-of-intervening-jobs", rank - 1); papiAttributeListAddLPString(&job->attributes, PAPI_ATTR_REPLACE, - "lpsched-file", file); + "lpsched-file", file); papiAttributeListAddLPString(&job->attributes, PAPI_ATTR_EXCL, - "job-name", file); + "job-name", file); papiAttributeListAddLPString(&job->attributes, PAPI_ATTR_EXCL, - "tsol-sensitivity-label", slabel); + "tsol-sensitivity-label", slabel); } void @@ -511,7 +509,7 @@ lpsched_read_job_configuration(service_t *svc, job_t *j, char *file) if ((r = getrequest(file)) == NULL) { detailed_error(svc, gettext("unable to read job data: %s"), - file); + file); return; } diff --git a/usr/src/cmd/print/bsd-sysv-commands/lpstat.c b/usr/src/cmd/print/bsd-sysv-commands/lpstat.c index ecf5d0b54f..4ba932cc91 100644 --- a/usr/src/cmd/print/bsd-sysv-commands/lpstat.c +++ b/usr/src/cmd/print/bsd-sysv-commands/lpstat.c @@ -700,6 +700,8 @@ report_job(papi_job_t job, int show_rank, int verbose) char *destination = "unknown"; int32_t id = -1; + static int check = 0; + static char *uri = NULL; (void) papiAttributeListGetString(attrs, NULL, "job-originating-user-name", &user); @@ -710,11 +712,75 @@ report_job(papi_job_t job, int show_rank, int verbose) (void) papiAttributeListGetString(attrs, NULL, "job-originating-host-name", &host); - if (host) - snprintf(User, sizeof (User), "%s@%s", user, host); - else - snprintf(User, sizeof (User), "%s", user); + if (check == 0) { + /* + * Read the attribute "job-printer-uri" + * just once + */ + (void) papiAttributeListGetString(attrs, NULL, + "job-printer-uri", &uri); + check = 1; + } + + if (host) { + /* Check if it is local printer or remote printer */ + uri_t *u = NULL; + + if ((uri != NULL) && (uri_from_string(uri, &u) == 0)) { + char *nodename = localhostname(); + + if ((u->host == NULL) || + (strcasecmp(u->host, "localhost") == 0) || + (strcasecmp(u->host, nodename) == 0)) { + if (strcasecmp(host, nodename) == 0) { + /* + * Request submitted locally + * for the local queue. + * Hostname will not be displayed + */ + snprintf(User, sizeof (User), "%s", + user); + } + else + snprintf(User, sizeof (User), "%s@%s", + user, host); + } else if (uri != NULL) { + /* + * It's a remote printer. + * In case of remote printers hostname is + * always displayed. + */ + snprintf(User, sizeof (User), "%s@%s", + user, host); + } + uri_free(u); + } else { + /* + * If attribute "job-printer-uri" + * cannot be read + * by default append the hostname + */ + snprintf(User, sizeof (User), "%s@%s", user, host); + } + } else { + /* + * When print server is s10u4 and ipp service is used + * "job-originating-hostname" attribute is not set + * So get the host information from the uri + */ + uri_t *u = NULL; + if ((uri != NULL) && (uri_from_string(uri, &u) == 0)) { + if ((u != NULL) && (u->host != NULL)) + snprintf(User, sizeof (User), "%s@%s", + user, u->host); + else + snprintf(User, sizeof (User), "%s", user); + + uri_free(u); + } else + snprintf(User, sizeof (User), "%s", user); + } (void) papiAttributeListGetInteger(attrs, NULL, "job-k-octets", &size); size *= 1024; /* for the approximate byte size */ (void) papiAttributeListGetInteger(attrs, NULL, "job-octets", &size); diff --git a/usr/src/lib/print/libipp-listener/Makefile.com b/usr/src/lib/print/libipp-listener/Makefile.com index 74db2efd60..6e06c1a360 100644 --- a/usr/src/lib/print/libipp-listener/Makefile.com +++ b/usr/src/lib/print/libipp-listener/Makefile.com @@ -19,10 +19,9 @@ # CDDL HEADER END # # -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Copyright 2009 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # -# ident "%Z%%M% %I% %E% SMI" # LIBRARY = libipp-listener.a @@ -55,7 +54,7 @@ CPPFLAGS += -I../../libipp-core/common MAPFILES = $(SRCDIR)/mapfile -LDLIBS += -lipp-core -lpapi -lc +LDLIBS += -lipp-core -lpapi -lc -lsocket -lnsl .KEEP_STATE: diff --git a/usr/src/lib/print/libipp-listener/common/print-job.c b/usr/src/lib/print/libipp-listener/common/print-job.c index 3b24d53339..4b95f32819 100644 --- a/usr/src/lib/print/libipp-listener/common/print-job.c +++ b/usr/src/lib/print/libipp-listener/common/print-job.c @@ -20,17 +20,20 @@ */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * */ /* $Id: print-job.c 146 2006-03-24 00:26:54Z njacobs $ */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <stdio.h> #include <stdlib.h> +#include <netdb.h> +#include <sys/types.h> +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> #include <papi.h> #include <ipp.h> #include <ipp-listener.h> @@ -47,12 +50,13 @@ ipp_print_job(papi_service_t svc, papi_attribute_t **request, char *queue = NULL; ssize_t rc; char buf[BUFSIZ]; + char *host = NULL; char *keys[] = { "attributes-natural-language", "attributes-charset", "printer-uri", NULL }; /* Get operational attributes from the request */ (void) papiAttributeListGetCollection(request, NULL, - "operational-attributes-group", &operational); + "operational-attributes-group", &operational); /* * The operational-attributes-group must contain: @@ -61,7 +65,7 @@ ipp_print_job(papi_service_t svc, papi_attribute_t **request, get_printer_id(operational, &queue, NULL); if (queue == NULL) { ipp_set_status(response, status, "printer-uri: %s", - papiStatusString(status)); + papiStatusString(status)); return (PAPI_BAD_REQUEST); } @@ -83,15 +87,59 @@ ipp_print_job(papi_service_t svc, papi_attribute_t **request, /* copy any job-attributes-group attributes for the PAPI call */ if (papiAttributeListGetCollection(request, NULL, - "job-attributes-group", &operational) == PAPI_OK) + "job-attributes-group", &operational) == PAPI_OK) copy_attributes(&job_attributes, operational); + /* Set "job-originating-host-name" attribute if not set */ + papiAttributeListGetString(job_attributes, NULL, + "job-originating-host-name", &host); + + if (host == NULL) { + int fd = -1; + (void) papiAttributeListGetInteger(request, NULL, + "peer-socket", &fd); + + if (fd != -1) { + struct sockaddr_in peer; + int peer_len; + + peer_len = sizeof (peer); + if (getpeername(fd, (struct sockaddr *)&peer, + &peer_len) == 0) { + struct hostent *he; + int error_num; + + he = getipnodebyaddr(&peer.sin_addr, + sizeof (peer.sin_addr), + peer.sin_family, &error_num); + + if ((he != NULL) && (he->h_name != NULL)) { + papiAttributeListAddString( + &job_attributes, + PAPI_ATTR_REPLACE, + "job-originating-host-name", + he->h_name); + } else { + /* + * Node-name could not be read + * so set the ip-address + */ + papiAttributeListAddString( + &job_attributes, + PAPI_ATTR_REPLACE, + "job-originating-host-name", + inet_ntoa(peer.sin_addr)); + } + } + } + } + /* request job creation with a resulting stream that we can write to */ status = papiJobStreamOpen(svc, queue, job_attributes, NULL, &s); papiAttributeListFree(job_attributes); if (status != PAPI_OK) { ipp_set_status(response, status, "job submission: %s", - ipp_svc_status_mesg(svc, status)); + ipp_svc_status_mesg(svc, status)); return (status); } @@ -100,7 +148,7 @@ ipp_print_job(papi_service_t svc, papi_attribute_t **request, status = papiJobStreamWrite(svc, s, buf, rc); if (status != PAPI_OK) { ipp_set_status(response, status, "write job data: %s", - ipp_svc_status_mesg(svc, status)); + ipp_svc_status_mesg(svc, status)); return (status); } @@ -108,7 +156,7 @@ ipp_print_job(papi_service_t svc, papi_attribute_t **request, status = papiJobStreamClose(svc, s, &j); if (status != PAPI_OK) { ipp_set_status(response, status, "close job stream: %s", - ipp_svc_status_mesg(svc, status)); + ipp_svc_status_mesg(svc, status)); papiJobFree(j); /* we shouldn't have a job, but just in case */ return (status); } diff --git a/usr/src/lib/print/libpapi-ipp/common/job.c b/usr/src/lib/print/libpapi-ipp/common/job.c index 0c4aac1af2..c2938850dc 100644 --- a/usr/src/lib/print/libpapi-ipp/common/job.c +++ b/usr/src/lib/print/libpapi-ipp/common/job.c @@ -140,6 +140,23 @@ populate_job_request(service_t *svc, papi_attribute_t ***request, /* add the job attributes group to the request */ if (job != NULL) { + /* + * Add job-originating-host-name to attributes + * if not already set. + */ + char *hostname = NULL; + + papiAttributeListGetString(job, NULL, + "job-originating-host-name", &hostname); + + if (hostname == NULL) { + char host[BUFSIZ]; + + if (gethostname(host, sizeof (host)) == 0) + papiAttributeListAddString(&job, PAPI_ATTR_EXCL, + "job-originating-host-name", host); + } + papiAttributeListAddCollection(request, PAPI_ATTR_REPLACE, "job-attributes-group", job); papiAttributeListFree(job); |