Cleanup
This commit is contained in:
136
net-ftp/opsi-atftp/files/atftp-0.7-blockno.patch
Normal file
136
net-ftp/opsi-atftp/files/atftp-0.7-blockno.patch
Normal file
@@ -0,0 +1,136 @@
|
||||
--- atftp-0.7/tftp_file.c~ 2010-05-27 13:05:12.000000000 -0500
|
||||
+++ atftp-0.7/tftp_file.c 2010-05-27 12:50:05.000000000 -0500
|
||||
@@ -133,19 +133,21 @@
|
||||
int mcast_sockfd = 0;
|
||||
struct sockaddr_in sa_mcast;
|
||||
struct ip_mreq mreq;
|
||||
struct hostent *host;
|
||||
int master_client = 0;
|
||||
unsigned int file_bitmap[NB_BLOCK];
|
||||
int prev_bitmap_hole = -1; /* the previous hole found in the bitmap */
|
||||
char string[MAXLEN];
|
||||
+ int rx_block_number;
|
||||
|
||||
int prev_block_number = 0; /* needed to support netascii convertion */
|
||||
int temp = 0;
|
||||
+ size_t ignore;
|
||||
|
||||
data->file_size = 0;
|
||||
tftp_cancel = 0;
|
||||
from.sin_addr.s_addr = 0;
|
||||
|
||||
memset(&sa_mcast, 0, sizeof(struct sockaddr_in));
|
||||
memset(&file_bitmap, 0, sizeof(file_bitmap));
|
||||
|
||||
@@ -300,17 +302,17 @@
|
||||
{
|
||||
connect(sockfd, (struct sockaddr *)&sa, sizeof(sa));
|
||||
connected = 1;
|
||||
}
|
||||
state = S_OACK_RECEIVED;
|
||||
break;
|
||||
case GET_ERROR:
|
||||
fprintf(stderr, "tftp: error received from server <");
|
||||
- fwrite(tftphdr->th_msg, 1, data_size - 4 - 1, stderr);
|
||||
+ ignore = fwrite(tftphdr->th_msg, 1, data_size - 4 - 1, stderr);
|
||||
fprintf(stderr, ">\n");
|
||||
state = S_ABORT;
|
||||
break;
|
||||
case GET_DATA:
|
||||
number_of_timeout = 0;
|
||||
/* if the socket if not connected, connect it */
|
||||
if (!connected)
|
||||
{
|
||||
@@ -513,21 +515,24 @@
|
||||
state = S_WAIT_PACKET;
|
||||
break;
|
||||
case S_DATA_RECEIVED:
|
||||
if ((multicast && master_client) || (!multicast))
|
||||
timeout_state = S_SEND_ACK;
|
||||
else
|
||||
timeout_state = S_WAIT_PACKET;
|
||||
|
||||
- block_number = ntohs(tftphdr->th_block);
|
||||
+ rx_block_number = ntohs(tftphdr->th_block);
|
||||
if (data->trace)
|
||||
fprintf(stderr, "received DATA <block: %d, size: %d>\n",
|
||||
ntohs(tftphdr->th_block), data_size - 4);
|
||||
|
||||
+ if ((uint16_t)rx_block_number == (uint16_t)(block_number+1))
|
||||
+ ++block_number;
|
||||
+
|
||||
if (tftp_file_write(fp, tftphdr->th_data, data->data_buffer_size - 4, block_number,
|
||||
data_size - 4, convert, &prev_block_number, &temp)
|
||||
!= data_size - 4)
|
||||
{
|
||||
|
||||
fprintf(stderr, "tftp: error writing to file %s\n",
|
||||
data->local_file);
|
||||
tftp_send_error(sockfd, &sa, ENOSPACE, data->data_buffer,
|
||||
@@ -613,19 +618,21 @@
|
||||
int connected; /* 1 when sockfd is connected */
|
||||
struct tftphdr *tftphdr = (struct tftphdr *)data->data_buffer;
|
||||
FILE *fp; /* the local file pointer */
|
||||
int number_of_timeout = 0;
|
||||
struct stat file_stat;
|
||||
int convert = 0; /* if true, do netascii convertion */
|
||||
char string[MAXLEN];
|
||||
|
||||
+ int ack_block_number;
|
||||
int prev_block_number = 0; /* needed to support netascii convertion */
|
||||
int prev_file_pos = 0;
|
||||
int temp = 0;
|
||||
+ size_t ignore;
|
||||
|
||||
data->file_size = 0;
|
||||
tftp_cancel = 0;
|
||||
from.sin_addr.s_addr = 0;
|
||||
|
||||
/* make sure the socket is not connected */
|
||||
sa.sin_family = AF_UNSPEC;
|
||||
connect(sockfd, (struct sockaddr *)&sa, sizeof(sa));
|
||||
@@ -759,20 +766,23 @@
|
||||
case GET_ACK:
|
||||
number_of_timeout = 0;
|
||||
/* if the socket if not connected, connect it */
|
||||
if (!connected)
|
||||
{
|
||||
//connect(sockfd, (struct sockaddr *)&sa, sizeof(sa));
|
||||
connected = 1;
|
||||
}
|
||||
- block_number = ntohs(tftphdr->th_block);
|
||||
+ ack_block_number = ntohs(tftphdr->th_block);
|
||||
+ if ((uint16_t)(block_number+1) == ack_block_number)
|
||||
+ ++block_number;
|
||||
if (data->trace)
|
||||
fprintf(stderr, "received ACK <block: %d>\n",
|
||||
- block_number);
|
||||
+ ack_block_number);
|
||||
+
|
||||
if ((last_block != -1) && (block_number > last_block))
|
||||
{
|
||||
state = S_END;
|
||||
break;
|
||||
}
|
||||
state = S_SEND_DATA;
|
||||
break;
|
||||
case GET_OACK:
|
||||
@@ -782,17 +792,17 @@
|
||||
{
|
||||
//connect(sockfd, (struct sockaddr *)&sa, sizeof(sa));
|
||||
connected = 1;
|
||||
}
|
||||
state = S_OACK_RECEIVED;
|
||||
break;
|
||||
case GET_ERROR:
|
||||
fprintf(stderr, "tftp: error received from server <");
|
||||
- fwrite(tftphdr->th_msg, 1, data_size - 4 - 1, stderr);
|
||||
+ ignore = fwrite(tftphdr->th_msg, 1, data_size - 4 - 1, stderr);
|
||||
fprintf(stderr, ">\n");
|
||||
state = S_ABORT;
|
||||
break;
|
||||
case GET_DISCARD:
|
||||
/* consider discarded packet as timeout to make sure when don't lock up
|
||||
if routing is broken */
|
||||
number_of_timeout++;
|
||||
fprintf(stderr, "tftp: packet discard <%s:%d>.\n",
|
||||
141
net-ftp/opsi-atftp/files/atftp-0.7-filecase.patch
Normal file
141
net-ftp/opsi-atftp/files/atftp-0.7-filecase.patch
Normal file
@@ -0,0 +1,141 @@
|
||||
* Case insensitive lookup patch for atftpd
|
||||
*
|
||||
* Copyright (c) 2006-2007 Gianluigi Tiesi <sherpya@netfarm.it>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this software; if not, write to the
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
diff -Nur atftp-0.7.dfsg.orig/tftpd.c atftp-0.7.dfsg/tftpd.c
|
||||
--- atftp-0.7.dfsg.orig/tftpd.c 2007-12-09 06:06:20.000000000 +0100
|
||||
+++ atftp-0.7.dfsg/tftpd.c 2007-12-09 06:08:51.229707272 +0100
|
||||
@@ -667,6 +667,15 @@
|
||||
switch (retval)
|
||||
{
|
||||
case GET_RRQ:
|
||||
+ if (data->tftp_options[OPT_FILENAME].value[0] == '\\')
|
||||
+ if (!tftpd_lookup_file(directory, data->tftp_options[OPT_FILENAME].value))
|
||||
+ {
|
||||
+ /* Short circuit */
|
||||
+ tftp_send_error(data->sockfd, &data->client_info->client,
|
||||
+ ENOTFOUND, data->data_buffer, data->data_buffer_size);
|
||||
+ stats_err_locked();
|
||||
+ break;
|
||||
+ }
|
||||
logger(LOG_NOTICE, "Serving %s to %s:%d",
|
||||
data->tftp_options[OPT_FILENAME].value,
|
||||
inet_ntoa(data->client_info->client.sin_addr),
|
||||
diff -Nur atftp-0.7.dfsg.orig/tftpd.h atftp-0.7.dfsg/tftpd.h
|
||||
--- atftp-0.7.dfsg.orig/tftpd.h 2004-02-27 03:05:26.000000000 +0100
|
||||
+++ atftp-0.7.dfsg/tftpd.h 2007-12-09 06:06:35.319368784 +0100
|
||||
@@ -77,6 +77,7 @@
|
||||
/*
|
||||
* Functions defined in tftpd_file.c
|
||||
*/
|
||||
+int tftpd_lookup_file(const char *directory, char *filename);
|
||||
int tftpd_rules_check(char *filename);
|
||||
int tftpd_receive_file(struct thread_data *data);
|
||||
int tftpd_send_file(struct thread_data *data);
|
||||
diff -Nur atftp-0.7.dfsg.orig/tftpd_file.c atftp-0.7.dfsg/tftpd_file.c
|
||||
--- atftp-0.7.dfsg.orig/tftpd_file.c 2004-02-18 03:21:47.000000000 +0100
|
||||
+++ atftp-0.7.dfsg/tftpd_file.c 2007-12-09 06:09:23.683773504 +0100
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
+#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
#include "tftpd.h"
|
||||
#include "tftp_io.h"
|
||||
@@ -60,6 +61,81 @@
|
||||
extern tftpd_pcre_self_t *pcre_top;
|
||||
#endif
|
||||
|
||||
+/*
|
||||
+ * Case insensitive file lookup, for windows clients
|
||||
+ */
|
||||
+
|
||||
+int tftpd_lookup_entry(const char *comp, char *dest)
|
||||
+{
|
||||
+ DIR *dirp;
|
||||
+ struct dirent *dptr;
|
||||
+ dirp = opendir(dest);
|
||||
+ if (!dirp) return 0;
|
||||
+ while ((dptr = readdir(dirp)))
|
||||
+ {
|
||||
+ if (!strcasecmp(dptr->d_name, comp))
|
||||
+ {
|
||||
+ strcat(dest, "/");
|
||||
+ strcat(dest, dptr->d_name);
|
||||
+ closedir(dirp);
|
||||
+ return 1;
|
||||
+ }
|
||||
+ }
|
||||
+ closedir(dirp);
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+int tftpd_lookup_file(const char *directory, char *filename)
|
||||
+{
|
||||
+ int found = 0;
|
||||
+ int len = 0;
|
||||
+ char dest[MAXLEN];
|
||||
+ char comp[MAXLEN];
|
||||
+ char *check = filename;
|
||||
+ char *seek = NULL;
|
||||
+
|
||||
+ dest[0] = 0;
|
||||
+ strcat(dest, directory);
|
||||
+ len = strlen(dest);
|
||||
+ if (dest[len-1] == '/')
|
||||
+ dest[len-1] = 0;
|
||||
+ check++;
|
||||
+ while (*check)
|
||||
+ {
|
||||
+ seek = strchr(check, '\\');
|
||||
+ if (!seek)
|
||||
+ {
|
||||
+ if ((*check) && (tftpd_lookup_entry(check, dest)))
|
||||
+ found = 1;
|
||||
+ break;
|
||||
+ }
|
||||
+ len = seek - check;
|
||||
+ memcpy(comp, check, len);
|
||||
+ comp[len]=0;
|
||||
+ if (!tftpd_lookup_entry(comp, dest))
|
||||
+ break;
|
||||
+ check += len + 1;
|
||||
+ }
|
||||
+
|
||||
+ if (found)
|
||||
+ {
|
||||
+ filename[0] = 0;
|
||||
+ strcat(filename, dest + strlen(directory));
|
||||
+ }
|
||||
+ else
|
||||
+ {
|
||||
+ seek = filename;
|
||||
+ while (*seek)
|
||||
+ {
|
||||
+ if (*seek == '\\') *seek = '/';
|
||||
+ seek++;
|
||||
+ }
|
||||
+ filename++;
|
||||
+ }
|
||||
+
|
||||
+ logger(LOG_DEBUG, "Filecase lookup file: %s (found %s)", filename, (found ? "yes" : "no"));
|
||||
+ return found;
|
||||
+}
|
||||
|
||||
/*
|
||||
* Rules for filenames. This is common to both tftpd_recieve_file
|
||||
20
net-ftp/opsi-atftp/files/atftp-0.7-gcc.patch
Normal file
20
net-ftp/opsi-atftp/files/atftp-0.7-gcc.patch
Normal file
@@ -0,0 +1,20 @@
|
||||
--- argz.h.orig 2005-02-07 16:04:41.000000000 -0500
|
||||
+++ argz.h 2005-02-07 16:05:01.000000000 -0500
|
||||
@@ -180,7 +180,7 @@
|
||||
#ifdef __USE_EXTERN_INLINES
|
||||
extern inline char *
|
||||
__argz_next (__const char *__argz, size_t __argz_len,
|
||||
- __const char *__entry) __THROW
|
||||
+ __const char *__entry)
|
||||
{
|
||||
if (__entry)
|
||||
{
|
||||
@@ -194,7 +194,7 @@
|
||||
}
|
||||
extern inline char *
|
||||
argz_next (__const char *__argz, size_t __argz_len,
|
||||
- __const char *__entry) __THROW
|
||||
+ __const char *__entry)
|
||||
{
|
||||
return __argz_next (__argz, __argz_len, __entry);
|
||||
}
|
||||
22
net-ftp/opsi-atftp/files/atftp-0.7-glibc24.patch
Normal file
22
net-ftp/opsi-atftp/files/atftp-0.7-glibc24.patch
Normal file
@@ -0,0 +1,22 @@
|
||||
--- atftp-0.7/stats.c.org
|
||||
+++ atftp-0.7/stats.c
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
+#include <unistd.h>
|
||||
#include "tftp_def.h"
|
||||
#include "stats.h"
|
||||
#include "logger.h"
|
||||
@@ -157,8 +158,9 @@
|
||||
|
||||
logger(LOG_INFO, " Load measurements:");
|
||||
+ long sc_clk_tck = sysconf(_SC_CLK_TCK);
|
||||
logger(LOG_INFO, " User: %8.3fs Sys:%8.3fs",
|
||||
- (double)(s_stats.tms.tms_utime) / CLK_TCK,
|
||||
- (double)(s_stats.tms.tms_stime) / CLK_TCK);
|
||||
+ (double)(s_stats.tms.tms_utime) / sc_clk_tck,
|
||||
+ (double)(s_stats.tms.tms_stime) / sc_clk_tck);
|
||||
logger(LOG_INFO, " Total:%8.3fs CPU:%8.3f%%",
|
||||
(double)(tmp.tv_sec + tmp.tv_usec * 1e-6),
|
||||
(double)(s_stats.tms.tms_utime + s_stats.tms.tms_stime) /
|
||||
12
net-ftp/opsi-atftp/files/atftp-0.7-illreply.patch
Normal file
12
net-ftp/opsi-atftp/files/atftp-0.7-illreply.patch
Normal file
@@ -0,0 +1,12 @@
|
||||
*** tftp_def.old.c 2009-02-28 17:56:12.000000000 +0100
|
||||
--- tftp_def.c 2009-02-28 17:57:02.000000000 +0100
|
||||
***************
|
||||
*** 141,146 ****
|
||||
--- 141,147 ----
|
||||
*/
|
||||
inline char *Strncpy(char *to, const char *from, size_t size)
|
||||
{
|
||||
+ if (size <= 0) { *to = '\000'; return to; }
|
||||
to[size-1] = '\000';
|
||||
return strncpy(to, from, size - 1);
|
||||
}
|
||||
94
net-ftp/opsi-atftp/files/atftp-0.7-password.patch
Normal file
94
net-ftp/opsi-atftp/files/atftp-0.7-password.patch
Normal file
@@ -0,0 +1,94 @@
|
||||
diff -Naur atftp-0.7.orig/tftp.c atftp-0.7/tftp.c
|
||||
--- atftp-0.7.orig/tftp.c 2004-03-15 18:55:56.000000000 -0500
|
||||
+++ atftp-0.7/tftp.c 2005-08-29 21:40:06.000000000 -0400
|
||||
@@ -525,6 +525,10 @@
|
||||
fprintf(stderr, " multicast: enabled\n");
|
||||
else
|
||||
fprintf(stderr, " multicast: disabled\n");
|
||||
+ if (data.tftp_options[OPT_PASSWORD].specified)
|
||||
+ fprintf(stderr, " password: enabled\n");
|
||||
+ else
|
||||
+ fprintf(stderr, " password: disabled\n");
|
||||
return ERR;
|
||||
}
|
||||
/* if disabling an option */
|
||||
@@ -971,6 +975,7 @@
|
||||
{ "put", 0, NULL, 'p'},
|
||||
{ "local-file", 1, NULL, 'l'},
|
||||
{ "remote-file", 1, NULL, 'r'},
|
||||
+ { "password", 1, NULL, 'P'},
|
||||
{ "tftp-timeout", 1, NULL, 'T'},
|
||||
{ "mode", 1, NULL, 'M'},
|
||||
{ "option", 1, NULL, 'O'},
|
||||
@@ -993,7 +998,7 @@
|
||||
};
|
||||
|
||||
/* Support old argument until 0.8 */
|
||||
- while ((c = getopt_long(argc, argv, /*"gpl:r:Vh"*/ "gpl:r:Vht:b:sm",
|
||||
+ while ((c = getopt_long(argc, argv, /*"gpl:r:Vh"*/ "gpl:r:Vht:b:smP:",
|
||||
options, &option_index)) != EOF)
|
||||
{
|
||||
switch (c)
|
||||
@@ -1028,6 +1033,11 @@
|
||||
else
|
||||
action = PUT;
|
||||
break;
|
||||
+ case 'P':
|
||||
+ snprintf(string, sizeof(string), "option password %s", optarg);
|
||||
+ make_arg(string, &ac, &av);
|
||||
+ process_cmd(ac, av);
|
||||
+ break;
|
||||
case 'l':
|
||||
interactive = 0;
|
||||
Strncpy(local_file, optarg, MAXLEN);
|
||||
@@ -1169,6 +1179,7 @@
|
||||
" -p, --put : put file\n"
|
||||
" -l, --local-file <file> : local file name\n"
|
||||
" -r, --remote-file <file> : remote file name\n"
|
||||
+ " -P, --password <password>: specify password (Linksys ext.)\n"
|
||||
" --tftp-timeout <value> : delay before retransmission, client side\n"
|
||||
#if 0
|
||||
" t, --timeout <value> : delay before retransmission, "
|
||||
diff -Naur atftp-0.7.orig/tftp_def.c atftp-0.7/tftp_def.c
|
||||
--- atftp-0.7.orig/tftp_def.c 2004-02-12 22:16:09.000000000 -0500
|
||||
+++ atftp-0.7/tftp_def.c 2005-08-29 21:36:57.000000000 -0400
|
||||
@@ -37,6 +37,7 @@
|
||||
{ "timeout", "5", 0, 1 }, /* 2348, 2349, 2090. */
|
||||
{ "blksize", "512", 0, 1 }, /* This is the default option */
|
||||
{ "multicast", "", 0, 1 }, /* structure */
|
||||
+ { "password", "", 0, 1}, /* password */
|
||||
{ "", "", 0, 0}
|
||||
};
|
||||
|
||||
diff -Naur atftp-0.7.orig/tftp_def.h atftp-0.7/tftp_def.h
|
||||
--- atftp-0.7.orig/tftp_def.h 2004-02-12 22:16:09.000000000 -0500
|
||||
+++ atftp-0.7/tftp_def.h 2005-08-29 20:16:27.000000000 -0400
|
||||
@@ -40,6 +40,7 @@
|
||||
#define OPT_TIMEOUT 3
|
||||
#define OPT_BLKSIZE 4
|
||||
#define OPT_MULTICAST 5
|
||||
+#define OPT_PASSWORD 6
|
||||
#define OPT_NUMBER 7
|
||||
|
||||
#define OPT_SIZE 12
|
||||
diff -Naur atftp-0.7.orig/tftp_io.c atftp-0.7/tftp_io.c
|
||||
--- atftp-0.7.orig/tftp_io.c 2004-02-18 20:30:00.000000000 -0500
|
||||
+++ atftp-0.7/tftp_io.c 2005-08-29 22:05:11.000000000 -0400
|
||||
@@ -70,10 +70,13 @@
|
||||
break;
|
||||
if (tftp_options[i].enabled && tftp_options[i].specified)
|
||||
{
|
||||
- Strncpy(data_buffer + buf_index, tftp_options[i].option,
|
||||
- data_buffer_size - buf_index);
|
||||
- buf_index += strlen(tftp_options[i].option);
|
||||
- buf_index++;
|
||||
+ if (i != OPT_PASSWORD)
|
||||
+ {
|
||||
+ Strncpy(data_buffer + buf_index, tftp_options[i].option,
|
||||
+ data_buffer_size - buf_index);
|
||||
+ buf_index += strlen(tftp_options[i].option);
|
||||
+ buf_index++;
|
||||
+ }
|
||||
Strncpy(data_buffer + buf_index, tftp_options[i].value,
|
||||
data_buffer_size - buf_index);
|
||||
buf_index += strlen(tftp_options[i].value);
|
||||
14
net-ftp/opsi-atftp/files/atftp-0.7-pcre.patch
Normal file
14
net-ftp/opsi-atftp/files/atftp-0.7-pcre.patch
Normal file
@@ -0,0 +1,14 @@
|
||||
--- atftp-0.7/tftpd_pcre.c~ 2005-10-17 23:14:52.000000000 +0200
|
||||
+++ atftp-0.7/tftpd_pcre.c 2005-10-17 23:14:52.000000000 +0200
|
||||
@@ -211,9 +211,9 @@
|
||||
chp++; /* point to value indicating substring */
|
||||
rc = pcre_get_substring(str, ovector, matches, *chp - 0x30, &tmpstr);
|
||||
/* found string */
|
||||
- if (rc > 0)
|
||||
+ if (rc > 0 && outchp - outstr + rc+1 < outsize)
|
||||
{
|
||||
- Strncpy(outchp, tmpstr, rc);
|
||||
+ Strncpy(outchp, tmpstr, rc+1);
|
||||
outchp += rc;
|
||||
pcre_free_substring(tmpstr);
|
||||
continue;
|
||||
96
net-ftp/opsi-atftp/files/atftp-0.7-spaced_filename.patch
Normal file
96
net-ftp/opsi-atftp/files/atftp-0.7-spaced_filename.patch
Normal file
@@ -0,0 +1,96 @@
|
||||
--- atftp-0.7/tftp.c~ 2010-06-03 08:51:14.000000000 -0500
|
||||
+++ atftp-0.7/tftp.c 2010-06-03 09:40:56.000000000 -0500
|
||||
@@ -18,16 +18,17 @@
|
||||
#include "config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <getopt.h>
|
||||
#include <string.h>
|
||||
+#include <stdarg.h>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <netdb.h>
|
||||
|
||||
#include <signal.h>
|
||||
@@ -344,16 +345,41 @@
|
||||
|
||||
/* If no names matched, then return NULL. */
|
||||
return NULL;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
+ * set argc/argv from variadic string arguments
|
||||
+*/
|
||||
+void make_arg_vector(int *argc, char***argv, ...)
|
||||
+{
|
||||
+ char **p;
|
||||
+ char *s;
|
||||
+ va_list argp;
|
||||
+
|
||||
+ // how many args?
|
||||
+ *argc = 0;
|
||||
+ va_start(argp, argv);
|
||||
+ while ( (s=va_arg(argp, char*)) )
|
||||
+ ++*argc;
|
||||
+
|
||||
+ // allocate storage
|
||||
+ *argv = malloc(*argc * sizeof (char*));
|
||||
+
|
||||
+ // store args
|
||||
+ p = *argv;
|
||||
+ va_start(argp, argv);
|
||||
+ while ( (s=va_arg(argp, char*)) )
|
||||
+ *p++ = s;
|
||||
+}
|
||||
+
|
||||
+/*
|
||||
* Split a string into args.
|
||||
*/
|
||||
void make_arg(char *string, int *argc, char ***argv)
|
||||
{
|
||||
static char *tmp = NULL;
|
||||
size_t argz_len;
|
||||
|
||||
/* split the string to an argz vector */
|
||||
@@ -1142,30 +1168,26 @@
|
||||
argv[optind+1]);
|
||||
make_arg(string, &ac, &av);
|
||||
process_cmd(ac, av);
|
||||
}
|
||||
|
||||
if (!interactive)
|
||||
{
|
||||
if (action == PUT)
|
||||
- snprintf(string, sizeof(string), "put %s %s", local_file,
|
||||
- remote_file);
|
||||
+ make_arg_vector(&ac,&av,"put",local_file,remote_file,NULL);
|
||||
else if (action == GET)
|
||||
- snprintf(string, sizeof(string), "get %s %s", remote_file,
|
||||
- local_file);
|
||||
+ make_arg_vector(&ac,&av,"get",remote_file,local_file,NULL);
|
||||
else if (action == MGET)
|
||||
- snprintf(string, sizeof(string), "mget %s %s", remote_file,
|
||||
- local_file);
|
||||
+ make_arg_vector(&ac,&av,"mget",remote_file,local_file,NULL);
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "No action specified in batch mode!\n");
|
||||
exit(ERR);
|
||||
}
|
||||
- make_arg(string, &ac, &av);
|
||||
if (process_cmd(ac, av) == ERR)
|
||||
exit(ERR);
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
||||
void tftp_usage(void)
|
||||
{
|
||||
23
net-ftp/opsi-atftp/files/atftp-0.7-tests.patch
Normal file
23
net-ftp/opsi-atftp/files/atftp-0.7-tests.patch
Normal file
@@ -0,0 +1,23 @@
|
||||
diff -Naur atftp-0.7.orig/test/test.sh atftp-0.7/test/test.sh
|
||||
--- atftp-0.7.orig/test/test.sh 2003-04-28 21:59:51.000000000 -0400
|
||||
+++ atftp-0.7/test/test.sh 2005-10-26 22:42:15.000000000 -0400
|
||||
@@ -151,7 +151,7 @@
|
||||
test_blocksize 1428
|
||||
test_blocksize 16000
|
||||
test_blocksize 64000
|
||||
-test_blocksize 65465
|
||||
+test_blocksize 65464
|
||||
|
||||
#
|
||||
# testing fot tsize
|
||||
@@ -162,9 +162,9 @@
|
||||
TSIZE=`grep "OACK <tsize:" out | sed -e "s/[^0-9]//g"`
|
||||
if [ "$TSIZE" != "2048" ]; then
|
||||
echo "ERROR (server report $TSIZE bytes but it should be 2048)"
|
||||
+ ERROR=1
|
||||
else
|
||||
echo "OK"
|
||||
- ERROR=1
|
||||
fi
|
||||
|
||||
#
|
||||
4
net-ftp/opsi-atftp/files/atftp.confd
Normal file
4
net-ftp/opsi-atftp/files/atftp.confd
Normal file
@@ -0,0 +1,4 @@
|
||||
# Config file for tftp server
|
||||
|
||||
TFTPD_ROOT="/tftproot"
|
||||
TFTPD_OPTS="--daemon --user nobody --group nobody"
|
||||
28
net-ftp/opsi-atftp/files/atftp.init
Executable file
28
net-ftp/opsi-atftp/files/atftp.init
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/sbin/runscript
|
||||
|
||||
depend() {
|
||||
use logger
|
||||
need net
|
||||
}
|
||||
|
||||
checkconfig() {
|
||||
if [ ! -d ${TFTPD_ROOT} ]
|
||||
then
|
||||
eerror "You need a tftp root directory"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
start() {
|
||||
checkconfig || return 1
|
||||
ebegin "Starting tftpd"
|
||||
start-stop-daemon --start --quiet --exec /usr/sbin/in.tftpd \
|
||||
-- ${TFTPD_OPTS} ${TFTPD_ROOT}
|
||||
eend $?
|
||||
}
|
||||
|
||||
stop() {
|
||||
ebegin "Stopping tftpd"
|
||||
start-stop-daemon --stop --quiet --exec /usr/sbin/in.tftpd
|
||||
eend $?
|
||||
}
|
||||
Reference in New Issue
Block a user