Ejemplo n.º 1
0
static
DWORD
RunSilentWithStatus(
    PCSTR Command,
    PSTR* Args,
    PLONG Status
    )
{
    DWORD ceError = ERROR_SUCCESS;
    int EE = 0;
    LONG status = 0;
    PPROCINFO procInfo = NULL;

    ceError = DJSpawnProcessSilent(Command, Args, &procInfo);
    GOTO_CLEANUP_ON_DWORD_EE(ceError, EE);

    ceError = DJGetProcessStatus(procInfo, &status);
    GOTO_CLEANUP_ON_DWORD_EE(ceError, EE);

cleanup:
    if (procInfo)
    {
        FreeProcInfo(procInfo);
    }

    *Status = status;

    if (EE || ceError)
    {
        DJ_LOG_VERBOSE("RunSiledWithStatus LEAVE -> 0x%08x (EE = %d)", ceError, EE);
    }

    return ceError;
}
Ejemplo n.º 2
0
static
void
KickLookupd(
    )
{
    DWORD ceError = ERROR_SUCCESS;
    int EE = 0;
    char stopCommand[] = "/usr/bin/killall";
    PSTR stopArgs[3] = { stopCommand, "lookupd" };
#if 0
    char startCommand[] = "/usr/sbin/lookupd";
    PSTR startArgs[2] = { startCommand };
#endif
    LONG status = 0;

    ceError = RunSilentWithStatus(stopCommand, stopArgs, &status);
    GOTO_CLEANUP_ON_DWORD_EE(ceError, EE);
    if (status != 0)
    {
        DJ_LOG_ERROR("%s failed [Status code: %d]", stopCommand, status);
        goto cleanup;
    }

    // We do not technically need to restart it since it will restart on
    // demand.
#if 0
    ceError = RunSilentWithStatus(startCommand, startArgs, &status);
    GOTO_CLEANUP_ON_DWORD_EE(ceError, EE);
    if (status != 0)
    {
        DJ_LOG_ERROR("%s failed [Status code: %d]", startCommand, status);
    }
#endif

cleanup:
    DJ_LOG_VERBOSE("KickLookupd LEAVE -> 0x%08x (EE = %d)", ceError, EE);
}
Ejemplo n.º 3
0
static
DWORD
SetMacOsXHostName(
    PCSTR HostName
    )
{
    DWORD ceError = ERROR_SUCCESS;
    int EE = 0;
    char command[] = "scutil";
    /* ISSUE-2007/08/01-dalmeida -- Fix const-ness of arg array in procutils */
    PSTR args[5] = { command, "--set", "HostName", (char*)HostName };
    PPROCINFO procInfo = NULL;
    LONG status = 0;

    ceError = DJSpawnProcessSilent(command, args, &procInfo);
    GOTO_CLEANUP_ON_DWORD_EE(ceError, EE);

    ceError = DJGetProcessStatus(procInfo, &status);
    GOTO_CLEANUP_ON_DWORD_EE(ceError, EE);

    if (status != 0) {
        DJ_LOG_ERROR("%s failed [Status code: %d]", command, status);
        ceError = ERROR_BAD_COMMAND;
        GOTO_CLEANUP_ON_DWORD_EE(ceError, EE);
    }

cleanup:
    if (procInfo)
    {
        FreeProcInfo(procInfo);
    }

    DJ_LOG_VERBOSE("SetMacOsXHostName LEAVE -> 0x%08x (EE = %d)", ceError, EE);

    return ceError;
}
Ejemplo n.º 4
0
static
void
MacDnsCacheFlush()
{
    DWORD ceError = ERROR_SUCCESS;
    int EE = 0;
    char stopCommand[] = "/usr/bin/killall";
    PSTR stopArgs[3] = { "-HUP", "mDNSResponder", NULL };
    LONG status = 0;

    ceError = RunSilentWithStatus(stopCommand, stopArgs, &status);
    GOTO_CLEANUP_ON_DWORD_EE(ceError, EE);
    if (status != 0)
    {
        DJ_LOG_ERROR("%s failed [Status code: %d]", stopCommand, status);
        goto cleanup;
    }

cleanup:
    DJ_LOG_VERBOSE("MacDnsCacheFlush LEAVE -> 0x%08x (EE = %d)", ceError, EE);
}