~ssalley/ubuntu/maverick/likewise-open/likewise-open.fix627272

« back to all changes in this revision

Viewing changes to domainjoin/libdomainjoin/src/djauthinfo.c

  • Committer: Bazaar Package Importer
  • Author(s): Gerald Carter, Michael Casadevall, Gerald Carter
  • Date: 2010-03-13 07:42:44 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20100313074244-j1gy0zo19cc32xhl
Tags: 5.4.0.42111-1
[ Michael Casadevall ]
* LP: #517300
  - added debian/patches/disable_parallel_builds.diff to allow successful builds
    on non-x86 architectures caused by improperly parsing /proc/cpuinfo to
    determine the number of CPUs and set make -jX.
  - added debian/patches/correct_lwio_configure_detection.diff to correct configure
    tests for properly checking proc filesystems on non-x86 linux platforms
  - added ${misc:Depends} to Depends lines to satisfy lintian
  - Added debian/README.source to satisfy lintian 
  - Bumped standards version to 3.8.3

[ Gerald Carter ]
* New upstream release. (LP: #538616)
* likewise-open.install: Include uninstalled binaries and ncalrpc
    servers required for domainjoin-cli {join,leave}
* patches/version-in-share.diff:
  - Corrected location of VERSION file in lsassd

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 
31
31
#include "domainjoin.h"
32
32
#include "djfirewall.h"
 
33
#include "djauditing.h"
33
34
#include "djdistroinfo.h"
34
35
#include "djauthconf.h"
35
36
#include "djauthinfo.h"
115
116
    )
116
117
{
117
118
    PSTR buffer = NULL;
118
 
 
 
119
    PCSTR symbol = NULL;
 
120
    PCSTR description = "Unknown error";
 
121
    DWORD err = CENTERROR_DOMAINJOIN_LSASS_ERROR;
119
122
    size_t bufferSize;
 
123
 
 
124
    symbol = LwWin32ExtErrorToName(code);
 
125
    if (symbol == NULL)
 
126
    {
 
127
        symbol = "Unknown";
 
128
    }
 
129
 
120
130
    bufferSize = LwGetErrorString(code, NULL, 0);
121
131
    LW_CLEANUP_CTERR(dest, CTAllocateMemory(bufferSize, PPCAST(&buffer)));
122
132
    if (LwGetErrorString(code, buffer, bufferSize) == bufferSize && bufferSize > 0 && strlen(buffer) > 0)
123
133
    {
124
 
        DWORD err = CENTERROR_DOMAINJOIN_LSASS_ERROR;
125
 
 
126
 
        switch (code)
127
 
        {
128
 
            case LW_ERROR_FAILED_TO_LOOKUP_DC:
129
 
                err = CENTERROR_DOMAINJOIN_UNRESOLVED_DOMAIN_NAME;
130
 
                break;
131
 
        }
132
 
 
133
 
        LWRaiseEx(dest, err, file, line, "Lsass Error", "0x%X - %s", code, buffer);
134
 
        if (dest != NULL)
135
 
        {
136
 
            (*dest)->subcode = code;
137
 
        }
138
 
        goto cleanup;
139
 
    }
140
 
 
141
 
    LWRaiseEx(dest, CENTERROR_DOMAINJOIN_LSASS_ERROR, file, line, "Unable to convert lsass error", "Lsass error code 0x%X has occurred, but an error string cannot be retrieved", code);
 
134
        description = buffer;
 
135
    }
 
136
 
 
137
    switch (code)
 
138
    {
 
139
        case LW_ERROR_FAILED_TO_LOOKUP_DC:
 
140
            err = CENTERROR_DOMAINJOIN_UNRESOLVED_DOMAIN_NAME;
 
141
            break;
 
142
    }
 
143
 
 
144
    LWRaiseEx(dest, err, file, line, "Lsass Error", "%d (0x%X) %s - %s", code, code, symbol, description);
142
145
    if (dest != NULL)
