From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ot1-x330.google.com (mail-ot1-x330.google.com [IPv6:2607:f8b0:4864:20::330]) by sourceware.org (Postfix) with ESMTPS id D9424386103A for ; Sun, 14 Feb 2021 11:56:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org D9424386103A Received: by mail-ot1-x330.google.com with SMTP id d7so3623547otq.6 for ; Sun, 14 Feb 2021 03:56:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=CpFSL9N/bZgf6Dr+iqG350Wm7H5TWwJ2EC3oPZHzdes=; b=ehaa97Mt/RmZKkCFWXKhsO/8LRH//wOvYHE2xl9IQoBkngo67MhDPlsGcZ5NXUmjhj +ksKBAnhUd/lkRiPqeUWvHxFaQLZCPXwdjTbib/4Sp8BfoSc+WKptnazBbCDz1jZEvkI 0NT8+ixUqPJZzr0NszgI4FpYRwHssihOqsbeaVTCWrFhepFaNGhewH8IsfQNJ6Bss0t/ up3g8IF8G7vlRMjYQc8vsZwbjf/zGTuvnTjCqAKujy+639ZWDV2u6BW27c/RhblYWQaF r9lzcXCVa8E+Pei3Bw9ufTrIwfLosfvMKr6ngUNb21T/GEzZwoY8m81jYMQO3WYpnmVW fUXQ== X-Gm-Message-State: AOAM533V/Gsk9248RdxXYgtnX+f3rgn3XOvnUnWJ/fq3lo4HJuVF9JJi olkrRBwmRtlVunUB/rNOP9Rm1yOM5l4yx6Ib/vMeN3Z8XUE= X-Google-Smtp-Source: ABdhPJyxfj6em+Z1zoG2788Gt4sGfoSw6nDIltZutoso9BX5+29LwKmDxSdh0DCYdnWNyKRregSxtBBf66t5aCk3WMM= X-Received: by 2002:a9d:12f3:: with SMTP id g106mr7774803otg.29.1613303795208; Sun, 14 Feb 2021 03:56:35 -0800 (PST) MIME-Version: 1.0 From: David Macek Date: Sun, 14 Feb 2021 12:56:22 +0100 Message-ID: Subject: Root directory being a junction fools realpath() To: cygwin-developers@cygwin.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-5.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: cygwin-developers@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component developers mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Feb 2021 11:56:38 -0000 Greetings. I think I found a way to fool Cygwin into misplacing its root directory. Given recent Cygwin with GCC and a simple test program: ``` #include #include #include int main() { char real[PATH_MAX]; realpath("/", real); printf("/ -> %s\n", real); return 0; } ``` ... compiled with: $ gcc -D_DEFAULT_SOURCE -o new.exe -Wall -Wextra -std=c11 new.c ... and my set-up with a junction (`mklink /j link target`) realpath() result is dependent on which path I use to invoke the Cygwin root process: > dir C:\ | findstr cygwin64 10. 02. 2021 12:13 cygwin64 > dir D:\ | findstr cygwin64 14. 02. 2021 12:19 cygwin64 [C:\cygwin64] > C:\cygwin64\bin\bash -lc /cygdrive/w/new / -> / > D:\cygwin64\bin\bash -lc /cygdrive/w/new / -> /cygdrive/c/cygwin64 It seems the current working directory doesn't matter at all, same as the directory where the test program resides. Regular substs don't seem to have the same effect. I can do more tests if requested. I assume this is not intended behavior, because the root should always be the root for Cygwin processes, no matter how they're invoked. If possible ping me on IRC if anything because I don't check my mail too often. -- David Macek