Revision 24319,
1.8 KB
checked in by broder, 15 years ago
(diff) |
New Moira snapshot from SVN.
|
Rev | Line | |
---|
[24319] | 1 | /* $Id: xfer_003.c 3956 2010-01-05 20:56:56Z zacheiss $ |
---|
[23095] | 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>. |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | #include <mit-copyright.h> |
---|
| 9 | #include <moira.h> |
---|
| 10 | #include "update_server.h" |
---|
| 11 | |
---|
| 12 | #include <ctype.h> |
---|
| 13 | #include <stdio.h> |
---|
| 14 | #include <stdlib.h> |
---|
| 15 | #include <string.h> |
---|
| 16 | |
---|
[24319] | 17 | RCSID("$HeadURL: svn+ssh://svn.mit.edu/moira/trunk/moira/update/xfer_003.c $ $Id: xfer_003.c 3956 2010-01-05 20:56:56Z zacheiss $"); |
---|
[23095] | 18 | |
---|
| 19 | /* |
---|
| 20 | * |
---|
| 21 | * syntax: |
---|
| 22 | * >>> (STRING)"xfer_003" filesize checksum pathname |
---|
| 23 | * <<< (int)0 |
---|
| 24 | * >>> (STRING)data |
---|
| 25 | * <<< (int)code |
---|
| 26 | * >>> (STRING)data |
---|
| 27 | * <<< (int)code |
---|
| 28 | * ... |
---|
| 29 | * >>> (STRING)data (last data block) |
---|
| 30 | * <<< (int)code (from read, write, checksum verify) |
---|
| 31 | * |
---|
| 32 | * function: |
---|
| 33 | * perform initial preparations and receive file as |
---|
| 34 | * a single string, storing it into <pathname>.moira_update. |
---|
| 35 | * this version of transfer encrypts the file being transferred. |
---|
| 36 | */ |
---|
| 37 | |
---|
| 38 | void xfer_003(int conn, char *str) |
---|
| 39 | { |
---|
| 40 | int file_size, checksum, code; |
---|
| 41 | char *pathname, *p; |
---|
| 42 | |
---|
| 43 | str += 8; |
---|
| 44 | while (*str == ' ') |
---|
| 45 | str++; |
---|
| 46 | if (!*str) |
---|
| 47 | { |
---|
| 48 | failure: |
---|
| 49 | send_int(conn, MR_ARGS); |
---|
| 50 | return; |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | file_size = strtol(str, &p, 10); |
---|
| 54 | if (p == str) |
---|
| 55 | { |
---|
| 56 | send_int(conn, MR_ARGS); |
---|
| 57 | return; |
---|
| 58 | } |
---|
| 59 | else |
---|
| 60 | str = p; |
---|
| 61 | while (*str == ' ') |
---|
| 62 | str++; |
---|
| 63 | |
---|
| 64 | checksum = strtol(str, &p, 10); |
---|
| 65 | if (p == str) |
---|
| 66 | { |
---|
| 67 | send_int(conn, MR_ARGS); |
---|
| 68 | return; |
---|
| 69 | } |
---|
| 70 | else |
---|
| 71 | str = p; |
---|
| 72 | while (*str == ' ') |
---|
| 73 | str++; |
---|
| 74 | |
---|
| 75 | if (*str != '/') |
---|
| 76 | goto failure; |
---|
| 77 | pathname = str; |
---|
| 78 | |
---|
| 79 | if (!have_authorization) |
---|
| 80 | { |
---|
| 81 | send_int(conn, MR_PERM); |
---|
| 82 | return; |
---|
| 83 | } |
---|
| 84 | |
---|
| 85 | send_ok(conn); |
---|
| 86 | code = get_file(conn, pathname, file_size, checksum, 0444, 1); |
---|
| 87 | if (!code) |
---|
| 88 | com_err(whoami, 0, "Transferred file %s", pathname); |
---|
| 89 | |
---|
| 90 | return; |
---|
| 91 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.