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__*/
41
#include <sys/types.h>
42
#include <sys/socket.h>
44
#include "lck/sge_lock.h"
46
#include "comm/commlib.h"
47
#include "comm/lists/cl_util.h"
49
#include "rmon/sgermon.h"
51
#include "uti/sge_hostname.h"
52
#include "uti/sge_log.h"
53
#include "uti/sge_stdlib.h"
54
#include "uti/sge_string.h"
55
#include "uti/sge_unistd.h"
56
#include "uti/sge_env.h"
57
#include "uti/sge_prog.h"
58
#include "uti/setup_path.h"
59
#include "uti/sge_bootstrap.h"
60
#include "uti/sge_uidgid.h"
61
#include "uti/sge_profiling.h"
62
#include "uti/msg_utilib.h"
63
#include "uti/sge_language.h"
64
#include "uti/sge_spool.h"
66
#include "sgeobj/sge_answer.h"
68
#include "gdi/qm_name.h"
70
#include "sgeobj/sge_feature.h"
71
#include "sgeobj/sge_conf.h"
72
#include "sgeobj/sge_object.h"
75
#include "sge_csp_path.h"
76
#include "msg_gdilib.h"
79
** need this for lInit(nmv)
81
extern lNameSpace nmv[];
84
/* TODO: throw this out asap */
85
#include "gdi/sge_gdi.h"
87
void gdi_once_init(void);
88
void feature_mt_init(void);
89
void sc_mt_init(void);
92
#include "gdi/sge_gdi_ctx.h"
93
#include "gdi/sge_gdi2.h"
94
#include "gdi/sge_gdi_packet_internal.h"
97
sge_env_state_class_t* sge_env_state_obj;
98
sge_prog_state_class_t* sge_prog_state_obj;
99
sge_path_state_class_t* sge_path_state_obj;
100
sge_bootstrap_state_class_t* sge_bootstrap_state_obj;
101
sge_csp_path_class_t* sge_csp_path_obj;
103
char* component_name;
106
char* component_username;
112
char *ssl_private_key;
113
char *ssl_certificate;
116
int last_commlib_error;
117
sge_error_class_t *eh;
119
bool is_qmaster_internal_client;
123
static pthread_key_t gdi_state_key;
124
static pthread_once_t gdi_once_control = PTHREAD_ONCE_INIT;
127
/* gdi request base */
128
u_long32 request_id; /* incremented with each GDI request to have a unique request ID
129
it is ensured that the request ID is also contained in answer */
132
static void gdi_state_destroy(void* state) {
136
void gdi_once_init(void) {
137
pthread_key_create(&gdi_state_key, &gdi_state_destroy);
140
static void gdi_state_init(gdi_state_t* state) {
141
state->request_id = 0;
144
/****** gid/gdi_setup/gdi_mt_init() ************************************************
146
* gdi_mt_init() -- Initialize GDI state for multi threading use.
149
* void gdi_mt_init(void)
152
* Set up GDI. This function must be called at least once before any of the
153
* GDI functions is used. This function is idempotent, i.e. it is safe to
154
* call it multiple times.
156
* Thread local storage for the GDI state information is reserved.
165
* MT-NOTE: gdi_mt_init() is MT safe
167
*******************************************************************************/
168
void gdi_mt_init(void)
170
pthread_once(&gdi_once_control, gdi_once_init);
173
/****** libs/gdi/gdi_state_get_????() ************************************
175
* gdi_state_get_????() - read access to gdilib global variables
178
* Provides access to either global variable or per thread global
181
******************************************************************************/
182
u_long32 gdi_state_get_next_request_id(void)
184
GET_SPECIFIC(gdi_state_t, gdi_state,
185
gdi_state_init, gdi_state_key, "gdi_state_get_next_request_id");
186
gdi_state->request_id++;
187
return gdi_state->request_id;
191
sge_gdi_ctx_class_t* ctx;
192
} sge_gdi_ctx_thread_local_t;
194
static pthread_once_t sge_gdi_ctx_once = PTHREAD_ONCE_INIT;
195
static pthread_key_t sge_gdi_ctx_key;
196
static void sge_gdi_thread_local_ctx_once_init(void);
197
static void sge_gdi_thread_local_ctx_destroy(void* theState);
198
static void sge_gdi_thread_local_ctx_init(sge_gdi_ctx_thread_local_t* theState);
200
static void sge_gdi_thread_local_ctx_once_init(void)
202
pthread_key_create(&sge_gdi_ctx_key, sge_gdi_thread_local_ctx_destroy);
205
static void sge_gdi_thread_local_ctx_destroy(void* theState) {
206
sge_gdi_ctx_thread_local_t *tl = (sge_gdi_ctx_thread_local_t*)theState;
211
static void sge_gdi_thread_local_ctx_init(sge_gdi_ctx_thread_local_t* theState)
213
memset(theState, 0, sizeof(sge_gdi_ctx_thread_local_t));
217
sge_gdi_ctx_class_t* sge_gdi_get_thread_local_ctx() {
219
pthread_once(&sge_gdi_ctx_once, sge_gdi_thread_local_ctx_once_init);
221
GET_SPECIFIC(sge_gdi_ctx_thread_local_t, tl, sge_gdi_thread_local_ctx_init, sge_gdi_ctx_key,
222
"sge_gdi_get_thread_local_ctx");
227
void sge_gdi_set_thread_local_ctx(sge_gdi_ctx_class_t* ctx) {
229
DENTER(TOP_LAYER, "sge_gdi_set_thread_local_ctx");
231
pthread_once(&sge_gdi_ctx_once, sge_gdi_thread_local_ctx_once_init);
233
GET_SPECIFIC(sge_gdi_ctx_thread_local_t, tl, sge_gdi_thread_local_ctx_init, sge_gdi_ctx_key,
234
"set_thread_local_ctx");
238
sge_bootstrap_state_set_thread_local(ctx->get_sge_bootstrap_state(ctx));
239
log_state_set_log_context(ctx);
241
sge_bootstrap_state_set_thread_local(NULL);
242
log_state_set_log_context(NULL);
249
sge_gdi_ctx_setup(sge_gdi_ctx_class_t *thiz, int prog_number, const char* component_name,
250
int thread_number, const char *thread_name, const char* username,
251
const char *groupname, const char *sge_root, const char *sge_cell,
252
int sge_qmaster_port, int sge_execd_port, bool from_services,
253
bool is_qmaster_internal_client);
255
static void sge_gdi_ctx_destroy(void *theState);
257
static void sge_gdi_ctx_set_is_setup(sge_gdi_ctx_class_t *thiz, bool is_setup);
258
static bool sge_gdi_ctx_is_setup(sge_gdi_ctx_class_t *thiz);
259
static void sge_gdi_ctx_class_get_errors(sge_gdi_ctx_class_t *thiz, lList **alpp, bool clear_errors);
260
static void sge_gdi_ctx_class_error(sge_gdi_ctx_class_t *thiz, int error_type, int error_quality, const char* fmt, ...);
261
static sge_env_state_class_t* get_sge_env_state(sge_gdi_ctx_class_t *thiz);
262
static sge_prog_state_class_t* get_sge_prog_state(sge_gdi_ctx_class_t *thiz);
263
static sge_path_state_class_t* get_sge_path_state(sge_gdi_ctx_class_t *thiz);
264
static sge_csp_path_class_t* get_sge_csp_path(sge_gdi_ctx_class_t *thiz);
265
static sge_bootstrap_state_class_t* get_sge_bootstrap_state(sge_gdi_ctx_class_t *thiz);
266
static int reresolve_qualified_hostname(sge_gdi_ctx_class_t *thiz);
267
static cl_com_handle_t* get_com_handle(sge_gdi_ctx_class_t *thiz);
268
static const char* get_component_name(sge_gdi_ctx_class_t *thiz);
269
static const char* get_thread_name(sge_gdi_ctx_class_t *thiz);
270
static const char* get_progname(sge_gdi_ctx_class_t *thiz);
271
static const char* get_ca_local_root(sge_gdi_ctx_class_t *thiz);
272
static const char* get_ca_root(sge_gdi_ctx_class_t *thiz);
273
static u_long32 get_who(sge_gdi_ctx_class_t *thiz);
274
static bool is_daemonized(sge_gdi_ctx_class_t *thiz);
275
static void set_daemonized(sge_gdi_ctx_class_t *thiz, bool daemonized);
276
static bool get_job_spooling(sge_gdi_ctx_class_t *thiz);
277
static void set_job_spooling(sge_gdi_ctx_class_t *thiz, bool job_spooling);
278
static u_long32 get_listener_thread_count(sge_gdi_ctx_class_t *thiz);
279
static u_long32 get_worker_thread_count(sge_gdi_ctx_class_t *thiz);
280
static u_long32 get_scheduler_thread_count(sge_gdi_ctx_class_t *thiz);
281
static u_long32 get_jvm_thread_count(sge_gdi_ctx_class_t *thiz);
282
static const char* get_master(sge_gdi_ctx_class_t *thiz, bool reread);
283
static u_long32 get_sge_qmaster_port(sge_gdi_ctx_class_t *thiz);
284
static u_long32 get_sge_execd_port(sge_gdi_ctx_class_t *thiz);
285
static const char* get_spooling_method(sge_gdi_ctx_class_t *thiz);
286
static const char* get_spooling_lib(sge_gdi_ctx_class_t *thiz);
287
static const char* get_spooling_params(sge_gdi_ctx_class_t *thiz);
288
static const char* get_username(sge_gdi_ctx_class_t *thiz);
289
static const char* get_cell_root(sge_gdi_ctx_class_t *thiz);
290
static const char* get_sge_root(sge_gdi_ctx_class_t *thiz);
291
static const char* get_groupname(sge_gdi_ctx_class_t *thiz);
292
static uid_t ctx_get_uid(sge_gdi_ctx_class_t *thiz);
293
static gid_t ctx_get_gid(sge_gdi_ctx_class_t *thiz);
294
static const char* get_qualified_hostname(sge_gdi_ctx_class_t *thiz);
295
static const char* get_unqualified_hostname(sge_gdi_ctx_class_t *thiz);
296
static const char* get_default_cell(sge_gdi_ctx_class_t *thiz);
297
static const char* get_admin_user(sge_gdi_ctx_class_t *thiz);
298
static const char* get_binary_path(sge_gdi_ctx_class_t *thiz);
299
static const char* get_qmaster_spool_dir(sge_gdi_ctx_class_t *thiz);
300
static const char* get_bootstrap_file(sge_gdi_ctx_class_t *thiz);
301
static const char* get_act_qmaster_file(sge_gdi_ctx_class_t *thiz);
302
static const char* get_acct_file(sge_gdi_ctx_class_t *thiz);
303
static const char* get_reporting_file(sge_gdi_ctx_class_t *thiz);
304
static const char* get_shadow_master_file(sge_gdi_ctx_class_t *thiz);
305
static sge_exit_func_t get_exit_func(sge_gdi_ctx_class_t *thiz);
306
static void set_exit_func(sge_gdi_ctx_class_t *thiz, sge_exit_func_t exfunc);
307
static void set_private_key(sge_gdi_ctx_class_t *thiz, const char *pkey);
308
static void set_certificate(sge_gdi_ctx_class_t *thiz, const char *cert);
309
static const char* get_private_key(sge_gdi_ctx_class_t *thiz);
310
static const char* get_certificate(sge_gdi_ctx_class_t *thiz);
311
static int ctx_get_last_commlib_error(sge_gdi_ctx_class_t *thiz);
312
static void ctx_set_last_commlib_error(sge_gdi_ctx_class_t *thiz, int cl_error);
313
static bool ctx_is_qmaster_internal_client(sge_gdi_ctx_class_t *thiz);
315
static int sge_gdi_ctx_class_prepare_enroll(sge_gdi_ctx_class_t *thiz);
316
static int sge_gdi_ctx_class_connect(sge_gdi_ctx_class_t *thiz);
317
static int sge_gdi_ctx_class_is_alive(sge_gdi_ctx_class_t *thiz);
319
static lList* sge_gdi_ctx_class_gdi_tsm(sge_gdi_ctx_class_t *thiz, const char *schedd_name, const char *cell);
320
static lList* sge_gdi_ctx_class_gdi_kill(sge_gdi_ctx_class_t *thiz, lList *id_list, const char *cell,
321
u_long32 option_flags, u_long32 action_flag);
322
static bool sge_gdi_ctx_class_gdi_get_mapping_name(sge_gdi_ctx_class_t *thiz, const char *requestedHost, char *buf, int buflen);
323
static bool sge_gdi_ctx_class_gdi_check_permission(sge_gdi_ctx_class_t *thiz, lList **alpp, int option);
325
static int sge_gdi_ctx_log_flush_func(cl_raw_list_t* list_p);
327
static void sge_gdi_ctx_class_dprintf(sge_gdi_ctx_class_t *ctx);
329
sge_gdi_ctx_class_t *
330
sge_gdi_ctx_class_create(int prog_number, const char *component_name,
331
int thread_number, const char *thread_name,
332
const char *username, const char *groupname,
333
const char *sge_root, const char *sge_cell,
334
int sge_qmaster_port, int sge_execd_port,
335
bool from_services, bool is_qmaster_internal_client,
338
sge_gdi_ctx_class_t *ret = (sge_gdi_ctx_class_t *)sge_malloc(sizeof(sge_gdi_ctx_class_t));
339
sge_gdi_ctx_t *gdi_ctx = NULL;
341
DENTER(TOP_LAYER, "sge_gdi_ctx_class_create");
344
answer_list_add_sprintf(alpp, STATUS_EMALLOC,
345
ANSWER_QUALITY_ERROR, MSG_MEMORY_MALLOCFAILED);
349
if (is_qmaster_internal_client) {
350
ret->sge_gdi_packet_execute = sge_gdi_packet_execute_internal;
351
ret->sge_gdi_packet_wait_for_result = sge_gdi_packet_wait_for_result_internal;
353
ret->sge_gdi_packet_execute = sge_gdi_packet_execute_external;
354
ret->sge_gdi_packet_wait_for_result = sge_gdi_packet_wait_for_result_external;
357
ret->gdi_multi = sge_gdi2_multi;
358
ret->gdi_wait = sge_gdi2_wait;
360
ret->get_errors = sge_gdi_ctx_class_get_errors;
361
ret->prepare_enroll = sge_gdi_ctx_class_prepare_enroll;
362
ret->connect = sge_gdi_ctx_class_connect;
363
ret->is_alive = sge_gdi_ctx_class_is_alive;
364
ret->tsm = sge_gdi_ctx_class_gdi_tsm;
365
ret->kill = sge_gdi_ctx_class_gdi_kill;
366
ret->gdi_check_permission = sge_gdi_ctx_class_gdi_check_permission;
367
ret->gdi_get_mapping_name = sge_gdi_ctx_class_gdi_get_mapping_name;
369
ret->get_sge_env_state = get_sge_env_state;
370
ret->get_sge_prog_state = get_sge_prog_state;
371
ret->get_sge_path_state = get_sge_path_state;
372
ret->get_sge_bootstrap_state = get_sge_bootstrap_state;
373
ret->reresolve_qualified_hostname = reresolve_qualified_hostname;
374
ret->get_component_name = get_component_name;
375
ret->get_thread_name = get_thread_name;
376
ret->get_progname = get_progname;
377
ret->get_who = get_who;
378
ret->is_daemonized = is_daemonized;
379
ret->set_daemonized = set_daemonized;
380
ret->get_job_spooling = get_job_spooling;
381
ret->set_job_spooling = set_job_spooling;
382
ret->get_listener_thread_count = get_listener_thread_count;
383
ret->get_worker_thread_count = get_worker_thread_count;
384
ret->get_scheduler_thread_count = get_scheduler_thread_count;
385
ret->get_jvm_thread_count = get_jvm_thread_count;
386
ret->get_qualified_hostname = get_qualified_hostname;
387
ret->get_unqualified_hostname = get_unqualified_hostname;
388
ret->get_master = get_master;
389
ret->get_sge_qmaster_port = get_sge_qmaster_port;
390
ret->get_sge_execd_port = get_sge_execd_port;
391
ret->get_username = get_username;
392
ret->get_spooling_method = get_spooling_method;
393
ret->get_spooling_lib = get_spooling_lib;
394
ret->get_spooling_params = get_spooling_params;
395
ret->get_admin_user = get_admin_user;
396
ret->get_binary_path = get_binary_path;
397
ret->get_qmaster_spool_dir = get_qmaster_spool_dir;
398
ret->get_bootstrap_file = get_bootstrap_file;
399
ret->get_act_qmaster_file = get_act_qmaster_file;
400
ret->get_acct_file = get_acct_file;
401
ret->get_reporting_file = get_reporting_file;
402
ret->get_shadow_master_file = get_shadow_master_file;
403
ret->get_default_cell = get_default_cell;
404
ret->get_cell_root = get_cell_root;
405
ret->get_sge_root = get_sge_root;
406
ret->get_groupname = get_groupname;
407
ret->get_uid = ctx_get_uid;
408
ret->get_gid = ctx_get_gid;
409
ret->get_com_handle = get_com_handle;
411
ret->set_exit_func = set_exit_func;
412
ret->get_exit_func = get_exit_func;
414
ret->set_private_key = set_private_key;
415
ret->set_certificate = set_certificate;
416
ret->get_private_key = get_private_key;
417
ret->get_certificate = get_certificate;
418
ret->get_ca_root = get_ca_root;
419
ret->get_ca_local_root = get_ca_local_root;
420
ret->is_qmaster_internal_client = ctx_is_qmaster_internal_client;
422
ret->dprintf = sge_gdi_ctx_class_dprintf;
424
ret->sge_gdi_ctx_handle = (sge_gdi_ctx_t*)sge_malloc(sizeof(sge_gdi_ctx_t));
425
memset(ret->sge_gdi_ctx_handle, 0, sizeof(sge_gdi_ctx_t));
427
if (!ret->sge_gdi_ctx_handle) {
428
answer_list_add_sprintf(alpp, STATUS_EMALLOC,
429
ANSWER_QUALITY_ERROR, MSG_MEMORY_MALLOCFAILED);
430
sge_gdi_ctx_class_destroy(&ret);
435
** create error handler of context
437
gdi_ctx = (sge_gdi_ctx_t*)ret->sge_gdi_ctx_handle;
438
gdi_ctx->eh = sge_error_class_create();
440
answer_list_add_sprintf(alpp, STATUS_EMALLOC,
441
ANSWER_QUALITY_ERROR, MSG_MEMORY_MALLOCFAILED);
446
if (!sge_gdi_ctx_setup(ret, prog_number, component_name, thread_number, thread_name,
447
username, groupname, sge_root, sge_cell, sge_qmaster_port,
448
sge_execd_port, from_services, is_qmaster_internal_client)) {
449
sge_gdi_ctx_class_get_errors(ret, alpp, true);
450
sge_gdi_ctx_class_destroy(&ret);
455
** set default exit func, maybe overwritten
457
ret->set_exit_func(ret, gdi2_default_exit_func);
462
void sge_gdi_ctx_class_destroy(sge_gdi_ctx_class_t **pst)
464
DENTER(TOP_LAYER, "sge_gdi_ctx_class_destroy");
470
/* free internal context structure */
471
sge_gdi_ctx_destroy((*pst)->sge_gdi_ctx_handle);
478
static void sge_gdi_ctx_class_get_errors(sge_gdi_ctx_class_t *thiz, lList **alpp, bool clear_errors)
480
sge_gdi_ctx_t *gdi_ctx = NULL;
482
DENTER(TOP_LAYER, "sge_gdi_ctx_class_get_errors");
484
if (!thiz || !thiz->sge_gdi_ctx_handle) {
488
gdi_ctx = (sge_gdi_ctx_t*)thiz->sge_gdi_ctx_handle;
490
sge_error_to_answer_list(gdi_ctx->eh, alpp, clear_errors);
495
static void sge_gdi_ctx_class_error(sge_gdi_ctx_class_t *thiz, int error_type, int error_quality, const char* fmt, ...)
497
sge_gdi_ctx_t *gdi_ctx = NULL;
499
DENTER(TOP_LAYER, "sge_gdi_ctx_class_error");
501
if (!thiz || !thiz->sge_gdi_ctx_handle) {
505
gdi_ctx = (sge_gdi_ctx_t*)thiz->sge_gdi_ctx_handle;
510
va_start(arg_list, fmt);
511
gdi_ctx->eh->verror(gdi_ctx->eh, error_type, error_quality, fmt, arg_list);
518
static void sge_gdi_ctx_set_is_setup(sge_gdi_ctx_class_t *thiz, bool is_setup)
520
sge_gdi_ctx_t *gdi_ctx = NULL;
522
DENTER(TOP_LAYER, "sge_gdi_ctx_set_is_setup");
524
if (!thiz || !thiz->sge_gdi_ctx_handle) {
528
gdi_ctx = (sge_gdi_ctx_t*)thiz->sge_gdi_ctx_handle;
530
gdi_ctx->is_setup = is_setup;
536
static bool sge_gdi_ctx_is_setup(sge_gdi_ctx_class_t *thiz)
538
sge_gdi_ctx_t *gdi_ctx = NULL;
540
DENTER(TOP_LAYER, "sge_gdi_ctx_is_setup");
542
if (!thiz || !thiz->sge_gdi_ctx_handle) {
546
gdi_ctx = (sge_gdi_ctx_t*)thiz->sge_gdi_ctx_handle;
548
DRETURN(gdi_ctx->is_setup);
553
sge_gdi_ctx_setup(sge_gdi_ctx_class_t *thiz, int prog_number, const char* component_name,
554
int thread_number, const char *thread_name, const char* username,
555
const char *groupname, const char *sge_root, const char *sge_cell,
556
int sge_qmaster_port, int sge_execd_port, bool from_services,
557
bool qmaster_internal_client)
559
sge_gdi_ctx_t *es = (sge_gdi_ctx_t *)thiz->sge_gdi_ctx_handle;
560
sge_error_class_t *eh = es->eh;
562
DENTER(TOP_LAYER, "sge_gdi_ctx_setup");
565
* Call all functions which have to be called once for each process.
566
* Those functions will then be called when the first thread of a process
567
* creates its context.
580
/* TODO: shall we do that here ? */
583
es->is_qmaster_internal_client = qmaster_internal_client;
585
es->sge_env_state_obj = sge_env_state_class_create(sge_root, sge_cell, sge_qmaster_port, sge_execd_port, from_services, qmaster_internal_client, eh);
586
if (!es->sge_env_state_obj) {
590
es->sge_prog_state_obj = sge_prog_state_class_create(es->sge_env_state_obj, prog_number, eh);
591
if (!es->sge_prog_state_obj) {
595
es->sge_path_state_obj = sge_path_state_class_create(es->sge_env_state_obj, eh);
596
if (!es->sge_path_state_obj) {
600
es->sge_bootstrap_state_obj = sge_bootstrap_state_class_create(es->sge_path_state_obj, eh);
601
if (!es->sge_bootstrap_state_obj) {
605
if (feature_initialize_from_string(es->sge_bootstrap_state_obj->get_security_mode(es->sge_bootstrap_state_obj))) {
609
es->sge_csp_path_obj = sge_csp_path_class_create(es->sge_env_state_obj, es->sge_prog_state_obj, eh);
610
if (!es->sge_csp_path_obj) {
614
if (component_name == NULL) {
615
es->component_name = strdup(prognames[prog_number]);
617
es->component_name = strdup(component_name);
620
if (thread_name == NULL) {
621
es->thread_name = strdup(prognames[prog_number]);
623
es->thread_name = strdup(thread_name);
626
/* set uid and gid */
629
struct passwd pw_struct;
633
size = get_pw_buffer_size();
634
buffer = sge_malloc(size);
635
pwd = sge_getpwnam_r(username, &pw_struct, buffer, size);
638
eh->error(eh, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR, "sge_getpwnam_r failed for username %s", username);
642
es->uid = pwd->pw_uid;
643
if (groupname != NULL) {
645
if (sge_group2gid(groupname, &gid, MAX_NIS_RETRIES) == 1) {
646
eh->error(eh, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR, "sge_group2gid failed for groupname %s", groupname);
652
es->gid = pwd->pw_gid;
658
es->username = strdup(username);
660
#if defined( INTERIX )
661
/* Strip Windows domain name from user name */
665
plus_sign = strstr(es->username, "+");
666
if (plus_sign!=NULL) {
668
strcpy(es->username, plus_sign);
676
if (groupname != NULL) {
677
es->groupname = strdup(groupname);
679
if (_sge_gid2group(es->gid, &(es->gid), &(es->groupname), MAX_NIS_RETRIES)) {
680
eh->error(eh, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR, MSG_GDI_GETGRGIDXFAILEDERRORX_U, sge_u32c(es->gid));
686
** set the component_username and check if login is needed
689
struct passwd *pwd = NULL;
692
struct passwd pwentry;
694
size = get_pw_buffer_size();
695
buffer = sge_malloc(size);
696
if (getpwuid_r((uid_t)getuid(), &pwentry, buffer, size, &pwd) == 0) {
697
es->component_username = sge_strdup(es->component_username, pwd->pw_name);
700
eh->error(eh, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR, "getpwuid_r failed");
706
** TODO: Login to system somehow and send something like a token with request
707
** similar like the secret key in CSP mode
709
DPRINTF(("es->username: '%s', es->component_username: '%s'\n", es->username, es->component_username));
710
if (strcmp(es->username, es->component_username) != 0) {
712
eh->error(eh, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR, "!!!! Alert login needed !!!!!");
715
eh->error(eh, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR, "!!!! First time login !!!!!");
716
/* sge_authenticate(es->username, callback_handler); */
726
sge_gdi_ctx_class_t *
727
sge_gdi_ctx_class_create_from_bootstrap(int prog_number, const char* component_name,
728
int thread_number, const char *thread_name,
729
const char* url, const char* username, lList **alpp)
731
char sge_root[BUFSIZ];
732
char sge_cell[BUFSIZ];
733
char sge_qmaster_port[BUFSIZ];
735
char sge_url[BUFSIZ];
737
struct saved_vars_s *url_ctx = NULL;
738
int sge_qmaster_p = 0;
740
bool is_qmaster_internal_client = false;
742
sge_gdi_ctx_class_t * ret = NULL;
744
DENTER(TOP_LAYER, "sge_gdi_ctx_class_create_from_bootstrap");
746
/* determine the connection type: local/remote */
747
if (!strncmp(url, "internal://", (sizeof("internal://")-1))) {
748
DPRINTF(("**** Using internal context for %s ****\n", component_name));
749
is_qmaster_internal_client = true;
753
DPRINTF(("url = %s\n", url));
754
if (is_qmaster_internal_client) {
755
sscanf(url, "internal://%s", sge_url);
757
sscanf(url, "bootstrap://%s", sge_url);
759
DPRINTF(("sge_url = %s\n", sge_url));
761
/* search for sge_root */
762
token = sge_strtok_r(sge_url, "@", &url_ctx);
763
if (token == NULL ) {
764
answer_list_add_sprintf(alpp, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR, "invalid url, sge_root not found");
765
sge_free_saved_vars(url_ctx);
768
strcpy(sge_root, token);
770
/* search for sge_cell */
771
token = sge_strtok_r(NULL, ":", &url_ctx);
773
if (token == NULL ) {
774
answer_list_add_sprintf(alpp, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR, "invalid url, sge_cell not found");
775
sge_free_saved_vars(url_ctx);
778
strcpy(sge_cell, token);
780
/* get the qmaster port */
781
token = sge_strtok_r(NULL, NULL, &url_ctx);
783
if (token == NULL ) {
784
answer_list_add_sprintf(alpp, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR, "invalid url, qmaster_port not found");
785
sge_free_saved_vars(url_ctx);
788
strcpy(sge_qmaster_port, token);
790
sge_qmaster_p = atoi(sge_qmaster_port);
792
if (sge_qmaster_p <= 0 ) {
793
answer_list_add_sprintf(alpp, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR, "invalid url, invalid sge_qmaster_port port %s", sge_qmaster_port);
794
sge_free_saved_vars(url_ctx);
798
sge_free_saved_vars(url_ctx);
800
/* TODO we need a way to define the execd port, from_services is always false (certs from keystore) */
802
ret = sge_gdi_ctx_class_create(prog_number, component_name, thread_number, thread_name,
803
username, NULL, sge_root, sge_cell, sge_qmaster_p, sge_execd_p,
804
false, is_qmaster_internal_client, alpp);
810
static void sge_gdi_ctx_destroy(void *theState)
812
sge_gdi_ctx_t *s = (sge_gdi_ctx_t *)theState;
814
DENTER(TOP_LAYER, "sge_gdi_ctx_destroy");
816
sge_env_state_class_destroy(&(s->sge_env_state_obj));
817
sge_prog_state_class_destroy(&(s->sge_prog_state_obj));
818
sge_path_state_class_destroy(&(s->sge_path_state_obj));
819
sge_bootstrap_state_class_destroy(&(s->sge_bootstrap_state_obj));
820
sge_csp_path_class_destroy(&(s->sge_csp_path_obj));
822
sge_free(s->username);
823
sge_free(s->groupname);
824
sge_free(s->component_name);
825
sge_free(s->thread_name);
826
sge_free(s->component_username);
827
sge_free(s->ssl_certificate);
828
sge_free(s->ssl_private_key);
829
sge_error_class_destroy(&(s->eh));
835
static int sge_gdi_ctx_class_connect(sge_gdi_ctx_class_t *thiz)
839
bool is_alive_check = true;
841
DENTER(TOP_LAYER, "sge_gdi_ctx_class_connect");
844
** TODO: must contain similar functionality as sge_gdi_setup
847
ret = sge_gdi_ctx_class_prepare_enroll(thiz);
849
/* check if master is alive */
850
if (ret == CL_RETVAL_OK && is_alive_check) {
851
const char *master = thiz->get_master(thiz, true);
852
DPRINTF(("thiz->get_master(thiz) = %s\n", master));
853
ret = thiz->is_alive(thiz);
859
static int sge_gdi_ctx_class_prepare_enroll(sge_gdi_ctx_class_t *thiz) {
861
sge_path_state_class_t* path_state = thiz->get_sge_path_state(thiz);
862
sge_bootstrap_state_class_t * bootstrap_state = thiz->get_sge_bootstrap_state(thiz);
863
cl_host_resolve_method_t resolve_method = CL_SHORT;
864
cl_framework_t communication_framework = CL_CT_TCP;
865
cl_com_handle_t* handle = NULL;
866
const char *help = NULL;
867
const char *default_domain = NULL;
868
int cl_ret = CL_RETVAL_OK;
870
DENTER(TOP_LAYER, "sge_gdi_ctx_class_prepare_enroll");
872
/* context setup is complete => setup the commlib
874
** there is a problem in qsub if it is used with CL_RW_THREAD, the signaling in qsub -sync
878
if (cl_com_setup_commlib_complete() == CL_FALSE) {
879
switch (thiz->get_who(thiz)) {
886
INFO((SGE_EVENT,MSG_GDI_MULTI_THREADED_STARTUP));
887
cl_ret = cl_com_setup_commlib(CL_RW_THREAD, CL_LOG_OFF, sge_gdi_ctx_log_flush_func);
890
INFO((SGE_EVENT,MSG_GDI_SINGLE_THREADED_STARTUP));
891
cl_ret = cl_com_setup_commlib(CL_NO_THREAD, CL_LOG_OFF, sge_gdi_ctx_log_flush_func);
893
** verbose logging is switched on by default
895
log_state_set_log_verbose(1);
897
if (cl_ret != CL_RETVAL_OK) {
898
sge_gdi_ctx_class_error(thiz, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR,
899
"cl_com_setup_commlib failed: %s", cl_get_error_text(cl_ret));
904
/* set the alias file */
905
cl_ret = cl_com_set_alias_file((char*)path_state->get_alias_file(path_state));
906
if (cl_ret != CL_RETVAL_OK && cl_ret != ctx_get_last_commlib_error(thiz)) {
907
sge_gdi_ctx_class_error(thiz, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR,
908
"cl_com_set_alias_file failed: %s", cl_get_error_text(cl_ret));
912
/* setup the resolve method */
914
if( bootstrap_state->get_ignore_fqdn(bootstrap_state) == false ) {
915
resolve_method = CL_LONG;
917
if ((help = bootstrap_state->get_default_domain(bootstrap_state)) != NULL) {
918
if (SGE_STRCASECMP(help, NONE_STR) != 0) {
919
default_domain = help;
923
cl_ret = cl_com_set_resolve_method(resolve_method, (char*)default_domain);
924
if (cl_ret != CL_RETVAL_OK && cl_ret != ctx_get_last_commlib_error(thiz)) {
925
sge_gdi_ctx_class_error(thiz, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR,
926
"cl_com_set_resolve_method failed: %s", cl_get_error_text(cl_ret));
931
** reresolve qualified hostname with use of host aliases
932
** (corresponds to reresolve_me_qualified_hostname)
934
cl_ret = thiz->reresolve_qualified_hostname(thiz);
935
if (cl_ret != CL_RETVAL_OK && cl_ret != ctx_get_last_commlib_error(thiz)) {
936
sge_gdi_ctx_class_error(thiz, STATUS_EUNKNOWN, ANSWER_QUALITY_WARNING,
937
"reresolve hostname failed: %s", cl_get_error_text(cl_ret));
943
** TODO set a general_communication_error
945
cl_ret = cl_com_set_error_func(general_communication_error);
946
if (cl_ret != CL_RETVAL_OK && cl_ret != ctx_get_last_commlib_error(thiz)) {
947
sge_gdi_ctx_class_error(thiz, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR,
948
"cl_com_set_error_func failed: %s", cl_get_error_text(cl_ret));
952
/* TODO set tag name function */
953
cl_ret = cl_com_set_tag_name_func(sge_dump_message_tag);
954
if (cl_ret != CL_RETVAL_OK && cl_ret != ctx_get_last_commlib_error(thiz)) {
955
sge_gdi_ctx_class_error(thiz, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR,
956
"cl_com_set_tag_name_func failed: %s", cl_get_error_text(cl_ret));
960
#ifdef DEBUG_CLIENT_SUPPORT
961
/* set debug client callback function to rmon's debug client callback */
962
cl_ret = cl_com_set_application_debug_client_callback_func(rmon_debug_client_callback);
963
if (cl_ret != CL_RETVAL_OK && cl_ret != ctx_get_last_commlib_error(thiz)) {
964
sge_gdi_ctx_class_error(thiz, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR,
965
"cl_com_set_application_debug_client_callback_func failed: %s", cl_get_error_text(cl_ret));
970
handle = thiz->get_com_handle(thiz);
971
if (handle == NULL) {
972
/* handle does not exist, create one */
974
int me_who = thiz->get_who(thiz);
975
const char *progname = thiz->get_progname(thiz);
976
const char *master = thiz->get_master(thiz, true);
977
const char *qualified_hostname = thiz->get_qualified_hostname(thiz);
978
u_long32 sge_qmaster_port = thiz->get_sge_qmaster_port(thiz); /* TODO: reresolving of port from /etc/services etc. */
979
u_long32 sge_execd_port = thiz->get_sge_execd_port(thiz);
980
int my_component_id = 0; /* 1 for daemons, 0=automatical for clients */
982
if (master == NULL && !(me_who == QMASTER)) {
983
DRETURN(CL_RETVAL_UNKNOWN);
989
if (strcasecmp(bootstrap_state->get_security_mode(bootstrap_state), "csp") == 0) {
990
cl_ssl_setup_t *sec_ssl_setup_config = NULL;
991
cl_ssl_cert_mode_t ssl_cert_mode = CL_SSL_PEM_FILE;
992
sge_csp_path_class_t *sge_csp = get_sge_csp_path(thiz);
994
if (thiz->get_certificate(thiz) != NULL) {
995
ssl_cert_mode = CL_SSL_PEM_BYTE;
996
sge_csp->set_cert_file(sge_csp, thiz->get_certificate(thiz));
997
sge_csp->set_key_file(sge_csp, thiz->get_private_key(thiz));
999
sge_csp->dprintf(sge_csp);
1001
communication_framework = CL_CT_SSL;
1002
cl_ret = cl_com_create_ssl_setup(&sec_ssl_setup_config,
1004
CL_SSL_v23, /* ssl_method */
1005
(char*)sge_csp->get_CA_cert_file(sge_csp), /* ssl_CA_cert_pem_file */
1006
(char*)sge_csp->get_CA_key_file(sge_csp), /* ssl_CA_key_pem_file */
1007
(char*)sge_csp->get_cert_file(sge_csp), /* ssl_cert_pem_file */
1008
(char*)sge_csp->get_key_file(sge_csp), /* ssl_key_pem_file */
1009
(char*)sge_csp->get_rand_file(sge_csp), /* ssl_rand_file */
1010
(char*)sge_csp->get_reconnect_file(sge_csp), /* ssl_reconnect_file */
1011
(char*)sge_csp->get_crl_file(sge_csp), /* ssl_crl_file */
1012
sge_csp->get_refresh_time(sge_csp), /* ssl_refresh_time */
1013
(char*)sge_csp->get_password(sge_csp), /* ssl_password */
1014
sge_csp->get_verify_func(sge_csp)); /* ssl_verify_func (cl_ssl_verify_func_t) */
1015
if (cl_ret != CL_RETVAL_OK && cl_ret != ctx_get_last_commlib_error(thiz)) {
1016
DPRINTF(("return value of cl_com_create_ssl_setup(): %s\n", cl_get_error_text(cl_ret)));
1017
sge_gdi_ctx_class_error(thiz, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR, MSG_GDI_CANT_CONNECT_HANDLE_SSUUS,
1021
cl_get_error_text(cl_ret));
1026
** set the CSP credential info into commlib
1028
cl_ret = cl_com_specify_ssl_configuration(sec_ssl_setup_config);
1029
if (cl_ret != CL_RETVAL_OK && cl_ret != ctx_get_last_commlib_error(thiz)) {
1030
DPRINTF(("return value of cl_com_specify_ssl_configuration(): %s\n", cl_get_error_text(cl_ret)));
1031
sge_gdi_ctx_class_error(thiz, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR, MSG_GDI_CANT_CONNECT_HANDLE_SSUUS,
1032
(char*)thiz->get_component_name(thiz), 0,
1034
cl_get_error_text(cl_ret));
1035
cl_com_free_ssl_setup(&sec_ssl_setup_config);
1038
cl_com_free_ssl_setup(&sec_ssl_setup_config);
1041
if ( me_who == QMASTER ||
1044
me_who == SHADOWD ) {
1045
my_component_id = 1;
1051
/* add qmaster as known endpoint */
1052
DPRINTF(("re-read actual qmaster file (prepare_enroll)\n"));
1053
cl_com_append_known_endpoint_from_name((char*)master,
1054
(char*)prognames[QMASTER],
1059
handle = cl_com_create_handle(&cl_ret,
1060
communication_framework,
1065
(char*)thiz->get_component_name(thiz),
1069
cl_com_set_auto_close_mode(handle, CL_CM_AC_ENABLED);
1070
if (handle == NULL) {
1071
if (cl_ret != CL_RETVAL_OK && cl_ret != ctx_get_last_commlib_error(thiz)) {
1073
** TODO: eh error handler does no logging
1075
ERROR((SGE_EVENT, MSG_GDI_CANT_GET_COM_HANDLE_SSUUS,
1077
(char*)thiz->get_component_name(thiz),
1078
sge_u32c(my_component_id),
1079
sge_u32c(sge_execd_port),
1080
cl_get_error_text(cl_ret)));
1086
DPRINTF(("creating QMASTER handle\n"));
1087
cl_com_append_known_endpoint_from_name((char*)master,
1088
(char*) prognames[QMASTER],
1094
/* do a later qmaster commlib listen before creating qmaster handle */
1095
/* TODO: CL_COMMLIB_DELAYED_LISTEN is set to CL_FALSE, because
1096
enabling it might cause problems with current shadowd and
1097
startup qmaster implementation */
1098
cl_commlib_set_global_param(CL_COMMLIB_DELAYED_LISTEN, CL_FALSE);
1100
handle = cl_com_create_handle(&cl_ret,
1101
communication_framework,
1102
CL_CM_CT_MESSAGE, /* message based tcp communication */
1104
sge_qmaster_port, /* create service on qmaster port */
1105
CL_TCP_DEFAULT, /* use standard connect mode */
1106
(char*)thiz->get_component_name(thiz),
1107
my_component_id, /* this endpoint is called "qmaster"
1110
0); /* select timeout is set to 1 second 0 usec */
1111
if (handle == NULL) {
1112
if (cl_ret != CL_RETVAL_OK && cl_ret != ctx_get_last_commlib_error(thiz)) {
1114
** TODO: eh error handler does no logging
1116
ERROR((SGE_EVENT, MSG_GDI_CANT_GET_COM_HANDLE_SSUUS,
1118
(char*)thiz->get_component_name(thiz),
1119
sge_u32c(my_component_id),
1120
sge_u32c(sge_qmaster_port),
1121
cl_get_error_text(cl_ret)));
1124
/* TODO: remove reresolving here */
1126
char act_resolved_qmaster_name[CL_MAXHOSTLEN];
1127
cl_com_set_synchron_receive_timeout(handle, 5);
1128
/* TODO: reresolve master */
1129
master = thiz->get_master(thiz, true);
1131
if (master != NULL) {
1132
/* TODO: sge_hostcmp uses implicitly bootstrap state info */
1133
/* check a running qmaster on different host */
1134
if (getuniquehostname(master, act_resolved_qmaster_name, 0) == CL_RETVAL_OK &&
1135
sge_hostcmp(act_resolved_qmaster_name, qualified_hostname) != 0) {
1136
DPRINTF(("act_qmaster file contains host "SFQ" which doesn't match local host name "SFQ"\n",
1137
master, qualified_hostname));
1139
cl_com_set_error_func(NULL);
1141
alive_back = thiz->is_alive(thiz);
1142
cl_ret = cl_com_set_error_func(general_communication_error);
1143
if (cl_ret != CL_RETVAL_OK) {
1144
ERROR((SGE_EVENT, cl_get_error_text(cl_ret)) );
1147
if (alive_back == CL_RETVAL_OK && getenv("SGE_TEST_HEARTBEAT_TIMEOUT") == NULL ) {
1148
CRITICAL((SGE_EVENT, MSG_GDI_MASTER_ON_HOST_X_RUNINNG_TERMINATE_S, master));
1149
/* TODO: remove !!! */
1152
DPRINTF(("qmaster on host "SFQ" is down\n", master));
1155
DPRINTF(("act_qmaster file contains local host name\n"));
1158
DPRINTF(("skipping qmaster alive check because act_qmaster is not availabe\n"));
1164
DPRINTF(("creating QMON GDI handle\n"));
1165
handle = cl_com_create_handle(&cl_ret,
1166
communication_framework,
1171
(char*)thiz->get_component_name(thiz),
1175
cl_com_set_auto_close_mode(handle, CL_CM_AC_ENABLED);
1176
if (handle == NULL) {
1177
if (cl_ret != CL_RETVAL_OK && cl_ret != ctx_get_last_commlib_error(thiz)) {
1178
ERROR((SGE_EVENT, MSG_GDI_CANT_CONNECT_HANDLE_SSUUS,
1180
(char*)thiz->get_component_name(thiz),
1181
sge_u32c(my_component_id),
1182
sge_u32c(sge_qmaster_port),
1183
cl_get_error_text(cl_ret)));
1189
/* this is for "normal" gdi clients of qmaster */
1190
DPRINTF(("creating %s GDI handle\n", thiz->get_component_name(thiz)));
1191
handle = cl_com_create_handle(&cl_ret,
1192
communication_framework,
1197
(char*)thiz->get_component_name(thiz),
1201
if (handle == NULL) {
1202
/* if (cl_ret != CL_RETVAL_OK && cl_ret != ctx_get_last_commlib_error(thiz)) { */
1203
sge_gdi_ctx_class_error(thiz, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR,
1204
MSG_GDI_CANT_CONNECT_HANDLE_SSUUS,
1205
thiz->get_qualified_hostname(thiz),
1206
thiz->get_component_name(thiz),
1207
sge_u32c(my_component_id),
1208
sge_u32c(sge_qmaster_port),
1209
cl_get_error_text(cl_ret));
1214
ctx_set_last_commlib_error(thiz, cl_ret);
1217
#ifdef DEBUG_CLIENT_SUPPORT
1218
/* set rmon callback for message printing (after handle creation) */
1219
rmon_set_print_callback(gdi_rmon_print_callback_function);
1222
if ((thiz->get_who(thiz) == QMASTER) && (getenv("SGE_TEST_SOCKET_BIND") != NULL)) {
1223
/* this is for testsuite socket bind test (issue 1096 ) */
1225
gettimeofday(&now,NULL);
1227
/* if this environment variable is set, we wait 15 seconds after
1228
communication lib setup */
1229
DPRINTF(("waiting for 60 seconds, because environment SGE_TEST_SOCKET_BIND is set\n"));
1230
while ( handle != NULL && now.tv_sec - handle->start_time.tv_sec <= 60 ) {
1231
DPRINTF(("timeout: "sge_U32CFormat"\n",sge_u32c(now.tv_sec - handle->start_time.tv_sec)));
1232
cl_commlib_trigger(handle, 1);
1233
gettimeofday(&now,NULL);
1235
DPRINTF(("continue with setup\n"));
1240
static int sge_gdi_ctx_class_is_alive(sge_gdi_ctx_class_t *thiz)
1242
cl_com_SIRM_t* status = NULL;
1243
int cl_ret = CL_RETVAL_OK;
1244
cl_com_handle_t *handle = thiz->get_com_handle(thiz);
1247
const char* comp_name = prognames[QMASTER];
1248
const char* comp_host = thiz->get_master(thiz, false);
1251
DENTER(TOP_LAYER, "sge_gdi_ctx_class_is_alive");
1253
if (handle == NULL) {
1254
sge_gdi_ctx_class_error(thiz, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR,
1255
"handle not found %s:0", thiz->get_component_name(thiz));
1256
DRETURN(CL_RETVAL_PARAMS);
1259
DPRINTF(("to->comp_host, to->comp_name, to->comp_id: %s/%s/%d\n", comp_host?comp_host:"", comp_name?comp_name:"", comp_id));
1260
cl_ret = cl_commlib_get_endpoint_status(handle, (char*)comp_host, (char*)comp_name, comp_id, &status);
1261
if (cl_ret != CL_RETVAL_OK) {
1262
sge_gdi_ctx_class_error(thiz, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR,
1263
"cl_commlib_get_endpoint_status failed: "SFQ, cl_get_error_text(cl_ret));
1265
DEBUG((SGE_EVENT,MSG_GDI_QMASTER_STILL_RUNNING));
1268
if (status != NULL) {
1269
DEBUG((SGE_EVENT,MSG_GDI_ENDPOINT_UPTIME_UU, sge_u32c(status->runtime) ,
1270
sge_u32c(status->application_status)));
1271
cl_com_free_sirm_message(&status);
1277
static lList* sge_gdi_ctx_class_gdi_tsm(sge_gdi_ctx_class_t *thiz, const char *schedd_name, const char *cell)
1281
DENTER(TOP_LAYER, "sge_gdi_ctx_class_gdi_tsm");
1283
alp = gdi2_tsm(thiz, schedd_name, cell);
1289
static lList* sge_gdi_ctx_class_gdi_kill(sge_gdi_ctx_class_t *thiz, lList *id_list, const char *cell,
1290
u_long32 option_flags, u_long32 action_flag)
1294
DENTER(TOP_LAYER, "sge_gdi_ctx_class_gdi_kill");
1296
alp = gdi2_kill(thiz, id_list, cell, option_flags, action_flag);
1302
static bool sge_gdi_ctx_class_gdi_check_permission(sge_gdi_ctx_class_t *thiz, lList **alpp, int option)
1306
DENTER(TOP_LAYER, "sge_gdi_ctx_class_gdi_check_permission");
1308
ret = sge_gdi2_check_permission(thiz, alpp, option);
1314
static bool sge_gdi_ctx_class_gdi_get_mapping_name(sge_gdi_ctx_class_t *thiz, const char *requestedHost, char *buf, int buflen)
1318
DENTER(TOP_LAYER, "sge_gdi_ctx_class_gdi_get_mapping_name");
1320
ret = sge_gdi2_get_mapping_name(thiz, requestedHost, buf, buflen);
1326
static void sge_gdi_ctx_class_dprintf(sge_gdi_ctx_class_t *ctx)
1328
DENTER(TOP_LAYER, "sge_gdi_ctx_class_dprintf");
1333
DPRINTF(("vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv\n"));
1335
(ctx->get_sge_env_state(ctx))->dprintf(ctx->get_sge_env_state(ctx));
1336
(ctx->get_sge_prog_state(ctx))->dprintf(ctx->get_sge_prog_state(ctx));
1337
(ctx->get_sge_path_state(ctx))->dprintf(ctx->get_sge_path_state(ctx));
1338
(ctx->get_sge_bootstrap_state(ctx))->dprintf(ctx->get_sge_bootstrap_state(ctx));
1340
DPRINTF(("master: %s\n", ctx->get_master(ctx, false)));
1341
DPRINTF(("uid/username: %d/%s\n", (int) ctx->get_uid(ctx), ctx->get_username(ctx)));
1342
DPRINTF(("gid/groupname: %d/%s\n", (int) ctx->get_gid(ctx), ctx->get_groupname(ctx)));
1344
DPRINTF(("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"));
1350
/** --------- getter/setter ------------------------------------------------- */
1351
static cl_com_handle_t* get_com_handle(sge_gdi_ctx_class_t *thiz)
1353
sge_gdi_ctx_t *es = (sge_gdi_ctx_t *) thiz->sge_gdi_ctx_handle;
1354
return cl_com_get_handle(es->component_name, 0);
1357
static sge_env_state_class_t* get_sge_env_state(sge_gdi_ctx_class_t *thiz)
1359
sge_gdi_ctx_t *es = (sge_gdi_ctx_t *) thiz->sge_gdi_ctx_handle;
1360
return es->sge_env_state_obj;
1363
static sge_prog_state_class_t* get_sge_prog_state(sge_gdi_ctx_class_t *thiz)
1365
sge_gdi_ctx_t *es = (sge_gdi_ctx_t *) thiz->sge_gdi_ctx_handle;
1366
return es->sge_prog_state_obj;
1369
static sge_path_state_class_t* get_sge_path_state(sge_gdi_ctx_class_t *thiz)
1371
sge_gdi_ctx_t *es = (sge_gdi_ctx_t *) thiz->sge_gdi_ctx_handle;
1372
return es->sge_path_state_obj;
1375
static sge_csp_path_class_t* get_sge_csp_path(sge_gdi_ctx_class_t *thiz)
1377
sge_gdi_ctx_t *es = (sge_gdi_ctx_t *) thiz->sge_gdi_ctx_handle;
1378
return es->sge_csp_path_obj;
1381
static sge_bootstrap_state_class_t* get_sge_bootstrap_state(sge_gdi_ctx_class_t *thiz)
1383
sge_gdi_ctx_t *es = (sge_gdi_ctx_t *) thiz->sge_gdi_ctx_handle;
1384
return es->sge_bootstrap_state_obj;
1387
static const char* get_master(sge_gdi_ctx_class_t *thiz, bool reread) {
1388
sge_gdi_ctx_t *es = (sge_gdi_ctx_t *) thiz->sge_gdi_ctx_handle;
1389
sge_path_state_class_t* path_state = thiz->get_sge_path_state(thiz);
1390
sge_error_class_t *eh = es ? es->eh : NULL;
1392
DENTER(BASIS_LAYER, "sge_gdi_ctx_class->get_master");
1394
if (es->master == NULL || reread) {
1395
char err_str[SGE_PATH_MAX+128];
1396
char master_name[CL_MAXHOSTLEN];
1398
if (get_qm_name(master_name, path_state->get_act_qmaster_file(path_state), err_str) == -1) {
1400
eh->error(eh, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR, MSG_GDI_READMASTERNAMEFAILED_S, err_str);
1404
DPRINTF(("(re-)reading act_qmaster file. Got master host \"%s\"\n", master_name));
1406
** TODO: thread locking needed here ?
1408
es->master = sge_strdup(es->master,master_name);
1410
DRETURN(es->master);
1413
static const char* get_qualified_hostname(sge_gdi_ctx_class_t *thiz) {
1414
sge_prog_state_class_t* prog_state = thiz->get_sge_prog_state(thiz);
1415
const char *qualified_hostname = NULL;
1417
DENTER(BASIS_LAYER, "sge_gdi_ctx_class->get_progname");
1418
qualified_hostname = prog_state->get_qualified_hostname(prog_state);
1419
DRETURN(qualified_hostname);
1422
static const char* get_unqualified_hostname(sge_gdi_ctx_class_t *thiz) {
1423
sge_prog_state_class_t* prog_state = thiz->get_sge_prog_state(thiz);
1424
const char *unqualified_hostname = NULL;
1426
DENTER(BASIS_LAYER, "sge_gdi_ctx_class->get_unqualified_hostname");
1427
unqualified_hostname = prog_state->get_unqualified_hostname(prog_state);
1428
DRETURN(unqualified_hostname);
1431
static const char* get_component_name(sge_gdi_ctx_class_t *thiz) {
1432
sge_gdi_ctx_t *es = (sge_gdi_ctx_t *) thiz->sge_gdi_ctx_handle;
1433
const char* ret = NULL;
1434
DENTER(BASIS_LAYER, "sge_gdi_ctx_class->get_component_name");
1435
ret = es->component_name;
1439
static const char* get_thread_name(sge_gdi_ctx_class_t *thiz) {
1440
sge_gdi_ctx_t *es = (sge_gdi_ctx_t *) thiz->sge_gdi_ctx_handle;
1441
const char* ret = NULL;
1442
DENTER(BASIS_LAYER, "sge_gdi_ctx_class->get_thread_name");
1443
ret = es->thread_name;
1447
static const char* get_progname(sge_gdi_ctx_class_t *thiz) {
1448
sge_prog_state_class_t* prog_state = thiz->get_sge_prog_state(thiz);
1449
const char *progname = NULL;
1451
DENTER(BASIS_LAYER, "sge_gdi_ctx_class->get_progname");
1452
progname = prog_state->get_sge_formal_prog_name(prog_state);
1456
static u_long32 get_who(sge_gdi_ctx_class_t *thiz) {
1457
sge_prog_state_class_t* prog_state = thiz->get_sge_prog_state(thiz);
1458
u_long32 prognumber = 0;
1460
DENTER(BASIS_LAYER, "sge_gdi_ctx_class->get_who");
1461
prognumber = prog_state->get_who(prog_state);
1462
DRETURN(prognumber);
1465
static bool is_daemonized(sge_gdi_ctx_class_t *thiz) {
1466
sge_prog_state_class_t* prog_state = thiz->get_sge_prog_state(thiz);
1467
bool is_daemonized = false;
1469
DENTER(BASIS_LAYER, "sge_gdi_ctx_class->is_daemonized");
1470
is_daemonized = (prog_state->get_daemonized(prog_state)) ? true : false;
1471
DRETURN(is_daemonized);
1474
static void set_daemonized(sge_gdi_ctx_class_t *thiz, bool daemonized) {
1475
sge_prog_state_class_t* prog_state = thiz->get_sge_prog_state(thiz);
1476
DENTER(BASIS_LAYER, "sge_gdi_ctx_class->set_daemonized");
1477
prog_state->set_daemonized(prog_state, daemonized);
1481
static bool get_job_spooling(sge_gdi_ctx_class_t *thiz) {
1482
sge_bootstrap_state_class_t* bootstrap_state = thiz->get_sge_bootstrap_state(thiz);
1483
bool job_spooling = true;
1485
DENTER(BASIS_LAYER, "sge_gdi_ctx_class->get_job_spooling");
1486
job_spooling = bootstrap_state->get_job_spooling(bootstrap_state);
1487
DRETURN(job_spooling);
1490
static void set_job_spooling(sge_gdi_ctx_class_t *thiz, bool job_spooling) {
1491
sge_bootstrap_state_class_t* bootstrap_state = thiz->get_sge_bootstrap_state(thiz);
1493
DENTER(BASIS_LAYER, "sge_gdi_ctx_class->set_job_spooling");
1494
bootstrap_state->set_job_spooling(bootstrap_state, job_spooling);
1498
static const char* get_spooling_method(sge_gdi_ctx_class_t *thiz) {
1499
sge_bootstrap_state_class_t* bootstrap_state = thiz->get_sge_bootstrap_state(thiz);
1500
const char *spooling_method = NULL;
1502
DENTER(BASIS_LAYER, "sge_gdi_ctx_class->get_spooling_method");
1503
spooling_method = bootstrap_state->get_spooling_method(bootstrap_state);
1504
DRETURN(spooling_method);
1507
static const char* get_spooling_lib(sge_gdi_ctx_class_t *thiz) {
1508
sge_bootstrap_state_class_t* bootstrap_state = thiz->get_sge_bootstrap_state(thiz);
1509
const char *spooling_lib = NULL;
1511
DENTER(BASIS_LAYER, "sge_gdi_ctx_class->get_spooling_lib");
1512
spooling_lib = bootstrap_state->get_spooling_lib(bootstrap_state);
1513
DRETURN(spooling_lib);
1516
static const char* get_spooling_params(sge_gdi_ctx_class_t *thiz) {
1517
sge_bootstrap_state_class_t* bootstrap_state = thiz->get_sge_bootstrap_state(thiz);
1518
const char *spooling_params = NULL;
1520
DENTER(BASIS_LAYER, "sge_gdi_ctx_class->get_spooling_params");
1521
spooling_params = bootstrap_state->get_spooling_params(bootstrap_state);
1522
DRETURN(spooling_params);
1525
static u_long32 get_listener_thread_count(sge_gdi_ctx_class_t *thiz) {
1526
sge_bootstrap_state_class_t* bootstrap_state = thiz->get_sge_bootstrap_state(thiz);
1527
u_long32 thread_count = 0;
1529
DENTER(BASIS_LAYER, "sge_gdi_ctx_class->get_listenr_thread_count");
1530
thread_count = bootstrap_state->get_listener_thread_count(bootstrap_state);
1531
DRETURN(thread_count);
1534
static u_long32 get_worker_thread_count(sge_gdi_ctx_class_t *thiz) {
1535
sge_bootstrap_state_class_t* bootstrap_state = thiz->get_sge_bootstrap_state(thiz);
1536
u_long32 thread_count = 0;
1538
DENTER(BASIS_LAYER, "sge_gdi_ctx_class->get_worker_thread_count");
1539
thread_count = bootstrap_state->get_worker_thread_count(bootstrap_state);
1540
DRETURN(thread_count);
1543
static u_long32 get_scheduler_thread_count(sge_gdi_ctx_class_t *thiz) {
1544
sge_bootstrap_state_class_t* bootstrap_state = thiz->get_sge_bootstrap_state(thiz);
1545
u_long32 thread_count = 0;
1547
DENTER(BASIS_LAYER, "sge_gdi_ctx_class->get_scheduler_thread_count");
1548
thread_count = bootstrap_state->get_scheduler_thread_count(bootstrap_state);
1549
DRETURN(thread_count);
1552
static u_long32 get_jvm_thread_count(sge_gdi_ctx_class_t *thiz) {
1553
sge_bootstrap_state_class_t* bootstrap_state = thiz->get_sge_bootstrap_state(thiz);
1554
u_long32 thread_count = 0;
1556
DENTER(BASIS_LAYER, "sge_gdi_ctx_class->get_jvm_thread_count");
1557
thread_count = bootstrap_state->get_jvm_thread_count(bootstrap_state);
1558
DRETURN(thread_count);
1561
static sge_exit_func_t get_exit_func(sge_gdi_ctx_class_t *thiz) {
1562
sge_prog_state_class_t* prog_state = thiz->get_sge_prog_state(thiz);
1563
sge_exit_func_t exit_func = NULL;
1564
DENTER(BASIS_LAYER, "sge_gdi_ctx_class->get_exit_func");
1565
exit_func = prog_state->get_exit_func(prog_state);
1569
static void set_exit_func(sge_gdi_ctx_class_t *thiz, sge_exit_func_t exit_func) {
1570
sge_prog_state_class_t* prog_state = thiz->get_sge_prog_state(thiz);
1571
DENTER(BASIS_LAYER, "sge_gdi_ctx_class->set_exit_func");
1572
prog_state->set_exit_func(prog_state, exit_func);
1576
static void set_private_key(sge_gdi_ctx_class_t *thiz, const char *pkey) {
1577
sge_gdi_ctx_t *es = (sge_gdi_ctx_t *) thiz->sge_gdi_ctx_handle;
1579
DENTER(BASIS_LAYER, "sge_gdi_ctx_class->set_private_key");
1581
if ( es->ssl_private_key != NULL ) {
1582
FREE(es->ssl_private_key);
1584
es->ssl_private_key = pkey ? strdup(pkey): NULL;
1589
static const char* get_private_key(sge_gdi_ctx_class_t *thiz) {
1590
sge_gdi_ctx_t *es = (sge_gdi_ctx_t *) thiz->sge_gdi_ctx_handle;
1591
const char *pkey = NULL;
1593
DENTER(BASIS_LAYER, "sge_gdi_ctx_class->get_private_key");
1594
pkey = es->ssl_private_key;
1599
static void set_certificate(sge_gdi_ctx_class_t *thiz, const char *cert) {
1600
sge_gdi_ctx_t *es = (sge_gdi_ctx_t *) thiz->sge_gdi_ctx_handle;
1602
DENTER(BASIS_LAYER, "sge_gdi_ctx_class->set_certificate");
1604
if (es->ssl_certificate != NULL) {
1605
FREE(es->ssl_certificate);
1607
es->ssl_certificate = cert ? strdup(cert) : NULL;
1612
static const char* get_certificate(sge_gdi_ctx_class_t *thiz) {
1613
sge_gdi_ctx_t *es = (sge_gdi_ctx_t *) thiz->sge_gdi_ctx_handle;
1614
const char *cert = NULL;
1616
DENTER(BASIS_LAYER, "sge_gdi_ctx_class->get_certificate");
1617
cert = es->ssl_certificate;
1621
static const char* get_ca_local_root(sge_gdi_ctx_class_t *thiz) {
1622
sge_csp_path_class_t *sge_csp = get_sge_csp_path(thiz);
1623
const char *ca_local_root = NULL;
1625
DENTER(BASIS_LAYER, "sge_gdi_ctx_class->get_ca_local_root");
1626
if (sge_csp != NULL) {
1627
ca_local_root = sge_csp->get_ca_local_root(sge_csp);
1629
DRETURN(ca_local_root);
1632
static const char* get_ca_root(sge_gdi_ctx_class_t *thiz) {
1633
sge_csp_path_class_t *sge_csp = get_sge_csp_path(thiz);
1634
const char *ca_root = NULL;
1636
DENTER(BASIS_LAYER, "sge_gdi_ctx_class->get_ca_root");
1637
if (sge_csp != NULL) {
1638
ca_root = sge_csp->get_ca_root(sge_csp);
1643
static const char* get_default_cell(sge_gdi_ctx_class_t *thiz) {
1644
sge_prog_state_class_t* prog_state = thiz->get_sge_prog_state(thiz);
1645
const char *default_cell = NULL;
1647
DENTER(BASIS_LAYER, "sge_gdi_ctx_class->get_default_cell");
1648
default_cell = prog_state->get_default_cell(prog_state);
1649
DRETURN(default_cell);
1653
static const char* get_cell_root(sge_gdi_ctx_class_t *thiz) {
1654
sge_path_state_class_t* path_state = thiz->get_sge_path_state(thiz);
1655
const char *cell_root = NULL;
1657
DENTER(BASIS_LAYER, "sge_gdi_ctx_class->get_cell_root");
1658
cell_root = path_state->get_cell_root(path_state);
1662
static const char* get_sge_root(sge_gdi_ctx_class_t *thiz) {
1663
sge_path_state_class_t* path_state = thiz->get_sge_path_state(thiz);
1664
const char *sge_root = NULL;
1666
DENTER(BASIS_LAYER, "sge_gdi_ctx_class->get_sge_root");
1667
sge_root = path_state->get_sge_root(path_state);
1672
static const char* get_admin_user(sge_gdi_ctx_class_t *thiz) {
1673
sge_bootstrap_state_class_t * bootstrap_state = thiz->get_sge_bootstrap_state(thiz);
1674
return bootstrap_state->get_admin_user(bootstrap_state);
1677
static const char* get_binary_path(sge_gdi_ctx_class_t *thiz) {
1678
sge_bootstrap_state_class_t * bootstrap_state = thiz->get_sge_bootstrap_state(thiz);
1679
return bootstrap_state->get_binary_path(bootstrap_state);
1682
static const char* get_qmaster_spool_dir(sge_gdi_ctx_class_t *thiz) {
1683
sge_bootstrap_state_class_t * bootstrap_state = thiz->get_sge_bootstrap_state(thiz);
1684
return bootstrap_state->get_qmaster_spool_dir(bootstrap_state);
1687
static const char* get_bootstrap_file(sge_gdi_ctx_class_t *thiz) {
1688
sge_path_state_class_t *path_state = thiz->get_sge_path_state(thiz);
1689
return path_state->get_bootstrap_file(path_state);
1692
static const char* get_act_qmaster_file(sge_gdi_ctx_class_t *thiz) {
1693
sge_path_state_class_t *path_state = thiz->get_sge_path_state(thiz);
1694
return path_state->get_act_qmaster_file(path_state);
1697
static const char* get_acct_file(sge_gdi_ctx_class_t *thiz) {
1698
sge_path_state_class_t *path_state = thiz->get_sge_path_state(thiz);
1699
return path_state->get_acct_file(path_state);
1702
static const char* get_reporting_file(sge_gdi_ctx_class_t *thiz) {
1703
sge_path_state_class_t *path_state = thiz->get_sge_path_state(thiz);
1704
return path_state->get_reporting_file(path_state);
1708
static const char* get_shadow_master_file(sge_gdi_ctx_class_t *thiz) {
1709
sge_path_state_class_t *path_state = thiz->get_sge_path_state(thiz);
1710
return path_state->get_shadow_masters_file(path_state);
1714
static const char* get_username(sge_gdi_ctx_class_t *thiz) {
1715
sge_gdi_ctx_t *es = (sge_gdi_ctx_t *) thiz->sge_gdi_ctx_handle;
1716
return es->username;
1719
static const char* get_groupname(sge_gdi_ctx_class_t *thiz) {
1720
sge_gdi_ctx_t *es = (sge_gdi_ctx_t *) thiz->sge_gdi_ctx_handle;
1721
return es->groupname;
1725
static u_long32 get_sge_qmaster_port(sge_gdi_ctx_class_t *thiz) {
1726
sge_env_state_class_t *es = thiz->get_sge_env_state(thiz);
1727
return es->get_sge_qmaster_port(es);
1730
static u_long32 get_sge_execd_port(sge_gdi_ctx_class_t *thiz) {
1731
sge_env_state_class_t *es = thiz->get_sge_env_state(thiz);
1732
return es->get_sge_execd_port(es);
1735
static int ctx_get_last_commlib_error(sge_gdi_ctx_class_t *thiz) {
1736
sge_gdi_ctx_t *es = (sge_gdi_ctx_t *) thiz->sge_gdi_ctx_handle;
1737
return es->last_commlib_error;
1740
static void ctx_set_last_commlib_error(sge_gdi_ctx_class_t *thiz, int cl_error) {
1741
sge_gdi_ctx_t *es = (sge_gdi_ctx_t *) thiz->sge_gdi_ctx_handle;
1742
es->last_commlib_error = cl_error;
1746
static uid_t ctx_get_uid(sge_gdi_ctx_class_t *thiz) {
1747
sge_gdi_ctx_t *es = (sge_gdi_ctx_t *) thiz->sge_gdi_ctx_handle;
1751
static gid_t ctx_get_gid(sge_gdi_ctx_class_t *thiz) {
1752
sge_gdi_ctx_t *es = (sge_gdi_ctx_t *) thiz->sge_gdi_ctx_handle;
1756
static bool ctx_is_qmaster_internal_client(sge_gdi_ctx_class_t *thiz) {
1757
sge_gdi_ctx_t *es = (sge_gdi_ctx_t *) thiz->sge_gdi_ctx_handle;
1758
return es->is_qmaster_internal_client;
1762
static int sge_gdi_ctx_log_flush_func(cl_raw_list_t* list_p)
1765
cl_log_list_elem_t* elem = NULL;
1767
DENTER(COMMD_LAYER, "sge_gdi_ctx_log_flush_func");
1769
if (list_p == NULL) {
1770
DRETURN(CL_RETVAL_LOG_NO_LOGLIST);
1773
if ((ret_val = cl_raw_list_lock(list_p)) != CL_RETVAL_OK) {
1777
while ((elem = cl_log_list_get_first_elem(list_p) ) != NULL) {
1779
if (elem->log_parameter == NULL) {
1782
param = elem->log_parameter;
1785
switch(elem->log_type) {
1787
if (log_state_get_log_level() >= LOG_ERR) {
1788
ERROR((SGE_EVENT, "%s %-20s=> %s %s\n", elem->log_module_name, elem->log_thread_name, elem->log_message, param ));
1790
printf("%s %-20s=> %s %s\n", elem->log_module_name, elem->log_thread_name, elem->log_message, param);
1793
case CL_LOG_WARNING:
1794
if (log_state_get_log_level() >= LOG_WARNING) {
1795
WARNING((SGE_EVENT,"%s %-20s=> %s %s\n", elem->log_module_name, elem->log_thread_name, elem->log_message, param ));
1797
printf("%s %-20s=> %s %s\n", elem->log_module_name, elem->log_thread_name, elem->log_message, param);
1801
if (log_state_get_log_level() >= LOG_INFO) {
1802
INFO((SGE_EVENT, "%s %-20s=> %s %s\n", elem->log_module_name, elem->log_thread_name, elem->log_message, param ));
1804
printf("%s %-20s=> %s %s\n", elem->log_module_name, elem->log_thread_name, elem->log_message, param);
1808
if (log_state_get_log_level() >= LOG_DEBUG) {
1809
DEBUG((SGE_EVENT, "%s %-20s=> %s %s\n", elem->log_module_name, elem->log_thread_name, elem->log_message, param ));
1811
printf("%s %-20s=> %s %s\n", elem->log_module_name, elem->log_thread_name, elem->log_message, param);
1817
cl_log_list_del_log(list_p);
1820
if ((ret_val = cl_raw_list_unlock(list_p)) != CL_RETVAL_OK) {
1823
DRETURN(CL_RETVAL_OK);
1828
** only helper function to do the setup for clients similar to sge_setup()
1831
sge_setup2(sge_gdi_ctx_class_t **context, u_long32 progid, u_long32 thread_id,
1832
lList **alpp, bool is_qmaster_intern_client)
1834
char user[128] = "";
1835
char group[128] = "";
1836
const char *sge_root = NULL;
1837
const char *sge_cell = NULL;
1838
u_long32 sge_qmaster_port = 0;
1839
u_long32 sge_execd_port = 0;
1840
bool from_services = false;
1842
DENTER(TOP_LAYER, "sge_setup2");
1844
if (context == NULL) {
1845
answer_list_add_sprintf(alpp, STATUS_ESEMANTIC, ANSWER_QUALITY_CRITICAL, MSG_GDI_CONTEXT_NULL);
1851
** get the environment for now here -> sge_env_class_t should be enhanced and used instead as input param
1853
sge_root = getenv("SGE_ROOT");
1854
if (sge_root == NULL) {
1855
answer_list_add_sprintf(alpp, STATUS_ESEMANTIC,
1856
ANSWER_QUALITY_CRITICAL, MSG_SGEROOTNOTSET);
1859
sge_cell = getenv("SGE_CELL")?getenv("SGE_CELL"):DEFAULT_CELL;
1860
sge_qmaster_port = sge_get_qmaster_port(&from_services);
1861
sge_execd_port = sge_get_execd_port();
1864
* uidgid_mt_init() needs to be called here already so that sge_uid2user()
1865
* sge_gid2group() works correctly. Other *_mt_init() functions are called
1866
* in sge_gdi_ctx_class_create();
1870
if (sge_uid2user(geteuid(), user, sizeof(user), MAX_NIS_RETRIES)) {
1871
answer_list_add_sprintf(alpp, STATUS_ESEMANTIC, ANSWER_QUALITY_CRITICAL, MSG_SYSTEM_RESOLVEUSER);
1875
if (sge_gid2group(getegid(), group, sizeof(group), MAX_NIS_RETRIES)) {
1876
answer_list_add_sprintf(alpp, STATUS_ESEMANTIC, ANSWER_QUALITY_CRITICAL, MSG_SYSTEM_RESOLVEGROUP);
1880
/* a dynamic eh handler is created */
1881
*context = sge_gdi_ctx_class_create(progid, prognames[progid], thread_id,
1882
threadnames[thread_id], user, group,
1883
sge_root, sge_cell, sge_qmaster_port,
1884
sge_execd_port, from_services,
1885
is_qmaster_intern_client, alpp);
1887
if (*context == NULL) {
1892
** TODO: we set the log state context here
1893
** this should be done more explicitily !!!
1895
log_state_set_log_context(*context);
1898
** TODO: bootstrap info is used in cull functions sge_hostcpy
1899
** ignore_fqdn, domain_name
1900
** Therefore we have to set it into the thread ctx
1902
sge_gdi_set_thread_local_ctx(*context);
1909
** only helper function to do the setup for clients similar to sge_gdi_setup()
1911
int sge_gdi2_setup(sge_gdi_ctx_class_t **context_ref, u_long32 progid, u_long32 thread_id, lList **alpp)
1914
bool alpp_was_null = true;
1916
DENTER(TOP_LAYER, "sge_gdi2_setup");
1918
if (context_ref && sge_gdi_ctx_is_setup(*context_ref)) {
1919
if (alpp_was_null) {
1920
SGE_ADD_MSG_ID(sprintf(SGE_EVENT, MSG_GDI_GDI_ALREADY_SETUP));
1922
answer_list_add_sprintf(alpp, STATUS_EEXIST, ANSWER_QUALITY_WARNING,
1923
MSG_GDI_GDI_ALREADY_SETUP);
1925
DRETURN(AE_ALREADY_SETUP);
1927
ret = sge_setup2(context_ref, progid, thread_id, alpp, false);
1932
if ((*context_ref)->prepare_enroll(*context_ref) != CL_RETVAL_OK) {
1933
sge_gdi_ctx_class_get_errors(*context_ref, alpp, true);
1934
DRETURN(AE_QMASTER_DOWN);
1937
sge_gdi_ctx_set_is_setup(*context_ref, true);
1942
static int reresolve_qualified_hostname(sge_gdi_ctx_class_t *thiz) {
1943
char unique_hostname[CL_MAXHOSTLEN];
1944
sge_prog_state_class_t* prog_state = thiz->get_sge_prog_state(thiz);
1945
int ret = CL_RETVAL_OK;
1947
DENTER(TOP_LAYER, "gdi2_reresolve_qualified_hostname");
1949
ret=getuniquehostname(prog_state->get_qualified_hostname(prog_state), unique_hostname, 0);
1950
if( ret != CL_RETVAL_OK ) {
1953
prog_state->set_qualified_hostname(prog_state, unique_hostname);