What to do in Perl in this case?

I am confused by what the second line in this piece of code does. $ runas should be evaluated for the user I think. What does $ <do? This is contained in a CGI script.

my $runAS = (getpwnam("username"))[2]; $runAS = $< if ($runAS == 0); 
+4
source share
3 answers

$< is a special variable in perl:

The real uid of this process. You can change both the real uid and the effective uid at the same time using POSIX :: setuid (). since changing to $ <a system call is required, check $! after attempting a change to detect possible errors.

+12
source

from http://perldoc.perl.org/perlvar.html

 $< 

The real uid of this process. You can change both the real uid and the effective uid at the same time using POSIX :: setuid (). Since changes to $ <require a system call, check $! after trying to change, detect possible errors.

Mnemonics: this is your uid from which you came if you use setuid.

+6
source

On the perlvar man page:

$ <The real uid of this process.

So $< returns a real, numeric user id. This is not the username of the user, but the number assigned by the system administrator. For example, if your username was aglassman and mine, thb , on the same system, then your UID may be 1005 and mine, 1006, depending on which of our accounts sysadmin was created. On a Linux platform, see the /etc/passwd for your system UIDs.

+1
source

Source: https://habr.com/ru/post/1416665/


All Articles