/* 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_netsharesetinfo.c * * Abstract: * * Likewise Server Service (srvsvc) RPC client and server * * NetShareSetInfo server API * * Authors: Krishna Ganugapati (krishnag@likewisesoftware.com) * Sriram Nambakam (snambakam@likewisesoftware.com) * Rafal Szczesniak (rafal@likewise.com) */ #include "includes.h" NET_API_STATUS SrvSvcNetShareSetInfo( /* [in] */ handle_t IDL_handle, /* [in] */ wchar16_t *server_name, /* [in] */ wchar16_t *netname, /* [in] */ UINT32 level, /* [in] */ srvsvc_NetShareInfo info, /* [in, out] */ UINT32 *parm_error ) { 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_SET_SHARE_INFO; PSTR pszSmbPath = NULL; IO_FILE_NAME filename = { 0 }; SHARE_INFO_SETINFO_PARAMS SetParams = { 0 }; SetParams.dwInfoLevel = level; SetParams.pwszNetname = netname; switch (SetParams.dwInfoLevel) { case 0: SetParams.Info.p0 = (PSHARE_INFO_0)info.info0; break; case 1: SetParams.Info.p1 = (PSHARE_INFO_1)info.info1; break; case 2: SetParams.Info.p2 = (PSHARE_INFO_2)info.info2; break; case 501: SetParams.Info.p501 = (PSHARE_INFO_501)info.info501; break; case 502: SetParams.Info.p502 = (PSHARE_INFO_502)info.info502; break; case 1005: SetParams.Info.p502 = (PSHARE_INFO_1005)info.info1005; goto cleanup; break; default: ntStatus = STATUS_INVALID_LEVEL; BAIL_ON_NT_STATUS(ntStatus); } ntStatus = LwShareInfoMarshalSetParameters( &SetParams, &pInBuffer, &dwInLength ); BAIL_ON_NT_STATUS(ntStatus); dwError = LwAllocateMemory( dwOutLength, (void**)&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: */