initialize

in lib/instance_agent/plugins/codedeploy/application_specification/mode_info.rb [12:52]


          def initialize(mode)
            mode = mode.to_s
            while mode.length < 3 do
              mode = "0" + mode;
            end
            if mode.length > 4
              raise AppSpecValidationException, "The deployment failed because the length of a permissions mode (#{mode}) in the application specification file is invalid. Permissions modes must be between one and four characters long. Update the permissions section of the AppSpec file, and then try again."
            end
            mode.each_char do |char|
              if (char.ord < '0'.ord) || (char.ord > '7'.ord)
                raise AppSpecValidationException, "The deployment failed because the permissions mode (#{mode}) in the application specification file contains an invalid character (#{char}). Update the permissions section of the AppSpec file, and then try again."
              end
            end
            @mode = mode
            mode_array = mode.reverse.chars.entries

            @world = mode_array[0]
            world_bits = to_bits(@world.to_i, 3)
            @world_readable = (world_bits[0] == 1)
            @world_writable = (world_bits[1] == 1)
            @world_executable = (world_bits[2] == 1)

            @group = mode_array[1]
            group_bits = to_bits(@group.to_i, 3)
            @group_readable = (group_bits[0] == 1)
            @group_writable = (group_bits[1] == 1)
            @group_executable = (group_bits[2] == 1)

            @owner = mode_array[2]
            owner_bits = to_bits(@owner.to_i, 3)
            @owner_readable = (owner_bits[0] == 1)
            @owner_writable = (owner_bits[1] == 1)
            @owner_executable = (owner_bits[2] == 1)

            special = (mode_array.length > 3) ? mode_array[3]: '0'
            special_bits = to_bits(special.to_i, 3)
            @setuid = (special_bits[0] == 1)
            @setgid = (special_bits[1] == 1)
            @sticky = (special_bits[2] == 1)
          end