b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States/*
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * CDDL HEADER START
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States *
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * The contents of this file are subject to the terms of the
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * Common Development and Distribution License (the "License").
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * You may not use this file except in compliance with the License.
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States *
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * or http://www.opensolaris.org/os/licensing.
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * See the License for the specific language governing permissions
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * and limitations under the License.
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States *
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * When distributing Covered Code, include this CDDL HEADER in each
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * If applicable, add the following below this CDDL HEADER, with the
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * fields enclosed by brackets "[]" replaced with your own identifying
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * information: Portions Copyright [yyyy] [name of copyright owner]
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States *
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * CDDL HEADER END
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States */
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States/*
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States/*
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * Service Control Services (SVCCTL) RPC interface definition.
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * This interface provides remote access to list SMF services
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * from a Windows client.
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States *
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * SVCCTL access is restricted to administrators: members of the
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * Domain Admins or Administrators groups.
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States */
8d7e41661dc4633488e93b13363137523ce59977jose borrego
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States#include <stdio.h>
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States#include <strings.h>
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright#include <smbsrv/libsmb.h>
148c5f43199ca0b43fc8e3b643aab11cd66ea327Alan Wright#include <smbsrv/libmlsvc.h>
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States#include <smbsrv/nmpipes.h>
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh#include <smbsrv/ntifs.h>
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown#include <smbsrv/winsvc.h>
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown#include <smbsrv/ndl/svcctl.ndl>
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown#include <smbsrv/libmlsvc.h>
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh#define SVCCTL_SECURITY_BUFSIZE 256
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh#define SVCCTL_ENUMSERVICES_MINBUFSIZE 1024
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States#define SVCCTL_OPENSVC_OP_UNIMPLEMENTED(S) \
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ((S) & SERVICE_CHANGE_CONFIG) || \
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ((S) & SERVICE_PAUSE_CONTINUE) || \
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ((S) & SERVICE_START) || \
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ((S) & SERVICE_STOP) || \
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ((S) & SERVICE_ENUMERATE_DEPENDENTS)
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desaitypedef union {
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai uint8_t *svc_buf;
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai svc_description_t *svc_desc;
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai svc_failure_actions_t *svc_fac;
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai svc_delayed_auto_start_t *svc_dstart;
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai svc_config_failure_action_t *svc_cfa;
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai} svc_config_rsp_t;
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai
8d7e41661dc4633488e93b13363137523ce59977jose borregostatic int svcctl_s_Close(void *, ndr_xa_t *);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintoshstatic int svcctl_s_ControlService(void *, ndr_xa_t *);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintoshstatic int svcctl_s_DeleteService(void *, ndr_xa_t *);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintoshstatic int svcctl_s_QueryServiceSecurity(void *, ndr_xa_t *);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintoshstatic int svcctl_s_SetServiceSecurity(void *, ndr_xa_t *);
8d7e41661dc4633488e93b13363137523ce59977jose borregostatic int svcctl_s_OpenManager(void *, ndr_xa_t *);
8d7e41661dc4633488e93b13363137523ce59977jose borregostatic int svcctl_s_OpenService(void *, ndr_xa_t *);
8d7e41661dc4633488e93b13363137523ce59977jose borregostatic int svcctl_s_QueryServiceStatus(void *, ndr_xa_t *);
8d7e41661dc4633488e93b13363137523ce59977jose borregostatic int svcctl_s_QueryServiceConfig(void *, ndr_xa_t *);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintoshstatic int svcctl_s_StartService(void *, ndr_xa_t *);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintoshstatic int svcctl_s_EnumDependentServices(void *, ndr_xa_t *);
8d7e41661dc4633488e93b13363137523ce59977jose borregostatic int svcctl_s_EnumServicesStatus(void *, ndr_xa_t *);
8d7e41661dc4633488e93b13363137523ce59977jose borregostatic int svcctl_s_GetServiceDisplayNameW(void *, ndr_xa_t *);
8d7e41661dc4633488e93b13363137523ce59977jose borregostatic int svcctl_s_GetServiceKeyNameW(void *, ndr_xa_t *);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintoshstatic int svcctl_s_OpenSCManagerA(void *, ndr_xa_t *);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintoshstatic int svcctl_s_OpenServiceA(void *, ndr_xa_t *);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintoshstatic int svcctl_s_EnumServicesStatusA(void *, ndr_xa_t *);
8d7e41661dc4633488e93b13363137523ce59977jose borregostatic int svcctl_s_QueryServiceConfig2W(void *, ndr_xa_t *);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintoshstatic int svcctl_s_QueryServiceStatusEx(void *, ndr_xa_t *);
8d7e41661dc4633488e93b13363137523ce59977jose borrego
8d7e41661dc4633488e93b13363137523ce59977jose borregostatic ndr_stub_table_t svcctl_stub_table[] = {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States { svcctl_s_Close, SVCCTL_OPNUM_Close },
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh { svcctl_s_ControlService, SVCCTL_OPNUM_ControlService },
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh { svcctl_s_DeleteService, SVCCTL_OPNUM_DeleteService },
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh { svcctl_s_QueryServiceSecurity, SVCCTL_OPNUM_QueryServiceSecurity },
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh { svcctl_s_SetServiceSecurity, SVCCTL_OPNUM_SetServiceSecurity },
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States { svcctl_s_OpenManager, SVCCTL_OPNUM_OpenManager },
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States { svcctl_s_OpenService, SVCCTL_OPNUM_OpenService },
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States { svcctl_s_QueryServiceStatus, SVCCTL_OPNUM_QueryServiceStatus },
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States { svcctl_s_QueryServiceConfig, SVCCTL_OPNUM_QueryServiceConfig },
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh { svcctl_s_StartService, SVCCTL_OPNUM_StartService },
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh { svcctl_s_EnumDependentServices,
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh SVCCTL_OPNUM_EnumDependentServices },
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States { svcctl_s_EnumServicesStatus, SVCCTL_OPNUM_EnumServicesStatus },
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States { svcctl_s_GetServiceDisplayNameW,
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States SVCCTL_OPNUM_GetServiceDisplayNameW },
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States { svcctl_s_GetServiceKeyNameW, SVCCTL_OPNUM_GetServiceKeyNameW },
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh { svcctl_s_OpenSCManagerA, SVCCTL_OPNUM_OpenSCManagerA },
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh { svcctl_s_OpenServiceA, SVCCTL_OPNUM_OpenServiceA },
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh { svcctl_s_EnumServicesStatusA, SVCCTL_OPNUM_EnumServicesStatusA },
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States { svcctl_s_QueryServiceConfig2W, SVCCTL_OPNUM_QueryServiceConfig2W },
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh { svcctl_s_QueryServiceStatusEx, SVCCTL_OPNUM_QueryServiceStatusEx },
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States {0}
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States};
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
8d7e41661dc4633488e93b13363137523ce59977jose borregostatic ndr_service_t svcctl_service = {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States "SVCCTL", /* name */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States "Service Control Services", /* desc */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States "\\svcctl", /* endpoint */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States PIPE_NTSVCS, /* sec_addr_port */
8d7e41661dc4633488e93b13363137523ce59977jose borrego "367abb81-9844-35f1-ad32-98f038001003", 2, /* abstract */
8d7e41661dc4633488e93b13363137523ce59977jose borrego NDR_TRANSFER_SYNTAX_UUID, 2, /* transfer */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States 0, /* no bind_instance_size */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States 0, /* no bind_req() */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States 0, /* no unbind_and_close() */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States 0, /* use generic_call_stub() */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States &TYPEINFO(svcctl_interface), /* interface ti */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svcctl_stub_table /* stub_table */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States};
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States/*
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * svcctl_initialize
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States *
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * This function registers the SVCCTL RPC interface with the RPC runtime
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * library. It must be called in order to use either the client side
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * or the server side functions.
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United Statesvoid
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United Statessvcctl_initialize(void)
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States{
8d7e41661dc4633488e93b13363137523ce59977jose borrego (void) ndr_svc_register(&svcctl_service);
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown svcctl_init();
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown}
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brownvoid
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brownsvcctl_finalize(void)
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown{
1fcced4c370617db71610fecffd5451a5894ca5eJordan Brown svcctl_fini();
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States}
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States/*
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * svcctl_hdlookup
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States *
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * Handle lookup wrapper to validate the local service and/or manager context.
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United Statesstatic ndr_handle_t *
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United Statessvcctl_hdlookup(ndr_xa_t *mxa, ndr_hdid_t *id, svcctl_context_type_t type)
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States{
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ndr_handle_t *hd;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svcctl_context_t *ctx;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if ((hd = ndr_hdlookup(mxa, id)) == NULL)
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States return (NULL);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if ((ctx = (svcctl_context_t *)hd->nh_data) == NULL)
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States return (NULL);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if ((ctx->c_type != type) || (ctx->c_ctx.uc_cp == NULL))
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States return (NULL);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States return (hd);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States}
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States/*
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * svcctl_hdfree
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States *
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * Handle deallocation wrapper to free the local service and/or manager context.
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United Statesstatic void
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United Statessvcctl_hdfree(ndr_xa_t *mxa, ndr_hdid_t *id)
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States{
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ndr_handle_t *hd;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svcctl_context_t *ctx;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svcctl_manager_context_t *mgr_ctx;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svcctl_service_context_t *svc_ctx;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if ((hd = ndr_hdlookup(mxa, id)) != NULL) {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ctx = (svcctl_context_t *)hd->nh_data;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States switch (ctx->c_type) {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States case SVCCTL_MANAGER_CONTEXT:
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States mgr_ctx = ctx->c_ctx.uc_mgr;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svcctl_scm_fini(mgr_ctx);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svcctl_scm_scf_handle_fini(mgr_ctx);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States free(mgr_ctx);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States break;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States case SVCCTL_SERVICE_CONTEXT:
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svc_ctx = ctx->c_ctx.uc_svc;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States free(svc_ctx->sc_mgrid);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States free(svc_ctx->sc_svcname);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States free(svc_ctx);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States break;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States default:
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States break;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States free(ctx);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ndr_hdfree(mxa, id);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States}
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States/*
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * svcctl_mgr_hdalloc
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States *
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * Handle allocation wrapper to setup the local manager context.
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United Statesstatic ndr_hdid_t *
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United Statessvcctl_mgr_hdalloc(ndr_xa_t *mxa)
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States{
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svcctl_context_t *ctx;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svcctl_manager_context_t *mgr_ctx;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if ((ctx = malloc(sizeof (svcctl_context_t))) == NULL)
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States return (NULL);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ctx->c_type = SVCCTL_MANAGER_CONTEXT;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if ((mgr_ctx = malloc(sizeof (svcctl_manager_context_t))) == NULL) {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States free(ctx);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States return (NULL);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States bzero(mgr_ctx, sizeof (svcctl_manager_context_t));
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if (svcctl_scm_scf_handle_init(mgr_ctx) < 0) {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States free(mgr_ctx);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States free(ctx);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States return (NULL);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if (svcctl_scm_init(mgr_ctx) < 0) {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svcctl_scm_scf_handle_fini(mgr_ctx);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States free(mgr_ctx);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States free(ctx);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States return (NULL);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ctx->c_ctx.uc_mgr = mgr_ctx;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States return (ndr_hdalloc(mxa, ctx));
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States}
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States/*
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * svcctl_get_mgr_ctx
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States *
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * This function looks up a reference to local manager context.
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United Statesstatic svcctl_manager_context_t *
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United Statessvcctl_get_mgr_ctx(ndr_xa_t *mxa, ndr_hdid_t *mgr_id)
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States{
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ndr_handle_t *hd;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svcctl_manager_context_t *mgr_ctx;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States hd = svcctl_hdlookup(mxa, mgr_id, SVCCTL_MANAGER_CONTEXT);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if (hd == NULL)
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States return (NULL);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States mgr_ctx = ((svcctl_context_t *)hd->nh_data)->c_ctx.uc_mgr;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States return (mgr_ctx);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States}
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States/*
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * svcctl_svc_hdalloc
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States *
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * Handle allocation wrapper to setup the local service context.
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United Statesstatic ndr_hdid_t *
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United Statessvcctl_svc_hdalloc(ndr_xa_t *mxa, ndr_hdid_t *mgr_id, char *svc_name)
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States{
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svcctl_context_t *ctx;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svcctl_service_context_t *svc_ctx;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svcctl_manager_context_t *mgr_ctx;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States int max_name_sz = 0;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States char *svcname;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States mgr_ctx = svcctl_get_mgr_ctx(mxa, mgr_id);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if (mgr_ctx == NULL)
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States return (NULL);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States max_name_sz = mgr_ctx->mc_scf_max_fmri_len;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if ((ctx = malloc(sizeof (svcctl_context_t))) == NULL) {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svcctl_hdfree(mxa, mgr_id);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States return (NULL);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ctx->c_type = SVCCTL_SERVICE_CONTEXT;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if ((svc_ctx = malloc(sizeof (svcctl_service_context_t))) == NULL) {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svcctl_hdfree(mxa, mgr_id);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States free(ctx);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States return (NULL);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States bzero(svc_ctx, sizeof (svcctl_service_context_t));
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svc_ctx->sc_mgrid = malloc(sizeof (ndr_hdid_t));
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svcname = malloc(max_name_sz);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if ((svc_ctx->sc_mgrid == NULL) || (svcname == NULL)) {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States free(svc_ctx->sc_mgrid);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States free(svc_ctx);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svcctl_hdfree(mxa, mgr_id);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States free(ctx);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States return (NULL);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svc_ctx->sc_svcname = svcname;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States bcopy(mgr_id, svc_ctx->sc_mgrid, sizeof (ndr_hdid_t));
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States (void) strlcpy(svc_ctx->sc_svcname, svc_name, max_name_sz);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ctx->c_ctx.uc_svc = svc_ctx;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States return (ndr_hdalloc(mxa, ctx));
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States}
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States/*
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * svcctl_s_Close
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States *
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * This is a request to close the SVCCTL interface specified by the
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * handle. Free the handle and zero out the result handle for the
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * client.
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States *
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * Returns:
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * ERROR_SUCCESS
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * ERROR_INVALID_HANDLE
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United Statesstatic int
8d7e41661dc4633488e93b13363137523ce59977jose borregosvcctl_s_Close(void *arg, ndr_xa_t *mxa)
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States{
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States struct svcctl_Close *param = arg;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ndr_hdid_t *id = (ndr_hdid_t *)&param->handle;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svcctl_hdfree(mxa, id);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States bzero(&param->result_handle, sizeof (svcctl_handle_t));
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->status = ERROR_SUCCESS;
8d7e41661dc4633488e93b13363137523ce59977jose borrego return (NDR_DRC_OK);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States}
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh/*
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh * svcctl_s_ControlService
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh */
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintoshstatic int
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintoshsvcctl_s_ControlService(void *arg, ndr_xa_t *mxa)
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh{
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh struct svcctl_ControlService *param = arg;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh ndr_hdid_t *id = (ndr_hdid_t *)&param->service_handle;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh ndr_handle_t *hd;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh svcctl_manager_context_t *mgr_ctx;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh svcctl_service_context_t *svc_ctx;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh svcctl_svc_node_t *svc;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh hd = svcctl_hdlookup(mxa, id, SVCCTL_SERVICE_CONTEXT);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if (hd == NULL) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh bzero(param, sizeof (struct svcctl_ControlService));
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->status = ERROR_INVALID_HANDLE;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh return (NDR_DRC_OK);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh }
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh svc_ctx = ((svcctl_context_t *)hd->nh_data)->c_ctx.uc_svc;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh mgr_ctx = svcctl_get_mgr_ctx(mxa, svc_ctx->sc_mgrid);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if (mgr_ctx == NULL) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh bzero(param, sizeof (struct svcctl_ControlService));
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->status = ERROR_INVALID_HANDLE;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh return (NDR_DRC_OK);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh }
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh switch (param->control) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh case SERVICE_CONTROL_STOP:
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh case SERVICE_CONTROL_PAUSE:
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh case SERVICE_CONTROL_CONTINUE:
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh case SERVICE_CONTROL_INTERROGATE:
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh case SERVICE_CONTROL_SHUTDOWN:
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh case SERVICE_CONTROL_PARAMCHANGE:
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh case SERVICE_CONTROL_NETBINDADD:
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh case SERVICE_CONTROL_NETBINDREMOVE:
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh case SERVICE_CONTROL_NETBINDENABLE:
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh case SERVICE_CONTROL_NETBINDDISABLE:
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh break;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh default:
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh bzero(param, sizeof (struct svcctl_ControlService));
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->status = ERROR_INVALID_PARAMETER;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh return (NDR_DRC_OK);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh }
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh svc = svcctl_scm_find_service(mgr_ctx, svc_ctx->sc_svcname);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if (svc == NULL || svc->sn_state == NULL) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh bzero(param, sizeof (struct svcctl_ControlService));
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->status = ERROR_SERVICE_DOES_NOT_EXIST;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh return (NDR_DRC_OK);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh }
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->service_status.service_type = SERVICE_WIN32_SHARE_PROCESS;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->service_status.cur_state = svcctl_scm_map_status(svc->sn_state);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->service_status.ctrl_accepted = 0;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->service_status.w32_exitcode = 0;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->service_status.svc_specified_exitcode = 0;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->service_status.check_point = 0;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->service_status.wait_hint = 0;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->status = ERROR_SUCCESS;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh return (NDR_DRC_OK);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh}
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh/*
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh * svcctl_s_DeleteService
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh */
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintoshstatic int
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintoshsvcctl_s_DeleteService(void *arg, ndr_xa_t *mxa)
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh{
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh struct svcctl_DeleteService *param = arg;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh ndr_hdid_t *id = (ndr_hdid_t *)&param->service_handle;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh ndr_handle_t *hd;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh hd = svcctl_hdlookup(mxa, id, SVCCTL_SERVICE_CONTEXT);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if (hd == NULL) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->status = ERROR_INVALID_HANDLE;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh return (NDR_DRC_OK);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh }
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->status = ERROR_SUCCESS;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh return (NDR_DRC_OK);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh}
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh/*
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh * svcctl_s_QueryServiceSecurity
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh */
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintoshstatic int
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintoshsvcctl_s_QueryServiceSecurity(void *arg, ndr_xa_t *mxa)
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh{
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh struct svcctl_QueryServiceSecurity *param = arg;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh ndr_hdid_t *id = (ndr_hdid_t *)&param->service_handle;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh ndr_handle_t *hd;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh uint32_t sec_info;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh uint32_t bytes_needed = 0;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh uint32_t status;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh hd = svcctl_hdlookup(mxa, id, SVCCTL_SERVICE_CONTEXT);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if (hd == NULL) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh status = ERROR_INVALID_HANDLE;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh goto query_service_security_error;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh }
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh sec_info = param->security_info & SMB_ALL_SECINFO;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if (sec_info == 0) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh status = ERROR_INVALID_PARAMETER;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh goto query_service_security_error;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh }
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if (param->buf_size < SVCCTL_SECURITY_BUFSIZE) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh bytes_needed = SVCCTL_SECURITY_BUFSIZE;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh status = ERROR_INSUFFICIENT_BUFFER;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh goto query_service_security_error;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh }
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->buffer = NDR_MALLOC(mxa, SVCCTL_SECURITY_BUFSIZE);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if (param->buffer == NULL) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh status = ERROR_NOT_ENOUGH_MEMORY;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh goto query_service_security_error;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh }
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh bzero(param->buffer, sizeof (SVCCTL_SECURITY_BUFSIZE));
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->buf_size = SVCCTL_SECURITY_BUFSIZE;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->bytes_needed = 0;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->status = ERROR_SUCCESS;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh return (NDR_DRC_OK);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintoshquery_service_security_error:
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh bzero(param, sizeof (struct svcctl_QueryServiceSecurity));
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->buf_size = 0;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->buffer = NDR_MALLOC(mxa, sizeof (uint32_t));
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->bytes_needed = bytes_needed;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->status = status;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh return (NDR_DRC_OK);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh}
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh/*
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh * svcctl_s_SetServiceSecurity
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh */
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintoshstatic int
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintoshsvcctl_s_SetServiceSecurity(void *arg, ndr_xa_t *mxa)
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh{
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh struct svcctl_SetServiceSecurity *param = arg;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh ndr_hdid_t *id = (ndr_hdid_t *)&param->service_handle;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh ndr_handle_t *hd;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh hd = svcctl_hdlookup(mxa, id, SVCCTL_SERVICE_CONTEXT);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if (hd == NULL) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->status = ERROR_INVALID_HANDLE;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh return (NDR_DRC_OK);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh }
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if ((param->security_info & SMB_ALL_SECINFO) == 0) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->status = ERROR_INVALID_PARAMETER;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh return (NDR_DRC_OK);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh }
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->status = ERROR_ACCESS_DENIED;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh return (NDR_DRC_OK);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh}
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States/*
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * svcctl_s_OpenManager
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States *
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * Request to open the service control manager.
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * The caller must have administrator rights in order to open this
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * interface. We don't support write (SC_MANAGER_LOCK) access.
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States *
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * Returns:
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * ERROR_SUCCESS
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * ERROR_ACCESS_DENIED
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States *
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * On success, returns a handle for use with subsequent svcctl requests.
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United Statesstatic int
8d7e41661dc4633488e93b13363137523ce59977jose borregosvcctl_s_OpenManager(void *arg, ndr_xa_t *mxa)
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States{
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States struct svcctl_OpenManager *param = arg;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ndr_hdid_t *id = NULL;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States int rc;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States rc = ndr_is_admin(mxa);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if ((rc == 0) || (param->desired_access & SC_MANAGER_LOCK) != 0) {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States bzero(&param->handle, sizeof (svcctl_handle_t));
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->status = ERROR_ACCESS_DENIED;
8d7e41661dc4633488e93b13363137523ce59977jose borrego return (NDR_DRC_OK);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States id = svcctl_mgr_hdalloc(mxa);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if (id) {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States bcopy(id, &param->handle, sizeof (svcctl_handle_t));
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->status = ERROR_SUCCESS;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States } else {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States bzero(&param->handle, sizeof (svcctl_handle_t));
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->status = ERROR_ACCESS_DENIED;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
8d7e41661dc4633488e93b13363137523ce59977jose borrego return (NDR_DRC_OK);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States}
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States/*
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * svcctl_s_OpenService
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States *
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * Return a handle for use with subsequent svcctl requests.
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States *
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * Returns:
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * ERROR_SUCCESS
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * ERROR_INVALID_HANDLE
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * ERROR_SERVICE_DOES_NOT_EXIST
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * ERROR_CALL_NOT_IMPLEMENTED
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United Statesstatic int
8d7e41661dc4633488e93b13363137523ce59977jose borregosvcctl_s_OpenService(void *arg, ndr_xa_t *mxa)
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States{
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States struct svcctl_OpenService *param = arg;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ndr_hdid_t *mgrid = (ndr_hdid_t *)&param->manager_handle;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ndr_hdid_t *id = NULL;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ndr_handle_t *hd;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States DWORD status;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svcctl_manager_context_t *mgr_ctx;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States char *svc_name = (char *)param->service_name;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States boolean_t unimplemented_operations = B_FALSE;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States /* Allow service handle allocations for only status & config queries */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States unimplemented_operations =
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States SVCCTL_OPENSVC_OP_UNIMPLEMENTED(param->desired_access);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if (unimplemented_operations) {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States bzero(&param->service_handle, sizeof (svcctl_handle_t));
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->status = ERROR_CALL_NOT_IMPLEMENTED;
8d7e41661dc4633488e93b13363137523ce59977jose borrego return (NDR_DRC_OK);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States hd = svcctl_hdlookup(mxa, mgrid, SVCCTL_MANAGER_CONTEXT);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if (hd == NULL) {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States bzero(&param->service_handle, sizeof (svcctl_handle_t));
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->status = ERROR_INVALID_HANDLE;
8d7e41661dc4633488e93b13363137523ce59977jose borrego return (NDR_DRC_OK);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States mgr_ctx = ((svcctl_context_t *)hd->nh_data)->c_ctx.uc_mgr;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States status = svcctl_scm_validate_service(mgr_ctx, svc_name);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if (status != ERROR_SUCCESS) {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States bzero(&param->service_handle, sizeof (svcctl_handle_t));
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->status = status;
8d7e41661dc4633488e93b13363137523ce59977jose borrego return (NDR_DRC_OK);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States id = svcctl_svc_hdalloc(mxa, mgrid, svc_name);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if (id) {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States bcopy(id, &param->service_handle, sizeof (svcctl_handle_t));
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->status = ERROR_SUCCESS;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States } else {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States bzero(&param->service_handle, sizeof (svcctl_handle_t));
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->status = ERROR_ACCESS_DENIED;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
8d7e41661dc4633488e93b13363137523ce59977jose borrego return (NDR_DRC_OK);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States}
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States/*
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * svcctl_s_QueryServiceStatus
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States *
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * Returns:
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * ERROR_SUCCESS
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * ERROR_INVALID_HANDLE
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United Statesstatic int
8d7e41661dc4633488e93b13363137523ce59977jose borregosvcctl_s_QueryServiceStatus(void *arg, ndr_xa_t *mxa)
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States{
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States struct svcctl_QueryServiceStatus *param = arg;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ndr_hdid_t *id = (ndr_hdid_t *)&param->service_handle;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ndr_handle_t *hd;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svcctl_manager_context_t *mgr_ctx;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svcctl_service_context_t *svc_ctx;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svcctl_svc_node_t *svc;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States hd = svcctl_hdlookup(mxa, id, SVCCTL_SERVICE_CONTEXT);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if (hd == NULL) {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States bzero(param, sizeof (struct svcctl_QueryServiceStatus));
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->status = ERROR_INVALID_HANDLE;
8d7e41661dc4633488e93b13363137523ce59977jose borrego return (NDR_DRC_OK);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svc_ctx = ((svcctl_context_t *)hd->nh_data)->c_ctx.uc_svc;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States mgr_ctx = svcctl_get_mgr_ctx(mxa, svc_ctx->sc_mgrid);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if (mgr_ctx == NULL) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh bzero(param, sizeof (struct svcctl_QueryServiceStatus));
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->status = ERROR_INVALID_HANDLE;
8d7e41661dc4633488e93b13363137523ce59977jose borrego return (NDR_DRC_OK);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svc = svcctl_scm_find_service(mgr_ctx, svc_ctx->sc_svcname);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if (svc == NULL || svc->sn_state == NULL) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh bzero(param, sizeof (struct svcctl_QueryServiceStatus));
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->status = ERROR_SERVICE_DOES_NOT_EXIST;
8d7e41661dc4633488e93b13363137523ce59977jose borrego return (NDR_DRC_OK);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->service_status.service_type = SERVICE_WIN32_SHARE_PROCESS;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->service_status.cur_state = svcctl_scm_map_status(svc->sn_state);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->service_status.ctrl_accepted = 0;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->service_status.w32_exitcode = 0;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->service_status.svc_specified_exitcode = 0;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->service_status.check_point = 0;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->service_status.wait_hint = 0;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->status = ERROR_SUCCESS;
8d7e41661dc4633488e93b13363137523ce59977jose borrego return (NDR_DRC_OK);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States}
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States/*
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh * svcctl_s_EnumDependentServices
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States *
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh * Enumerate the list of services that depend on the specified service.
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh */
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintoshstatic int
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintoshsvcctl_s_EnumDependentServices(void *arg, ndr_xa_t *mxa)
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh{
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh struct svcctl_EnumDependentServices *param = arg;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh ndr_hdid_t *id = (ndr_hdid_t *)&param->service_handle;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh ndr_handle_t *hd;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh svcctl_manager_context_t *mgr_ctx;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh svcctl_service_context_t *svc_ctx;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh svcctl_svc_node_t *svc;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh int input_bufsize = 0;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh uint32_t status;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh hd = svcctl_hdlookup(mxa, id, SVCCTL_SERVICE_CONTEXT);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if (hd == NULL) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh status = ERROR_INVALID_HANDLE;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh goto enum_dependent_services_error;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh }
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh svc_ctx = ((svcctl_context_t *)hd->nh_data)->c_ctx.uc_svc;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh mgr_ctx = svcctl_get_mgr_ctx(mxa, svc_ctx->sc_mgrid);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if (mgr_ctx == NULL) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh status = ERROR_INVALID_HANDLE;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh goto enum_dependent_services_error;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh }
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh svc = svcctl_scm_find_service(mgr_ctx, svc_ctx->sc_svcname);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if (svc == NULL || svc->sn_state == NULL) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh status = ERROR_SERVICE_DOES_NOT_EXIST;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh goto enum_dependent_services_error;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh }
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh switch (param->svc_state) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh case SERVICE_STOPPED:
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh case SERVICE_START_PENDING:
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh case SERVICE_STOP_PENDING:
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh case SERVICE_RUNNING:
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh case SERVICE_CONTINUE_PENDING:
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh case SERVICE_PAUSE_PENDING:
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh case SERVICE_PAUSED:
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh break;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh default:
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh status = ERROR_INVALID_PARAMETER;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh goto enum_dependent_services_error;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh }
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if ((input_bufsize = param->buf_size) == 0) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh bzero(param, sizeof (struct svcctl_EnumDependentServices));
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->buf_size = input_bufsize;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->services = NDR_STRDUP(mxa, "");
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->bytes_needed = 1024;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->svc_num = 0;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->status = ERROR_MORE_DATA;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh return (NDR_DRC_OK);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh }
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->services = NDR_MALLOC(mxa, input_bufsize);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if (param->services == NULL) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh status = ERROR_NOT_ENOUGH_MEMORY;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh goto enum_dependent_services_error;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh }
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh bzero(param->services, input_bufsize);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->buf_size = input_bufsize;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->bytes_needed = 0;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->svc_num = 0;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->status = ERROR_SUCCESS;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh return (NDR_DRC_OK);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintoshenum_dependent_services_error:
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh bzero(param, sizeof (struct svcctl_EnumDependentServices));
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->services = NDR_STRDUP(mxa, "");
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->status = status;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh return (NDR_DRC_OK);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh}
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh/*
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh * svcctl_s_EnumServicesStatus
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States *
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh * Enumerate the list of services we support.
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United Statesstatic int
8d7e41661dc4633488e93b13363137523ce59977jose borregosvcctl_s_EnumServicesStatus(void *arg, ndr_xa_t *mxa)
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States{
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States struct svcctl_EnumServicesStatus *param = arg;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ndr_hdid_t *id = (ndr_hdid_t *)&param->manager_handle;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ndr_handle_t *hd;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svcctl_manager_context_t *mgr_ctx;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh uint32_t buf_size = 0;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh uint32_t svc_num;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh uint32_t resume_handle = 0;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh uint32_t status;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if (param->resume_handle != NULL)
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh resume_handle = *param->resume_handle;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States hd = svcctl_hdlookup(mxa, id, SVCCTL_MANAGER_CONTEXT);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if (hd == NULL) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh status = ERROR_INVALID_HANDLE;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh goto enum_services_status_error;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States mgr_ctx = ((svcctl_context_t *)hd->nh_data)->c_ctx.uc_mgr;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if (svcctl_scm_refresh(mgr_ctx) != 0) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh status = ERROR_INVALID_HANDLE;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh goto enum_services_status_error;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh buf_size = param->buf_size;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->services = NDR_MALLOC(mxa, buf_size);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if (param->services == NULL) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh status = ERROR_NOT_ENOUGH_MEMORY;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh goto enum_services_status_error;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh bzero(param->services, buf_size);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if (buf_size < SVCCTL_ENUMSERVICES_MINBUFSIZE) {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->bytes_needed = mgr_ctx->mc_bytes_needed;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->svc_num = 0;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if (param->resume_handle)
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh *param->resume_handle = 0;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->status = ERROR_MORE_DATA;
8d7e41661dc4633488e93b13363137523ce59977jose borrego return (NDR_DRC_OK);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh svc_num = svcctl_scm_enum_services(mgr_ctx, param->services,
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh buf_size, &resume_handle, B_TRUE);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->buf_size = buf_size;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->svc_num = svc_num;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if (resume_handle != 0) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if (param->resume_handle != NULL)
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh *param->resume_handle = resume_handle;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->bytes_needed = mgr_ctx->mc_bytes_needed;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->status = ERROR_MORE_DATA;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh } else {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if (param->resume_handle)
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh *param->resume_handle = 0;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->bytes_needed = 0;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->status = ERROR_SUCCESS;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh }
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh return (NDR_DRC_OK);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintoshenum_services_status_error:
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh bzero(param, sizeof (struct svcctl_EnumServicesStatus));
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->services = NDR_STRDUP(mxa, "");
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->status = status;
8d7e41661dc4633488e93b13363137523ce59977jose borrego return (NDR_DRC_OK);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States}
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States/*
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * svcctl_s_QueryServiceConfig
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States *
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * Returns:
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * ERROR_SUCCESS
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * ERROR_INVALID_HANDLE
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United Statesstatic int
8d7e41661dc4633488e93b13363137523ce59977jose borregosvcctl_s_QueryServiceConfig(void *arg, ndr_xa_t *mxa)
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States{
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States struct svcctl_QueryServiceConfig *param = arg;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ndr_hdid_t *id = (ndr_hdid_t *)&param->service_handle;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ndr_handle_t *hd;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svcctl_manager_context_t *mgr_ctx;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svcctl_service_context_t *svc_ctx;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svcctl_svc_node_t *svc;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States int bytes_needed = 0;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svc_config_t *cfg;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States hd = svcctl_hdlookup(mxa, id, SVCCTL_SERVICE_CONTEXT);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if (hd == NULL) {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States bzero(param, sizeof (struct svcctl_QueryServiceConfig));
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->status = ERROR_INVALID_HANDLE;
8d7e41661dc4633488e93b13363137523ce59977jose borrego return (NDR_DRC_OK);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svc_ctx = ((svcctl_context_t *)hd->nh_data)->c_ctx.uc_svc;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States mgr_ctx = svcctl_get_mgr_ctx(mxa, svc_ctx->sc_mgrid);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if (mgr_ctx == NULL) {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States bzero(param, sizeof (struct svcctl_QueryServiceConfig));
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->status = ERROR_INVALID_HANDLE;
8d7e41661dc4633488e93b13363137523ce59977jose borrego return (NDR_DRC_OK);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svc = svcctl_scm_find_service(mgr_ctx, svc_ctx->sc_svcname);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if (svc == NULL || svc->sn_fmri == NULL) {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States bzero(param, sizeof (struct svcctl_QueryServiceConfig));
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->status = ERROR_SERVICE_DOES_NOT_EXIST;
8d7e41661dc4633488e93b13363137523ce59977jose borrego return (NDR_DRC_OK);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States cfg = &param->service_cfg;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States cfg->service_type = SERVICE_WIN32_SHARE_PROCESS;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States cfg->start_type = SERVICE_AUTO_START;
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai cfg->error_control = SERVICE_ERROR_IGNORE;
8d7e41661dc4633488e93b13363137523ce59977jose borrego cfg->binary_pathname = NDR_STRDUP(mxa, "");
8d7e41661dc4633488e93b13363137523ce59977jose borrego cfg->loadorder_group = NDR_STRDUP(mxa, "");
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States cfg->tag_id = 0;
8d7e41661dc4633488e93b13363137523ce59977jose borrego cfg->dependencies = NDR_STRDUP(mxa, "");
8d7e41661dc4633488e93b13363137523ce59977jose borrego cfg->service_startname = NDR_STRDUP(mxa, "");
8d7e41661dc4633488e93b13363137523ce59977jose borrego cfg->display_name = NDR_STRDUP(mxa, svc->sn_fmri);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States bytes_needed = sizeof (svc_config_t);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States bytes_needed += SVCCTL_WNSTRLEN((const char *)cfg->binary_pathname);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States bytes_needed += SVCCTL_WNSTRLEN((const char *)cfg->loadorder_group);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States bytes_needed += SVCCTL_WNSTRLEN((const char *)cfg->dependencies);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States bytes_needed += SVCCTL_WNSTRLEN((const char *)cfg->service_startname);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States bytes_needed += SVCCTL_WNSTRLEN(svc->sn_fmri);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if (param->buf_size < bytes_needed) {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States bzero(param, sizeof (struct svcctl_QueryServiceConfig));
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->cfg_bytes = bytes_needed;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->status = ERROR_INSUFFICIENT_BUFFER;
8d7e41661dc4633488e93b13363137523ce59977jose borrego return (NDR_DRC_OK);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->cfg_bytes = bytes_needed;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->status = ERROR_SUCCESS;
8d7e41661dc4633488e93b13363137523ce59977jose borrego return (NDR_DRC_OK);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States}
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh/*
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh * svcctl_s_StartService
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh */
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintoshstatic int
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintoshsvcctl_s_StartService(void *arg, ndr_xa_t *mxa)
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh{
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh struct svcctl_StartService *param = arg;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh ndr_hdid_t *id = (ndr_hdid_t *)&param->service_handle;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh ndr_handle_t *hd;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh svcctl_manager_context_t *mgr_ctx;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh svcctl_service_context_t *svc_ctx;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh svcctl_svc_node_t *svc;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh hd = svcctl_hdlookup(mxa, id, SVCCTL_SERVICE_CONTEXT);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if (hd == NULL) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->status = ERROR_INVALID_HANDLE;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh return (NDR_DRC_OK);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh }
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh svc_ctx = ((svcctl_context_t *)hd->nh_data)->c_ctx.uc_svc;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh mgr_ctx = svcctl_get_mgr_ctx(mxa, svc_ctx->sc_mgrid);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if (mgr_ctx == NULL) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->status = ERROR_INVALID_HANDLE;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh return (NDR_DRC_OK);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh }
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh svc = svcctl_scm_find_service(mgr_ctx, svc_ctx->sc_svcname);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if (svc == NULL || svc->sn_fmri == NULL)
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->status = ERROR_SERVICE_DOES_NOT_EXIST;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh else
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->status = ERROR_SERVICE_ALREADY_RUNNING;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh return (NDR_DRC_OK);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh}
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States/*
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * svcctl_s_GetServiceDisplayNameW
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States *
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * Returns:
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * ERROR_SUCCESS
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * ERROR_INVALID_HANDLE
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * ERROR_SERVICE_DOES_NOT_EXIST
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United Statesstatic int
8d7e41661dc4633488e93b13363137523ce59977jose borregosvcctl_s_GetServiceDisplayNameW(void *arg, ndr_xa_t *mxa)
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States{
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States struct svcctl_GetServiceDisplayNameW *param = arg;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ndr_hdid_t *id = (ndr_hdid_t *)&param->manager_handle;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ndr_handle_t *hd;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svcctl_svc_node_t *svc;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svcctl_manager_context_t *mgr_ctx;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States hd = svcctl_hdlookup(mxa, id, SVCCTL_MANAGER_CONTEXT);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if (hd == NULL) {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States bzero(param, sizeof (struct svcctl_GetServiceDisplayNameW));
8d7e41661dc4633488e93b13363137523ce59977jose borrego param->display_name = NDR_STRDUP(mxa, "");
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->status = ERROR_INVALID_HANDLE;
8d7e41661dc4633488e93b13363137523ce59977jose borrego return (NDR_DRC_OK);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States mgr_ctx = ((svcctl_context_t *)hd->nh_data)->c_ctx.uc_mgr;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svc = svcctl_scm_find_service(mgr_ctx, (char *)param->service_name);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if (svc == NULL || svc->sn_fmri == NULL) {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States bzero(param, sizeof (struct svcctl_GetServiceDisplayNameW));
8d7e41661dc4633488e93b13363137523ce59977jose borrego param->display_name = NDR_STRDUP(mxa, "");
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->status = ERROR_SERVICE_DOES_NOT_EXIST;
8d7e41661dc4633488e93b13363137523ce59977jose borrego return (NDR_DRC_OK);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
8d7e41661dc4633488e93b13363137523ce59977jose borrego param->display_name = NDR_STRDUP(mxa, svc->sn_fmri);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if (param->display_name == NULL) {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States bzero(param, sizeof (struct svcctl_GetServiceDisplayNameW));
8d7e41661dc4633488e93b13363137523ce59977jose borrego param->display_name = NDR_STRDUP(mxa, "");
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->status = ERROR_NOT_ENOUGH_MEMORY;
8d7e41661dc4633488e93b13363137523ce59977jose borrego return (NDR_DRC_OK);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->buf_size = strlen(svc->sn_fmri);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->status = ERROR_SUCCESS;
8d7e41661dc4633488e93b13363137523ce59977jose borrego return (NDR_DRC_OK);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States}
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States/*
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * svcctl_s_GetServiceKeyNameW
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States *
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * Returns:
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * ERROR_SUCCESS
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * ERROR_INVALID_HANDLE
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * ERROR_SERVICE_DOES_NOT_EXIST
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United Statesstatic int
8d7e41661dc4633488e93b13363137523ce59977jose borregosvcctl_s_GetServiceKeyNameW(void *arg, ndr_xa_t *mxa)
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States{
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States struct svcctl_GetServiceKeyNameW *param = arg;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ndr_hdid_t *id = (ndr_hdid_t *)&param->manager_handle;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ndr_handle_t *hd;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svcctl_svc_node_t *svc;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svcctl_manager_context_t *mgr_ctx;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States hd = svcctl_hdlookup(mxa, id, SVCCTL_MANAGER_CONTEXT);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if (hd == NULL) {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States bzero(param, sizeof (struct svcctl_GetServiceKeyNameW));
8d7e41661dc4633488e93b13363137523ce59977jose borrego param->key_name = NDR_STRDUP(mxa, "");
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->status = ERROR_INVALID_HANDLE;
8d7e41661dc4633488e93b13363137523ce59977jose borrego return (NDR_DRC_OK);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States mgr_ctx = ((svcctl_context_t *)hd->nh_data)->c_ctx.uc_mgr;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svc = svcctl_scm_find_service(mgr_ctx, (char *)param->service_name);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if (svc == NULL || svc->sn_name == NULL) {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States bzero(param, sizeof (struct svcctl_GetServiceKeyNameW));
8d7e41661dc4633488e93b13363137523ce59977jose borrego param->key_name = NDR_STRDUP(mxa, "");
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->status = ERROR_SERVICE_DOES_NOT_EXIST;
8d7e41661dc4633488e93b13363137523ce59977jose borrego return (NDR_DRC_OK);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
8d7e41661dc4633488e93b13363137523ce59977jose borrego param->key_name = NDR_STRDUP(mxa, svc->sn_name);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if (param->key_name == NULL) {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States bzero(param, sizeof (struct svcctl_GetServiceKeyNameW));
8d7e41661dc4633488e93b13363137523ce59977jose borrego param->key_name = NDR_STRDUP(mxa, "");
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->status = ERROR_NOT_ENOUGH_MEMORY;
8d7e41661dc4633488e93b13363137523ce59977jose borrego return (NDR_DRC_OK);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->buf_size = strlen(svc->sn_name);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->status = ERROR_SUCCESS;
8d7e41661dc4633488e93b13363137523ce59977jose borrego return (NDR_DRC_OK);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States}
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh/*
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh * svcctl_s_OpenSCManagerA
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh *
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh * Request to open the service control manager.
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh * The caller must have administrator rights in order to open this
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh * interface. We don't support write (SC_MANAGER_LOCK) access.
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh *
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh * Returns:
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh * ERROR_SUCCESS
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh * ERROR_ACCESS_DENIED
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh *
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh * On success, returns a handle for use with subsequent svcctl requests.
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh */
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintoshstatic int
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintoshsvcctl_s_OpenSCManagerA(void *arg, ndr_xa_t *mxa)
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh{
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh struct svcctl_OpenSCManagerA *param = arg;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh ndr_hdid_t *id = NULL;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh int rc;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh rc = ndr_is_admin(mxa);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if ((rc == 0) || (param->desired_access & SC_MANAGER_LOCK) != 0) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh bzero(&param->handle, sizeof (svcctl_handle_t));
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->status = ERROR_ACCESS_DENIED;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh return (NDR_DRC_OK);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh }
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh id = svcctl_mgr_hdalloc(mxa);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if (id) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh bcopy(id, &param->handle, sizeof (svcctl_handle_t));
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->status = ERROR_SUCCESS;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh } else {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh bzero(&param->handle, sizeof (svcctl_handle_t));
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->status = ERROR_ACCESS_DENIED;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh }
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh return (NDR_DRC_OK);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh}
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh/*
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh * svcctl_s_OpenServiceA
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh *
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh * Return a handle for use with subsequent svcctl requests.
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh *
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh * Returns:
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh * ERROR_SUCCESS
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh * ERROR_INVALID_HANDLE
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh * ERROR_SERVICE_DOES_NOT_EXIST
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh * ERROR_CALL_NOT_IMPLEMENTED
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh */
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintoshstatic int
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintoshsvcctl_s_OpenServiceA(void *arg, ndr_xa_t *mxa)
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh{
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh struct svcctl_OpenServiceA *param = arg;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh ndr_hdid_t *mgrid = (ndr_hdid_t *)&param->manager_handle;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh ndr_hdid_t *id = NULL;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh ndr_handle_t *hd;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh DWORD status;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh svcctl_manager_context_t *mgr_ctx;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh char *svc_name = (char *)param->service_name->value;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh boolean_t unimplemented_operations = B_FALSE;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh /* Allow service handle allocations for only status & config queries */
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh unimplemented_operations =
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh SVCCTL_OPENSVC_OP_UNIMPLEMENTED(param->desired_access);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if (unimplemented_operations) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh bzero(&param->service_handle, sizeof (svcctl_handle_t));
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->status = ERROR_CALL_NOT_IMPLEMENTED;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh return (NDR_DRC_OK);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh }
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh hd = svcctl_hdlookup(mxa, mgrid, SVCCTL_MANAGER_CONTEXT);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if (hd == NULL) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh bzero(&param->service_handle, sizeof (svcctl_handle_t));
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->status = ERROR_INVALID_HANDLE;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh return (NDR_DRC_OK);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh }
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh mgr_ctx = ((svcctl_context_t *)hd->nh_data)->c_ctx.uc_mgr;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh status = svcctl_scm_validate_service(mgr_ctx, svc_name);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if (status != ERROR_SUCCESS) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh bzero(&param->service_handle, sizeof (svcctl_handle_t));
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->status = status;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh return (NDR_DRC_OK);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh }
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh id = svcctl_svc_hdalloc(mxa, mgrid, svc_name);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if (id) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh bcopy(id, &param->service_handle, sizeof (svcctl_handle_t));
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->status = ERROR_SUCCESS;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh } else {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh bzero(&param->service_handle, sizeof (svcctl_handle_t));
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->status = ERROR_ACCESS_DENIED;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh }
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh return (NDR_DRC_OK);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh}
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh/*
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh * svcctl_s_EnumServicesStatusA
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh *
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh * Enumerate the list of services we support as ASCII.
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh */
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintoshstatic int
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintoshsvcctl_s_EnumServicesStatusA(void *arg, ndr_xa_t *mxa)
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh{
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh struct svcctl_EnumServicesStatusA *param = arg;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh ndr_hdid_t *id = (ndr_hdid_t *)&param->manager_handle;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh ndr_handle_t *hd;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh svcctl_manager_context_t *mgr_ctx;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh uint32_t buf_size;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh uint32_t svc_num;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh uint32_t resume_handle = 0;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh uint32_t status;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh buf_size = param->buf_size;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if (param->resume_handle != NULL)
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh resume_handle = *param->resume_handle;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh hd = svcctl_hdlookup(mxa, id, SVCCTL_MANAGER_CONTEXT);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if (hd == NULL) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh status = ERROR_INVALID_HANDLE;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh goto enum_services_status_error;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh }
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh mgr_ctx = ((svcctl_context_t *)hd->nh_data)->c_ctx.uc_mgr;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if (svcctl_scm_refresh(mgr_ctx) != 0) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh status = ERROR_INVALID_HANDLE;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh goto enum_services_status_error;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh }
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->services = NDR_MALLOC(mxa, buf_size);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if (param->services == NULL) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh status = ERROR_NOT_ENOUGH_MEMORY;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh goto enum_services_status_error;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh }
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh bzero(param->services, buf_size);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh svc_num = svcctl_scm_enum_services(mgr_ctx, param->services,
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh buf_size, &resume_handle, B_FALSE);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->buf_size = buf_size;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->svc_num = svc_num;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if (resume_handle != 0) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if (param->resume_handle != NULL)
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh *param->resume_handle = resume_handle;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->bytes_needed = mgr_ctx->mc_bytes_needed;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->status = ERROR_MORE_DATA;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh } else {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if (param->resume_handle)
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh *param->resume_handle = 0;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->bytes_needed = 0;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->status = ERROR_SUCCESS;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh }
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh return (NDR_DRC_OK);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintoshenum_services_status_error:
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh bzero(param, sizeof (struct svcctl_EnumServicesStatusA));
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->services = NDR_STRDUP(mxa, "");
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->status = status;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh return (NDR_DRC_OK);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh}
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States/*
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * svcctl_s_QueryServiceConfig2W
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States *
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * Returns:
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * ERROR_SUCCESS
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * ERROR_INVALID_HANDLE
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * ERROR_INVALID_LEVEL
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States * ERROR_NOT_ENOUGH_MEMORY
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States */
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United Statesstatic int
8d7e41661dc4633488e93b13363137523ce59977jose borregosvcctl_s_QueryServiceConfig2W(void *arg, ndr_xa_t *mxa)
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States{
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States struct svcctl_QueryServiceConfig2W *param = arg;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ndr_hdid_t *id = (ndr_hdid_t *)&param->service_handle;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States ndr_handle_t *hd;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svcctl_manager_context_t *mgr_ctx;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svcctl_service_context_t *svc_ctx;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svcctl_svc_node_t *svc;
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai svc_config_rsp_t svc_rsp;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States int offset, input_bufsize, bytes_needed = 0;
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown smb_wchar_t *wide_desc;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States char *desc;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States DWORD status;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States hd = svcctl_hdlookup(mxa, id, SVCCTL_SERVICE_CONTEXT);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if (hd == NULL) {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States bzero(param, sizeof (struct svcctl_QueryServiceConfig2W));
8d7e41661dc4633488e93b13363137523ce59977jose borrego param->buffer = NDR_STRDUP(mxa, "");
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->status = ERROR_INVALID_HANDLE;
8d7e41661dc4633488e93b13363137523ce59977jose borrego return (NDR_DRC_OK);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States input_bufsize = param->buf_size;
8d7e41661dc4633488e93b13363137523ce59977jose borrego param->buffer = NDR_MALLOC(mxa, input_bufsize);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if (param->buffer == NULL) {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States bzero(param, sizeof (struct svcctl_QueryServiceConfig2W));
8d7e41661dc4633488e93b13363137523ce59977jose borrego param->buffer = NDR_STRDUP(mxa, "");
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->status = ERROR_NOT_ENOUGH_MEMORY;
8d7e41661dc4633488e93b13363137523ce59977jose borrego return (NDR_DRC_OK);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States bzero(param->buffer, input_bufsize);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai svc_rsp.svc_buf = param->buffer;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States status = ERROR_SUCCESS;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States switch (param->info_level) {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States case SERVICE_CONFIG_DESCRIPTION:
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svc_ctx = ((svcctl_context_t *)hd->nh_data)->c_ctx.uc_svc;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States mgr_ctx = svcctl_get_mgr_ctx(mxa, svc_ctx->sc_mgrid);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if (mgr_ctx == NULL) {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->status = ERROR_INVALID_HANDLE;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States break;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States svc = svcctl_scm_find_service(mgr_ctx, svc_ctx->sc_svcname);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if (svc == NULL || svc->sn_desc == NULL) {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States status = ERROR_SERVICE_DOES_NOT_EXIST;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States break;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States desc = svc->sn_desc;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States bytes_needed = SVCCTL_WNSTRLEN(desc);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if (input_bufsize <= bytes_needed) {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->bytes_needed = bytes_needed;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->status = ERROR_INSUFFICIENT_BUFFER;
8d7e41661dc4633488e93b13363137523ce59977jose borrego return (NDR_DRC_OK);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States offset = sizeof (svc_description_t);
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai svc_rsp.svc_desc->desc = offset;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States /*LINTED E_BAD_PTR_CAST_ALIGN*/
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown wide_desc = (smb_wchar_t *)&param->buffer[offset];
bbf6f00c25b6a2bed23c35eac6d62998ecdb338cJordan Brown (void) smb_mbstowcs(wide_desc, desc, (strlen(desc) + 1));
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai offset += SVCCTL_WNSTRLEN(desc);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->bytes_needed = offset;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States break;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States case SERVICE_CONFIG_FAILURE_ACTIONS:
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai bzero(svc_rsp.svc_fac, sizeof (svc_failure_actions_t));
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai bytes_needed = sizeof (svc_failure_actions_t);
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai if (input_bufsize <= bytes_needed) {
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai param->bytes_needed = bytes_needed;
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai param->status = ERROR_INSUFFICIENT_BUFFER;
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai return (NDR_DRC_OK);
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai }
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai param->bytes_needed = bytes_needed;
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai break;
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai case SERVICE_CONFIG_DELAYED_AUTO_START_INFO:
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai svc_rsp.svc_dstart->dstart = 0;
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai param->bytes_needed = sizeof (svc_delayed_auto_start_t);
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai break;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai case SERVICE_CONFIG_FAILURE_ACTIONS_FLAG:
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai svc_rsp.svc_cfa->cfa = 0;
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai param->bytes_needed = sizeof (svc_config_failure_action_t);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States break;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai case SERVICE_CONFIG_SERVICE_SID_INFO:
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai case SERVICE_CONFIG_REQUIRED_PRIVILEGES_INFO:
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai case SERVICE_CONFIG_PRESHUTDOWN_INFO:
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai case SERVICE_CONFIG_TRIGGER_INFO:
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai case SERVICE_CONFIG_PREFERRED_NODE:
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States default:
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States status = ERROR_INVALID_LEVEL;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States break;
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States if (status != ERROR_SUCCESS) {
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States bzero(param, sizeof (struct svcctl_QueryServiceConfig2W));
8d7e41661dc4633488e93b13363137523ce59977jose borrego param->buffer = NDR_STRDUP(mxa, "");
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->status = status;
8d7e41661dc4633488e93b13363137523ce59977jose borrego return (NDR_DRC_OK);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States }
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States param->status = ERROR_SUCCESS;
8d7e41661dc4633488e93b13363137523ce59977jose borrego return (NDR_DRC_OK);
b89a8333f5e1f75ec0c269b22524bd2eccb972banatalie li - Sun Microsystems - Irvine United States}
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh/*
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh * svcctl_s_QueryServiceStatusEx
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh */
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintoshstatic int
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintoshsvcctl_s_QueryServiceStatusEx(void *arg, ndr_xa_t *mxa)
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh{
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh struct svcctl_QueryServiceStatusEx *param = arg;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh ndr_hdid_t *id = (ndr_hdid_t *)&param->service_handle;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh ndr_handle_t *hd;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh svcctl_manager_context_t *mgr_ctx;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh svcctl_service_context_t *svc_ctx;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh svcctl_svc_node_t *svc;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh svc_status_ex_t *svc_status_ex;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh uint32_t input_bufsize;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh uint32_t bytes_needed;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh DWORD status;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh hd = svcctl_hdlookup(mxa, id, SVCCTL_SERVICE_CONTEXT);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if (hd == NULL) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh status = ERROR_INVALID_HANDLE;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh goto query_service_status_ex_error;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh }
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh svc_ctx = ((svcctl_context_t *)hd->nh_data)->c_ctx.uc_svc;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh mgr_ctx = svcctl_get_mgr_ctx(mxa, svc_ctx->sc_mgrid);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if (mgr_ctx == NULL) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh status = ERROR_INVALID_HANDLE;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh goto query_service_status_ex_error;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh }
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if (param->info_level != SC_STATUS_PROCESS_INFO) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh status = ERROR_INVALID_PARAMETER;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh goto query_service_status_ex_error;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh }
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai bytes_needed = sizeof (svc_status_ex_t);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if ((input_bufsize = param->buf_size) < bytes_needed) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh bzero(param, sizeof (struct svcctl_QueryServiceStatusEx));
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->buf_size = input_bufsize;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->buffer = NDR_STRDUP(mxa, "");
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->bytes_needed = bytes_needed;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->status = ERROR_INSUFFICIENT_BUFFER;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh return (NDR_DRC_OK);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh }
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if ((svc_status_ex = NDR_MALLOC(mxa, bytes_needed)) == NULL) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh status = ERROR_NOT_ENOUGH_MEMORY;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh goto query_service_status_ex_error;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh }
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh svc = svcctl_scm_find_service(mgr_ctx, svc_ctx->sc_svcname);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh if (svc == NULL || svc->sn_state == NULL) {
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh status = ERROR_SERVICE_DOES_NOT_EXIST;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh goto query_service_status_ex_error;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh }
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh svc_status_ex->service_type = SERVICE_WIN32_SHARE_PROCESS;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh svc_status_ex->cur_state = svcctl_scm_map_status(svc->sn_state);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh svc_status_ex->ctrl_accepted = 0;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh svc_status_ex->w32_exitcode = 0;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh svc_status_ex->svc_specified_exitcode = 0;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh svc_status_ex->check_point = 0;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh svc_status_ex->wait_hint = 0;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh svc_status_ex->process_id = 1;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh svc_status_ex->service_flags = 1;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->buffer = (uint8_t *)svc_status_ex;
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai param->buf_size = input_bufsize;
e3f2c991a8548408db0a2787bd8b43d5124821d3Keyur Desai param->bytes_needed = bytes_needed;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->status = ERROR_SUCCESS;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh return (NDR_DRC_OK);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintoshquery_service_status_ex_error:
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh bzero(param, sizeof (struct svcctl_QueryServiceStatusEx));
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->buffer = NDR_STRDUP(mxa, "");
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh param->status = status;
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh return (NDR_DRC_OK);
037cac007b685e7ea79f6ef7e8e62bfd342a4d56joyce mcintosh}