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__*/
45
#include "sge_string.h"
48
#include "sge_uidgid.h"
49
#include "msg_utilib.h"
51
#if defined(__SunOS_5_7) || defined(__SunOS_5_8) || defined(__SunOS_5_9)
52
/* Redefinitions from S10+ sys/types.h */
54
/* Missing in SunOS < 10 */
55
static int unsetenv(const char *var) {
63
/* Redefinitions from libcontract.h */
64
typedef void *ct_stathdl_t;
66
/* Redefinitions from sys/contract.h */
67
#define CTD_COMMON 0 /* No additional detail */
68
#define CTD_FIXED 1 /* O(1) info */
69
#define CTD_ALL 2 /* O(n) info */
72
/* Redefinitions from sys/contract/process.h */
73
#define CT_PR_INHERIT 0x1 /* give contract to parent */
74
#define CT_PR_NOORPHAN 0x2 /* kill when contract is abandoned */
75
#define CT_PR_PGRPONLY 0x4 /* only kill process group on fatal errors */
76
#define CT_PR_REGENT 0x8 /* automatically detach inherited contracts */
77
#define CT_PR_ALLPARAM 0xf
79
#define CT_PR_EV_EMPTY 0x1 /* contract is empty */
80
#define CT_PR_EV_FORK 0x2 /* process was forked (and was added) */
81
#define CT_PR_EV_EXIT 0x4 /* process exited (and left contract) */
82
#define CT_PR_EV_CORE 0x8 /* process dumps core */
83
#define CT_PR_EV_SIGNAL 0x10 /* process received fatal signal */
84
#define CT_PR_EV_HWERR 0x20 /* process experienced uncorrectable error */
85
#define CT_PR_ALLEVENT 0x3f
86
#define CT_PR_ALLFATAL (CT_PR_EV_CORE | CT_PR_EV_SIGNAL | CT_PR_EV_HWERR)
88
/* Redefinitions from sys/ctfs.h */
89
#define CTFS_ROOT "/system/contract"
91
/* Redefinitions from libscf.h */
92
typedef struct scf_handle scf_handle_t;
93
typedef struct scf_simple_prop scf_simple_prop_t;
95
#define SMF_IMMEDIATE 0x1
96
#define SMF_TEMPORARY 0x2
97
#define SMF_AT_NEXT_BOOT 0x4
99
typedef enum scf_error {
100
SCF_ERROR_NONE = 1000, /* no error */
101
SCF_ERROR_NOT_BOUND, /* handle not bound */
102
SCF_ERROR_NOT_SET, /* cannot use unset argument */
103
SCF_ERROR_NOT_FOUND, /* nothing of that name found */
104
SCF_ERROR_TYPE_MISMATCH, /* type does not match value */
105
SCF_ERROR_IN_USE, /* cannot modify while in-use */
106
SCF_ERROR_CONNECTION_BROKEN, /* repository connection gone */
107
SCF_ERROR_INVALID_ARGUMENT, /* bad argument */
108
SCF_ERROR_NO_MEMORY, /* no memory available */
109
SCF_ERROR_CONSTRAINT_VIOLATED, /* required constraint not met */
110
SCF_ERROR_EXISTS, /* object already exists */
111
SCF_ERROR_NO_SERVER, /* repository server unavailable */
112
SCF_ERROR_NO_RESOURCES, /* server has insufficient resources */
113
SCF_ERROR_PERMISSION_DENIED, /* insufficient privileges for action */
114
SCF_ERROR_BACKEND_ACCESS, /* backend refused access */
115
SCF_ERROR_HANDLE_MISMATCH, /* mismatched SCF handles */
116
SCF_ERROR_HANDLE_DESTROYED, /* object bound to destroyed handle */
117
SCF_ERROR_VERSION_MISMATCH, /* incompatible SCF version */
118
SCF_ERROR_BACKEND_READONLY, /* backend is read-only */
119
SCF_ERROR_DELETED, /* object has been deleted */
121
SCF_ERROR_CALLBACK_FAILED = 1080, /* user callback function failed */
123
SCF_ERROR_INTERNAL = 1101 /* internal error */
127
/* Our new defines */
128
#define QMASTER_FMRI "svc:/application/sge/qmaster:"
129
#define SHADOWD_FMRI "svc:/application/sge/shadowd:"
130
#define EXECD_FMRI "svc:/application/sge/execd:"
132
static int libsLoaded = -1;
133
static int libscfLoaded = -1;
134
static int libcontractLoaded = -1;
135
static char *FMRI = NULL;
136
static int useSMF = -1;
138
pthread_once_t FMRIcontrol = PTHREAD_ONCE_INIT;
139
pthread_once_t useSMFcontrol = PTHREAD_ONCE_INIT;
140
pthread_once_t libscontrol = PTHREAD_ONCE_INIT;
141
pthread_once_t libscfcontrol = PTHREAD_ONCE_INIT;
142
pthread_once_t libcontractcontrol = PTHREAD_ONCE_INIT;
145
static void* scf_lib = NULL;
146
/* Used libscf function pointers */
147
static scf_error_t (*shared_scf_func__scf_error)(void);
148
static const char *(*shared_scf_func__scf_strerror)(scf_error_t);
149
static scf_simple_prop_t *(*shared_scf_func__scf_simple_prop_get)(scf_handle_t *handle,
150
const char *instance, const char *pgname, const char *propname);
151
static char *(*shared_scf_func__scf_simple_prop_next_astring)(scf_simple_prop_t *prop);
152
static void (*shared_scf_func__scf_simple_prop_free)(scf_simple_prop_t *prop);
153
static char *(*shared_scf_func__smf_get_state)(const char *fmri);
154
static int (*shared_scf_func__smf_disable_instance)(const char *fmri, int flag);
157
static void* contract_lib = NULL;
158
/* Used libcontract function pointers */
159
static int (*shared_contract_func__ct_tmpl_activate)(int ctfd);
160
static int (*shared_contract_func__ct_tmpl_clear)(int ctfd);
161
static int (*shared_contract_func__ct_tmpl_set_critical)(int ctfd, uint_t flag);
162
static int (*shared_contract_func__ct_tmpl_set_informative)(int ctfd, uint_t flag);
163
static int (*shared_contract_func__ct_ctl_abandon)(int ctfd);
164
static int (*shared_contract_func__ct_status_read)(int ctfd, int flag, ct_stathdl_t *st);
165
static void (*shared_contract_func__ct_status_free)(ct_stathdl_t st);
166
static ctid_t(*shared_contract_func__ct_status_get_id)(ct_stathdl_t st);
167
static int (*shared_contract_func__ct_pr_tmpl_set_fatal)(int ctfd, uint_t flag);
168
static int (*shared_contract_func__ct_pr_tmpl_set_param)(int ctfd, uint_t flag);
171
/************************** sge_init_lib() *************************************
173
* sge_init_lib() -- loads func_name symbols from shared library lib_name
174
* and stores the func_ptr
176
* static int sge_init_lib(void *lib_ptr,
178
* const char *func_name[],
179
* const void *func_ptr[])
182
* loads func_name symbols from shared lib lib_name and stores the func_ptr
185
* void *lib_ptr - pointer to the opened shared lib (dlopen())
186
* char *lib_name - name of the library (e.g: "libcontract.so")
187
* const char *func_name[] - array of library function names to be loaded
188
* const void *func_ptr[] - destination array for each function
196
* LOCAL helper function
200
* init_contract_lib()
201
*******************************************************************************/
202
static int sge_init_lib(void *lib_ptr, char *lib_name,
203
const char *func_name[], const void *func_ptr[])
207
DENTER(TOP_LAYER, "sge_init_lib");
209
if (lib_ptr == NULL) {
210
lib_ptr = dlopen(lib_name, RTLD_LAZY | RTLD_NODELETE);
211
if (lib_ptr != NULL) {
213
while (func_name[i] != NULL) {
214
*((int**)(func_ptr[i])) = (int*)dlsym(lib_ptr, func_name[i]);
216
if (*((int**)(func_ptr[i])) == NULL) {
217
DPRINTF(("%s: unable to initialize function %s\n",
218
"sge_init_lib", func_name[i]));
221
DPRINTF(("function "SFQ" successfully initialized\n",
228
DPRINTF(("Can't open %s library\n", lib_name));
238
/************************** init_scf_lib() *************************************
240
* init_scf_lib() -- initialize shared SCF library
243
* static void init_scf_lib(void)
246
* Stores the required SCF library functions to the appropriate function
256
* LOCAL helper function, to be called only in once_libscf_init() as
257
* pthread_once init function
261
*******************************************************************************/
262
static void init_scf_lib(void)
264
const char *func_name[] = {
267
"scf_simple_prop_get",
268
"scf_simple_prop_next_astring",
269
"scf_simple_prop_free",
271
"smf_disable_instance",
275
const void *func_ptr[] = {
276
&shared_scf_func__scf_error,
277
&shared_scf_func__scf_strerror,
278
&shared_scf_func__scf_simple_prop_get,
279
&shared_scf_func__scf_simple_prop_next_astring,
280
&shared_scf_func__scf_simple_prop_free,
281
&shared_scf_func__smf_get_state,
282
&shared_scf_func__smf_disable_instance,
286
DENTER(TOP_LAYER, "init_scf_lib");
287
if (sge_init_lib(scf_lib, "libscf.so", func_name, func_ptr) == 0) {
296
/********************** once_libscf_init() *************************************
298
* once_libscf_init() -- initialize shared SCF library
301
* static int once_libscf_init(void)
304
* Stores the required SCF library functions to the appropriate function
312
* 0 - libscf was not loaded (ERROR)
313
* 1 - libscf was loaded (SUCCESS)
316
* LOCAL helper function, to be called as pthread_once init function
319
* sge_smf_init_libs()
320
* sge_smf_temporary_disable_instance()
321
*******************************************************************************/
322
static int once_libscf_init(void)
324
DENTER(TOP_LAYER, "once_libscf_init");
325
/* Init scf lib ONCE */
326
if (pthread_once(&libscfcontrol, init_scf_lib) != 0) {
327
DPRINTF(("once_libscf_init() -> pthread_once call failed: useSMF=%d, libscf=%d, libcontract=%d\n",
328
useSMF, libscfLoaded, libcontractLoaded));
331
DPRINTF(("once_libscf_init() -> useSMF=%d, libscf=%d, libcontract=%d\n",
332
useSMF, libscfLoaded, libcontractLoaded));
333
DRETURN((libscfLoaded == 1) ? 0 : 1);
337
/********************* init_contract_lib() *************************************
339
* init_contract_lib() -- initialize shared CONTRACT library
342
* static void init_contract_lib(void)
345
* Stores the required CONTRACT library functions to the appropriate function
355
* LOCAL helper function, to be called as pthread_once init function
358
* sge_smf_init_libs()
359
*******************************************************************************/
360
static void init_contract_lib(void)
362
const char *func_name[] = {
365
"ct_tmpl_set_critical",
366
"ct_tmpl_set_informative",
371
"ct_pr_tmpl_set_fatal",
372
"ct_pr_tmpl_set_param",
376
const void *func_ptr[] = {
377
&shared_contract_func__ct_tmpl_activate,
378
&shared_contract_func__ct_tmpl_clear,
379
&shared_contract_func__ct_tmpl_set_critical,
380
&shared_contract_func__ct_tmpl_set_informative,
381
&shared_contract_func__ct_ctl_abandon,
382
&shared_contract_func__ct_status_read,
383
&shared_contract_func__ct_status_free,
384
&shared_contract_func__ct_status_get_id,
385
&shared_contract_func__ct_pr_tmpl_set_fatal,
386
&shared_contract_func__ct_pr_tmpl_set_param,
390
DENTER(TOP_LAYER, "init_contract_lib");
391
if (sge_init_lib(contract_lib, "libcontract.so", func_name, func_ptr) == 0) {
392
libcontractLoaded = 1;
394
libcontractLoaded = 0;
400
/************************** init_scf_lib() *************************************
402
* init_smf_libs() -- initialize shared SCF library
405
* static void init_smf_libs(void)
408
* Stores the required SCF library functions to the appropriate function
418
* LOCAL helper function, to be called only in as pthread_once init function
421
* sge_smf_init_libs()
422
*******************************************************************************/
423
static void init_smf_libs(void)
425
DENTER(TOP_LAYER, "init_smf_libs");
426
/* Init shared libs ONCE */
428
pthread_once(&libcontractcontrol, init_contract_lib);
429
if (libscfLoaded && libcontractLoaded) {
438
/********************** sge_smf_init_libs() ************************************
440
* sge_smf_init_libs() -- initialize SCF and CONTRACT shared libraries
443
* int sge_smf_init_libs(void)
446
* Try once to initialize SCF and CONTRACT shared libraries
453
* 0 - loading was successful
454
* 1 - loading failed (ERROR)
457
* MT-NOTES: sge_smf_init_libs is MT-safe because it modifies once
458
* static variables (libsLoaded) and returns it's value next time
461
* sge_smf_init_libs()
462
* sge_smf_temporary_disable_instance()
463
*******************************************************************************/
464
int sge_smf_init_libs(void)
466
DENTER(TOP_LAYER, "sge_smf_init_libs");
467
/* Init shared libs ONCE */
468
pthread_once(&libscontrol, init_smf_libs);
469
DRETURN((libsLoaded == 1) ? 0 : 1);
473
/********************** is_valid_sge_fmri() ************************************
475
* sge_smf_init_libs() -- initialize SCF and CONTRACT shared libraries
478
* static int is_valid_sge_fmri(char *fmri)
481
* Checks if service's fmri starts with valid sge service name
484
* char* fmri - service fmri to be validated
488
* 0 - invalid fmri (ERROR)
489
* 1 - valid fmri (OK)
492
* LOCAL helper function
497
*******************************************************************************/
498
static int is_valid_sge_fmri(char *fmri)
500
DENTER(TOP_LAYER, "is_valid_sge_fmri");
503
if (strncmp(EXECD_FMRI, fmri, strlen(EXECD_FMRI)) == 0) {
506
/* Test for qmaster */
507
if (strncmp(QMASTER_FMRI, fmri, strlen(QMASTER_FMRI)) == 0) {
510
/* Test for shadowd */
511
if (strncmp(SHADOWD_FMRI, fmri, strlen(SHADOWD_FMRI)) == 0) {
517
/***************************** init_fmri() *************************************
519
* init_fmri() -- initialize shared SCF library
522
* static void init_fmri(void)
525
* Detects service FMRI if process was started over SMF and stores the name
526
* to static variable called FMRI.
535
* LOCAL helper function, to be called only in as pthread_once init function
539
*******************************************************************************/
540
static void init_fmri(void)
542
DENTER(TOP_LAYER, "init_fmri");
543
/* Will be set is started over SMF */
544
char *temp = getenv("SMF_FMRI");
545
/* We explicitly check the fmri for valid service names */
546
if (temp && is_valid_sge_fmri(temp)) {
547
FMRI = sge_strdup(NULL, temp);
548
DPRINTF(("init_fmri() - FMRI set to %s\n", (FMRI==NULL) ? "NULL" : FMRI));
554
/******************************* get_fmri() ************************************
556
* get_fmri() -- initialize fmri and return the value
559
* static char *get_fmri(void)
562
* Once initializes service fmri and always returns the initialized value.
569
* NULL - no FMRI, smf was/can not be used
570
* other - valid service fmri of this process
573
* LOCAL helper function
577
*******************************************************************************/
578
static char *get_fmri(void)
580
DENTER(TOP_LAYER, "get_fmri");
581
if (pthread_once(&FMRIcontrol, init_fmri) != 0) {
582
ERROR((SGE_EVENT, MSG_SMF_PTHREAD_ONCE_FAILED_S, "get_fmri()"));
584
DPRINTF(("get_fmri() -> useSMF=%d, FMRI=%s\n",
585
useSMF, (FMRI==NULL) ? "NULL" : FMRI));
590
/***************************** init_use_smf() **********************************
592
* init_use_smf() -- initialize useSMF variable
595
* static void init_use_smf(void)
598
* Initialize useSMF variable. Set to 1 only if system is SMF capable and
599
* process was started over SMF. 0 otherwise.
608
* LOCAL helper function, to be called only in as pthread_once init function
612
*******************************************************************************/
613
static void init_use_smf(void)
618
DENTER(TOP_LAYER, "init_use_smf");
620
if (get_fmri() == NULL) {
624
/* We check if we use SMF */
625
fd = open("/etc/svc/volatile/repository_door", O_RDONLY);
627
/* File does not exist - no SMF */
630
status = fstat(fd, &buff);
632
if (errno == ENOENT) {
633
/* File does not exist - no SMF */
636
ERROR((SGE_EVENT, "Repository stat call failed: %s", *strerror(errno)));
638
/* What now disable queues or just disable SMF ? */
641
/* USING SMF ONLY if having sge FMRI and repository_door is really a door */
642
useSMF = S_ISDOOR(buff.st_mode);
650
/*************************** sge_smf_used() ************************************
652
* sge_smf_used() -- once initialize useSMF ad return it's value
655
* int sge_smf_used(void)
658
* Once initialize useSMF ad return it's value
665
* 0 - smf is not being used
666
* 1 - smf is being used
669
* MT-NOTES: sge_smf_used is MT-safe because it modifies once
670
* static variables (useSMF) and returns it's value next time
673
* sge_smf_contract_fork()
674
*******************************************************************************/
675
int sge_smf_used(void)
677
DENTER(TOP_LAYER, "sge_smf_used");
678
if (pthread_once(&useSMFcontrol, init_use_smf) != 0) {
679
ERROR((SGE_EVENT, MSG_SMF_PTHREAD_ONCE_FAILED_S, "sge_smf_used()"));
681
DPRINTF(("sge_smf_used() -> useSMF=%d\n", useSMF));
686
/********************** contracts_pre_fork() ***********************************
688
* contracts_pre_fork() -- initialize contract template
691
* static int contracts_pre_fork(void)
694
* Initialize contract template
701
* -1 - contract template creation failed
702
* other - fd to the contract template
705
* LOCAL helper function
708
* sge_smf_contract_fork()
709
*******************************************************************************/
710
static int contracts_pre_fork(void)
715
DENTER(TOP_LAYER, "contracts_pre_fork");
717
fd = open64(CTFS_ROOT "/process/template", O_RDWR);
722
* Execd doesn't do anything with the new contract.
723
* Deliver no events, don't inherit, and allow it to be orphaned.
725
err |= shared_contract_func__ct_tmpl_set_critical(fd, 0);
726
err |= shared_contract_func__ct_tmpl_set_informative(fd, 0);
727
err |= shared_contract_func__ct_pr_tmpl_set_fatal(fd, CT_PR_EV_HWERR);
728
err |= shared_contract_func__ct_pr_tmpl_set_param(fd, CT_PR_PGRPONLY);
729
if (err || shared_contract_func__ct_tmpl_activate(fd)) {
737
/********************** contracts_post_fork() **********************************
739
* contracts_post_fork() -- close template, abandon new contract in parent
742
* static int contracts_post_fork(int ctfd,
748
* To be called after fork(). Close the contract templated created in
749
* contract_pre_fork(). In parent process we abandon the new contract.
752
* int ctfd - contract template fd
753
* int pid - result of fork()
754
* char *err_str - pointer for error message
755
* int err_length - max error message length
760
* -2 - contracts_post_fork() failed
761
* input pid otherwise
764
* LOCAL helper function
767
* sge_smf_contract_fork()
768
*******************************************************************************/
769
static int contracts_post_fork(int ctfd, int pid, char *err_str, int err_length)
771
char path[PATH_MAX]; /* PATH_MAX defined in limits.h */
775
DENTER(TOP_LAYER, "contracts_post_fork");
776
/* Clear active template, abandon latest contract. */
780
shared_contract_func__ct_tmpl_clear(ctfd);
783
/* We modify the child env not to contain SMF vars (not part of the service) */
784
unsetenv("SMF_FMRI");
785
unsetenv("SMF_METHOD");
786
unsetenv("SMF_RESTARTER");
788
} else if (pid < 0) {
791
/* Parent has to explicitly abandon the new contract */
792
if ((cfd = open64(CTFS_ROOT "/process/latest", O_RDONLY)) == -1) {
793
snprintf(err_str,err_length, MSG_SMF_CONTRACT_CREATE_FAILED_S,
797
if ((errno = shared_contract_func__ct_status_read(cfd, CTD_COMMON, &st)) != 0) {
798
snprintf(err_str, err_length, MSG_SMF_CONTRACT_CREATE_FAILED_S,
803
latest = shared_contract_func__ct_status_get_id(st);
804
shared_contract_func__ct_status_free(st);
806
n = snprintf(path, PATH_MAX, CTFS_ROOT "/all/%ld/ctl", latest);
808
snprintf(err_str, err_length, MSG_SMF_CONTRACT_CONTROL_OPEN_FAILED_S,
809
*strerror(ENAMETOOLONG));
812
if ((cfd = open64(path, O_WRONLY)) == -1) {
813
snprintf(err_str, err_length, MSG_SMF_CONTRACT_CONTROL_OPEN_FAILED_S,
817
if (shared_contract_func__ct_ctl_abandon(cfd)) {
818
snprintf(err_str, err_length, MSG_SMF_CONTRACT_ABANDON_FAILED_US,
819
cfd, *strerror(errno));
828
/*************************** sge_smf_contract_fork() ***************************
830
* sge_smf_contract_fork() -- fork() with child in new contract
833
* int sge_smf_contract_fork(char *err_str, int err_length)
836
* Once initialize useSMF ad return it's value
839
* char *err_str - error message
840
* int err_length - max error message length
845
* -2 - contract_pre_fork failed
846
* -3 - contract_post_fork failed
847
* -4 - smflibs could not be loaded
848
* result of fork() otherwise
851
* MT-NOTES: sge_smf_contract_fork is not MT-safe
855
*******************************************************************************/
856
int sge_smf_contract_fork(char *err_str, int err_length)
860
DENTER(TOP_LAYER, "sge_smf_contract_fork");
862
if (sge_smf_used() == 0) {
864
DPRINTF(("normally forked %d\n", pid));
867
/* Check if shared libs were loaded */
868
if (libsLoaded == 0) {
869
snprintf(err_str, err_length, MSG_SMF_LOAD_LIB_FAILED);
872
/* Create new contract template */
873
ctfd = contracts_pre_fork();
875
/* Could not create new contract template */
876
snprintf(err_str, err_length, MSG_SMF_CONTRACT_CREATE_FAILED);
881
/* Dispose of the template and immediatelly abandon the contract */
882
pid = contracts_post_fork(ctfd, pid, err_str, err_length);
884
/* post_fork failed */
887
DPRINTF(("contract forked %d\n", pid));
894
/******************** sge_smf_temporary_disable_instance() *********************
896
* sge_smf_temporary_disable_instance() -- temporary disable smf instance
899
* void sge_smf_temporary_disable_instance(void)
902
* Temporary disable this service instance in smf
911
* Can be called only if sge_smf_used() return 1 and sge_smf_used() was
914
* MT-NOTES: sge_smf_temporary_disable_instance is MT-safe because it
915
* modifies once static variables (libscfLoaded)
919
* execd/execd_exit_func()
920
*******************************************************************************/
921
void sge_smf_temporary_disable_instance(void)
923
uid_t old_euid = NULL;
925
DENTER(TOP_LAYER, "sge_smf_temporary_disable_instance");
926
if (once_libscf_init() != 0) {
927
ERROR((SGE_EVENT, MSG_SMF_LOAD_LIBSCF_FAILED_S, "sge_smf_temporary_disable_instance()"));
930
/* We need to be root */
931
if (!sge_is_start_user_superuser()) {
934
old_euid = geteuid();
935
seteuid(SGE_SUPERUSER_UID);
937
int ret = shared_scf_func__smf_disable_instance(FMRI, SMF_TEMPORARY);
938
if (change_user == 1) {
942
ERROR((SGE_EVENT, MSG_SMF_DISABLE_FAILED_SSUU,
943
FMRI,shared_scf_func__scf_strerror(shared_scf_func__scf_error()), geteuid(), getuid()));
946
DPRINTF(("Service %s temporary disabled.\n", FMRI));
951
/******************** sge_smf_get_instance_state() *****************************
953
* sge_smf_get_instance_state() -- get instance state
956
* char *sge_smf_get_instance_state(void)
959
* Get this instance state from SMF.
968
* MT-NOTES: sge_smf_get_instance_state is MT-safe
971
* sge_smf_get_instance_next_state()
972
*******************************************************************************/
973
char *sge_smf_get_instance_state(void) {
974
return shared_scf_func__smf_get_state(FMRI);
978
/******************** sge_smf_get_instance_next_state() ***********************
980
* sge_smf_get_instance_next_state() -- get instance state
983
* char *sge_smf_get_instance_next_state(void)
986
* Get this instance state from SMF.
995
* MT-NOTES: sge_smf_get_instance_state is MT-safe
998
* sge_smf_get_instance_next_state()
999
*******************************************************************************/
1000
char *sge_smf_get_instance_next_state()
1002
scf_simple_prop_t *prop;
1003
const char *state_str;
1006
DENTER(TOP_LAYER, "sge_smf_get_instance_next_state");
1008
if ((prop = shared_scf_func__scf_simple_prop_get(NULL, FMRI, SCF_PG_RESTARTER, SCF_PROPERTY_NEXT_STATE)) == NULL) {
1012
if ((state_str = shared_scf_func__scf_simple_prop_next_astring(prop)) == NULL) {
1013
shared_scf_func__scf_simple_prop_free(prop);
1017
if ((ret = strdup(state_str)) == NULL) {
1018
ERROR((SGE_EVENT, "Out of memory"));
1022
shared_scf_func__scf_simple_prop_free(prop);
1029
/* Just a dummy function */