Skip to content

Commit

Permalink
Reindent the UsersRoutines#CreateHome
Browse files Browse the repository at this point in the history
  • Loading branch information
dgdavid committed Feb 4, 2019
1 parent 0784a2f commit f52f29b
Showing 1 changed file with 18 additions and 12 deletions.
30 changes: 18 additions & 12 deletions src/modules/UsersRoutines.pm
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,22 @@ BEGIN { $TYPEINFO{CreateHome} = ["function",
}
sub CreateHome {

my $self = shift;
my $self = shift;
my ( $skel, $home, $use_btrfs ) = @_;

# create a path to new home directory, if not exists
my $home_path = substr ($home, 0, rindex ($home, "/"));
if (length($home_path) and !%{SCR->Read (".target.stat", $home_path)}) {
SCR->Execute (".target.mkdir", $home_path);
# Create a path to new home directory, if not exists
my $home_path = substr( $home, 0, rindex( $home, "/" ) );
if ( length($home_path) and !%{ SCR->Read( ".target.stat", $home_path ) } )
{
SCR->Execute( ".target.mkdir", $home_path );
}
my %stat = %{SCR->Read (".target.stat", $home)};

my %stat = %{ SCR->Read( ".target.stat", $home ) };
if (%stat) {
if ($home ne "/var/lib/nobody") {
y2error ("$home directory already exists: no mkdir");
}
return 0;
if ( $home ne "/var/lib/nobody" ) {
y2error("$home directory already exists: no mkdir");
}
return 0;
}

if ( $use_btrfs && valid_btrfs($home) ) {
Expand All @@ -119,15 +121,19 @@ sub CreateHome {
}
else {
if ( !SCR->Execute( ".target.mkdir", $home ) ) {
y2error("Error creating $home");
y2error("Error creating '$home'");

return 0;
}
}

# Now copy the skeleton
if ( $skel ne "" && %{ SCR->Read( ".target.stat", $skel ) } ) {
my $cmd = sprintf( "/usr/bin/cp -r '%s/.' '%s'", String->Quote($skel), String->Quote($home) );
my $cmd = sprintf(
"/usr/bin/cp -r '%s/.' '%s'",
String->Quote($skel),
String->Quote($home)
);
my %cmd_out = %{ SCR->Execute( ".target.bash_output", $cmd ) };
my $stderr = $cmd_out{"stderr"} || "";

Expand Down

0 comments on commit f52f29b

Please sign in to comment.