seteuid()

Установить эффективный идентификатор пользователя

Прототип:

#include <unistd.h>
int seteuid( uid_t uid );

Аргументы:

uid
The effective user ID that you want to use for the process.

Библиотека:

libc

Описание:

The seteuid() function lets the calling process set the effective user ID, based on the following:

The real and saved user IDs aren't changed.


Note: If a set-UID process sets its effective user ID to its real user ID, it can still set its effective user ID back to the saved set-UID.

The “superuser” is defined as any process with an effective user ID of 0, or an effective user ID of root.

Возвращаемое значение:

0
Успешное завершение.
-1
Возникла ошибка. Код ошибки записан в errno.

Коды ошибок:

EINVAL
The value of uid is out of range.
EPERM
The process isn't the superuser, and uid doesn't match the real user ID or the saved set-user ID.

Примеры:

/*
* This process sets its effective userid to 0 (root).
*/
#include <stdio.h>
#include <sys/types.h>
#include <unistd.h>
#include <stdlib.h>
int main( void )
{
uid_t oeuid;
oeuid = geteuid();
if ( seteuid( 0 ) == -1 )
{
perror( "seteuid" );
return (EXIT_FAILURE);
}
printf( "effective userid now 0, was %d\n", oeuid );
return (EXIT_SUCCESS);
}

Классификация:

POSIX 1003.1

Точка остановки потока
Нет
Обработчик прерываний
Нет
Обработчик сигналов
Да
В потоке
Да

Тематические ссылки:

errno, geteuid(), setegid(), setuid(), setgid()




Предыдущий раздел: Описание API системной библиотеки