delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2019/06/17/12:00:56

X-Recipient: archive-cygwin AT delorie DOT com
DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:reply-to:subject:references:to:from:message-id
:date:mime-version:in-reply-to:content-type
:content-transfer-encoding; q=dns; s=default; b=FLWyc3e1kYEhfCol
tHbIsiL9y8EOO53CYpCHgxEv9hXZxSOaN/DYVkRnv0uFOK9oHpHNYDuQEl4BIeFf
bV6QFUsq91C7PH5LZhw1ogC+tEuEGZSjMl2/eiL5Dn0VjsKvSmsHhj3A3jJsgAzF
RsK+oD+XcD4IE762SlhPTsqiRE0=
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id
:list-unsubscribe:list-subscribe:list-archive:list-post
:list-help:sender:reply-to:subject:references:to:from:message-id
:date:mime-version:in-reply-to:content-type
:content-transfer-encoding; s=default; bh=9mmTkC/haat0AwfbeIduyb
OGAic=; b=iABnDypqk2wWAhgGhu4g3K0giHqC8LPQNVHI6Nel9DiWMyNg8FcLU4
8bEVmdUixBwcBw+q2kNESYNA1+3D+ziMg4efWUtlxzMavpwOICewq51Psj0HCebc
ZZenVI075C8bZvAS5FIMKDj4nqV+rmdrfGOqCJWwrx9xVxui1pVps=
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
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
Authentication-Results: sourceware.org; auth=none
X-Spam-SWARE-Status: No, score=-3.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 spammy=Reader, H*F:D*ca
X-HELO: smtp-out-so.shaw.ca
Reply-To: Brian DOT Inglis AT SystematicSw DOT ab DOT ca
Subject: Re: balance command complains about missing rendezvous directory
References: <CAJwCUQOCtFOO6PbM0D7oCi2ErsXUnnKBUHkej50dAzFu_wj6Lw AT mail DOT gmail DOT com> <db5c5634-1faf-47da-0902-90595a4cacde AT SystematicSw DOT ab DOT ca> <CAJwCUQNuhxfrC50Vn0gCoea6f6vWaHinp=P+81dOOsfSkjdWsw AT mail DOT gmail DOT com>
To: "cygwin AT cygwin DOT com" <cygwin AT cygwin DOT com>
From: Brian Inglis <Brian DOT Inglis AT SystematicSw DOT ab DOT ca>
Openpgp: preference=signencrypt
Message-ID: <dfe26974-0eed-83e1-b6d0-dd1ef2573903@SystematicSw.ab.ca>
Date: Mon, 17 Jun 2019 09:59:24 -0600
User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.7.1
MIME-Version: 1.0
In-Reply-To: <CAJwCUQNuhxfrC50Vn0gCoea6f6vWaHinp=P+81dOOsfSkjdWsw@mail.gmail.com>
X-IsSubscribed: yes

