From owner-freebsd-hackers@freebsd.org Sun Sep 27 18:29:59 2020 Return-Path: Delivered-To: freebsd-hackers@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 7652E423D1B for ; Sun, 27 Sep 2020 18:29:59 +0000 (UTC) (envelope-from yuri@rawbw.com) Received: from shell1.rawbw.com (shell1.rawbw.com [198.144.192.42]) by mx1.freebsd.org (Postfix) with ESMTP id 4BzvMV2cnKz44l5 for ; Sun, 27 Sep 2020 18:29:54 +0000 (UTC) (envelope-from yuri@rawbw.com) Received: from yv.noip.me (c-73-189-35-76.hsd1.ca.comcast.net [73.189.35.76]) (authenticated bits=0) by shell1.rawbw.com (8.15.1/8.15.1) with ESMTPSA id 08RITleV012907 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NO) for ; Sun, 27 Sep 2020 11:29:48 -0700 (PDT) (envelope-from yuri@rawbw.com) X-Authentication-Warning: shell1.rawbw.com: Host c-73-189-35-76.hsd1.ca.comcast.net [73.189.35.76] claimed to be yv.noip.me To: Freebsd hackers list From: Yuri Subject: Is it possible to exit the chroot(2) environment? Message-ID: Date: Sun, 27 Sep 2020 11:29:46 -0700 User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 Content-Language: en-US X-Rspamd-Queue-Id: 4BzvMV2cnKz44l5 X-Spamd-Bar: - Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=pass (mx1.freebsd.org: domain of yuri@rawbw.com designates 198.144.192.42 as permitted sender) smtp.mailfrom=yuri@rawbw.com X-Spamd-Result: default: False [-1.39 / 15.00]; SUBJECT_ENDS_QUESTION(1.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FREEFALL_USER(0.00)[yuri]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MID_RHS_MATCH_FROM(0.00)[]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; HAS_XAW(0.00)[]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; RCPT_COUNT_ONE(0.00)[1]; NEURAL_HAM_LONG(-0.97)[-0.966]; ARC_NA(0.00)[]; TO_DN_ALL(0.00)[]; NEURAL_HAM_SHORT(-0.24)[-0.235]; DMARC_NA(0.00)[rawbw.com]; R_SPF_ALLOW(-0.20)[+ip4:198.144.192.32/27]; NEURAL_HAM_MEDIUM(-0.99)[-0.991]; RCVD_NO_TLS_LAST(0.10)[]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; MIME_TRACE(0.00)[0:+,1:+,2:~]; RCVD_COUNT_TWO(0.00)[2]; ASN(0.00)[asn:7961, ipnet:198.144.192.0/19, country:US]; MAILMAN_DEST(0.00)[freebsd-hackers]; RECEIVED_SPAMHAUS_PBL(0.00)[73.189.35.76:received] Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Content-Filtered-By: Mailman/MimeDel 2.1.33 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Sep 2020 18:29:59 -0000 This line https://github.com/rpm-software-management/rpm/blob/master/lib/rpmchroot.c#L155 calls chroot(".") in order to exit from the chroot environment. It apparently succeeds on Linux (this is rpm), but it fails on FreeBSD with "Operation not permitted", while executed under sudo. The chroot(2) man page doesn't mention anything about exiting the chroot environment. Does chroot(2) behave differently on Linux and FreeBSD, and chroot(".") is a valid way to exit on Linux and not on FreeBSD? Or what is going on here? I wish somebody familiar with chroot add this information into the chroot(2) man page. Thank you, Yuri