717: def writesub(default, file, *args, &bloc)
718: obj = get_config_file_default(default)
719: chown = nil
720: if Puppet::Util::SUIDManager.uid == 0
721: chown = [obj.owner, obj.group]
722: else
723: chown = [nil, nil]
724: end
725:
726: Puppet::Util::SUIDManager.asuser(*chown) do
727: mode = obj.mode || 0640
728: if args.empty?
729: args << "w"
730: end
731:
732: args << mode
733:
734:
735: Puppet::Util.withumask(File.umask ^ 0111) do
736: File.open(file, *args) do |file|
737: yield file
738: end
739: end
740: end
741: end