Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sub take_ownership{
- # Looks like this is required to make sure that permissions are correct...
- my ($home_path, $action) = @_;
- my $icaclsStr = "";
- my $takeownCommand = "";
- my $chmodCommand = "";
- my $fullCommands = "";
- if (defined $home_path && $home_path ne "" && -e "$home_path"){
- my $windows_home_path = clean(`cygpath -wa $home_path`);
- logger "Running takeown commands on path of $home_path and $windows_home_path";
- #cygwin path handling
- $takeownCommand = 'takeown /U cyg_server /f "' . $home_path . '" /r >/dev/null 2>&1';
- $chmodCommand = 'chmod 775 -R "' . $home_path . '" >/dev/null 2>&1';
- if(defined $action && $action eq "str"){
- $fullCommands .= $takeownCommand . "\n";
- $fullCommands .= $chmodCommand . "\n";
- }else{
- system($takeownCommand);
- system($chmodCommand);
- }
- # Windows path handling
- if(defined $windows_home_path && $windows_home_path ne ""){
- $takeownCommand = 'takeown /U cyg_server /f "' . $windows_home_path . '" /r >/dev/null 2>&1';
- $chmodCommand = 'chmod 775 -R "' . $windows_home_path . '" >/dev/null 2>&1';
- $icaclsStr = 'icacls "' . $windows_home_path . '" /grant cyg_server:\\(OI\\)\\(CI\\)F /T >/dev/null 2>&1';
- if(defined $action && $action eq "str"){
- $fullCommands .= $takeownCommand . "\n";
- $fullCommands .= $chmodCommand . "\n";
- $fullCommands .= $icaclsStr . "\n";
- }else{
- logger "Running icacls command: $icaclsStr";
- system($takeownCommand);
- system($chmodCommand);
- system($icaclsStr);
- }
- }
- }
- if($fullCommands ne ""){
- return $fullCommands;
- }
- return 1;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement