#include <afsconfig.h>
#include <afs/param.h>
-RCSID
- ("$Header$");
#include <afs/stds.h>
#ifdef AFS_AIX32_ENV
#include <sys/file.h>
#include <dirent.h>
#endif
-#ifdef HAVE_STRING_H
#include <string.h>
-#else
-#ifdef HAVE_STRINGS_H
-#include <strings.h>
-#endif
-#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <afs/cellconfig.h>
#include <afs/afsutil.h>
#include <afs/fileutil.h>
+#include <afs/com_err.h>
+#ifdef AFS_AIX_ENV
+#include <sys/statfs.h>
+#endif
#include "update.h"
#include "global.h"
-extern int UPDATE_ExecuteRequest();
static int AddObject(char **expPath, char *dir);
static int PathInDirectory(char *dir, char *path);
+int update_SendFile(int, struct rx_call *, struct stat *);
+int update_SendDirInfo(char *, struct rx_call *, struct stat *,
+ char *origDir);
struct afsconf_dir *cdir;
int nDirs;
int dirLevel[MAXENTRIES];
char *whoami;
-static int Quit();
+static int Quit(char *);
+
+int rxBind = 0;
+
+#define ADDRSPERSITE 16 /* Same global is in rx/rx_user.c */
+afs_uint32 SHostAddrs[ADDRSPERSITE];
/* check whether caller is authorized to manage RX statistics */
int
-update_rxstat_userok(call)
- struct rx_call *call;
+update_rxstat_userok(struct rx_call *call)
{
return afsconf_SuperUser(cdir, call, NULL);
}
return inDir;
}
-
int
-AuthOkay(call, name)
- struct rx_call *call;
- char *name;
+AuthOkay(struct rx_call *call, char *name)
{
int i;
rxkad_level level;
}
int
-osi_audit()
+osi_audit(void)
{
/* this sucks but it works for now.
*/
#endif
int
-main(argc, argv)
- int argc;
- char *argv[];
+main(int argc, char *argv[])
{
struct rx_securityClass *securityObjects[3];
struct rx_service *service;
+ afs_uint32 host = htonl(INADDR_ANY);
int a = 0;
rxkad_level level;
for (a = 1; a < argc; a++) {
if (argv[a][0] == '-') { /* parse options */
- char arg[256];
- lcstring(arg, argv[a], sizeof(arg));
- newLevel = StringToLevel(&argv[a][1]);
- if (newLevel != -1) {
- level = newLevel; /* set new level */
+ if (strcmp(argv[a], "-rxbind") == 0) {
+ rxBind = 1;
continue;
+ } else {
+ char arg[256];
+ lcstring(arg, argv[a], sizeof(arg));
+ newLevel = rxkad_StringToLevel(&argv[a][1]);
+ if (newLevel != -1) {
+ level = newLevel; /* set new level */
+ continue;
+ }
}
usage:
- Quit("Usage: upserver [<directory>+] [-crypt <directory>+] [-clear <directory>+] [-auth <directory>+] [-help]\n");
+ Quit("Usage: upserver [<directory>+] [-crypt <directory>+] [-clear <directory>+] [-auth <directory>+] [-rxbind] [-help]\n");
} else {
int dirlen;
if (nDirs >= sizeof(dirName) / sizeof(dirName[0]))
exit(1);
}
+ if (rxBind) {
+ afs_int32 ccode;
+ if (AFSDIR_SERVER_NETRESTRICT_FILEPATH ||
+ AFSDIR_SERVER_NETINFO_FILEPATH) {
+ char reason[1024];
+ ccode = parseNetFiles(SHostAddrs, NULL, NULL,
+ ADDRSPERSITE, reason,
+ AFSDIR_SERVER_NETINFO_FILEPATH,
+ AFSDIR_SERVER_NETRESTRICT_FILEPATH);
+ } else
+ {
+ ccode = rx_getAllAddr(SHostAddrs, ADDRSPERSITE);
+ }
+ if (ccode == 1)
+ host = SHostAddrs[0];
+ }
+
/* Initialize Rx, telling it port number this server will use for its
* single service */
- if (rx_Init(htons(AFSCONF_UPDATEPORT)) < 0)
+ if (rx_InitHost(host, htons(AFSCONF_UPDATEPORT)) < 0)
Quit("rx_init");
/* Create a single security object, in this case the null security object,
* which is called to decode requests is passed in here
* (UPDATE_ExecuteRequest). */
service =
- rx_NewService(0, UPDATE_SERVICEID, "UPDATE", securityObjects, 3,
- UPDATE_ExecuteRequest);
+ rx_NewServiceHost(host, 0, UPDATE_SERVICEID, "UPDATE", securityObjects,
+ 3, UPDATE_ExecuteRequest);
if (service == (struct rx_service *)0)
Quit("rx_NewService");
rx_SetMaxProcs(service, 2);
/* fetch the file name and send it to the remote requester specified by call */
int
-UPDATE_FetchFile(call, name)
- struct rx_call *call;
- char *name;
+UPDATE_FetchFile(struct rx_call *call, char *name)
{
int fd = -1;
int error = 0;
/* construct a local path from a canonical (wire-format) path */
if ((error = ConstructLocalPath(name, "/", &reqObject))) {
- com_err(whoami, error, "Unable to construct local path");
+ afs_com_err(whoami, error, "Unable to construct local path");
return UPDATE_ERROR;
}
/* fetch dir info about directory name and send it to remote host associated
with call. */
int
-UPDATE_FetchInfo(call, name)
- struct rx_call *call;
- char *name;
+UPDATE_FetchInfo(struct rx_call *call, char *name)
{
- int fd = -1;
int error = 0;
struct stat status;
char *reqObject;
/* construct a local path from a canonical (wire-format) path */
if ((error = ConstructLocalPath(name, "/", &reqObject))) {
- com_err(whoami, error, "Unable to construct local path");
+ afs_com_err(whoami, error, "Unable to construct local path");
return UPDATE_ERROR;
}
}
if ((status.st_mode & S_IFMT) != S_IFDIR) {
printf(" file %s is not a directory \n", reqObject);
- if (fd >= 0)
- close(fd);
error = -1;
}
- if (fd >= 0)
- close(fd);
if (!error)
error = update_SendDirInfo(reqObject, call, &status, name);
}
}
static int
-Quit(msg, a, b)
- char *msg;
+Quit(char *msg)
{
- fprintf(stderr, msg, a, b);
+ fprintf(stderr, msg);
exit(1);
}
int
-update_SendFile(fd, call, status)
- register int fd;
- register struct rx_call *call;
- register struct stat *status;
+update_SendFile(register int fd, register struct rx_call *call, register struct stat *status)
{
char *buffer = (char *)0;
int blockSize;
afs_int32 length, tlen;
-#ifdef notdef
- XDR xdr;
-#endif
#ifdef AFS_AIX_ENV
-#include <sys/statfs.h>
struct statfs tstatfs;
#endif
printf("malloc failed\n");
return UPDATE_ERROR;
}
-#ifdef notdef
- xdrrx_create(&xdr, call, XDR_ENCODE);
- if (!xdr_afs_int32(&xdr, &length))
- error = UPDATE_ERROR;
-#else
tlen = htonl(length);
- rx_Write(call, &tlen, sizeof(afs_int32)); /* send length on fetch */
-#endif
+ rx_Write(call, (char *)&tlen, sizeof(afs_int32)); /* send length on fetch */
while (!error && length) {
register int nbytes = (length > blockSize ? blockSize : length);
nbytes = read(fd, buffer, nbytes);
/* Enumerate dir (name) and write dir entry info into temp file.
*/
int
-update_SendDirInfo(name, call, status, origDir)
- char *name; /* Name of dir to enumerate */
- register struct rx_call *call; /* rx call */
- register struct stat *status; /* stat struct for dir */
- char *origDir; /* orig name of dir before being localized */
+update_SendDirInfo(char *name, /* Name of dir to enumerate */
+ register struct rx_call *call, /* rx call */
+ register struct stat *status, /* stat struct for dir */
+ char *origDir) /* orig name of dir before being localized */
{
DIR *dirp;
struct dirent *dp;
}
if (error == 0) {
fd = open(dirInfoFile, O_RDONLY, 0);
- if (fd) {
+ if (fd >= 0) {
fstat(fd, &tstatus);
errcode = update_SendFile(fd, call, &tstatus);
if (errcode)
/* construct a local path from a canonical (wire-format) path */
if ((error = ConstructLocalPath(dir, "/", expPath))) {
- com_err(whoami, error, "Unable to construct local path");
+ afs_com_err(whoami, error, "Unable to construct local path");
return error;
}
/* stat the object */
error = stat(*expPath, &statbuf);
if (error) {
- com_err(whoami, error, ";Can't stat object.");
+ afs_com_err(whoami, error, ";Can't stat object.");
return error;
}
/* now check if the object has an exportable (file/dir) type */