unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Service names on machines with bad service files
@ 2011-09-19  9:30 Lars Magne Ingebrigtsen
  2011-09-19  9:40 ` Lars Magne Ingebrigtsen
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Lars Magne Ingebrigtsen @ 2011-09-19  9:30 UTC (permalink / raw)
  To: emacs-devel

A Windows user has a problem with opening a connection using port
"imaps", which doesn't exist in that user's service file (or wherever
Windows stashes these things).

So I'm wondering whether there's any nice way to determine that that's
the situation and work around it.

(open-network-stream "hello" nil "gmail.com" "hello")
=>
Debugger entered--Lisp error: (error "gmail.com/hello Servname not supported for ai_socktype")

Possibilities are:

1) Don't use "imaps", but just say "993".  This would work, and it's
simple.  But is it rude to use port numbers instead of service names?
Are users supposed to be able to edit /etc/services and have "imaps" go
off somewhere else entirely?

2) Somehow determine that the OS doesn't know what "imaps" is, and use
"993" as a fallback.  I have no idea whether that's easy to do.

3) Make `open-network-stream' "know" about these mappings (a variable),
and if we get the right error message (i.e. the one above), we try again
using that mapping.  This would probably mean propagating RET
meaningfully (somehow) from `make-network-process' here:

      ret = getaddrinfo (SSDATA (host), portstring, &hints, &res);
      if (ret)
#ifdef HAVE_GAI_STRERROR
	error ("%s/%s %s", SSDATA (host), portstring, gai_strerror (ret));
#else
	error ("%s/%s getaddrinfo error %d", SSDATA (host), portstring, ret);
#endif
      immediate_quit = 0;

Thoughts?      

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Service names on machines with bad service files
  2011-09-19  9:30 Service names on machines with bad service files Lars Magne Ingebrigtsen
@ 2011-09-19  9:40 ` Lars Magne Ingebrigtsen
  2011-09-19 10:07   ` Julien Danjou
  2011-09-19 19:07   ` Chong Yidong
  2011-09-19 19:32 ` Andy Wingo
  2011-09-25 11:38 ` Ted Zlatanov
  2 siblings, 2 replies; 12+ messages in thread
From: Lars Magne Ingebrigtsen @ 2011-09-19  9:40 UTC (permalink / raw)
  To: emacs-devel

Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

> 2) Somehow determine that the OS doesn't know what "imaps" is, and use
> "993" as a fallback.  I have no idea whether that's easy to do.

This would be very easy to do.  It would mean making a new C-level
function that basically just calls getservbyname and returns the port
number.  So nnimap would the call `open-network-stream' with
(or (service-port-number "imaps") 993).

That sounds quite nice, doesn't it?

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Service names on machines with bad service files
  2011-09-19  9:40 ` Lars Magne Ingebrigtsen
@ 2011-09-19 10:07   ` Julien Danjou
  2011-09-19 19:07   ` Chong Yidong
  1 sibling, 0 replies; 12+ messages in thread
From: Julien Danjou @ 2011-09-19 10:07 UTC (permalink / raw)
  To: Lars Magne Ingebrigtsen; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 389 bytes --]

On Mon, Sep 19 2011, Lars Magne Ingebrigtsen wrote:

> This would be very easy to do.  It would mean making a new C-level
> function that basically just calls getservbyname and returns the port
> number.  So nnimap would the call `open-network-stream' with
> (or (service-port-number "imaps") 993).
>
> That sounds quite nice, doesn't it?

I tend to agree.

-- 
Julien Danjou

[-- Attachment #2: Type: application/pgp-signature, Size: 835 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Service names on machines with bad service files
  2011-09-19  9:40 ` Lars Magne Ingebrigtsen
  2011-09-19 10:07   ` Julien Danjou
@ 2011-09-19 19:07   ` Chong Yidong
  2011-09-19 20:25     ` chad
  1 sibling, 1 reply; 12+ messages in thread
From: Chong Yidong @ 2011-09-19 19:07 UTC (permalink / raw)
  To: Lars Magne Ingebrigtsen; +Cc: emacs-devel

Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

> Lars Magne Ingebrigtsen <larsi@gnus.org> writes:
>
>> 2) Somehow determine that the OS doesn't know what "imaps" is, and use
>> "993" as a fallback.  I have no idea whether that's easy to do.
>
> This would be very easy to do.  It would mean making a new C-level
> function that basically just calls getservbyname and returns the port
> number.  So nnimap would the call `open-network-stream' with
> (or (service-port-number "imaps") 993).
>
> That sounds quite nice, doesn't it?

I'd rather use just 993.  Doing (or (service-port-number "imaps") 993)
doesn't really make sense.  OTOH, no one will ever change the service
names from their standard values, so the value will always be 993
anyway.



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Service names on machines with bad service files
  2011-09-19  9:30 Service names on machines with bad service files Lars Magne Ingebrigtsen
  2011-09-19  9:40 ` Lars Magne Ingebrigtsen
@ 2011-09-19 19:32 ` Andy Wingo
  2011-09-25 11:40   ` Ted Zlatanov
  2011-09-25 11:38 ` Ted Zlatanov
  2 siblings, 1 reply; 12+ messages in thread
