delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2004/10/12/22:30:45

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
Message-ID: <416C92BD.90100@hq.astra.ph>
Date: Wed, 13 Oct 2004 10:28:13 +0800
From: Carlo Florendo <list-subscriber AT hq DOT astra DOT ph>
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.7) Gecko/20040616
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: other services ok, ftp not (was 1.5.11 - tcp problems)
References: <4745850620 DOT 20040921112624 AT scenta DOT co DOT uk> <416B3A95 DOT 4010506 AT hq DOT astra DOT ph> <Pine DOT GSO DOT 4 DOT 61 DOT 0410121150090 DOT 24643 AT slinky DOT cs DOT nyu DOT edu>
In-Reply-To: <Pine.GSO.4.61.0410121150090.24643@slinky.cs.nyu.edu>
X-IsSubscribed: yes

Hello Igor,

Igor Pechtchanski wrote:

> Carlo,
>
> See comments inline below.

Thank you so much for your comments!    However, updating the relevant 
directories to have +x, and updating all the relevant files to have +rx  
still didn't solve the issue.  I've tried to track down the problem via 
the source code of inetutils-1.3.2-28 and it seems the actual error 
message is produced by the following code:

File:  inetutils-1.3.2-28 /ftp/main.c  (line numbers preceed each line)

147     sp = getservbyname("ftp", "tcp");
148     if (sp == 0)
149         errx(1, "ftp/tcp: unknown service");

I compiled and run ftp from source.   I get the same result.  sp is 
always 0 (NULL).   Thus, there's something not correct about my system.  
To test whether the relevant files under /etc are really readable, I've 
made this short test code which tries to open the files hosts, networks, 
protocols and services and print their corresponding handles to show 
that they're readable.  In addition, I've also placed a file 
/cygdrive/c/testfile which has permissions 000 to make sure that it's 
unreadable by anyone. 

#include <stdio.h>
#include <netdb.h>

/* file name: test.c */

int main()
{
    FILE *handle_hosts = NULL,
        *handle_networks = NULL,
        *handle_protocols = NULL,
        *handle_services = NULL,
        *handle_testfile = NULL;

    struct servent *sp = NULL;


    handle_hosts = fopen
        ("/cygdrive/c/WINNT/system32/drivers/etc/hosts", "r");
    handle_networks= fopen
        ("/cygdrive/c/WINNT/system32/drivers/etc/networks", "r");
    handle_protocols= fopen
        ("/cygdrive/c/WINNT/system32/drivers/etc/protocol", "r");
    handle_services= fopen
        ("/cygdrive/c/WINNT/system32/drivers/etc/services", "r");
    handle_testfile = fopen("/cygdrive/c/testfile", "r");

    printf("%s: %#x\n", "hosts handle", handle_hosts);
    printf("%s: %#x\n", "networks handle", handle_networks);
    printf("%s: %#x\n", "protocols handle", handle_protocols);
    printf("%s: %#x\n", "servies handle", handle_services);
    printf("%s: %#x\n", "/cygdrive/c/testfile", handle_testfile);

    sp = getservbyname("ftp","tcp");
    printf("%s: %#x\n", "servent handle", sp);

    fcloseall();

    return 0;

}

The following is the output:


SYSTEM  /tmp/ftp/inetutils-1.3.2-28/ftp
$ gcc test.c

SYSTEM /tmp/ftp/inetutils-1.3.2-28/ftp
$ ./a.exe
/etc/hosts handle: 0xa0501e4
/etc/networks handle: 0xa05024c
/etc/protocol handle: 0xa0502b4
/etc/servies handle: 0xa05031c
/cygdrive/c/testfile: 0
servent handle: 0

As you can see, all the relevant files have their respective handles.  
Thus, they were opened successfully.  On the other hand, 
/cygdrive/c/testfile gets a 0 (NULL) handle (logically) since its 
permissions are 000.

Here's the /cygdrive/c/testfile listing:

SYSTEM  /tmp/ftp/inetutils-1.3.2-28/ftp
$ ls -l /cygdrive/c/testfile
----------    1 Carlo    None            0 Oct 13 09:19 /cygdrive/c/testfile

I hope that takes care of the files. 

Now, a curious thing to note is that the servent handle sp returned 0 
(NULL).  It's suppose to read /etc/services.   A cat of /etc/services 
(I'll just use the symlinks since I want to save time not typing the 
entire FQN (e.g. /cygdrive/c/winnt etc. )) give me:

$ cat /etc/services
# Copyright (c) 1993-1999 Microsoft Corp.
#
# This file contains port numbers for well-known services defined by IANA
#
# Format:
#
# <service name>  <port number>/<protocol>  [aliases...]   [#<comment>]
#

