Net-MitDK

 view release on metacpan or  search on metacpan

lib/Net/MitDK.pm  view on Meta::CPAN


	return (undef, "$profile is readonly") if $self->readonly;

	my $home = $self->homepath;
	unless ( -d $home ) {
		mkdir $home or return (undef, "Cannot create $home: $!");
		return (undef, "cannot chmod 0750 $home:$!") unless chmod 0750, $home;
		if ( $^O !~ /win32/i) {
			my (undef,undef,$gid) = getgrnam('nobody');
			return (undef, "no group `nobody`") unless defined $gid;
			return (undef, "cannot chown user:nobody $home:$!") unless chown $>, $gid, $home;
		}
	}

	my $json;
	my $encoder = JSON::XS->new->ascii->pretty;
	eval { $json = $encoder->encode($hash) };
	return (undef, "Cannot serialize profile: $!") if $@;

	my $file = "$home/$profile.profile";
	my $f;

lib/Net/MitDK.pm  view on Meta::CPAN

	} else {
		open $f, ">", $file or return (undef, "Cannot create $file:$!");
	}
	print $f $json or return (undef, "Cannot save $file:$!");
	close $f or return (undef, "Cannot save $file:$!");

	if ( $^O !~ /win32/i) {
		return (undef, "cannot chmod 0640 $file:$!") unless chmod 0640, $file;
		my (undef,undef,$gid) = getgrnam('nobody');
		return (undef, "no group `nobody`") unless defined $gid;
		return (undef, "cannot chown user:nobody $file:$!") unless chown $>, $gid, $file;
	}

	$self->{timestamps}->{$profile} = time;

	return 1;
}

sub remove
{
	my ($self, $profile) = @_;



( run in 0.572 second using v1.01-cache-2.11-cpan-71847e10f99 )