143
146
    {
144
147
        (*dest)->subcode = code;
814
817
{
815
818
    PSTR pszCanonicalizedOU = NULL;
816
819
    ModuleState *state = DJGetModuleStateByName(options, "join");
817
 
    BOOLEAN bNoTimeSyncFileExists = FALSE;
818
820
 
819
821
    if (!IsNullOrEmptyString(getenv("LD_LIBRARY_PATH")) ||
820
822
        !IsNullOrEmptyString(getenv("LD_PRELOAD")))
836
838
        pszCanonicalizedOU = NULL;
837
839
    }
838
840
 
839
 
    LW_CLEANUP_CTERR(exc, CTCheckFileExists(NO_TIME_SYNC_FILE,
840
 
                &bNoTimeSyncFileExists));
841
 
 
842
 
    if (options->disableTimeSync && !bNoTimeSyncFileExists)
843
 
    {
844
 
        /* Create no time sync file */
845
 
        FILE* noTimeSyncFile = NULL;
846
 
 
847
 
        LW_CLEANUP_CTERR(exc, CTOpenFile(NO_TIME_SYNC_FILE,
848
 
                    "w", &noTimeSyncFile));
849
 
 
850
 
        CTCloseFile(noTimeSyncFile);
851
 
    }
852
 
    else if (!options->disableTimeSync && bNoTimeSyncFileExists)
853
 
    {
854
 
        /* Remove no time sync file */
855
 
        LW_CLEANUP_CTERR(exc, CTRemoveFile(NO_TIME_SYNC_FILE));
856
 
    }
857
 
 
 
841
    LW_TRY(exc, SetLsassTimeSync("", !options->disableTimeSync, &LW_EXC));
858
842
 
859
843
    LW_TRY(exc, DJCreateComputerAccount(&options->shortDomainName, options, &LW_EXC));
860
844
 
1008
992
{
1009
993
    DWORD _err = 0;
1010
994
 
1011
 
    LW_CLEANUP_LSERR(exc, LWNetExtendEnvironmentForKrb5Affinity(FALSE));
 
995
    LW_CLEANUP_LSERR(exc, LWNetExtendEnvironmentForKrb5Affinity(TRUE));
1012
996
 
1013
997
    _err = LsaGetComputerDN(dn);
1014
998
    if(_err)
1173
1157
       LW_CLEANUP_CTERR(exc, CTMapSystemError(errno));
1174
1158
    }
1175
1159
 
1176
 
    LW_CLEANUP_LSERR(exc, LWNetExtendEnvironmentForKrb5Affinity(FALSE));
 
1160
    LW_CLEANUP_LSERR(exc, LWNetExtendEnvironmentForKrb5Affinity(TRUE));
1177
1161
 
1178
1162
    if ( options->disableTimeSync )
1179
1163
    {
1642
1626
 
1643
1627
    return;
1644
1628
}
 
1629
 
 
1630
void SetLsassTimeSync(PCSTR rootPrefix, BOOLEAN sync, LWException **exc)
 
1631
{
 
1632
    DWORD dwSync = sync;
 
1633
    HANDLE hReg = (HANDLE)NULL;
 
1634
    HKEY pAdKey = NULL;
 
1635
    HANDLE lsa = NULL;
 
1636
 
 
1637
    LW_CLEANUP_LSERR(exc, RegOpenServer(&hReg));
 
1638
    LW_CLEANUP_LSERR(exc, RegOpenKeyExA(
 
1639
                hReg,
 
1640
                NULL,
 
1641
                HKEY_THIS_MACHINE "\\Services\\lsass\\Parameters\\Providers\\ActiveDirectory",
 
1642
                0,
 
1643
                KEY_ALL_ACCESS,
 
1644
                &pAdKey));
 
1645
 
 
1646
    LW_CLEANUP_LSERR(exc, RegSetValueExA(
 
1647
                hReg,
 
1648
                pAdKey,
 
1649
                "SyncSystemTime",
 
1650
                0,
 
1651
                REG_DWORD,
 
1652
                &dwSync,
 
1653
                sizeof(dwSync)));
 
1654
 
 
1655
    LW_CLEANUP_LSERR(exc, LsaOpenServer(&lsa));
 
1656
    LW_CLEANUP_LSERR(exc, LsaRefreshConfiguration(lsa));
 
1657
 
 
1658
cleanup:
 
1659
    if (lsa)
 
1660
    {
 
1661
        LsaCloseServer(lsa);
 
1662
    }
 
1663
    RegCloseKey(hReg, pAdKey);
 
1664
    RegCloseServer(hReg);
 
1665
    return;
 
1666
}