gpt4 book ai didi

netkit-telnet源码编译安装

转载 作者:我是一只小鸟 更新时间:2022-12-24 14:33:13 32 4
gpt4 key购买 nike

介绍

Linux 下流行的 telnet 实现有两个:

  1. GNU inetutils: http://ftp.gnu.org/gnu/inetutils/ 。

  2. 哈佛netkit-telnet 。

    • 源码包: https://tracker.debian.org/pkg/netkit-telnet 。

    • https://github.com/marado/netkit-telnet-ssl 。

编译

编译环境

Ubuntu 20.04.4 LTS 。

编译telnet-0.17

下载并解压安装包 netkit-telnet_0.17.orig.tar.gz 。

编译源码 。

                        
                          netkit-telnet-0.17# ./configure
netkit-telnet-0.17# make

                        
                      

遇到的问题

官方的代码编译还是会遇到一些代码本身的问题,需要做些修改.

undefined reference

                        
                          commands.cc:(.text+0x25c4): undefined reference to `operator new(unsigned long)'
/usr/bin/ld: commands.cc:(.text+0x2651): undefined reference to `operator new(unsigned long)'
/usr/bin/ld: commands.cc:(.text+0x26e1): undefined reference to `operator new(unsigned long)'

collect2: error: ld returned 1 exit status

                        
                      

原因: 申明了函数却没实现,一般是链接阶段出现 。

                        
                          netkit-telnet-0.17# ./configure
Looking for a C++ compiler... gcc            <<< 发现编译c++文件应该编译器要选g++

                        
                      

解决:修改configure文件中c++文件的编译器 。

                        
                          # git diff
diff --git a/configure b/configure
index 429167a..e8780e7 100755
--- a/configure
+++ b/configure
@@ -122,7 +122,7 @@ EOF

 if [ x"$CXX" = x ]; then
     echo -n 'Looking for a C++ compiler... '
-    for TRY in egcs gcc g++ CC c++ cc; do
+    for TRY in egcs g++ CC c++ cc; do        <<<修改

                        
                      

exit函数不存在

                        
                          main.cc:92:2: error: 'exit' was not declared in this scope; did you mean 'Exit'?
   92 |  exit(1);
      |  ^~~~
      |  Exit
make[1]: *** [../MRULES:7: main.o] Error 1
make[1]: Leaving directory 'netkit-telnet-0.17/telnet'
make: *** [Makefile:8: telnet.build] Error 2

                        
                      

解决:

添加头文件 。

                        
                          #include <cstdlib>

                        
                      

error: 'memcpy' was not declared

                        
                          terminal.cc:696:5: error: 'memcpy' was not declared in this scope
  696 |     memcpy(new_tc.c_cc, old_tc.c_cc, sizeof(old_tc.c_cc));

                        
                      

解决:

c++ - ‘memcpy’ was not declared in this scope - Stack Overflow 。

运行

编译完成后生成可执行文件 。

                        
                          //客户端
netkit-telnet-0.17/telnet/telnet
//服务端
netkit-telnet-0.17/telnetd/telnetd

                        
                      

运行client端

                        
                          netkit-telnet-0.17/telnet# ./telnet
telnet> ?
Commands may be abbreviated.  Commands are:

close           close current connection
logout          forcibly logout remote user and close the connection
display         display operating parameters
mode            try to enter line or character mode ('mode ?' for more)
open            connect to a site
quit            exit telnet
send            transmit special characters ('send ?' for more)
set             set operating parameters ('set ?' for more)
unset           unset operating parameters ('unset ?' for more)
status          print status information
toggle          toggle operating parameters ('toggle ?' for more)
slc             set treatment of special characters

z               suspend telnet
environ         change environment variables ('environ ?' for more)

                        
                      

运行server端

                        
                          netkit-telnet-0.17/telnetd# ./telnetd -n 
Usage: telnetd [-debug] [-D (options|report|exercise|netdata|ptydata)]
         [-h] [-L login_program] [-n] [port]

                        
                      

最后此篇关于netkit-telnet源码编译安装的文章就讲到这里了,如果你想了解更多关于netkit-telnet源码编译安装的内容请搜索CFSDN的文章或继续浏览相关文章,希望大家以后支持我的博客! 。

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com