Beispiel #1
0
NTSTATUS
SrvReadConfig(
    PLWIO_SRV_CONFIG pConfig
    )
{
    NTSTATUS ntStatus = STATUS_SUCCESS;
    LWIO_SRV_CONFIG srvConfig = {0};
    PLWIO_CONFIG_REG pReg = NULL;
    BOOLEAN bUsePolicy = TRUE;

    ntStatus = SrvInitConfig(&srvConfig);
    BAIL_ON_NT_STATUS(ntStatus);

    ntStatus = LwIoOpenConfig(
                    "Services\\lwio\\Parameters\\Drivers\\srv",
                    "Policy\\Services\\lwio\\Parameters\\Drivers\\srv",
                    &pReg);
    if (ntStatus)
    {
        LWIO_LOG_ERROR("Failed to access device configuration [error code: %u]",
                       ntStatus);

        ntStatus = STATUS_DEVICE_CONFIGURATION_ERROR;
    }
    BAIL_ON_NT_STATUS(ntStatus);

    /* Ignore error as it may not exist; we can still use default. */
    LwIoReadConfigBoolean(
            pReg,
            "BootstrapDefaultSharePath",
            bUsePolicy,
            &srvConfig.bBootstrapDefaultSharePath);

    /* Ignore error as it may not exist; we can still use default. */
    LwIoReadConfigDword(
            pReg,
            "MonitorIntervalMinutes",
            bUsePolicy,
            LWIO_SRV_DEFAULT_MONITOR_INTERVAL_MINS_MIN,
            LWIO_SRV_DEFAULT_MONITOR_INTERVAL_MINS_MAX,
            &srvConfig.ulMonitorIntervalMinutes);

    ntStatus = SrvTransferConfigContents(&srvConfig, pConfig);
    BAIL_ON_NT_STATUS(ntStatus);

cleanup:

    if (pReg)
    {
        LwIoCloseConfig(pReg);
    }

    SrvFreeConfigContents(&srvConfig);

    return ntStatus;

error:

    goto cleanup;
}
Beispiel #2
0
NTSTATUS
SrvStatsConfigRead(
    PSRV_STATISTICS_CONFIG pConfig
    )
{
    NTSTATUS ntStatus = STATUS_SUCCESS;
    SRV_STATISTICS_CONFIG config = { 0 };
    PLWIO_CONFIG_REG pReg = NULL;
    BOOLEAN bUsePolicy = TRUE;

    ntStatus = SrvStatsConfigInitContents(&config);
    BAIL_ON_NT_STATUS(ntStatus);

    ntStatus = LwIoOpenConfig(
                "Services\\lwio\\Parameters\\Drivers\\srv\\statistics",
                "Policy\\Services\\lwio\\Parameters\\Drivers\\srv\\statistics",
                &pReg);
    if (ntStatus)
    {
        LWIO_LOG_ERROR(
            "Failed to access device statistics configuration [error code: %u]",
            ntStatus);

        ntStatus = STATUS_DEVICE_CONFIGURATION_ERROR;
    }
    BAIL_ON_NT_STATUS(ntStatus);

    /* Ignore error as it may not exist; we can still use default. */
    LwIoReadConfigString(
            pReg,
            "Path",
            bUsePolicy,
            &config.pszProviderPath);

    LwIoReadConfigBoolean(
            pReg,
            "EnableLogging",
            bUsePolicy,
            &config.bEnableLogging);

    ntStatus = SrvStatsConfigTransferContents(&config, pConfig);
    BAIL_ON_NT_STATUS(ntStatus);

cleanup:

    if (pReg)
    {
        LwIoCloseConfig(pReg);
    }

    return ntStatus;

error:

    SrvStatsConfigFreeContents(&config);

    goto cleanup;
}
Beispiel #3
0
static
NTSTATUS
SrvGetDefaultSharePath(
    PSTR* ppszFileSystemRoot
    )
{
    NTSTATUS ntStatus = STATUS_SUCCESS;
    PSTR     pszDefaultSharePath = NULL;
    PSTR     pszFileSystemRoot = NULL;
    PSTR     pszCursor = NULL;
    BOOLEAN  bUsePolicy = TRUE;
    CHAR     szTmpFSRoot[] = LWIO_SRV_FILE_SYSTEM_ROOT_A;
    PLWIO_CONFIG_REG pReg = NULL;

    ntStatus = LwIoOpenConfig(
                        "Services\\lwio\\Parameters\\Drivers\\srv",
                        "Policy\\Services\\lwio\\Parameters\\Drivers\\srv",
                        &pReg);
    BAIL_ON_NT_STATUS(ntStatus);

    ntStatus = LwIoReadConfigString(
                    pReg,
                    "DefaultSharePath",
                    bUsePolicy,
                    &pszDefaultSharePath);
    BAIL_ON_NT_STATUS(ntStatus);

    if (IsNullOrEmptyString(pszDefaultSharePath) ||
            ((*pszDefaultSharePath != '/') &&
             (*pszDefaultSharePath != '\\')))
    {
        LWIO_LOG_ERROR("Error: Default share path configured is not an absolute path");

        ntStatus = STATUS_INVALID_PARAMETER;
        BAIL_ON_NT_STATUS(ntStatus);
    }

    ntStatus = SrvAllocateStringPrintf(
                    &pszFileSystemRoot,
                    "%s%s%s",
                    &szTmpFSRoot[0],
                    (((szTmpFSRoot[strlen(&szTmpFSRoot[0])-1] == '/') ||
                      (szTmpFSRoot[strlen(&szTmpFSRoot[0])-1] == '\\')) ? "" : "\\"),
                    IsNullOrEmptyString(pszDefaultSharePath+1) ? "" : pszDefaultSharePath+1);
    BAIL_ON_NT_STATUS(ntStatus);

    for (pszCursor = pszFileSystemRoot; pszCursor && *pszCursor; pszCursor++)
    {
        if (*pszCursor == '/')
        {
            *pszCursor = '\\';
        }
    }

    *ppszFileSystemRoot = pszFileSystemRoot;

cleanup:

    if (pReg)
    {
        LwIoCloseConfig(pReg);
    }

    RTL_FREE(&pszDefaultSharePath);

    return ntStatus;

error:

    *ppszFileSystemRoot = NULL;

    LWIO_LOG_ERROR("Failed to access device configuration [error code: %u]",
                   ntStatus);

    ntStatus = STATUS_DEVICE_CONFIGURATION_ERROR;

    goto cleanup;
}