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__*/
35
#include "sge_string.h"
38
#include "cull_list.h"
39
#include "sge_answer.h"
41
#include "sge_hostname.h"
43
#include "sge_hgroup.h"
46
#include "sge_cuser.h"
47
#include "sge_object.h"
49
#include "msg_common.h"
50
#include "msg_sgeobjlib.h"
52
#define CUSER_LAYER TOP_LAYER
54
#ifndef __SGE_NO_USERMAPPING__
56
/* EB: ADOC: add comments */
59
cuser_create(lList **answer_list, const char *cluster_user, lList *remote_user)
61
lListElem *ret = NULL;
63
DENTER(CUSER_LAYER, "cuser_create");
64
if (cluster_user != NULL) {
65
ret = lCreateElem(CU_Type);
68
lSetString(ret, CU_name, cluster_user);
69
lSetList(ret, CU_ruser_list, remote_user);
71
SGE_ADD_MSG_ID(sprintf(SGE_EVENT,
72
MSG_MEM_MEMORYALLOCFAILED_S, SGE_FUNC));
73
answer_list_add(answer_list, SGE_EVENT,
74
STATUS_EMALLOC, ANSWER_QUALITY_ERROR);
82
const char **remote_user pointer to NULL pointer
83
don't free this pointer
86
cuser_get_remote_user(const lListElem *this_elem, lList **answer_list,
87
const char *hostname, const char **remote_user)
91
DENTER(CUSER_LAYER, "cuser_get_remote_user");
93
if (this_elem != NULL && hostname != NULL && remote_user != NULL) {
94
lList *attr_list = NULL;
96
attr_list = lGetList(this_elem, CU_ruser_list);
97
if (attr_list != NULL) {
98
bool is_ambiguous = false;
99
const char *matching_host_or_group = NULL;
100
const char *matching_group = NULL;
102
ret &= str_attr_list_find_value(attr_list, answer_list,
103
hostname, remote_user,
104
&matching_host_or_group,
108
SGE_ADD_MSG_ID(sprintf(SGE_EVENT,
109
MSG_CUSER_NOREMOTE_USER_S, "remote_user"));
110
answer_list_add(answer_list, SGE_EVENT,
111
STATUS_ERROR1, ANSWER_QUALITY_ERROR);
115
SGE_ADD_MSG_ID(sprintf(SGE_EVENT, MSG_INAVLID_PARAMETER_IN_S, SGE_FUNC));
116
answer_list_add(answer_list, SGE_EVENT,
117
STATUS_ERROR1, ANSWER_QUALITY_ERROR);
125
cuser_is_hgroup_referenced(const lListElem *this_elem,
126
const lListElem *hgroup)
130
DENTER(CUSER_LAYER, "cuser_is_hgroup_referenced");
131
if (this_elem != NULL && hgroup != NULL) {
132
const char *name = lGetHost(hgroup, HGRP_name);
133
lList *attr_list = lGetList(this_elem, CU_ruser_list);
134
lListElem *attr = str_attr_list_locate(attr_list, name);
145
cuser_list_find_hgroup_references(const lList *this_list,
147
const lListElem *hgroup,
153
DENTER(CUSER_LAYER, "cuser_find_hgroup_references");
154
if (this_list != NULL && hgroup != NULL && string_list != NULL) {
155
for_each(cuser, this_list) {
156
if (cuser_is_hgroup_referenced(cuser, hgroup)) {
157
const char *name = lGetString(cuser, CU_name);
159
lAddElemStr(string_list, ST_name, name, ST_Type);
168
cuser_list_get_master_list(void)
170
/* depending on the setting, we want to return the local thread setting and
171
not the global master list. The object_type_get_master_list_mt knows, which
173
return object_type_get_master_list(SGE_TYPE_CUSER);
177
cuser_list_locate(const lList *this_list, const char *cluster_user)
179
lListElem *ret = NULL;
181
DENTER(CUSER_LAYER, "cuser_list_locate");
182
if (this_list != NULL && cluster_user != NULL) {
183
ret = lGetElemStr(this_list, CU_name, cluster_user);
190
cuser_list_map_user(const lList *this_list, lList **answer_list,
191
const char *cluster_user, const char *hostname,
192
const char **remote_user)
196
DENTER(CUSER_LAYER, "cuser_list_map_user");
197
if (cluster_user != NULL && hostname != NULL && remote_user != NULL) {
198
lListElem *cuser = cuser_list_locate(this_list, cluster_user);
201
ret &= cuser_get_remote_user(cuser, answer_list,
202
hostname, remote_user);
204
/* No user mapping entry defined for this object */
205
*remote_user = cluster_user;
208
SGE_ADD_MSG_ID(sprintf(SGE_EVENT, MSG_INAVLID_PARAMETER_IN_S, SGE_FUNC));
209
answer_list_add(answer_list, SGE_EVENT,
210
STATUS_ERROR1, ANSWER_QUALITY_ERROR);