cleanup ENV SLICE from path
authorroot <root@rsync1.maxxo.com>
Wed, 11 Apr 2012 20:25:18 +0000 (22:25 +0200)
committerroot <root@rsync1.maxxo.com>
Wed, 11 Apr 2012 20:25:18 +0000 (22:25 +0200)
lib/CloudStore/API.pm

index 6902520..5ac4175 100644 (file)
@@ -35,7 +35,7 @@ sub new {
 
 sub slice_dir_port {
        my ($self,$slice) = @_;
-       my ( undef, $dir, $port, undef ) = getgrnam($slice);
+       my ( undef, $dir, $port, undef ) = getgrnam($slice) || die "getgrnam $slice: $!";
        warn "# slice_dir_port $slice = $dir $port\n";
        return ( $dir, $port );
 }
@@ -77,8 +77,12 @@ sub create_user {
        close($fh);
 
        my $slice = $ENV{SLICE} || 's1';
+       $slice =~ s{/.+/(\w+)$}{$1};
        my ( $dir, $port ) = $self->slice_dir_port( $slice );
 
+       $dir ||= $ENV{SLICE};
+       $port ||= 6501;
+
        if ( ! $found ) {
                $max_uid++;
                $dir .= "/$max_uid";