1 package CloudStore::API;
6 use Data::Dump qw(dump);
13 $self->{passwd} ||= '/var/lib/extrausers/passwd';
14 $self->{PORT} ||= $ENV{PORT} || die "no PORT in env";
15 $self->{SLICE} ||= $ENV{SLICE} || die "no SLICE in env";
21 my ($self,$login) = @_;
23 my @n = qw/ login passwd uid gid quota comment gecos dir shell expire /;
24 my @p = $login =~ m/^\d+$/ ? getpwuid $login : getpwnam $login;
25 warn "## $login ",dump(@p);
26 die "$login: $!" if $!;
28 $user->{$_} = shift @p foreach @n;
33 my ( $self, $new_email, $new_passwd, $new_quota ) = @_;
38 open(my $fh, '<', $self->{passwd});
40 my ( $login, $passwd, $uid, $gid, $email, $dir, $shell ) = split(/:/,$_);
41 $max_uid = $uid if $uid > $max_uid;
42 $found = $uid if $email eq $new_email;
48 my $dir = "$self->{SLICE}/$max_uid";
49 warn "# create_user $new_email $new_quota = $max_uid $dir";
50 open(my $fh, '>>', $self->{passwd});
51 print $fh "u$max_uid:$new_passwd:$max_uid:$self->{PORT}:$new_email:$dir:/bin/true\n";
56 chown $max_uid, $self->{PORT}, $dir;
63 my ( $self, $f_uid,$f_path, $t_uid,$t_path ) = @_;
69 my ( $uid, $from, $to ) = @_;
74 my ( $uid, $path ) = @_;