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