STABLE14-windows-cumulative-20041017

Cummulative update of changes including:

  * Add code to block the issuance of AFS tokens by aklog.exe or
    afscreds.exe when the Kerberos 5 principal name contains a dot.

  * Modify the IsAdmin() function to always treat the local SYSTEM
    account as an AFS client administrator.  Affects fs.exe and
    afs_config.exe.

  * Modify the internal handling of Quota Exceeded errors

  * Upgrade all reference count fields in the Windows cache manager
    and the osi library to use unsigned long instead of signed short.
    A similar fix has been applied to the afs rpc (rx) library.

  * fix the Windows cache manager to prevent it from replacing the
    rx_connection object associated with the cm_conn_t object on each
    and every operation if "fs crypt" was set.  This explains the
    dramatic performance difference when crypt is used vs clear.
    The problem: 'cryptall', a boolean flag indicating whether or not
    "fs crypt" is set, was being compared to the rx_connection
    cryptlevel which is either rxkad_clear:0 or rxkad_crypt:2.
    1 != 2 and therefore the rx_connection was always destroyed
    and replaced on each and every operation.

    Lock the cm_conn_t object around every call to RXAFS_xxxx functions.
    It is not safe for the cm_conn_t object to not be locked because
    rx_DestroyConnection might be called from another thread if:
        - the user's tokens have changed or expired
        - the crypt mode has changed

    This fix appears to have also taken care of the problems associated
    with Overlapped Writes resulting in Delayed Write errors.

  * fix NSIS installer's AdminGroup.exe to properly create and
    remove groups when given -create or -remove.  The string comparison
    test was wrong.

  * fs sysname now accepts a list of sysname values

  * added a new registry value HKLM\SOFTWARE\OpenAFS\Client "IoctlDebug"
    DWORD which when set to a non-zero value will cause error message
    text to be output to stderr from the pioctl() routine.  Useful in
    debugging failures of fs.exe, tokens.exe, etc.

  * added a test to the power management code to only perform a
    flush operation if there is at least one network adapter which
    is not a loopback adapter.

  * Fix bug in loading of registry value HKLM\SOFTWARE\OpenAFS\Client
    "EnableKFW".  This value will not be read if the key
    HKCU\SOFTWARE\OpenAFS\Client exists; even if the "EnableKFW"
    value under that key does not.

  * provide mechanisms to force the use of krb524d for Kerberos 5
    ticket to AFS token conversion.  For afslogon.dll and afscreds.exe
    there is a new registry value "Use524" and for aklog.exe a new
    command line parameter "-m".

  * Fix the pattern matching algorithm to properly match patterns
    ending with a '*'.

  * smb_ReceiveCoreRename() was factored to produce smb_Rename()
    which is used by both the original function and the new
    smb_ReceiveNTRename().  smb_ReceiveNTRename() supports the
    creation of HardLinks in addition to Renaming.  smb_Link()
    is a new function which creates HardLinks via cm_Link().
    cm_Link() is a new vnodeops function which creates links
    using RXAFS_Link().

    smb_ReceiveNTRename() does not support the File Copy and
    Move Cluster Information operations described in its interface.
    ReceiveNTRename is under documented in CIFS-TR-1p00_FINAL.pdf.

  * When opening files via symlinks, we should follow the symlinks
    until we reach the actual file stat cache entry.  The stat cache
    entry of the file should then be stored in the FID instead of
    stat scache entry of the symlink.

  * return bad operation errors for all unimplemented functions
    even if we do not know the functions exist.

  * Log bad packets and unknown operation packets to the trace log

  * Map CM_ERROR_BADOP to STATUS_NOT_SUPPORTED instead of
    0xC09820FF

  * Update list of known CIFS operations to include all those listed
    in CIFS-TR-1p00_FINAL.pdf.

  * Modify the handling of HKLM\SOFTWARE\OpenAFS\Client\Submounts
    to support the REG_EXPAND_SZ type.
This commit is contained in:
Jeffrey Altman 2004-10-18 05:09:25 +00:00 committed by Jeffrey Altman
parent 655344ea8f
commit 9ea40ebfb7
30 changed files with 6243 additions and 6044 deletions

View File

