# File lib/puppet/ssl/certificate_authority.rb, line 188 188: def next_serial 189: serial = nil 190: 191: # This is slightly odd. If the file doesn't exist, our readwritelock creates 192: # it, but with a mode we can't actually read in some cases. So, use 193: # a default before the lock. 194: unless FileTest.exist?(Puppet[:serial]) 195: serial = 0x1 196: end 197: 198: Puppet.settings.readwritelock(:serial) { |f| 199: if FileTest.exist?(Puppet[:serial]) 200: serial ||= File.read(Puppet.settings[:serial]).chomp.hex 201: end 202: 203: # We store the next valid serial, not the one we just used. 204: f << "%04X" % (serial + 1) 205: } 206: 207: return serial 208: end