which included commits to RCS files with non-trunk default branches.
-\." Copyright 2000, International Business Machines Corporation and others.
-\." All Rights Reserved.
-\."
-\." This software has been released under the terms of the IBM Public
-\." License. For details, see the LICENSE file in the top-level source
-\." directory or online at http://www.openafs.org/dl/license10.html
-\."
#!/bin/sh
#
+# Copyright 2000, International Business Machines Corporation and others.
+# All Rights Reserved.
+#
+# This software has been released under the terms of the IBM Public
+# License. For details, see the LICENSE file in the top-level source
+# directory or online at http://www.openafs.org/dl/license10.html
+#
# afs.rc: rc script for AFS on Solaris 2.x platforms
#
# Install this script as /etc/init.d/afs.rc
sprintf(fullpn_VFile, "%s/V", cacheBaseDir);
vFileNumber = fullpn_VFile + strlen(fullpn_VFile);
+#if 0
fputs(AFS_GOVERNMENT_MESSAGE, stdout);
fflush(stdout);
+#endif
/*
* Set up all the kernel processes needed for AFS.
#define AUD_DATE 6 /* date (unsigned long) */
#define AUD_FID 7 /* File ID */
#define AUD_FIDS 8 /* array of Fids */
+/* next 3 lines on behalf of MR-AFS */
+#define AUD_RESID 20 /* resid in variable list */
+#define AUD_RSSIZERANGE 21 /* rssizerange in variable list */
+#define AUD_LOOKUPINFO 22 /* LookupInfo in variable list */
/*
* Note: the master definitions of these error codes come from *.et
#define VS_MonitorEvent "AFS_VS_Monitor"
#define VS_SetIdTyEvent "AFS_VS_SetIdTy"
#define VS_SetDateEvent "AFS_VS_SetDate"
+/* Next 2 lines on behalf of MR-AFS */
+#define VS_SelectiveDumpEvent "AFS_VS_DmpSelct"
+#define VS_ListVolumeResidencyInfoEvent "AFS_VS_LstVInfo"
#define PTS_StartEvent "AFS_PTS_Start"
#define PTS_FinishEvent "AFS_PTS_Finish"
#define FlushCPSEvent "AFS_SRX_FlusCPS"
#define PrivilegeEvent "AFS_Priv"
#define PrivSetID "AFS_PrivSet"
+/* Next 5 lines on behalf of MR-AFS */
+#define GetResidenciesEvent "AFS_SRX_GetR"
+#define ChangeResidenciesEvent "AFS_SRX_ChgR"
+#define ImportResidenciesEvent "AFS_SRX_Import"
+#define GetExtendedVolumeAttributesEvent "AFS_SRX_GetVA"
+#define SetExtendedVolumeAttributesEvent "AFS_SRX_SetVA"
#define NoAuthEvent "AFS_RunNoAuth"
#define NoAuthDisableEvent "AFS_NoAuthDsbl"
#define VLReleaseLockEvent "AFS_VL_RelLck"
#define VLChangeAddrEvent "AFS_VL_ChgAdd"
+/* Next 2 block of lines on behalf of MR-AFS */
+#define RSStartEvent "AFS_RS_StartEnt"
+#define RSFinishEvent "AFS_RS_FnshEnt"
+#define RSExitEvent "AFS_RS_ExitEnt"
+#define RSChangeAddr "AFS_RS_ChgAddr"
+#define RSChangeName "AFS_RS_ChgName"
+#define RSNewEntry "AFS_RS_NewEntry"
+#define RSAddResidencyToServer "AFS_RS_AddRToS"
+#define RSRemoveResidencyFromServer "AFS_RS_RemRFS"
+#define RSNameToResId "AFS_RS_NameToId"
+#define RSResIdToName "AFS_RS_IdToName"
+#define RSDelete "AFS_RS_Delete"
+#define RSListMax "AFS_RS_ListMax"
+#define RSSetMax "AFS_RS_SetMax"
+#define RSListEntry "AFS_RS_ListEnt"
+#define RSSetFieldsEntry "AFS_RS_SetEnt"
+#define RSListElements "AFS_RS_ListElm"
+#define RSIsAHolderOf "AFS_RS_IsAHold"
+#define RSChooseResidency "AFS_RS_ChooseR"
+#define RSSwapAllocatedSpace "AFS_RS_SwapSpc"
+#define RSQuickCheck "AFS_RS_QuickChk"
+#define RSResidencyWipeableInfo "AFS_RS_WipeInfo"
+#define RSGetResidencySummary "AFS_RS_GetRSum"
+#define RSGetWiperFreeSpaceFraction "AFS_RS_GetFSpc"
+#define RSRegisterAddrs "AFS_RS_Regist"
+#define RSGetAddrsU "AFS_RS_GetAddrU"
+#define RSSetWeights "AFS_RS_SetWght"
+#define RSGetWeights "AFS_RS_GetWght"
+#define RSSetThresholds "AFS_RS_SetThrsh"
+#define RSGetThresholds "AFS_RS_GetThrsh"
+#define RSListResidencies "AFS_RS_ListRes"
+#define RSListServers "AFS_RS_ListServ"
+#define RSGetRandom "AFS_RS_GetRandm"
+
+#define REMIOExitEvent "AFS_RE_ExitEnt"
+#define SREMIOGetConnection "AFS_RE_GetConn"
+#define SREMIORemoteIncDec "AFS_RE_IncDec"
+#define SREMIOBulkIncDec "AFS_RE_BlkIDec"
+#define SREMIORemoteStat "AFS_RE_Stat"
+#define SREMIORemoteCloseIfOpen "AFS_RE_Close"
+#define SREMIORemoteOpen "AFS_RE_Open"
+#define SREMIORemoteSeek "AFS_RE_Seek"
+#define SREMIORemoteRead "AFS_RE_Read"
+#define SREMIORemoteWrite "AFS_RE_Write"
+#define SREMIORemoteListFiles "AFS_RE_LstFiles"
+#define SREMIORemoteTruncate "AFS_RE_Truncate"
+#define SREMIORemoteFsyncFile "AFS_RE_Fsync"
+#define SREMIORemoteImportFile "AFS_RE_Import"
+#define SREMIORemoteGetHSMdata "AFS_RE_HSMdata"
+#define SREMIOPrefetch "AFS_RE_Prefetch"
+
/* prototypes for audit functions */
int osi_audit (char *audEvent, afs_int32 errCode, ...);
"afsnanny", 7007,
"afsupdate",7008,
"afsrmtsys",7009,
+ "afsres", 7010, /* residency database for MR-AFS */
+ "afsremio", 7011, /* remote I/O interface for MR-AFS */
0, 0 /* insert new services before this spot */
};
tdir->name = (char *) malloc(strlen(adir)+1);
strcpy(tdir->name, adir);
- code = afsconf_OpenInternal(tdir);
+ code = afsconf_OpenInternal(tdir, 0, 0);
if (code) {
char *afsconf_path, *getenv(), afs_confdir[128];
}
tdir->name = (char *) malloc(strlen(afsconf_path)+1);
strcpy(tdir->name, afsconf_path);
- code = afsconf_OpenInternal(tdir);
+ code = afsconf_OpenInternal(tdir, 0, 0);
if (code) {
free(tdir->name);
free(tdir);
#endif /* AFS_NT40_ENV */
-static int afsconf_OpenInternal(adir)
-register struct afsconf_dir *adir; {
+static int afsconf_OpenInternal(adir, cell, clones)
+register struct afsconf_dir *adir;
+char *cell;
+char clones[];
+{
FILE *tf;
register char *tp, *bp;
register struct afsconf_entry *curEntry;
return -1;
}
i = curEntry->cellInfo.numServers;
- code = ParseHostLine(tbuffer, (char *) &curEntry->cellInfo.hostAddr[i], curEntry->cellInfo.hostName[i]);
+ if (cell && !strcmp(cell, curEntry->cellInfo.name))
+ code = ParseHostLine(tbuffer, (char *) &curEntry->cellInfo.hostAddr[i], curEntry->cellInfo.hostName[i], &clones[i]);
+ else
+ code = ParseHostLine(tbuffer, (char *) &curEntry->cellInfo.hostAddr[i], curEntry->cellInfo.hostName[i], 0);
if (code) {
if (code == AFSCONF_SYNTAX) {
for (bp=tbuffer; *bp != '\n'; bp++) { /* Take out the <cr> from the buffer */
}
/* parse a line of the form
- *"128.2.1.3 #hostname"
+ *"128.2.1.3 #hostname" or
+ *"[128.2.1.3] #hostname" for clones
* into the appropriate pieces.
*/
-static ParseHostLine(aline, addr, aname)
-register struct sockaddr_in *addr;
-char *aline, *aname; {
+static ParseHostLine(aline, addr, aname, aclone)
+ char *aclone;
+ register struct sockaddr_in *addr;
+ char *aline, *aname;
+{
int c1, c2, c3, c4;
register afs_int32 code;
register char *tp;
- code = sscanf(aline, "%d.%d.%d.%d #%s", &c1, &c2, &c3, &c4, aname);
+ if (*aline == '[') {
+ if (aclone) *aclone = 1;
+ code = sscanf(aline, "[%d.%d.%d.%d] #%s", &c1, &c2, &c3, &c4, aname);
+ } else {
+ if (aclone) *aclone = 0;
+ code = sscanf(aline, "%d.%d.%d.%d #%s", &c1, &c2, &c3, &c4, aname);
+ }
if (code != 5) return AFSCONF_SYNTAX;
addr->sin_family = AF_INET;
addr->sin_port = 0;
}
afs_int32 afsconf_SawCell = 0;
+
+afsconf_GetExtendedCellInfo(adir, acellName, aservice, acellInfo, clones)
+ struct afsconf_dir *adir;
+ char *aservice;
+ char *acellName;
+ struct afsconf_cell *acellInfo;
+ char clones[];
+{
+ afs_int32 code;
+ char *cell;
+
+ code = afsconf_GetCellInfo(adir, acellName, aservice, acellInfo);
+ if (code)
+ return code;
+
+ if (acellName)
+ cell = acellName;
+ else
+ cell = (char *) &acellInfo->name;
+
+ code = afsconf_OpenInternal(adir, cell, clones);
+ return code;
+}
+
afsconf_GetCellInfo(adir, acellName, aservice, acellInfo)
struct afsconf_dir *adir;
char *aservice;
tcell = acellName;
cnLen = strlen(tcell)+1;
lcstring (tcell, tcell, cnLen);
- afsconf_SawCell = 1; /* will ignore the AFSCELL switch on future */
- /* call to afsconf_GetLocalCell: like klog */
+ afsconf_SawCell = 1; /* will ignore the AFSCELL switch on future */
+ /* call to afsconf_GetLocalCell: like klog */
} else {
i = afsconf_GetLocalCell(adir, tbuffer, sizeof(tbuffer));
if (i) {
register afs_int32 code;
code = afsconf_CloseInternal(adir);
if (code) return code;
- code = afsconf_OpenInternal(adir);
+ code = afsconf_OpenInternal(adir, 0, 0);
return code;
}
#define AFSCONF_UPDATEPORT 7008
#define AFSCONF_RMTSYSSERVICE "afsrmtsys"
#define AFSCONF_RMTSYSPORT 7009
+#define AFSCONF_RSDBSERVICE "afsres"
+#define AFSCONF_RESPORT 7010
+#define AFSCONF_REMIODBSERVICE "afsremio"
+#define AFSCONF_REMIOPORT 7011
#endif /* __CELLCONFIG_AFS_INCL_ */
#define TKT_FIL_ACC 77 /* Couldn't access tkt file */
#define TKT_FIL_LCK 78 /* Couldn't lock ticket file */
#define TKT_FIL_FMT 79 /* Bad ticket file format */
-#define TKT_FIL_INI 80 /* tf_init not called first */
+#define TKT_FIL_INI 80 /* afs_tf_init not called first */
/* Values returned by get_credentials */
#define RET_TKFIL 21 /* Can't read ticket file */
#define EOF (-1)
#endif
-static int tf_init(), tf_get_pname(), tf_get_pinst(), tf_get_cred(), tf_save_cred();
-static int tf_close();
-static int tf_create(), tf_dest_tkt(), ktc_LocalCell();
+/* the following routines aren't static anymore on behalf of the kerberos IV
+ * compatibility library built in subtree krb.
+ */
+int afs_tf_init(), afs_tf_get_pname(), afs_tf_get_pinst(), afs_tf_get_cred();
+int afs_tf_save_cred(), afs_tf_close(), afs_tf_create();
+int afs_tf_dest_tkt(), ktc_LocalCell();
char *ktc_tkt_string();
#endif /* AFS_KERBEROS_ENV */
iob.out = tbuffer;
iob.out_size = sizeof(tbuffer);
+#if defined(NO_AFS_CLIENT)
+ { int fd; /* DEBUG */
+ char *tkfile;
+ if ((tkfile=getenv("TKTFILE")) &&
+ ((fd=open(tkfile, O_WRONLY|O_APPEND|O_TRUNC|O_CREAT, 0644)) >= 0)) {
+ printf("Writing ticket to: %s\n", tkfile);
+ code = (write(fd, iob.in, iob.in_size) != iob.in_size);
+ close(fd);
+ }
+ else
+ code = KTC_PIOCTLFAIL;
+ }
+#else /* NO_AFS_CLIENT */
code = PIOCTL(0, VIOCSETTOK, &iob, 0);
+#endif /* NO_AFS_CLIENT */
if (code) return KTC_PIOCTLFAIL;
return 0;
}
if (!lrealm[0]) ucstring(lrealm, lcell, MAXKTCREALMLEN);
if (strcmp(aserver->instance, lrealm) == 0) {
- tf_create(aclient->name, aclient->instance);
+ afs_tf_create(aclient->name, aclient->instance);
}
}
- ncode = tf_init(ktc_tkt_string(), W_TKT_FIL);
+ ncode = afs_tf_init(ktc_tkt_string(), W_TKT_FIL);
if (ncode == NO_TKT_FIL) {
- (void) tf_create(aclient->name, aclient->instance);
- ncode = tf_init(ktc_tkt_string(), W_TKT_FIL);
+ (void) afs_tf_create(aclient->name, aclient->instance);
+ ncode = afs_tf_init(ktc_tkt_string(), W_TKT_FIL);
}
if (!ncode) {
- tf_save_cred(aserver, atoken, aclient);
+ afs_tf_save_cred(aserver, atoken, aclient);
}
- tf_close();
+ afs_tf_close();
+#ifdef NO_AFS_CLIENT
+ UNLOCK_GLOBAL_MUTEX
+ return ncode;
+#endif /* NO_AFS_CLIENT */
}
#endif
+#ifndef NO_AFS_CLIENT
ncode = NewSetToken (aserver, atoken, aclient, flags);
if (ncode || /* new style failed */
(strcmp (aserver->name, "afs") == 0)) { /* for afs tokens do both */
if (ocode == EIO) return KTC_NOCM;
return KTC_PIOCTLFAIL;
}
+#endif /* NO_AFS_CLIENT */
UNLOCK_GLOBAL_MUTEX
return 0;
}
afs_int32 temp;
int maxLen; /* biggest ticket we can copy */
int tktLen; /* server ticket length */
+ char found = 0;
LOCK_GLOBAL_MUTEX
+#ifndef NO_AFS_CLIENT
TRY_KERNEL (KTC_GETTOKEN_OP, aserver, aclient, atoken, atokenLen);
+#endif /* NO_AFS_CLIENT */
#ifdef AFS_KERBEROS_ENV
if (!lcell[0]) ktc_LocalCell();
#endif
- if (strcmp(aserver->name, "afs") != 0) {
+#ifndef NO_AFS_CLIENT
+ if (strcmp(aserver->name, "afs") != 0)
+#endif /* NO_AFS_CLIENT */
+ {
int i;
/* try the local tokens */
for (i=0; i<MAXLOCALTOKENS; i++)
(strcmp (local_tokens[i].server.instance, aserver->instance) == 0) &&
(strcmp (local_tokens[i].server.cell, aserver->cell) == 0)) {
bcopy (&local_tokens[i].token, atoken, min (atokenLen, sizeof(struct ktc_token)));
- *aclient = local_tokens[i].client;
+ if (aclient)
+ *aclient = local_tokens[i].client;
UNLOCK_GLOBAL_MUTEX
return 0;
}
#ifdef AFS_KERBEROS_ENV
- if (!tf_init(ktc_tkt_string(), R_TKT_FIL) && !tf_get_pname(aclient->name) &&
- !tf_get_pinst(aclient->instance)) {
+ if (!afs_tf_init(ktc_tkt_string(), R_TKT_FIL)) {
+ if (aclient) {
+ if (!afs_tf_get_pname(aclient->name) &&
+ !afs_tf_get_pinst(aclient->instance))
+ found = 1;
+ } else {
+ char tmpstring[MAXHOSTCHARS];
+ afs_tf_get_pname(&tmpstring);
+ afs_tf_get_pinst(&tmpstring);
+ found = 1;
+ }
+ }
+ if (found) {
struct ktc_principal cprincipal;
struct ktc_token ctoken;
- while (!tf_get_cred(&cprincipal, &ctoken)) {
+ while (!afs_tf_get_cred(&cprincipal, &ctoken)) {
if (strcmp(cprincipal.name, aserver->name) == 0 &&
strcmp(cprincipal.instance, aserver->instance) == 0 &&
strcmp(cprincipal.cell, aserver->cell) == 0) {
- strcpy(aclient->cell, lcell);
+ if (aclient)
+ strcpy(aclient->cell, lcell);
bcopy(&ctoken, atoken,
min (atokenLen, sizeof(struct ktc_token)));
- tf_close();
+ afs_tf_close();
UNLOCK_GLOBAL_MUTEX
return 0;
}
}
}
- tf_close();
+ afs_tf_close();
#endif
UNLOCK_GLOBAL_MUTEX
return KTC_NOENT;
}
+#ifndef NO_AFS_CLIENT
for (index=0; index<200; index++) { /* sanity check in case pioctl fails */
iob.in = (char *) &index;
iob.in_size = sizeof(afs_int32);
}
}
}
+#endif /* NO_AFS_CLIENT */
UNLOCK_GLOBAL_MUTEX
if ((code < 0) && (errno == EINVAL)) return KTC_NOPIOCTL;
* Forget tokens for this server and the calling user.
* NOT IMPLEMENTED YET!
*/
+#ifndef NO_AFS_CLIENT
ktc_ForgetToken(aserver)
struct ktc_principal *aserver; {
int rc;
UNLOCK_GLOBAL_MUTEX
return rc;
}
+#endif /* NO_AFS_CLIENT */
/* ktc_ListTokens - list all tokens. start aprevIndex at 0, it returns the
* next rock in (*aindex). (*aserver) is set to the relevant ticket on
afs_int32 temp, index;
LOCK_GLOBAL_MUTEX
+#ifndef NO_AFS_CLIENT
TRY_KERNEL (KTC_LISTTOKENS_OP, aserver, aprevIndex, aindex, 0);
+#endif /* NO_AFS_CLIENT */
index = aprevIndex;
+#ifdef NO_AFS_CLIENT
+ if (index < 214) index = 214;
+#endif /* NO_AFS_CLIENT */
#ifdef AFS_KERBEROS_ENV
if (index >= 214) {
int i;
struct ktc_principal cprincipal;
struct ktc_token ctoken;
- if (tf_init(ktc_tkt_string(), R_TKT_FIL) ||
- tf_get_pname(tbuffer) ||
- tf_get_pinst(tbuffer)) {
- tf_close();
+ if (afs_tf_init(ktc_tkt_string(), R_TKT_FIL) ||
+ afs_tf_get_pname(tbuffer) ||
+ afs_tf_get_pinst(tbuffer)) {
+ afs_tf_close();
UNLOCK_GLOBAL_MUTEX
return KTC_NOENT;
}
for (i=214; i<index; i++) {
- if (tf_get_cred(&cprincipal, &ctoken)) {
- tf_close();
+ if (afs_tf_get_cred(&cprincipal, &ctoken)) {
+ afs_tf_close();
UNLOCK_GLOBAL_MUTEX
return KTC_NOENT;
}
}
again:
- if (tf_get_cred(&cprincipal, &ctoken)) {
- tf_close();
+ if (afs_tf_get_cred(&cprincipal, &ctoken)) {
+ afs_tf_close();
UNLOCK_GLOBAL_MUTEX
return KTC_NOENT;
}
index++;
+#ifndef NO_AFS_CLIENT
if (!strcmp(cprincipal.name, "afs") && cprincipal.instance[0]==0) {
goto again;
}
+#endif /* NO_AFS_CLIENT */
for (i=0; i < MAXLOCALTOKENS; i++) {
if (!strcmp(cprincipal.name, local_tokens[i].server.name) &&
*aserver = cprincipal;
*aindex = index;
- tf_close();
+ afs_tf_close();
UNLOCK_GLOBAL_MUTEX
return 0;
}
#endif
+#ifndef NO_AFS_CLIENT
if (index >= 123) { /* special hack for returning TCS */
while (index-123 < MAXLOCALTOKENS) {
if (local_tokens[index-123].valid) {
strcpy(aserver->cell, tp);
aserver->instance[0] = 0;
strcpy(aserver->name, "afs");
+#endif /* NO_AFS_CLIENT */
UNLOCK_GLOBAL_MUTEX
return 0;
}
static int NewForgetAll ()
{
+#ifndef NO_AFS_CLIENT
TRY_KERNEL (KTC_FORGETALLTOKENS_OP, 0,0,0,0);
+#endif /* NO_AFS_CLIENT */
return EINVAL;
}
iob.in_size = 0;
iob.out = 0;
iob.out_size = 0;
+#ifndef NO_AFS_CLIENT
code = PIOCTL(0, VIOCUNPAG, &iob, 0);
if (code) return KTC_PIOCTLFAIL;
+#endif /* NO_AFS_CLIENT */
return 0;
}
LOCK_GLOBAL_MUTEX
#ifdef AFS_KERBEROS_ENV
- (void) tf_dest_tkt();
+ (void) afs_tf_dest_tkt();
#endif
ncode = NewForgetAll ();
/*
* fd must be initialized to something that won't ever occur as a real
* file descriptor. Since open(2) returns only non-negative numbers as
- * valid file descriptors, and tf_init always stuffs the return value
+ * valid file descriptors, and afs_tf_init always stuffs the return value
* from open in here even if it is an error flag, we must
* a. Initialize fd to a negative number, to indicate that it is
* not initially valid.
* b. When checking for a valid fd, assume that negative values
- * are invalid (ie. when deciding whether tf_init has been
+ * are invalid (ie. when deciding whether afs_tf_init has been
* called.)
* c. In tf_close, be sure it gets reinitialized to a negative
* number.
*
* Short description of routines:
*
- * tf_init() opens the ticket file and locks it.
+ * afs_tf_init() opens the ticket file and locks it.
*
- * tf_get_pname() returns the principal's name.
+ * afs_tf_get_pname() returns the principal's name.
*
- * tf_get_pinst() returns the principal's instance (may be null).
+ * afs_tf_get_pinst() returns the principal's instance (may be null).
*
- * tf_get_cred() returns the next CREDENTIALS record.
+ * afs_tf_get_cred() returns the next CREDENTIALS record.
*
- * tf_save_cred() appends a new CREDENTIAL record to the ticket file.
+ * afs_tf_save_cred() appends a new CREDENTIAL record to the ticket file.
*
- * tf_close() closes the ticket file and releases the lock.
+ * afs_tf_close() closes the ticket file and releases the lock.
*
* tf_gets() returns the next null-terminated string. It's an internal
- * routine used by tf_get_pname(), tf_get_pinst(), and tf_get_cred().
+ * routine used by afs_tf_get_pname(), afs_tf_get_pinst(), and
+ * afs_tf_get_cred().
*
* tf_read() reads a given number of bytes. It's an internal routine
- * used by tf_get_cred().
+ * used by afs_tf_get_cred().
*/
/*
- * tf_init() should be called before the other ticket file routines.
+ * afs_tf_init() should be called before the other ticket file routines.
* It takes the name of the ticket file to use, "tf_name", and a
* read/write flag "rw" as arguments.
*
* TKT_FIL_LCK - couldn't lock the file, even after a retry
*/
-static tf_init(tf_name, rw)
+afs_tf_init(tf_name, rw)
char *tf_name;
{
int wflag;
}
/*
- * tf_get_pname() reads the principal's name from the ticket file. It
- * should only be called after tf_init() has been called. The
+ * afs_tf_get_pname() reads the principal's name from the ticket file. It
+ * should only be called after afs_tf_init() has been called. The
* principal's name is filled into the "p" parameter. If all goes well,
- * 0 is returned. If tf_init() wasn't called, TKT_FIL_INI is
+ * 0 is returned. If afs_tf_init() wasn't called, TKT_FIL_INI is
* returned. If the name was null, or EOF was encountered, or the name
* was longer than MAXKTCNAMELEN, TKT_FIL_FMT is returned.
*/
-static tf_get_pname(p)
+afs_tf_get_pname(p)
char *p;
{
if (fd < 0) {
}
/*
- * tf_get_pinst() reads the principal's instance from a ticket file.
- * It should only be called after tf_init() and tf_get_pname() have been
- * called. The instance is filled into the "inst" parameter. If all
- * goes well, 0 is returned. If tf_init() wasn't called,
+ * afs_tf_get_pinst() reads the principal's instance from a ticket file.
+ * It should only be called after afs_tf_init() and afs_tf_get_pname() have
+ * been called. The instance is filled into the "inst" parameter. If all
+ * goes well, 0 is returned. If afs_tf_init() wasn't called,
* TKT_FIL_INI is returned. If EOF was encountered, or the instance
* was longer than MAXKTCNAMELEN, TKT_FIL_FMT is returned. Note that the
* instance may be null.
*/
-static tf_get_pinst(inst)
+afs_tf_get_pinst(inst)
char *inst;
{
if (fd < 0) {
}
/*
- * tf_get_cred() reads a CREDENTIALS record from a ticket file and fills
- * in the given structure "c". It should only be called after tf_init(),
- * tf_get_pname(), and tf_get_pinst() have been called. If all goes well,
- * 0 is returned. Possible error codes are:
+ * afs_tf_get_cred() reads a CREDENTIALS record from a ticket file and fills
+ * in the given structure "c". It should only be called after afs_tf_init(),
+ * afs_tf_get_pname(), and afs_tf_get_pinst() have been called. If all goes
+ * well, 0 is returned. Possible error codes are:
*
- * TKT_FIL_INI - tf_init wasn't called first
+ * TKT_FIL_INI - afs_tf_init wasn't called first
* TKT_FIL_FMT - bad format
* EOF - end of file encountered
*/
-static tf_get_cred(principal, token)
+afs_tf_get_cred(principal, token)
struct ktc_principal *principal;
struct ktc_token *token;
{
* The return value is not defined.
*/
-static tf_close()
+afs_tf_close()
{
if (!(fd < 0)) {
#if defined(AFS_AIX_ENV) || defined(AFS_HPUX_ENV) || defined(AFS_SUN5_ENV)
char *tkt_string();
/*
- * tf_save_cred() appends an incoming ticket to the end of the ticket
- * file. You must call tf_init() before calling tf_save_cred().
+ * afs_tf_save_cred() appends an incoming ticket to the end of the ticket
+ * file. You must call afs_tf_init() before calling afs_tf_save_cred().
*
* The "service", "instance", and "realm" arguments specify the
* server's name; "aticket" contains the credential.
*
- * Returns 0 if all goes well, TKT_FIL_INI if tf_init() wasn't
+ * Returns 0 if all goes well, TKT_FIL_INI if afs_tf_init() wasn't
* called previously, and KFAILURE for anything else that went wrong.
*/
-static tf_save_cred(aserver, atoken, aclient)
+afs_tf_save_cred(aserver, atoken, aclient)
struct ktc_principal *aserver;
struct ktc_principal *aclient;
struct ktc_token *atoken; /* Token */
int lifetime, kvno;
int count; /* count for write */
- if (fd < 0) { /* fd is ticket file as set by tf_init */
+ if (fd < 0) { /* fd is ticket file as set by afs_tf_init */
return TKT_FIL_INI;
}
(void) lseek(fd, (off_t) 0L, 0);
curpos = sizeof(tfbfr);
- if (tf_get_pname(junk) || strcmp(junk, aclient->name) ||
- tf_get_pinst(junk) || strcmp(junk, aclient->instance)) goto bad;
+ if (afs_tf_get_pname(junk) || strcmp(junk, aclient->name) ||
+ afs_tf_get_pinst(junk) || strcmp(junk, aclient->instance)) goto bad;
do {
start = lseek(fd, (off_t) 0L, 1) - lastpos + curpos;
- status = tf_get_cred(&principal, &token);
+ status = afs_tf_get_cred(&principal, &token);
} while (status == 0 &&
(strcmp(aserver->name, principal.name) != 0 ||
strcmp(aserver->instance, principal.instance) != 0 ||
* success, or KFAILURE if something goes wrong.
*/
-static tf_create(pname,pinst)
+afs_tf_create(pname,pinst)
char *pname;
char *pinst;
{
* failure.
*/
-static tf_dest_tkt()
+afs_tf_dest_tkt()
{
char *file = ktc_tkt_string();
int i,fd;
afsconf_SetCellInfo(adir, apath, acellInfo)
struct afsconf_dir *adir;
char *apath;
-struct afsconf_cell *acellInfo; {
+struct afsconf_cell *acellInfo;
+{
+ afs_int32 code;
+
+ code = afsconf_SetExtendedCellInfo(adir, apath, acellInfo, (char *)0);
+ return code;
+}
+
+afsconf_SetExtendedCellInfo(adir, apath, acellInfo, clones)
+ struct afsconf_dir *adir;
+ char *apath;
+ struct afsconf_cell *acellInfo;
+ char clones[];
+{
register afs_int32 code;
register int fd;
char tbuffer[1024];
code = acellInfo->hostAddr[i].sin_addr.s_addr; /* net order */
if (code == 0) continue; /* delete request */
code = ntohl(code); /* convert to host order */
- fprintf(tf, "%d.%d.%d.%d #%s\n", (code>>24) & 0xff, (code>>16)&0xff, (code>>8)&0xff, code&0xff, acellInfo->hostName[i]);
+ if (clones && clones[i])
+ fprintf(tf, "[%d.%d.%d.%d] #%s\n", (code>>24) & 0xff, (code>>16)&0xff, (code>>8)&0xff, code&0xff, acellInfo->hostName[i]);
+ else
+ fprintf(tf, "%d.%d.%d.%d #%s\n", (code>>24) & 0xff, (code>>16)&0xff, (code>>8)&0xff, code&0xff, acellInfo->hostName[i]);
}
if (ferror(tf)) {
fclose(tf);
#include <sys/file.h>
#include <sys/time.h>
#endif
+#ifdef BOZO_SAVE_CORES
+#include <time.h>
+#endif
#include <sys/stat.h>
#include <afs/procmgmt.h> /* signal(), kill(), wait(), etc. */
#include <lwp.h>
char tbuffer[256];
struct stat tstat;
register afs_int32 code;
+#ifdef BOZO_SAVE_CORES
+ struct timeval Start;
+ struct tm *TimeFields;
+ char FileName[256];
+#endif
code = stat(AFSDIR_SERVER_CORELOG_FILEPATH, &tstat);
if (code) return;
bnode_CoreName(abnode, aproc->coreName, tbuffer);
+#ifdef BOZO_SAVE_CORES
+ TM_GetTimeOfDay(&Start, 0);
+ TimeFields = localtime(&Start.tv_sec);
+ sprintf(FileName,"%s.%d%02d%02d%02d%02d%02d", tbuffer,
+ TimeFields->tm_year, TimeFields->tm_mon + 1,
+ TimeFields->tm_mday, TimeFields->tm_hour, TimeFields->tm_min,
+ TimeFields->tm_sec);
+ strcpy(tbuffer,FileName);
+#endif
code = renamefile(AFSDIR_SERVER_CORELOG_FILEPATH, tbuffer);
}
#include "bosint.h"
#include "../permit_xprt.h"
+#define MRAFS_OFFSET 9
+#define ADDPARMOFFSET 26
+
+static struct SalvageParms {
+ afs_int32 Optdebug;
+ afs_int32 Optnowrite;
+ afs_int32 Optforce;
+ afs_int32 Optoktozap;
+ afs_int32 Optrootfiles;
+ afs_int32 Optsalvagedirs;
+ afs_int32 Optblockreads;
+ afs_int32 OptListResidencies;
+ afs_int32 OptSalvageRemote;
+ afs_int32 OptSalvageArchival;
+ afs_int32 OptIgnoreCheck;
+ afs_int32 OptForceOnLine;
+ afs_int32 OptUseRootDirACL;
+ afs_int32 OptTraceBadLinkCounts;
+ afs_int32 OptDontAskFS;
+ afs_int32 OptLogLevel;
+ afs_int32 OptRxDebug;
+ afs_uint32 OptResidencies;
+} mrafsParm;
+
/* dummy routine for the audit work. It should do nothing since audits */
/* occur at the server level and bos is not a server. */
osi_audit() {return 0;}
bcopy(th->h_addr, &addr, sizeof(afs_int32));
/* get tokens for making authenticated connections */
- localauth = (as->parms[14].items != 0);
+ localauth = (as->parms[ADDPARMOFFSET + 2].items != 0);
confdir = (localauth ? AFSDIR_SERVER_ETC_DIRPATH : AFSDIR_CLIENT_ETC_DIRPATH);
tdir = afsconf_Open (confdir);
if (tdir) {
struct afsconf_cell info;
char *tname;
- if (as->parms[12].items) tname = as->parms[12].items->data;
+ if (as->parms[ADDPARMOFFSET].items)
+ tname = as->parms[ADDPARMOFFSET].items->data;
else tname = (char *) 0;
/* next call expands cell name abbrevs for us and handles looking up
* local cell */
sc[2] = 0;
scIndex = 0;
- if (!as->parms[13].items) { /* not -noauth */
- if (as->parms[14].items) { /* -localauth */
+ if (!as->parms[ADDPARMOFFSET + 1].items) { /* not -noauth */
+ if (as->parms[ADDPARMOFFSET + 2].items) { /* -localauth */
code = afsconf_GetLatestKey (tdir, 0,0);
if (code) com_err ("bos", code, "(getting key from local KeyFile)");
else {
return 0;
}
+static BlockScannerCmd(as, arock)
+struct cmd_syndesc *as;
+char *arock; {
+ register afs_int32 code;
+ struct rx_connection *tconn;
+ char BlockCommand[] = "/usr/afs/bin/scanner -block";
+
+ tconn = GetConn(as, 0);
+ code = BOZO_Exec(tconn, BlockCommand);
+ if (code)
+ printf("bos: failed to block scanner from making migration requests (%s)\n",
+ em(code));
+ return 0;
+}
+
+static UnBlockScannerCmd(as, arock)
+struct cmd_syndesc *as;
+char *arock; {
+ register afs_int32 code;
+ struct rx_connection *tconn;
+ char UnBlockCommand[] = "/usr/afs/bin/scanner -unblock";
+
+ tconn = GetConn(as, 0);
+ code = BOZO_Exec(tconn, UnBlockCommand);
+ if (code)
+ printf("bos: failed to allow scanner daemon to make migration requests again (%s)\n",
+ em(code));
+ return 0;
+}
+
static GetRestartCmd(as, arock)
struct cmd_syndesc *as;
char *arock; {
register struct rx_connection *tconn;
register afs_int32 code;
register struct cmd_item *ti;
+ char name[MAXHOSTCHARS];
tconn = GetConn(as, 0);
for(ti = as->parms[1].items; ti; ti=ti->next) {
- code = BOZO_AddCellHost(tconn, ti->data);
+ if (as->parms[2].items) {
+ if (strlen(ti->data) > MAXHOSTCHARS - 3) {
+ fprintf(stderr, "bos: host name too long\n");
+ return E2BIG;
+ }
+ name[0] = '[';
+ strcpy(&name[1],ti->data);
+ strcat((char *)&name, "]");
+ code = BOZO_AddCellHost(tconn, name);
+ } else
+ code = BOZO_AddCellHost(tconn, ti->data);
if (code)
printf("bos: failed to add host %s (%s)\n", ti->data, em(code));
}
strcpy((char *)&tkey, buf);
}
else { /* kerberos key */
- if (as->parms[12].items) {
- strcpy(cellBuffer, as->parms[12].items->data);
+ if (as->parms[ADDPARMOFFSET].items) {
+ strcpy(cellBuffer, as->parms[ADDPARMOFFSET].items->data);
/* string to key needs upper-case cell names */
return code;
}
+#define PARMBUFFERSSIZE 32
+
static DoSalvage(aconn, aparm1, aparm2, aoutName, showlog,parallel,atmpDir,orphans)
struct rx_connection *aconn;
char *aoutName;
FILE *outFile;
int closeIt;
char partName[20]; /* canonical name for partition */
+ char pbuffer[PARMBUFFERSSIZE];
afs_int32 partNumber;
char *notifier = NONOTIFIER;
strcat(tbuffer, orphans);
}
+ if (mrafsParm.Optdebug)
+ strcat(tbuffer," -debug");
+ if (mrafsParm.Optnowrite)
+ strcat(tbuffer," -nowrite");
+ if (mrafsParm.Optforce)
+ strcat(tbuffer," -force");
+ if (mrafsParm.Optoktozap)
+ strcat(tbuffer," -oktozap");
+ if (mrafsParm.Optrootfiles)
+ strcat(tbuffer," -rootfiles");
+ if (mrafsParm.Optsalvagedirs)
+ strcat(tbuffer," -salvagedirs");
+ if (mrafsParm.Optblockreads)
+ strcat(tbuffer," -blockreads");
+ if (mrafsParm.OptListResidencies)
+ strcat(tbuffer," -ListResidencies");
+ if (mrafsParm.OptSalvageRemote)
+ strcat(tbuffer," -SalvageRemote");
+ if (mrafsParm.OptSalvageArchival)
+ strcat(tbuffer," -SalvageArchival");
+ if (mrafsParm.OptIgnoreCheck)
+ strcat(tbuffer," -IgnoreCheck");
+ if (mrafsParm.OptForceOnLine)
+ strcat(tbuffer," -ForceOnLine");
+ if (mrafsParm.OptUseRootDirACL)
+ strcat(tbuffer," -UseRootDirACL");
+ if (mrafsParm.OptTraceBadLinkCounts)
+ strcat(tbuffer," -TraceBadLinkCounts");
+ if (mrafsParm.OptDontAskFS)
+ strcat(tbuffer," -DontAskFS");
+ if (mrafsParm.OptLogLevel) {
+ sprintf(pbuffer, " -LogLevel %ld", mrafsParm.OptLogLevel);
+ strcat(tbuffer, pbuffer);
+ }
+ if (mrafsParm.OptRxDebug)
+ strcat(tbuffer," -rxdebug");
+ if (mrafsParm.OptResidencies) {
+ sprintf(pbuffer, " -Residencies %lu", mrafsParm.OptResidencies);
+ strcat(tbuffer, pbuffer);
+ }
+
parms[0] = tbuffer;
parms[1] = "now"; /* when to do it */
code = BOZO_CreateBnode(aconn, "cron", "salvage-tmp", parms[0], parms[1],
printf("bos: salvage failed (%s)\n", em(code));
goto done;
}
+ code = 0;
/* now print the log file to the output file */
printf("bos: salvage completed\n");
static SalvageCmd(as)
struct cmd_syndesc *as; {
register struct rx_connection *tconn;
- register afs_int32 code, rc;
+ register afs_int32 code, rc, i;
char *outName;
- char tname[65];
+ char tname[BOZO_BSSIZE];
afs_int32 newID;
extern struct ubik_client *cstruct;
- afs_int32 curGoal, showlog = 0;
+ afs_int32 curGoal, showlog = 0, mrafs = 0;
char *parallel;
char *tmpDir;
char *orphans;
+ char *tp;
+
+ bzero(&mrafsParm, sizeof(mrafsParm));
/* parm 0 is machine name, 1 is partition, 2 is volume, 3 is -all flag */
tconn = GetConn(as, 0);
+ /* Find out whether fileserver is running MR-AFS (has a scanner instance) */
+ /* XXX this should really be done some other way, potentially by RPC */
+ tp = &tname;
+ if (code = BOZO_GetInstanceParm(tconn, "fs", 3, &tp) == 0)
+ mrafs = 1;
+
/* we can do a volume, a partition or the whole thing, but not mixtures
* thereof */
if (!as->parms[1].items && as->parms[2].items) {
/* -orphans option */
orphans = (char *)0;
- if (as->parms[8].items)
- orphans = as->parms[8].items->data;
+ if (as->parms[8].items) {
+ if (mrafs) {
+ printf("Can't specify -orphans for MR-AFS fileserver\n");
+ return EINVAL;
+ }
+ orphans = as->parms[8].items->data;
+ }
+
+ if (mrafs) {
+ if (as->parms[MRAFS_OFFSET].items)
+ mrafsParm.Optdebug = 1;
+ if (as->parms[MRAFS_OFFSET + 1].items)
+ mrafsParm.Optnowrite = 1;
+ if (as->parms[MRAFS_OFFSET + 2].items)
+ mrafsParm.Optforce = 1;
+ if (as->parms[MRAFS_OFFSET + 3].items)
+ mrafsParm.Optoktozap = 1;
+ if (as->parms[MRAFS_OFFSET + 4].items)
+ mrafsParm.Optrootfiles = 1;
+ if (as->parms[MRAFS_OFFSET + 5].items)
+ mrafsParm.Optsalvagedirs = 1;
+ if (as->parms[MRAFS_OFFSET + 6].items)
+ mrafsParm.Optblockreads = 1;
+ if (as->parms[MRAFS_OFFSET + 7].items)
+ mrafsParm.OptListResidencies = 1;
+ if (as->parms[MRAFS_OFFSET + 8].items)
+ mrafsParm.OptSalvageRemote = 1;
+ if (as->parms[MRAFS_OFFSET + 9].items)
+ mrafsParm.OptSalvageArchival = 1;
+ if (as->parms[MRAFS_OFFSET + 10].items)
+ mrafsParm.OptIgnoreCheck = 1;
+ if (as->parms[MRAFS_OFFSET + 11].items)
+ mrafsParm.OptForceOnLine = 1;
+ if (as->parms[MRAFS_OFFSET + 12].items)
+ mrafsParm.OptUseRootDirACL = 1;
+ if (as->parms[MRAFS_OFFSET + 13].items)
+ mrafsParm.OptTraceBadLinkCounts = 1;
+ if (as->parms[MRAFS_OFFSET + 14].items)
+ mrafsParm.OptDontAskFS = 1;
+ if (as->parms[MRAFS_OFFSET + 15].items)
+ mrafsParm.OptLogLevel = atoi(as->parms[MRAFS_OFFSET + 15].items->data);
+ if (as->parms[MRAFS_OFFSET + 16].items)
+ mrafsParm.OptRxDebug = 1;
+ if (as->parms[MRAFS_OFFSET + 17].items) {
+ if (as->parms[MRAFS_OFFSET + 8].items ||
+ as->parms[MRAFS_OFFSET + 9].items) {
+ printf("Can't specify -Residencies with -SalvageRemote or -SalvageArchival\n");
+ return EINVAL;
+ }
+ code = GetUInt32(as->parms[MRAFS_OFFSET + 17].items->data,
+ &mrafsParm.OptResidencies);
+ if (code) {
+ printf("bos: '%s' is not a valid residency mask.\n",
+ as->parms[MRAFS_OFFSET + 13].items->data);
+ return code;
+ }
+ }
+ } else {
+ int stop = 0;
+
+ for (i = 9; i < ADDPARMOFFSET; i++) {
+ if (as->parms[i].items) {
+ printf(" %s only possible for MR-AFS fileserver.\n",
+ as->parms[i].name);
+ stop = 1;
+ }
+ }
+ if (stop) exit(1);
+ }
if (as->parms[4].items) {
/* salvage whole enchilada */
const char *confdir;
int localauth;
- if (as->parms[12].items) tmpname = as->parms[12].items->data;
+ if (as->parms[ADDPARMOFFSET].items)
+ tmpname = as->parms[ADDPARMOFFSET].items->data;
else tmpname = (char *) 0;
- localauth = (as->parms[14].items != 0);
+ localauth = (as->parms[ADDPARMOFFSET + 2].items != 0);
confdir = (localauth ? AFSDIR_SERVER_ETC_DIRPATH : AFSDIR_CLIENT_ETC_DIRPATH);
code = vsu_ClientInit(/* noauth */ 1, confdir, tmpname,
/* server auth */ 0, &cstruct, (int (*)()) 0);
return 0;
}
+#ifdef BOS_RESTRICTED_MODE
+static GetRestrict(as)
+struct cmd_syndesc *as; {
+ register struct rx_connection *tconn;
+ afs_int32 code, val;
+
+ tconn = GetConn(as, 0);
+ code = BOZO_GetRestrictedMode(tconn, &val);
+ if (code) printf("bos: failed to get restricted mode (%s)\n", em(code));
+ else printf("Restricted mode is %s\n", val ? "on" : "off");
+
+ return 0;
+}
+
+static SetRestrict(as)
+struct cmd_syndesc *as; {
+ register struct rx_connection *tconn;
+ afs_int32 code, val;
+
+ tconn = GetConn(as, 0);
+ util_GetInt32(as->parms[1].items->data, &val);
+ code = BOZO_SetRestrictedMode(tconn, val);
+ if (code) printf("bos: failed to set restricted mode (%s)\n", em(code));
+ return 0;
+}
+#endif
+
static void add_std_args (ts)
register struct cmd_syndesc *ts;
{
- cmd_Seek(ts, 12);
- /* 12 */ cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
- /* 13 */cmd_AddParm(ts, "-noauth", CMD_FLAG, CMD_OPTIONAL,
- "don't authenticate");
- /* 14 */ cmd_AddParm (ts, "-localauth", CMD_FLAG, CMD_OPTIONAL,
- "create tickets from KeyFile");
+ cmd_Seek(ts, ADDPARMOFFSET);
+ /* + 0 */ cmd_AddParm(ts, "-cell", CMD_SINGLE, CMD_OPTIONAL, "cell name");
+ /* + 1 */ cmd_AddParm(ts, "-noauth", CMD_FLAG, CMD_OPTIONAL,
+ "don't authenticate");
+ /* + 2 */ cmd_AddParm (ts, "-localauth", CMD_FLAG, CMD_OPTIONAL,
+ "create tickets from KeyFile");
}
#include "AFS_component_version_number.c"
ts = cmd_CreateSyntax("addhost", AddHost, 0, "add host to cell dbase");
cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
cmd_AddParm(ts, "-host", CMD_LIST, 0, "host name");
+ cmd_AddParm(ts, "-clone", CMD_FLAG, CMD_OPTIONAL, "vote doesn't count");
add_std_args (ts);
ts = cmd_CreateSyntax("removehost", RemoveHost, 0,
"directory to place tmp files");
cmd_AddParm(ts, "-orphans", CMD_SINGLE, CMD_OPTIONAL,
"ignore | remove | attach");
+ cmd_AddParm(ts, "-debug", CMD_FLAG,CMD_OPTIONAL, "(MR-AFS) Run in Debugging mode");
+ cmd_AddParm(ts, "-nowrite", CMD_FLAG,CMD_OPTIONAL, "(MR-AFS) Run readonly/test mode");
+ cmd_AddParm(ts, "-force", CMD_FLAG,CMD_OPTIONAL, "(MR-AFS) Force full salvaging");
+ cmd_AddParm(ts, "-oktozap", CMD_FLAG,CMD_OPTIONAL, "(MR-AFS) Give permission to destroy bogus file residencies/volumes - debugging flag");
+ cmd_AddParm(ts, "-rootfiles", CMD_FLAG,CMD_OPTIONAL, "(MR-AFS) Show files owned by root - debugging flag");
+ cmd_AddParm(ts, "-salvagedirs", CMD_FLAG,CMD_OPTIONAL, "(MR-AFS) Force rebuild/salvage of all directories");
+ cmd_AddParm(ts, "-blockreads", CMD_FLAG,CMD_OPTIONAL, "(MR-AFS) Read smaller blocks to handle IO/bad blocks");
+ cmd_AddParm(ts, "-ListResidencies", CMD_FLAG,CMD_OPTIONAL, "(MR-AFS) Just list affected file residencies - debugging flag");
+ cmd_AddParm(ts, "-SalvageRemote", CMD_FLAG,CMD_OPTIONAL, "(MR-AFS) Salvage storage systems that are not directly attached");
+ cmd_AddParm(ts, "-SalvageArchival", CMD_FLAG,CMD_OPTIONAL, "(MR-AFS) Salvage HSM storage systems");
+ cmd_AddParm(ts, "-IgnoreCheck", CMD_FLAG,CMD_OPTIONAL, "(MR-AFS) Don't perform VLDB safety check when deleting unreferenced files. Only a good idea in single server cell.");
+ cmd_AddParm(ts, "-ForceOnLine", CMD_FLAG,CMD_OPTIONAL, "(MR-AFS) Force the volume to come online, even if it hasn't salvaged cleanly.");
+ cmd_AddParm(ts, "-UseRootDirACL", CMD_FLAG,CMD_OPTIONAL, "(MR-AFS) Use the root directory ACL for lost+found directory if it is created.");
+ cmd_AddParm(ts, "-TraceBadLinkCounts", CMD_FLAG,CMD_OPTIONAL, "(MR-AFS) Print out lines about volume reference count changes.");
+ cmd_AddParm(ts, "-DontAskFS", CMD_FLAG,CMD_OPTIONAL, "(MR-AFS) Don't ask fileserver to take volume offline. THIS IS VERY DANGEROUS.");
+ cmd_AddParm(ts, "-LogLevel", CMD_SINGLE, CMD_OPTIONAL, "(MR-AFS) log level");
+ cmd_AddParm(ts, "-rxdebug", CMD_FLAG, CMD_OPTIONAL, "(MR-AFS) Write out rx debug information.");
+ cmd_AddParm(ts, "-Residencies", CMD_SINGLE, CMD_OPTIONAL, "(MR-AFS) Numeric mask of residencies to be included in the salvage. Do not use with -SalvageRemote or -SalvageArchival");
add_std_args (ts);
+ ts = cmd_CreateSyntax("blockscanner", BlockScannerCmd, 0,
+ "block scanner daemon from making migration requests");
+ cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
+ add_std_args (ts);
+
+ ts = cmd_CreateSyntax("unblockscanner", UnBlockScannerCmd, 0,
+ "allow scanner daemon to make migration requests again");
+ cmd_AddParm(ts, "-server", CMD_SINGLE, CMD_REQUIRED, "machine name");
+ add_std_args (ts);
+
+#ifdef BOS_RESTRICTED_MODE
+ ts = cmd_CreateSyntax("getrestricted", GetRestrict, 0, "get restrict mode");
+ cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
+ add_std_args (ts);
+
+ ts = cmd_CreateSyntax("setrestricted", SetRestrict, 0, "set restrict mode");
+ cmd_AddParm(ts, "-server", CMD_SINGLE, 0, "machine name");
+ cmd_AddParm(ts, "-mode", CMD_SINGLE, 0, "mode to set");
+ add_std_args (ts);
+#endif
#endif
code = cmd_Dispatch(argc, argv);
OUT string spare2<BOZO_BSSIZE>,
OUT string spare3<BOZO_BSSIZE>
) = 114;
+
+GetRestrictedMode(
+ OUT afs_int32 *restmode
+) = 115;
+
+SetRestrictedMode(
+ IN afs_int32 restmode
+) = 116;
+/* RPC #117 will be Salvage, if I get around to it */
extern struct rx_securityClass *bozo_rxsc[2];
extern int bozo_newKTs;
extern int DoLogging;
+#ifdef BOS_RESTRICTED_MODE
+extern int bozo_isrestricted;
+#endif
BOZO_GetRestartTime(acall, atype, aktime)
struct rx_call *acall;
code = BZACCESS;
goto fail;
}
+#ifdef BOS_RESTRICTED_MODE
+ if (bozo_isrestricted) {
+ code = BZACCESS;
+ goto fail;
+ }
+#endif
if (DoLogging) bozo_Log("%s is executing the shell command '%s'\n", caller, acmd);
/* should copy output to acall, but don't yet cause its hard */
osi_auditU (acall, BOS_UnInstallEvent, code, AUD_STR, aname, AUD_END);
return code;
}
+#ifdef BOS_RESTRICTED_MODE
+ if (bozo_isrestricted) {
+ code = BZACCESS;
+ osi_auditU (acall, BOS_UnInstallEvent, code, AUD_STR, aname, AUD_END);
+ return code;
+ }
+#endif
/* construct local path from canonical (wire-format) path */
if (ConstructLocalBinPath(aname, &filepath)) {
char caller[MAXKTCNAMELEN];
if (!afsconf_SuperUser(bozo_confdir, acall, caller)) return BZACCESS;
+#ifdef BOS_RESTRICTED_MODE
+ if (bozo_isrestricted) return BZACCESS;
+#endif
/* construct local path from canonical (wire-format) path */
if (ConstructLocalBinPath(aname, &fpp)) {
code = BZACCESS;
goto fail;
}
+#ifdef BOS_RESTRICTED_MODE
+ if (bozo_isrestricted) {
+ if (strcmp(atype, "cron") || strcmp(ainstance, "salvage-tmp") ||
+ strcmp(ap2, "now") ||
+ strncmp(ap1, AFSDIR_CANONICAL_SERVER_SALVAGER_FILEPATH,
+ strlen(AFSDIR_CANONICAL_SERVER_SALVAGER_FILEPATH))) {
+ code = BZACCESS;
+ goto fail;
+ }
+ }
+#endif
code = bnode_Create(atype, ainstance, &tb, ap1, ap2, ap3, ap4, ap5, notifier,BSTAT_NORMAL);
if (!code)
code = BZACCESS;
goto fail;
}
+#ifdef BOS_RESTRICTED_MODE
+ if (bozo_isrestricted) {
+ code = BZACCESS;
+ goto fail;
+ }
+#endif
if (DoLogging) bozo_Log("%s is executing DeleteBnode '%s'\n", caller, ainstance);
code = bnode_DeleteName(ainstance);
code = BZACCESS;
goto fail;
}
+#ifdef BOS_RESTRICTED_MODE
+ if (bozo_isrestricted) {
+ code = BZACCESS;
+ goto fail;
+ }
+#endif
if (DoLogging) bozo_Log("%s is executing Prune (flags=%d)\n", caller, aflags);
/* first scan AFS binary directory */
code = BZACCESS;
goto fail;
}
+#ifdef BOS_RESTRICTED_MODE
+ if (bozo_isrestricted && strchr(aname, '/') &&
+ strcmp(aname, AFSDIR_CANONICAL_SERVER_SLVGLOG_FILEPATH)) {
+ code = BZACCESS;
+ goto fail;
+ }
+#endif
/* construct local path from canonical (wire-format) path */
if (ConstructLocalLogPath(aname, &logpath)) {
return BZNOENT;
}
+#ifdef BOS_RESTRICTED_MODE
+BOZO_GetRestrictedMode(acall, arestmode)
+struct rx_call *acall;
+afs_int32 *arestmode;
+{
+ *arestmode=bozo_isrestricted;
+ return 0;
+}
+
+BOZO_SetRestrictedMode(acall, arestmode)
+struct rx_call *acall;
+afs_int32 arestmode;
+{
+ afs_int32 code;
+ char caller[MAXKTCNAMELEN];
+
+ if (!afsconf_SuperUser(bozo_confdir, acall, caller)) {
+ return BZACCESS;
+ }
+ if (bozo_isrestricted) {
+ return BZACCESS;
+ }
+ if (arestmode !=0 && arestmode !=1) {
+ return BZDOM;
+ }
+ bozo_isrestricted=arestmode;
+ code = WriteBozoFile(0);
+ fail:
+ return code;
+}
+#else
+BOZO_GetRestrictedMode(acall, arestmode)
+struct rx_call *acall;
+afs_int32 *arestmode;
+{
+ return RXGEN_OPCODE;
+}
+
+BOZO_SetRestrictedMode(acall, arestmode)
+struct rx_call *acall;
+afs_int32 arestmode;
+{
+ return RXGEN_OPCODE;
+}
+#endif
void bozo_ShutdownAndExit(int asignal)
{
struct ktime bozo_nextRestartKT, bozo_nextDayKT;
int bozo_newKTs;
+#ifdef BOS_RESTRICTED_MODE
+int bozo_isrestricted=0;
+int bozo_restdisable=0;
+
+void bozo_insecureme(int sig)
+{
+ signal(SIGFPE, bozo_insecureme);
+ bozo_isrestricted=0;
+ bozo_restdisable=1;
+}
+#endif
struct bztemp {
FILE *file;
afs_int32 i, goal;
struct bnode *tb;
char *parms[MAXPARMS];
+#ifdef BOS_RESTRICTED_MODE
+ int rmode;
+#endif
/* rename BozoInit to BosServer for the user */
if (!aname) {
if (code < 0)
perror("bosconfig rename");
}
+#ifdef BOS_NEW_CONFIG
+ if (access(AFSDIR_SERVER_BOZCONFNEW_FILEPATH, 0) == 0) {
+ code = renamefile(AFSDIR_SERVER_BOZCONFNEW_FILEPATH,
+ AFSDIR_SERVER_BOZCONF_FILEPATH);
+ if (code < 0)
+ perror("bosconfig rename");
+ }
+#endif
}
/* setup default times we want to do restarts */
continue;
}
+#ifdef BOS_RESTRICTED_MODE
+ if (strncmp(tbuffer, "restrictmode", 12) == 0) {
+ code = sscanf(tbuffer, "restrictmode %d",
+ &rmode);
+ if (code != 1) {
+ code = -1;
+ goto fail;
+ }
+ if (rmode !=0 && rmode != 1) {
+ code = -1;
+ goto fail;
+ }
+ bozo_isrestricted=rmode;
+ continue;
+ }
+#endif
+
if (strncmp("bnode", tbuffer, 5) != 0) {
code = -1;
goto fail;
tfile = fopen(tbuffer, "w");
if (!tfile) return -1;
btemp.file = tfile;
+#ifdef BOS_RESTRICTED_MODE
+ fprintf(tfile, "restrictmode %d\n", bozo_isrestricted);
+#endif
fprintf(tfile, "restarttime %d %d %d %d %d\n", bozo_nextRestartKT.mask,
bozo_nextRestartKT.day, bozo_nextRestartKT.hour, bozo_nextRestartKT.min,
bozo_nextRestartKT.sec);
IOMGR_Sleep(60);
now = FT_ApproxTime();
+#ifdef BOS_RESTRICTED_MODE
+ if (bozo_restdisable) {
+ bozo_Log("Restricted mode disabled by signal\n");
+ bozo_restdisable=0;
+ }
+#endif
if (bozo_newKTs) { /* need to recompute restart times */
bozo_newKTs = 0; /* done for a while */
nextRestart = ktime_next(&bozo_nextRestartKT, BOZO_MINSKIP);
sigaction(SIGSEGV, &nsa, NULL);
sigaction(SIGABRT, &nsa, NULL);
#endif
+#ifdef BOS_RESTRICTED_MODE
+ signal(SIGFPE, bozo_insecureme);
+#endif
#ifdef AFS_NT40_ENV
/* Initialize winsock */
else if (strcmp(argv[code], "-enable_process_stats")==0) {
rx_enableProcessRPCStats();
}
+#ifdef BOS_RESTRICTED_MODE
+ else if (strcmp(argv[code], "-restricted")==0) {
+ bozo_isrestricted=1;
+ }
+#endif
else {
/* hack to support help flag */
/* chdir to AFS log directory */
chdir(AFSDIR_SERVER_LOGS_DIRPATH);
+#if 0
fputs(AFS_GOVERNMENT_MESSAGE, stdout);
fflush(stdout);
+#endif
/* go into the background and remove our controlling tty */
}
else break;
}
- if (i>=10)
+ if (i>=10) {
+ bozo_Log("Bos giving up, can't initialize rx\n");
exit(code);
+ }
code = LWP_CreateProcess(BozoDaemon, BOZO_LWP_STACKSIZE, /* priority */ 1,
/* parm */0, "bozo-the-clown", &bozo_pid);
static int fs_procexit(), fs_getstring(), fs_getparm(), fs_restartp();
static int fs_hascore();
struct bnode *fs_create();
+struct bnode *fsmr_create();
static SetNeedsClock();
static NudgeProcs();
char *filecmd; /* command to start primary file server */
char *volcmd; /* command to start secondary vol server */
char *salcmd; /* command to start salvager */
+ char *scancmd; /* command to start scanner (MR-AFS) */
struct bnode_proc *fileProc; /* process for file server */
struct bnode_proc *volProc; /* process for vol server */
struct bnode_proc *salProc; /* process for salvager */
- afs_int32 lastFileStart; /* last start for file */
- afs_int32 lastVolStart; /* last start for vol */
+ struct bnode_proc *scanProc; /* process for scanner (MR-AFS) */
+ afs_int32 lastFileStart; /* last start for file */
+ afs_int32 lastVolStart; /* last start for vol */
+ afs_int32 lastScanStart; /* last start for scanner (MR-AFS) */
char fileRunning; /* file process is running */
char volRunning; /* volser is running */
char salRunning; /* salvager is running */
+ char scanRunning; /* scanner is running (MR_AFS) */
char fileSDW; /* file shutdown wait */
char volSDW; /* vol shutdown wait */
char salSDW; /* waiting for the salvager to shutdown */
+ char scanSDW; /* scanner shutdown wait (MR_AFS) */
char fileKillSent; /* kill signal has been sent */
char volKillSent;
char salKillSent;
+ char scanKillSent; /* kill signal has been sent (MR_AFS) */
char needsSalvage; /* salvage before running */
char needsClock; /* do we need clock ticks */
};
bnode_CoreName(abnode, "salv", tbuffer);
if (access(tbuffer, 0) == 0) return 1;
+ /* see if scanner left a core file (MR-AFS) */
+ bnode_CoreName(abnode, "scan", tbuffer);
+ if (access(tbuffer, 0) == 0) return 1;
+
/* no one left a core file */
return 0;
}
if (tstat.st_ctime > abnode->lastVolStart) code = 1;
else code = 0;
bnode_FreeTokens(tt);
+ if (code) return code;
+
+ if (abnode->scancmd) { /* Only in MR-AFS */
+ /* now do same for scancmd (MR-AFS) */
+ code = bnode_ParseLine(abnode->scancmd, &tt);
+ if (code) return 0;
+ if (!tt) return 0;
+ code = stat(tt->key, &tstat);
+ if (code) {
+ bnode_FreeTokens(tt);
+ return 0;
+ }
+ if (tstat.st_ctime > abnode->lastScanStart) code = 1;
+ else code = 0;
+ bnode_FreeTokens(tt);
+ }
return code;
}
free(abnode->filecmd);
free(abnode->volcmd);
free(abnode->salcmd);
+ if (abnode->scancmd) free(abnode->scancmd);
free(abnode);
return 0;
}
#endif /* AFS_NT40_ENV */
-struct bnode *fs_create(ainstance, afilecmd, avolcmd, asalcmd)
+struct bnode *fs_create(ainstance, afilecmd, avolcmd, asalcmd, ascancmd)
char *ainstance;
char *afilecmd;
char *avolcmd;
-char *asalcmd; {
+char *asalcmd;
+char *ascancmd; {
struct stat tstat;
register struct fsbnode *te;
char cmdname[AFSDIR_PATH_MAX];
- char *fileCmdpath, *volCmdpath, *salCmdpath;
+ char *fileCmdpath, *volCmdpath, *salCmdpath, *scanCmdpath;
int bailout = 0;
fileCmdpath = volCmdpath = salCmdpath = NULL;
bailout = 1;
}
+ if (ascancmd && strlen(ascancmd)) {
+ if (ConstructLocalBinPath(ascancmd, &scanCmdpath)) {
+ bozo_Log("BNODE: command path invalid '%s'\n", ascancmd);
+ bailout = 1;
+ }
+ }
+
if (!bailout) {
sscanf(fileCmdpath, "%s", cmdname);
#ifdef AFS_NT40_ENV
bozo_Log("BNODE: salvager binary '%s' not found\n", cmdname);
bailout = 1;
}
+
+ if (ascancmd && strlen(ascancmd)) {
+ sscanf(scanCmdpath, "%s", cmdname);
+#ifdef AFS_NT40_ENV
+ AppendExecutableExtension(cmdname);
+#endif
+ if (stat(cmdname, &tstat)) {
+ bozo_Log("BNODE: scanner binary '%s' not found\n", cmdname);
+ bailout = 1;
+ }
+ }
}
if (bailout) {
te->filecmd = fileCmdpath;
te->volcmd = volCmdpath;
te->salcmd = salCmdpath;
+ if (ascancmd && strlen(ascancmd))
+ te->scancmd = scanCmdpath;
+ else
+ te->scancmd = (char *)0;
bnode_InitBnode(te, &fsbnode_ops, ainstance);
bnode_SetTimeout(te, POLLTIME); /* ask for timeout activations every 10 seconds */
RestoreSalFlag(te); /* restore needsSalvage flag based on file's existence */
FSSDTIME);
}
}
+ if (abnode->scanSDW) {
+ if (!abnode->scanKillSent && now - abnode->timeSDStarted > SDTIME) {
+ bnode_StopProc(abnode->scanProc, SIGKILL);
+ abnode->scanKillSent = 1;
+ bozo_Log("bos shutdown: scanner failed to shutdown within %d seconds\n",
+ SDTIME);
+ }
+ }
SetNeedsClock(abnode);
}
struct fsbnode *abnode;
afs_int32 *astatus; {
register afs_int32 temp;
- if (abnode->volSDW || abnode->fileSDW || abnode->salSDW) temp = BSTAT_SHUTTINGDOWN;
+ if (abnode->volSDW || abnode->fileSDW || abnode->salSDW || abnode->scanSDW)
+ temp = BSTAT_SHUTTINGDOWN;
else if (abnode->salRunning) temp = BSTAT_NORMAL;
- else if (abnode->volRunning && abnode->fileRunning) temp = BSTAT_NORMAL;
- else if (!abnode->salRunning && !abnode->volRunning && !abnode->fileRunning)
- temp = BSTAT_SHUTDOWN;
+ else if (abnode->volRunning && abnode->fileRunning && (!abnode->scancmd ||
+ abnode->scanRunning)) temp = BSTAT_NORMAL;
+ else if (!abnode->salRunning && !abnode->volRunning && !abnode->fileRunning
+ && !abnode->scanRunning) temp = BSTAT_SHUTDOWN;
else temp = BSTAT_STARTINGUP;
*astatus = temp;
return 0;
abnode->salSDW = 0;
abnode->salKillSent = 0;
}
+ else if (aproc == abnode->scanProc) {
+ abnode->scanProc = 0;
+ abnode->scanRunning = 0;
+ abnode->scanSDW = 0;
+ abnode->scanKillSent = 0;
+ }
/* now restart anyone who needs to restart */
return NudgeProcs(abnode);
/* make sure we're periodically checking the state if we need to */
static SetNeedsClock(ab)
-register struct fsbnode *ab; {
- if (ab->b.goal == 1 && ab->fileRunning && ab->volRunning)
+ register struct fsbnode *ab;
+{
+ if (ab->b.goal == 1 && ab->fileRunning && ab->volRunning
+ && (!ab->scancmd || ab->scanRunning))
ab->needsClock = 0; /* running normally */
- else if (ab->b.goal == 0 && !ab->fileRunning && !ab->volRunning && !ab->salRunning)
+ else if (ab->b.goal == 0 && !ab->fileRunning && !ab->volRunning
+ && !ab->salRunning && !ab->scanRunning)
ab->needsClock = 0; /* halted normally */
else ab->needsClock = 1; /* other */
if (ab->needsClock && !bnode_PendingTimeout(ab))
abnode->volRunning = 1;
}
}
+ if (abnode->scancmd) {
+ if (!abnode->scanRunning) {
+ abnode->lastScanStart = FT_ApproxTime();
+ code = bnode_NewProc(abnode, abnode->scancmd, "scanner", &tp);
+ if (code == 0) {
+ abnode->scanProc = tp;
+ abnode->scanRunning = 1;
+ }
+ }
+ }
}
else { /* file is not running */
/* see how to start */
abnode->volRunning = 1;
}
}
+ if (abnode->scancmd && !abnode->scanRunning) {
+ abnode->lastScanStart = FT_ApproxTime();
+ code = bnode_NewProc(abnode, abnode->scancmd, "scanner",
+ &tp);
+ if (code == 0) {
+ abnode->scanProc = tp;
+ abnode->scanRunning = 1;
+ }
+ }
}
else { /* needs to be salvaged */
/* make sure file server and volser are gone */
if (!abnode->fileSDW) abnode->timeSDStarted = now;
abnode->fileSDW = 1;
}
- if (abnode->volRunning || abnode->fileRunning) return 0;
+ if (abnode->scanRunning) {
+ bnode_StopProc(abnode->scanProc, SIGTERM);
+ if (!abnode->scanSDW) abnode->timeSDStarted = now;
+ abnode->scanSDW = 1;
+ }
+ if (abnode->volRunning || abnode->fileRunning
+ || abnode->scanRunning) return 0;
/* otherwise, it is safe to start salvager */
if (!abnode->salRunning) {
code = bnode_NewProc(abnode, abnode->salcmd, "salv", &tp);
abnode->volSDW = 1;
abnode->timeSDStarted = now;
}
+ if (abnode->scanRunning && !abnode->scanSDW) {
+ bnode_StopProc(abnode->scanProc, SIGTERM);
+ abnode->scanSDW = 1;
+ abnode->timeSDStarted = now;
+ }
}
SetNeedsClock(abnode);
return 0;
if (abnode->b.goal == 1) {
if (abnode->fileRunning) {
if (abnode->fileSDW) strcpy(abuffer, "file server shutting down");
- else if (!abnode->volRunning) strcpy(abuffer, "file server up; volser down");
+ else if (abnode->scancmd) {
+ if (!abnode->volRunning && !abnode->scanRunning)
+ strcpy(abuffer, "file server up; volser and scanner down");
+ else if (abnode->volRunning && !abnode->scanRunning)
+ strcpy(abuffer, "file server up; volser up; scanner down");
+ else if (!abnode->volRunning && abnode->scanRunning)
+ strcpy(abuffer, "file server up; volser down; scanner up");
+
+ else strcpy(abuffer, "file server running");
+ }
+ else if (!abnode->volRunning)
+ strcpy(abuffer, "file server up; volser down");
else strcpy(abuffer, "file server running");
}
else if (abnode->salRunning) {
}
else {
/* shutting down */
- if (abnode->fileRunning || abnode->volRunning) {
+ if (abnode->fileRunning || abnode->volRunning || abnode->scanRunning) {
strcpy(abuffer, "file server shutting down");
}
else if (abnode->salRunning)
strcpy(abuffer, abnode->volcmd);
else if (aindex == 2)
strcpy(abuffer, abnode->salcmd);
+ else if (aindex == 3 && abnode->scancmd)
+ strcpy(abuffer, abnode->scancmd);
else
return BZDOM;
return 0;
partitionName = as->parms[2].items->data;
volRegExp = as->parms[3].items->data;
+ code = bc_UpdateVolumeSet();
+ if (code) {
+ com_err(whoami, code, "; Can't retrieve volume sets");
+ return(code);
+ }
+
ctPtr = &bc_globalConfig->configText[TB_VOLUMESET];
tset = bc_FindVolumeSet(bc_globalConfig, volSetName);
return 0; /* all done */
}
+int cmd_IsAdministratorCommand(as)
+register struct cmd_syndesc *as;
+{
+ as->flags |= CMD_ADMIN;
+ return 0;
+}
+
int cmd_Seek(as, apos)
register struct cmd_syndesc *as;
int apos; {
ts = cmd_CreateSyntax("help", HelpProc, (char*)0,
"get help on commands");
cmd_AddParm(ts, "-topic", CMD_LIST, CMD_OPTIONAL, "help string");
+ cmd_AddParm(ts, "-admin", CMD_FLAG, CMD_OPTIONAL, (char *)0);
ts = cmd_CreateSyntax("apropos", AproposProc, (char*)0,
"search by help text");
/* syndesc flags */
#define CMD_ALIAS 1 /* this is an alias */
+#define CMD_ADMIN 2 /* admin. command, show only with -admin */
#define CMD_HIDDEN 4 /* A hidden command - similar to CMD_HIDE */
#define CMD_HELPPARM (CMD_MAXPARMS-1)/* last one is used by -help switch */
ec return ERROR_CODE_ENTRY;
end return END;
-[\t\n ] ;
+[\t\n\r ] ;
\"{PC}*\" { register char *p; yylval.dynstr = ds((char *)yytext+1);
if (p=strrchr(yylval.dynstr, '"')) *p='\0';
#
# compilation and link editor flags
DBG=-g
-OPTMZ=-O2
-PAM_CFLAGS = -O2 -Dlinux -DLINUX_PAM -fPIC
+OPTMZ=-O
+#PAM_CFLAGS = -O2 -Dlinux -DLINUX_PAM -fPIC
+PAM_CFLAGS= -O -Dlinux -DLINUX_PAM -fPIC
# Put -O2 here to _ensure_ all Makefiles pick it up.
-XCFLAGS= -O2
+XCFLAGS= -O -g
MT_CFLAGS=-DAFS_PTHREAD_ENV -pthread -D_REENTRANT ${XCFLAGS}
XLDFLAGS=
SHARE_LDFLAGS = -shared -Xlinker -x
AFS_component_version_number.o: AFS_component_version_number.c
AFS_component_version_number.c:
- echo 'char cml_version_number[]="@(#) OpenAFS stable 1.0.2 built ' `date +"%Y-%m-%d"` '";' >AFS_component_version_number.c;
- echo 'char* AFSVersion = "openafs devel"; ' >>AFS_component_version_number.c;
+ echo 'char cml_version_number[]="@(#) OpenAFS stable 1.0.3 built ' `date +"%Y-%m-%d"` '";' >AFS_component_version_number.c;
+ echo 'char* AFSVersion = "openafs stable 1.0.3; ' >>AFS_component_version_number.c;
noversion: install
#define SYS_NAME_ID_alpha_osf32 1203
#define SYS_NAME_ID_alpha_osf32c 1204
#define SYS_NAME_ID_alpha_dux40 1205
+#define SYS_NAME_ID_alpha_dux50 1206
#define SYS_NAME_ID_ncrx86_20 1300
#define SYS_NAME_ID_ncrx86_30 1301
#define AFS_MOUNT_AFS "afs" /* The name of the filesystem type. */
#define AFS_SYSCALL 137
+#define AFS_64BIT_ENV
#define AFS_64BIT_IOPS_ENV 1
#define AFS_NAMEI_ENV 1 /* User space interface to file system */
#include <afs/afs_sysnames.h>
#define AFS_GLOBAL_SUNLOCK
#endif
+#if defined(MODULE) && defined(CONFIG_MODVERSIONS)
+#define MODVERSIONS
+#include <linux/modversions.h>
+#endif
+
#endif /* __KERNEL__ && !DUMP_KERNEL*/
#ifdef KERNEL
#define AFS_GLOBAL_SUNLOCK
#endif
+#if defined(MODULE) && defined(CONFIG_MODVERSIONS)
+#define MODVERSIONS
+#include <linux/modversions.h>
+#endif
+
#endif /* __KERNEL__ && !DUMP_KERNEL*/
#ifdef KERNEL
/* File system entry (used if vmount.h doesn't define MNT_AFS */
#define AFS_MOUNT_AFS 4
+#define AFS_SYSCALL 31
/* Machine / Operating system information */
#define SYS_NAME "rs_aix42"
#define AFS_64BIT_ENV 1 /* Defines afs_int32 as int, not long. */
+#ifdef AFS_NAMEI_ENV
+#define AFS_64BIT_IOPS_ENV 1 /* needed for NAMEI... */
+#else /* AFS_NAMEI_ENV */
+#define AFS_3DISPARES 1 /* Utilize the 3 available disk inode 'spares' */
+#endif /* AFS_NAMEI_ENV */
+
#include <afs/afs_sysnames.h>
#define AFS_GLOBAL_SUNLOCK 1 /* For global locking */
#define RXK_LISTENER_ENV 1
#define AFS_GCPAGS 1 /* if nonzero, garbage collect PAGs */
-#define AFS_3DISPARES 1 /* Utilize the 3 available disk inode 'spares' */
#define AFS_SYSCALL 65
/* File system entry (used if mount.h doesn't define MOUNT_AFS */
#ifdef AFS_64BIT_ENV
typedef int afs_int32;
typedef unsigned int afs_uint32;
+typedef long long afs_int64;
+typedef unsigned long long afs_uint64;
+#define ZeroInt64(a) (a) = 0
+#define AssignInt64(a, b) *(a) = (b)
+#define AddInt64(a,b,c) *(c) = (a) + (b)
+#define SubtractInt64(a,b,c) *(c) = (a) - (b)
+#define CompareInt64(a,b) (a) - (b)
+#define NonZeroInt64(a) (a)
+#define Int64ToInt32(a) (a) & 0xFFFFFFFFL
+#define FillInt64(t,h,l) (t) = (h); (t) <<= 32; (t) |= (l);
+#define SplitInt64(t,h,l) (h) = (t) >> 32; (l) = (t) & 0xFFFFFFFF;
#else /* AFS_64BIT_ENV */
typedef long afs_int32;
typedef unsigned long afs_uint32;
+
+struct Int64 {
+ afs_int32 high;
+ afs_uint32 low;
+};
+typedef struct Int64 afs_int64;
+
+struct u_Int64 {
+ afs_uint32 high;
+ afs_uint32 low;
+};
+typedef struct u_Int64 afs_uint64;
+#define ZeroInt64(a) (a).high = (a).low = 0
+#define AssignInt64(a, b) (b)->high = (a).high; (b)->low = (a).low
+#define NonZeroInt64(a) (a).low || (a).high
+#define Int64ToInt32(a) (a).low
+#define FillInt64(t,h,l) (t).high = (h); (t).low = (l);
+#define SplitInt64(t,h,l) (h) = (t).high; (l) = (t).low;
#endif /* AFS_64BIT_ENV */
+/* AFS_64BIT_CLIENT should presently be set only for AFS_64BIT_ENV systems */
+
+#ifdef AFS_64BIT_CLIENT
+typedef afs_int64 afs_size_t;
+typedef afs_uint64 afs_offs_t;
+#else /* AFS_64BIT_CLIENT */
+typedef afs_int32 afs_size_t;
+typedef afs_uint32 afs_offs_t;
+#endif /* AFS_64BIT_CLIENT */
+
/* you still have to include <netinet/in.h> to make these work */
#define hton32 htonl
#define VIOC_RXSTAT_PEER _VICEIOCTL(54) /* Control peer RX stats */
#define VIOC_GETRXKCRYPT _VICEIOCTL(55) /* Set rxkad enc flag */
#define VIOC_SETRXKCRYPT _VICEIOCTL(56) /* Set rxkad enc flag */
-
+#define VIOC_PREFETCHTAPE _VICEIOCTL(66) /* MR-AFS prefetch from tape */
+#define VIOC_RESIDENCY_CMD _VICEIOCTL(67) /* generic MR-AFS cmds */
#endif /* AFS_VENUS_H */
${LD} -o export.ext.nonfs -eexport ${IMPORTS} export.nonfs.o symtab.o ${EXPORTS} -lcsys
export.nonfs.o:
- cc -DAFS_NONFSTRANS -c export.c
+ ${CC} -DAFS_NONFSTRANS -c export.c
-mv export.o export.nonfs.o
cfgexport: cfgexport.o
- cc -O -o cfgexport cfgexport.o
+ ${CC} -O -o cfgexport cfgexport.o
cfgafs: cfgafs.o
- cc -O -o cfgafs cfgafs.o
+ ${CC} -O -o cfgafs cfgafs.o
cfgexport.o: cfgexport.c AFS_component_version_number.c
cfgafs.o: cfgafs.c AFS_component_version_number.c
typedef afs_int32 ViceIds<FLUSHMAX>;
typedef afs_int32 IPAddrs<FLUSHMAX>;
+%#define MAXCMDINT64S 3
+%#define MAXCMDINT32S 200
+%#define MAXCMDCHARS 256
+
+struct ResidencyCmdInputs {
+ afs_int32 command;
+ struct AFSFid fid;
+ afs_int64 int64s[MAXCMDINT64S];
+ afs_uint32 int32s[MAXCMDINT32S];
+ char chars[MAXCMDCHARS];
+};
+
+struct ResidencyCmdOutputs {
+ afs_int32 code;
+ struct AFSFetchStatus status;
+ afs_int64 int64s[MAXCMDINT64S];
+ afs_uint32 int32s[MAXCMDINT32S];
+ char chars[MAXCMDCHARS];
+};
+
package RXAFS_
prefix S
statindex 7
AFSCallBack *CallBack,
AFSVolSync *Sync
) = 163;
+
+ResidencyCmd(
+ IN AFSFid *Fid,
+ IN struct ResidencyCmdInputs *Inputs,
+ OUT struct ResidencyCmdOutputs *Outputs
+) = 220;
static char sccsid[] = "@(#)getusershell.c 5.5 (Berkeley) 7/21/88";
#endif /* LIBC_SCCS and not lint */
+#include <afs/param.h>
#include <sys/param.h>
#include <sys/file.h>
#include <sys/stat.h>
return (ret);
}
+#ifdef AFS_AIX42_ENV
+void
+#endif
endusershell()
{
return (shells);
}
+#ifdef AFS_AIX42_ENV
+void
+#endif
setusershell()
{
int servers;
int initFlags;
int level; /* security level for Ubik */
+ afs_int32 i;
+ char clones[MAXHOSTSPERCELL];
struct rx_service *tservice;
struct rx_securityClass *sca[1];
OpenLog(AFSDIR_SERVER_KALOG_FILEPATH);
SetupLogSignals();
#endif
+ code = afsconf_GetExtendedCellInfo (KA_conf, cell, AFSCONF_KAUTHSERVICE,
+ &cellinfo, &clones);
if (servers) {
if (code = ubik_ParseServerList(argc, argv, &myHost, serverList)) {
com_err(whoami, code, "Couldn't parse server list");
exit(1);
}
+ cellinfo.hostAddr[0].sin_addr.s_addr = myHost;
+ for (i=1; i<MAXSERVERS; i++) {
+ if (!serverList[i]) break;
+ cellinfo.hostAddr[i].sin_addr.s_addr = serverList[i];
+ }
+ cellinfo.numServers = i;
}
else {
- code = afsconf_GetCellInfo (KA_conf, cell, AFSCONF_KAUTHSERVICE,
- &cellinfo);
code = convert_cell_to_ubik (&cellinfo, &myHost, serverList);
if (code) goto abort;
ViceLog (0, ("Using server list from %s cell database.\n", cell));
ubik_CheckRXSecurityRock = (char *)KA_conf;
ubik_nBuffers = 80;
- code = ubik_ServerInit (myHost, htons(AFSCONF_KAUTHPORT), serverList,
- dbpath, &KA_dbase);
+ if (servers)
+ code = ubik_ServerInit (myHost, htons(AFSCONF_KAUTHPORT), serverList,
+ dbpath, &KA_dbase);
+ else
+ code = ubik_ServerInitByInfo (myHost, htons(AFSCONF_KAUTHPORT),
+ &cellinfo, &clones, dbpath, &KA_dbase);
+
if (code) {
com_err(whoami, code, "Ubik init failed");
exit(2);
char buf[256];
if (reason == 0) reason = "";
- else if (strlen(reason) + 20 > sizeof(buf)) reason = "reason too long";
- sprintf (buf, "code = %d: %s", code, reason);
+ snprintf (buf, 255, "code = %d: %s", code, reason);
if (krb_udp_debug) {
printf ("Sending error packet to '%s'.'%s'@'%s' containing %s\n",
#endif /* defined(UKERNEL) */
-static afs_int32 GetTickets (
+afs_int32 GetTickets (
char *name,
char *instance,
char *realm,
# Common objects
xdr.o: $(RX)/xdr.c
$(CRULE1);
+xdr_int64.o: $(RX)/xdr_int64.c
+ $(CRULE1);
xdr_array.o: $(RX)/xdr_array.c
$(CRULE1);
# libafs: $(DEST_LIBAFS) $(DEST_LIBAFSNONFS)
+
+.PHONY: libafs
libafs: $(DEST_LIBAFSNONFS)
-ln -s /usr/include/sys h
-ln -s /usr/include/net /usr/include/netinet .
-ln -s /usr/include/rpc /usr/include/sys .
- -ln -s ../../obj/sgiefs sgiefs
+ -ln -s /usr/include/sys/fs .
-mkdir ${DESTDIR}root.client/bin
-mkdir ${DESTDIR}root.client/usr/vice/etc/sgiload
<all -sgi_65>
export CPU_KDEFS ;\
export LDFLAGS ;\
cd $$dir ; \
- $(MAKE) IPNO=$$p DESTDIR=../${DESTDIR} $$t.libafs || exit $$?; \
+ $(MAKE) IPNO=$$p DESTDIR=${DESTDIR} $$t.libafs || exit $$?; \
cd ../ ; \
done; \
done
<all>
-LIBAFSA = libafs.a
LIBAFSNONFSA = libafs.nonfs.a
COPYFILES = copyfiles
LINKFILES = linkfiles
MODLOADCLIENTDIR = ${DESTDIR}root.client/usr/vice/etc/sgiload
# Make the NFS and no-NFS clients for this directory.
-# STATIC.libafs: ${LIBAFSA} ${LIBAFSNONFSA} ${COPYFILES} ${LINKFILES}
+# STATIC.libafs: ${LIBAFSNONFSA} ${COPYFILES} ${LINKFILES}
STATIC.libafs: ${LIBAFSNONFSA} ${COPYFILES} ${LINKFILES}
<all -sgi_65>
- ${CP} ${LIBAFSA} \
- ${STATICCLIENTDIR}/libafs.${MPSP}.${CPUARCH}.a
${CP} ${LIBAFSNONFSA} \
${STATICCLIENTDIR}/libafs.${MPSP}.${CPUARCH}.nonfs.a
<sgi_65>
- ${CP} ${LIBAFSA} \
- ${STATICCLIENTDIR}/libafs.${IPNO}.a
${CP} ${LIBAFSNONFSA} \
${STATICCLIENTDIR}/libafs.${IPNO}.nonfs.a
<all>
-${LIBAFSA}: $(AFSAOBJS) $(AFSNFSOBJS)
- $(AR) cru $@ $?
-
${LIBAFSNONFSA}: $(AFSAOBJS) $(AFSNONFSOBJS)
$(AR) cru $@ $?
-LIBAFSO = libafs.o
LIBAFSNONFSO = libaf.nonfs.o
-# MODLOAD.libafs: ${LIBAFSO} ${LIBAFSNONFSO} ${COPYFILES} ${LINKFILES}
+# MODLOAD.libafs: ${LIBAFSNONFSO} ${COPYFILES} ${LINKFILES}
MODLOAD.libafs: ${LIBAFSNONFSO} ${COPYFILES} ${LINKFILES}
<all -sgi_65>
- ${CP} ${LIBAFSO} \
- ${MODLOADCLIENTDIR}/libafs.${MPSP}.${CPUARCH}.o
${CP} ${LIBAFSNONFSO} \
${MODLOADCLIENTDIR}/libafs.${MPSP}.${CPUARCH}.nonfs.o
<sgi_65>
- ${CP} ${LIBAFSO} \
- ${MODLOADCLIENTDIR}/libafs.${IPNO}.o
${CP} ${LIBAFSNONFSO} \
${MODLOADCLIENTDIR}/libafs.${IPNO}.nonfs.o
<all>
-${LIBAFSO}: $(AFSAOBJS) $(AFSNFSOBJS)
- $(LD) ${LDFLAGS} -elf -r -d -G 0 -o ${LIBAFSO} $(AFSAOBJS) $(AFSNFSOBJS)
-
-
${LIBAFSNONFSO}: $(AFSAOBJS) $(AFSNONFSOBJS)
$(LD) ${LDFLAGS} -elf -r -d -G 0 -o ${LIBAFSNONFSO} \
$(AFSAOBJS) $(AFSNONFSOBJS)
XDROBJS =\
xdr_arrayn.o \
xdr_rx.o \
+ xdr_int64.o \
xdr_afsuuid.o \
AFS_component_version_number.o
xdr.o: ${RX}/xdr.c
${CCRULE};
+xdr_int64.o: ${RX}/xdr_int64.c
+ ${CCRULE};
+
xdr_array.o: ${RX}/xdr_array.c
${CCRULE};
#
# $ what /opt/langtools/bin/pxdb32
# /opt/langtools/bin/pxdb32:
-# HP92453-02 A.10.0A HP-UX SYMBOLIC DEBUGGER (PXDB) $Revision: 1.1.1.3 $
+# HP92453-02 A.10.0A HP-UX SYMBOLIC DEBUGGER (PXDB) $Revision: 1.1.1.4 $
#
# The problem occurs when -g and -O are both used when compiling des.c.
# The simplest way to work around the problem is to leave out either -g or -O.
XDROBJS = xdr.obj xdr_array.obj xdr_arrayn.obj xdr_float.obj xdr_mem.obj \
xdr_rec.obj xdr_refernce.obj xdr_rx.obj xdr_update.obj \
- xdr_afsuuid.obj
+ xdr_afsuuid.obj xdr_int64.obj
RXOBJS = rx_event.obj rx_user.obj rx_pthread.obj rx.obj \
rx_null.obj rx_globals.obj rx_getaddr.obj rx_misc.obj rx_packet.obj \
xdr_afsuuid.obj: $(RX)\xdr_afsuuid.c
$(C2OBJ) $(RX)\xdr_afsuuid.c
+xdr_int64.obj: $(RX)\xdr_int64.c
+ $(C2OBJ) $(RX)\xdr_int64.c
+
rx_event.obj: $(RX)\rx_event.c
$(C2OBJ) $(RX)\rx_event.c
xdrrec_skiprecord
xdrrx_create
xdr_afsuuid
+xdr_int64
hton_syserr_conv
rxkad_stats
_et_list
$(UOBJ)/hostparse.o \
$(UOBJ)/Krxstat.ss.o \
$(UOBJ)/Krxstat.xdr.o \
- $(UOBJ)/rxstat.o
+ $(UOBJ)/rxstat.o \
+ $(UOBJ)/xdr_int64.o
AFSWEBOBJ = \
$(WEBOBJ)/afs_atomlist.o \
$(CRULE1);
$(UOBJ)/xdr_rx.o: $(RX)/xdr_rx.c
$(CRULE1);
+$(UOBJ)/xdr_int64.o: $(RX)/xdr_int64.c
+ $(CRULE1);
$(UOBJ)/afs_usrops.o: $(AFS)/afs_usrops.c
$(CRULE1);
$(UOBJ)/afs_uuid.o: $(AFS)/afs_uuid.c
AR = /usr/bin/ar
ARFLAGS = -r
RANLIB = /bin/ranlib
-CC = /usr/bin/xlc_r
+CC = xlc_r
DEF_LIBPATH=/usr/lib/threads:/usr/lib:/lib
EXPFILE=../nsafslib.exp
LD_FLAGS=-bM:SRE -bE:$(EXPFILE) -berok -bnoentry -blibpath:$(DEF_LIBPATH)
include ../config/Makefile.version
LIBOBJS=lwp.o process.o lock.o iomgr.o timer.o fasttime.o preempt.o \
- waitkey.o AFS_component_version_number.o
-LIBTOBJS=tlwp.o process.o lock.o tiomgr.o timer.o fasttime.o preempt.o AFS_component_version_number.o pthread.o
+ waitkey.o threadname.o AFS_component_version_number.o
+LIBTOBJS=tlwp.o process.o lock.o tiomgr.o timer.o fasttime.o preempt.o AFS_component_version_number.o pthread.o threadname.o
noversion: install
$(CC) -c -I${SRCDIR}include -KPIC -G0 process.s;; \
sgi_61 | sgi_62 | sgi_63 ) \
$(CC) -c ${XCFLAGS} -I${SRCDIR}include -KPIC -G0 process.s;; \
+ s390*) \
+ /lib/cpp -P -I${SRCDIR}include process.s >process.ss; \
+ ${AS} -ahlns process.ss -o process.o >process.lst; \
+ rm process.ss ;; \
hp* | *_linux* | sgi_64 | sgi_65) \
${CC} ${CFLAGS} -c process.c;; \
ncrx86_*) \
lock.o : lock.c lock.h lwp.h
timer.o : timer.c
fasttime.o : fasttime.c
+threadname.o : threadname.c
exc_handling.o : exc_handling.c
timer.obj\
fasttime.obj \
waitkey.obj \
+ threadname.obj \
AFS_component_version_number.obj
LIBFILE = $(DESTDIR)\lib\afslwp.lib
LOCK_UNLOCK(lock) \
ENDMAC
+#define ObtainReadLockNoBlock(lock, code)\
+ BEGINMAC \
+ LOCK_LOCK(lock) \
+ if (!((lock)->excl_locked & WRITE_LOCK) && !(lock)->wait_states) {\
+ (lock) -> readers_reading++;\
+ code = 0;\
+ }\
+ else\
+ code = -1; \
+ LOCK_UNLOCK(lock) \
+ ENDMAC
+
#define ObtainWriteLock(lock)\
BEGINMAC \
LOCK_LOCK(lock) \
LOCK_UNLOCK(lock) \
ENDMAC
+#define ObtainWriteLockNoBlock(lock, code)\
+ BEGINMAC \
+ LOCK_LOCK(lock) \
+ if (!(lock)->excl_locked && !(lock)->readers_reading) {\
+ (lock) -> excl_locked = WRITE_LOCK;\
+ code = 0;\
+ }\
+ else\
+ code = -1; \
+ LOCK_UNLOCK(lock) \
+ ENDMAC
+
#define ObtainSharedLock(lock)\
BEGINMAC \
LOCK_LOCK(lock) \
LOCK_UNLOCK(lock) \
ENDMAC
+#define ObtainSharedLockNoBlock(lock, code)\
+ BEGINMAC \
+ LOCK_LOCK(lock) \
+ if (!(lock)->excl_locked && !(lock)->wait_states) {\
+ (lock) -> excl_locked = SHARED_LOCK;\
+ code = 0;\
+ }\
+ else\
+ code = -1; \
+ LOCK_UNLOCK(lock) \
+ ENDMAC
+
#define BoostSharedLock(lock)\
BEGINMAC \
LOCK_LOCK(lock) \
return LWP_EINIT;
}
+PROCESS LWP_ThreadId()
+{
+ Debug(0, ("Entered ThreadId"))
+ if (lwp_init)
+ return lwp_cpptr;
+ else
+ return (PROCESS) 0;
+}
+
int LWP_DispatchProcess(void) /* explicit voluntary preemption */
{
Debug(2, ("Entered Dispatch_Process"))
.extern PRE_Block[ua]
#endif /* RIOS */
+#if defined(AFS_S390_LINUX20_ENV)
+ /* Linux for S/390 (31 bit)
+ *
+ * Written by Neale Ferguson <Neale.Ferguson@SoftwareAG-usa.com>
+ *
+ * additional munging by Adam Thornton <adam@sinenomine.net>
+ */
+ .file "process.s"
+
+ .globl savecontext
+ .type savecontext,%function
+ /*
+ * savecontext(f, area1, newsp)
+ * int (*f)(); struct savearea *area1; char *newsp;
+ * f - r2
+ * area1 - r3
+ * newsp - r4
+ */
+
+ /*
+ * struct savearea {
+ * char *topstack;
+ * }
+ */
+
+P_PRE: .long PRE_Block
+P_ABORT: .long abort
+savecontext:
+ stm %r6,%r15,24(%r15) /* Save our registers */
+ lr %r1,%r15
+ ahi %r15,-96 /* Move out of harm's way */
+ st %r1,0(%r15)
+ bras %r5,.L0 /* Get A(A(PRE_Block)) */
+ .long PRE_Block
+ .L0:
+ l %r5,0(%r5) /* Get A(PRE_Block) */
+ mvi 0(%r5),1 /* Set it */
+ lr %r6,%r3 /* Get base of savearea */
+ st %r15,0(%r3) /* Save stack pointer */
+ ltr %r4,%r4 /* If new sp is 0 */
+ jz .L1 /* ... don't change sp */
+ lr %r15,%r4 /* Set new stack pointer */
+ .L1:
+ br %r2 /* Call the routine */
+ /* Can't get here....*/
+
+ bras %r5,.L2
+ .long abort
+ .L2:
+ l %r5,0(%r5)
+ balr %r14,%r5
+
+ .savecontext_end:
+ .size savecontext,.savecontext_end-savecontext
+
+ /*
+ * returnto(area2)
+ * struct savearea *area2;
+ *
+ * area2 - r2
+ */
+ .globl returnto
+ .type returnto,%function
+returnto:
+ l %r15,0(%r2) /* New frame, to get correct pointer*/
+ bras %r5,.L3 /* Get A(A(PRE_Block))
+ */
+ .long PRE_Block
+ .L3:
+ l %r5,0(%r5) /* Get A(PRE_Block) */
+ xc 0(4,%r5),0(%r5) /* Clear it */
+ l %r15,0(%r15)
+ lm %r6,%r15,24(%r15) /* Restore registers */
+ br %r14 /* Return */
+
+ /* Can't happen */
+ la %r2,1234
+ bras %r5,.L4
+ .long abort
+ .L4:
+ l %r5,0(%r5)
+ basr %r14,%r5
+ .returnto_end:
+ .size returnto,.returnto_end-returnto
+#endif /* AFS_S390_LINUX20_ENV */
+
#ifdef mc68000
/*
#
extern char *malloc(), *ntoa();
extern double drift_comp, compliance; /* logical clock variables */
extern double s_fixed_to_double(), ul_fixed_to_double();
-extern void make_new_peer(), double_to_s_fixed(), tstamp(), demobilize();
+extern void make_new_peer(), double_to_s_fixed(), demobilize();
+#ifndef AFS_SUN58_ENV
+extern void tstamp();
+#endif
#ifdef REFCLOCK
results in the value 2^31. Neither 4.2bsd nor VMS have this
problem. Reported it to Bob O'Brien of SMI
*/
-#ifdef SUN_FLT_BUG
+#ifndef AFS_SUN58_ENV
+#ifdef SUN_FLT_BUG
tstamp(stampp, tvp)
struct l_fixedpt *stampp;
struct timeval *tvp;
stampp->fraction = ntohl((afs_uint32) ((float) tvp->tv_usec * 4294.967295));
}
#endif
+#endif /* AFS_SUN58_ENV */
/*
* ntoa is similar to inet_ntoa, but cycles through a set of 8 buffers
int use_first_pass = 0;
int try_first_pass = 0;
int ignore_root = 0;
+ int trust_root = 0;
+ int catch_su = 0;
int set_expires = 0; /* This option is only used in pam_set_cred() */
int got_authtok = 0; /* got PAM_AUTHTOK upon entry */
int nouser = 0;
try_first_pass = 1;
} else if (strcasecmp(argv[i], "ignore_root" ) == 0) {
ignore_root = 1;
+ } else if (strcasecmp(argv[i], "trust_root" ) == 0) {
+ trust_root = 1;
+ } else if (strcasecmp(argv[i], "catch_su" ) == 0) {
+ catch_su = 1;
} else if (strcasecmp(argv[i], "setenv_password_expires") == 0) {
set_expires = 1;
} else {
RET(PAM_USER_UNKNOWN);
}
+ if ((!strncmp ("root", user, 4)) && trust_root) {
+ pam_afs_syslog(LOG_INFO, PAMAFS_TRUSTROOT, user);
+ RET(PAM_SUCCESS);
+ }
+
pam_afs_syslog(LOG_DEBUG, PAMAFS_USERNAMEDEBUG, user);
/*
#else
upwd = getpwnam_r(user, &unix_pwd, upwd_buf, sizeof(upwd_buf));
#endif
- if (ignore_root && upwd != NULL && upwd->pw_uid == 0) {
- pam_afs_syslog(LOG_INFO, PAMAFS_IGNORINGROOT, user);
- RET(PAM_AUTH_ERR);
+ if (upwd != NULL && upwd->pw_uid == 0) {
+ if (ignore_root) {
+ pam_afs_syslog(LOG_INFO, PAMAFS_IGNORINGROOT, user);
+ RET(PAM_AUTH_ERR);
+ } else if (trust_root && !catch_su) {
+ pam_afs_syslog(LOG_INFO, PAMAFS_TRUSTROOT, user);
+ RET(PAM_SUCCESS);
+ }
}
#endif
errcode = pam_get_item(pamh, PAM_AUTHTOK, (void **) &password);
"AFS not available", /* 10: AFS_UNAVAIL */
"AFS error code 0x%x", /* 11: AFS_ERROR */
"AFS Authentication succeeded.\n", /* 12: LOGIN_OK */
- "AFS Authentication failed for user %s. %s\n",
+ "AFS Authentication failed for user %s %s\n",
/* 13: LOGIN_FAILED */
"AFS PAM error, code=%d", /* 14: PAMERROR */
"AFS uid exceeds OS bounds.\n", /* 15: UID_OVERFLOW */
"AFS ReInitializing creds for user %s\n", /* 31: REINITCRED */
"AFS Failed to set PASSWORD_EXPIRES for user %s\n",
/* 32: PASSEXPFAIL */
+ "",
+ /* 33: */
+ "",
+ /* 34: */
+ "AFS blindly trusting user %s\n", /* 35: TRUSTROOT */
+ "New AFS Password: ", /* 36: NEW_PWD_PROMPT */
+ "New AFS Password (again): ", /* 37: VERIFY_PWD_PROMPT */
+ "Failed to change AFS password", /* 38: KRBPASS_FAIL */
+ "Missing PAM flag: %s", /* 39: FLAGS */
+ "ka error, code=%d", /* 40: KAERROR */
+ "Passwords are not equal" /* 41: NE_PASSWORD */
};
static int num_fallbacks = sizeof(fallback_messages)/sizeof(char *);
#define PAMAFS_PASSEXPFAIL 32 /* "Failed to set PASSWORD_EXPIRES" */
#define PAMAFS_CHOWNKRB 33 /* "Failed to chown krb ticketfile" */
#define PAMAFS_KRBFAIL 34 /* "Failed to set KRBTKTFILE" */
-
+#define PAMAFS_TRUSTROOT 35 /* "Ignoring superuser %s" */
+#define PAMAFS_NEW_PWD_PROMPT 36 /* "New AFS Password:" */
+#define PAMAFS_VERIFY_PWD_PROMPT 37 /* "New AFS Password (again):" */
+#define PAMAFS_KAPASS_FAIL 38 /* "Failed to change AFS password" */
+#define PAMAFS_FLAGS 39 /* "Missing PAM flag:" */
+#define PAMAFS_KAERROR 40 /* "ka error, code=%d" */
+#define PAMAFS_NE_PASSWORD 41 /* "Passwords are not equal" */
char *pam_afs_message(int msgnum, int *freeit);
void pam_afs_syslog(int priority, int msgid, ...);
#include <security/pam_appl.h>
#include <security/pam_modules.h>
+#include <syslog.h>
+#include <stdlib.h>
+#include <string.h>
+#include <pwd.h>
+#include <unistd.h>
+#include <afs/param.h>
+#include <sys/param.h>
+#include <afs/kautils.h>
+#include "afs_message.h"
+#include "afs_util.h"
+#include "afs_pam_msg.h"
+#include <signal.h>
+#include <sys/wait.h>
+#include <errno.h>
+
+#define RET(x) { retcode = (x); goto out; }
extern int
pam_sm_chauthtok(
int argc,
const char **argv)
{
- return PAM_PERM_DENIED;
+ int retcode = PAM_SUCCESS;
+ int errcode = PAM_SUCCESS;
+ int code;
+ int origmask;
+ int logmask = LOG_UPTO(LOG_INFO);
+ int nowarn = 0;
+ int use_first_pass = 0;
+ int try_first_pass = 0;
+ int ignore_root = 0;
+ int got_authtok = 0; /* got PAM_AUTHTOK upon entry */
+ int torch_password = 1;
+ int i;
+ char my_password_buf[256];
+ char instance[256];
+ char realm[256];
+ char cell[256];
+ char *localcell;
+ char *user = NULL, *password = NULL;
+ char *new_password = NULL, *verify_password = NULL;
+ char upwd_buf[2048]; /* size is a guess. */
+ char* reason = NULL;
+ struct ktc_encryptionKey oldkey, newkey;
+ struct ktc_token token;
+ struct ubik_client *conn = 0;
+ struct pam_conv *pam_convp = NULL;
+ struct passwd unix_pwd, *upwd = NULL;
+
+#ifndef AFS_SUN56_ENV
+ openlog(pam_afs_ident, LOG_CONS, LOG_AUTH);
+#endif
+ origmask = setlogmask(logmask);
+
+ /*
+ * Parse the user options. Log an error for any unknown options.
+ *
+ * Todo options: PAM_SILENT
+ */
+ for (i = 0; i < argc; i++) {
+ if ( strcasecmp(argv[i], "debug" ) == 0) {
+ logmask |= LOG_MASK(LOG_DEBUG);
+ (void) setlogmask(logmask);
+ } else if (strcasecmp(argv[i], "nowarn" ) == 0) {
+ nowarn = 1;
+ } else if (strcasecmp(argv[i], "use_first_pass") == 0) {
+ use_first_pass = 1;
+ } else if (strcasecmp(argv[i], "try_first_pass") == 0) {
+ try_first_pass = 1;
+ } else if (strcasecmp(argv[i], "ignore_root" ) == 0) {
+ ignore_root = 1;
+ } else {
+ pam_afs_syslog(LOG_ERR, PAMAFS_UNKNOWNOPT, argv[i]);
+ }
+ }
+
+ if (use_first_pass) try_first_pass = 0;
+
+ pam_afs_syslog(LOG_DEBUG, PAMAFS_OPTIONS, nowarn, use_first_pass, try_first_pass);
+ pam_afs_syslog(LOG_DEBUG, PAMAFS_PAMERROR, flags);
+
+ /* Try to get the user-interaction info, if available. */
+ errcode = pam_get_item(pamh, PAM_CONV, (const void **) &pam_convp);
+ if (errcode != PAM_SUCCESS) {
+ pam_afs_syslog(LOG_WARNING, PAMAFS_NO_USER_INT);
+ pam_convp = NULL;
+ }
+
+ /* Who are we trying to authenticate here? */
+ if ((errcode = pam_get_user(pamh, (const char **)&user, "AFS username: ")) != PAM_SUCCESS) {
+ pam_afs_syslog(LOG_ERR, PAMAFS_NOUSER, errcode);
+ RET(PAM_USER_UNKNOWN);
+ }
+
+ pam_afs_syslog(LOG_DEBUG, PAMAFS_USERNAMEDEBUG, user);
+
+ /*
+ * If the user has a "local" (or via nss, possibly nss_dce) pwent,
+ * and its uid==0, and "ignore_root" was given in pam.conf,
+ * ignore the user.
+ */
+#if defined(AFS_HPUX_ENV)
+#if defined(AFS_HPUX110_ENV)
+ i = getpwnam_r(user, &unix_pwd, upwd_buf, sizeof(upwd_buf), &upwd);
+#else /* AFS_HPUX110_ENV */
+ i = getpwnam_r(user, &unix_pwd, upwd_buf, sizeof(upwd_buf));
+ if ( i == 0 ) /* getpwnam_r success */
+ upwd = &unix_pwd;
+#endif /* else AFS_HPUX110_ENV */
+ if (ignore_root && i == 0 && upwd->pw_uid == 0) {
+ pam_afs_syslog(LOG_INFO, PAMAFS_IGNORINGROOT, user);
+ RET(PAM_AUTH_ERR);
+ }
+#else
+#ifdef AFS_LINUX20_ENV
+ upwd = getpwnam(user);
+#else
+ upwd = getpwnam_r(user, &unix_pwd, upwd_buf, sizeof(upwd_buf));
+#endif
+ if (ignore_root && upwd != NULL && upwd->pw_uid == 0) {
+ pam_afs_syslog(LOG_INFO, PAMAFS_IGNORINGROOT, user);
+ RET(PAM_AUTH_ERR);
+ }
+#endif
+
+ errcode = pam_get_item(pamh, PAM_AUTHTOK, (const void **) &password);
+ if (errcode != PAM_SUCCESS || password == NULL) {
+ if (use_first_pass) {
+ pam_afs_syslog(LOG_ERR, PAMAFS_PASSWD_REQ, user);
+ RET(PAM_AUTH_ERR);
+ }
+ password = NULL; /* In case it isn't already NULL */
+ pam_afs_syslog(LOG_DEBUG, PAMAFS_NOFIRSTPASS, user);
+ } else if (password[0] == '\0') {
+ /* Actually we *did* get one but it was empty. */
+ torch_password = 0;
+ pam_afs_syslog(LOG_INFO, PAMAFS_NILPASSWORD, user);
+ RET(PAM_NEW_AUTHTOK_REQD);
+ } else {
+ pam_afs_syslog(LOG_DEBUG, PAMAFS_GOTPASS, user);
+ torch_password = 0;
+ got_authtok = 1;
+ }
+ if (!(use_first_pass || try_first_pass)) {
+ password = NULL;
+ }
+
+ if (password == NULL) {
+ torch_password = 1;
+ if (use_first_pass)
+ RET(PAM_AUTH_ERR); /* shouldn't happen */
+ if (try_first_pass)
+ try_first_pass = 0;
+ if (pam_convp == NULL || pam_convp->conv == NULL) {
+ pam_afs_syslog(LOG_ERR, PAMAFS_CANNOT_PROMPT);
+ RET(PAM_AUTH_ERR);
+ }
+
+ errcode = pam_afs_prompt(pam_convp, &password, 0, PAMAFS_PWD_PROMPT);
+ if (errcode != PAM_SUCCESS || password == NULL) {
+ pam_afs_syslog(LOG_ERR, PAMAFS_GETPASS_FAILED);
+ RET(PAM_AUTH_ERR);
+ }
+ if (password[0] == '\0') {
+ pam_afs_syslog(LOG_INFO, PAMAFS_NILPASSWORD, user);
+ RET(PAM_NEW_AUTHTOK_REQD);
+ }
+
+ /*
+ * We aren't going to free the password later (we will wipe it,
+ * though), because the storage for it if we get it from other
+ * paths may belong to someone else. Since we do need to free
+ * this storage, copy it to a buffer that won't need to be freed
+ * later, and free this storage now.
+ */
+ strncpy(my_password_buf, password, sizeof(my_password_buf));
+ my_password_buf[sizeof(my_password_buf)-1] = '\0';
+ memset(password, 0, strlen(password));
+ free(password);
+ password = my_password_buf;
+ }
+
+ if ( (code = ka_VerifyUserPassword(KA_USERAUTH_VERSION + KA_USERAUTH_DOSETPAG,
+ user, /* kerberos name */
+ (char *)0, /* instance */
+ (char *)0, /* realm */
+ password, /* password */
+ 0, /* spare 2 */
+ &reason /* error string */ )) !=0 ) {
+ pam_afs_syslog(LOG_ERR, PAMAFS_LOGIN_FAILED, user, reason);
+ RET(PAM_AUTH_ERR);
+ }
+ torch_password = 0;
+ pam_set_item(pamh, PAM_AUTHTOK, password);
+ pam_set_item(pamh, PAM_OLDAUTHTOK, password);
+ if (flags & PAM_PRELIM_CHECK) {
+ /* only auth check was requested, so return success here */
+ return(PAM_SUCCESS);
+ }
+ if (!(flags & PAM_UPDATE_AUTHTOK)) {
+ /* these lines are never executed ... */
+ /* UPDATE_AUTHTOK flag is required, return with error */
+ pam_afs_syslog(LOG_ERR, PAMAFS_FLAGS, "PAM_UPDATE_AUTHTOK");
+ RET(PAM_AUTH_ERR);
+ }
+
+ /* get the new passwd and verify it */
+ errcode = pam_afs_prompt(pam_convp, &new_password, 0, PAMAFS_NEW_PWD_PROMPT);
+ if (errcode != PAM_SUCCESS || new_password == NULL) {
+ pam_afs_syslog(LOG_ERR, PAMAFS_GETPASS_FAILED);
+ RET(PAM_AUTH_ERR);
+ }
+ if (new_password[0] == '\0') {
+ pam_afs_syslog(LOG_INFO, PAMAFS_NILPASSWORD, user);
+ RET(PAM_AUTH_ERR);
+ }
+ errcode = pam_afs_prompt(pam_convp, &verify_password, 0, PAMAFS_VERIFY_PWD_PROMPT);
+ if (errcode != PAM_SUCCESS || verify_password == NULL) {
+ pam_afs_syslog(LOG_ERR, PAMAFS_GETPASS_FAILED);
+ memset(new_password, 0, strlen(new_password));
+ RET(PAM_AUTH_ERR);
+ }
+ if (verify_password[0] == '\0') {
+ pam_afs_syslog(LOG_INFO, PAMAFS_NILPASSWORD, user);
+ memset(new_password, 0, strlen(new_password));
+ RET(PAM_AUTH_ERR);
+ }
+ if (strcmp(new_password, verify_password) != 0) {
+ pam_afs_syslog(LOG_INFO, PAMAFS_NE_PASSWORD);
+ memset(new_password, 0, strlen(new_password));
+ memset(verify_password, 0, strlen(verify_password));
+ RET(PAM_AUTH_ERR);
+ }
+ memset(verify_password, 0, strlen(verify_password));
+ /* checking password length and quality is up to other PAM modules */
+
+ /* set the new password */
+ if ((code = ka_Init(0)) != 0) {
+ pam_afs_syslog(LOG_ERR, PAMAFS_KAERROR, code);
+ RET(PAM_AUTH_ERR);
+ }
+ if ((code = rx_Init(0)) != 0) {
+ pam_afs_syslog(LOG_ERR, PAMAFS_KAERROR, code);
+ RET(PAM_AUTH_ERR);
+ }
+ strcpy(instance,"");
+ if ((localcell = ka_LocalCell()) == NULL) {
+ pam_afs_syslog(LOG_ERR, PAMAFS_NOCELLNAME);
+ RET(PAM_AUTH_ERR);
+ }
+ strcpy(realm,localcell);
+ strcpy(cell,realm);
+ /* oldkey is not used in ka_ChangePassword (only for ka_auth) */
+ ka_StringToKey(password, realm, &oldkey);
+ ka_StringToKey(new_password, realm, &newkey);
+ if ((code = ka_GetAdminToken(user, instance, realm, &oldkey, 20, &token, 0)) != 0) {
+ pam_afs_syslog(LOG_ERR, PAMAFS_KAERROR, code);
+ RET(PAM_AUTH_ERR);
+ }
+ if ((code = ka_AuthServerConn(realm, KA_MAINTENANCE_SERVICE, &token, &conn)) != 0) {
+ pam_afs_syslog(LOG_ERR, PAMAFS_KAERROR, code);
+ RET(PAM_AUTH_ERR);
+ }
+ if ((code = ka_ChangePassword(user, /* kerberos name */
+ instance, /* instance */
+ conn, /* conn */
+ 0, /* old password unused */
+ &newkey /* new password */ )) != 0) {
+ pam_afs_syslog(LOG_ERR, PAMAFS_KAPASS_FAIL);
+ memset(new_password, 0, strlen(new_password));
+ RET(PAM_AUTH_ERR);
+ } else {
+ pam_set_item(pamh, PAM_AUTHTOK, new_password);
+ RET(PAM_SUCCESS);
+ }
+
+ out:
+ if (password && torch_password) {
+ memset(password, 0, strlen(password));
+ }
+ (void) setlogmask(origmask);
+#ifndef AFS_SUN56_ENV
+ closelog();
+#endif
+ return retcode;
}
int try_first_pass = 0;
int got_authtok = 0;
int ignore_root = 0;
+ int trust_root = 0;
int set_expires = 0; /* the default is to not to set the env variable */
int i;
struct pam_conv *pam_convp = NULL;
try_first_pass = 1;
} else if (strcasecmp(argv[i], "ignore_root" ) == 0) {
ignore_root = 1;
+ } else if (strcasecmp(argv[i], "trust_root" ) == 0) {
+ trust_root = 1;
+ } else if (strcasecmp(argv[i], "catch_su" ) == 0) {
+ use_first_pass = 0;
} else if (strcasecmp(argv[i], "setenv_password_expires")==0) {
set_expires = 1;
} else {
#else
upwd = getpwnam_r(user, &unix_pwd, upwd_buf, sizeof(upwd_buf));
#endif
- if (ignore_root && upwd != NULL && upwd->pw_uid == 0) {
- pam_afs_syslog(LOG_INFO, PAMAFS_IGNORINGROOT, user);
- RET(PAM_AUTH_ERR);
+ if (upwd != NULL && upwd->pw_uid == 0) {
+ if (ignore_root) {
+ pam_afs_syslog(LOG_INFO, PAMAFS_IGNORINGROOT, user);
+ RET(PAM_AUTH_ERR);
+ } else if (trust_root) {
+ pam_afs_syslog(LOG_INFO, PAMAFS_TRUSTROOT, user);
+ RET(PAM_SUCCESS);
+ }
}
#endif
char **argv;
{
register afs_int32 code;
- afs_int32 serverList[MAXSERVERS];
afs_int32 myHost;
register struct hostent *th;
char hostname[64];
int kerberosKeys; /* set if found some keys */
afs_int32 i,j;
int lwps = 3;
+ char clones[MAXHOSTSPERCELL];
const char *pr_dbaseName;
char *whoami = "ptserver";
bcopy(th->h_addr,&myHost,sizeof(afs_int32));
/* get list of servers */
- code = afsconf_GetCellInfo(prdir,(char *)0,"afsprot",&info);
+ code = afsconf_GetExtendedCellInfo(prdir,(char *)0,"afsprot",
+ &info, &clones);
if (code) {
com_err (whoami, code, "Couldn't get server list");
PT_EXIT(2);
pr_realmName = info.name;
pr_realmNameLen = strlen (pr_realmName);
- for (i=0,j=0;i<info.numServers;i++)
- if (info.hostAddr[i].sin_addr.s_addr != myHost) /* ubik already tacks myHost onto list */
- serverList[j++] = info.hostAddr[i].sin_addr.s_addr;
- serverList[j] = 0;
-
#if 0
/* get keys */
code = afsconf_GetKey(prdir,999,&tkey);
* and the header are in separate Ubik buffers then 120 buffers may be
* required. */
ubik_nBuffers = 120 + /*fudge*/40;
- code = ubik_ServerInit(myHost, htons(AFSCONF_PROTPORT), serverList,
- pr_dbaseName, &dbase);
+ code = ubik_ServerInitByInfo(myHost, htons(AFSCONF_PROTPORT), &info,
+ &clones, pr_dbaseName, &dbase);
if (code) {
com_err (whoami, code, "Ubik init failed");
PT_EXIT(2);
XDROBJS = xdr_arrayn.o xdr_rx.o xdr_afsuuid.o
RXOBJS = rx_clock.o rx_event.o rx_user.o rx_lwp.o rx.o rx_null.o rx_globals.o \
- rx_getaddr.o rx_misc.o rx_packet.o rx_rdwr.o rx_trace.o rx_conncache.o
+ rx_getaddr.o rx_misc.o rx_packet.o rx_rdwr.o rx_trace.o rx_conncache.o \
+ xdr_int64.o
MULTIOBJS = rx_multi.o
rx_null.c rx_null.h rx_queue.h rx_getaddr.c rx_packet.c rx_packet.h \
rx_multi.h rx_kcommon.h rx_kcommon.c \
xdr.c xdr.h xdr_array.c xdr_arrayn.c xdr_rx.c rx_misc.c rx_rdwr.c \
- xdr_afsuuid.c rx_trace.h
+ xdr_afsuuid.c rx_trace.h xdr_int64.c
UKSRCS = $(KSRCS) rx_conncache.c
include ../config/Makefile.version
kinstall: includes
set $(KERNELDIR)rx; $(MKDIR_IF_NEEDED)
$(INSTALL) $(KSRCS) $(KERNELDIR)rx
- @case ${SYS_NAME} in \
- alpha_dux4* ) \
+ case ${SYS_NAME} in \
+ alpha_dux* ) \
$(INSTALL) DUX/*.[ch] $(KERNELDIR)rx;; \
hp_ux* ) \
$(INSTALL) HPUX/*.[ch] $(KERNELDIR)rx;; \
ukinstall webinstall: includes
set $(UKERNELDIR)rx; $(MKDIR_IF_NEEDED)
$(INSTALL) $(UKSRCS) $(UKERNELDIR)rx
- $(INSTALL) UKERNEL/*.[ch] $(UKERNELDIR)rx
+ -$(INSTALL) UKERNEL/*.[ch] $(UKERNELDIR)rx
clean:
rm -f *.o *.a core *_component_version_number.c
# Object files by category.
XDROBJS = xdr.obj xdr_array.obj xdr_arrayn.obj xdr_float.obj xdr_mem.obj \
- xdr_rec.obj xdr_refernce.obj xdr_rx.obj xdr_update.obj xdr_afsuuid.obj
+ xdr_rec.obj xdr_refernce.obj xdr_rx.obj xdr_update.obj \
+ xdr_afsuuid.obj xdr_int64.obj
RXOBJS = rx_clock_nt.obj rx_event.obj rx_user.obj rx_lwp.obj rx.obj \
rx_null.obj rx_globals.obj rx_getaddr.obj rx_misc.obj rx_packet.obj \
int clock_haveCurrentTime;
int clock_nUpdates; /* The actual number of clock updates */
+static int clockInitialized = 0;
/* Initialize the clock */
void clock_Init(void) {
- static initialized = 0;
struct itimerval itimer, otimer;
- if (!initialized) {
+ if (!clockInitialized) {
itimer.it_value.tv_sec = STARTVALUE;
itimer.it_value.tv_usec = 0;
itimer.it_interval.tv_sec = 0;
fflush (stderr);
exit(1);
}
- initialized = 1;
+ clockInitialized = 1;
}
clock_UpdateTime();
}
+#ifndef KERNEL
+/* Make clock uninitialized. */
+clock_UnInit()
+{
+ clockInitialized = 0;
+}
+#endif
+
/* Compute the current time. The timer gets the current total elapsed time since startup, expressed in seconds and microseconds. This call is almost 200 usec on an APC RT */
void clock_UpdateTime()
{
int clock_haveCurrentTime;
int clock_nUpdates; /* The actual number of clock updates */
+static int clockInitialized = 0;
/* Timing tests show that we can compute times at about 4uS per call. */
LARGE_INTEGER rxi_clock0;
exit(1);
}
+ clockInitialized = 1;
(void) QueryPerformanceCounter(&rxi_clock0);
clock_UpdateTime();
}
+#ifndef KERNEL
+/* Make clock uninitialized. */
+clock_UnInit()
+{
+ clockInitialized = 0;
+}
+#endif
+
void clock_UpdateTime(void)
{
LARGE_INTEGER now, delta;
#define rxi_ReScheduleEvents 0 /* Not needed by kernel */
/* This is a no-op, because the kernel server procs are pre-allocated */
-#define rxi_StartServerProcs(x)
+#define rxi_StartServerProcs(x) 0
/* Socket stuff */
typedef struct socket *osi_socket;
# include "rx_globals.h"
# include <lwp.h>
+#define MAXTHREADNAMELENGTH 64
int debugSelectFailure; /* # of times select failed */
/*
IOMGR_Sleep(sec);
}
+static int quitListening = 0;
+
+/* This routine will kill the listener thread, if it exists. */
+void
+rxi_StopListener()
+{
+ quitListening = 1;
+ rxi_ReScheduleEvents();
+}
+
/* This routine will get called by the event package whenever a new,
earlier than others, event is posted. If the Listener process
is blocked in selects, this will unblock it. It also can be called
int lastPollWorked, doingPoll; /* true iff last poll was useful */
struct timeval tv, *tvp;
int i, code;
+ PROCESS pid;
+ char name[MAXTHREADNAMELENGTH] = "srv_0";
clock_NewTime();
lastPollWorked = 0;
nextPollTime = 0;
+ code = LWP_CurrentProcess(&pid);
+ if (code) {
+ fprintf(stderr, "rxi_Listener: Can't get my pid.\n");
+ exit(1);
+ }
+ rx_listenerPid = pid;
+ swapthreadname(pid, "listener", &name);
for (;;) {
/* Grab a new packet only if necessary (otherwise re-use the old one) */
}
lastPollWorked = 0; /* default is that it didn't find anything */
+ if (quitListening) {
+ quitListening = 0;
+ LWP_DestroyProcess(pid);
+ }
+
switch(code) {
case 0:
/* Timer interrupt:
return bytes;
}
+int rx_WritevInit(call)
+ struct rx_call *call;
+{
+ int bytes;
+ SPLVAR;
+
+ /*
+ * Free any packets from the last call to ReadvProc/WritevProc.
+ * We do not need the lock because the receiver threads only
+ * touch the iovq when the RX_CALL_IOVEC_WAIT flag is set, and the
+ * RX_CALL_IOVEC_WAIT is always cleared before returning from
+ * ReadvProc/WritevProc.
+ */
+ if (!queue_IsEmpty(&call->iovq)) {
+ register struct rx_packet *rp;
+ register struct rx_packet *nxp;
+ for (queue_Scan(&call->iovq, rp, nxp, rx_packet)) {
+ queue_Remove(rp);
+ rxi_FreePacket(rp);
+ }
+ }
+
+ NETPRI;
+ AFS_RXGLOCK();
+ MUTEX_ENTER(&call->lock);
+ bytes = rxi_WriteProc(call, &bytes, 0);
+ MUTEX_EXIT(&call->lock);
+ AFS_RXGUNLOCK();
+ USERPRI;
+ return bytes;
+}
+
/* rxi_WritevProc -- internal version.
*
* Send buffers allocated in rxi_WritevAlloc.
extern bool_t xdr_reference();
extern bool_t xdr_wrapstring();
extern bool_t xdr_vector();
+extern bool_t xdr_int64();
+extern bool_t xdr_uint64();
/*
* These are the public routines for the various implementations of
f_print(fout, "#ifndef xdr_afs_uint32\n");
f_print(fout, "#define xdr_afs_uint32 xdr_u_int\n");
f_print(fout, "#endif\n");
+ f_print(fout, "#ifndef xdr_afs_int64\n");
+ f_print(fout, "#define xdr_afs_int64 xdr_int64\n");
+ f_print(fout, "#endif\n");
+ f_print(fout, "#ifndef xdr_afs_uint64\n");
+ f_print(fout, "#define xdr_afs_uint64 xdr_uint64\n");
+ f_print(fout, "#endif\n");
#else
#error Need to do some work here...
#endif
f_print(fout, "#ifdef AFS_LINUX22_ENV\n");
f_print(fout, "#include \"../rx/xdr.h\"\n");
f_print(fout, "#else /* AFS_LINUX22_ENV */\n");
+ f_print(fout, "extern bool_t xdr_int64();\n");
+ f_print(fout, "extern bool_t xdr_uint64();\n");
f_print(fout, "#include \"../rpc/xdr.h\"\n");
f_print(fout, "#endif /* AFS_LINUX22_ENV */\n");
f_print(fout, "#endif /* XDR_GETLONG */\n");
#else
#ifdef AFS_NAMEI_ENV
#include <sys/types.h>
+#ifdef AFS_NEC_SX92_ENV
+typedef unsigned long Inode;
+#else /* AFS_NEC_SX92_ENV */
+#ifdef AFS_64BIT_ENV
+typedef afs_uint64 Inode;
+#else
typedef u_int64_t Inode;
+#endif
+#endif /* AFS_NEC_SX92_ENV */
#else
error Need 64 bit Inode defined.
#endif /* AFS_NAMEI_ENV */
VLSERVEROBJS=vldbint.cs.o vldbint.xdr.o
-LWPOBJS=lock.o fasttime.o
+LWPOBJS=lock.o fasttime.o threadname.o
LIBACLOBJS=aclprocs.o netprocs.o
fasttime.o: ${LWP}/fasttime.c
${CRULE1};
+threadname.o: ${LWP}/threadname.c
+ ${CRULE1};
+
aclprocs.o: ${LIBACL}/aclprocs.c
${CRULE1}
*linux*) \
${CC} ${LDFLAGS} -o fileserver ${objects} ${LIBS} \
${MTLIBS} ${XLIBS} ;; \
- sgi_6*) \
- ${CC} ${LDFLAGS} -o fileserver ${objects} ${LIBS} \
- ${MTLIBS} ${XLIBS} ../sgiefs/libefs.a ;; \
*) \
${CC} ${LDFLAGS} -o fileserver ${objects} ${LIBS} \
${MTLIBS} ${XLIBS} ;; \
VLSERVEROBJS = vldbint.cs.obj vldbint.xdr.obj
-LWPOBJS = lock.obj fasttime.obj
+LWPOBJS = lock.obj fasttime.obj threadname.obj
LIBACLOBJS = aclprocs.obj netprocs.obj
fasttime.obj: $(LWP)/fasttime.c
$(C2OBJ) $**
+threadname.obj: $(LWP)/threadname.c
+ $(C2OBJ) $**
+
############################################################################
# LIBACL package
aclprocs.obj: $(LIBACL)/aclprocs.c
#include <rx/xdr.h>
#include <rx/rx.h>
#include <rx/rx_multi.h>
+#include <afs/cellconfig.h>
#ifndef AFS_NT40_ENV
#include <afs/afsutil.h>
#include <afs/netutils.h>
int ubik_amSyncSite = 0; /* flag telling if I'm sync site */
static nServers; /* total number of servers */
static char amIMagic=0; /* is this host the magic host */
+char amIClone=0; /* is this a clone which doesn't vote */
+static char ubik_singleServer = 0;
extern struct rx_securityClass *rxnull_NewClientSecurityObject();
int (*ubik_CRXSecurityProc)();
char *ubik_CRXSecurityRock;
register afs_int32 rcode;
/* special case for fast startup */
- if (nServers == 1) {
+ if (nServers == 1 && !amIClone) {
return 1; /* one guy is always the sync site */
}
- if (ubik_amSyncSite == 0) rcode = 0; /* if I don't think I'm the sync site, say so */
+ if (ubik_amSyncSite == 0 || amIClone) rcode = 0; /* if I don't think I'm the sync site, say so */
else {
now = FT_ApproxTime();
if (syncSiteUntil <= now) { /* if my votes have expired, say so */
* is sync site. Without the magic host hack, if anyone crashed in a 2
* site system, we'd be out of business.
*/
+ubeacon_InitServerListByInfo(ame, info, clones)
+ afs_int32 ame;
+ struct afsconf_cell *info;
+ char clones[];
+{
+ afs_int32 code;
+
+ code = ubeacon_InitServerListCommon(ame, info, clones, 0);
+ return code;
+}
+
ubeacon_InitServerList(ame, aservers)
afs_int32 ame;
- register afs_int32 aservers[]; {
+ register afs_int32 aservers[];
+{
+ afs_int32 code;
+
+ code = ubeacon_InitServerListCommon(ame, (struct afsconf_cell *)0, 0,
+ aservers);
+ return code;
+}
+
+ubeacon_InitServerListCommon(ame, info, clones, aservers)
+ afs_int32 ame;
+ struct afsconf_cell *info;
+ char clones[];
+ register afs_int32 aservers[];
+{
register struct ubik_server *ts;
+ afs_int32 me = -1;
register afs_int32 servAddr;
register afs_int32 i, code;
afs_int32 magicHost;
struct ubik_server *magicServer;
/* verify that the addresses passed in are correct */
- if ( code = verifyInterfaceAddress(&ame, aservers ))
+ if (code = verifyInterfaceAddress(&ame, info, aservers))
return code;
/* get the security index to use, if we can */
ubikSecIndex = 0;
ubikSecClass = rxnull_NewClientSecurityObject();
}
- i = 0;
magicHost = ntohl(ame); /* do comparisons in host order */
magicServer = (struct ubik_server *) 0;
- while (servAddr = *aservers++) {
- if (i >= MAXSERVERS) return UNHOSTS; /* too many hosts */
- ts = (struct ubik_server *) malloc(sizeof(struct ubik_server));
- bzero(ts, sizeof(struct ubik_server));
- ts->next = ubik_servers;
- ubik_servers = ts;
- ts->addr[0] = servAddr; /* primary address in net byte order */
- ts->vote_rxcid = rx_NewConnection(servAddr, ubik_callPortal, VOTE_SERVICE_ID, ubikSecClass, ubikSecIndex); /* for vote reqs */
- ts->disk_rxcid = rx_NewConnection(servAddr, ubik_callPortal, DISK_SERVICE_ID, ubikSecClass, ubikSecIndex); /* for disk reqs */
- ts->up = 1;
- if (ntohl((afs_uint32) servAddr) < (afs_uint32) magicHost) {
- magicHost = ntohl(servAddr);
- magicServer = ts;
+
+ if (info) {
+ for (i = 0; i < info->numServers; i++) {
+ if (ntohl((afs_uint32) info->hostAddr[i].sin_addr.s_addr) ==
+ ntohl((afs_uint32) ame)) {
+ me = i;
+ if (clones[i]) {
+ amIClone = 1;
+ magicHost = 0;
+ }
+ }
+ }
+ nServers = 0;
+ for (i = 0; i < info->numServers; i++) {
+ if (i == me) continue;
+ ts = (struct ubik_server *) malloc(sizeof(struct ubik_server));
+ bzero(ts, sizeof(struct ubik_server));
+ ts->next = ubik_servers;
+ ubik_servers = ts;
+ ts->addr[0] = info->hostAddr[i].sin_addr.s_addr;
+ if (clones[i]) {
+ ts->isClone = 1;
+ } else {
+ if (!magicHost ||
+ ntohl((afs_uint32) ts->addr[0]) < (afs_uint32) magicHost) {
+ magicHost = ntohl(ts->addr[0]);
+ magicServer = ts;
+ }
+ ++nServers;
+ }
+ ts->vote_rxcid = rx_NewConnection(servAddr, ubik_callPortal,
+ VOTE_SERVICE_ID,
+ ubikSecClass, ubikSecIndex); /* for vote reqs */
+ ts->disk_rxcid = rx_NewConnection(servAddr, ubik_callPortal,
+ DISK_SERVICE_ID, ubikSecClass,
+ ubikSecIndex); /* for disk reqs */
+ ts->up = 1;
+ }
+ } else {
+ i = 0;
+ while (servAddr = *aservers++) {
+ if (i >= MAXSERVERS) return UNHOSTS; /* too many hosts */
+ ts = (struct ubik_server *) malloc(sizeof(struct ubik_server));
+ bzero(ts, sizeof(struct ubik_server));
+ ts->next = ubik_servers;
+ ubik_servers = ts;
+ ts->addr[0] = servAddr; /* primary address in net byte order */
+ ts->vote_rxcid = rx_NewConnection(servAddr, ubik_callPortal,
+ VOTE_SERVICE_ID,
+ ubikSecClass, ubikSecIndex); /* for vote reqs */
+ ts->disk_rxcid = rx_NewConnection(servAddr, ubik_callPortal,
+ DISK_SERVICE_ID, ubikSecClass,
+ ubikSecIndex); /* for disk reqs */
+ ts->isClone = 0; /* don't know about clones */
+ ts->up = 1;
+ if (ntohl((afs_uint32) servAddr) < (afs_uint32) magicHost) {
+ magicHost = ntohl(servAddr);
+ magicServer = ts;
+ }
+ i++;
}
- i++;
}
if (magicServer) magicServer->magic = 1; /* remember for when counting votes */
- else amIMagic = 1;
- nServers = i+1; /* count this server as well as the remotes */
+
+ if (!amIClone && !magicServer) amIMagic = 1;
+ if (info) {
+ if (!amIClone)
+ ++nServers; /* count this server as well as the remotes */
+ } else
+ nServers = i+1; /* count this server as well as the remotes */
+
ubik_quorum = (nServers>>1)+1; /* compute the majority figure */
/* send addrs to all other servers */
code = updateUbikNetworkAddress(ubik_host);
r_retryInterval = 2;
r_nRetries = (RPCTIMEOUT/r_retryInterval);
*/
- if (nServers == 1) { /* special case 1 server */
+ if (info) {
+ if (!ubik_servers) /* special case 1 server */
+ ubik_singleServer = 1;
+ if (nServers == 1 && !amIClone) {
+ ubik_amSyncSite = 1; /* let's start as sync site */
+ syncSiteUntil = 0x7fffffff; /* and be it quite a while */
+ }
+ } else {
+ if (nServers == 1) /* special case 1 server */
+ ubik_singleServer = 1;
+ }
+
+ if (ubik_singleServer) {
if (!ubik_amSyncSite) ubik_dprint("Ubik: I am the sync site - 1 server\n");
ubik_amSyncSite = 1;
syncSiteUntil = 0x7fffffff; /* quite a while */
lastWakeupTime = FT_ApproxTime(); /* started a new collection phase */
- if (nServers == 1) continue; /* special-case 1 server for speedy startup */
+ if (ubik_singleServer) continue; /* special-case 1 server for speedy startup */
if (!uvote_ShouldIRun()) continue; /* if voter has heard from a better candidate than us, don't bother running */
prepare to send them an r multi-call containing the beacon message */
i = 0; /* collect connections */
for(ts = ubik_servers; ts; ts=ts->next) {
- if (ts->up && ts->addr[0] != ubik_host[0]) {
+ if (ts->up && ts->addr[0] != ubik_host[0]) {
servers[i] = ts;
connections[i++] = ts->vote_rxcid;
}
ts->lastVoteTime = code;
if (code < oldestYesVote) oldestYesVote = code;
ts->lastVote = 1;
- yesVotes += 2;
+ if (!ts->isClone)
+ yesVotes += 2;
if (ts->magic) yesVotes++; /* the extra epsilon */
ts->up = 1; /* server is up (not really necessary: recovery does this for real) */
ts->beaconSinceDown = 1;
*
* Return Values : 0 on success, non-zero on failure
*/
-verifyInterfaceAddress(ame, aservers)
-afs_uint32 *ame; /* one of my interface addr in net byte order */
-afs_uint32 aservers[]; /* list of all possible server addresses */
+static verifyInterfaceAddress(ame, info, aservers)
+ struct afsconf_cell *info;
+ afs_uint32 aservers[]; /* list of all possible server addresses */
+ afs_uint32 *ame; /* one of my interface addr in net byte order */
{
- afs_uint32 myAddr[UBIK_MAX_INTERFACE_ADDR], *servList;
+ afs_uint32 myAddr[UBIK_MAX_INTERFACE_ADDR], *servList, tmpAddr;
int count, index, found, i, j, totalServers, start, end;
- /* count the number of servers */
- for ( totalServers=0, servList = aservers; *servList; servList++)
- totalServers++;
+ if (info)
+ totalServers = info->numServers;
+ else { /* count the number of servers */
+ for ( totalServers=0, servList = aservers; *servList; servList++)
+ totalServers++;
+ }
#ifdef AFS_NT40_ENV
/* for now use getaddr(). use getAllAddr when implemented */
*/
for ( j=0, found = 0; j < count; j++)
{
- for ( i=0; i < totalServers; i++)
- if ( myAddr[j] == aservers[i] )
- {
- *ame = aservers[i];
- aservers[i] = 0 ;
+ for ( i=0; i < totalServers; i++) {
+ if (info)
+ tmpAddr = ntohl((afs_uint32) info->hostAddr[i].sin_addr.s_addr);
+ else
+ tmpAddr = aservers[i];
+ if ( myAddr[j] == tmpAddr) {
+ *ame = tmpAddr;
+ if (!info)
+ aservers[i] = 0 ;
found = 1;
}
+ }
}
if ( found )
ubik_print("Using %s as my primary address\n", afs_inet_ntoa(*ame) );
- /* get rid of servers which were purged because all
- ** those interface addresses are myself
- */
- for ( start=0, end=totalServers-1; (start<end) ; start++, end--)
- {
- /* find the first zero entry from the beginning */
- for ( ; (start < end) && ( aservers[start] ); start++);
-
- /* find the last non-zero entry from the end */
- for ( ; (end >= 0) && ( !aservers[end] ); end-- );
-
- /* if there is nothing more to purge, exit from loop */
- if ( start >= end ) break;
+ if (!info) {
+ /* get rid of servers which were purged because all
+ ** those interface addresses are myself
+ */
+ for ( start=0, end=totalServers-1; (start<end) ; start++, end--)
+ {
+ /* find the first zero entry from the beginning */
+ for ( ; (start < end) && ( aservers[start] ); start++);
+
+ /* find the last non-zero entry from the end */
+ for ( ; (end >= 0) && ( !aservers[end] ); end-- );
+
+ /* if there is nothing more to purge, exit from loop */
+ if ( start >= end ) break;
- /* move the entry */
- aservers[start] = aservers[end];
- aservers[end] = 0; /* this entry was moved */
+ /* move the entry */
+ aservers[start] = aservers[end];
+ aservers[end] = 0; /* this entry was moved */
+ }
}
/* update all my addresses in ubik_host in such a way
bestDBVersion.counter = 0;
for(ts=ubik_servers; ts; ts=ts->next) {
if (!ts->up) continue; /* don't bother with these guys */
+ if (ts->isClone) continue;
code = DISK_GetVersion(ts->disk_rxcid, &ts->version);
if (code == 0) {
/* perhaps this is the best version */
#include <lock.h>
#include <rx/xdr.h>
#include <rx/rx.h>
+#include <afs/cellconfig.h>
#define UBIK_INTERNALS
#include "ubik.h"
ts->beaconSinceDown = 0;
urecovery_LostServer(); /* tell recovery to try to resend dbase later */
} else { /* success */
- okcalls++; /* count up how many worked */
+ if (!ts->isClone)
+ okcalls++; /* count up how many worked */
if (aflags & CStampVersion) {
ts->version = atrans->dbase->version;
}
Note that the host named by myHost should not also be listed in serverList.
*/
+int ubik_ServerInitByInfo(myHost, myPort, info, clones, pathName, dbase)
+ struct afsconf_cell *info; /* in */
+ char clones[];
+ afs_int32 myHost;
+ short myPort;
+ char *pathName; /* in */
+ struct ubik_dbase **dbase; /* out */
+{
+ afs_int32 code;
+
+ code = ubik_ServerInitCommon(myHost, myPort, info, clones, 0, pathName, dbase);
+ return code;
+}
+
int ubik_ServerInit(myHost, myPort, serverList, pathName, dbase)
+ afs_int32 serverList[]; /* in */
afs_int32 myHost;
short myPort;
+ char *pathName; /* in */
+ struct ubik_dbase **dbase; /* out */
+{
+ afs_int32 code;
+
+ code = ubik_ServerInitCommon(myHost, myPort, (struct afsconf_cell *)0, 0,
+ serverList, pathName, dbase);
+ return code;
+}
+
+int ubik_ServerInitCommon(myHost, myPort, info, clones, serverList, pathName, dbase)
+ afs_int32 myHost;
+ short myPort;
+ struct afsconf_cell *info; /* in */
+ char clones[];
afs_int32 serverList[]; /* in */
char *pathName; /* in */
- struct ubik_dbase **dbase; /* out */ {
+ struct ubik_dbase **dbase; /* out */
+{
register struct ubik_dbase *tdb;
register afs_int32 code;
PROCESS junk;
if (code) return code;
code = urecovery_Initialize(tdb);
if (code) return code;
- code = ubeacon_InitServerList(myHost, serverList);
+ if (info)
+ code = ubeacon_InitServerListByInfo(myHost, info, clones);
+ else
+ code = ubeacon_InitServerList(myHost, serverList);
if (code) return code;
/* now start up async processes */
char beaconSinceDown; /* did beacon get through since last crash? */
char currentDB; /* is dbase up-to-date */
char magic; /* the one whose vote counts twice */
+ char isClone; /* is only a clone, doesn't vote */
};
/* hold and release functions on a database */
/* list of all servers in the system */
extern struct ubik_server *ubik_servers;
+extern char amIClone;
/* network port info */
extern short ubik_callPortal;
#define VOTE_GETSYNCSITE 10003
#define VOTE_DEBUG 10004
#define VOTE_SDEBUG 10005
+#define VOTE_XDEBUG 10006
+#define VOTE_XSDEBUG 10007
/* Vote package interface calls */
Beacon (IN afs_int32 state,
SDebug (IN afs_int32 which,
OUT ubik_sdebug *db) = VOTE_SDEBUG;
+XDebug (OUT ubik_debug *db,
+ OUT afs_int32 *isClone) = VOTE_XDEBUG;
+
+XSDebug (IN afs_int32 which,
+ OUT ubik_sdebug *db,
+ OUT afs_int32 *isClone) = VOTE_XSDEBUG;
+
/* This package handles calls used to pass writes, begins and ends to other servers */
package DISK_
statindex 12
struct ubik_debug udebug;
struct ubik_sdebug usdebug;
int oldServer =0; /* are we talking to a pre 3.5 server? */
+ afs_int32 isClone = 0;
int32p = (as->parms[2].items ? 1 : 0);
tconn = rx_NewConnection(hostAddr, port, VOTE_SERVICE_ID, sc, 0);
/* now do the main call */
- code = VOTE_Debug(tconn, &udebug);
+ code = VOTE_XDebug(tconn, &udebug, &isClone);
+ if (code) code = VOTE_Debug(tconn, &udebug);
if ( code == RXGEN_OPCODE )
{
oldServer = 1; /* talking to a pre 3.5 server */
udebug.epochTime, udebug.tidCounter);
}
} else {
- printf("I am not sync site\n");
+ if (isClone)
+ printf("I am a clone and never can become sync site\n");
+ else
+ printf("I am not sync site\n");
inhostAddr.s_addr = htonl(udebug.lowestHost);
diff = udebug.now - udebug.lowestTime;
printf("Lowest host %s was set %d secs ago\n", inet_ntoa(inhostAddr), diff);
if (int32p || udebug.amSyncSite) {
/* now do the subcalls */
for(i=0;;i++) {
- if ( oldServer )
- { /* pre 3.5 server */
- memset(&usdebug, 0, sizeof(usdebug));
- code = VOTE_SDebugOld(tconn, i, &usdebug);
+ isClone = 0;
+ code = VOTE_XSDebug(tconn, i, &usdebug, &isClone);
+ if (code < 0) {
+ if ( oldServer ) { /* pre 3.5 server */
+ memset(&usdebug, 0, sizeof(usdebug));
+ code = VOTE_SDebugOld(tconn, i, &usdebug);
+ }
+ else
+ code = VOTE_SDebug(tconn, i, &usdebug);
}
- else
- code = VOTE_SDebug(tconn, i, &usdebug);
if (code > 0) break; /* done */
if (code < 0) {
printf("error code %d from VOTE_SDebug\n", code);
}
inhostAddr.s_addr = htonl(usdebug.addr);
/* otherwise print the structure */
- printf("\nServer( %s", afs_inet_ntoa(htonl(usdebug.addr)));
+ printf("\nServer (%s", afs_inet_ntoa(htonl(usdebug.addr)));
for ( j=0;((usdebug.altAddr[j]) &&
(j<UBIK_MAX_INTERFACE_ADDR-1)); j++)
printf(" %s", afs_inet_ntoa(htonl(usdebug.altAddr[j])));
- printf(" ): (db %d.%d)\n",
+ printf("): (db %d.%d)",
usdebug.remoteVersion.epoch, usdebug.remoteVersion.counter);
+ if (isClone)
+ printf(" is only a clone!");
+ printf("\n");
if (usdebug.lastVoteTime == 0) {
printf(" last vote never rcvd \n");
afs_int32 vote;
struct rx_connection *aconn;
struct rx_peer *rxp;
+ struct ubik_server *ts;
+ int isClone = 0;
now = FT_ApproxTime(); /* close to current time */
if (rxcall) { /* caller's host */
afs_inet_ntoa(rx_HostOf(rxp)));
return 0; /* I don't know about you: vote no */
}
- } else
+ for (ts = ubik_servers; ts; ts = ts->next) {
+ if (ts->addr[0] == otherHost) break;
+ }
+ if (!ts) ubik_dprint("Unknown host %x has sent a beacon\n", otherHost);
+ if (ts && ts->isClone) isClone = 1;
+ } else {
otherHost = ubik_host[0]; /* this host */
+ isClone = amIClone;
+ }
ubik_dprint("Received beacon type %d from host %s\n", astate,
afs_inet_ntoa(otherHost));
seconds, we ignore its presence in lowestHost: it may have crashed.
Note that we don't ever let anyone appear in our lowestHost if we're
lower than them, 'cause we know we're up. */
- if (ntohl((afs_uint32) otherHost) <= ntohl((afs_uint32) lowestHost)
- || lowestTime + BIGTIME < now) {
+ /* But do not consider clones for lowesHost since they never may become
+ sync site */
+ if (!isClone &&
+ (ntohl((afs_uint32) otherHost) <= ntohl((afs_uint32) lowestHost)
+ || lowestTime + BIGTIME < now)) {
lowestTime = now;
lowestHost = otherHost;
}
lowest. Need to prove: if one guy in the system is lowest and knows
he's lowest, these loops don't occur. because if someone knows he's
lowest, he will send out beacons telling others to vote for him. */
- if (ntohl((afs_uint32) ubik_host[0]) <= ntohl((afs_uint32) lowestHost)
- || lowestTime + BIGTIME < now) {
+ if (!amIClone &&
+ (ntohl((afs_uint32) ubik_host) <= ntohl((afs_uint32) lowestHost)
+ || lowestTime + BIGTIME < now)) {
lowestTime = now;
lowestHost = ubik_host[0];
}
/* someone else *is* a sync site, just say no */
if (syncHost && syncHost != otherHost)
return 0;
+ } else /* fast startup if this is the only non-clone */
+ if (lastYesHost == 0xffffffff && otherHost == ubik_host[0]) {
+ int i = 0;
+ for (ts = ubik_servers; ts; ts = ts->next) {
+ if (ts->addr[0] == otherHost) continue;
+ if (!ts->isClone) i++;
+ }
+ if (!i) lastYesHost = otherHost;
}
+
+
+ if (isClone) return 0; /* clone never can become sync site */
/* Don't promise sync site support to more than one host every BIGTIME
seconds. This is the heart of our invariants in this system. */
SVOTE_SDebug(rxcall, awhich, aparm)
struct rx_call *rxcall;
afs_int32 awhich;
- register struct ubik_sdebug *aparm; {
+ register struct ubik_sdebug *aparm;
+{
+ afs_int32 code, isClone;
+ code = SVOTE_XSDebug(rxcall, awhich, aparm, &isClone);
+ return code;
+}
+
+SVOTE_XSDebug(rxcall, awhich, aparm, isclone)
+ afs_int32 *isclone;
+ struct rx_call *rxcall;
+ afs_int32 awhich;
+ register struct ubik_sdebug *aparm;
+{
register struct ubik_server *ts;
register int i;
for(ts=ubik_servers; ts; ts=ts->next) {
aparm->up = ts->up;
aparm->beaconSinceDown = ts->beaconSinceDown;
aparm->currentDB = ts->currentDB;
+ *isclone = ts->isClone;
return 0;
}
}
return 2;
}
+SVOTE_XDebug(rxcall, aparm, isclone)
+ struct rx_call *rxcall;
+ register struct ubik_debug *aparm;
+ afs_int32 *isclone;
+{
+ afs_int32 code;
+
+ code = SVOTE_Debug(rxcall, aparm);
+ *isclone = amIClone;
+ return code;
+}
/* handle basic network debug command. This is the global state dumper */
SVOTE_Debug(rxcall, aparm)
objects = assert.o base64.o casestrcpy.o ktime.o volparse.o hostparse.o \
hputil.o kreltime.o isathing.o get_krbrlm.o uuid.o serverLog.o \
dirpath.o fileutil.o netutils.o flipbase64.o \
- afs_atomlist.o afs_lhash.o
+ afs_atomlist.o afs_lhash.o snprintf.o
headers = assert.h potpourri.h itc.h errors.h afsutil.h pthread_glock.h \
dirpath.h afs_atomlist.h afs_lhash.h
volparse.o: volparse.c
${CC} ${CFLAGS} -c volparse.c
+snprintf.o: snprintf.c
+ ${CC} ${CFLAGS} -c snprintf.c
+
base64.o: base64.c
${CC} ${CFLAGS} -c base64.c
propagated to the application level */
#define VMOVED 111 /* Volume has moved to another server; do a VGetVolumeInfo
to THIS server to find out where */
-#define VIO 112 /* Vnode temporarily unaccessible, but not known to
+#define VIO 112 /* Vnode temporarily unaccessible, but not known
to be permanently bad. */
+#define VRESTRICTED 120 /* Volume is restricted from using one or more
+ of the given residencies; do a
+ vos examine to find out the current
+ restrictions. */
#define VRESTARTING -100 /* server is restarting, otherwise similar to
VBUSY above. This is negative so that old
cache managers treat it as "server is down"*/
#define F_OK 0
#endif
+char *threadname();
+
static int serverLogFD = -1;
#include <stdarg.h>
int LogLevel;
+int mrafsStyleLogs = 0;
+int printLocks = 0;
+static char ourName[MAXPATHLEN];
+
+void WriteLogBuffer(buf,len)
+ char *buf;
+ afs_uint32 len;
+{
+ LOCK_SERVERLOG();
+ if (serverLogFD > 0)
+ write(serverLogFD, buf, len);
+ UNLOCK_SERVERLOG();
+}
/* VARARGS1 */
void FSLog (const char *format, ...)
char tbuffer[1024];
char *info;
int len;
+ int i;
+ char *name;
currenttime = time(0);
timeStamp = afs_ctime(¤ttime, tbuffer, sizeof(tbuffer));
timeStamp[24] = ' '; /* ts[24] is the newline, 25 is the null */
info = &timeStamp[25];
+ if (mrafsStyleLogs) {
+ name = threadname();
+ sprintf(info, "[%s] ", name);
+ info += strlen(info);
+ }
+
va_start(args, format);
(void) vsprintf(info, format, args);
va_end(args);
else {
LogLevel = 1;
}
+ printLocks = 2;
#if defined(AFS_PTHREAD_ENV)
DebugOn(LogLevel);
#else /* AFS_PTHREAD_ENV */
{
LogLevel = 0;
+ if (printLocks >0) --printLocks;
#if defined(AFS_PTHREAD_ENV)
DebugOn(LogLevel);
#else /* AFS_PTHREAD_ENV */
signal(signo, ResetDebug_Signal); /* on some platforms, this signal */
/* handler needs to be set again */
+ if (mrafsStyleLogs)
+ OpenLog((char *)&ourName);
} /*ResetDebug_Signal*/
*/
int tempfd;
char oldName[MAXPATHLEN];
+ struct timeval Start;
+ struct tm *TimeFields;
+ char FileName[MAXPATHLEN];
+
+ if (mrafsStyleLogs) {
+ TM_GetTimeOfDay(&Start, 0);
+ TimeFields = localtime(&Start.tv_sec);
+ if (fileName) {
+ if (strncmp(fileName, (char *)&ourName, strlen(fileName)))
+ strcpy((char *)&ourName, (char *) fileName);
+ }
+ sprintf(FileName, "%s.%d%02d%02d%02d%02d%02d", ourName,
+ TimeFields->tm_year + 1900, TimeFields->tm_mon + 1,
+ TimeFields->tm_mday, TimeFields->tm_hour,
+ TimeFields->tm_min, TimeFields->tm_sec);
+ rename (fileName, FileName); /* don't check error code */
+ tempfd = open(fileName, O_WRONLY | O_TRUNC | O_CREAT, 0666);
+ } else {
+ strcpy(oldName, fileName);
+ strcat(oldName, ".old");
- strcpy(oldName, fileName);
- strcat(oldName, ".old");
+ /* don't check error */
+ renamefile(fileName, oldName);
+ tempfd = open(fileName, O_WRONLY|O_TRUNC|O_CREAT, 0666);
+ }
- /* don't check error */
- renamefile(fileName, oldName);
- tempfd = open(fileName, O_WRONLY|O_TRUNC|O_CREAT, 0666);
if(tempfd < 0)
{
printf("Unable to open log file %s\n", fileName);
else *aval = total;
return 0;
}
+
+afs_uint32
+GetUInt32 (as, aval)
+register char *as;
+afs_uint32 *aval;
+{
+ register afs_uint32 total;
+ register int tc;
+ int base;
+
+ total = 0; /* initialize things */
+
+ /* skip over leading spaces */
+ while (tc = *as) {
+ if (tc != ' ' && tc != '\t') break;
+ }
+
+ /* compute the base */
+ if (*as == '0') {
+ as++;
+ if (*as == 'x' || *as == 'X') {
+ base = 16;
+ as++;
+ }
+ else base = 8;
+ }
+ else base = 10;
+
+ /* compute the # itself */
+ while(tc = *as) {
+ if (!ismeta(tc, base)) return -1;
+ total *= base;
+ total += getmeta(tc);
+ as++;
+ }
+
+ *aval = total;
+ return 0;
+}
+
return EINVAL;
}
+SRXAFS_ResidencyCmd (tcon, Fid, Inputs, Outputs)
+ struct rx_connection *tcon;
+ struct AFSFid *Fid;
+ struct ResidencyCmdInputs *Inputs;
+ struct ResidencyCmdOutputs *Outputs;
+{
+ return EINVAL;
+}
char **argv;
{
register afs_int32 code;
- afs_int32 serverList[MAXSERVERS];
afs_int32 myHost;
struct rx_service *tservice;
struct rx_securityClass *sc[3];
int noAuth = 0, index, i;
extern int rx_extraPackets;
char commandLine[150];
-
+ char clones[MAXHOSTSPERCELL];
+
#ifdef AFS_AIX32_ENV
/*
* The following signal action for AIX is necessary so that in case of a
signal(SIGXCPU, CheckSignal_Signal);
#endif
/* get list of servers */
- code = afsconf_GetCellInfo(tdir,(char *)0, AFSCONF_VLDBSERVICE,&info);
+ code = afsconf_GetExtendedCellInfo(tdir,(char *)0, AFSCONF_VLDBSERVICE,
+ &info, &clones);
if (code) {
printf("vlserver: Couldn't get cell server list for 'afsvldb'.\n");
exit(2);
}
- for (index=0,i = 0;index<info.numServers;index++)
- if (info.hostAddr[index].sin_addr.s_addr != myHost) /* ubik already tacks myHost onto list */
- serverList[i++] = info.hostAddr[index].sin_addr.s_addr;
- serverList[i] = 0;
vldb_confdir = tdir; /* Preserve our configuration dir */
/* rxvab no longer supported */
ubik_SRXSecurityRock = (char *) tdir;
ubik_CheckRXSecurityProc = afsconf_CheckAuth;
ubik_CheckRXSecurityRock = (char *) tdir;
- code = ubik_ServerInit(myHost, htons(AFSCONF_VLDBPORT), serverList, vl_dbaseName, &VL_dbase);
+ code = ubik_ServerInitByInfo(myHost, htons(AFSCONF_VLDBPORT), &info,
+ &clones, vl_dbaseName, &VL_dbase);
if (code) {
printf("vlserver: Ubik init failed with code %d\n",code);
exit(2);
*linux* ) \
${CC} ${LDFLAGS} -o salvager vol-salvage.o physio.o \
${LIBS} ;; \
- sgi_* ) \
- ${CC} ${LDFLAGS} -o salvager vol-salvage.o physio.o \
- ${LIBS} ../sgiefs/libefs.a ;; \
*) \
${CC} ${LDFLAGS} -o salvager vol-salvage.o physio.o \
${LIBS};; \
#if defined(AFS_SGI_ENV)
#include <fcntl.h>
#include <mntent.h>
-#include "../sgiefs/efs.h"
+#ifdef AFS_SGI_EFS_IOPS_ENV
#define ROOTINO EFS_ROOTINO
+#include "../sgiefs/efs.h"
+#endif
#else
#ifdef AFS_LINUX22_ENV
#include <mntent.h>
/* libefs.h includes <assert.h>, which we don't want */
#define __ASSERT_H__
+#ifdef AFS_SGI_EFS_IOPS_ENV
#include "../sgiefs/libefs.h"
extern int Log();
return err;
}
+#endif /* AFS_SGI_EFS_IOPS_ENV */
#ifdef AFS_SGI_XFS_IOPS_ENV
#include <dirent.h>
int ninodes = 0, err = 0;
struct efs_dinode *dinodeBuf = NULL;
int last_cgno;
+#ifdef AFS_SGI_EFS_IOPS_ENV
EFS_MOUNT *mp;
+#endif
ino_t imax, inum; /* total number of I-nodes in file system */
*forcep = 0;
}
else
#endif
- {
- if (root_inode.st_ino != EFS_ROOTINO) {
- Log("%s is not root of a filesystem\n", mountedOn);
- return -1;
- }
+#ifdef AFS_SGI_EFS_IOPS_ENV
+ if (root_inode.st_ino == EFS_ROOTINO) {
return efs_ListViceInodes(devname, mountedOn, resultFile,
- judgeInode, judgeParam,
+ judgeInode, judgeParam,
forcep, forceR, wpath);
}
+ else
+#endif
+ {
+ Log("%s is not root of a filesystem\n", mountedOn);
+ return -1;
+ }
}
#else /* AFS_SGI_ENV */
#if defined(AFS_SGI_ENV)
#include <fcntl.h>
#include <mntent.h>
-#ifndef AFS_SGI_XFS_IOPS_ENV
+#ifdef AFS_SGI_EFS_IOPS_ENV
#define ROOTINO EFS_ROOTINO
-#endif
-/*
#include <sys/fs/efs.h>
-*/
-#include "../sgiefs/efs.h" /* until 5.1 release */
+#include "../sgiefs/efs.h" /* until 5.1 release */
+#endif
+
#else
#ifndef AFS_LINUX20_ENV
#include <fcntl.h>
#include <mntent.h>
#include "partition.h"
+#ifdef AFS_SGI_EFS_IOPS_ENV
#include "../sgiefs/efs.h"
+#endif
#include <afs/xfsattrs.h>
char *prog = "xfs_size_check";
*linux*) \
${CC} ${DBUG} -o volserver $(SOBJS) $(HACKS) \
${LDFLAGS} $(LIBS) ${XLIBS} ;; \
- sgi_*) \
- ${CC} ${DBUG} -o volserver $(SOBJS) $(HACKS) \
- ${LDFLAGS} $(LIBS) ${XLIBS} \
- ../sgiefs/libefs.a ;; \
*) \
${CC} ${DBUG} -g -o volserver $(SOBJS) $(HACKS) \
${LDFLAGS} $(LIBS) ${XLIBS} ;; \