From: Andy Wingo @ 2011-09-19 19:32 UTC (permalink / raw)
  To: emacs-devel

On Mon 19 Sep 2011 05:30, Lars Magne Ingebrigtsen <larsi@gnus.org> writes:

> (open-network-stream "hello" nil "gmail.com" "hello")
> =>
> Debugger entered--Lisp error: (error "gmail.com/hello Servname not supported for ai_socktype")

Perhaps gnulib could help here, supplying missing service definitions on
Windows systems.

Andy
-- 
http://wingolog.org/



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Service names on machines with bad service files
  2011-09-19 19:07   ` Chong Yidong
@ 2011-09-19 20:25     ` chad
  0 siblings, 0 replies; 12+ messages in thread
From: chad @ 2011-09-19 20:25 UTC (permalink / raw)
  To: Chong Yidong; +Cc: Lars Magne Ingebrigtsen, emacs-devel


On Sep 19, 2011, at 12:07 PM, Chong Yidong wrote:
> 
> I'd rather use just 993.  Doing (or (service-port-number "imaps") 993)
> doesn't really make sense.  OTOH, no one will ever change the service
> names from their standard values, so the value will always be 993
> anyway.

I've no idea if there's any need to do so anymore, but I've worked in 
systems (predating ssl) where we changed the service numbers in 
/etc/services.  I imagine that it's rare, but if anyone cares, it seems
like (defconst imaps-port 993) is cheap and easy.

*Chad





^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Service names on machines with bad service files
  2011-09-19  9:30 Service names on machines with bad service files Lars Magne Ingebrigtsen
  2011-09-19  9:40 ` Lars Magne Ingebrigtsen
  2011-09-19 19:32 ` Andy Wingo
@ 2011-09-25 11:38 ` Ted Zlatanov
  2011-09-26 17:01   ` Lars Magne Ingebrigtsen
  2 siblings, 1 reply; 12+ messages in thread
From: Ted Zlatanov @ 2011-09-25 11:38 UTC (permalink / raw)
  To: emacs-devel

On Mon, 19 Sep 2011 11:30:22 +0200 Lars Magne Ingebrigtsen <larsi@gnus.org> wrote: 

LMI> A Windows user has a problem with opening a connection using port
LMI> "imaps", which doesn't exist in that user's service file (or wherever
LMI> Windows stashes these things).

LMI> So I'm wondering whether there's any nice way to determine that that's
LMI> the situation and work around it.
...
LMI> 2) Somehow determine that the OS doesn't know what "imaps" is, and use
LMI> "993" as a fallback.  I have no idea whether that's easy to do.

I think this is the best solution: map service names to ports in an
OS-specific way.

For W32, http://support.microsoft.com/kb/832017 could be used.  It gives
several standard port assignments in tables.  That whole article could
be transformed into a "services" file at compile time or provided
dynamically.

Ted




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Service names on machines with bad service files
  2011-09-19 19:32 ` Andy Wingo
@ 2011-09-25 11:40   ` Ted Zlatanov
  0 siblings, 0 replies; 12+ messages in thread
From: Ted Zlatanov @ 2011-09-25 11:40 UTC (permalink / raw)
  To: emacs-devel

On Mon, 19 Sep 2011 15:32:31 -0400 Andy Wingo <wingo@pobox.com> wrote: 

AW> On Mon 19 Sep 2011 05:30, Lars Magne Ingebrigtsen <larsi@gnus.org> writes:
>> (open-network-stream "hello" nil "gmail.com" "hello")
>> =>
>> Debugger entered--Lisp error: (error "gmail.com/hello Servname not supported for ai_socktype")

AW> Perhaps gnulib could help here, supplying missing service definitions on
AW> Windows systems.

Since XEmacs doesn't use gnulib and Gnus supports XEmacs, that wouldn't
help the Gnus developers because they still have to support that edge
case.  It would be nice, though :) See my earlier e-mail for the W32
service-to-port mapping straight from the horse's mouth.

Ted




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Service names on machines with bad service files
  2011-09-25 11:38 ` Ted Zlatanov
@ 2011-09-26 17:01   ` Lars Magne Ingebrigtsen
  2011-09-26 19:27     ` Ted Zlatanov
  0 siblings, 1 reply; 12+ messages in thread
From: Lars Magne Ingebrigtsen @ 2011-09-26 17:01 UTC (permalink / raw)
  To: emacs-devel

Ted Zlatanov <tzz@lifelogs.com> writes:

> I think this is the best solution: map service names to ports in an
> OS-specific way.

Service names aren't really OS-specific.  :-)

> For W32, http://support.microsoft.com/kb/832017 could be used.  It gives
> several standard port assignments in tables.  That whole article could
> be transformed into a "services" file at compile time or provided
> dynamically.

I don't really think that helps much.  imaps is 993, and nothing else.

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Service names on machines with bad service files
  2011-09-26 17:01   ` Lars Magne Ingebrigtsen
