seteuid
The process.seteuid()
method sets the effective user identity of the process. (See seteuid(2)
.) The id
can be passed as either a numeric ID or a username string. If a username is specified, the method blocks while resolving the associated numeric ID.
import process from 'node:process';
if (process.geteuid && process.seteuid) {
console.log(`Current uid: ${process.geteuid()}`);
try {
process.seteuid(501);
console.log(`New uid: ${process.geteuid()}`);
} catch (err) {
console.log(`Failed to set uid: ${err}`);
}
}
Content copied to clipboard
This function is only available on POSIX platforms (i.e. not Windows or Android). This feature is not available in Worker
threads.
Since
v2.0.0
Parameters
id
A user name or ID