i-need-sleep-20040406

* fix uninitialized return variables in smb.c and smb3.c

 * open the osi_log file as early as possible in afsd_init.c

 * create an argv to use for non-service executions

 * add support for \\afs\.cellname for rw volumes

====================
This delta was composed from multiple commits as part of the CVS->Git migration.
The checkin message with each commit was inconsistent.
The following are the additional commit messages.
====================

Do not use IsKerberosLogon() it does not always report the right value.
This commit is contained in:
Jeffrey Altman 2004-04-06 09:53:15 +00:00 committed by Jeffrey Altman
parent 0054374495
commit 991edf329f
6 changed files with 97 additions and 74 deletions

View File

@ -163,11 +163,12 @@ void afsd_ForceTrace(BOOL flush)
{
HANDLE handle;
int len;
char buf[100];
char buf[256];
if (!logReady) return;
if (!logReady)
return;
len = GetTempPath(99, buf);
len = GetTempPath(sizeof(buf)-10, buf);
strcpy(&buf[len], "/afsd.log");
handle = CreateFile(buf, GENERIC_WRITE, FILE_SHARE_READ,
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
@ -214,7 +215,8 @@ int afsd_InitCM(char **reasonP)
osi_LongToUID(1000, &debugID);
code = osi_InitDebug(&debugID);
afsi_log("osi_InitDebug code %d", code);
// osi_LockTypeSetDefault("stat"); /* comment this out for speed *
// osi_LockTypeSetDefault("stat"); /* comment this out for speed *
if (code != 0) {
*reasonP = "unknown error";
return -1;
@ -242,6 +244,24 @@ int afsd_InitCM(char **reasonP)
osi_panic(buf, __FILE__, __LINE__);
}
dummyLen = sizeof(traceBufSize);
code = RegQueryValueEx(parmKey, "TraceBufferSize", NULL, NULL,
(BYTE *) &traceBufSize, &dummyLen);
if (code == ERROR_SUCCESS)
afsi_log("Trace Buffer size %d", traceBufSize);
else {
traceBufSize = CM_CONFIGDEFAULT_TRACEBUFSIZE;
afsi_log("Default trace buffer size %d", traceBufSize);
}
/* setup and enable debug log */
afsd_logp = osi_LogCreate("afsd", traceBufSize);
afsi_log("osi_LogCreate log addr %x", (int)afsd_logp);
osi_LogEnable(afsd_logp);
logReady = 1;
osi_Log0(afsd_logp, "Log init");
dummyLen = sizeof(cacheSize);
code = RegQueryValueEx(parmKey, "CacheSize", NULL, NULL,
(BYTE *) &cacheSize, &dummyLen);
@ -380,16 +400,6 @@ int afsd_InitCM(char **reasonP)
/* Don't log */
}
dummyLen = sizeof(traceBufSize);
code = RegQueryValueEx(parmKey, "TraceBufferSize", NULL, NULL,
(BYTE *) &traceBufSize, &dummyLen);
if (code == ERROR_SUCCESS)
afsi_log("Trace Buffer size %d", traceBufSize);
else {
traceBufSize = CM_CONFIGDEFAULT_TRACEBUFSIZE;
afsi_log("Default trace buffer size %d", traceBufSize);
}
dummyLen = sizeof(cm_sysName);
code = RegQueryValueEx(parmKey, "SysName", NULL, NULL,
cm_sysName, &dummyLen);
@ -527,14 +537,6 @@ int afsd_InitCM(char **reasonP)
/* turn from 1024 byte units into memory blocks */
cacheBlocks = (cacheSize * 1024) / buf_bufferSize;
/* setup and enable debug log */
afsd_logp = osi_LogCreate("afsd", traceBufSize);
afsi_log("osi_LogCreate log addr %x", (int)afsd_logp);
osi_LogEnable(afsd_logp);
logReady = 1;
osi_Log0(afsd_logp, "Log init");
/* get network related info */
cm_noIPAddr = CM_MAXINTERFACE_ADDR;
code = syscfg_GetIFInfo(&cm_noIPAddr,

View File

@ -540,7 +540,8 @@ void afsd_Main(DWORD argc, LPTSTR *argv)
DWORD __stdcall afsdMain_thread(void* notUsed)
{
afsd_Main(0, (LPTSTR*)NULL);
char * argv[2] = {AFS_DAEMON_SERVICE_NAME, NULL};
afsd_Main(1, (LPTSTR*)argv);
return(0);
}

View File

@ -52,6 +52,7 @@ extern int errno;
#define AFS_CELLSERVDB AFS_CELLSERVDB_NT
#endif /* DJGPP || WIN95 */
#ifdef DEBUG
DWORD TraceOption=1;
#define TRACE_OPTION_EVENT 1
@ -84,6 +85,7 @@ void DebugEvent_local(char *a,char *b,...)
DeregisterEventSource(h);
va_end(marker);
}
#endif /* DEBUG */
static long cm_ParsePair(char *lineBufferp, char *leftp, char *rightp)
{
@ -213,7 +215,9 @@ long cm_SearchCellFile(char *cellNamep, char *newCellNamep,
bestp = fopen(wdir, "r");
#ifdef DEBUG
DebugEvent_local("AFS- cm_searchfile fopen", "Handle[%x], wdir[%s]", bestp, wdir);
#endif
/* have we seen the cell line for the guy we're looking for? */
inRightCell = 0;
@ -269,8 +273,10 @@ long cm_SearchCellFile(char *cellNamep, char *newCellNamep,
strcpy(newCellNamep, lineBuffer+1);
inRightCell = 1;
tracking = 0;
#ifdef DEBUG
DebugEvent_local("AFS- cm_searchfile is cell", "inRightCell[%x], linebuffer[%s]",
inRightCell, lineBuffer);
#endif
}
else if (strnicmp(lineBuffer+1, cellNamep,
strlen(cellNamep)) == 0) {
@ -310,13 +316,14 @@ long cm_SearchCellFile(char *cellNamep, char *newCellNamep,
/* add the server to the VLDB list */
WSASetLastError(0);
thp = gethostbyname(valuep);
#ifdef DEBUG
{
int iErr = 0;
iErr = WSAGetLastError();
int iErr = WSAGetLastError();
DebugEvent_local("AFS- cm_searchfile inRightCell",
"thp[%x], valuep[%s], WSAGetLastError[%d]",
thp, valuep, iErr);
}
#endif
if (thp) {
memcpy(&vlSockAddr.sin_addr.s_addr, thp->h_addr,
sizeof(long));
@ -363,7 +370,9 @@ long cm_SearchCellByDNS(char *cellNamep, char *newCellNamep, int *ttl,
int i;
struct sockaddr_in vlSockAddr;
#ifdef DEBUG
DebugEvent_local("AFS SearchCellDNS-","Doing search for [%s]", cellNamep);
#endif
rc = getAFSServer(cellNamep, cellHosts, &numServers, ttl);
if (rc == 0 && numServers > 0) { /* found the cell */
for (i = 0; i < numServers; i++) {
@ -391,7 +400,9 @@ long cm_SearchCellByDNS(char *cellNamep, char *newCellNamep, int *ttl,
success = FALSE;
#ifdef DEBUG
DebugEvent_local("AFS SearchCellDNS-","Doing search for [%s]", cellNamep);
#endif
/* query the AFSDB records of cell */
if(DnsQuery_A(cellNamep, DNS_TYPE_AFSDB, DNS_QUERY_STANDARD, NULL, &pDnsCell, NULL) == ERROR_SUCCESS) {

View File

@ -1269,17 +1269,24 @@ int smb_FindShare(smb_vc_t *vcp, smb_packet_t *inp, char *shareName,
}
else /* create \\<netbiosName>\<cellname> */
{
char * p = shareName;
int rw = 0;
if ( *p == '.' ) {
p++;
rw = 1;
}
/* Get the full name for this cell */
code = cm_SearchCellFile(shareName, temp, 0, 0);
code = cm_SearchCellFile(p, temp, 0, 0);
#ifdef AFS_AFSDB_ENV
if (code && cm_dnsEnabled) {
int ttl;
code = cm_SearchCellByDNS(shareName, temp, &ttl, 0, 0);
code = cm_SearchCellByDNS(p, temp, &ttl, 0, 0);
}
#endif
/* construct the path */
if (code == 0) {
sprintf(pathName,"/%s/",temp);
if (code == 0) {
sprintf(pathName,rw ? "/.%s/" : "/%s/",temp);
*pathNamep = strdup(strlwr(pathName));
return 1;
}
@ -1858,7 +1865,7 @@ void smb_SendPacket(smb_vc_t *vcp, smb_packet_t *inp)
{
NCB *ncbp;
int extra;
long code;
long code = 0;
unsigned char *tp;
int localNCB = 0;
#ifdef DJGPP
@ -2196,7 +2203,7 @@ long smb_ReceiveCoreReadRaw(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp
long count, minCount, finalCount;
unsigned short fd;
smb_fid_t *fidp;
long code;
long code = 0;
cm_user_t *userp = NULL;
NCB *ncbp;
int rc;
@ -2519,7 +2526,7 @@ void smb_WaitingLocksDaemon()
smb_vc_t *vcp;
smb_packet_t *inp, *outp;
NCB *ncbp;
long code;
long code = 0;
while(1) {
lock_ObtainWrite(&smb_globalLock);
@ -2839,7 +2846,7 @@ long smb_ReceiveCoreSearchVolume(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t
long smb_ApplyDirListPatches(smb_dirListPatch_t **dirPatchespp,
cm_user_t *userp, cm_req_t *reqp)
{
long code;
long code = 0;
cm_scache_t *scp;
char *dptr;
long dosTime;
@ -2905,7 +2912,7 @@ long smb_ReceiveCoreSearchDir(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *ou
int attribute;
long nextCookie;
char *tp;
long code;
long code = 0;
char *pathp;
cm_dirEntry_t *dep;
int maxCount;
@ -3388,7 +3395,7 @@ long smb_ReceiveCoreSearchDir(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *ou
long smb_ReceiveCoreCheckPath(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
{
char *pathp;
long code;
long code = 0;
cm_scache_t *rootScp;
cm_scache_t *newScp;
cm_user_t *userp;
@ -3450,7 +3457,7 @@ long smb_ReceiveCoreCheckPath(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *ou
long smb_ReceiveCoreSetFileAttributes(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
{
char *pathp;
long code;
long code = 0;
cm_scache_t *rootScp;
unsigned short attribute;
cm_attr_t attr;
@ -3547,7 +3554,7 @@ long smb_ReceiveCoreSetFileAttributes(smb_vc_t *vcp, smb_packet_t *inp, smb_pack
long smb_ReceiveCoreGetFileAttributes(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
{
char *pathp;
long code;
long code = 0;
cm_scache_t *rootScp;
cm_scache_t *newScp, *dscp;
long dosTime;
@ -3705,7 +3712,7 @@ long smb_ReceiveCoreOpen(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
char *lastNamep;
int share;
int attribute;
long code;
long code = 0;
cm_user_t *userp;
cm_scache_t *scp;
long dosTime;
@ -3833,7 +3840,7 @@ typedef struct smb_unlinkRock {
int smb_UnlinkProc(cm_scache_t *dscp, cm_dirEntry_t *dep, void *vrockp, osi_hyper_t *offp)
{
long code;
long code = 0;
smb_unlinkRock_t *rockp;
int caseFold;
int match;
@ -3875,7 +3882,7 @@ int smb_UnlinkProc(cm_scache_t *dscp, cm_dirEntry_t *dep, void *vrockp, osi_hype
long smb_ReceiveCoreUnlink(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
{
int attribute;
long code;
long code = 0;
char *pathp;
char *tp;
cm_space_t *spacep;
@ -3954,7 +3961,7 @@ typedef struct smb_renameRock {
int smb_RenameProc(cm_scache_t *dscp, cm_dirEntry_t *dep, void *vrockp, osi_hyper_t *offp)
{
long code;
long code = 0;
smb_renameRock_t *rockp;
int caseFold;
int match;
@ -3991,7 +3998,7 @@ int smb_RenameProc(cm_scache_t *dscp, cm_dirEntry_t *dep, void *vrockp, osi_hype
long smb_ReceiveCoreRename(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
{
long code;
long code = 0;
char *oldPathp;
char *newPathp;
char *tp;
@ -4143,7 +4150,7 @@ typedef struct smb_rmdirRock {
int smb_RmdirProc(cm_scache_t *dscp, cm_dirEntry_t *dep, void *vrockp, osi_hyper_t *offp)
{
long code;
long code = 0;
smb_rmdirRock_t *rockp;
int match;
char shortName[13];
@ -4178,7 +4185,7 @@ int smb_RmdirProc(cm_scache_t *dscp, cm_dirEntry_t *dep, void *vrockp, osi_hyper
long smb_ReceiveCoreRemoveDir(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
{
long code;
long code = 0;
char *pathp;
char *tp;
cm_space_t *spacep;
@ -4243,7 +4250,7 @@ long smb_ReceiveCoreFlush(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
unsigned short fid;
smb_fid_t *fidp;
cm_user_t *userp;
long code;
long code = 0;
cm_req_t req;
cm_InitReq(&req);
@ -4311,7 +4318,7 @@ void smb_FullName(cm_scache_t *dscp, cm_scache_t *scp, char *pathp,
char **newPathp, cm_user_t *userp, cm_req_t *reqp)
{
struct smb_FullNameRock rock;
long code;
long code = 0;
rock.name = pathp;
rock.vnode = scp;
@ -4330,7 +4337,7 @@ long smb_ReceiveCoreClose(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
smb_fid_t *fidp;
cm_user_t *userp;
long dosTime;
long code;
long code = 0;
cm_req_t req;
cm_InitReq(&req);
@ -4423,7 +4430,7 @@ long smb_ReadData(smb_fid_t *fidp, osi_hyper_t *offsetp, long count, char *op,
#endif /* !DJGPP */
{
osi_hyper_t offset;
long code;
long code = 0;
cm_scache_t *scp;
cm_buf_t *bufferp;
osi_hyper_t fileLength;
@ -4577,7 +4584,7 @@ long smb_WriteData(smb_fid_t *fidp, osi_hyper_t *offsetp, long count, char *op,
#endif /* !DJGPP */
{
osi_hyper_t offset;
long code;
long code = 0;
long written = 0;
cm_scache_t *scp;
osi_hyper_t fileLength; /* file's length at start of write */
@ -4807,7 +4814,7 @@ long smb_ReceiveCoreWrite(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
long count, written = 0;
unsigned short fd;
smb_fid_t *fidp;
long code;
long code = 0;
cm_user_t *userp;
cm_attr_t truncAttr; /* attribute struct used for truncating file */
char *op;
@ -4901,7 +4908,7 @@ void smb_CompleteWriteRaw(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp,
dos_ptr rawBuf;
#endif /* !DJGPP */
long written = 0;
long code;
long code = 0;
fd = smb_GetSMBParm(inp, 0);
fidp = smb_FindFID(vcp, fd, 0);
@ -4967,7 +4974,7 @@ long smb_ReceiveCoreWriteRaw(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *out
long totalCount;
unsigned short fd;
smb_fid_t *fidp;
long code;
long code = 0;
cm_user_t *userp;
char *op;
unsigned short writeMode;
@ -5083,7 +5090,7 @@ long smb_ReceiveCoreRead(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
long count, finalCount;
unsigned short fd;
smb_fid_t *fidp;
long code;
long code = 0;
cm_user_t *userp;
char *op;
@ -5148,7 +5155,7 @@ long smb_ReceiveCoreRead(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
long smb_ReceiveCoreMakeDir(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
{
char *pathp;
long code;
long code = 0;
cm_space_t *spacep;
char *tp;
cm_user_t *userp;
@ -5249,7 +5256,7 @@ BOOL smb_IsLegalFilename(char *filename)
long smb_ReceiveCoreCreate(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
{
char *pathp;
long code;
long code = 0;
cm_space_t *spacep;
char *tp;
int excl;
@ -5408,7 +5415,7 @@ long smb_ReceiveCoreCreate(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
long smb_ReceiveCoreSeek(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
{
long code;
long code = 0;
long offset;
int whence;
unsigned short fd;
@ -5467,7 +5474,7 @@ void smb_DispatchPacket(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp,
static showErrors = 0;
smb_dispatch_t *dp;
smb_t *smbp;
unsigned long code;
unsigned long code = 0;
unsigned char *outWctp;
int nparms; /* # of bytes of parameters */
char tbuffer[200];
@ -6328,7 +6335,7 @@ void InitNCBslot(int idx)
void smb_Listener(void *parmp)
{
NCB *ncbp;
long code;
long code = 0;
long len;
long i, j;
smb_vc_t *vcp;
@ -6994,7 +7001,7 @@ void smb_Shutdown(void)
#ifdef DJGPP
dos_ptr dos_ncb;
#endif
long code;
long code = 0;
int i;
/*fprintf(stderr, "Entering smb_Shutdown\n");*/

View File

@ -506,7 +506,7 @@ long smb_ReceiveV3Tran2A(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
int parmCount;
int dataCount;
int firstPacket;
long code;
long code = 0;
/* We sometimes see 0 word count. What to do? */
if (*inp->wctp == 0) {
@ -629,7 +629,7 @@ long smb_ReceiveTran2Open(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t *op)
{
char *pathp;
smb_tran2Packet_t *outp;
long code;
long code = 0;
cm_space_t *spacep;
int excl;
cm_user_t *userp;
@ -1066,7 +1066,7 @@ long cm_GetShortName(char *pathp, cm_user_t *userp, cm_req_t *reqp,
cm_space_t *spacep;
cm_scache_t *dscp;
int caseFold = CM_FLAG_FOLLOW | CM_FLAG_CASEFOLD;
long code;
long code = 0;
osi_hyper_t thyper;
spacep = cm_GetSpace();
@ -1112,7 +1112,7 @@ long smb_ReceiveTran2QPathInfo(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t
cm_user_t *userp;
cm_space_t *spacep;
cm_scache_t *scp, *dscp;
long code;
long code = 0;
char *op;
char *tidPathp;
char *lastComp;
@ -1321,7 +1321,7 @@ long smb_ReceiveTran2QFileInfo(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t
smb_fid_t *fidp;
cm_scache_t *scp;
char *op;
long code;
long code = 0;
cm_req_t req;
cm_InitReq(&req);
@ -1423,7 +1423,7 @@ long smb_ReceiveTran2QFileInfo(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t
long smb_ReceiveTran2SetFileInfo(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t *op)
{
long code;
long code = 0;
unsigned short fid;
smb_fid_t *fidp;
unsigned short infoLevel;
@ -1595,7 +1595,7 @@ long smb_ApplyV3DirListPatches(cm_scache_t *dscp,
smb_dirListPatch_t **dirPatchespp, int infoLevel, cm_user_t *userp,
cm_req_t *reqp)
{
long code;
long code = 0;
cm_scache_t *scp;
cm_scache_t *targetScp; /* target if scp is a symlink */
char *dptr;
@ -1880,7 +1880,7 @@ long smb_ReceiveTran2SearchDir(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t
int attribute;
long nextCookie;
char *tp;
long code;
long code = 0;
char *pathp;
cm_dirEntry_t *dep;
int maxCount;
@ -2492,7 +2492,7 @@ long smb_ReceiveV3FindNotifyClose(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t
long smb_ReceiveV3OpenX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
{
char *pathp;
long code;
long code = 0;
cm_space_t *spacep;
int excl;
cm_user_t *userp;
@ -2768,7 +2768,7 @@ long smb_ReceiveV3LockingX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
LARGE_INTEGER LOffset, LLength;
smb_waitingLock_t *waitingLock;
void *lockp;
long code;
long code = 0;
int i;
cm_InitReq(&req);
@ -2889,7 +2889,7 @@ long smb_ReceiveV3GetAttributes(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *
unsigned short fid;
smb_fid_t *fidp;
cm_scache_t *scp;
long code;
long code = 0;
long searchTime;
cm_user_t *userp;
cm_req_t req;
@ -2951,7 +2951,7 @@ long smb_ReceiveV3SetAttributes(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *
unsigned short fid;
smb_fid_t *fidp;
cm_scache_t *scp;
long code;
long code = 0;
long searchTime;
long unixTime;
cm_user_t *userp;
@ -3005,7 +3005,7 @@ long smb_ReceiveV3ReadX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
long count, finalCount;
unsigned short fd;
smb_fid_t *fidp;
long code;
long code = 0;
cm_user_t *userp;
char *op;
@ -3086,7 +3086,7 @@ long smb_ReceiveV3ReadX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
long smb_ReceiveNTCreateX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
{
char *pathp, *realPathp;
long code;
long code = 0;
cm_space_t *spacep;
cm_user_t *userp;
cm_scache_t *dscp; /* parent dir */
@ -3575,7 +3575,7 @@ long smb_ReceiveNTCreateX(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
long smb_ReceiveNTTranCreate(smb_vc_t *vcp, smb_packet_t *inp, smb_packet_t *outp)
{
char *pathp, *realPathp;
long code;
long code = 0;
cm_space_t *spacep;
cm_user_t *userp;
cm_scache_t *dscp; /* parent dir */

View File

@ -901,8 +901,10 @@ KFW_import_windows_lsa(void)
if (!pkrb5_init_context)
return;
#ifdef COMMENT
if ( !MSLSA_IsKerberosLogon() )
return;
#endif
code = pkrb5_init_context(&ctx);
if (code) goto cleanup;