- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Perl Question
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-24-2008 01:10 AM
тАО09-24-2008 01:10 AM
Perl Question
1) $)=(getgrnam('vsm'))[2];
2) $>=(getpwnam('postgres'))[2];
in my application.
Can anyone help me understand these two statements
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-24-2008 01:57 AM
тАО09-24-2008 01:57 AM
Re: Perl Question
$ man perlvar
:
$) The effective gid of this process. If you are on a machine
that supports membership in multiple groups simultaneously,
gives a space separated list of groups you are in. The first
number is the one returned by getegid (), and the subsequent
ones by getgroups (), one of which may be the same as the first
number.
Similarly, a value assigned to $) must also be a space-
separated list of numbers. The first number sets the effective
gid, and the rest (if any) are passed to setgroups (). To get
the effect of an empty list for setgroups (), just repeat the
new effective gid; that is, to force an effective gid of 5 and
an effectively empty setgroups () list, say " $) = "5 5" ".
You can change both the effective gid and the real gid at the
same time by using POSIX::setgid () (use only a single numeric
argument). Changes to $) require a check to $! to detect any
possible errors after an attempted change.
(Mnemonic: parentheses are used to group things. The effective
gid is the group that's right for you, if you're running
setgid.)
$<, $>, $( and $) can be set only on machines that support the
corresponding set[re][ug]id() routine. $( and $) can be
swapped only on machines supporting setregid ().
:
$> The effective uid of this process. Example:
$< = $>; # set real to effective uid
($<,$>) = ($>,$<); # swap real and effective uid
You can change both the effective uid and the real uid at the
same time by using POSIX::setuid (). Changes to $> require a
check to $! to detect any possible errors after an attempted
change.
(Mnemonic: it's the uid you went to, if you're running setuid.)
$< and $> can be swapped only on machines supporting
setreuid ().
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-24-2008 03:14 AM
тАО09-24-2008 03:14 AM
Re: Perl Question
as Merijn already wrote,
the only need to assign to these Perl special variables was if you wanted to drop privileges in an e.g. forked off child process.
Your assignments would slice off the 2nd element of the lists returned from getgrnam() for a group 'vsm' and getpwnam() for a user 'postgres', which as you can find out by "perldoc -f getpwent" should return the gid and the uid respectively.
Besides, the slicing looks redundant anyway because getgrnam() would return the gid, and getpwnam() the uid if both were used in scalar context, as in your example.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-25-2008 01:27 AM
тАО09-25-2008 01:27 AM
Re: Perl Question
Thanks for that detailed information but I wanted to know the use of these statements in short I dont much understand about effective uid setreid and all .
Can you simply tell what are these statements meant for
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-25-2008 01:30 AM
тАО09-25-2008 01:30 AM