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:mime-version:references:in-reply-to:from:date :message-id:subject:to:content-type:content-transfer-encoding; q=dns; s=default; b=ZXlTrl4hcjuFfyGkBeySv9FJmW80lslQU6V7TlXVrnd eZJlCIW+hDK/EAt2j40OAvYNaBgl3vL4tP/2cnm6ExwNnicLcnKRVFq7r9MCrvx/ thcsEU36YyXZy7daMeh8hwvUcJIOBqLrhsYpuY9e2QZliAVcgR3VexZQxjC7+YOE = 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:mime-version:references:in-reply-to:from:date :message-id:subject:to:content-type:content-transfer-encoding; s=default; bh=Vfh7WYV2iGsCsPhkyl2cKnBAJ+g=; b=a9/AeRtjdNjwZA2FI fpJzuyK1TIaQifM8cAqxiOu7W5v3Xh162HePSrXSpp5Tmpic63ukFyzYgQZyTAaU LPBdrjLVgxKQ7tNd25HIkVcbyBuduwnse1hDdkpLHwvcutLBKUGcUHghKjolnCrM R8oZ4sW0DK1xXECypkqHekniZg= Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , 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=0.0 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy=alle, sk:unsubsc, cygwincom, UD:cygwin.com X-HELO: mail-io1-f53.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-transfer-encoding; bh=1fEsR8EAJERhRqE6epdLzde6xAaueYOpuAw0zLqhb98=; b=clg0mYfucLnPUmmj4zVWG1YEdtiXvuPw5k3dUbfzjXxb54Mk4m/vBZCFw7Mt6/d3fF UUGUgpOE3L0wWGDpP52YZOIxcioKWflVT78uz8zj3uwTyYChsfZQIBYLYn7tPCjliy54 nzEic0vV9Ze3AOOlmZBQW+FTLcFbirr13PddNcvBlGYNF8kgCq1x9SFl+uXZ2KfKGpwl zNuAGjRLV3XB0pOwag3inSy0Xa8HUTLU8RpwTo/Ek7mwYfs6Yxh0IMF1NgpykxP7cCUw lYqsxXa324gZKy89uJhseyzZuvVGZtnZsMiNqH8rYDrKG6eoPVHLbZPusS07d2Tex99X QYMg== MIME-Version: 1.0 References: In-Reply-To: From: Marco Coletti Date: Mon, 17 Jun 2019 16:29:10 +0200 Message-ID: Subject: Re: balance command complains about missing rendezvous directory To: Brian DOT Inglis AT systematicsw DOT ab DOT ca, cygwin AT cygwin DOT com Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id x5HEUQix003643 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 ======== 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)) { > > -- > 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 > -- 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