In perl language when talking about special cases of filehandling File Test= -r,-w,-x are READ,WRITE AND EXECUTE options for effective user File Test= -R,-W,-X are READ,WRITE AND EXECUTE options for real user. Where does the concept of real user and effective user imply in perl?
2 Answers
This isn't a perl concept, it's a Unix concept. It's to do with setuid processes - and in particular, permissions when operating as root.
If a process starts as you then it's real UID remains yours. But if it setuid
s to another user (doesn't have to be root) it'll have a different permission set.
The tests above allow you to differentiate between the two cases - could I as a normal user edit this file, and can I as a privileged user do so?

- 52,974
- 7
- 60
- 101
-
1Hi sobrique I am kind of getting you but can you briefly tell me about setuid as setuid is even divided into two parts further one is setuid only and another one is seteuid which states setting effective user. so what can i interpret from these two cases? – Puneet Bawa Nov 05 '15 at 12:14
As much as my experience with Perl and Ubuntu is concerned:
- Normally it is not possible to use setuid file bit with Perl scripts (see Can i setuid for perl script? for details).
- When a Perl script is started so the $< (real user id), as well as $> (the effective user id) will be set to the same user, who started the script.
- If this initial user is root (i.e. the $< and $> are both 0), so you can change the effective user id by setting the $> and you can also later change the effective user id back. If the user was not root initially so you will get an exception about permissions when trying to change the effective user.
- I didn't find any way to somehow grant the "change effective user" permission to an other user than the root.
What I wrote above applies to a standard Perl installation on Ubuntu. If you tweak it somehow, e.g. you change setuid bit on the Perl interpret (not on the script), so you can have a different $<, $> after the script is started, but normally you don't want to do that.
With Perl on Windows:
- When trying to modify $> so I get always a "not implemented" exception.

- 3,149
- 2
- 26
- 28