This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: balance command complains about missing rendezvous directory


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]