changes param src to path, and updates docs accordingly

pull/18777/head
Phil 9 years ago committed by Matt Clay
parent 00a4ec5e3b
commit 43074a736d

@ -88,15 +88,15 @@ $result = New-Object psobject @{
changed = $false changed = $false
} }
If ($params.src) { If ($params.path) {
$src = $params.src.toString() $path = $params.path.toString()
If (-Not (Test-Path -Path $src)) { If (-Not (Test-Path -Path $path)) {
Fail-Json $result "$src file or directory does not exist on the host" Fail-Json $result "$path file or directory does not exist on the host"
} }
} }
Else { Else {
Fail-Json $result "missing required argument: src" Fail-Json $result "missing required argument: path"
} }
If ($params.user) { If ($params.user) {
@ -124,7 +124,7 @@ Else {
If ($params.inherit) { If ($params.inherit) {
# If it's a file then no flags can be set or an exception will be thrown # If it's a file then no flags can be set or an exception will be thrown
If (Test-Path -Path $src -PathType Leaf) { If (Test-Path -Path $path -PathType Leaf) {
$inherit = "None" $inherit = "None"
} }
Else { Else {
@ -133,7 +133,7 @@ If ($params.inherit) {
} }
Else { Else {
# If it's a file then no flags can be set or an exception will be thrown # If it's a file then no flags can be set or an exception will be thrown
If (Test-Path -Path $src -PathType Leaf) { If (Test-Path -Path $path -PathType Leaf) {
$inherit = "None" $inherit = "None"
} }
Else { Else {
@ -176,7 +176,7 @@ Try {
$objUser = New-Object System.Security.Principal.NTAccount($user) $objUser = New-Object System.Security.Principal.NTAccount($user)
$objACE = New-Object System.Security.AccessControl.FileSystemAccessRule ($objUser, $colRights, $InheritanceFlag, $PropagationFlag, $objType) $objACE = New-Object System.Security.AccessControl.FileSystemAccessRule ($objUser, $colRights, $InheritanceFlag, $PropagationFlag, $objType)
$objACL = Get-ACL $src $objACL = Get-ACL $path
# Check if the ACE exists already in the objects ACL list # Check if the ACE exists already in the objects ACL list
$match = $false $match = $false
@ -190,7 +190,7 @@ Try {
If ($state -eq "add" -And $match -eq $false) { If ($state -eq "add" -And $match -eq $false) {
Try { Try {
$objACL.AddAccessRule($objACE) $objACL.AddAccessRule($objACE)
Set-ACL $src $objACL Set-ACL $path $objACL
$result.changed = $true $result.changed = $true
} }
Catch { Catch {
@ -200,7 +200,7 @@ Try {
ElseIf ($state -eq "remove" -And $match -eq $true) { ElseIf ($state -eq "remove" -And $match -eq $true) {
Try { Try {
$objACL.RemoveAccessRule($objACE) $objACL.RemoveAccessRule($objACE)
Set-ACL $src $objACL Set-ACL $path $objACL
$result.changed = $true $result.changed = $true
} }
Catch { Catch {
@ -219,7 +219,7 @@ Try {
} }
} }
Catch { Catch {
Fail-Json $result "an error occured when attempting to $state $rights permission(s) on $src for $user" Fail-Json $result "an error occured when attempting to $state $rights permission(s) on $path for $user"
} }
Exit-Json $result Exit-Json $result

@ -29,18 +29,15 @@ short_description: Set file/directory permissions for a system user or group.
description: description:
- Add or remove rights/permissions for a given user or group for the specified src file or folder. - Add or remove rights/permissions for a given user or group for the specified src file or folder.
options: options:
src: path:
description: description:
- File or Directory - File or Directory
required: yes required: yes
default: none
aliases: []
user: user:
description: description:
- User or Group to add specified rights to act on src file/folder - User or Group to add specified rights to act on src file/folder
required: yes required: yes
default: none default: none
aliases: []
state: state:
description: description:
- Specify whether to add (present) or remove (absent) the specified access rule - Specify whether to add (present) or remove (absent) the specified access rule
@ -49,7 +46,6 @@ options:
- present - present
- absent - absent
default: present default: present
aliases: []
type: type:
description: description:
- Specify whether to allow or deny the rights specified - Specify whether to allow or deny the rights specified
@ -58,7 +54,6 @@ options:
- allow - allow
- deny - deny
default: none default: none
aliases: []
rights: rights:
description: description:
- The rights/permissions that are to be allowed/denyed for the specified user or group for the given src file or directory. Can be entered as a comma separated list (Ex. "Modify, Delete, ExecuteFile"). For more information on the choices see MSDN FileSystemRights Enumeration. - The rights/permissions that are to be allowed/denyed for the specified user or group for the given src file or directory. Can be entered as a comma separated list (Ex. "Modify, Delete, ExecuteFile"). For more information on the choices see MSDN FileSystemRights Enumeration.
@ -86,7 +81,6 @@ options:
- WriteData - WriteData
- WriteExtendedAttributes - WriteExtendedAttributes
default: none default: none
aliases: []
inherit: inherit:
description: description:
- Inherit flags on the ACL rules. Can be specified as a comma separated list (Ex. "ContainerInherit, ObjectInherit"). For more information on the choices see MSDN InheritanceFlags Enumeration. - Inherit flags on the ACL rules. Can be specified as a comma separated list (Ex. "ContainerInherit, ObjectInherit"). For more information on the choices see MSDN InheritanceFlags Enumeration.
@ -96,7 +90,6 @@ options:
- ObjectInherit - ObjectInherit
- None - None
default: For Leaf File: None; For Directory: ContainerInherit, ObjectInherit; default: For Leaf File: None; For Directory: ContainerInherit, ObjectInherit;
aliases: []
propagation: propagation:
description: description:
- Propagation flag on the ACL rules. For more information on the choices see MSDN PropagationFlags Enumeration. - Propagation flag on the ACL rules. For more information on the choices see MSDN PropagationFlags Enumeration.
@ -106,7 +99,6 @@ options:
- NoPropagateInherit - NoPropagateInherit
- InheritOnly - InheritOnly
default: "None" default: "None"
aliases: []
author: Phil Schwartz, Trond Hindenes author: Phil Schwartz, Trond Hindenes
''' '''

Loading…
Cancel
Save