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:from:subject:reply-to:to:references:message-id :date:mime-version:in-reply-to:content-type :content-transfer-encoding; q=dns; s=default; b=S3ryckfzdD/fNMT3 HZe0e+AO/1NljgtCNIdn/o6MCtbwfdmgaIvQg/oxtk/Q8SmdBouC++4O4Q27aQqH RAoQ7c5Ng+SKurJzpMcrl5Drhv/SV8Sl2CxRdwbpX5uoZVdJbcs866FdB2zzV2nj /CjaOME8zZinyHsA6h+4IgNjPjc= 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:from:subject:reply-to:to:references:message-id :date:mime-version:in-reply-to:content-type :content-transfer-encoding; s=default; bh=ZP99ALle2sBPWF+tItHk0/ RRp7w=; b=LcBWITyaqo7pmSmATgPvMIKkDO0weDJlZik5xcZi6k6DuNR6a9usEh QQWoc1CoqBL1jbEDgkii+xsYf9mks808m11x1vt4t4xO9Z72RDNl32NZzZ8HSpEj q/8I9WxvJceahbaTC88OFSc1QgH5at+H7pKvTmnFWMJm2FUPn5AR8= 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=-3.1 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 spammy=1005, HContent-Transfer-Encoding:8bit X-HELO: smtp-out-so.shaw.ca From: Brian Inglis Subject: Re: balance command complains about missing rendezvous directory Reply-To: Brian DOT Inglis AT SystematicSw DOT ab DOT ca To: cygwin AT cygwin DOT com References: Openpgp: preference=signencrypt Message-ID: Date: Fri, 14 Jun 2019 14:18:42 -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: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes 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