|
385 | 385 | \end{slide} |
386 | 386 |
|
387 | 387 | \begin{itemize} |
388 | | -\item pro reálné UID je volání \texttt{getuid}, volání \texttt{getruid} |
389 | | -neexistuje |
390 | | -\item \texttt{getgroups}: kdy¾ \texttt{gidsz~==~0}, jen vrátí poèet |
391 | | -skupin. Kdy¾ \texttt{0 < gidsz < \#skupin}, vrátí \texttt{-1}. |
392 | | -\item v UNIXu je mnoho typù jako \verb#uid_t#, \verb#gid_t#, |
393 | | -\verb#size_t#, apod. Vesmìs jsou to celoèíselné typy, èasto je |
394 | | -najdete v \texttt{/usr/inc{}lude/sys/types.h} |
395 | | -\item Solaris má pøíkaz \texttt{pcred}, který jednodu¹e zobrazí informace o |
396 | | -identifikaci procesu: |
| 388 | +\item The \texttt{getuid} returns real UID, there is nothing like |
| 389 | +\texttt{getruid}. |
| 390 | +\item \texttt{getgroups}: when \texttt{gidsz~==~0}, it returns the number of |
| 391 | +groups. When \texttt{0 < gidsz < \#skupin}, it returns \texttt{-1}. |
| 392 | +\item In UNIXu there are many data types such as \verb#uid_t#, \verb#gid_t#, |
| 393 | +\verb#size_t#, etc. Generally these are integer types, you can often find them |
| 394 | +in the \texttt{/usr/inc{}lude/sys/types.h} header file. |
| 395 | +\item Solaris has the \texttt{pcred} command, that will print process |
| 396 | +idenfitication information in simple form: |
397 | 397 | \begin{verbatim} |
398 | 398 | $ pcred 5464 |
399 | 399 | 5464: e/r/suid=1993 e/r/sgid=110 |
|
425 | 425 | \end{slide} |
426 | 426 |
|
427 | 427 | \begin{itemize} |
428 | | -\item o nastavení UID pro proces s EUID 0 viz také poznámky na stranì |
| 428 | +\item W.r.t. setting UID for a process with EUID 0 see also the notes on page |
429 | 429 | \pageref{ROOT_SETUID}. |
430 | | -\item co vý¹e uvedené tedy znamená: proces s efektivními právy superu¾ivatele |
431 | | -mù¾e libovolnì mìnit identitu. Ostatní procesory mohou pouze støídat svá |
432 | | -reálná a efektivní práva. |
433 | | -\item program \emph{login} vyu¾ívá volání \texttt{setuid} |
434 | | -\item pokud chce process s UID~==~0 zmìnit svou identitu, musí |
435 | | -nejprve volat \texttt{setgid} a \texttt{setgroups}. Teprve pak |
436 | | -lze zavolat \texttt{setuid}. Pøi opaèném poøadí volání by proces |
437 | | -po provedení \texttt{setuid} u¾ nemìl práva na \texttt{setgid} a |
438 | | -\texttt{setgroups}. |
439 | | -\item \texttt{setgroups} není uvedeno v UNIX~98 ani UNIX~03. |
440 | | -\item RUID/EUID jsou ulo¾ené v záznamu tabulky procesù pro pøíslu¹ný proces a |
441 | | -zároveò v tzv. \emph{u-area} (viz napøíklad [Bach]). EUID v tabulce procesù se |
442 | | -nazývá ji¾ zmínìné uschované UID, neboli \emph{saved UID}. Jak ji¾ bylo |
443 | | -øeèeno, uschované UID se pou¾ívá pro kontrolu, kdy¾ se proces chce vrátit k |
444 | | -EUID, se kterým byl spu¹tìn (po té, co doèasnì nastavil své EUID na UID |
445 | | -u¾ivatele, který proces spustil, tj. na RUID). |
446 | | -\item pokud tedy jako root vytvoøíte SUID program a v nìm zavoláte |
447 | | -\texttt{setuid} pro jakéholi UID mimo 0, ji¾ se v programu k EUID==0 nemù¾ete |
448 | | -vrátit (je to logické -- pøedstavte si situaci, kdy se u¾ivatel loguje do |
449 | | -systému). V tom pøípadì byste museli pou¾ít volání \texttt{seteuid}, které |
450 | | -nastavuje pouze EUID. |
451 | | -\item pøíklad: \example{setuid/screate-file.c} |
| 430 | +\item To recap the above: a process with effective rights of superuser can |
| 431 | +arbitrarily change its identity. The rest can only switch between its read and |
| 432 | +effective IDs. |
| 433 | +\item The \emph{login} program uses the \texttt{setuid} syscall. |
| 434 | +\item If a process with UID~==~0 wants to change its identity, it has to call |
| 435 | +\texttt{setgid} first and then \texttt{setgroups}. Only after that it can call |
| 436 | +\texttt{setuid}. Any other ordering would mean that the process would lack the |
| 437 | +rights to perform the opearation in question, e.g. once \texttt{setuid} returns |
| 438 | +it would not have the rights to perform \texttt{setgid} and \texttt{setgroups}. |
| 439 | +\item \texttt{setgroups} is not part of UNIX~98 or UNIX~03. |
| 440 | +\item RUID/EUID are saved in in kernel process structure and also in the so |
| 441 | +called \emph{u-area} (see e.g. [Bach]). |
| 442 | +\item If a root SUID program calls \texttt{setuid} for UID other than 0, it can |
| 443 | +no longer return to EUID==0 (this makes sense, imagine a user logging into the |
| 444 | +system). For different behavior \texttt{seteuid} (that sets just EUID) would |
| 445 | +have to be used. |
| 446 | +\item Example: \example{setuid/screate-file.c} |
452 | 447 | \end{itemize} |
453 | 448 |
|
454 | 449 | \pdfbookmark[1]{file system}{filesys} |
|
0 commit comments