1 Star 0 Fork 8

yixiangzhike/tftp

forked from src-openEuler/tftp 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
tftp-enhanced-logging.patch 3.37 KB
一键复制 编辑 原始数据 按行查看 历史
hexiaowen 提交于 2019-09-30 11:18 . Package init
--- a/tftpd/tftpd.c 2016-03-02 11:32:30.710775130 +0100
+++ b/tftpd/tftpd.c 2016-03-02 11:36:24.086541019 +0100
@@ -1056,14 +1056,14 @@ int main(int argc, char **argv)
static char *rewrite_access(char *, int, const char **);
static int validate_access(char *, int, const struct formats *, const char **);
-static void tftp_sendfile(const struct formats *, struct tftphdr *, int);
+static void tftp_sendfile(const struct formats *, struct tftphdr *, int, char *);
static void tftp_recvfile(const struct formats *, struct tftphdr *, int);
struct formats {
const char *f_mode;
char *(*f_rewrite) (char *, int, const char **);
int (*f_validate) (char *, int, const struct formats *, const char **);
- void (*f_send) (const struct formats *, struct tftphdr *, int);
+ void (*f_send) (const struct formats *, struct tftphdr *, int, char *);
void (*f_recv) (const struct formats *, struct tftphdr *, int);
int f_convert;
};
@@ -1129,6 +1129,9 @@ int tftp(struct tftphdr *tp, int size)
nak(EACCESS, errmsgptr); /* File denied by mapping rule */
exit(0);
}
+ ecode =
+ (*pf->f_validate) (filename, tp_opcode, pf, &errmsgptr);
+
if (verbosity >= 1) {
tmp_p = (char *)inet_ntop(from.sa.sa_family, SOCKADDR_P(&from),
tmpbuf, INET6_ADDRSTRLEN);
@@ -1147,9 +1150,14 @@ int tftp(struct tftphdr *tp, int size)
tp_opcode == WRQ ? "WRQ" : "RRQ",
tmp_p, origfilename,
filename);
+
+ if (ecode == 1) {
+ syslog(LOG_NOTICE, "Client %s File not found %s\n",
+ tmp_p,filename);
+ }
+
}
- ecode =
- (*pf->f_validate) (filename, tp_opcode, pf, &errmsgptr);
+
if (ecode) {
nak(ecode, errmsgptr);
exit(0);
@@ -1172,12 +1180,12 @@ int tftp(struct tftphdr *tp, int size)
if (tp_opcode == WRQ)
(*pf->f_recv) (pf, (struct tftphdr *)ackbuf, ap - ackbuf);
else
- (*pf->f_send) (pf, (struct tftphdr *)ackbuf, ap - ackbuf);
+ (*pf->f_send) (pf, (struct tftphdr *)ackbuf, ap - ackbuf, origfilename);
} else {
if (tp_opcode == WRQ)
(*pf->f_recv) (pf, NULL, 0);
else
- (*pf->f_send) (pf, NULL, 0);
+ (*pf->f_send) (pf, NULL, 0, origfilename);
}
exit(0); /* Request completed */
}
@@ -1557,7 +1565,7 @@ static int validate_access(char *filenam
/*
* Send the requested file.
*/
-static void tftp_sendfile(const struct formats *pf, struct tftphdr *oap, int oacklen)
+static void tftp_sendfile(const struct formats *pf, struct tftphdr *oap, int oacklen, char *filename)
{
struct tftphdr *dp;
struct tftphdr *ap; /* ack packet */
@@ -1648,6 +1656,13 @@ static void tftp_sendfile(const struct f
if (!++block)
block = rollover_val;
} while (size == segsize);
+ tmp_p = (char *)inet_ntop(from.sa.sa_family, SOCKADDR_P(&from),
+ tmpbuf, INET6_ADDRSTRLEN);
+ if (!tmp_p) {
+ tmp_p = tmpbuf;
+ strcpy(tmpbuf, "???");
+ }
+ syslog(LOG_NOTICE, "Client %s finished %s",tmp_p,filename);
abort:
(void)fclose(file);
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/yixiangzhike/tftp.git
git@gitee.com:yixiangzhike/tftp.git
yixiangzhike
tftp
tftp
master

搜索帮助