GNOME-GNORBA

 view release on metacpan or  search on metacpan

GNORBA.pm  view on Meta::CPAN

use Fcntl qw(LOCK_EX LOCK_UN O_CREAT O_EXCL O_WRONLY O_RDONLY);

my $COOKIE_LENGTH = 63;

sub get_cookie_reliably {
    my $setme = shift;

    # We assume that if we could get this far, then /tmp/orit-$username
    # is already secured (because of CORBA_ORB_init)
    
    my $pwname = getpwuid($<);
#    my $name = "/tmp/orbit-$pwname/cookie";
    my $name = "/tmp/orbit-cookie";
    
    if (defined $setme) {
	if (!sysopen COOKIEFILE, $name, O_CREAT | O_WRONLY, 0600) {
	    warn "GNOME::GNORBA: Could not create cookie file: $!\n";
	    return undef;
	}
	
	flock (COOKIEFILE, LOCK_EX);



( run in 0.306 second using v1.01-cache-2.11-cpan-8d75d55dd25 )