On 2019-06-17 08:29, Marco Coletti wrote:
> Il giorno ven 14 giu 2019 alle ore 22:18 Brian Inglis ha scritto:
>> On 2019-06-14 09:25, Marco Coletti wrote:
>>> Windows 10 x64
>>> Just installed Cygwin and balance package.
>>> =======
>>> $ balance -d -f -b 127.0.0.1 1080 127.0.0.1:1090
>>> source port 1080
>>> ERROR: rendezvous directory not available and/or creatable
>>>        please create /var/run/balance/ with mode 01777 like this:
>>>        # mkdir -m 01777 /var/run/balance/
>>> argv[0]=/usr/bin/balance
>>> bindhost=127.0.0.1
>>> $ ls -ld /var/run/balance
>>> drwxrwxrwt+ 1 SO000419 Domain Users 0 Jun 14 16:48 /var/run/balance
>>> $ ls -l /var/run/balance/.keep-balance
>>> -rw-r--r-- 1 SO000419 Domain Users 0 Apr 28  2013 /var/run/balance/.keep-balance
>>> ========
>>> The same balance command works on Ubuntu 16.04.6.
>>
>> The error is produced by the following code in balance.c:
>>
>>   stat(SHMDIR, &buffer);
>>   if (!S_ISDIR(buffer.st_mode)) {
>>     mode_t old = umask(0);
>>     if (mkdir(SHMDIR, 01777) < 0) {
>>       if(errno != EEXIST) {
>>         fprintf(stderr, "ERROR: rendezvous directory not available and/or
>> creatable\n");
>>         fprintf(stderr, "       please create %s with mode 01777 like this: \n",
>> SHMDIR);
>>         fprintf(stderr, "       # mkdir -m 01777 %s\n", SHMDIR);
>>         umask(old);
>>         exit(EX_UNAVAILABLE);
>>       }
>>     }
>>     umask(old);
>>   }
>>
>> where balance.h defines:
>> #define SHMDIR          "/var/run/balance/"
>>
>> I ran mkdir under strace on a similar directory and got the expected errno:
>> $ ls -dglo /var/run/blkid
>> drwxrwxrwt+ 1 0 Mar 23 05:30 /var/run/blkid
>> $ strace -o mkdir.strace /bin/mkdir -m01777 /var/run/blkid/
>> /usr/bin/mkdir: cannot create directory ‘/var/run/blkid/’: File exists
>> $ grep -m1 ', errno' mkdir.strace
>> 58   71709 [main] mkdir 5564 mkdir: -1 = mkdir(/var/run/blkid, 1005), errno 17
>> $ fgrep -w EEXIST /usr/include/sys/errno.h
>> #define EEXIST 17       /* File exists */
>>
>> You could run balance under strace to see the errno reported:
>> $ strace -o balance.strace balance -d -f -b 127.0.0.1 1080 127.0.0.1:1090
>> and scan balance.strace log for the mkdir call and errno value as above, and
>> what happens after.
>>
>> If the strace output does not show enough info, you may have to install the
>> balance-debuginfo package to be able to run balance under gdb, to see the mkdir
>> errno value returned, and what happens after.
>>
>> The quoted code is not very robust, as buffer is on the stack so starts with
>> random bits, and the stat result is not checked to see if it succeeds, before
>> checking the mode, which may be unset; it assumes static zero initialization,
>> failing the mode check if stat fails; it would be safer rewritten as:
>>
>>   if (stat(SHMDIR, &buffer) < 0 ||
>>       !S_ISDIR(buffer.st_mode)) {
> I found a stray version of balance.exe outside of the cygwin direcotry tree.
> Now the problem is this:
> =======
> $ /usr/sbin/balance -d -f -b 127.0.0.1 1080 127.0.0.1:1090
> argv[0]=/usr/sbin/balance
> bindhost=127.0.0.1
> source port 1080
> file /var/run/balance/balance.1080.127.0.0.1 already exists
> using AF_UNSPEC
> shmget: Function not implemented
> $ cygcheck.exe /usr/sbin/balance
> C:\cygwin64\usr\sbin\balance.exe
>   C:\cygwin64\bin\cygwin1.dll
>     C:\windows\system32\KERNEL32.dll
>       C:\windows\system32\ntdll.dll
>       C:\windows\system32\KERNELBASE.dll

API docs has a link to Implementation Notes:
https://cygwin.com/cygwin-api/std-notes.html

"The XSI IPC functions semctl, semget, semop, shmat, shmctl, shmdt, shmget,
msgctl, msgget, msgrcv and msgsnd are only available when cygserver is running."

and for cygserver, you may need to tweak SHM configuration parameters in
/etc/cygserver.conf, and ensure it is started at system startup as a service by
using cygrunsrv.

-- 
Take care. Thanks, Brian Inglis, Calgary, Alberta, Canada

This email may be disturbing to some readers as it contains
too much technical detail. Reader discretion is advised.

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

- Raw text -


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