1
/*___INFO__MARK_BEGIN__*/
2
/*************************************************************************
4
* The Contents of this file are made available subject to the terms of
5
* the Sun Industry Standards Source License Version 1.2
7
* Sun Microsystems Inc., March, 2001
10
* Sun Industry Standards Source License Version 1.2
11
* =================================================
12
* The contents of this file are subject to the Sun Industry Standards
13
* Source License Version 1.2 (the "License"); You may not use this file
14
* except in compliance with the License. You may obtain a copy of the
15
* License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
17
* Software provided under this License is provided on an "AS IS" basis,
18
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
19
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
20
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
21
* See the License for the specific provisions governing your rights and
22
* obligations concerning the Software.
24
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
26
* Copyright: 2001 by Sun Microsystems, Inc.
28
* All Rights Reserved.
30
************************************************************************/
31
/*___INFO__MARK_END__*/
37
#include "sge_all_listsL.h"
40
#include "sge_order.h"
41
#include "sge_follow.h"
42
#include "sge_c_gdi.h"
44
#include "sge_host_qmaster.h"
45
#include "sge_job_qmaster.h"
46
#include "sge_userset_qmaster.h"
47
#include "sge_calendar_qmaster.h"
48
#include "sge_manop_qmaster.h"
49
#include "sge_centry_qmaster.h"
50
#include "sge_cqueue_qmaster.h"
51
#include "sge_pe_qmaster.h"
52
#include "sge_resource_quota_qmaster.h"
53
#include "sge_resource_quota.h"
55
#include "configuration_qmaster.h"
56
#include "sge_event_master.h"
57
#include "sched_conf_qmaster.h"
58
#include "sge_userprj_qmaster.h"
59
#include "sge_ckpt_qmaster.h"
60
#include "sge_hgroup_qmaster.h"
61
#include "sge_sharetree_qmaster.h"
62
#include "sge_cuser_qmaster.h"
63
#include "sge_feature.h"
64
#include "sge_qmod_qmaster.h"
68
#include "sge_qmaster_threads.h"
71
#include "sge_security.h"
72
#include "sge_answer.h"
75
#include "sge_qinstance.h"
76
#include "sge_userprj.h"
78
#include "sge_userset.h"
79
#include "sge_manop.h"
80
#include "sge_calendar.h"
81
#include "sge_sharetree.h"
82
#include "sge_hgroup.h"
83
#include "sge_cuser.h"
84
#include "sge_centry.h"
85
#include "sge_cqueue.h"
87
#include "sge_advance_reservation_qmaster.h"
88
#include "sge_sched_process_events.h"
89
#include "sge_thread_scheduler.h"
90
#include "sge_thread_jvm.h"
92
#include "uti/sge_bootstrap.h"
94
#include "gdi/sge_gdi_packet_pb_cull.h"
95
#include "gdi/sge_gdi_packet.h"
97
#include "sgeobj/sge_event.h"
98
#include "sgeobj/sge_utility.h"
100
#include "msg_common.h"
101
#include "msg_qmaster.h"
104
sge_c_gdi_get(gdi_object_t *ao, sge_gdi_packet_class_t *packet, sge_gdi_task_class_t *task, monitoring_t *monitor);
107
sge_c_gdi_add(sge_gdi_ctx_class_t *ctx, sge_gdi_packet_class_t *packet, sge_gdi_task_class_t *task,
108
gdi_object_t *ao, int sub_command, monitoring_t *monitor);
110
static void sge_c_gdi_del(sge_gdi_ctx_class_t *ctx,
111
sge_gdi_packet_class_t *packet, sge_gdi_task_class_t *task,
113
monitoring_t *monitor);
115
static void sge_c_gdi_mod(sge_gdi_ctx_class_t *ctx, gdi_object_t *ao,
116
sge_gdi_packet_class_t *packet, sge_gdi_task_class_t *task,
118
monitoring_t *monitor);
120
static void sge_c_gdi_copy(sge_gdi_ctx_class_t *ctx, gdi_object_t *ao,
121
sge_gdi_packet_class_t *packet, sge_gdi_task_class_t *task, int sub_command,
122
monitoring_t *monitor);
124
static void sge_c_gdi_trigger(sge_gdi_ctx_class_t *ctx,
125
sge_gdi_packet_class_t *packet, sge_gdi_task_class_t *task,
126
monitoring_t *monitor);
128
static void sge_c_gdi_permcheck(sge_gdi_packet_class_t *packet, sge_gdi_task_class_t *task,
129
monitoring_t *monitor);
131
static void sge_gdi_do_permcheck(sge_gdi_packet_class_t *packet, sge_gdi_task_class_t *task);
133
static void sge_c_gdi_replace(sge_gdi_ctx_class_t *ctx, gdi_object_t *ao,
134
sge_gdi_packet_class_t *packet, sge_gdi_task_class_t *task,
135
int sub_command, monitoring_t *monitor);
139
sge_gdi_shutdown_event_client(sge_gdi_ctx_class_t *ctx, sge_gdi_packet_class_t *packet,
140
sge_gdi_task_class_t *task, monitoring_t *monitor,
141
object_description *object_base);
144
sge_gdi_tigger_thread_state_transition(sge_gdi_ctx_class_t *ctx,
145
sge_gdi_packet_class_t *packet,
146
sge_gdi_task_class_t *task,
147
monitoring_t *monitor);
149
static int get_client_id(lListElem*, int*);
152
trigger_scheduler_monitoring(sge_gdi_packet_class_t *packet, sge_gdi_task_class_t *task,
153
monitoring_t *monitor);
155
static int sge_chck_mod_perm_user(lList **alpp, u_long32 target, char *user, monitoring_t *monitor);
156
static int sge_chck_mod_perm_host(lList **alpp, u_long32 target, char *host,
157
char *commproc, int mod, lListElem *ep,
158
monitoring_t *monitor, object_description *object_base);
161
sge_task_check_get_perm_host(sge_gdi_packet_class_t *packet, sge_gdi_task_class_t *task,
162
monitoring_t *monitor, object_description *object_base);
165
static int schedd_mod(sge_gdi_ctx_class_t *ctx,
166
lList **alpp, lListElem *modp, lListElem *ep, int add,
167
const char *ruser, const char *rhost, gdi_object_t *object,
168
int sub_command, monitoring_t *monitor );
171
* Prevent these functions made inline by compiler. This is
172
* necessary for Solaris 10 dtrace pid provider to work.
175
#pragma no_inline(sge_c_gdi_permcheck, sge_c_gdi_trigger, sge_c_gdi_copy, sge_c_gdi_get, sge_c_gdi_del, sge_c_gdi_mod, sge_c_gdi_add, sge_c_gdi_copy)
178
/* ------------------------------ generic gdi objects --------------------- */
180
static gdi_object_t gdi_object[] = {
181
{ SGE_CALENDAR_LIST, CAL_name, CAL_Type, "calendar", SGE_TYPE_CALENDAR, calendar_mod, calendar_spool, calendar_update_queue_states },
182
{ SGE_EVENT_LIST, 0, NULL, "event", SGE_TYPE_NONE, NULL, NULL, NULL },
183
{ SGE_ADMINHOST_LIST, AH_name, AH_Type, "adminhost", SGE_TYPE_ADMINHOST, host_mod, host_spool, host_success },
184
{ SGE_SUBMITHOST_LIST, SH_name, SH_Type, "submithost", SGE_TYPE_SUBMITHOST, host_mod, host_spool, host_success },
185
{ SGE_EXECHOST_LIST, EH_name, EH_Type, "exechost", SGE_TYPE_EXECHOST, host_mod, host_spool, host_success },
186
{ SGE_CQUEUE_LIST, CQ_name, CQ_Type, "cluster queue", SGE_TYPE_CQUEUE, cqueue_mod, cqueue_spool, cqueue_success },
187
{ SGE_JOB_LIST, 0, NULL, "job", SGE_TYPE_JOB, NULL, NULL, NULL },
188
{ SGE_CENTRY_LIST, CE_name, CE_Type, "complex entry", SGE_TYPE_CENTRY, centry_mod, centry_spool, centry_success },
189
{ SGE_ORDER_LIST, 0, NULL, "order", SGE_TYPE_NONE, NULL, NULL, NULL },
190
{ SGE_MASTER_EVENT, 0, NULL, "master event", SGE_TYPE_NONE, NULL, NULL, NULL },
191
{ SGE_MANAGER_LIST, 0, NULL, "manager", SGE_TYPE_MANAGER, NULL, NULL, NULL },
192
{ SGE_OPERATOR_LIST, 0, NULL, "operator", SGE_TYPE_OPERATOR, NULL, NULL, NULL },
193
{ SGE_PE_LIST, PE_name, PE_Type, "parallel environment", SGE_TYPE_PE, pe_mod, pe_spool, pe_success },
194
{ SGE_CONFIG_LIST, 0, NULL, "configuration", SGE_TYPE_NONE, NULL, NULL, NULL },
195
{ SGE_SC_LIST, 0, NULL, "scheduler configuration", SGE_TYPE_NONE, schedd_mod, NULL, NULL },
196
{ SGE_USER_LIST, UU_name, UU_Type, "user", SGE_TYPE_USER, userprj_mod, userprj_spool, userprj_success },
197
{ SGE_USERSET_LIST, US_name, US_Type, "userset", SGE_TYPE_USERSET, userset_mod, userset_spool, userset_success },
198
{ SGE_PROJECT_LIST, PR_name, PR_Type, "project", SGE_TYPE_PROJECT, userprj_mod, userprj_spool, userprj_success },
199
{ SGE_SHARETREE_LIST, 0, NULL, "sharetree", SGE_TYPE_SHARETREE, NULL, NULL, NULL },
200
{ SGE_CKPT_LIST, CK_name, CK_Type, "checkpoint interface", SGE_TYPE_CKPT, ckpt_mod, ckpt_spool, ckpt_success },
201
{ SGE_JOB_SCHEDD_INFO_LIST, 0, NULL, "schedd info", SGE_TYPE_JOB_SCHEDD_INFO, NULL, NULL, NULL },
202
{ SGE_ZOMBIE_LIST, 0, NULL, "job zombie list", SGE_TYPE_ZOMBIE, NULL, NULL, NULL },
203
{ SGE_RQS_LIST, RQS_name, RQS_Type, "resource quota set", SGE_TYPE_RQS, rqs_mod, rqs_spool, rqs_success },
204
#ifndef __SGE_NO_USERMAPPING__
205
{ SGE_USER_MAPPING_LIST, CU_name, CU_Type, "user mapping entry", SGE_TYPE_CUSER, cuser_mod, cuser_spool, cuser_success },
207
{ SGE_HGROUP_LIST, HGRP_name, HGRP_Type, "host group", SGE_TYPE_HGROUP, hgroup_mod, hgroup_spool, hgroup_success },
208
{ SGE_AR_LIST, AR_id, AR_Type, "advance reservation", SGE_TYPE_AR, ar_mod, ar_spool, ar_success },
209
{ SGE_DUMMY_LIST, 0, NULL, "general request", SGE_TYPE_NONE, NULL, NULL, NULL },
210
{ 0, 0, NULL, NULL, SGE_TYPE_NONE, NULL, NULL, NULL }
214
void sge_clean_lists(void)
218
for(;gdi_object[i].target != 0 ; i++) {
219
if (gdi_object[i].list_type != SGE_TYPE_NONE) {
220
lList **master_list = object_type_get_master_list(gdi_object[i].list_type);
221
/* fprintf(stderr, "---> freeing list %s, it has %d elems\n", gdi_object[i].object_name, lGetNumberOfElem(*master_list)); */
222
lFreeList(master_list);
230
/* EB: TODO: CLEANUP: should be replaced with sge_gdi_packet_verify_version() */
233
* MT-NOTE: verify_request_version() is MT safe
235
int verify_request_version(lList **alpp, u_long32 version, char *host, char *commproc, int id)
237
char *client_version = NULL;
240
const vdict_t *vp, *vdict = GRM_GDI_VERSION_ARRAY;
242
DENTER(TOP_LAYER, "verify_request_version");
244
if (version == GRM_GDI_VERSION) {
248
for (vp = &vdict[0]; vp->version; vp++) {
249
if (version == vp->version) {
250
client_version = vp->release;
255
sge_dstring_init(&ds, buffer, sizeof(buffer));
257
if (client_version) {
258
WARNING((SGE_EVENT, MSG_GDI_WRONG_GDI_SSISS,
259
host, commproc, id, client_version, feature_get_product_name(FS_VERSION, &ds)));
261
WARNING((SGE_EVENT, MSG_GDI_WRONG_GDI_SSIUS,
262
host, commproc, id, sge_u32c(version), feature_get_product_name(FS_VERSION, &ds)));
264
answer_list_add(alpp, SGE_EVENT, STATUS_EVERSION, ANSWER_QUALITY_ERROR);
270
/* ------------------------------------------------------------ */
272
sge_c_gdi(sge_gdi_ctx_class_t *ctx, sge_gdi_packet_class_t *packet,
273
sge_gdi_task_class_t *task, lList **answer_list, monitoring_t *monitor)
275
const char *target_name = NULL;
276
const char *operation_name = NULL;
279
sge_pack_buffer *pb = &(packet->pb);
281
DENTER(TOP_LAYER, "sge_c_gdi");
283
ao = get_gdi_object(task->target);
285
target_name = ao->object_name;
287
if (ao == NULL || target_name == NULL) {
288
target_name = MSG_UNKNOWN_OBJECT;
291
sub_command = SGE_GDI_GET_SUBCOMMAND(task->command);
292
task->command = SGE_GDI_GET_OPERATION(task->command);
293
operation_name = sge_gdi_task_get_operation_name(task);
295
DPRINTF(("GDI %s %s (%s/%s/%d) (%s/%d/%s/%d)\n",
296
operation_name, target_name, packet->host, packet->commproc,
297
(int)task->id, packet->user, (int)packet->uid, packet->group, (int)packet->gid));
299
switch (task->command) {
301
MONITOR_GDI_GET(monitor);
302
sge_c_gdi_get(ao, packet, task, monitor);
303
sge_gdi_packet_pack_task(packet, task, answer_list, pb);
306
MONITOR_GDI_ADD(monitor);
307
sge_c_gdi_add(ctx, packet, task, ao, sub_command, monitor);
308
sge_gdi_packet_pack_task(packet, task, answer_list, pb);
311
MONITOR_GDI_DEL(monitor);
312
sge_c_gdi_del(ctx, packet, task, sub_command, monitor);
313
sge_gdi_packet_pack_task(packet, task, answer_list, pb);
316
MONITOR_GDI_MOD(monitor);
317
sge_c_gdi_mod(ctx, ao, packet, task, sub_command, monitor);
318
sge_gdi_packet_pack_task(packet, task, answer_list, pb);
321
MONITOR_GDI_CP(monitor);
322
sge_c_gdi_copy(ctx, ao, packet, task, sub_command, monitor);
323
sge_gdi_packet_pack_task(packet, task, answer_list, pb);
325
case SGE_GDI_TRIGGER:
326
MONITOR_GDI_TRIG(monitor);
327
sge_c_gdi_trigger(ctx, packet, task, monitor);
328
sge_gdi_packet_pack_task(packet, task, answer_list, pb);
330
case SGE_GDI_PERMCHECK:
331
MONITOR_GDI_PERM(monitor);
332
sge_c_gdi_permcheck(packet, task, monitor);
333
sge_gdi_packet_pack_task(packet, task, answer_list, pb);
335
case SGE_GDI_REPLACE:
336
MONITOR_GDI_REPLACE(monitor);
337
sge_c_gdi_replace(ctx, ao, packet, task, sub_command, monitor);
338
sge_gdi_packet_pack_task(packet, task, answer_list, pb);
341
SGE_ADD_MSG_ID(sprintf(SGE_EVENT, MSG_SGETEXT_UNKNOWNOP));
342
answer_list_add(&(task->answer_list), SGE_EVENT, STATUS_ENOIMP,
343
ANSWER_QUALITY_ERROR);
344
sge_gdi_packet_pack_task(packet, task, answer_list, pb);
352
sge_c_gdi_get(gdi_object_t *ao, sge_gdi_packet_class_t *packet, sge_gdi_task_class_t *task, monitoring_t *monitor)
354
object_description *object_base = object_type_get_object_description();
356
DENTER(TOP_LAYER, "sge_c_gdi_get");
358
/* Whatever client sent with this get request - we don't need it */
359
lFreeList(&(task->data_list));
361
if (!sge_task_check_get_perm_host(packet, task, monitor, object_base)) {
366
switch (task->target) {
369
sprintf(SGE_EVENT, "SGE_QHOST\n");
370
answer_list_add(&(task->answer_list), SGE_EVENT, STATUS_OK, ANSWER_QUALITY_INFO);
371
task->do_select_pack_simultaneous = false;
376
task->data_list = sge_select_event_clients("", task->condition, task->enumeration);
377
task->do_select_pack_simultaneous = false;
378
sprintf(SGE_EVENT, MSG_GDI_OKNL);
379
answer_list_add(&(task->answer_list), SGE_EVENT, STATUS_OK, ANSWER_QUALITY_END);
382
case SGE_CONFIG_LIST: {
383
#if 0 /* EB: TODO PACKING */
384
do_gdi_get_config_list(request, answer, before, after);
388
conf = sge_get_configuration();
390
task->data_list = lSelectHashPack("", conf, task->condition, task->enumeration, false, NULL);
391
task->do_select_pack_simultaneous = false;
392
sprintf(SGE_EVENT, MSG_GDI_OKNL);
393
answer_list_add(&(task->answer_list), SGE_EVENT, STATUS_OK, ANSWER_QUALITY_END);
399
case SGE_SC_LIST: /* TODO EB: move this into the scheduler configuration,
400
and pack the list right away */
404
conf = sconf_get_config_list();
405
task->data_list = lSelectHashPack("", conf, task->condition, task->enumeration, false, NULL);
406
task->do_select_pack_simultaneous = false;
407
sprintf(SGE_EVENT, MSG_GDI_OKNL);
408
answer_list_add(&(task->answer_list), SGE_EVENT, STATUS_OK, ANSWER_QUALITY_END);
417
* If the scheduler is not available the information in the job info
418
* messages are outdated. In this case we have to reject the request.
420
if (task->target == SGE_JOB_SCHEDD_INFO_LIST &&
421
!sge_has_event_client(EV_ID_SCHEDD) ) {
422
answer_list_add(&(task->answer_list),MSG_SGETEXT_JOBINFOMESSAGESOUTDATED,
423
STATUS_ESEMANTIC, ANSWER_QUALITY_ERROR);
424
} else if (ao == NULL || ao->list_type == SGE_TYPE_NONE) {
425
SGE_ADD_MSG_ID(sprintf(SGE_EVENT, MSG_SGETEXT_OPNOIMPFORTARGET));
426
answer_list_add(&(task->answer_list), SGE_EVENT, STATUS_ENOIMP, ANSWER_QUALITY_ERROR);
428
lList *data_source = *object_type_get_master_list(ao->list_type);
430
if (packet->is_intern_request) {
431
/* intern requests need no pb so it is not necessary to postpone the operation */
432
task->data_list = lSelectHashPack("", data_source, task->condition,
433
task->enumeration, false, NULL);
434
task->do_select_pack_simultaneous = false;
437
* DIRTY HACK: The "ok" message should be removed from the answer list
438
* 05/21/2007 qualitiy was ANSWER_QUALITY_INFO but this results in "ok"
439
* messages on qconf side
441
sprintf(SGE_EVENT, MSG_GDI_OKNL);
442
answer_list_add(&(task->answer_list), SGE_EVENT, STATUS_OK, ANSWER_QUALITY_END);
445
/* lSelect will be postponed till packing */
446
task->data_list = data_source;
447
task->do_select_pack_simultaneous = true;
450
* answer list creation is also done during packing!!!!
460
* MT-NOTE: sge_c_gdi_add() is MT safe
463
sge_c_gdi_add(sge_gdi_ctx_class_t *ctx, sge_gdi_packet_class_t *packet, sge_gdi_task_class_t *task,
464
gdi_object_t *ao, int sub_command, monitoring_t *monitor)
467
lList *ticket_orders = NULL;
468
object_description *object_base = object_type_get_object_description();
470
DENTER(TOP_LAYER, "sge_c_gdi_add");
472
if (!packet->host || !packet->user || !packet->commproc) {
473
CRITICAL((SGE_EVENT, MSG_SGETEXT_NULLPTRPASSED_S, SGE_FUNC));
474
answer_list_add(&(task->answer_list), SGE_EVENT, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR);
479
/* check permissions of host and user */
480
if ((!sge_chck_mod_perm_user(&(task->answer_list), task->target, packet->user, monitor)) &&
481
(!sge_chck_mod_perm_host(&(task->answer_list), task->target, packet->host,
482
packet->commproc, 0, NULL, monitor, object_base))) {
484
if (task->target == SGE_EVENT_LIST) {
487
next = lFirst(task->data_list);
488
while ((ep = next) != NULL) {/* is thread save. the global lock is used, when needed */
491
/* fill address infos from request into event client that must be added */
492
lSetHost(ep, EV_host, packet->host);
493
lSetString(ep, EV_commproc, packet->commproc);
494
lSetUlong(ep, EV_commid, packet->commproc_id);
496
/* fill in authentication infos from request */
497
lSetUlong(ep, EV_uid, packet->uid);
498
if (!event_client_verify(ep, &(task->answer_list), true)) {
499
ERROR((SGE_EVENT, MSG_QMASTER_INVALIDEVENTCLIENT_SSS,
500
packet->user, packet->commproc, packet->host));
502
mconf_set_max_dynamic_event_clients(sge_set_max_dynamic_event_clients(mconf_get_max_dynamic_event_clients()));
504
sge_add_event_client(ep, &(task->answer_list),
505
(sub_command & SGE_GDI_RETURN_NEW_VERSION) ? &(task->data_list) : NULL,
506
packet->user, packet->host, (event_client_update_func_t)NULL, monitor);
509
} else if (task->target == SGE_JOB_LIST) {
512
next = lFirst(task->data_list);
513
while ((ep = next) != NULL) { /* is thread save. the global lock is used, when needed */
515
/* fill address infos from request into event client that must be added */
516
if (!job_verify_submitted_job(ep, &(task->answer_list))) {
517
ERROR((SGE_EVENT, MSG_QMASTER_INVALIDJOBSUBMISSION_SSS,
518
packet->user, packet->commproc, packet->host));
520
/* submit needs to know user and group */
522
ep, &(task->answer_list),
523
(sub_command & SGE_GDI_RETURN_NEW_VERSION) ?
524
&(task->data_list) : NULL,
525
packet->user, packet->host, packet->uid, packet->gid, packet->group,
526
packet, task, monitor);
529
} else if (task->target == SGE_SC_LIST ) {
532
next = lFirst(task->data_list);
533
while ((ep = next) != NULL) {
536
sge_mod_sched_configuration(ctx, ep, &(task->answer_list), packet->user, packet->host);
539
bool is_scheduler_resync = false;
540
lList *tmp_list = NULL;
543
if (task->target == SGE_ORDER_LIST) {
544
sge_set_commit_required();
547
next = lFirst(task->data_list);
548
while ((ep = next) != NULL) {
551
/* add each element */
552
switch (task->target) {
555
switch (sge_follow_order(ctx, ep, &(task->answer_list), packet->user, packet->host,
556
&ticket_orders, monitor, object_base)) {
558
case 0 : /* everything went fine */
560
case -2 : is_scheduler_resync = true;
563
/* stop the order processing */
564
WARNING((SGE_EVENT, "Skipping remaining %d orders", lGetNumberOfRemainingElem(ep)));
568
default : DPRINTF(("--> FAILED: unexpected state from in the order processing <--\n"));
572
case SGE_MANAGER_LIST:
573
case SGE_OPERATOR_LIST:
574
sge_add_manop(ctx, ep, &(task->answer_list), packet->user, packet->host, task->target);
577
case SGE_SHARETREE_LIST:
578
sge_add_sharetree(ctx, ep, object_base[SGE_TYPE_SHARETREE].list, &(task->answer_list), packet->user, packet->host);
583
SGE_ADD_MSG_ID( sprintf(SGE_EVENT, MSG_SGETEXT_OPNOIMPFORTARGET));
584
answer_list_add(&(task->answer_list), SGE_EVENT, STATUS_ENOIMP, ANSWER_QUALITY_ERROR);
588
if (task->target==SGE_EXECHOST_LIST && !strcmp(prognames[EXECD], packet->commproc)) {
592
* Evaluate subcommand.
594
if (sub_command == SGE_GDI_EXECD_RESTART) {
599
sge_execd_startedup(ctx, ep, &(task->answer_list), packet->user,
600
packet->host, task->target,
601
monitor, is_restart);
603
sge_gdi_add_mod_generic(ctx, &(task->answer_list), ep, 1, ao, packet->user, packet->host, sub_command, &tmp_list, monitor);
609
if (task->target == SGE_ORDER_LIST) {
611
sge_set_next_spooling_time();
612
answer_list_add(&(task->answer_list), "OK\n", STATUS_OK, ANSWER_QUALITY_INFO);
615
if (is_scheduler_resync) {
616
sge_resync_schedd(monitor); /* ask for a total update */
620
** tmp_list contains the changed AR element, set in ar_success
622
if (SGE_GDI_IS_SUBCOMMAND_SET(sub_command, SGE_GDI_RETURN_NEW_VERSION)) {
623
lFreeList(&(task->data_list));
624
task->data_list = tmp_list;
628
lFreeList(&tmp_list);
632
if (ticket_orders != NULL) {
633
if (mconf_get_reprioritize() == 1) {
634
distribute_ticket_orders(ctx, ticket_orders, monitor, object_base);
636
/* tickets not needed at execd's if no repriorization is done */
637
DPRINTF(("NO TICKET DELIVERY\n"));
640
lFreeList(&ticket_orders);
647
* MT-NOTE: sge_c_gdi-del() is MT safe
650
sge_c_gdi_del(sge_gdi_ctx_class_t *ctx,
651
sge_gdi_packet_class_t *packet, sge_gdi_task_class_t *task,
653
monitoring_t *monitor)
656
object_description *object_base = object_type_get_object_description();
658
DENTER(GDI_LAYER, "sge_c_gdi_del");
660
if (sge_chck_mod_perm_user(&(task->answer_list), task->target, packet->user, monitor)) {
664
if (sge_chck_mod_perm_host(&(task->answer_list), task->target, packet->host,
665
packet->commproc, 0, NULL, monitor, object_base)) {
669
if (task->data_list == NULL) {
670
/* delete whole list */
672
switch (task->target)
674
case SGE_SHARETREE_LIST:
675
sge_del_sharetree(ctx, object_base[SGE_TYPE_SHARETREE].list, &(task->answer_list),
676
packet->user, packet->host);
679
SGE_ADD_MSG_ID( sprintf(SGE_EVENT, MSG_SGETEXT_OPNOIMPFORTARGET));
680
answer_list_add(&(task->answer_list), SGE_EVENT, STATUS_ENOIMP, ANSWER_QUALITY_ERROR);
684
sge_set_commit_required();
686
for_each (ep, task->data_list) {
687
/* try to remove the element */
688
switch (task->target)
690
case SGE_ADMINHOST_LIST:
691
case SGE_SUBMITHOST_LIST:
692
case SGE_EXECHOST_LIST:
693
sge_del_host(ctx, ep, &(task->answer_list), packet->user, packet->host, task->target, *object_base[SGE_TYPE_HGROUP].list);
696
case SGE_CQUEUE_LIST:
697
cqueue_del(ctx, ep, &(task->answer_list), packet->user, packet->host);
701
sge_gdi_del_job(ctx, ep, &(task->answer_list), packet->user, packet->host, sub_command, monitor);
704
case SGE_CENTRY_LIST:
705
sge_del_centry(ctx, ep, &(task->answer_list), packet->user, packet->host);
709
sge_del_pe(ctx, ep, &(task->answer_list), packet->user, packet->host);
712
case SGE_MANAGER_LIST:
713
case SGE_OPERATOR_LIST:
714
sge_del_manop(ctx, ep, &(task->answer_list), packet->user, packet->host, task->target);
717
case SGE_CONFIG_LIST:
718
sge_del_configuration(ctx, ep, &(task->answer_list), packet->user, packet->host);
722
sge_del_userprj(ctx, ep, &(task->answer_list), object_base[SGE_TYPE_USER].list, packet->user, packet->host, 1);
725
case SGE_USERSET_LIST:
726
sge_del_userset(ctx, ep, &(task->answer_list), object_base[SGE_TYPE_USERSET].list, packet->user, packet->host);
729
case SGE_PROJECT_LIST:
730
sge_del_userprj(ctx, ep, &(task->answer_list), object_base[SGE_TYPE_PROJECT].list, packet->user, packet->host, 0);
734
rqs_del(ctx, ep, &(task->answer_list), object_base[SGE_TYPE_RQS].list, packet->user, packet->host);
738
sge_del_ckpt(ctx, ep, &(task->answer_list), packet->user, packet->host);
741
case SGE_CALENDAR_LIST:
742
sge_del_calendar(ctx, ep, &(task->answer_list), packet->user, packet->host);
744
#ifndef __SGE_NO_USERMAPPING__
745
case SGE_USER_MAPPING_LIST:
746
cuser_del(ctx, ep, &(task->answer_list), packet->user, packet->host);
749
case SGE_HGROUP_LIST:
750
hgroup_del(ctx, ep, &(task->answer_list), packet->user, packet->host);
753
ar_del(ctx, ep, &(task->answer_list), object_base[SGE_TYPE_AR].list, packet->user, packet->host, monitor);
756
SGE_ADD_MSG_ID( sprintf(SGE_EVENT, MSG_SGETEXT_OPNOIMPFORTARGET));
757
answer_list_add(&(task->answer_list), SGE_EVENT, STATUS_ENOIMP, ANSWER_QUALITY_ERROR);
759
} /* switch target */
761
} /* for_each element */
771
* MT-NOTE: sge_c_gdi_copy() is MT safe
773
static void sge_c_gdi_copy(sge_gdi_ctx_class_t *ctx, gdi_object_t *ao,
774
sge_gdi_packet_class_t *packet, sge_gdi_task_class_t *task, int sub_command,
775
monitoring_t *monitor)
777
lListElem *ep = NULL;
778
object_description *object_base = object_type_get_object_description();
780
DENTER(TOP_LAYER, "sge_c_gdi_copy");
782
if (!packet->host || !packet->user || !packet->commproc) {
783
CRITICAL((SGE_EVENT, MSG_SGETEXT_NULLPTRPASSED_S, SGE_FUNC));
784
answer_list_add(&(task->answer_list), SGE_EVENT, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR);
789
if (sge_chck_mod_perm_user(&(task->answer_list), task->target, packet->user, monitor)) {
794
if (sge_chck_mod_perm_host(&(task->answer_list), task->target, packet->host,
795
packet->commproc, 0, NULL, monitor, object_base)) {
800
for_each (ep, task->data_list) {
801
switch (task->target)
804
/* gdi_copy_job uses the global lock internal */
805
sge_gdi_copy_job(ctx, ep, &(task->answer_list),
806
(sub_command & SGE_GDI_RETURN_NEW_VERSION) ? &(task->answer_list) : NULL,
807
packet->user, packet->host, packet->uid, packet->gid, packet->group, packet, task, monitor);
811
SGE_ADD_MSG_ID( sprintf(SGE_EVENT, MSG_SGETEXT_OPNOIMPFORTARGET));
812
answer_list_add(&(task->answer_list), SGE_EVENT, STATUS_ENOIMP, ANSWER_QUALITY_ERROR);
821
/* ------------------------------------------------------------ */
823
static void sge_gdi_do_permcheck(sge_gdi_packet_class_t *packet, sge_gdi_task_class_t *task)
826
lListElem *ep = NULL;
828
DENTER(GDI_LAYER, "sge_gdi_do_permcheck");
831
DPRINTF(("User: %s\n", packet->user ));
833
if (task->answer_list == NULL) {
834
const char *mapped_user = NULL;
835
const char* requested_host = NULL;
836
bool did_mapping = false;
839
/* create PERM_Type list for answer structure*/
840
lp = lCreateList("permissions", PERM_Type);
841
ep = lCreateElem(PERM_Type);
844
/* set sge username */
845
lSetString(ep, PERM_sge_username, packet->user);
847
/* set requested host name */
848
if (task->data_list == NULL) {
849
requested_host = packet->host;
851
lList* tmp_lp = NULL;
852
lListElem* tmp_ep = NULL;
854
tmp_lp = task->data_list;
855
tmp_ep = tmp_lp->first;
856
requested_host = lGetHost(tmp_ep, PERM_req_host);
857
#ifndef __SGE_NO_USERMAPPING__
858
cuser_list_map_user(*(cuser_list_get_master_list()), NULL,
859
packet->user, requested_host, &mapped_user);
864
if (requested_host != NULL) {
865
lSetHost(ep, PERM_req_host, requested_host);
868
if (did_mapping && strcmp(mapped_user, packet->user)) {
869
DPRINTF(("execution mapping: user %s mapped to %s on host %s\n",
870
packet->user, mapped_user, requested_host));
872
lSetString(ep, PERM_req_username, mapped_user);
874
lSetString(ep, PERM_req_username, "");
878
/* check for manager permission */
880
if (manop_is_manager(packet->user)) {
883
lSetUlong(ep, PERM_manager, value);
885
/* check for operator permission */
887
if (manop_is_operator(packet->user)) {
890
lSetUlong(ep, PERM_operator, value);
891
if ((task->condition != NULL) && (task->enumeration != NULL)) {
892
task->data_list = lSelect("", lp, task->condition, task->enumeration);
895
task->data_list = lp;
899
sprintf(SGE_EVENT, MSG_GDI_OKNL);
900
answer_list_add(&(task->answer_list), SGE_EVENT, STATUS_OK, ANSWER_QUALITY_END);
906
* MT-NOTE: sge_c_gdi_permcheck() is MT safe
909
sge_c_gdi_permcheck(sge_gdi_packet_class_t *packet, sge_gdi_task_class_t *task,
910
monitoring_t *monitor)
912
DENTER(GDI_LAYER, "sge_c_gdi_permcheck");
913
switch (task->target) {
915
sge_gdi_do_permcheck(packet, task);
918
WARNING((SGE_EVENT, MSG_SGETEXT_OPNOIMPFORTARGET));
919
answer_list_add(&(task->answer_list), SGE_EVENT, STATUS_ENOIMP, ANSWER_QUALITY_ERROR);
924
void sge_c_gdi_replace(sge_gdi_ctx_class_t *ctx, gdi_object_t *ao,
925
sge_gdi_packet_class_t *packet, sge_gdi_task_class_t *task,
926
int sub_command, monitoring_t *monitor)
928
lList *tmp_list = NULL;
929
lListElem *ep = NULL;
930
object_description *object_base = object_type_get_object_description();
932
DENTER(GDI_LAYER, "sge_c_gdi_replace");
934
if (sge_chck_mod_perm_user(&(task->answer_list), task->target, packet->user, monitor)) {
938
if (sge_chck_mod_perm_host(&(task->answer_list), task->target, packet->host,
939
packet->commproc, 0, NULL, monitor, object_base)) {
943
switch (task->target)
947
if (rqs_replace_request_verify(&(task->answer_list), task->data_list) != true) {
950
/* delete all currently defined rule sets */
951
ep = lFirst(*object_base[SGE_TYPE_RQS].list);
953
rqs_del(ctx, ep, &(task->answer_list), object_base[SGE_TYPE_RQS].list, packet->user, packet->host);
954
ep = lFirst(*object_base[SGE_TYPE_RQS].list);
957
for_each(ep, task->data_list) {
958
sge_gdi_add_mod_generic(ctx, &(task->answer_list), ep, 1, ao, packet->user, packet->host, SGE_GDI_SET_ALL, &tmp_list, monitor);
960
lFreeList(&tmp_list);
964
SGE_ADD_MSG_ID(sprintf(SGE_EVENT, MSG_SGETEXT_OPNOIMPFORTARGET));
965
answer_list_add(&(task->answer_list), SGE_EVENT, STATUS_ENOIMP, ANSWER_QUALITY_ERROR);
972
* MT-NOTE: sge_c_gdi_trigger() is MT safe
975
sge_c_gdi_trigger(sge_gdi_ctx_class_t *ctx, sge_gdi_packet_class_t *packet,
976
sge_gdi_task_class_t *task, monitoring_t *monitor)
978
u_long32 target = task->target;
979
object_description *object_base = object_type_get_object_description();
981
DENTER(GDI_LAYER, "sge_c_gdi_trigger");
984
case SGE_EXECHOST_LIST: /* kill execd */
985
case SGE_MASTER_EVENT: /* kill master */
986
case SGE_SC_LIST: /* trigger scheduler monitoring */
987
if (!host_list_locate(*object_base[SGE_TYPE_ADMINHOST].list, packet->host)) {
988
ERROR((SGE_EVENT, MSG_SGETEXT_NOADMINHOST_S, packet->host));
989
answer_list_add(&(task->answer_list), SGE_EVENT, STATUS_EDENIED2HOST, ANSWER_QUALITY_ERROR);
990
SGE_UNLOCK(LOCK_GLOBAL, LOCK_WRITE);
995
if (SGE_EXECHOST_LIST == target) {
996
sge_gdi_kill_exechost(ctx, packet, task);
999
if (SGE_SC_LIST == target) {
1000
trigger_scheduler_monitoring(packet, task, monitor);
1001
} else if (target == SGE_MASTER_EVENT) {
1002
sge_gdi_kill_master(packet, task);
1006
case SGE_CQUEUE_LIST:
1008
sge_set_commit_required();
1009
sge_gdi_qmod(ctx, packet, task, monitor);
1013
case SGE_EVENT_LIST:
1014
/* kill scheduler or event client */
1015
sge_gdi_shutdown_event_client(ctx, packet, task, monitor, object_base);
1016
answer_list_log(&(task->answer_list), false, true);
1018
case SGE_DUMMY_LIST:
1019
sge_gdi_tigger_thread_state_transition(ctx, packet, task, monitor);
1020
answer_list_log(&(task->answer_list), false, true);
1023
/* permissions should be checked in the functions. Here we don't
1024
know what is to do, so we don't know what permissions we need */
1025
WARNING((SGE_EVENT, MSG_SGETEXT_OPNOIMPFORTARGET));
1026
answer_list_add(&(task->answer_list), SGE_EVENT, STATUS_ENOIMP, ANSWER_QUALITY_ERROR);
1035
sge_gdi_tigger_thread_state_transition(sge_gdi_ctx_class_t *ctx,
1036
sge_gdi_packet_class_t *packet,
1037
sge_gdi_task_class_t *task,
1038
monitoring_t *monitor)
1040
lListElem *elem = NULL; /* ID_Type */
1041
lList **answer_list = &(task->answer_list);
1043
DENTER(TOP_LAYER, "sge_gdi_tigger_thread_state_transition");
1044
for_each (elem, task->data_list) {
1045
const char *name = lGetString(elem, ID_str);
1046
sge_thread_state_transitions_t action = (sge_thread_state_transitions_t) lGetUlong(elem, ID_action);
1049
if (strcasecmp(name, threadnames[SCHEDD_THREAD]) == 0) {
1050
if (action == SGE_THREAD_TRIGGER_START) {
1051
sge_scheduler_initialize(ctx, answer_list);
1052
} else if (action == SGE_THREAD_TRIGGER_STOP) {
1053
sge_scheduler_terminate(ctx, answer_list);
1055
ERROR((SGE_EVENT, MSG_TRIGGER_STATENOTSUPPORTED_DS, action, name));
1056
answer_list_add(&(task->answer_list), SGE_EVENT,
1057
STATUS_EEXIST, ANSWER_QUALITY_WARNING);
1060
} else if (strcasecmp(name, threadnames[JVM_THREAD]) == 0) {
1061
if (action == SGE_THREAD_TRIGGER_START) {
1062
sge_jvm_initialize(ctx, answer_list);
1063
} else if (action == SGE_THREAD_TRIGGER_STOP) {
1064
sge_jvm_terminate(ctx, answer_list);
1066
ERROR((SGE_EVENT, MSG_TRIGGER_STATENOTSUPPORTED_DS, action, name));
1067
answer_list_add(&(task->answer_list), SGE_EVENT,
1068
STATUS_EEXIST, ANSWER_QUALITY_WARNING);
1072
ERROR((SGE_EVENT, MSG_TRIGGER_NOTSUPPORTED_S, name));
1073
answer_list_add(&(task->answer_list), SGE_EVENT,
1074
STATUS_EEXIST, ANSWER_QUALITY_WARNING);
1077
ERROR((SGE_EVENT, MSG_TRIGGER_NOTSUPPORTED_S, ""));
1078
answer_list_add(&(task->answer_list), SGE_EVENT,
1079
STATUS_EEXIST, ANSWER_QUALITY_WARNING);
1085
/****** qmaster/sge_c_gdi/sge_gdi_shutdown_event_client() **********************
1087
* sge_gdi_shutdown_event_client() -- shutdown event client
1091
* sge_gdi_shutdown_event_client(sge_gdi_ctx_class_t *ctx,
1092
* sge_gdi_packet_class_t *packet,
1093
* sge_gdi_task_class_t *task,
1094
* monitoring_t *monitor,
1095
* object_description *object_base)
1098
* Shutdown event clients by client id. tasks data_list does contain a list of
1099
* client id's. This is a list of 'ID_Type' elements.
1102
* sge_gdi_ctx_class_t *ctx - context
1103
* sge_gdi_packet_class_t *packet - request packet
1104
* sge_gdi_task_class_t *task - request task
1105
* monitoring_t *monitor - the monitoring structure
1111
* MT-NOTE: sge_gdi_shutdown_event_client() is NOT MT safe.
1113
*******************************************************************************/
1115
sge_gdi_shutdown_event_client(sge_gdi_ctx_class_t *ctx, sge_gdi_packet_class_t *packet,
1116
sge_gdi_task_class_t *task, monitoring_t *monitor,
1117
object_description *object_base)
1119
lListElem *elem = NULL; /* ID_Type */
1121
DENTER(TOP_LAYER, "sge_gdi_shutdown_event_client");
1123
for_each (elem, task->data_list) {
1124
lList *local_alp = NULL;
1125
int client_id = EV_ID_ANY;
1128
if (get_client_id(elem, &client_id) != 0) {
1129
answer_list_add(&(task->answer_list), SGE_EVENT, STATUS_EEXIST, ANSWER_QUALITY_ERROR);
1133
if (client_id == EV_ID_SCHEDD &&
1134
!host_list_locate(*object_base[SGE_TYPE_ADMINHOST].list, packet->host)) {
1135
ERROR((SGE_EVENT, MSG_SGETEXT_NOADMINHOST_S, packet->host));
1136
answer_list_add(&(task->answer_list), SGE_EVENT, STATUS_EDENIED2HOST, ANSWER_QUALITY_ERROR);
1138
} else if (!host_list_locate(*object_base[SGE_TYPE_SUBMITHOST].list, packet->host)
1139
&& !host_list_locate(*object_base[SGE_TYPE_ADMINHOST].list, packet->host)) {
1140
ERROR((SGE_EVENT, MSG_SGETEXT_NOSUBMITORADMINHOST_S, packet->host));
1141
answer_list_add(&(task->answer_list), SGE_EVENT, STATUS_EDENIED2HOST, ANSWER_QUALITY_ERROR);
1145
/* thread shutdown */
1146
if (client_id == EV_ID_SCHEDD) {
1147
sge_scheduler_terminate(ctx, NULL);
1150
if (client_id == EV_ID_ANY) {
1151
res = sge_shutdown_dynamic_event_clients(packet->user, &(local_alp), monitor);
1153
res = sge_shutdown_event_client(client_id, packet->user, packet->uid, &(local_alp), monitor);
1156
if ((res == EINVAL) && (client_id == EV_ID_SCHEDD)) {
1157
lFreeList(&local_alp);
1158
answer_list_add(&(task->answer_list), MSG_COM_NOSCHEDDREGMASTER, STATUS_EEXIST, ANSWER_QUALITY_WARNING);
1161
answer_list_append_list(&(task->answer_list), &local_alp);
1167
} /* sge_gdi_shutdown_event_client() */
1169
/****** qmaster/sge_c_gdi/get_client_id() **************************************
1171
* get_client_id() -- get client id from ID_Type element.
1174
* static int get_client_id(lListElem *anElem, int *anID)
1177
* Get client id from ID_Type element. The client id is converted to an
1178
* integer and stored in 'anID'.
1181
* lListElem *anElem - ID_Type element
1182
* int *anID - will contain client id on return
1185
* EINVAL - failed to extract client id.
1189
* MT-NOTE: get_client_id() is MT safe.
1191
* Using 'errno' to check for 'strtol' error situations is recommended
1194
*******************************************************************************/
1195
static int get_client_id(lListElem *anElem, int *anID)
1197
const char *id = NULL;
1199
DENTER(TOP_LAYER, "get_client_id");
1201
if ((id = lGetString(anElem, ID_str)) == NULL)
1207
errno = 0; /* errno is thread local */
1209
*anID = strtol(id, NULL, 0);
1213
ERROR((SGE_EVENT, MSG_GDI_EVENTCLIENTIDFORMAT_S, id));
1220
} /* get_client_id() */
1222
/****** qmaster/sge_c_gdi/trigger_scheduler_monitoring() ***********************
1224
* trigger_scheduler_monitoring() -- trigger scheduler monitoring
1228
* trigger_scheduler_monitoring(sge_gdi_packet_class_t *packet, sge_gdi_task_class_t *task,
1229
* monitoring_t *monitor)
1232
* Trigger scheduler monitoring.
1235
* sge_gdi_packet_class_t *packet - request packet
1236
* sge_gdi_task_class_t *task - request task
1242
* MT-NOTE: trigger_scheduler_monitoring() is MT safe, using global lock
1247
*******************************************************************************/
1249
trigger_scheduler_monitoring(sge_gdi_packet_class_t *packet, sge_gdi_task_class_t *task,
1250
monitoring_t *monitor)
1253
DENTER(GDI_LAYER, "trigger_scheduler_monitoring");
1255
if (!manop_is_manager(packet->user)) {
1256
SGE_UNLOCK(LOCK_GLOBAL, LOCK_READ);
1257
WARNING((SGE_EVENT, MSG_COM_NOSCHEDMONPERMS));
1258
answer_list_add(&(task->answer_list), SGE_EVENT, STATUS_ENOMGR, ANSWER_QUALITY_WARNING);
1262
if (!sge_add_event_for_client(EV_ID_SCHEDD, 0, sgeE_SCHEDDMONITOR, 0, 0, NULL, NULL, NULL, NULL)) {
1263
WARNING((SGE_EVENT, MSG_COM_NOSCHEDDREGMASTER));
1264
answer_list_add(&(task->answer_list), SGE_EVENT, STATUS_EEXIST, ANSWER_QUALITY_WARNING);
1269
INFO((SGE_EVENT, MSG_COM_SCHEDMON_SS, packet->user, packet->host));
1270
answer_list_add(&(task->answer_list), SGE_EVENT, STATUS_OK, ANSWER_QUALITY_INFO);
1274
} /* trigger_scheduler_monitoring() */
1277
* MT-NOTE: sge_c_gdi_mod() is MT safe
1279
void sge_c_gdi_mod(sge_gdi_ctx_class_t *ctx, gdi_object_t *ao,
1280
sge_gdi_packet_class_t *packet, sge_gdi_task_class_t *task, int sub_command,
1281
monitoring_t *monitor)
1284
lList *tmp_list = NULL;
1285
bool is_locked = false;
1286
object_description *object_base = object_type_get_object_description();
1288
DENTER(TOP_LAYER, "sge_c_gdi_mod");
1290
if (sge_chck_mod_perm_user(&(task->answer_list), task->target, packet->user, monitor)) {
1295
for_each (ep, task->data_list) {
1296
if (sge_chck_mod_perm_host(&(task->answer_list), task->target, packet->host,
1297
packet->commproc, 1, ep, monitor, object_base)) {
1301
if (task->target == SGE_CONFIG_LIST) {
1302
sge_mod_configuration(ctx, ep, &(task->answer_list), packet->user, packet->host);
1303
} else if (task->target == SGE_EVENT_LIST) {
1304
/* fill address infos from request into event client that must be added */
1305
lSetHost(ep, EV_host, packet->host);
1306
lSetString(ep, EV_commproc, packet->commproc);
1307
lSetUlong(ep, EV_commid, packet->id);
1309
/* fill in authentication infos from request */
1310
lSetUlong(ep, EV_uid, packet->uid);
1311
if (!event_client_verify(ep, &(task->answer_list), false)) {
1312
ERROR((SGE_EVENT, MSG_QMASTER_INVALIDEVENTCLIENT_SSS,
1313
packet->user, packet->commproc, packet->host));
1315
sge_mod_event_client(ep, &(task->answer_list), packet->user, packet->host);
1317
} else if (task->target == SGE_SC_LIST) {
1318
sge_mod_sched_configuration(ctx, ep, &(task->answer_list), packet->user, packet->host);
1321
sge_set_commit_required();
1325
switch (task->target)
1328
sge_gdi_mod_job(ctx, ep, &(task->answer_list), packet->user, packet->host, sub_command);
1331
case SGE_SHARETREE_LIST:
1332
sge_mod_sharetree(ctx, ep, object_base[SGE_TYPE_SHARETREE].list,
1333
&(task->answer_list), packet->user, packet->host);
1337
SGE_ADD_MSG_ID( sprintf(SGE_EVENT, MSG_SGETEXT_OPNOIMPFORTARGET));
1338
answer_list_add(&(task->answer_list), SGE_EVENT, STATUS_ENOIMP, ANSWER_QUALITY_ERROR);
1341
sge_gdi_add_mod_generic(ctx, &(task->answer_list), ep, 0, ao, packet->user, packet->host, sub_command, &tmp_list, monitor);
1351
/* postprocessing for the list of requests */
1352
if (lGetNumberOfElem(tmp_list) != 0) {
1353
switch (task->target) {
1354
case SGE_CENTRY_LIST:
1355
DPRINTF(("rebuilding consumable debitation\n"));
1356
centry_redebit_consumables(ctx, tmp_list);
1361
lFreeList(&tmp_list);
1368
* MT-NOTE: sge_chck_mod_perm_user() is MT safe
1370
static int sge_chck_mod_perm_user(lList **alpp, u_long32 target, char *user, monitoring_t *monitor)
1373
DENTER(TOP_LAYER, "sge_chck_mod_perm_user");
1376
/* check permissions of user */
1379
case SGE_ORDER_LIST:
1380
case SGE_ADMINHOST_LIST:
1381
case SGE_SUBMITHOST_LIST:
1382
case SGE_EXECHOST_LIST:
1383
case SGE_CQUEUE_LIST:
1384
case SGE_CENTRY_LIST:
1385
case SGE_OPERATOR_LIST:
1386
case SGE_MANAGER_LIST:
1388
case SGE_CONFIG_LIST:
1391
case SGE_PROJECT_LIST:
1392
case SGE_SHARETREE_LIST:
1394
case SGE_CALENDAR_LIST:
1395
case SGE_USER_MAPPING_LIST:
1396
case SGE_HGROUP_LIST:
1398
/* user must be a manager */
1399
if (!manop_is_manager(user)) {
1400
ERROR((SGE_EVENT, MSG_SGETEXT_MUSTBEMANAGER_S, user));
1401
answer_list_add(alpp, SGE_EVENT, STATUS_ENOMGR, ANSWER_QUALITY_ERROR);
1402
SGE_UNLOCK(LOCK_GLOBAL, LOCK_READ);
1408
case SGE_USERSET_LIST:
1409
/* user must be a operator */
1410
if (!manop_is_operator(user)) {
1411
ERROR((SGE_EVENT, MSG_SGETEXT_MUSTBEOPERATOR_S, user));
1412
answer_list_add(alpp, SGE_EVENT, STATUS_ENOMGR, ANSWER_QUALITY_ERROR);
1421
what checking could we do here ?
1423
we had to check if there is a queue configured for scheduling
1424
of jobs of this group/user. If there is no such queue we
1425
had to deny submitting.
1427
Other checkings need to be done in stub functions.
1432
case SGE_EVENT_LIST:
1434
an event client can be started by any user - it can only
1435
read objects like SGE_GDI_GET
1436
delete requires more info - is done in sge_gdi_kill_eventclient
1441
Advance reservation can be submitted by a manager or any user in the aruser access list.
1443
if (!manop_is_manager(user) && !userset_is_ar_user(*userset_list_get_master_list(), user) ) {
1444
ERROR((SGE_EVENT, MSG_SGETEXT_MUSTBEMANAGERORUSER_SS, user, AR_USERS));
1445
answer_list_add(alpp, SGE_EVENT, STATUS_ENOMGR, ANSWER_QUALITY_ERROR);
1450
SGE_ADD_MSG_ID(sprintf(SGE_EVENT, MSG_SGETEXT_OPNOIMPFORTARGET));
1451
answer_list_add(alpp, SGE_EVENT, STATUS_ENOIMP, ANSWER_QUALITY_ERROR);
1460
* MT-NOTE: sge_chck_mod_perm_host() is MT safe
1462
static int sge_chck_mod_perm_host(lList **alpp, u_long32 target, char *host,
1463
char *commproc, int mod, lListElem *ep,
1464
monitoring_t *monitor, object_description *object_base)
1466
DENTER(TOP_LAYER, "sge_chck_mod_perm_host");
1468
/* check permissions of host */
1471
case SGE_ORDER_LIST:
1472
case SGE_ADMINHOST_LIST:
1473
case SGE_OPERATOR_LIST:
1474
case SGE_MANAGER_LIST:
1475
case SGE_SUBMITHOST_LIST:
1476
case SGE_CQUEUE_LIST:
1477
case SGE_CENTRY_LIST:
1479
case SGE_CONFIG_LIST:
1482
case SGE_USERSET_LIST:
1483
case SGE_PROJECT_LIST:
1484
case SGE_SHARETREE_LIST:
1486
case SGE_CALENDAR_LIST:
1487
case SGE_USER_MAPPING_LIST:
1488
case SGE_HGROUP_LIST:
1491
/* host must be SGE_ADMINHOST_LIST */
1492
if (!host_list_locate(*object_base[SGE_TYPE_ADMINHOST].list, host)) {
1493
ERROR((SGE_EVENT, MSG_SGETEXT_NOADMINHOST_S, host));
1494
answer_list_add(alpp, SGE_EVENT, STATUS_EDENIED2HOST, ANSWER_QUALITY_ERROR);
1499
case SGE_EXECHOST_LIST:
1501
/* host must be either admin host or exec host and execd */
1503
if (!(host_list_locate(*object_base[SGE_TYPE_ADMINHOST].list, host) ||
1504
(host_list_locate(*object_base[SGE_TYPE_EXECHOST].list, host) && !strcmp(commproc, prognames[EXECD])))) {
1505
ERROR((SGE_EVENT, MSG_SGETEXT_NOADMINHOST_S, host));
1506
answer_list_add(alpp, SGE_EVENT, STATUS_EDENIED2HOST, ANSWER_QUALITY_ERROR);
1513
** check if override ticket change request, if yes we need
1514
** to be on an admin host and must not be on a submit host
1516
if (mod && (lGetPosViaElem(ep, JB_override_tickets, SGE_NO_ABORT) >= 0)) {
1517
/* host must be SGE_ADMINHOST_LIST */
1518
if (!host_list_locate(*object_base[SGE_TYPE_ADMINHOST].list, host)) {
1519
ERROR((SGE_EVENT, MSG_SGETEXT_NOADMINHOST_S, host));
1520
answer_list_add(alpp, SGE_EVENT, STATUS_EDENIED2HOST, ANSWER_QUALITY_ERROR);
1525
/* host must be SGE_SUBMITHOST_LIST */
1526
if (!host_list_locate(*object_base[SGE_TYPE_SUBMITHOST].list, host)) {
1527
ERROR((SGE_EVENT, MSG_SGETEXT_NOSUBMITHOST_S, host));
1528
answer_list_add(alpp, SGE_EVENT, STATUS_EDENIED2HOST, ANSWER_QUALITY_ERROR);
1533
case SGE_EVENT_LIST:
1534
/* to start an event client or if an event client
1535
performs modify requests on itself
1536
it must be on a submit or an admin host
1538
if ( (!host_list_locate(*object_base[SGE_TYPE_SUBMITHOST].list, host))
1539
&& (!host_list_locate(*object_base[SGE_TYPE_ADMINHOST].list, host))) {
1540
ERROR((SGE_EVENT, MSG_SGETEXT_NOSUBMITORADMINHOST_S, host));
1541
answer_list_add(alpp, SGE_EVENT, STATUS_EDENIED2HOST, ANSWER_QUALITY_ERROR);
1546
/* host must be SGE_SUBMITHOST_LIST */
1547
if (!host_list_locate(*object_base[SGE_TYPE_SUBMITHOST].list, host)) {
1548
ERROR((SGE_EVENT, MSG_SGETEXT_NOSUBMITHOST_S, host));
1549
answer_list_add(alpp, SGE_EVENT, STATUS_EDENIED2HOST, ANSWER_QUALITY_ERROR);
1554
SGE_ADD_MSG_ID(sprintf(SGE_EVENT, MSG_SGETEXT_OPNOIMPFORTARGET));
1555
answer_list_add(alpp, SGE_EVENT, STATUS_ENOIMP, ANSWER_QUALITY_ERROR);
1563
/* EB: TODO: ST: skip execution of this function if it is internal GDI request */
1564
/* EB: TODO: ST: move usage of this code into listener in future */
1566
sge_task_check_get_perm_host(sge_gdi_packet_class_t *packet, sge_gdi_task_class_t *task,
1567
monitoring_t *monitor, object_description *object_base)
1573
DENTER(TOP_LAYER, "sge_task_check_get_perm_host");
1575
target = task->target;
1576
host = packet->host;
1578
/* check permissions of host */
1580
case SGE_ORDER_LIST:
1581
case SGE_EVENT_LIST:
1582
case SGE_ADMINHOST_LIST:
1583
case SGE_OPERATOR_LIST:
1584
case SGE_MANAGER_LIST:
1585
case SGE_SUBMITHOST_LIST:
1586
case SGE_CQUEUE_LIST:
1587
case SGE_CENTRY_LIST:
1591
case SGE_USERSET_LIST:
1592
case SGE_PROJECT_LIST:
1593
case SGE_SHARETREE_LIST:
1595
case SGE_CALENDAR_LIST:
1596
case SGE_USER_MAPPING_LIST:
1597
case SGE_HGROUP_LIST:
1598
case SGE_EXECHOST_LIST:
1600
case SGE_ZOMBIE_LIST:
1601
case SGE_JOB_SCHEDD_INFO_LIST:
1604
/* host must be admin or submit host */
1605
if (!host_list_locate(*object_base[SGE_TYPE_ADMINHOST].list, host) &&
1606
!host_list_locate(*object_base[SGE_TYPE_SUBMITHOST].list, host)) {
1607
SGE_ADD_MSG_ID(sprintf(SGE_EVENT, MSG_SGETEXT_NOSUBMITORADMINHOST_S, host));
1608
answer_list_add(&(task->answer_list), SGE_EVENT, STATUS_EDENIED2HOST, ANSWER_QUALITY_ERROR);
1612
case SGE_CONFIG_LIST:
1613
/* host must be admin or submit host or exec host */
1614
if (!host_list_locate(*object_base[SGE_TYPE_ADMINHOST].list, host) &&
1615
!host_list_locate(*object_base[SGE_TYPE_SUBMITHOST].list, host) &&
1616
!host_list_locate(*object_base[SGE_TYPE_EXECHOST].list, host)) {
1617
SGE_ADD_MSG_ID(sprintf(SGE_EVENT, MSG_SGETEXT_NOSUBMITORADMINHOST_S, host));
1618
answer_list_add(&(task->answer_list), SGE_EVENT, STATUS_EDENIED2HOST, ANSWER_QUALITY_ERROR);
1623
SGE_ADD_MSG_ID(sprintf(SGE_EVENT, MSG_SGETEXT_OPNOIMPFORTARGET));
1624
answer_list_add(&(task->answer_list), SGE_EVENT, STATUS_ENOIMP, ANSWER_QUALITY_ERROR);
1634
this is our strategy:
1636
do common checks and search old object
1637
make a copy of the old object (this will become the new object)
1638
modify new object using reduced object as instruction
1639
on error: dispose new object
1640
store new object to disc
1641
on error: dispose new object
1642
on success create events
1643
replace old object by new queue
1645
int sge_gdi_add_mod_generic(
1646
sge_gdi_ctx_class_t *ctx,
1648
lListElem *instructions, /* our instructions - a reduced object */
1649
int add, /* true in case of add */
1650
gdi_object_t *object,
1655
monitoring_t *monitor
1660
lList *tmp_alp = NULL;
1661
lListElem *new_obj = NULL,
1665
char ds_buffer[256];
1667
DENTER(TOP_LAYER, "sge_gdi_add_mod_generic");
1669
sge_dstring_init(&buffer, ds_buffer, sizeof(ds_buffer));
1671
/* DO COMMON CHECKS AND SEARCH OLD OBJECT */
1672
if (!instructions || !object) {
1673
CRITICAL((SGE_EVENT, MSG_SGETEXT_NULLPTRPASSED_S, SGE_FUNC));
1674
answer_list_add(alpp, SGE_EVENT, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR);
1675
DRETURN(STATUS_EUNKNOWN);
1678
/* ep is no element of this type, if ep doesn't contain the the primary key attribute */
1679
if (lGetPosViaElem(instructions, object->key_nm, SGE_NO_ABORT) < 0)
1681
CRITICAL((SGE_EVENT, MSG_SGETEXT_MISSINGCULLFIELD_SS, lNm2Str(object->key_nm), SGE_FUNC));
1682
answer_list_add(alpp, SGE_EVENT, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR);
1683
DRETURN(STATUS_EUNKNOWN);
1687
* resolve host name in case of objects with hostnames as key
1688
* before searching for the objects
1690
if ( object->key_nm == EH_name ||
1691
object->key_nm == AH_name ||
1692
object->key_nm == SH_name ) {
1693
if (sge_resolve_host(instructions, object->key_nm) != CL_RETVAL_OK) {
1694
const char *host = lGetHost(instructions, object->key_nm);
1695
ERROR((SGE_EVENT, MSG_SGETEXT_CANTRESOLVEHOST_S, host ? host : "NULL"));
1696
answer_list_add(alpp, SGE_EVENT, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR);
1697
DRETURN(STATUS_EUNKNOWN);
1701
/* get and verify the primary key */
1702
pos = lGetPosViaElem(instructions, object->key_nm, SGE_NO_ABORT);
1703
dataType = lGetPosType(lGetElemDescr(instructions),pos);
1704
if (dataType == lUlongT) {
1705
u_long32 id = lGetUlong(instructions, object->key_nm);
1706
sge_dstring_sprintf(&buffer, sge_u32, id);
1707
name = sge_dstring_get_string(&buffer);
1709
old_obj = lGetElemUlong(*object_type_get_master_list(object->list_type), object->key_nm, id);
1710
} else if (dataType == lHostT) {
1711
name = lGetHost(instructions, object->key_nm);
1712
old_obj = lGetElemHost(*object_type_get_master_list(object->list_type), object->key_nm, name);
1715
name = lGetString(instructions, object->key_nm);
1716
old_obj = lGetElemStr(*object_type_get_master_list(object->list_type), object->key_nm, name);
1720
answer_list_add(alpp, MSG_OBJ_NAME_MISSING,
1721
STATUS_EEXIST, ANSWER_QUALITY_ERROR);
1722
DRETURN(STATUS_EEXIST);
1725
/* prevent duplicates / modifying non existing objects */
1726
if ((old_obj && add) ||
1727
(!old_obj && !add)) {
1728
ERROR((SGE_EVENT, add?
1729
MSG_SGETEXT_ALREADYEXISTS_SS:MSG_SGETEXT_DOESNOTEXIST_SS,
1730
object->object_name, name));
1731
answer_list_add(alpp, SGE_EVENT, STATUS_EEXIST, ANSWER_QUALITY_ERROR);
1732
DRETURN(STATUS_EEXIST);
1735
/* create a new object (add case), or make a copy of the old object (mod case) */
1736
if (!(new_obj = (add
1737
? lCreateElem(object->type)
1738
: lCopyElem(old_obj)))) {
1739
ERROR((SGE_EVENT, MSG_MEM_MALLOC));
1740
answer_list_add(alpp, SGE_EVENT, STATUS_EEXIST, ANSWER_QUALITY_ERROR);
1741
DRETURN(STATUS_EEXIST);
1744
/* modify the new object base on information in the request */
1745
if (object->modifier(ctx, &tmp_alp, new_obj, instructions, add, ruser, rhost,
1746
object, sub_command, monitor) != 0) {
1749
/* ON ERROR: DISPOSE NEW OBJECT */
1750
/* failure: just append last elem in tmp_alp
1751
elements before may contain invalid success messages */
1754
*alpp = lCreateList("answer", AN_Type);
1757
if (object->type == AR_Type) {
1758
lAppendList(*alpp, tmp_alp);
1759
lFreeList(&tmp_alp);
1761
lListElem *failure = lLast(tmp_alp);
1763
lDechainElem(tmp_alp, failure);
1764
lAppendElem(*alpp, failure);
1765
lFreeList(&tmp_alp);
1769
lFreeElem(&new_obj);
1770
DRETURN(STATUS_EUNKNOWN);
1775
if (object->writer(ctx, alpp, new_obj, object)) {
1776
lFreeElem(&new_obj);
1777
lFreeList(&tmp_alp);
1778
DRETURN(STATUS_EUNKNOWN);
1782
if (*alpp == NULL) {
1783
*alpp = lCreateList("answer", AN_Type);
1786
/* copy tmp_alp to alpp */
1787
lAppendList(*alpp, tmp_alp);
1789
lFreeList(&tmp_alp);
1792
lList **master_list = NULL;
1794
master_list = object_type_get_master_list(object->list_type);
1796
/* chain out the old object */
1798
lDechainElem(*master_list, old_obj);
1801
/* ensure our global list exists */
1802
if (*master_list == NULL ) {
1803
*master_list = lCreateList(object->object_name, object->type);
1806
/* chain in new object */
1807
lAppendElem(*master_list, new_obj);
1810
/* once we successfully added/modified the object, do final steps (on_success callback) */
1811
if (object->on_success) {
1812
object->on_success(ctx, new_obj, old_obj, object, tmp_list, monitor);
1815
lFreeElem(&old_obj);
1817
if (!SGE_GDI_IS_SUBCOMMAND_SET(sub_command, SGE_GDI_RETURN_NEW_VERSION)) {
1819
add?MSG_SGETEXT_ADDEDTOLIST_SSSS:
1820
MSG_SGETEXT_MODIFIEDINLIST_SSSS, ruser, rhost, name, object->object_name));
1822
answer_list_add(alpp, SGE_EVENT, STATUS_OK, ANSWER_QUALITY_INFO);
1829
* MT-NOTE: get_gdi_object() is MT safe
1831
gdi_object_t *get_gdi_object(u_long32 target)
1835
DENTER(TOP_LAYER, "get_gdi_object");
1837
for (i=0; gdi_object[i].target; i++) {
1838
if (target == gdi_object[i].target) {
1839
DRETURN(&gdi_object[i]);
1846
static int schedd_mod(sge_gdi_ctx_class_t *ctx, lList **alpp, lListElem *modp,
1847
lListElem *ep, int add, const char *ruser,
1848
const char *rhost, gdi_object_t *object, int sub_command,
1849
monitoring_t *monitor) {
1851
DENTER(TOP_LAYER, "schedd_mod");
1853
ret = sconf_validate_config_(alpp) ? 0 : 1;