Qual é o uso de set-user-ID de um arquivo de programa?

0

De APUE

When we execute a program file, the effective user ID of the process is usually the real user ID. However, we can also set the set-user-ID bit in the file’s mode word (st_mode) that says, ‘‘When this file is executed, set the effective user ID of the process to be the owner of the file (st_uid).’’

For example, if the owner of the file is the superuser and if the file’s set-user-ID bit is set, then while that program file is running as a process, it has superuser privileges. This happens regardless of the real user ID of the process that executes the file. As an example, the UNIX System program that allows anyone to change his or her password, passwd(1), is a set-user-ID program. This is required so that the program can write the new password to the password file, typically either /etc/passwd or /etc/shadow, files that should be writable only by the superuser. Because a process that is running set-user-ID to some other user usually assumes extra permissions, it must be written carefully.

Suponha que o bit set-user-ID em um arquivo de programa esteja configurado.

Quando a alteração do ID de usuário efetivo do processo para ser o proprietário do arquivo acontecer, antes ou após o kernel decide que o processo pode executar o arquivo por meio do teste de acesso a arquivos?

  • Se "antes", como o ID do usuário efetivo do processo é alterado para ser o proprietário do arquivo primeiro, o kernel não decide sempre que o processo pode executar o arquivo por meio do teste de acesso a arquivos? / p>

  • Se "after", como o kernel decide que o processo pode executar o arquivo por meio do teste de acesso a arquivos, o processo deve ter o ID efetivo correspondente ao proprietário do arquivo e o arquivo também tem o bit de permissão definido. Então, por que há a necessidade de ainda alterar o ID do usuário efetivo do processo para ser o proprietário do arquivo?

Obrigado.

    
por Tim 25.04.2018 / 22:19

0 respostas