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__*/
38
#include "sge_manop_qmaster.h"
39
#include "sge_event_master.h"
41
#include "sge_uidgid.h"
42
#include "sge_answer.h"
43
#include "sge_manop.h"
45
#include "sge_persistence_qmaster.h"
46
#include "spool/sge_spooling.h"
48
#include "msg_common.h"
49
#include "msg_qmaster.h"
51
/* ------------------------------------------------------------
53
sge_add_manop() - adds an manop list to the global manager/operator
56
if the invoking process is the qmaster
57
the added manop list is spooled in the MANAGER_FILE/OPERATOR_FILE
61
sge_gdi_ctx_class_t *ctx,
66
u_long32 target /* may be SGE_MANAGER_LIST or SGE_OPERATOR_LIST */
68
const char *manop_name;
69
const char *object_name;
75
ev_event eve = sgeE_EVENTSIZE;
77
DENTER(TOP_LAYER, "sge_add_manop");
79
if ( !ep || !ruser || !rhost ) {
80
CRITICAL((SGE_EVENT, MSG_SGETEXT_NULLPTRPASSED_S, SGE_FUNC));
81
answer_list_add(alpp, SGE_EVENT, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR);
83
return STATUS_EUNKNOWN;
87
case SGE_MANAGER_LIST:
88
lpp = object_type_get_master_list(SGE_TYPE_MANAGER);
89
object_name = MSG_OBJ_MANAGER;
92
eve = sgeE_MANAGER_ADD;
94
case SGE_OPERATOR_LIST:
95
lpp = object_type_get_master_list(SGE_TYPE_OPERATOR);
96
object_name = MSG_OBJ_OPERATOR;
99
eve = sgeE_OPERATOR_ADD;
102
DPRINTF(("unknown target passed to %s\n", SGE_FUNC));
104
return STATUS_EUNKNOWN;
107
/* ep is no acl element, if ep has no UM_name/UO_name */
108
if ((pos = lGetPosViaElem(ep, key, SGE_NO_ABORT)) < 0) {
109
CRITICAL((SGE_EVENT, MSG_SGETEXT_MISSINGCULLFIELD_SS,
110
lNm2Str(key), SGE_FUNC));
111
answer_list_add(alpp, SGE_EVENT, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR);
113
return STATUS_EUNKNOWN;
116
manop_name = lGetPosString(ep, pos);
118
CRITICAL((SGE_EVENT, MSG_SGETEXT_NULLPTRPASSED_S, SGE_FUNC));
119
answer_list_add(alpp, SGE_EVENT, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR);
121
return STATUS_EUNKNOWN;
124
if (lGetElemStr(*lpp, key, manop_name)) {
125
ERROR((SGE_EVENT, MSG_SGETEXT_ALREADYEXISTS_SS, object_name, manop_name));
126
answer_list_add(alpp, SGE_EVENT, STATUS_EEXIST, ANSWER_QUALITY_ERROR);
128
return STATUS_EEXIST;
131
/* update in interal lists */
132
added = lAddElemStr(lpp, key, manop_name, descr);
135
if(!sge_event_spool(ctx, alpp, 0, eve,
136
0, 0, manop_name, NULL, NULL,
137
added, NULL, NULL, true, true)) {
138
ERROR((SGE_EVENT, MSG_CANTSPOOL_SS, object_name, manop_name));
139
answer_list_add(alpp, SGE_EVENT, STATUS_EDISK, ANSWER_QUALITY_ERROR);
141
/* remove element from list */
142
lRemoveElem(*lpp, &added);
148
INFO((SGE_EVENT, MSG_SGETEXT_ADDEDTOLIST_SSSS,
149
ruser, rhost, manop_name, object_name));
150
answer_list_add(alpp, SGE_EVENT, STATUS_OK, ANSWER_QUALITY_INFO);
155
/* ------------------------------------------------------------
157
sge_del_manop() - deletes an access list from the global acl_list
161
sge_gdi_ctx_class_t *ctx,
166
u_long32 target /* may be SGE_MANAGER_LIST or SGE_OPERATOR_LIST */
170
const char *manop_name;
171
const char *object_name;
174
ev_event eve = sgeE_EVENTSIZE;
177
DENTER(TOP_LAYER, "sge_del_manop");
179
if ( !ep || !ruser || !rhost ) {
180
CRITICAL((SGE_EVENT, MSG_SGETEXT_NULLPTRPASSED_S, SGE_FUNC));
181
answer_list_add(alpp, SGE_EVENT, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR);
183
return STATUS_EUNKNOWN;
187
case SGE_MANAGER_LIST:
188
lpp = object_type_get_master_list(SGE_TYPE_MANAGER);
189
object_name = MSG_OBJ_MANAGER;
191
eve = sgeE_MANAGER_DEL;
193
case SGE_OPERATOR_LIST:
194
lpp = object_type_get_master_list(SGE_TYPE_OPERATOR);
195
object_name = MSG_OBJ_OPERATOR;
197
eve = sgeE_OPERATOR_DEL;
200
DPRINTF(("unknown target passed to %s\n", SGE_FUNC));
202
return STATUS_EUNKNOWN;
205
/* ep is no manop element, if ep has no UM_name/UO_name */
206
if ((pos = lGetPosViaElem(ep, key, SGE_NO_ABORT)) < 0) {
207
CRITICAL((SGE_EVENT, MSG_SGETEXT_MISSINGCULLFIELD_SS,
208
lNm2Str(key), SGE_FUNC));
209
answer_list_add(alpp, SGE_EVENT, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR);
211
return STATUS_EUNKNOWN;
214
manop_name = lGetPosString(ep, pos);
216
CRITICAL((SGE_EVENT, MSG_SGETEXT_NULLPTRPASSED_S, SGE_FUNC));
217
answer_list_add(alpp, SGE_EVENT, STATUS_EUNKNOWN, ANSWER_QUALITY_ERROR);
219
return STATUS_EUNKNOWN;
222
/* prevent removing of root from man/op-list */
223
if (!strcmp(manop_name, "root")) {
224
ERROR((SGE_EVENT, MSG_SGETEXT_MAY_NOT_REMOVE_USER_FROM_LIST_SS, "root", object_name));
225
answer_list_add(alpp, SGE_EVENT, STATUS_EEXIST, ANSWER_QUALITY_ERROR);
227
return STATUS_EEXIST;
230
found = lGetElemStr(*lpp, key, manop_name);
232
ERROR((SGE_EVENT, MSG_SGETEXT_DOESNOTEXIST_SS, object_name, manop_name));
233
answer_list_add(alpp, SGE_EVENT, STATUS_EEXIST, ANSWER_QUALITY_ERROR);
235
return STATUS_EEXIST;
238
lDechainElem(*lpp, found);
241
if (!sge_event_spool(ctx, alpp, 0, eve,
242
0, 0, manop_name, NULL, NULL,
243
NULL, NULL, NULL, true, true)) {
244
ERROR((SGE_EVENT, MSG_CANTSPOOL_SS, object_name, manop_name));
245
answer_list_add(alpp, SGE_EVENT, STATUS_EDISK, ANSWER_QUALITY_ERROR);
248
lAppendElem(*lpp, found);
255
INFO((SGE_EVENT, MSG_SGETEXT_REMOVEDFROMLIST_SSSS,
256
ruser, rhost, manop_name, object_name));
257
answer_list_add(alpp, SGE_EVENT, STATUS_OK, ANSWER_QUALITY_INFO);