ふり返る暇なんて無いね

日々のメモ書きをつらつらと

connectがhomebrewで入らなくなったので自前でビルドする

sshで踏み台するときにconectコマンドを使うのですが、いつからかhomebrewで入らなくなったので、環境作り直しの時に調べるの面倒なので入れ方メモ。

wget ftp://ftp.st.ryukoku.ac.jp/pub/security/tool/openssh-supports/connect.c
gcc connect.c -o connect -lresolv
# 適当にPATHが通ってるところに置いておく
sudo mv connect ~/opt/bin/

compile時に大量にwarningsがでるが一応バイナリはできる。

connect.c:1937:13: warning: passing 'unsigned char *' to parameter of type 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]
    strcpy( ptr, relay_user );
            ^~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/secure/_string.h:83:27: note: expanded from macro 'strcpy'
  __builtin___strcpy_chk (dest, src, __darwin_obsz (dest))
                          ^
connect.c:1941:13: warning: passing 'unsigned char *' to parameter of type 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]
    strcpy( ptr, pass );
            ^~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/secure/_string.h:83:27: note: expanded from macro 'strcpy'
  __builtin___strcpy_chk (dest, src, __darwin_obsz (dest))
                          ^
connect.c:1947:20: warning: passing 'unsigned char [1024]' to parameter of type 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]
    atomic_out( s, buf, ptr-buf );
                   ^~~
connect.c:1756:29: note: passing argument to parameter 'buf' here
atomic_out( SOCKET s, char *buf, int size )
                            ^
connect.c:1949:19: warning: passing 'unsigned char [1024]' to parameter of type 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]
    atomic_in( s, buf, 2 );
                  ^~~
connect.c:1782:28: note: passing argument to parameter 'buf' here
atomic_in( SOCKET s, char *buf, int size )
                           ^
connect.c:2035:36: warning: initializing 'unsigned char *' with an expression of type 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]
    unsigned char buf[256], *ptr, *env = socks5_auth;
                                   ^     ~~~~~~~~~~~
connect.c:2046:13: warning: assigning to 'unsigned char *' from 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]
        env = getparam(ENV_SOCKS5_AUTH);
            ^ ~~~~~~~~~~~~~~~~~~~~~~~~~
connect.c:2053:36: warning: passing 'unsigned char *' to parameter of type 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]
        n_auth = socks5_auth_parse(env, auth_list, 10);
                                   ^~~
connect.c:2008:25: note: passing argument to parameter 'start' here
socks5_auth_parse(char *start, unsigned char *auth_list, int max_auth){
                        ^
connect.c:2061:20: warning: passing 'unsigned char [256]' to parameter of type 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]
    atomic_out( s, buf, ptr-buf );              /* send requst */
                   ^~~
connect.c:1756:29: note: passing argument to parameter 'buf' here
atomic_out( SOCKET s, char *buf, int size )
                            ^
connect.c:2062:19: warning: passing 'unsigned char [256]' to parameter of type 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]
    atomic_in( s, buf, 2 );                     /* recv response */
                  ^~~
connect.c:1782:28: note: passing argument to parameter 'buf' here
atomic_in( SOCKET s, char *buf, int size )
                           ^
connect.c:2115:20: warning: passing 'unsigned char [256]' to parameter of type 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]
    atomic_out( s, buf, ptr-buf);               /* send request */
                   ^~~
connect.c:1756:29: note: passing argument to parameter 'buf' here
atomic_out( SOCKET s, char *buf, int size )
                            ^
connect.c:2116:19: warning: passing 'unsigned char [256]' to parameter of type 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]
    atomic_in( s, buf, 4 );                     /* recv response */
                  ^~~
connect.c:1782:28: note: passing argument to parameter 'buf' here
atomic_in( SOCKET s, char *buf, int size )
                           ^
connect.c:2125:23: warning: passing 'unsigned char *' to parameter of type 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]
        atomic_in( s, ptr, 4+2 );               /* recv IPv4 addr and port */
                      ^~~
connect.c:1782:28: note: passing argument to parameter 'buf' here
atomic_in( SOCKET s, char *buf, int size )
                           ^
connect.c:2128:23: warning: passing 'unsigned char *' to parameter of type 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]
        atomic_in( s, ptr, 1 );                 /* recv name and port */
                      ^~~
connect.c:1782:28: note: passing argument to parameter 'buf' here
atomic_in( SOCKET s, char *buf, int size )
                           ^
connect.c:2129:23: warning: passing 'unsigned char *' to parameter of type 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]
        atomic_in( s, ptr+1, *(unsigned char*)ptr + 2);
                      ^~~~~
connect.c:1782:28: note: passing argument to parameter 'buf' here
atomic_in( SOCKET s, char *buf, int size )
                           ^
connect.c:2132:23: warning: passing 'unsigned char *' to parameter of type 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]
        atomic_in( s, ptr, 16+2 );              /* recv IPv6 addr and port */
                      ^~~
connect.c:1782:28: note: passing argument to parameter 'buf' here
atomic_in( SOCKET s, char *buf, int size )
                           ^
connect.c:2193:13: warning: passing 'unsigned char *' to parameter of type 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]
    strcpy( ptr, relay_user );
            ^~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/secure/_string.h:83:27: note: expanded from macro 'strcpy'
  __builtin___strcpy_chk (dest, src, __darwin_obsz (dest))
                          ^
connect.c:2197:17: warning: passing 'unsigned char *' to parameter of type 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]
        strcpy( ptr, dest_host );
                ^~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/secure/_string.h:83:27: note: expanded from macro 'strcpy'
  __builtin___strcpy_chk (dest, src, __darwin_obsz (dest))
                          ^
connect.c:2202:20: warning: passing 'unsigned char [256]' to parameter of type 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]
    atomic_out( s, buf, ptr-buf);               /* send request */
                   ^~~
connect.c:1756:29: note: passing argument to parameter 'buf' here
atomic_out( SOCKET s, char *buf, int size )
                            ^
connect.c:2203:19: warning: passing 'unsigned char [256]' to parameter of type 'char *' converts between pointers to integer types with different sign [-Wpointer-sign]
    atomic_in( s, buf, 8 );                     /* recv response */
                  ^~~
connect.c:1782:28: note: passing argument to parameter 'buf' here
atomic_in( SOCKET s, char *buf, int size )
                           ^
connect.c:2248:9: warning: assigning to 'char *' from 'unsigned char *' converts between pointers to integer types with different sign [-Wpointer-sign]
    dst = (unsigned char *)buf;
        ^ ~~~~~~~~~~~~~~~~~~~~
connect.c:2749:41: warning: passing 'int *' to parameter of type 'socklen_t *' (aka 'unsigned int *') converts between pointers to integer types with different sign [-Wpointer-sign]
    connection = accept( sock, &client, &socklen);
                                        ^~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/sys/socket.h:560:69: note: passing argument to parameter here
int     accept(int, struct sockaddr * __restrict, socklen_t * __restrict)
                                                                        ^
21 warnings generated.