From owner-freebsd-current@freebsd.org Mon Nov 28 07:08:43 2016 Return-Path: Delivered-To: freebsd-current@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 54D8AC58B3A for ; Mon, 28 Nov 2016 07:08:43 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: from mail-io0-f177.google.com (mail-io0-f177.google.com [209.85.223.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 1D1A0103A for ; Mon, 28 Nov 2016 07:08:42 +0000 (UTC) (envelope-from cse.cem@gmail.com) Received: by mail-io0-f177.google.com with SMTP id c21so210115252ioj.1 for ; Sun, 27 Nov 2016 23:08:42 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:reply-to:in-reply-to:references :from:date:message-id:subject:to:cc:content-transfer-encoding; bh=th90qFeBV3RoUFRl1lrqWeM3I6OEIFcMelBuLa0M51k=; b=iZaF5+UALd89NGxfJQZw36rkDm+8kcPpGYchXWuG1iWPj9aW6kLNz8/mZIBTQ3dRrc KsR7gmTrs4p1EumHtyanJxNbMJJZjB419hG3EXQkzI7re31zQWt5eTx82ur8MNxz22Hx vJsBAvbOnUoafUPjuVytoYpaQJMpGdLKIkUnAmMt6Gx9GGk0LEJq2IoBLBbgWMB/bg3v tSF0yde9kkXhEhsGbgZTUUmIzXRqXzVQiJRX2sIM+4S9ub61nhtHdeU1zVeo+f8BZ/12 UjrT+CBoYnfI4EbVfAmSogALzlXNvkz/KPm/gi73VQ0sw8Wu/9HEKARm5l2KBUHJmZ7Z rnEQ== X-Gm-Message-State: AKaTC02Ai0zNvsrk2VH1gc67hMzSnSxbW3+bdYzJ1TgToElaJC9erDeaIyBDjn9zWP5CgQ== X-Received: by 10.36.228.204 with SMTP id o195mr17368991ith.102.1480316915968; Sun, 27 Nov 2016 23:08:35 -0800 (PST) Received: from mail-io0-f174.google.com (mail-io0-f174.google.com. [209.85.223.174]) by smtp.gmail.com with ESMTPSA id x74sm8794769ita.22.2016.11.27.23.08.35 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 27 Nov 2016 23:08:35 -0800 (PST) Received: by mail-io0-f174.google.com with SMTP id j65so215413342iof.0 for ; Sun, 27 Nov 2016 23:08:35 -0800 (PST) X-Received: by 10.107.16.170 with SMTP id 42mr16702536ioq.93.1480316915543; Sun, 27 Nov 2016 23:08:35 -0800 (PST) MIME-Version: 1.0 Reply-To: cem@freebsd.org Received: by 10.36.109.68 with HTTP; Sun, 27 Nov 2016 23:08:35 -0800 (PST) In-Reply-To: References: <5874fe09-4261-5616-9c0a-a71581c4d548@hs.ntnu.edu.tw> From: Conrad Meyer Date: Sun, 27 Nov 2016 23:08:35 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: r308432: Capsicumized `basename` make zsh prompt broken To: iblis Cc: FreeBSD Current Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Nov 2016 07:08:43 -0000 Hi Iblis, Yes, I think caph_limit_stdio will break many similar programs in similar use. I think we'll need to change that behavior. Something like this: https://reviews.freebsd.org/D8657 Best, Conrad On Sun, Nov 27, 2016 at 10:40 PM, iblis wrote: > Hi Conrad, > Thanks for your reply. > > I revert the basename.c and `< /dev/null` do the trick! > I'm also curious that will `caph_limit_stdio` break lots of program wo= rk > with some shell scripts? > > -- > Iblis Lin > > > On 11/28/2016 12:55, Conrad Meyer wrote: >> >> Hi Iblis, >> >> I see no such problem running 'basename $HOME' in a normal shell >> environment: >> >>> $ basename $HOME >>> cmeyer >> >> >> I suppose in your use, perhaps stdin is already closed? I think this >> is a limitation of caph_limit_stdio() in general. >> >> Can you try instead: >> >> function set_prompt { >> prompt=3D"$(basename $HOME < /dev/null) >" >> } >> >> And see if it resolves the issue? >> >> Thanks, >> Conrad >> >> On Sun, Nov 27, 2016 at 8:33 PM, iblis wrote: >>> >>> Hi, >>> Here is a minimal config of zsh prompt invoking `basename`: >>> ``` >>> =E2=94=94=E2=94=80[iblis@abeing]% cat /home/ib-test/.zshenv >>> >>> function set_prompt { >>> prompt=3D"$(basename $HOME) >" >>> } >>> >>> function zle-line-init zle-keymap-select { >>> set_prompt >>> zle reset-prompt >>> } >>> >>> zle -N zle-line-init >>> zle -N zle-keymap-select >>> >>> set_prompt >>> ``` >>> >>> and launching zsh will get something like this: >>> >>> ``` >>> =E2=94=94=E2=94=80[iblis@abeing]% sudo su ib-test >>> >>> ib-test >basename: capsicum: Bad file descriptor >>>> >>>> >>>> basename: capsicum: Bad file descriptor >>>> >>> ``` >>> >>> >>> To be honest, I have no idea about what casper/caspicum is. I just >>> changed >>> the `basename.c` and zsh work again. >>> >>> Index: basename.c >>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >>> --- basename.c (revision 309213) >>> +++ basename.c (working copy) >>> @@ -65,7 +65,7 @@ >>> >>> setlocale(LC_ALL, ""); >>> >>> - if (caph_limit_stdio() < 0 || (cap_enter() < 0 && errno !=3D ENOSYS)) >>> + if (cap_enter() < 0 && errno !=3D ENOSYS) >>> err(1, "capsicum"); >>> >>> aflag =3D 0; >>> >>> >>> Any idea? >>> >>> -- >>> Iblis Lin >>> _______________________________________________ >>> freebsd-current@freebsd.org mailing list >>> https://lists.freebsd.org/mailman/listinfo/freebsd-current >>> To unsubscribe, send any mail to >>> "freebsd-current-unsubscribe@freebsd.org" >> >> _______________________________________________ >> freebsd-current@freebsd.org mailing list >> https://lists.freebsd.org/mailman/listinfo/freebsd-current >> To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.or= g" >> >