chorankates / rouster

Rouster.is_a?('abstraction layer for controlling Vagrant virtual machines') => true
BSD 3-Clause "New" or "Revised" License
109 stars 14 forks source link

Fix handling of usernames with dashes. #114

Closed froismo closed 6 years ago

froismo commented 6 years ago

Regex doesn't handle username with dashes, parsing "alpha-user" and "beta-user" both as "user". When this happens logging is done, and if "aplha-user" has a different home directory than "beta-user" than rouster crashes because of incorrect number of arguments to sprintf. Producing a backtrace such as:

    /home/centos/rouster/lib/rouster/deltas.rb:788:in `sprintf'
    /home/centos/rouster/lib/rouster/deltas.rb:788:in `block (2 levels) in get_users'
    /home/centos/rouster/lib/rouster/deltas.rb:774:in `each'
    /home/centos/rouster/lib/rouster/deltas.rb:774:in `block in get_users'
    /home/centos/rouster/lib/rouster/deltas.rb:772:in `each'
    /home/centos/rouster/lib/rouster/deltas.rb:772:in `get_users'
    /home/centos/rouster/lib/rouster/testing.rb:722:in `validate_user'

The proposed change explicitly allows dashes and fixes the logging statements to prevent crashing.

chorankates-sfdc commented 6 years ago

@froismo - thanks for the fixes.

how do you feel about adding \. to that character set? i know it isn't in NAME_REGEX, but it is used and we're already here..

froismo commented 6 years ago

Sounds like a great idea.