Ticket #219: locking.patch
| File locking.patch, 3.6 kB (added by jamtur01, 10 months ago) |
|---|
-
a/lib/puppet/provider/nameservice.rb
old new 186 186 self.ensure = :absent 187 187 end 188 188 189 def locked190 self.ensure = :locked191 end192 193 def unlocked194 self.ensure = :unlocked195 end196 197 189 def ensure 198 190 if exists? 199 191 :present … … 202 194 end 203 195 end 204 196 197 def locked 198 self.status = :locked 199 end 200 201 def unlocked 202 self.status = :unlocked 203 end 204 205 #def status 206 # if exists? 207 # :unlocked 208 # else 209 # :locked 210 # end 211 #end 212 213 def status=(value) 214 cmd = nil 215 event = nil 216 case value 217 when :unlocked 218 unless exists? 219 info "absent - cannot unlock" 220 return nil 221 end 222 223 cmd = self.unlockcmd 224 type = "unlock" 225 when :locked 226 # FIXME - what happens when already locked? 227 228 cmd = self.lockcmd 229 type = "lock" 230 end 231 232 begin 233 execute(cmd) 234 rescue Puppet::ExecutionFailure => detail 235 raise Puppet::Error, "Could not %s %s %s: %s" % 236 [type, @resource.class.name, @resource.name, detail] 237 end 238 end 239 205 240 # This is only used when creating or destroying the object. 206 241 def ensure=(value) 207 242 cmd = nil … … 229 264 # blah blah, define elsewhere, blah blah 230 265 cmd = self.addcmd 231 266 type = "create" 232 when :locked233 unless exists?234 #the object doesn't exist - can't lock it235 info "is absent - cannot lock"236 return nil237 end238 239 cmd = self.lockcmd240 type = "locked"241 when :unlocked242 unless exists?243 #the object doesn't exist - can't unlock it244 info "is absent - cannot unlock"245 return nil246 end247 248 cmd = self.unlockcmd249 type = "unlocked"250 267 end 251 268 252 269 begin -
a/lib/puppet/type/user.rb
old new 33 33 provider.delete 34 34 end 35 35 36 newvalue(:locked, :event => :user_locked) do37 provider.locked38 end39 40 newvalue(:unlocked, :event => :user_unlocked) do41 provider.unlocked42 end43 44 36 desc "The basic state that the object should be in." 45 37 46 38 # If they're talking about the thing at all, they generally want to … … 81 73 82 74 end 83 75 76 newproperty(:status) do 77 desc "The status of the user. Can be specified as locked or 78 unlocked. Status defaults to unlocked." 79 80 newvalue(:locked, :event => :user_locked) do 81 provider.locked 82 end 83 84 newvalue(:unlocked, :event => :user_unlocked) do 85 provider.unlocked 86 end 87 88 end 89 84 90 newproperty(:uid) do 85 91 desc "The user ID. Must be specified numerically. For new users 86 92 being created, if no user ID is specified then one will be