#include <afsconfig.h>
#include <afs/param.h>
-RCSID
- ("$Header$");
#include <afs/stds.h>
#ifdef AFS_AIX32_ENV
#include <sys/time.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
#endif
#include "update.h"
#include "global.h"
+#include "update_internal.h"
char *whoami;
static int verbose;
afs_int32 atime, afs_int32 mtime);
static int RenameNewFiles(struct filestr *modFiles);
static int PathsAreEquivalent(char *path1, char *path2);
+int FetchFile(struct rx_call *, char *, char *, int);
+int IsCompatible(char *, afs_int32, afs_int32);
+int NotOnHost(char *, struct filestr *);
+int update_ReceiveFile(int, struct rx_call *, struct stat *);
afs_int32
GetServer(char *aname)
int
-osi_audit()
+osi_audit(void)
{
/* this sucks but it works for now.
*/
errcode = rx_Init(0);
if (errcode) {
printf("Rx initialize failed \n");
- com_err(whoami, errcode, "calling Rx init");
+ afs_com_err(whoami, errcode, "calling Rx init");
exit(1);
}
exit(1);
}
if (errcode) {
- com_err(whoami, errcode, "Couldn't get security obect for localAuth");
+ afs_com_err(whoami, errcode, "Couldn't get security obect for localAuth");
exit(1);
}
/* construct local path from canonical (wire-format) path */
if ((errcode = ConstructLocalPath(df->name, "/", &curDir))) {
- com_err(whoami, errcode, "Unable to construct local path");
+ afs_com_err(whoami, errcode, "Unable to construct local path");
return errcode;
}
#else
if (mkdir(curDir, 0700) < 0) {
#endif
- com_err(whoami, errno, "can't create dir");
+ afs_com_err(whoami, errno, "can't create dir");
printf("upclient: Can't update dir %s\n", curDir);
return -1;
}
error = rx_EndCall(call, 0);
if (error && !errcode) {
printf("could not end rx call \n");
- com_err(whoami, error, "calling EndCall");
+ afs_com_err(whoami, error, "calling EndCall");
goto fail;
}
if (errcode) {
printf
("warning: could not fetch the contents of directory %s \n",
df->name);
- com_err(whoami, errcode, "calling FetchFile");
+ afs_com_err(whoami, errcode, "calling FetchFile");
cnt++;
goto fail;
}
stream = fopen(dirbuf, "r");
if (stream == NULL) {
printf("fopen failed on %s \n", dirbuf);
- com_err(whoami, errno, "fopen");
+ afs_com_err(whoami, errno, "fopen");
goto fail;
}
umask(00);
dirp = opendir(curDir);
if (dirp == 0) {
- com_err(whoami, errno, "Can't open local dir %s", curDir);
+ afs_com_err(whoami, errno, "Can't open local dir %s", curDir);
goto fail;
}
errcode = unlink(filename);
if (errcode) {
printf("could not delete file %s \n", filename);
- com_err(whoami, errno, "could not delete file %s",
+ afs_com_err(whoami, errno, "could not delete file %s",
filename);
}
}
/* construct a local path from canonical (wire-format) path */
if ((error = ConstructLocalPath(filename, "/", &localname))) {
- com_err(whoami, error, "Unable to construct local path");
+ afs_com_err(whoami, error, "Unable to construct local path");
return error;
}
fd = open(localFile, O_CREAT | O_TRUNC | O_WRONLY, 0666);
if (fd < 0) {
printf("Could not create %s\n", localFile);
- com_err(whoami, errno, "Could not create %s", localFile);
+ afs_com_err(whoami, errno, "Could not create %s", localFile);
error = UPDATE_ERROR;
return error;
}
if (fstat(fd, &status) < 0) {
- com_err(whoami, errno, "Could not stat %s", localFile);
+ afs_com_err(whoami, errno, "Could not stat %s", localFile);
close(fd);
- printf("could not stast %s\n", localFile);
+ printf("could not stat %s\n", localFile);
return UPDATE_ERROR;
}
if (update_ReceiveFile(fd, call, &status))
struct statfs tstatfs;
#endif
- len = rx_Read(call, &length, sizeof(afs_int32));
+ len = rx_Read(call, (char *)&length, sizeof(afs_int32));
length = ntohl(length);
if (len != sizeof(afs_int32))
return UPDATE_ERROR;
if (!nbytes)
error = UPDATE_ERROR;
if (write(fd, buffer, nbytes) != nbytes) {
- com_err(whoami, errno, "File system write failed!");
+ afs_com_err(whoami, errno, "File system write failed!");
printf("File system write failed!\n");
error = UPDATE_ERROR;
}
for (tf = okhostfiles; tf; tf = tf->next) {
/* construct local path from canonical (wire-format) path */
if ((rc = ConstructLocalPath(tf->name, "/", &hostfile))) {
- com_err(whoami, rc, "Unable to construct local path");
+ afs_com_err(whoami, rc, "Unable to construct local path");
return -1;
}
if (PathsAreEquivalent(hostfile, filename)) {
for (tf = modFiles; tf; tf = tf->next) {
/* construct local path from canonical (wire-format) path */
if ((errcode = ConstructLocalPath(tf->name, "/", &fname))) {
- com_err(whoami, errcode, "Unable to construct local path");
+ afs_com_err(whoami, errcode, "Unable to construct local path");
return errcode;
}
strcpy(newname, fname);
errcode = renamefile(newname, fname);
if (errcode) {
printf("could not rename %s to %s\n", newname, fname);
- com_err(whoami, errno, "could not rename %s to %s", newname,
+ afs_com_err(whoami, errno, "could not rename %s to %s", newname,
fname);
}
free(fname);
/* construct local path from canonical (wire-format) path */
errcode = ConstructLocalPath(filename, "/", &lfile);
if (errcode) {
- com_err(whoami, errcode, "Unable to construct local path");
+ afs_com_err(whoami, errcode, "Unable to construct local path");
return -1;
}
strcpy(newfile, lfile);
if (errcode) {
printf("failed to fetch file %s \n", filename);
- com_err(whoami, errcode, "fetching file");
+ afs_com_err(whoami, errcode, "fetching file");
+ unlink(newfile);
return 1;
}
if (errcode) {
printf("could not change protection on %s to %u\n", newfile,
(unsigned int)mode);
- com_err(whoami, errno, "could not change protection on %s to %u",
+ afs_com_err(whoami, errno, "could not change protection on %s to %u",
newfile, mode);
+ unlink(newfile);
return 1;
}
#ifdef AFS_NT40_ENV
if (errcode) {
printf("warning: could not change uid and gid on %s to %u and %u \n",
newfile, gid, uid);
- com_err(whoami, errno,
+ afs_com_err(whoami, errno,
"warning: could not change uid and gid on %s to %u and %u",
newfile, gid, uid);
}
if (errcode) {
printf("could not change access and modify times on %s to %u %u\n",
newfile, (unsigned int)atime, (unsigned int)mtime);
- com_err(whoami, errno,
+ afs_com_err(whoami, errno,
"could not change access and modify times on %s to %u %u",
newfile, atime, mtime);
+ unlink(newfile);
return 1;
}