.\" -*- coding: UTF-8 -*- .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992 .\" .\" %%%LICENSE_START(VERBATIM) .\" Permission is granted to make and distribute verbatim copies of this .\" manual provided the copyright notice and this permission notice are .\" preserved on all copies. .\" .\" Permission is granted to copy and distribute modified versions of this .\" manual under the conditions for verbatim copying, provided that the .\" entire resulting derived work is distributed under the terms of a .\" permission notice identical to this one. .\" .\" Since the Linux kernel and libraries are constantly changing, this .\" manual page may be incorrect or out-of-date. The author(s) assume no .\" responsibility for errors or omissions, or for damages resulting from .\" the use of the information contained herein. The author(s) may not .\" have taken the same level of care in the production of this manual, .\" which is licensed free of charge, as they might when working .\" professionally. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" %%%LICENSE_END .\" .\" Modified by Michael Haardt .\" Modified 1993-07-21 by Rik Faith .\" Modified 1994-08-21 by Michael Chastain .\" Modified 1996-06-13 by aeb .\" Modified 1996-11-06 by Eric S. Raymond .\" Modified 1997-08-21 by Joseph S. Myers .\" Modified 2004-06-23 by Michael Kerrisk .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH CHROOT 2 "21 grudnia 2020 r." Linux "Podręcznik programisty Linuksa" .SH NAZWA chroot \- zmiana katalogu głównego .SH SKŁADNIA \fB#include \fP .PP \fBint chroot(const char *\fP\fIpath\fP\fB);\fP .PP .RS -4 Wymagane ustawienia makr biblioteki glibc (patrz \fBfeature_test_macros\fP(7)): .RE .PP \fBchroot\fP(): .ad l .RS 4 .PD 0 .TP 4 Od glibc 2.2.2: .nf _XOPEN_SOURCE && ! (_POSIX_C_SOURCE\ >=\ 200112L) || /* Od glibc 2.20: */ _DEFAULT_SOURCE || /* Wersje Glibc <= 2.19: */ _BSD_SOURCE .fi .TP 4 Przed glibc 2.2.2: brak .PD .RE .ad b .SH OPIS \fBchroot\fP() changes the root directory of the calling process to that specified in \fIpath\fP. This directory will be used for pathnames beginning with \fI/\fP. The root directory is inherited by all children of the calling process. .PP Only a privileged process (Linux: one with the \fBCAP_SYS_CHROOT\fP capability in its user namespace) may call \fBchroot\fP(). .PP This call changes an ingredient in the pathname resolution process and does nothing else. In particular, it is not intended to be used for any kind of security purpose, neither to fully sandbox a process nor to restrict filesystem system calls. In the past, \fBchroot\fP() has been used by daemons to restrict themselves prior to passing paths supplied by untrusted users to system calls such as \fBopen\fP(2). However, if a folder is moved out of the chroot directory, an attacker can exploit that to get out of the chroot directory as well. The easiest way to do that is to \fBchdir\fP(2) to the to\-be\-moved directory, wait for it to be moved out, then open a path like \&../../../etc/passwd. .PP .\" This is how the "slightly trickier variation" works: .\" https://github.com/QubesOS/qubes-secpack/blob/master/QSBs/qsb-014-2015.txt#L142 A slightly trickier variation also works under some circumstances if \fBchdir\fP(2) is not permitted. If a daemon allows a "chroot directory" to be specified, that usually means that if you want to prevent remote users from accessing files outside the chroot directory, you must ensure that folders are never moved out of it. .PP Funkcja ta nie zmienia bieżącego katalogu roboczego, więc `.' może znajdować się poza drzewem zakorzenionym w `/'. W szczególności, superużytkownik może uciec `uwięzienia w chroot' wykonując .PP .in +4n .EX mkdir foo; chroot foo; cd .. .EE .in .PP Funkcja ta nie zamyka otwartych deskryptorów plików, więc takie deskryptory plików mogą zezwalać na dostęp poza nowym drzewem zakorzenionym w `/'. .SH "WARTOŚĆ ZWRACANA" Po pomyślnym zakończeniu zwracane jest zero. Po błędzie zwracane jest \-1 i odpowiednio ustawiane jest \fIerrno\fP. .SH BŁĘDY Dla niektórych systemów plików mogą być zwracane inne błędy niż opisane poniżej. Najogólniejsze błędy to: .TP \fBEACCES\fP .\" Also search permission is required on the final component, .\" maybe just to guarantee that it is a directory? Brak praw do przeszukiwania dla składowej ścieżki. (Patrz także \fBpath_resolution\fP(7)). .TP \fBEFAULT\fP \fIpath\fP wskazuje poza dostępną dla użytkownika przestrzeń adresową. .TP \fBEIO\fP Wystąpił błąd wejścia/wyjścia. .TP \fBELOOP\fP Podczas rozwiązywania \fIpath\fP napotkano zbyt wiele dowiązań symbolicznych. .TP \fBENAMETOOLONG\fP \fIpath\fP jest zbyt długie. .TP \fBENOENT\fP Plik nie istnieje. .TP \fBENOMEM\fP Brak pamięci jądra. .TP \fBENOTDIR\fP Składowa ścieżki \fIpath\fP nie jest katalogiem. .TP \fBEPERM\fP The caller has insufficient privilege. .SH "ZGODNE Z" .\" SVr4 documents additional EINTR, ENOLINK and EMULTIHOP error conditions. .\" X/OPEN does not document EIO, ENOMEM or EFAULT error conditions. SVr4, 4.4BSD, SUSv2 (marked LEGACY). This function is not part of POSIX.1\-2001. .SH UWAGI A child process created via \fBfork\fP(2) inherits its parent's root directory. The root directory is left unchanged by \fBexecve\fP(2). .PP The magic symbolic link, \fI/proc/[pid]/root\fP, can be used to discover a process's root directory; see \fBproc\fP(5) for details. .PP FreeBSD ma silniejszą funkcję systemową \fIjail\fP(). .SH "ZOBACZ TAKŻE" \fBchroot\fP(1), \fBchdir\fP(2), \fBpivot_root\fP(2), \fBpath_resolution\fP(7), \fBswitch_root\fP(8) .SH "O STRONIE" Angielska wersja tej strony pochodzi z wydania 5.10 projektu Linux \fIman\-pages\fP. Opis projektu, informacje dotyczące zgłaszania błędów oraz najnowszą wersję oryginału można znaleźć pod adresem \%https://www.kernel.org/doc/man\-pages/. .SH TŁUMACZENIE Autorami polskiego tłumaczenia niniejszej strony podręcznika są: Przemek Borys , Robert Luberda i Michał Kułach . Niniejsze tłumaczenie jest wolną dokumentacją. Bliższe informacje o warunkach licencji można uzyskać zapoznając się z .UR https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License w wersji 3 .UE lub nowszej. Nie przyjmuje się ŻADNEJ ODPOWIEDZIALNOŚCI. Błędy w tłumaczeniu strony podręcznika prosimy zgłaszać na adres .MT manpages-pl-list@lists.sourceforge.net .ME .