@ 2011-09-26 19:27     ` Ted Zlatanov
  2011-09-26 19:33       ` Lars Magne Ingebrigtsen
  0 siblings, 1 reply; 12+ messages in thread
From: Ted Zlatanov @ 2011-09-26 19:27 UTC (permalink / raw)
  To: emacs-devel

On Mon, 26 Sep 2011 19:01:56 +0200 Lars Magne Ingebrigtsen <larsi@gnus.org> wrote: 

LMI> Ted Zlatanov <tzz@lifelogs.com> writes:
>> I think this is the best solution: map service names to ports in an
>> OS-specific way.

LMI> Service names aren't really OS-specific.  :-)

They are.  You're thinking of the "famous" ones like imaps, but there
are many unstandardized "lesser celebrities" that are only relevant in
the W32 domain for instance.

>> For W32, http://support.microsoft.com/kb/832017 could be used.  It gives
>> several standard port assignments in tables.  That whole article could
>> be transformed into a "services" file at compile time or provided
>> dynamically.

LMI> I don't really think that helps much.  imaps is 993, and nothing else.

We could hard-code just the ones we need in a global table, if you want
to limit the scope to that.  I was proposing something more adaptable
that would serve as a platform services reference.  Perhaps that's
overengineering it but I was misled by the thread subject :)

Ted




^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Service names on machines with bad service files
  2011-09-26 19:27     ` Ted Zlatanov
@ 2011-09-26 19:33       ` Lars Magne Ingebrigtsen
  2011-09-26 19:49         ` Ted Zlatanov
  0 siblings, 1 reply; 12+ messages in thread
From: Lars Magne Ingebrigtsen @ 2011-09-26 19:33 UTC (permalink / raw)
  To: emacs-devel

Ted Zlatanov <tzz@lifelogs.com> writes:

> They are.  You're thinking of the "famous" ones like imaps, but there
> are many unstandardized "lesser celebrities" that are only relevant in
> the W32 domain for instance.

Yeah, I don't care about those.  :-)

> We could hard-code just the ones we need in a global table, if you want
> to limit the scope to that.  I was proposing something more adaptable
> that would serve as a platform services reference.  Perhaps that's
> overengineering it but I was misled by the thread subject :)

I think that's overengineering.  :-)  But for Emacs 24.2 I want to
implement the `get-service-number' function (or whatever it'll be
called) as previously discussed.

-- 
(domestic pets only, the antidote for overdose, milk.)
  bloggy blog http://lars.ingebrigtsen.no/



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: Service names on machines with bad service files
  2011-09-26 19:33       ` Lars Magne Ingebrigtsen
@ 2011-09-26 19:49         ` Ted Zlatanov
  0 siblings, 0 replies; 12+ messages in thread
From: Ted Zlatanov @ 2011-09-26 19:49 UTC (permalink / raw)
  To: emacs-devel

On Mon, 26 Sep 2011 21:33:34 +0200 Lars Magne Ingebrigtsen <larsi@gnus.org> wrote: 

LMI> Ted Zlatanov <tzz@lifelogs.com> writes:
>> They are.  You're thinking of the "famous" ones like imaps, but there
>> are many unstandardized "lesser celebrities" that are only relevant in
>> the W32 domain for instance.

LMI> Yeah, I don't care about those.  :-)

>> We could hard-code just the ones we need in a global table, if you want
>> to limit the scope to that.  I was proposing something more adaptable
>> that would serve as a platform services reference.  Perhaps that's
>> overengineering it but I was misled by the thread subject :)

LMI> I think that's overengineering.  :-)  But for Emacs 24.2 I want to
LMI> implement the `get-service-number' function (or whatever it'll be
LMI> called) as previously discussed.

Sounds good to me.  Thanks in advance for doing this.

Ted




^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2011-09-26 19:49 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-19  9:30 Service names on machines with bad service files Lars Magne Ingebrigtsen
2011-09-19  9:40 ` Lars Magne Ingebrigtsen
2011-09-19 10:07   ` Julien Danjou
2011-09-19 19:07   ` Chong Yidong
2011-09-19 20:25     ` chad
2011-09-19 19:32 ` Andy Wingo
2011-09-25 11:40   ` Ted Zlatanov
2011-09-25 11:38 ` Ted Zlatanov
2011-09-26 17:01   ` Lars Magne Ingebrigtsen
2011-09-26 19:27     ` Ted Zlatanov
2011-09-26 19:33       ` Lars Magne Ingebrigtsen
2011-09-26 19:49         ` Ted Zlatanov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).