]> andersk Git - moira.git/blob - update/xfer_003.c
Implement AUTH_002, which isn't vulnerable to replay attacks. Remove
[moira.git] / update / xfer_003.c
1 /*
2  *      $Source$
3  *      $Header$
4  */
5 /*  (c) Copyright 1988, 1992 by the Massachusetts Institute of Technology.
6  *  For copying and distribution information, please see the file
7  *  <mit-copyright.h>.
8  */
9
10 #ifndef lint
11 static char *rcsid_xfer_002_c = "$Header$";
12 #endif
13
14 #include <mit-copyright.h>
15 #include <stdio.h>
16 #include <gdb.h>
17 #include <ctype.h>
18 #include <sys/param.h>
19 #include <sys/file.h>
20 #include <string.h>
21 #include <moira.h>
22
23 extern CONNECTION conn;
24 extern char buf[BUFSIZ];
25
26 extern int code, errno;
27
28 extern int have_authorization, have_file, done;
29
30 /*
31  *
32  * syntax:
33  * >>> (STRING)"xfer_003" filesize checksum pathname
34  * <<< (int)0
35  * >>> (STRING)data
36  * <<< (int)code
37  * >>> (STRING)data
38  * <<< (int)code
39  * ...
40  * >>> (STRING)data     (last data block)
41  * <<< (int)code        (from read, write, checksum verify)
42  *
43  * function:
44  *      perform initial preparations and receive file as
45  * a single string, storing it into <pathname>.moira_update.
46  * this version of transfer encrypts the file being transferred.
47  */
48
49 int
50 xfer_003(str)
51     char *str;
52 {
53     int file_size;
54     int checksum;
55     char *pathname;
56     
57     str += 8;
58     while (*str == ' ')
59         str++;
60     if (!*str) {
61     failure:
62         reject_call(MR_ARGS);
63         return(0);
64     }
65     file_size = atoi(str);
66     while (isdigit(*str))
67         str++;
68     while (*str == ' ')
69         str++;
70     checksum = atoi(str);
71     while (isdigit(*str))
72         str++;
73     while (*str == ' ')
74         str++;
75     if (*str != '/')
76         goto failure;
77     pathname = str;
78     if (!have_authorization) {
79         reject_call(MR_PERM);
80         return(0);
81     }
82     if (done)                   /* re-initialize data */
83         initialize();
84     code = send_ok();
85     if (code)
86         lose("sending ok for file xfer (2)");
87     code = get_file(pathname, file_size, checksum, 0444, 1);
88     if (!code) {
89         char buf[BUFSIZ];
90         have_file = 1;
91         strcpy(buf, "transferred file ");
92         strcat(buf, pathname);
93         mr_log_info(buf);
94     }
95     return(0);
96 }
This page took 0.046661 seconds and 5 git commands to generate.