@ -373,7 +373,7 @@ int afsd_InitCM(char **reasonP)
static struct rx_securityClass *nullServerSecurityClassp;
struct hostent *thp;
char *msgBuf;
char buf[200];
char buf[1024];
HKEY parmKey;
DWORD dummyLen;
DWORD regType;
@ -645,15 +645,37 @@ int afsd_InitCM(char **reasonP)
}
cm_sysName = cm_sysNameList[0];
dummyLen = MAXSYSNAME;
code = RegQueryValueEx(parmKey, "SysName", NULL, NULL, cm_sysName, &dummyLen);
if (code == ERROR_SUCCESS)
afsi_log("Sys name %s", cm_sysName);
else {
dummyLen = sizeof(buf);
code = RegQueryValueEx(parmKey, "SysName", NULL, NULL, buf, &dummyLen);
if (code == ERROR_SUCCESS && buf[0]) {
char * p, *q;
afsi_log("Sys name %s", buf);
for (p = q = buf; p < cm_sysName + dummyLen; p++)
{
if (*p == '\0' || isspace(*p)) {
memcpy(cm_sysNameList[cm_sysNameCount],q,p-q);
cm_sysNameList[cm_sysNameCount][p-q] = '\0';
cm_sysNameCount++;
do {
if (*p == '\0')
goto done_sysname;
p++;
} while (*p == '\0' || isspace(*p));
q = p;
p--;
}
}
done_sysname:
StringCbCopyA(cm_sysName, MAXSYSNAME, cm_sysNameList[0]);
} else {
cm_sysNameCount = 1;
StringCbCopyA(cm_sysName, MAXSYSNAME, "i386_nt40");
StringCbCopyA(cm_sysNameList[0], MAXSYSNAME, "i386_nt40");
afsi_log("Default sys name %s", cm_sysName);
}
cm_sysNameCount = 1;
dummyLen = sizeof(cryptall);
code = RegQueryValueEx(parmKey, "SecurityLevel", NULL, NULL,

View File

@ -55,6 +55,8 @@ jmp_buf notifier_jmp;
extern int traceOnPanic;
extern HANDLE afsi_file;
int powerEventsRegistered = 0;
/*
* Notifier function for use by osi_panic
*/
@ -271,32 +273,34 @@ afsd_ServiceControlHandlerEx(
** Return any error code to deny request,
** i.e. as if returning BROADCAST_QUERY_DENY
*/
switch((int) dwEventType)
{
case PBT_APMQUERYSUSPEND:
case PBT_APMQUERYSTANDBY:
if (powerEventsRegistered) {
switch((int) dwEventType)
{
case PBT_APMQUERYSUSPEND:
case PBT_APMQUERYSTANDBY:
#ifdef FLUSH_VOLUME
/* handle event */
dwRet = afsd_ServiceFlushVolume((DWORD) lpEventData);
/* handle event */
dwRet = afsd_ServiceFlushVolume((DWORD) lpEventData);
#else
dwRet = NO_ERROR;
dwRet = NO_ERROR;
#endif
break;
break;
/* allow remaining case PBT_WhatEver */
case PBT_APMSUSPEND:
case PBT_APMSTANDBY:
case PBT_APMRESUMECRITICAL:
case PBT_APMRESUMESUSPEND:
case PBT_APMRESUMESTANDBY:
case PBT_APMBATTERYLOW:
case PBT_APMPOWERSTATUSCHANGE:
case PBT_APMOEMEVENT:
case PBT_APMRESUMEAUTOMATIC:
default:
dwRet = NO_ERROR;
}
/* allow remaining case PBT_WhatEver */
case PBT_APMSUSPEND:
case PBT_APMSTANDBY:
case PBT_APMRESUMECRITICAL:
case PBT_APMRESUMESUSPEND:
case PBT_APMRESUMESTANDBY:
case PBT_APMBATTERYLOW:
case PBT_APMPOWERSTATUSCHANGE:
case PBT_APMOEMEVENT:
case PBT_APMRESUMEAUTOMATIC:
default:
dwRet = NO_ERROR;
}
}
}
} /* end switch(ctrlCode) */
return dwRet;
@ -308,7 +312,7 @@ afsd_ServiceControlHandlerEx(
*/
/* DEE Could check first if we are run as SYSTEM */
#define MAX_RETRIES 30
static void MountGlobalDrives()
static void MountGlobalDrives(void)
{
char szAfsPath[_MAX_PATH];
char szDriveToMapTo[5];
@ -492,8 +496,30 @@ void afsd_Main(DWORD argc, LPTSTR *argv)
}
#ifdef REGISTER_POWER_NOTIFICATIONS
/* create thread used to flush cache */
PowerNotificationThreadCreate();
{
HKEY hkParm;
DWORD code;
DWORD dummyLen;
int bpower = TRUE;
/* see if we should handle power notifications */
code = RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSConfigKeyName, 0, KEY_QUERY_VALUE, &hkParm);
if (code == ERROR_SUCCESS) {
dummyLen = sizeof(bpower);
code = RegQueryValueEx(hkParm, "FlushOnHibernate", NULL, NULL,
(BYTE *) &bpower, &dummyLen);
if(code != ERROR_SUCCESS)
bpower = TRUE;
RegCloseKey(hkParm);
}
/* create thread used to flush cache */
if (bpower) {
PowerNotificationThreadCreate();
powerEventsRegistered = 1;
}
}
#endif
/* allow an exit to be called prior to any initialization */
@ -609,7 +635,8 @@ void afsd_Main(DWORD argc, LPTSTR *argv)
#ifdef REGISTER_POWER_NOTIFICATIONS
/* terminate thread used to flush cache */
PowerNotificationThreadExit();
if (powerEventsRegistered)
PowerNotificationThreadExit();
#endif
/* Remove the ExceptionFilter */

View File

@ -927,11 +927,11 @@ KFW_import_windows_lsa(void)
princ_realm = krb5_princ_realm(ctx, princ);
for ( i=0; i<princ_realm->length; i++ ) {
realm[i] = princ_realm->data[i];
realm[i] = princ_realm->data[i];
cell[i] = tolower(princ_realm->data[i]);
}
cell[i] = '\0';
realm[i] = '\0';
cell[i] = '\0';
realm[i] = '\0';
code = KFW_AFS_klog(ctx, cc, "afs", cell, realm, pLeash_get_default_lifetime(),NULL);
if ( IsDebuggerPresent() ) {
@ -2583,10 +2583,10 @@ KFW_AFS_klog(
memset(ServiceName, '\0', sizeof(ServiceName));
memset(realm_of_user, '\0', sizeof(realm_of_user));
memset(realm_of_cell, '\0', sizeof(realm_of_cell));
if (cell && cell[0])
strcpy(Dmycell, cell);
else
memset(Dmycell, '\0', sizeof(Dmycell));
if (cell && cell[0])
strcpy(Dmycell, cell);
else
memset(Dmycell, '\0', sizeof(Dmycell));
// NULL or empty cell returns information on local cell
if (rc = KFW_AFS_get_cellconfig(Dmycell, &ak_cellconfig, local_cell))
@ -2612,13 +2612,21 @@ KFW_AFS_klog(
memset((char *)&increds, 0, sizeof(increds));
code = pkrb5_cc_get_principal(ctx, cc, &client_principal);
if (code) {
if (code) {
if ( code == KRB5_CC_NOTFOUND && IsDebuggerPresent() )
{
OutputDebugString("Principal Not Found for ccache\n");
}
goto skip_krb5_init;
}
if ( strchr(krb5_princ_component(ctx,client_principal,0),'.') != NULL )
{
OutputDebugString("Illegal Principal name contains dot in first component\n");
rc = KRB5KRB_ERR_GENERIC;
goto cleanup;
}
i = krb5_princ_realm(ctx, client_principal)->length;
if (i > REALM_SZ-1)
i = REALM_SZ-1;

View File

@ -72,7 +72,7 @@ typedef struct cm_buf {
*/
struct cm_buf *allp; /* next in all list */
osi_mutex_t mx; /* mutex protecting structure except refcount */
int refCount; /* reference count (buf_globalLock) */
unsigned long refCount; /* reference count (buf_globalLock) */
long idCounter; /* counter for softrefs; bumped at each recycle */
long dirtyCounter; /* bumped at each dirty->clean transition */
#ifdef notdef

View File

@ -808,6 +808,7 @@ long cm_GetCallback(cm_scache_t *scp, struct cm_user *userp,
int mustCall;
long sflags;
cm_fid_t sfid;
struct rx_connection * callp;
osi_Log2(afsd_logp, "GetCallback scp %x flags %lX", scp, flags);
@ -871,10 +872,11 @@ long cm_GetCallback(cm_scache_t *scp, struct cm_user *userp,
code = cm_Conn(&sfid, userp, reqp, &connp);
if (code) continue;
lock_ObtainMutex(&connp->mx);
code = RXAFS_FetchStatus(connp->callp, &tfid,
callp = cm_GetRxConn(connp);
code = RXAFS_FetchStatus(callp, &tfid,
&afsStatus, &callback, &volSync);
lock_ReleaseMutex(&connp->mx);
rx_PutConnection(callp);
} while (cm_Analyze(connp, userp, reqp, &sfid, &volSync, NULL,
&cbr, code));
code = cm_MapRPCError(code, reqp);

View File

@ -565,7 +565,7 @@ long cm_ConnByServer(cm_server_t *serverp, cm_user_t *userp, cm_conn_t **connpp)
tcp->refCount = 1;
lock_ReleaseMutex(&tcp->mx);
} else {
if ((tcp->ucgen < ucellp->gen) ||
if ((tcp->ucgen < ucellp->gen) ||
(tcp->cryptlevel != (cryptall ? rxkad_crypt : rxkad_clear)))
{
lock_ObtainMutex(&tcp->mx);
@ -602,3 +602,15 @@ long cm_Conn(struct cm_fid *fidp, struct cm_user *userp, cm_req_t *reqp,
cm_FreeServerList(serverspp);
return code;
}
extern struct rx_connection *
cm_GetRxConn(cm_conn_t *connp)
{
struct rx_connection * rxconn;
lock_ObtainMutex(&connp->mx);
rxconn = connp->callp;
rx_GetConnection(rxconn);
lock_ReleaseMutex(&connp->mx);
return rxconn;
}

View File

@ -23,7 +23,7 @@ typedef struct cm_conn {
struct rx_connection *callp; /* locked by mx */
struct cm_user *userp; /* locked by mx; a held reference */
osi_mutex_t mx; /* mutex for some of these fields */
int refCount; /* locked by cm_connLock */
unsigned long refCount; /* locked by cm_connLock */
int ucgen; /* ucellp's generation number */
long flags; /* locked by mx */
int cryptlevel; /* encrytion status */
@ -83,6 +83,7 @@ typedef struct cm_req {
cache managers treat it as "server is down"*/
#include "cm_server.h"
#include "rx.h"
extern void cm_InitConn(void);
@ -106,4 +107,6 @@ extern void cm_PutConn(cm_conn_t *connp);
extern void cm_GCConnections(cm_server_t *serverp);
extern struct rx_connection * cm_GetRxConn(cm_conn_t *connp);
#endif /* __CM_CONN_H_ENV__ */

View File

@ -129,12 +129,13 @@ long cm_BufWrite(void *vfidp, osi_hyper_t *offsetp, long length, long flags,
if (code)
continue;
lock_ObtainMutex(&connp->mx);
callp = rx_NewCall(connp->callp);
lock_ReleaseMutex(&connp->mx);
osi_Log3(afsd_logp, "CALL StoreData vp %x, off 0x%x, size 0x%x",
(long) scp, biod.offset.LowPart, nbytes);
lock_ObtainMutex(&connp->mx);
code = StartRXAFS_StoreData(callp, &tfid, &inStatus,
biod.offset.LowPart, nbytes, truncPos);
@ -174,8 +175,6 @@ long cm_BufWrite(void *vfidp, osi_hyper_t *offsetp, long length, long flags,
osi_Log1(afsd_logp, "EndRXAFS_StoreData failed (%lX)",code);
}
code = rx_EndCall(callp, code);
lock_ReleaseMutex(&connp->mx);
osi_Log0(afsd_logp, "CALL StoreData DONE");
} while (cm_Analyze(connp, userp, reqp, &scp->fid, &volSync, NULL, NULL, code));
@ -263,9 +262,10 @@ long cm_StoreMini(cm_scache_t *scp, cm_user_t *userp, cm_req_t *reqp)
if (code)
continue;
callp = rx_NewCall(connp->callp);
lock_ObtainMutex(&connp->mx);
callp = rx_NewCall(connp->callp);
lock_ReleaseMutex(&connp->mx);
code = StartRXAFS_StoreData(callp, &tfid, &inStatus,
0, 0, truncPos);
@ -273,8 +273,6 @@ long cm_StoreMini(cm_scache_t *scp, cm_user_t *userp, cm_req_t *reqp)
code = EndRXAFS_StoreData(callp, &outStatus, &volSync);
code = rx_EndCall(callp, code);
lock_ReleaseMutex(&connp->mx);
} while (cm_Analyze(connp, userp, reqp, &scp->fid, &volSync, NULL, NULL, code));
code = cm_MapRPCError(code, reqp);
@ -1241,6 +1239,7 @@ long cm_GetBuffer(cm_scache_t *scp, cm_buf_t *bufp, int *cpffp, cm_user_t *up,
lock_ObtainMutex(&connp->mx);
callp = rx_NewCall(connp->callp);
lock_ReleaseMutex(&connp->mx);
osi_Log3(afsd_logp, "CALL FetchData vp %x, off 0x%x, size 0x%x",
(long) scp, biod.offset.LowPart, biod.length);
@ -1353,8 +1352,6 @@ long cm_GetBuffer(cm_scache_t *scp, cm_buf_t *bufp, int *cpffp, cm_user_t *up,
osi_Log0(afsd_logp, "CALL EndCall returns RXKADUNKNOWNKEY");
osi_Log0(afsd_logp, "CALL FetchData DONE");
lock_ReleaseMutex(&connp->mx);
} while (cm_Analyze(connp, up, reqp, &scp->fid, &volSync, NULL, NULL, code));
fetchingcompleted:

View File

@ -51,7 +51,7 @@ typedef struct cm_diskcache {
int openfd; /* open file descriptor */
struct cm_diskcache *hash_next;
struct cm_diskcache *hash_prev;
int refCount;
unsigned long refCount;
osi_mutex_t mx;
} cm_diskcache_t;

View File

@ -30,7 +30,7 @@ cm_localMountPoint_t* cm_localMountPoints;
osi_mutex_t cm_Freelance_Lock;
int cm_localMountPointChangeFlag = 0;
int cm_freelanceEnabled = 0;
afs_uint32 FakeFreelanceModTime = 0x3b49f6e2;
time_t FakeFreelanceModTime = 0x3b49f6e2;
void cm_InitFakeRootDir();
@ -81,23 +81,23 @@ void cm_InitFreelance() {
int lpid;
#endif
lock_InitializeMutex(&cm_Freelance_Lock, "Freelance Lock");
lock_InitializeMutex(&cm_Freelance_Lock, "Freelance Lock");
// yj: first we make a call to cm_initLocalMountPoints
// to read all the local mount points from an ini file
cm_InitLocalMountPoints();
// yj: first we make a call to cm_initLocalMountPoints
// to read all the local mount points from an ini file
cm_InitLocalMountPoints();
// then we make a call to InitFakeRootDir to create
// a fake root directory based on the local mount points
cm_InitFakeRootDir();
// --- end of yj code
// then we make a call to InitFakeRootDir to create
// a fake root directory based on the local mount points
cm_InitFakeRootDir();
// --- end of yj code
#if !defined(DJGPP)
/* Start the registry monitor */
phandle = thrd_Create(NULL, 65536, (ThreadFunc) cm_FreelanceChangeNotifier,
NULL, 0, &lpid, "cm_FreelanceChangeNotifier");
osi_assert(phandle != NULL);
thrd_CloseHandle(phandle);
osi_assert(phandle != NULL);
thrd_CloseHandle(phandle);
#endif
}
@ -105,186 +105,186 @@ void cm_InitFreelance() {
/* to be called while holding freelance lock unless during init. */
void cm_InitFakeRootDir() {
int i, t1, t2;
char* currentPos;
int noChunks;
int i, t1, t2;
char* currentPos;
int noChunks;
// allocate space for the fake info
cm_dirHeader_t fakeDirHeader;
cm_dirEntry_t fakeEntry;
cm_pageHeader_t fakePageHeader;
// allocate space for the fake info
cm_dirHeader_t fakeDirHeader;
cm_dirEntry_t fakeEntry;
cm_pageHeader_t fakePageHeader;
// i'm going to calculate how much space is needed for
// this fake root directory. we have these rules:
// 1. there are cm_noLocalMountPoints number of entries
// 2. each page is CM_DIR_PAGESIZE in size
// 3. the first 13 chunks of the first page are used for
// some header stuff
// 4. the first chunk of all subsequent pages are used
// for page header stuff
// 5. a max of CM_DIR_EPP entries are allowed per page
// 6. each entry takes 1 or more chunks, depending on
// the size of the mount point string, as determined
// by cm_NameEntries
// 7. each chunk is CM_DIR_CHUNKSIZE bytes
// i'm going to calculate how much space is needed for
// this fake root directory. we have these rules:
// 1. there are cm_noLocalMountPoints number of entries
// 2. each page is CM_DIR_PAGESIZE in size
// 3. the first 13 chunks of the first page are used for
// some header stuff
// 4. the first chunk of all subsequent pages are used
// for page header stuff
// 5. a max of CM_DIR_EPP entries are allowed per page
// 6. each entry takes 1 or more chunks, depending on
// the size of the mount point string, as determined
// by cm_NameEntries
// 7. each chunk is CM_DIR_CHUNKSIZE bytes
int CPP = CM_DIR_PAGESIZE / CM_DIR_CHUNKSIZE;
int curChunk = 13; // chunks 0 - 12 are used for header stuff
// of the first page in the directory
int curPage = 0;
int curDirEntry = 0;
int curDirEntryInPage = 0;
int sizeOfCurEntry;
int dirSize;
int CPP = CM_DIR_PAGESIZE / CM_DIR_CHUNKSIZE;
int curChunk = 13; // chunks 0 - 12 are used for header stuff
// of the first page in the directory
int curPage = 0;
int curDirEntry = 0;
int curDirEntryInPage = 0;
int sizeOfCurEntry;
int dirSize;
/* Reserve 2 directory chunks for "." and ".." */
curChunk += 2;
/* Reserve 2 directory chunks for "." and ".." */
curChunk += 2;
while (curDirEntry!=cm_noLocalMountPoints) {
sizeOfCurEntry = cm_NameEntries((cm_localMountPoints+curDirEntry)->namep, 0);
if ((curChunk + sizeOfCurEntry >= CPP) ||
(curDirEntryInPage + 1 >= CM_DIR_EPP)) {
curPage++;
curDirEntryInPage = 0;
curChunk = 1;
}
curChunk += sizeOfCurEntry;
curDirEntry++;
curDirEntryInPage++;
}
while (curDirEntry!=cm_noLocalMountPoints) {
sizeOfCurEntry = cm_NameEntries((cm_localMountPoints+curDirEntry)->namep, 0);
if ((curChunk + sizeOfCurEntry >= CPP) ||
(curDirEntryInPage + 1 >= CM_DIR_EPP)) {
curPage++;
curDirEntryInPage = 0;
curChunk = 1;
}
curChunk += sizeOfCurEntry;
curDirEntry++;
curDirEntryInPage++;
}
dirSize = (curPage+1) * CM_DIR_PAGESIZE;
cm_FakeRootDir = malloc(dirSize);
cm_fakeDirSize = dirSize;
dirSize = (curPage+1) * CM_DIR_PAGESIZE;
cm_FakeRootDir = malloc(dirSize);
cm_fakeDirSize = dirSize;
// yj: when we get here, we've figured out how much memory we need and
// allocated the appropriate space for it. we now prceed to fill
// it up with entries.
curPage = 0;
curDirEntry = 0;
curDirEntryInPage = 0;
curChunk = 0;
// fields in the directory entry that are unused.
fakeEntry.flag = 1;
fakeEntry.length = 0;
fakeEntry.next = 0;
fakeEntry.fid.unique = htonl(1);
// yj: when we get here, we've figured out how much memory we need and
// allocated the appropriate space for it. we now prceed to fill
// it up with entries.
curPage = 0;
curDirEntry = 0;
curDirEntryInPage = 0;
curChunk = 0;
// the first page is special, it uses fakeDirHeader instead of fakePageHeader
// we fill up the page with dirEntries that belong there and we make changes
// to the fakeDirHeader.header.freeBitmap along the way. Then when we're done
// filling up the dirEntries in this page, we copy the fakeDirHeader into
// the top of the page.
// fields in the directory entry that are unused.
fakeEntry.flag = 1;
fakeEntry.length = 0;
fakeEntry.next = 0;
fakeEntry.fid.unique = htonl(1);
// init the freeBitmap array
for (i=0; i<8; i++)
fakeDirHeader.header.freeBitmap[i]=0;
// the first page is special, it uses fakeDirHeader instead of fakePageHeader
// we fill up the page with dirEntries that belong there and we make changes
// to the fakeDirHeader.header.freeBitmap along the way. Then when we're done
// filling up the dirEntries in this page, we copy the fakeDirHeader into
// the top of the page.
fakeDirHeader.header.freeBitmap[0] = 0xff;
fakeDirHeader.header.freeBitmap[1] = 0x7f;
// init the freeBitmap array
for (i=0; i<8; i++)
fakeDirHeader.header.freeBitmap[i]=0;
// we start counting at 13 because the 0th to 12th chunks are used for header
curChunk = 13;
fakeDirHeader.header.freeBitmap[0] = 0xff;
fakeDirHeader.header.freeBitmap[1] = 0x7f;
// stick the first 2 entries "." and ".." in
fakeEntry.fid.unique = htonl(1);
fakeEntry.fid.vnode = htonl(1);
strcpy(fakeEntry.name, ".");
currentPos = cm_FakeRootDir + curPage * CM_DIR_PAGESIZE + curChunk * CM_DIR_CHUNKSIZE;
memcpy(currentPos, &fakeEntry, CM_DIR_CHUNKSIZE);
curChunk++; curDirEntryInPage++;
strcpy(fakeEntry.name, "..");
currentPos = cm_FakeRootDir + curPage * CM_DIR_PAGESIZE + curChunk * CM_DIR_CHUNKSIZE;
memcpy(currentPos, &fakeEntry, CM_DIR_CHUNKSIZE);
curChunk++; curDirEntryInPage++;
// keep putting stuff into page 0 if
// 1. we're not done with all entries
// 2. we have less than CM_DIR_EPP entries in page 0
// 3. we're not out of chunks in page 0
// we start counting at 13 because the 0th to 12th chunks are used for header
curChunk = 13;
while( (curDirEntry!=cm_noLocalMountPoints) &&
(curDirEntryInPage < CM_DIR_EPP) &&
(curChunk + cm_NameEntries((cm_localMountPoints+curDirEntry)->namep, 0) <= CPP))
{
// stick the first 2 entries "." and ".." in
fakeEntry.fid.unique = htonl(1);
fakeEntry.fid.vnode = htonl(1);
strcpy(fakeEntry.name, ".");
currentPos = cm_FakeRootDir + curPage * CM_DIR_PAGESIZE + curChunk * CM_DIR_CHUNKSIZE;
memcpy(currentPos, &fakeEntry, CM_DIR_CHUNKSIZE);
curChunk++; curDirEntryInPage++;
strcpy(fakeEntry.name, "..");
currentPos = cm_FakeRootDir + curPage * CM_DIR_PAGESIZE + curChunk * CM_DIR_CHUNKSIZE;
memcpy(currentPos, &fakeEntry, CM_DIR_CHUNKSIZE);
curChunk++; curDirEntryInPage++;
noChunks = cm_NameEntries((cm_localMountPoints+curDirEntry)->namep, 0);
fakeEntry.fid.vnode = htonl(curDirEntry + 2);
currentPos = cm_FakeRootDir + curPage * CM_DIR_PAGESIZE + curChunk * CM_DIR_CHUNKSIZE;
// keep putting stuff into page 0 if
// 1. we're not done with all entries
// 2. we have less than CM_DIR_EPP entries in page 0
// 3. we're not out of chunks in page 0
memcpy(currentPos, &fakeEntry, CM_DIR_CHUNKSIZE);
strcpy(currentPos + 12, (cm_localMountPoints+curDirEntry)->namep);
curDirEntry++;
curDirEntryInPage++;
for (i=0; i<noChunks; i++) {
t1 = (curChunk + i) / 8;
t2 = curChunk + i - (t1*8);
fakeDirHeader.header.freeBitmap[t1] |= (1 << t2);
}
curChunk+=noChunks;
}
while( (curDirEntry!=cm_noLocalMountPoints) &&
(curDirEntryInPage < CM_DIR_EPP) &&
(curChunk + cm_NameEntries((cm_localMountPoints+curDirEntry)->namep, 0) <= CPP))
{
// when we get here, we're done with filling in the entries for page 0
// copy in the header info
noChunks = cm_NameEntries((cm_localMountPoints+curDirEntry)->namep, 0);
fakeEntry.fid.vnode = htonl(curDirEntry + 2);
currentPos = cm_FakeRootDir + curPage * CM_DIR_PAGESIZE + curChunk * CM_DIR_CHUNKSIZE;
memcpy(cm_FakeRootDir, &fakeDirHeader, 13 * CM_DIR_CHUNKSIZE);
memcpy(currentPos, &fakeEntry, CM_DIR_CHUNKSIZE);
strcpy(currentPos + 12, (cm_localMountPoints+curDirEntry)->namep);
curDirEntry++;
curDirEntryInPage++;
for (i=0; i<noChunks; i++) {
t1 = (curChunk + i) / 8;
t2 = curChunk + i - (t1*8);
fakeDirHeader.header.freeBitmap[t1] |= (1 << t2);
}
curChunk+=noChunks;
}
curPage++;
// when we get here, we're done with filling in the entries for page 0
// copy in the header info
// ok, page 0's done. Move on to the next page.
while (curDirEntry!=cm_noLocalMountPoints) {
// setup a new page
curChunk = 1; // the zeroth chunk is reserved for page header
curDirEntryInPage = 0;
for (i=0; i<8; i++) {
fakePageHeader.freeBitmap[i]=0;
}
fakePageHeader.freeCount = 0;
fakePageHeader.pgcount = 0;
fakePageHeader.tag = htons(1234);
// while we're on the same page...
while ( (curDirEntry!=cm_noLocalMountPoints) &&
(curDirEntryInPage < CM_DIR_EPP) &&
(curChunk + cm_NameEntries((cm_localMountPoints+curDirEntry)->namep, 0) <= CPP))
{
// add an entry to this page
memcpy(cm_FakeRootDir, &fakeDirHeader, 13 * CM_DIR_CHUNKSIZE);
noChunks = cm_NameEntries((cm_localMountPoints+curDirEntry)->namep, 0);
fakeEntry.fid.vnode=htonl(curDirEntry+2);
currentPos = cm_FakeRootDir + curPage * CM_DIR_PAGESIZE + curChunk * CM_DIR_CHUNKSIZE;
memcpy(currentPos, &fakeEntry, CM_DIR_CHUNKSIZE);
strcpy(currentPos + 12, (cm_localMountPoints+curDirEntry)->namep);
curDirEntry++;
curDirEntryInPage++;
for (i=0; i<noChunks; i++) {
t1 = (curChunk + i) / 8;
t2 = curChunk + i - (t1*8);
fakePageHeader.freeBitmap[t1] |= (1 << t2);
}
curChunk+=noChunks;
}
memcpy(cm_FakeRootDir + curPage * CM_DIR_PAGESIZE, &fakePageHeader, sizeof(fakePageHeader));
curPage++;
curPage++;
}
// we know the fakeDir is setup properly, so we claim that we have callback
// ok, page 0's done. Move on to the next page.
while (curDirEntry!=cm_noLocalMountPoints) {
// setup a new page
curChunk = 1; // the zeroth chunk is reserved for page header
curDirEntryInPage = 0;
for (i=0; i<8; i++) {
fakePageHeader.freeBitmap[i]=0;
}
fakePageHeader.freeCount = 0;
fakePageHeader.pgcount = 0;
fakePageHeader.tag = htons(1234);
// while we're on the same page...
while ( (curDirEntry!=cm_noLocalMountPoints) &&
(curDirEntryInPage < CM_DIR_EPP) &&
(curChunk + cm_NameEntries((cm_localMountPoints+curDirEntry)->namep, 0) <= CPP))
{
// add an entry to this page
noChunks = cm_NameEntries((cm_localMountPoints+curDirEntry)->namep, 0);
fakeEntry.fid.vnode=htonl(curDirEntry+2);
currentPos = cm_FakeRootDir + curPage * CM_DIR_PAGESIZE + curChunk * CM_DIR_CHUNKSIZE;
memcpy(currentPos, &fakeEntry, CM_DIR_CHUNKSIZE);
strcpy(currentPos + 12, (cm_localMountPoints+curDirEntry)->namep);
curDirEntry++;
curDirEntryInPage++;
for (i=0; i<noChunks; i++) {
t1 = (curChunk + i) / 8;
t2 = curChunk + i - (t1*8);
fakePageHeader.freeBitmap[t1] |= (1 << t2);
}
curChunk+=noChunks;
}
memcpy(cm_FakeRootDir + curPage * CM_DIR_PAGESIZE, &fakePageHeader, sizeof(fakePageHeader));
curPage++;
}
// we know the fakeDir is setup properly, so we claim that we have callback
osi_Log0(afsd_logp,"cm_InitFakeRootDir fakeDirCallback=1");
cm_fakeDirCallback=1;
cm_fakeDirCallback=1;
// when we get here, we've set up everything! done!
// when we get here, we've set up everything! done!
}
int cm_FakeRootFid(cm_fid_t *fidp)
{
fidp->cell = AFS_FAKE_ROOT_CELL_ID; /* root cell */
fidp->volume = AFS_FAKE_ROOT_VOL_ID; /* root.afs ? */
fidp->vnode = 0x1;
fidp->unique = 0x1;
return 0;
fidp->cell = AFS_FAKE_ROOT_CELL_ID; /* root cell */
fidp->volume = AFS_FAKE_ROOT_VOL_ID; /* root.afs ? */
fidp->vnode = 0x1;
fidp->unique = 0x1;
return 0;
}
/* called directly from ioctl */
@ -307,83 +307,80 @@ int cm_clearLocalMountPointChange() {
}
int cm_reInitLocalMountPoints() {
cm_fid_t aFid;
int i, hash;
cm_scache_t *scp, **lscpp, *tscp;
cm_fid_t aFid;
int i, hash;
cm_scache_t *scp, **lscpp, *tscp;
osi_Log0(afsd_logp,"----- freelance reinitialization starts ----- ");
osi_Log0(afsd_logp,"----- freelance reinitialization starts ----- ");
// first we invalidate all the SCPs that were created
// for the local mount points
// first we invalidate all the SCPs that were created
// for the local mount points
osi_Log0(afsd_logp,"Invalidating local mount point scp... ");
osi_Log0(afsd_logp,"Invalidating local mount point scp... ");
aFid.cell = AFS_FAKE_ROOT_CELL_ID;
aFid.volume=AFS_FAKE_ROOT_VOL_ID;
aFid.unique=0x1;
aFid.vnode=0x2;
aFid.cell = AFS_FAKE_ROOT_CELL_ID;
aFid.volume=AFS_FAKE_ROOT_VOL_ID;
aFid.unique=0x1;
aFid.vnode=0x2;
lock_ObtainWrite(&cm_scacheLock);
lock_ObtainMutex(&cm_Freelance_Lock); /* always scache then freelance lock */
for (i=0; i<cm_noLocalMountPoints; i++) {
hash = CM_SCACHE_HASH(&aFid);
for (scp=cm_hashTablep[hash]; scp; scp=scp->nextp) {
if (scp->fid.volume == aFid.volume &&
scp->fid.vnode == aFid.vnode &&
scp->fid.unique == aFid.unique
) {
lock_ObtainWrite(&cm_scacheLock);
lock_ObtainMutex(&cm_Freelance_Lock); /* always scache then freelance lock */
for (i=0; i<cm_noLocalMountPoints; i++) {
hash = CM_SCACHE_HASH(&aFid);
for (scp=cm_hashTablep[hash]; scp; scp=scp->nextp) {
if (scp->fid.volume == aFid.volume &&
scp->fid.vnode == aFid.vnode &&
scp->fid.unique == aFid.unique
) {
// mark the scp to be reused
lock_ReleaseWrite(&cm_scacheLock);
lock_ObtainMutex(&scp->mx);
cm_DiscardSCache(scp);
lock_ReleaseMutex(&scp->mx);
cm_CallbackNotifyChange(scp);
lock_ObtainWrite(&cm_scacheLock);
scp->refCount--;
// mark the scp to be reused
lock_ReleaseWrite(&cm_scacheLock);
lock_ObtainMutex(&scp->mx);
cm_DiscardSCache(scp);
lock_ReleaseMutex(&scp->mx);
cm_CallbackNotifyChange(scp);
lock_ObtainWrite(&cm_scacheLock);
scp->refCount--;
// take the scp out of the hash
lscpp = &cm_hashTablep[hash];
for (tscp=*lscpp; tscp; lscpp = &tscp->nextp, tscp = *lscpp) {
if (tscp == scp) break;
}
*lscpp = scp->nextp;
scp->flags &= ~CM_SCACHEFLAG_INHASH;
// take the scp out of the hash
lscpp = &cm_hashTablep[hash];
for (tscp=*lscpp; tscp; lscpp = &tscp->nextp, tscp = *lscpp) {
if (tscp == scp) break;
}
*lscpp = scp->nextp;
scp->flags &= ~CM_SCACHEFLAG_INHASH;
}
}
aFid.vnode = aFid.vnode + 1;
}
lock_ReleaseWrite(&cm_scacheLock);
osi_Log0(afsd_logp,"\tall old scp cleared!");
// we must free the memory that was allocated in the prev
// cm_InitLocalMountPoints call
osi_Log0(afsd_logp,"Removing old localmountpoints... ");
free(cm_localMountPoints);
osi_Log0(afsd_logp,"\tall old localmountpoints cleared!");
}
}
aFid.vnode = aFid.vnode + 1;
}
lock_ReleaseWrite(&cm_scacheLock);
osi_Log0(afsd_logp,"\tall old scp cleared!");
// now re-init the localmountpoints
osi_Log0(afsd_logp,"Creating new localmountpoints... ");
cm_InitLocalMountPoints();
osi_Log0(afsd_logp,"\tcreated new set of localmountpoints!");
// we must free the memory that was allocated in the prev
// cm_InitLocalMountPoints call
osi_Log0(afsd_logp,"Removing old localmountpoints... ");
free(cm_localMountPoints);
osi_Log0(afsd_logp,"\tall old localmountpoints cleared!");
// now we have to free the memory allocated in cm_initfakerootdir
osi_Log0(afsd_logp,"Removing old fakedir... ");
free(cm_FakeRootDir);
osi_Log0(afsd_logp,"\t\told fakedir removed!");
// now re-init the localmountpoints
osi_Log0(afsd_logp,"Creating new localmountpoints... ");
cm_InitLocalMountPoints();
osi_Log0(afsd_logp,"\tcreated new set of localmountpoints!");
// now we have to free the memory allocated in cm_initfakerootdir
osi_Log0(afsd_logp,"Removing old fakedir... ");
free(cm_FakeRootDir);
osi_Log0(afsd_logp,"\t\told fakedir removed!");
// then we re-create that dir
osi_Log0(afsd_logp,"Creating new fakedir... ");
cm_InitFakeRootDir();
osi_Log0(afsd_logp,"\t\tcreated new fakedir!");
// then we re-create that dir
osi_Log0(afsd_logp,"Creating new fakedir... ");
cm_InitFakeRootDir();
osi_Log0(afsd_logp,"\t\tcreated new fakedir!");
lock_ReleaseMutex(&cm_Freelance_Lock);
lock_ReleaseMutex(&cm_Freelance_Lock);
osi_Log0(afsd_logp,"----- freelance reinit complete -----");
return 0;
osi_Log0(afsd_logp,"----- freelance reinit complete -----");
return 0;
}
@ -392,12 +389,12 @@ int cm_reInitLocalMountPoints() {
// process for the freelance client.
/* to be called while holding freelance lock unless during init. */
long cm_InitLocalMountPoints() {
FILE *fp;
FILE *fp;
int i;
char line[512];
char* t;
cm_localMountPoint_t* aLocalMountPoint;
char hdir[120];
char line[512];
char*t, *t2;
cm_localMountPoint_t* aLocalMountPoint;
char hdir[120];
long code;
char rootCellName[256];
#if !defined(DJGPP)
@ -465,6 +462,11 @@ long cm_InitLocalMountPoints() {
RegEnumValue( hkFreelance, dwIndex, szValueName, &dwValueSize, NULL,
&dwType, line, &dwSize);
/* find the trailing dot; null terminate after it */
t2 = strrchr(line, '.');
if (t2)
*(t2+1) = '\0';
// line is not empty, so let's parse it
t = strchr(line, '#');
if (!t)
@ -477,12 +479,13 @@ long cm_InitLocalMountPoints() {
continue;
}
aLocalMountPoint->namep=malloc(t-line+1);
memcpy(aLocalMountPoint->namep, line, t-line);
*(aLocalMountPoint->namep + (t-line)) = 0;
strncpy(aLocalMountPoint->namep, line, t-line);
aLocalMountPoint->namep[t-line] = '\0';
aLocalMountPoint->mountPointStringp=malloc(strlen(line) - (t-line) + 1);
memcpy(aLocalMountPoint->mountPointStringp, t, strlen(line)-(t-line)-2);
*(aLocalMountPoint->mountPointStringp + (strlen(line)-(t-line)-2)) = 0;
/* copy the mount point string without the trailing dot */
aLocalMountPoint->mountPointStringp=malloc(strlen(t));
strncpy(aLocalMountPoint->mountPointStringp, t, strlen(t)-1);
aLocalMountPoint->mountPointStringp[strlen(t)-1] = '\0';
osi_Log2(afsd_logp,"found mount point: name %s, string %s",
osi_LogSaveString(afsd_logp,aLocalMountPoint->namep),
@ -499,13 +502,13 @@ long cm_InitLocalMountPoints() {
/* What follows is the old code to read freelance mount points
* out of a text file modified to copy the data into the registry
*/
cm_GetConfigDir(hdir);
strcat(hdir, AFS_FREELANCE_INI);
// open the ini file for reading
fp = fopen(hdir, "r");
cm_GetConfigDir(hdir);
strcat(hdir, AFS_FREELANCE_INI);
// open the ini file for reading
fp = fopen(hdir, "r");
// if we fail to open the file, create an empty one
if (!fp) {
// if we fail to open the file, create an empty one
if (!fp) {
fp = fopen(hdir, "w");
code = cm_GetRootCellName(rootCellName);
if (code == 0) {
@ -519,10 +522,10 @@ long cm_InitLocalMountPoints() {
fclose(fp);
return 0; /* success */
}
}
}
// we successfully opened the file
osi_Log0(afsd_logp,"opened afs_freelance.ini");
// we successfully opened the file
osi_Log0(afsd_logp,"opened afs_freelance.ini");
#if !defined(DJGPP)
RegCreateKeyEx( HKEY_LOCAL_MACHINE,
@ -537,41 +540,41 @@ long cm_InitLocalMountPoints() {
dwIndex = 0;
#endif
// now we read the first line to see how many entries
// there are
fgets(line, sizeof(line), fp);
// now we read the first line to see how many entries
// there are
fgets(line, sizeof(line), fp);
// if the line is empty at any point when we're reading
// we're screwed. report error and return.
if (*line==0) {
afsi_log("error occurred while reading afs_freelance.ini");
fprintf(stderr, "error occurred while reading afs_freelance.ini");
return -1;
}
// if the line is empty at any point when we're reading
// we're screwed. report error and return.
if (*line==0) {
afsi_log("error occurred while reading afs_freelance.ini");
fprintf(stderr, "error occurred while reading afs_freelance.ini");
return -1;
}
// get the number of entries there are from the first line
// that we read
cm_noLocalMountPoints = atoi(line);
// get the number of entries there are from the first line
// that we read
cm_noLocalMountPoints = atoi(line);
// create space to store the local mount points
cm_localMountPoints = malloc(sizeof(cm_localMountPoint_t) * cm_noLocalMountPoints);
aLocalMountPoint = cm_localMountPoints;
// now we read n lines and parse them into local mount points
// where n is the number of local mount points there are, as
// determined above.
// Each line in the ini file represents 1 local mount point and
// is in the format xxx#yyy:zzz, where xxx is the directory
// entry name, yyy is the cell name and zzz is the volume name.
// #yyy:zzz together make up the mount point.
for (i=0; i<cm_noLocalMountPoints; i++) {
fgets(line, sizeof(line), fp);
// check that the line is not empty
if (line[0]==0) {
afsi_log("error occurred while parsing entry in %s: empty line in line %d", AFS_FREELANCE_INI, i);
fprintf(stderr, "error occurred while parsing entry in afs_freelance.ini: empty line in line %d", i);
return -1;
}
// create space to store the local mount points
cm_localMountPoints = malloc(sizeof(cm_localMountPoint_t) * cm_noLocalMountPoints);
aLocalMountPoint = cm_localMountPoints;
// now we read n lines and parse them into local mount points
// where n is the number of local mount points there are, as
// determined above.
// Each line in the ini file represents 1 local mount point and
// is in the format xxx#yyy:zzz, where xxx is the directory
// entry name, yyy is the cell name and zzz is the volume name.
// #yyy:zzz together make up the mount point.
for (i=0; i<cm_noLocalMountPoints; i++) {
fgets(line, sizeof(line), fp);
// check that the line is not empty
if (line[0]==0) {
afsi_log("error occurred while parsing entry in %s: empty line in line %d", AFS_FREELANCE_INI, i);
fprintf(stderr, "error occurred while parsing entry in afs_freelance.ini: empty line in line %d", i);
return -1;
}
#if !defined(DJGPP)
if ( hkFreelance ) {
@ -584,46 +587,46 @@ long cm_InitLocalMountPoints() {
}
#endif
// line is not empty, so let's parse it
t = strchr(line, '#');
// line is not empty, so let's parse it
t = strchr(line, '#');
if (!t)
t = strchr(line, '%');
// make sure that there is a '#' or '%' separator in the line
if (!t) {
afsi_log("error occurred while parsing entry in %s: no # or %% separator in line %d", AFS_FREELANCE_INI, i);
fprintf(stderr, "error occurred while parsing entry in afs_freelance.ini: no # or %% separator in line %d", i);
return -1;
}
aLocalMountPoint->namep=malloc(t-line+1);
memcpy(aLocalMountPoint->namep, line, t-line);
*(aLocalMountPoint->namep + (t-line)) = 0;
// make sure that there is a '#' or '%' separator in the line
if (!t) {
afsi_log("error occurred while parsing entry in %s: no # or %% separator in line %d", AFS_FREELANCE_INI, i);
fprintf(stderr, "error occurred while parsing entry in afs_freelance.ini: no # or %% separator in line %d", i);
return -1;
}
aLocalMountPoint->namep=malloc(t-line+1);
memcpy(aLocalMountPoint->namep, line, t-line);
*(aLocalMountPoint->namep + (t-line)) = 0;
aLocalMountPoint->mountPointStringp=malloc(strlen(line) - (t-line) + 1);
memcpy(aLocalMountPoint->mountPointStringp, t, strlen(line)-(t-line)-2);
*(aLocalMountPoint->mountPointStringp + (strlen(line)-(t-line)-2)) = 0;
memcpy(aLocalMountPoint->mountPointStringp, t, strlen(line)-(t-line)-2);
*(aLocalMountPoint->mountPointStringp + (strlen(line)-(t-line)-2)) = 0;
osi_Log2(afsd_logp,"found mount point: name %s, string %s",
aLocalMountPoint->namep,
aLocalMountPoint->mountPointStringp);
aLocalMountPoint++;
}
fclose(fp);
}
fclose(fp);
#if !defined(DJGPP)
if ( hkFreelance ) {
RegCloseKey(hkFreelance);
DeleteFile(hdir);
}
#endif
return 0;
return 0;
}
int cm_getNoLocalMountPoints() {
return cm_noLocalMountPoints;
return cm_noLocalMountPoints;
}
cm_localMountPoint_t* cm_getLocalMountPoint(int vnode) {
return 0;
return 0;
}
long cm_FreelanceAddMount(char *filename, char *cellname, char *volume, int rw, cm_fid_t *fidp)

View File

@ -17,11 +17,11 @@ extern void cm_InitFreelance();
extern long cm_FreelanceRemoveMount(char *toremove);
extern long cm_FreelanceAddMount(char *filename, char *cellname, char *volume, int rw, cm_fid_t *fidp);
extern int cm_clearLocalMountPointChange();
extern int cm_FakeRootFid(cm_fid_t *fidp);
#define AFS_FREELANCE_INI "afs_freelance.ini"
#define AFS_FAKE_ROOT_CELL_ID 0xFFFFFFFF
#define AFS_FAKE_ROOT_VOL_ID 0xFFFFFFFF
extern afs_uint32 FakeFreelanceModTime;
extern time_t FakeFreelanceModTime;
#endif // _CM_FREELANCE_H

View File

@ -411,6 +411,7 @@ long cm_IoctlGetACL(smb_ioctl_t *ioctlp, cm_user_t *userp)
AFSFid fid;
int tlen;
cm_req_t req;
struct rx_connection * callp;
cm_InitReq(&req);
@ -427,9 +428,10 @@ long cm_IoctlGetACL(smb_ioctl_t *ioctlp, cm_user_t *userp)
code = cm_Conn(&scp->fid, userp, &req, &connp);
if (code) continue;
lock_ObtainMutex(&connp->mx);
code = RXAFS_FetchACL(connp->callp, &fid, &acl, &fileStatus, &volSync);
lock_ReleaseMutex(&connp->mx);
callp = cm_GetRxConn(connp);
code = RXAFS_FetchACL(callp, &fid, &acl, &fileStatus, &volSync);
rx_PutConnection(callp);
} while (cm_Analyze(connp, userp, &req, &scp->fid, &volSync, NULL, NULL, code));
code = cm_MapRPCError(code, &req);
cm_ReleaseSCache(scp);
@ -478,6 +480,7 @@ long cm_IoctlSetACL(struct smb_ioctl *ioctlp, struct cm_user *userp)
long code;
AFSFid fid;
cm_req_t req;
struct rx_connection * callp;
cm_InitReq(&req);
@ -494,9 +497,10 @@ long cm_IoctlSetACL(struct smb_ioctl *ioctlp, struct cm_user *userp)
code = cm_Conn(&scp->fid, userp, &req, &connp);
if (code) continue;
lock_ObtainMutex(&connp->mx);
code = RXAFS_StoreACL(connp->callp, &fid, &acl, &fileStatus, &volSync);
lock_ReleaseMutex(&connp->mx);
callp = cm_GetRxConn(connp);
code = RXAFS_StoreACL(callp, &fid, &acl, &fileStatus, &volSync);
rx_PutConnection(callp);
} while (cm_Analyze(connp, userp, &req, &scp->fid, &volSync, NULL, NULL, code));
code = cm_MapRPCError(code, &req);
@ -578,6 +582,7 @@ long cm_IoctlSetVolumeStatus(struct smb_ioctl *ioctlp, struct cm_user *userp)
char *cp;
cm_cell_t *cellp;
cm_req_t req;
struct rx_connection * callp;
cm_InitReq(&req);
@ -621,10 +626,11 @@ long cm_IoctlSetVolumeStatus(struct smb_ioctl *ioctlp, struct cm_user *userp)
code = cm_Conn(&scp->fid, userp, &req, &tcp);
if (code) continue;
lock_ObtainMutex(&tcp->mx);
code = RXAFS_SetVolumeStatus(tcp->callp, scp->fid.volume,
callp = cm_GetRxConn(tcp);
code = RXAFS_SetVolumeStatus(callp, scp->fid.volume,
&storeStat, volName, offLineMsg, motd);
lock_ReleaseMutex(&tcp->mx);
rx_PutConnection(callp);
} while (cm_Analyze(tcp, userp, &req, &scp->fid, NULL, NULL, NULL, code));
code = cm_MapRPCError(code, &req);
@ -668,6 +674,7 @@ long cm_IoctlGetVolumeStatus(struct smb_ioctl *ioctlp, struct cm_user *userp)
char *OfflineMsg;
char *MOTD;
cm_req_t req;
struct rx_connection * callp;
cm_InitReq(&req);
@ -681,10 +688,11 @@ long cm_IoctlGetVolumeStatus(struct smb_ioctl *ioctlp, struct cm_user *userp)
code = cm_Conn(&scp->fid, userp, &req, &tcp);
if (code) continue;
lock_ObtainMutex(&tcp->mx);
code = RXAFS_GetVolumeStatus(tcp->callp, scp->fid.volume,
callp = cm_GetRxConn(tcp);
code = RXAFS_GetVolumeStatus(callp, scp->fid.volume,
&volStat, &Name, &OfflineMsg, &MOTD);
lock_ReleaseMutex(&tcp->mx);
rx_PutConnection(callp);
} while (cm_Analyze(tcp, userp, &req, &scp->fid, NULL, NULL, NULL, code));
code = cm_MapRPCError(code, &req);

View File

@ -58,7 +58,7 @@ typedef struct cm_scache {
* write-locked to prevent buffers from
* being created during a truncate op, etc.
*/
int refCount; /* reference count; cm_scacheLock */
unsigned long refCount; /* reference count; cm_scacheLock */
osi_queueData_t *bufReadsp; /* queue of buffers being read */
osi_queueData_t *bufWritesp; /* queue of buffers being written */

View File

@ -50,6 +50,7 @@ void cm_CheckServers(long flags, cm_cell_t *cellp)
long now;
int wasDown;
cm_conn_t *connp;
struct rx_connection * callp;
lock_ObtainWrite(&cm_serverLock);
for (tsp = cm_allServersp; tsp; tsp = tsp->allNextp) {
@ -95,9 +96,9 @@ void cm_CheckServers(long flags, cm_cell_t *cellp)
}
else {
/* file server */
lock_ObtainMutex(&connp->mx);
code = RXAFS_GetTime(connp->callp, &secs, &usecs);
lock_ReleaseMutex(&connp->mx);
callp = cm_GetRxConn(connp);
code = RXAFS_GetTime(callp, &secs, &usecs);
rx_PutConnection(callp);
}
if (wasDown)
rx_SetConnDeadTime(connp->callp, ConnDeadtimeout);

View File

@ -27,7 +27,7 @@ typedef struct cm_server {
struct cm_conn *connsp; /* locked by cm_connLock */
long flags; /* by mx */
struct cm_cell *cellp; /* cell containing this server */
int refCount; /* locked by cm_serverLock */
unsigned long refCount; /* locked by cm_serverLock */
osi_mutex_t mx;
unsigned short ipRank; /* server priority */
} cm_server_t;
@ -38,7 +38,7 @@ typedef struct cm_serverRef {
struct cm_serverRef *next; /* locked by cm_serverLock */
struct cm_server *server; /* locked by cm_serverLock */
enum repstate status; /* locked by cm_serverLock */
int refCount; /* locked by cm_serverLock */
unsigned long refCount; /* locked by cm_serverLock */
} cm_serverRef_t;
/* types */

View File

@ -39,7 +39,7 @@ typedef struct cm_ucell {
#define CM_UCELLFLAG_BADTIX 4 /* tickets are bad or expired */
typedef struct cm_user {
int refCount; /* ref count */
unsigned long refCount; /* ref count */
cm_ucell_t *cellInfop; /* list of cell info */
osi_mutex_t mx; /* mutex */
int vcRefs; /* count of references from virtual circuits */

View File

@ -1128,6 +1128,7 @@ long cm_Unlink(cm_scache_t *dscp, char *namep, cm_user_t *userp, cm_req_t *reqp)
int sflags;
AFSFetchStatus newDirStatus;
AFSVolSync volSync;
struct rx_connection * callp;
#ifdef AFS_FREELANCE_CLIENT
if (cm_freelanceEnabled && dscp == cm_rootSCachep) {
@ -1154,10 +1155,11 @@ long cm_Unlink(cm_scache_t *dscp, char *namep, cm_user_t *userp, cm_req_t *reqp)
if (code)
continue;
lock_ObtainMutex(&connp->mx);
code = RXAFS_RemoveFile(connp->callp, &afsFid, namep,
callp = cm_GetRxConn(connp);
code = RXAFS_RemoveFile(callp, &afsFid, namep,
&newDirStatus, &volSync);
lock_ReleaseMutex(&connp->mx);
rx_PutConnection(callp);
} while (cm_Analyze(connp, userp, reqp, &dscp->fid, &volSync, NULL, NULL, code));
code = cm_MapRPCError(code, reqp);
@ -1647,6 +1649,7 @@ void cm_TryBulkStat(cm_scache_t *dscp, osi_hyper_t *offsetp, cm_user_t *userp,
long j;
cm_scache_t *scp;
cm_fid_t tfid;
struct rx_connection * callp;
osi_Log1(afsd_logp, "cm_TryBulkStat dir 0x%x", (long) dscp);
@ -1685,10 +1688,11 @@ void cm_TryBulkStat(cm_scache_t *dscp, osi_hyper_t *offsetp, cm_user_t *userp,
if (code)
continue;
lock_ObtainMutex(&connp->mx);
code = RXAFS_BulkStatus(connp->callp, &fidStruct,
callp = cm_GetRxConn(connp);
code = RXAFS_BulkStatus(callp, &fidStruct,
&statStruct, &callbackStruct, &volSync);
lock_ReleaseMutex(&connp->mx);
rx_PutConnection(callp);
} while (cm_Analyze(connp, userp, reqp, &dscp->fid,
&volSync, NULL, &cbReq, code));
code = cm_MapRPCError(code, reqp);
@ -1884,6 +1888,7 @@ long cm_SetAttr(cm_scache_t *scp, cm_attr_t *attrp, cm_user_t *userp,
cm_conn_t *connp;
AFSFid tfid;
AFSStoreStatus afsInStatus;
struct rx_connection * callp;
/* handle file length setting */
if (attrp->mask & CM_ATTRMASK_LENGTH)
@ -1912,10 +1917,11 @@ long cm_SetAttr(cm_scache_t *scp, cm_attr_t *attrp, cm_user_t *userp,
if (code)
continue;
lock_ObtainMutex(&connp->mx);
code = RXAFS_StoreStatus(connp->callp, &tfid,
callp = cm_GetRxConn(connp);
code = RXAFS_StoreStatus(callp, &tfid,
&afsInStatus, &afsOutStatus, &volSync);
lock_ReleaseMutex(&connp->mx);
rx_PutConnection(callp);
} while (cm_Analyze(connp, userp, reqp,
&scp->fid, &volSync, NULL, NULL, code));
code = cm_MapRPCError(code, reqp);
@ -1952,6 +1958,7 @@ long cm_Create(cm_scache_t *dscp, char *namep, long flags, cm_attr_t *attrp,
AFSFetchStatus newFileStatus;
AFSCallBack newFileCallback;
AFSVolSync volSync;
struct rx_connection * callp;
/* can't create names with @sys in them; must expand it manually first.
* return "invalid request" if they try.
@ -1986,12 +1993,14 @@ long cm_Create(cm_scache_t *dscp, char *namep, long flags, cm_attr_t *attrp,
dirAFSFid.Volume = dscp->fid.volume;
dirAFSFid.Vnode = dscp->fid.vnode;
dirAFSFid.Unique = dscp->fid.unique;
lock_ObtainMutex(&connp->mx);
callp = cm_GetRxConn(connp);
code = RXAFS_CreateFile(connp->callp, &dirAFSFid, namep,
&inStatus, &newAFSFid, &newFileStatus,
&updatedDirStatus, &newFileCallback,
&volSync);
lock_ReleaseMutex(&connp->mx);
rx_PutConnection(callp);
} while (cm_Analyze(connp, userp, reqp,
&dscp->fid, &volSync, NULL, &cbReq, code));
code = cm_MapRPCError(code, reqp);
@ -2071,6 +2080,7 @@ long cm_MakeDir(cm_scache_t *dscp, char *namep, long flags, cm_attr_t *attrp,
AFSFetchStatus newDirStatus;
AFSCallBack newDirCallback;
AFSVolSync volSync;
struct rx_connection * callp;
/* can't create names with @sys in them; must expand it manually first.
* return "invalid request" if they try.
@ -2105,12 +2115,14 @@ long cm_MakeDir(cm_scache_t *dscp, char *namep, long flags, cm_attr_t *attrp,
dirAFSFid.Volume = dscp->fid.volume;
dirAFSFid.Vnode = dscp->fid.vnode;
dirAFSFid.Unique = dscp->fid.unique;
lock_ObtainMutex(&connp->mx);
callp = cm_GetRxConn(connp);
code = RXAFS_MakeDir(connp->callp, &dirAFSFid, namep,
&inStatus, &newAFSFid, &newDirStatus,
&updatedDirStatus, &newDirCallback,
&volSync);
lock_ReleaseMutex(&connp->mx);
rx_PutConnection(callp);
} while (cm_Analyze(connp, userp, reqp,
&dscp->fid, &volSync, NULL, &cbReq, code));
code = cm_MapRPCError(code, reqp);
@ -2165,6 +2177,7 @@ long cm_Link(cm_scache_t *dscp, char *namep, cm_scache_t *sscp, long flags,
AFSFetchStatus updatedDirStatus;
AFSFetchStatus newLinkStatus;
AFSVolSync volSync;
struct rx_connection * callp;
if (dscp->fid.cell != sscp->fid.cell ||
dscp->fid.volume != sscp->fid.volume) {
@ -2190,12 +2203,12 @@ long cm_Link(cm_scache_t *dscp, char *namep, cm_scache_t *sscp, long flags,
existingAFSFid.Vnode = sscp->fid.vnode;
existingAFSFid.Unique = sscp->fid.unique;
lock_ObtainMutex(&connp->mx);
code = RXAFS_Link(connp->callp, &dirAFSFid, namep, &existingAFSFid,
callp = cm_GetRxConn(connp);
code = RXAFS_Link(callp, &dirAFSFid, namep, &existingAFSFid,
&newLinkStatus, &updatedDirStatus, &volSync);
lock_ReleaseMutex(&connp->mx);
rx_PutConnection(callp);
osi_Log1(smb_logp," RXAFS_Link returns %d", code);
} while (cm_Analyze(connp, userp, reqp,
&dscp->fid, &volSync, NULL, NULL, code));
@ -2224,6 +2237,7 @@ long cm_SymLink(cm_scache_t *dscp, char *namep, char *contentsp, long flags,
AFSFetchStatus updatedDirStatus;
AFSFetchStatus newLinkStatus;
AFSVolSync volSync;
struct rx_connection * callp;
/* before starting the RPC, mark that we're changing the directory data,
* so that someone who does a chmod on the dir will wait until our
@ -2247,11 +2261,13 @@ long cm_SymLink(cm_scache_t *dscp, char *namep, char *contentsp, long flags,
dirAFSFid.Volume = dscp->fid.volume;
dirAFSFid.Vnode = dscp->fid.vnode;
dirAFSFid.Unique = dscp->fid.unique;
lock_ObtainMutex(&connp->mx);
code = RXAFS_Symlink(connp->callp, &dirAFSFid, namep, contentsp,
callp = cm_GetRxConn(connp);
code = RXAFS_Symlink(callp, &dirAFSFid, namep, contentsp,
&inStatus, &newAFSFid, &newLinkStatus,
&updatedDirStatus, &volSync);
lock_ReleaseMutex(&connp->mx);
rx_PutConnection(callp);
} while (cm_Analyze(connp, userp, reqp,
&dscp->fid, &volSync, NULL, NULL, code));
code = cm_MapRPCError(code, reqp);
@ -2298,6 +2314,7 @@ long cm_RemoveDir(cm_scache_t *dscp, char *namep, cm_user_t *userp,
int didEnd;
AFSFetchStatus updatedDirStatus;
AFSVolSync volSync;
struct rx_connection * callp;
/* before starting the RPC, mark that we're changing the directory data,
* so that someone who does a chmod on the dir will wait until our
@ -2320,10 +2337,12 @@ long cm_RemoveDir(cm_scache_t *dscp, char *namep, cm_user_t *userp,
dirAFSFid.Volume = dscp->fid.volume;
dirAFSFid.Vnode = dscp->fid.vnode;
dirAFSFid.Unique = dscp->fid.unique;
lock_ObtainMutex(&connp->mx);
code = RXAFS_RemoveDir(connp->callp, &dirAFSFid, namep,
callp = cm_GetRxConn(connp);
code = RXAFS_RemoveDir(callp, &dirAFSFid, namep,
&updatedDirStatus, &volSync);
lock_ReleaseMutex(&connp->mx);
rx_PutConnection(callp);
} while (cm_Analyze(connp, userp, reqp,
&dscp->fid, &volSync, NULL, NULL, code));
code = cm_MapRPCErrorRmdir(code, reqp);
@ -2370,6 +2389,7 @@ long cm_Rename(cm_scache_t *oldDscp, char *oldNamep, cm_scache_t *newDscp,
AFSFetchStatus updatedNewDirStatus;
AFSVolSync volSync;
int oneDir;
struct rx_connection * callp;
/* before starting the RPC, mark that we're changing the directory data,
* so that someone who does a chmod on the dir will wait until our call
@ -2461,12 +2481,14 @@ long cm_Rename(cm_scache_t *oldDscp, char *oldNamep, cm_scache_t *newDscp,
newDirAFSFid.Volume = newDscp->fid.volume;
newDirAFSFid.Vnode = newDscp->fid.vnode;
newDirAFSFid.Unique = newDscp->fid.unique;
lock_ObtainMutex(&connp->mx);
code = RXAFS_Rename(connp->callp, &oldDirAFSFid, oldNamep,
callp = cm_GetRxConn(connp);
code = RXAFS_Rename(callp, &oldDirAFSFid, oldNamep,
&newDirAFSFid, newNamep,
&updatedOldDirStatus, &updatedNewDirStatus,
&volSync);
lock_ReleaseMutex(&connp->mx);
rx_PutConnection(callp);
} while (cm_Analyze(connp, userp, reqp, &oldDscp->fid,
&volSync, NULL, NULL, code));
code = cm_MapRPCError(code, reqp);
@ -2508,6 +2530,7 @@ long cm_Lock(cm_scache_t *scp, unsigned char LockType,
cm_file_lock_t *fileLock;
osi_queue_t *q;
int found = 0;
struct rx_connection * callp;
/* Look for a conflict. Also, if we are asking for a shared lock,
* look for another shared lock, so we don't have to do an RPC.
@ -2538,10 +2561,12 @@ long cm_Lock(cm_scache_t *scp, unsigned char LockType,
code = cm_Conn(&scp->fid, userp, reqp, &connp);
if (code)
break;
lock_ObtainMutex(&connp->mx);
code = RXAFS_SetLock(connp->callp, &tfid, Which,
callp = cm_GetRxConn(connp);
code = RXAFS_SetLock(callp, &tfid, Which,
&volSync);
lock_ReleaseMutex(&connp->mx);
rx_PutConnection(callp);
} while (cm_Analyze(connp, userp, reqp, &scp->fid, &volSync,
NULL, NULL, code));
lock_ObtainMutex(&scp->mx);
@ -2581,6 +2606,7 @@ long cm_Unlock(cm_scache_t *scp, unsigned char LockType,
int anotherReader = 0;
int smallLock = 0;
int found = 0;
struct rx_connection * callp;
if (LargeIntegerLessThan(LLength, scp->length))
smallLock = 1;
@ -2633,9 +2659,11 @@ long cm_Unlock(cm_scache_t *scp, unsigned char LockType,
code = cm_Conn(&scp->fid, userp, reqp, &connp);
if (code)
break;
lock_ObtainMutex(&connp->mx);
code = RXAFS_ReleaseLock(connp->callp, &tfid, &volSync);
lock_ReleaseMutex(&connp->mx);
callp = cm_GetRxConn(connp);
code = RXAFS_ReleaseLock(callp, &tfid, &volSync);
rx_PutConnection(callp);
} while (cm_Analyze(connp, userp, reqp, &scp->fid, &volSync,
NULL, NULL, code));
code = cm_MapRPCError(code, reqp);
@ -2654,6 +2682,7 @@ void cm_CheckLocks()
AFSVolSync volSync;
cm_conn_t *connp;
long code;
struct rx_connection * callp;
cm_InitReq(&req);
@ -2676,10 +2705,12 @@ void cm_CheckLocks()
&req, &connp);
if (code)
break;
lock_ObtainMutex(&connp->mx);
code = RXAFS_ExtendLock(connp->callp, &tfid,
callp = cm_GetRxConn(connp);
code = RXAFS_ExtendLock(callp, &tfid,
&volSync);
lock_ReleaseMutex(&connp->mx);
rx_PutConnection(callp);
} while (cm_Analyze(connp, fileLock->userp, &req,
&fileLock->fid, &volSync, NULL, NULL,
code));
@ -2703,6 +2734,7 @@ long cm_RetryLock(cm_file_lock_t *oldFileLock, int vcp_is_dead)
osi_queue_t *q;
cm_req_t req;
int found = 0;
struct rx_connection * callp;
if (vcp_is_dead) {
code = CM_ERROR_TIMEDOUT;
@ -2746,10 +2778,12 @@ long cm_RetryLock(cm_file_lock_t *oldFileLock, int vcp_is_dead)
&req, &connp);
if (code)
break;
lock_ObtainMutex(&connp->mx);
code = RXAFS_SetLock(connp->callp, &tfid, Which,
callp = cm_GetRxConn(connp);
code = RXAFS_SetLock(callp, &tfid, Which,
&volSync);
lock_ReleaseMutex(&connp->mx);
rx_PutConnection(callp);
} while (cm_Analyze(connp, oldFileLock->userp, &req,
&oldFileLock->fid, &volSync,
NULL, NULL, code));

View File

@ -15,7 +15,7 @@ extern unsigned int cm_mountRootGen;
/* parms for attribute setting call */
typedef struct cm_attr {
int mask;
unsigned long clientModTime;
time_t clientModTime;
osi_hyper_t length;
int unixModeBits;
long owner;

View File

@ -20,7 +20,7 @@ typedef struct cm_volume {
struct cm_fid *dotdotFidp; /* parent of volume root */
osi_mutex_t mx;
long flags; /* by mx */
int refCount; /* by cm_volumeLock */
unsigned long refCount; /* by cm_volumeLock */
cm_serverRef_t *rwServersp; /* by mx */
cm_serverRef_t *roServersp; /* by mx */
cm_serverRef_t *bkServersp; /* by mx */

View File

@ -88,7 +88,8 @@ main(argc, argv)
if (tokenExpireTime <= current_time)
printf("[>> Expired <<]\n");
else {
expireString = ctime(&tokenExpireTime);
time_t t = tokenExpireTime;
expireString = ctime(&t);
expireString += 4; /* Skip day of week */
expireString[12] = '\0'; /* Omit secs & year */
printf("[Expires %s]\n", expireString);

View File

@ -609,8 +609,6 @@ BOOL IsAdmin (void)
return FALSE;
}
fTested = TRUE;
dwSize = 0;
dwSize2 = 0;
@ -645,39 +643,76 @@ BOOL IsAdmin (void)
if (OpenProcessToken (GetCurrentProcess(), TOKEN_QUERY, &hToken))
{
/* We'll have to allocate a chunk of memory to store the list of
* groups to which this user belongs; find out how much memory
* we'll need.
*/
DWORD dwSize = 0;
PTOKEN_GROUPS pGroups;
GetTokenInformation (hToken, TokenGroups, NULL, dwSize, &dwSize);
pGroups = (PTOKEN_GROUPS)malloc(dwSize);
/* Allocate that buffer, and read in the list of groups. */
if (GetTokenInformation (hToken, TokenGroups, pGroups, dwSize, &dwSize))
{
/* Look through the list of group SIDs and see if any of them
* matches the AFS Client Admin group SID.
if (!CheckTokenMembership(hToken, psidAdmin, &fAdmin)) {
/* We'll have to allocate a chunk of memory to store the list of
* groups to which this user belongs; find out how much memory
* we'll need.
*/
size_t iGroup = 0;
for (; (!fAdmin) && (iGroup < pGroups->GroupCount); ++iGroup)
DWORD dwSize = 0;
PTOKEN_GROUPS pGroups;
GetTokenInformation (hToken, TokenGroups, NULL, dwSize, &dwSize);
pGroups = (PTOKEN_GROUPS)malloc(dwSize);
/* Allocate that buffer, and read in the list of groups. */
if (GetTokenInformation (hToken, TokenGroups, pGroups, dwSize, &dwSize))
{
if (EqualSid (psidAdmin, pGroups->Groups[ iGroup ].Sid)) {
fAdmin = TRUE;
/* Look through the list of group SIDs and see if any of them
* matches the AFS Client Admin group SID.
*/
size_t iGroup = 0;
for (; (!fAdmin) && (iGroup < pGroups->GroupCount); ++iGroup)
{
if (EqualSid (psidAdmin, pGroups->Groups[ iGroup ].Sid)) {
fAdmin = TRUE;
}
}
}
if (pGroups)
free(pGroups);
}
if (pGroups)
free(pGroups);
/* if do not have permission because we were not explicitly listed
* in the Admin Client Group let's see if we are the SYSTEM account
*/
if (!fAdmin) {
PTOKEN_USER pTokenUser;
SID_IDENTIFIER_AUTHORITY SIDAuth = SECURITY_NT_AUTHORITY;
PSID pSidLocalSystem = 0;
DWORD gle;
GetTokenInformation(hToken, TokenUser, NULL, 0, &dwSize);
pTokenUser = (PTOKEN_USER)malloc(dwSize);
if (!GetTokenInformation(hToken, TokenUser, pTokenUser, dwSize, &dwSize))
gle = GetLastError();
if (AllocateAndInitializeSid( &SIDAuth, 1,
SECURITY_LOCAL_SYSTEM_RID,
0, 0, 0, 0, 0, 0, 0,
&pSidLocalSystem))
{
if (EqualSid(pTokenUser->User.Sid, pSidLocalSystem)) {
fAdmin = TRUE;
}
FreeSid(pSidLocalSystem);
}
if ( pTokenUser )
free(pTokenUser);
}
}
}
free(psidAdmin);
free(pszRefDomain);
fTested = TRUE;
}
return fAdmin;
@ -2447,7 +2482,7 @@ struct afsconf_cell *info;
}
else {
/* got a ticket */
if (ttoken.kvno >= 0 && ttoken.kvno <= 255) scIndex = 2; /* kerberos */
if (ttoken.kvno >= 0 && ttoken.kvno <= 256) scIndex = 2; /* kerberos */
else {
fprintf (stderr, "fs: funny kvno (%d) in ticket, proceeding\n",
ttoken.kvno);

File diff suppressed because it is too large Load Diff

View File

@ -141,7 +141,7 @@ typedef struct myncb {
/* one per virtual circuit */
typedef struct smb_vc {
struct smb_vc *nextp; /* not used */
int refCount; /* the reference count */
unsigned long refCount; /* the reference count */
long flags; /* the flags, if any; locked by mx */
osi_mutex_t mx; /* the mutex */
long vcID; /* VC id */
@ -177,7 +177,7 @@ typedef struct smb_vc {
/* one per user session */
typedef struct smb_user {
struct smb_user *nextp; /* next sibling */
long refCount; /* ref count */
unsigned long refCount; /* ref count */
long flags; /* flags; locked by mx */
osi_mutex_t mx;
long userID; /* the session identifier */
@ -187,7 +187,7 @@ typedef struct smb_user {
typedef struct smb_username {
struct smb_username *nextp; /* next sibling */
long refCount; /* ref count */
unsigned long refCount; /* ref count */
long flags; /* flags; locked by mx */
osi_mutex_t mx;
struct cm_user *userp; /* CM user structure */
@ -202,7 +202,7 @@ typedef struct smb_username {
/* one per tree-connect */
typedef struct smb_tid {
struct smb_tid *nextp; /* next sibling */
long refCount;
unsigned long refCount;
long flags;
osi_mutex_t mx; /* for non-tree-related stuff */
unsigned short tid; /* the tid */
@ -218,7 +218,7 @@ typedef struct smb_tid {
/* one per process ID */
typedef struct smb_pid {
struct smb_pid *nextp; /* next sibling */
long refCount;
unsigned long refCount;
long flags;
osi_mutex_t mx; /* for non-tree-related stuff */
unsigned short pid; /* the pid */
@ -260,8 +260,8 @@ typedef struct smb_ioctl {
/* one per file ID; these are really file descriptors */
typedef struct smb_fid {
osi_queue_t q;
long refCount;
long flags;
unsigned long refCount;
unsigned long flags;
osi_mutex_t mx; /* for non-tree-related stuff */
unsigned short fid; /* the file ID */
struct smb_vc *vcp; /* back ptr */
@ -313,7 +313,7 @@ typedef struct smb_fid {
typedef struct smb_dirSearch {
osi_queue_t q; /* queue of all outstanding cookies */
osi_mutex_t mx; /* just in case the caller screws up */
int refCount; /* reference count */
unsigned long refCount; /* reference count */
long cookie; /* value returned to the caller */
struct cm_scache *scp; /* vnode of the dir we're searching */
time_t lastTime; /* last time we used this */

File diff suppressed because it is too large Load Diff

View File

@ -390,11 +390,11 @@ static int get_v5cred(krb5_context context,
memset((char *)&increds, 0, sizeof(increds));
if ((r = krb5_build_principal(context, &increds.server,
strlen(realm), realm,
name,
(inst && strlen(inst)) ? inst : 0,
0))) {
if ((r = krb5_build_principal(context, &increds.server,
strlen(realm), realm,
name,
(inst && strlen(inst)) ? inst : 0,
0))) {
return((int)r);
}
@ -624,6 +624,12 @@ static int auth_to_cell(krb5_context context, char *cell, char *realm)
{ /* using krb5 */
int retry = 1;
if ( strchr(name,'.') != NULL ) {
fprintf(stderr, "%s: Can't support principal names including a dot.\n",
progname);
return(AKLOG_MISC);
}
try_v5:
if (dflag)
printf("Getting v5 tickets: %s/%s@%s\n", name, instance, realm_of_cell);

View File

@ -523,7 +523,7 @@ void QueryDriveMapList_ReadMappings (PDRIVEMAPLIST pList)
&dwType, (LPBYTE)mapping, &mappingLen);
if ( dwType == REG_EXPAND_SZ ) {
TCHAR buf[MAX_PATH];
DWORD dummyLen = ExpandEnvironmentStrings(buf, mapping, MAX_PATH);
DWORD dummyLen = ExpandEnvironmentStrings(mapping, buf, MAX_PATH);
if (dummyLen > MAX_PATH)
continue;
_tcsncpy(mapping, buf, MAX_PATH);

View File

@ -76,8 +76,6 @@ BOOL IsAdmin (void)
return FALSE;
}
fTested = TRUE;
dwSize = 0;
dwSize2 = 0;
@ -99,7 +97,7 @@ BOOL IsAdmin (void)
return TRUE;
}
psidAdmin = (PSID) malloc(dwSize); memset(psidAdmin,0,dwSize);
psidAdmin = (PSID)malloc(dwSize); memset(psidAdmin,0,dwSize);
pszRefDomain = (char *)malloc(dwSize2);
if (!LookupAccountName(NULL, pszAdminGroup, psidAdmin, &dwSize, pszRefDomain, &dwSize2, &snu)) {
@ -112,39 +110,76 @@ BOOL IsAdmin (void)
if (OpenProcessToken (GetCurrentProcess(), TOKEN_QUERY, &hToken))
{
/* We'll have to allocate a chunk of memory to store the list of
* groups to which this user belongs; find out how much memory
* we'll need.
*/
DWORD dwSize = 0;
PTOKEN_GROUPS pGroups;
GetTokenInformation (hToken, TokenGroups, NULL, dwSize, &dwSize);
pGroups = (PTOKEN_GROUPS)malloc(dwSize);
/* Allocate that buffer, and read in the list of groups. */
if (GetTokenInformation (hToken, TokenGroups, pGroups, dwSize, &dwSize))
{
/* Look through the list of group SIDs and see if any of them
* matches the AFS Client Admin group SID.
if (!CheckTokenMembership(hToken, psidAdmin, &fAdmin)) {
/* We'll have to allocate a chunk of memory to store the list of
* groups to which this user belongs; find out how much memory
* we'll need.
*/
size_t iGroup = 0;
for (; (!fAdmin) && (iGroup < pGroups->GroupCount); ++iGroup)
DWORD dwSize = 0;
PTOKEN_GROUPS pGroups;
GetTokenInformation (hToken, TokenGroups, NULL, dwSize, &dwSize);
pGroups = (PTOKEN_GROUPS)malloc(dwSize);
/* Allocate that buffer, and read in the list of groups. */
if (GetTokenInformation (hToken, TokenGroups, pGroups, dwSize, &dwSize))
{
if (EqualSid (psidAdmin, pGroups->Groups[ iGroup ].Sid)) {
fAdmin = TRUE;
/* Look through the list of group SIDs and see if any of them
* matches the AFS Client Admin group SID.
*/
size_t iGroup = 0;
for (; (!fAdmin) && (iGroup < pGroups->GroupCount); ++iGroup)
{
if (EqualSid (psidAdmin, pGroups->Groups[ iGroup ].Sid)) {
fAdmin = TRUE;
}
}
}
if (pGroups)
free(pGroups);
}
if (pGroups)
free(pGroups);
/* if do not have permission because we were not explicitly listed
* in the Admin Client Group let's see if we are the SYSTEM account
*/
if (!fAdmin) {
PTOKEN_USER pTokenUser;
SID_IDENTIFIER_AUTHORITY SIDAuth = SECURITY_NT_AUTHORITY;
PSID pSidLocalSystem = 0;
DWORD gle;
GetTokenInformation(hToken, TokenUser, NULL, 0, &dwSize);
pTokenUser = (PTOKEN_USER)malloc(dwSize);
if (!GetTokenInformation(hToken, TokenUser, pTokenUser, dwSize, &dwSize))
gle = GetLastError();
if (AllocateAndInitializeSid( &SIDAuth, 1,
SECURITY_LOCAL_SYSTEM_RID,
0, 0, 0, 0, 0, 0, 0,
&pSidLocalSystem))
{
if (EqualSid(pTokenUser->User.Sid, pSidLocalSystem)) {
fAdmin = TRUE;
}
FreeSid(pSidLocalSystem);
}
if ( pTokenUser )
free(pTokenUser);
}
}
}
free(psidAdmin);
free(pszRefDomain);
fTested = TRUE;
}
return fAdmin;

View File

@ -35,7 +35,7 @@ typedef struct osi_sleepInfo {
unsigned short states; /* states bits */
unsigned short idx; /* sleep hash table we're in, if in hash */
unsigned short waitFor; /* what are we waiting for; used for bulk wakeups */
unsigned short refCount;/* reference count from FDs */
unsigned long refCount;/* reference count from FDs */
} osi_sleepInfo_t;
/* first guy is the most recently added process */

View File

@ -56,8 +56,8 @@ typedef struct osi_qiStat {
*/
typedef struct osi_mutexStat {
osi_queue_t q; /* queue of all mutexes */
osi_turnstile_t turn; /* the real turnstile */
short refCount; /* so we can iterate cleanly */
osi_turnstile_t turn; /* the real turnstile */
unsigned long refCount; /* so we can iterate cleanly */
short states;
/* track # of lock calls and blocks */
@ -79,7 +79,7 @@ typedef struct osi_mutexStat {
typedef struct osi_rwlockStat {
osi_queue_t q; /* queue of all mutexes */
osi_turnstile_t turn; /* the real turnstile */
short refCount; /* so we can iterate cleanly */
unsigned long refCount; /* so we can iterate cleanly */
short states;
/* statistics */

View File

@ -590,14 +590,11 @@ static void pthread_sync_terminate_thread(void) {
(pthread_cache_done || pthread_once(&pthread_cache_once, create_once));
if (terminate_thread_handle == INVALID_HANDLE_VALUE) {
CHAR eventName[MAX_PATH];
static eventCount = 0;
sprintf(eventName, "terminate_thread_wakeup_event %d::%d", _getpid(), eventCount++);
terminate_thread_wakeup_event = CreateEvent((LPSECURITY_ATTRIBUTES) 0,
TRUE, FALSE, (LPCTSTR) eventName);
terminate_thread_handle = CreateThread((LPSECURITY_ATTRIBUTES) 0, 0,
terminate_thread_routine, (LPVOID) 0, 0,
&terminate_thread_id);
terminate_thread_wakeup_event = CreateEvent((LPSECURITY_ATTRIBUTES) 0,
TRUE, FALSE, (LPCTSTR) 0);
terminate_thread_handle = CreateThread((LPSECURITY_ATTRIBUTES) 0, 0,
terminate_thread_routine, (LPVOID) 0, 0,
&terminate_thread_id);
} else {
SetEvent (terminate_thread_wakeup_event);
}
@ -714,11 +711,8 @@ static cond_waiters_t *get_waiter() {
if (queue_IsEmpty(&waiter_cache)) {
new = (cond_waiters_t *) malloc(sizeof(cond_waiters_t));
if (new != NULL) {
CHAR eventName[MAX_PATH];
static eventCount = 0;
sprintf(eventName, "cond_waiters_t %d::%d", _getpid(), eventCount++);
new->event = CreateEvent((LPSECURITY_ATTRIBUTES) 0, FALSE,
FALSE, (LPCTSTR) eventName);
new->event = CreateEvent((LPSECURITY_ATTRIBUTES) 0, FALSE,
FALSE, (LPCTSTR) 0);
if (new->event == NULL) {
free(new);
new = NULL;