/* Editor Settings: expandtabs and use 4 spaces for indentation * ex: set softtabstop=4 tabstop=8 expandtab shiftwidth=4: * */ /* * Copyright Likewise Software * All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or (at * your option) any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. You should have received a copy of the GNU General * Public License along with this program. If not, see * . * * LIKEWISE SOFTWARE MAKES THIS SOFTWARE AVAILABLE UNDER OTHER LICENSING * TERMS AS WELL. IF YOU HAVE ENTERED INTO A SEPARATE LICENSE AGREEMENT * WITH LIKEWISE SOFTWARE, THEN YOU MAY ELECT TO USE THE SOFTWARE UNDER THE * TERMS OF THAT SOFTWARE LICENSE AGREEMENT INSTEAD OF THE TERMS OF THE GNU * GENERAL PUBLIC LICENSE, NOTWITHSTANDING THE ABOVE NOTICE. IF YOU * HAVE QUESTIONS, OR WISH TO REQUEST A COPY OF THE ALTERNATE LICENSING * TERMS OFFERED BY LIKEWISE SOFTWARE, PLEASE CONTACT LIKEWISE SOFTWARE AT * license@likewisesoftware.com */ /* * Copyright (C) Likewise Software. All rights reserved. * * Module Name: * * srvsvc_netsharedel.c * * Abstract: * * Likewise Server Service (srvsvc) RPC client and server * * SrvSvcNetShareDel server API * * Authors: Krishna Ganugapati (krishnag@likewisesoftware.com) * Sriram Nambakam (snambakam@likewisesoftware.com) * Rafal Szczesniak (rafal@likewise.com) */ #include "includes.h" NET_API_STATUS SrvSvcNetShareDel( /* [in] */ handle_t IDL_handle, /* [in] */ wchar16_t *server_name, /* [in] */ wchar16_t *netname, /* [in] */ UINT32 reserved ) { NTSTATUS ntStatus = 0; DWORD dwError = 0; PBYTE pInBuffer = NULL; DWORD dwInLength = 0; PBYTE pOutBuffer = NULL; DWORD dwOutLength = 4096; IO_FILE_HANDLE hFile = NULL; IO_STATUS_BLOCK IoStatusBlock = { 0 }; ACCESS_MASK DesiredAccess = 0; LONG64 AllocationSize = 0; FILE_ATTRIBUTES FileAttributes = 0; FILE_SHARE_FLAGS ShareAccess = 0; FILE_CREATE_DISPOSITION CreateDisposition = 0; FILE_CREATE_OPTIONS CreateOptions = 0; ULONG IoControlCode = SRV_DEVCTL_DELETE_SHARE; PSTR pszSmbPath = NULL; IO_FILE_NAME filename = { 0 }; SHARE_INFO_DELETE_PARAMS DeleteParams = { 0 }; DeleteParams.servername = server_name; DeleteParams.netname = netname; ntStatus = LwShareInfoMarshalDeleteParameters( &DeleteParams, &pInBuffer, &dwInLength ); BAIL_ON_NT_STATUS(ntStatus); dwError = LwAllocateMemory( dwOutLength, (PVOID*)&pOutBuffer ); BAIL_ON_SRVSVC_ERROR(dwError); dwError = LwAllocateStringPrintf( &pszSmbPath, "\\srv" ); BAIL_ON_SRVSVC_ERROR(dwError); dwError = LwMbsToWc16s( pszSmbPath, &filename.FileName ); BAIL_ON_SRVSVC_ERROR(dwError); ntStatus = NtCreateFile( &hFile, NULL, &IoStatusBlock, &filename, NULL, NULL, DesiredAccess, AllocationSize, FileAttributes, ShareAccess, CreateDisposition, CreateOptions, NULL, 0, NULL ); BAIL_ON_NT_STATUS(ntStatus); ntStatus = NtDeviceIoControlFile( hFile, NULL, &IoStatusBlock, IoControlCode, pInBuffer, dwInLength, pOutBuffer, dwOutLength ); BAIL_ON_NT_STATUS(ntStatus); cleanup: if (hFile) { NtCloseFile(hFile); } LW_SAFE_FREE_MEMORY(pInBuffer); LW_SAFE_FREE_MEMORY(pOutBuffer); LW_SAFE_FREE_MEMORY(pszSmbPath); LW_SAFE_FREE_MEMORY(filename.FileName); if (dwError == ERROR_SUCCESS && ntStatus != STATUS_SUCCESS) { dwError = LwNtStatusToWin32Error(ntStatus); } return dwError; error: goto cleanup; } /* local variables: mode: c c-basic-offset: 4 indent-tabs-mode: nil tab-width: 4 end: */