echo                7/tcp
echo                7/udp
discard             9/tcp    sink null
discard             9/udp    sink null
systat             11/tcp    users                  #Active users
systat             11/tcp    users                  #Active users
daytime            13/tcp
daytime            13/udp
qotd               17/tcp    quote                  #Quote of the day
qotd               17/udp    quote                  #Quote of the day
chargen            19/tcp    ttytst source          #Character generator
chargen            19/udp    ttytst source          #Character generator
ftp-data           20/tcp                           #FTP, data
ftp                21/tcp                           #FTP. control
telnet             23/tcp
smtp               25/tcp    mail                   #Simple Mail 
Transfer Protocol

<file truncated>


FWIW, the cat of  protocol gives me:

$ cat /etc/protocols
# Copyright (c) 1993-1999 Microsoft Corp.
#
# This file contains the Internet protocols as defined by RFC 1700
# (Assigned Numbers).
#
# Format:
#
# <protocol name>  <assigned number>  [aliases...]   [#<comment>]

ip       0     IP       # Internet protocol
icmp     1     ICMP     # Internet control message protocol
ggp      3     GGP      # Gateway-gateway protocol
tcp      6     TCP      # Transmission control protocol

<file truncated>

The cat of /etc/hosts gives:

$ cat /etc/hosts
# Copyright (c) 1993-1999 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

127.0.0.1       localhost

<end of file>

The cat of networks gives:

$ cat /etc/networks
# Copyright (c) 1993-1999 Microsoft Corp.
#
# This file contains network name/network number mappings for
# local networks. Network numbers are recognized in dotted decimal form.
#
# Format:
#
# <network name>  <network number>     [aliases...]  [#<comment>]
#
# For example:
#
#    loopback     127
#    campus       284.122.107
#    london       284.122.108

loopback                 127

<end of file>


Thus, the files services, hosts, protocols, and networks,  are all 
readable even via the symlinks so it means that the actual files under 
C:\WINT\ etc, are really readable.
It seems that the problem is not with the file and directory permissions.

>> SYSTEM /cygdrive/c/winnt/system32
>> $ ls -ld drivers
>> drwxrwxr--+   4 Administ SYSTEM      28672 Sep 20 15:34 drivers
>
>         ^^^

Permissions fixed now.

>> SYSTEM /cygdrive/c/winnt/system32
>> $ cd drivers
>>
>> SYSTEM /cygdrive/c/winnt/system32/drivers
>> $ ls -ld etc
>> drwxrwxr--+   2 Administ SYSTEM       4096 Jun 22 00:09 etc
>
>          ^^^
>
> They have to be executable, not readable.  The readable bit controls
> listing the contents of the directory, but accessing the files requires
> the directory to be executable.


Done.

>
>> SYSTEM /cygdrive/c/winnt/system32/drivers
>> $ cd etc
>>
>> SYSTEM /cygdrive/c/winnt/system32/drivers/etc
>> $ ls -l
>> total 15
>> -rwxrwx---+   1 Administ SYSTEM       1757 Apr 11  2004 hosts
>
>         ^^^
>
>> -rwxrwx---+   1 Administ SYSTEM       3683 Jul 14  2003 lmhosts.sam
>> -rwxrwx---+   1 Administ SYSTEM        407 Jul 14  2003 networks
>
>         ^^^
>
>> -rwxrwx---+   1 Administ SYSTEM        799 Jul 14  2003 protocol
>
>         ^^^
>
>> -rwxrwxr--+   1 Administ SYSTEM       7116 Jul 14  2003 services
>
>
> All of the above have to be readable, too.


Done too.

>
>> However, I stll get the same error:
>>
>> SYSTEM /cygdrive/c/winnt/system32/drivers/etc
>> $ ftp
>> ftp: ftp/tcp: unknown service
>>
>> Then, I copied the services file itself and temporarily renamed the
>> symlink. After invoking ftp, it still didn't work.
>
>
> Of course it wouldn't.  Cygwin uses Winsock, which looks for the files in
> the above directory, not in /etc.  The /etc links are simply to make
> Cygwin look more like Linux.


Ok. Thanks for the info.

Sorry for being a bit verbose on this mail.  However, I thought it 
would've been better on my part if I erred giving more info than giving 
less.  If some of this info is superflous, please let me know.

So, are there more things which I have to look into?

Thanks!

Best Regards,

Carlo
--
Carlo Florendo
Astra Philippines Inc.
www.astra.ph








--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019