18
18
You should have received a copy of the GNU General Public License
19
19
along with this program; if not, write to the Free Software
20
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
22
The author of the program may be contacted at ian@airs.com or
23
c/o Cygnus Support, 48 Grove Street, Somerville, MA 02144.
22
The author of the program may be contacted at ian@airs.com.
29
const char rec_rcsid[] = "$Id: rec.c,v 1.43 1995/08/02 01:21:12 ian Rel $";
28
const char rec_rcsid[] = "$Id: rec.c,v 1.48 2002/03/05 19:10:41 ian Rel $";
342
344
&& (cbytes == -1 || qdaemon->clocal_size < cbytes))
343
345
cbytes = qdaemon->clocal_size;
347
fquote = fcmd_needs_quotes (&qtrans->s);
352
if ((qdaemon->ifeatures & FEATURE_QUOTES) == 0)
353
return flocal_rec_fail (qtrans, &qtrans->s, qdaemon->qsys,
354
"remote system does not support required quoting");
355
uquote_cmd (&qtrans->s, &squoted);
345
359
/* We send the string
346
360
R from to user options
348
362
We put a dash in front of options. If we are talking to a
349
363
counterpart, we also send the maximum size file we are prepared
350
364
to accept, as returned by esysdep_open_receive. */
351
clen = (strlen (qtrans->s.zfrom) + strlen (qtrans->s.zto)
352
+ strlen (qtrans->s.zuser) + strlen (qtrans->s.zoptions) + 30);
365
clen = (strlen (qcmd->zfrom) + strlen (qcmd->zto)
366
+ strlen (qcmd->zuser) + strlen (qcmd->zoptions) + 30);
353
367
zsend = zbufalc (clen);
354
368
if ((qdaemon->ifeatures & FEATURE_SIZES) == 0)
355
sprintf (zsend, "R %s %s %s -%s", qtrans->s.zfrom, qtrans->s.zto,
356
qtrans->s.zuser, qtrans->s.zoptions);
369
sprintf (zsend, "R %s %s %s -%s", qcmd->zfrom, qcmd->zto,
370
qcmd->zuser, qcmd->zoptions);
357
371
else if ((qdaemon->ifeatures & FEATURE_V103) == 0)
358
sprintf (zsend, "R %s %s %s -%s 0x%lx", qtrans->s.zfrom, qtrans->s.zto,
359
qtrans->s.zuser, qtrans->s.zoptions, (unsigned long) cbytes);
372
sprintf (zsend, "R %s %s %s -%s 0x%lx", qcmd->zfrom, qcmd->zto,
373
qcmd->zuser, qcmd->zoptions, (unsigned long) cbytes);
361
sprintf (zsend, "R %s %s %s -%s %ld", qtrans->s.zfrom, qtrans->s.zto,
362
qtrans->s.zuser, qtrans->s.zoptions, cbytes);
375
sprintf (zsend, "R %s %s %s -%s %ld", qcmd->zfrom, qcmd->zto,
376
qcmd->zuser, qcmd->zoptions, cbytes);
364
378
fret = (*qdaemon->qproto->pfsendcmd) (qdaemon, zsend, qtrans->ilocal,
365
379
qtrans->iremote);
366
380
ubuffree (zsend);
383
ufree_quoted_cmd (&squoted);
368
385
/* There is a potential space leak here: if pfsendcmd fails, we
369
386
might need to free qtrans. However, it is possible that by the
370
387
time pfsendcmd returns, a response will have been received which
1005
1019
zerr = strerror (errno);
1006
1020
ulog (LOG_ERROR, "%s: close: %s", qtrans->s.zto, zerr);
1007
1021
(void) remove (qinfo->ztemp);
1009
else if (! fsysdep_move_file (qinfo->ztemp, qinfo->zfile, qinfo->fspool,
1010
FALSE, ! qinfo->fspool,
1013
: (const char *) NULL)))
1017
/* Keep the temporary file if there is 1.5 times the amount of
1018
required free space. This is just a random guess, to make an
1019
unusual situtation potentially less painful. */
1020
cspace = csysdep_bytes_free (qinfo->ztemp);
1022
cspace = FREE_SPACE_DELTA;
1023
cspace -= (qdaemon->qsys->uuconf_cfree_space
1024
+ qdaemon->qsys->uuconf_cfree_space / 2);
1027
(void) remove (qinfo->ztemp);
1028
zerr = "could not move to final location";
1035
zalc = zbufalc (sizeof "could not move to final location (left as )"
1036
+ strlen (qinfo->ztemp));
1037
sprintf (zalc, "could not move to final location (left as %s)",
1042
az[i++] = "The file\n\t";
1043
az[i++] = qinfo->ztemp;
1045
"\nwas saved because the move to the final location failed.\n";
1046
az[i++] = "See the UUCP logs for more details.\n";
1047
az[i++] = "The file transfer was from\n\t";
1048
az[i++] = qdaemon->qsys->uuconf_zname;
1050
az[i++] = qtrans->s.zfrom;
1051
az[i++] = "\nto\n\t";
1052
az[i++] = qtrans->s.zto;
1053
az[i++] = "\nand was requested by\n\t";
1054
az[i++] = qtrans->s.zuser;
1056
(void) fsysdep_mail (OWNER, "UUCP temporary file saved", i, az);
1058
ulog (LOG_ERROR, "%s: %s", qinfo->zfile, zerr);
1022
qtrans->e = EFILECLOSED;
1063
if (! qinfo->fspool)
1026
qtrans->e = EFILECLOSED;
1027
if (! fsysdep_move_file (qinfo->ztemp, qinfo->zfile, qinfo->fspool,
1028
FALSE, ! qinfo->fspool,
1031
: (const char *) NULL)))
1067
/* Unless we can change the ownership of the file, the only
1068
choice to make about these bits is whether to set the
1069
execute bit or not. */
1070
if ((qtrans->s.imode & 0111) != 0)
1035
/* Keep the temporary file if there is 1.5 times the amount
1036
of required free space. This is just a random guess, to
1037
make an unusual situtation potentially less painful. */
1038
cspace = csysdep_bytes_free (qinfo->ztemp);
1040
cspace = FREE_SPACE_DELTA;
1041
cspace -= (qdaemon->qsys->uuconf_cfree_space
1042
+ qdaemon->qsys->uuconf_cfree_space / 2);
1045
(void) remove (qinfo->ztemp);
1046
zerr = "could not move to final location";
1074
(void) fsysdep_change_mode (qinfo->zfile, imode);
1053
zalc = zbufalc (sizeof "could not move to final location (left as )"
1054
+ strlen (qinfo->ztemp));
1055
sprintf (zalc, "could not move to final location (left as %s)",
1060
az[i++] = "The file\n\t";
1061
az[i++] = qinfo->ztemp;
1063
"\nwas saved because the move to the final location failed.\n";
1064
az[i++] = "See the UUCP logs for more details.\n";
1065
az[i++] = "The file transfer was from\n\t";
1066
az[i++] = qdaemon->qsys->uuconf_zname;
1068
az[i++] = qtrans->s.zfrom;
1069
az[i++] = "\nto\n\t";
1070
az[i++] = qtrans->s.zto;
1071
az[i++] = "\nand was requested by\n\t";
1072
az[i++] = qtrans->s.zuser;
1074
(void) fsysdep_mail (OWNER, "UUCP temporary file saved", i, az);
1076
ulog (LOG_ERROR, "%s: %s", qinfo->zfile, zerr);
1081
if (! qinfo->fspool)
1085
/* Unless we can change the ownership of the file, the
1086
only choice to make about these bits is whether to
1087
set the execute bit or not. */
1088
if ((qtrans->s.imode & 0111) != 0)
1092
(void) fsysdep_change_mode (qinfo->zfile, imode);
1080
1099
ustats (zerr == NULL, qtrans->s.zuser, qdaemon->qsys->uuconf_zname,
1172
fprintf (e, "U %s %s\n", qtrans->s.zuser, qdaemon->qsys->uuconf_zname);
1173
fprintf (e, "F %s\n", qtrans->s.zto);
1174
fprintf (e, "I %s\n", qtrans->s.zto);
1191
if (! fcmd_needs_quotes (&qtrans->s))
1193
fprintf (e, "U %s %s\n", qtrans->s.zuser,
1194
qdaemon->qsys->uuconf_zname);
1195
fprintf (e, "F %s\n", qtrans->s.zto);
1196
fprintf (e, "I %s\n", qtrans->s.zto);
1197
if (strchr (qtrans->s.zoptions, 'R') != NULL)
1198
fprintf (e, "R %s\n", qtrans->s.znotify);
1199
fprintf (e, "C %s\n", qtrans->s.zcmd);
1208
z1 = zquote_cmd_string (qtrans->s.zuser, FALSE);
1209
z2 = zquote_cmd_string (qdaemon->qsys->uuconf_zname, FALSE);
1210
fprintf (e, "U %s %s\n", z1, z2);
1214
z1 = zquote_cmd_string (qtrans->s.zto, FALSE);
1215
fprintf (e, "F %s\n", z1);
1216
fprintf (e, "I %s\n", z1);
1219
if (strchr (qtrans->s.zoptions, 'R') != NULL)
1221
z1 = zquote_cmd_string (qtrans->s.znotify, FALSE);
1222
fprintf (e, "R %s\n", z1);
1226
z1 = zquote_cmd_string (qtrans->s.zcmd, TRUE);
1227
fprintf (e, "C %s\n", z1);
1175
1231
if (strchr (qtrans->s.zoptions, 'N') != NULL)
1176
1232
fprintf (e, "N\n");
1177
1233
if (strchr (qtrans->s.zoptions, 'Z') != NULL)
1178
1234
fprintf (e, "Z\n");
1179
if (strchr (qtrans->s.zoptions, 'R') != NULL)
1180
fprintf (e, "R %s\n", qtrans->s.znotify);
1181
1235
if (strchr (qtrans->s.zoptions, 'e') != NULL)
1182
1236
fprintf (e, "e\n");
1183
fprintf (e, "C %s\n", qtrans->s.zcmd);