6 Einträge, 1 Seite |
1
2
3
4
5
6
7
#
# Check for root
#
if [ `id -u` != "0" ]; then
echo -e "You should be root to start this program"
do_exit ${ERR_no_suid}
fi
Quote\n\n...
# $REAL_USER_ID
# $UID
# $<
The real uid of this process. (Mnemonic: it's the uid you came from, if you're running setuid.) You can change both the real uid and the effective uid at the same time by using POSIX::setuid(). Since changes to $< require a system call, check $! after a change attempt to detect any possible errors.
# $EFFECTIVE_USER_ID
# $EUID
# $>
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().
...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#!/usr/bin/perl use strict; use warnings; my $id = '^uid=0'; my $testid = qx{/usr/bin/id}; if ( $testid !~ /$id/ ) { print "[-] access denied!"; exit; } else { print "[+] startin\' script"; #&foo(); }
6 Einträge, 1 Seite |