Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

passwd resource does not ignore comments #725

Closed
chris-rock opened this issue May 9, 2016 · 0 comments
Closed

passwd resource does not ignore comments #725

chris-rock opened this issue May 9, 2016 · 0 comments
Labels
Type: Bug Feature not working as expected
Milestone

Comments

@chris-rock
Copy link
Contributor

Description

cat /etc/passwd        
##
# User Database
# 
# Note that this file is consulted directly only when the system is running
# in single-user mode.  At other times this information is provided by
# Open Directory.
#
# See the opendirectoryd(8) man page for additional information about
# Open Directory.
##
nobody:*:-2:-2:Unprivileged User:/var/empty:/usr/bin/false

I would expect that the comments are not parsed as users:

$ inspec shell 
Welcome to the interactive InSpec Shell
To find out how to use it, type: help

inspec> passwd.users
=> ["##",
 "# User Database",
 "# ",
 "# Note that this file is consulted directly only when the system is running",
 "# in single-user mode.  At other times this information is provided by",
 "# Open Directory.",
 "#",
 "# See the opendirectoryd(8) man page for additional information about",
 "# Open Directory.",
 "##",
 "nobody",
...]
inspec> 

InSpec and Platform Version

Mac OS 10.10
InSpec 0.20.1

Replication Case

Ensure the /etc/passwd includes comments.

Possible Solutions

Extend https://github.com/chef/inspec/blob/master/lib/utils/parser.rb#L20 to handle comments properly

@chris-rock chris-rock added the Type: Bug Feature not working as expected label May 9, 2016
@chris-rock chris-rock added this to the 0.31.0 milestone Aug 15, 2016
stevendanna added a commit that referenced this issue Aug 16, 2016
Most passwd/shadow implementations treat lines that start with '#' as
comments. For example, the implementation in OS X:

     if (buf[0] == '#') {
          /* skip comments for Rhapsody. */
          continue;
     }

https://opensource.apple.com/source/remote_cmds/remote_cmds-41/rpc_yppasswdd.tproj/passwd.c

Fixes #725

Signed-off-by: Steven Danna <steve@chef.io>
@stevendanna stevendanna self-assigned this Aug 16, 2016
chris-rock pushed a commit that referenced this issue Aug 16, 2016
Most passwd/shadow implementations treat lines that start with '#' as
comments. For example, the implementation in OS X:

     if (buf[0] == '#') {
          /* skip comments for Rhapsody. */
          continue;
     }

https://opensource.apple.com/source/remote_cmds/remote_cmds-41/rpc_yppasswdd.tproj/passwd.c

Fixes #725

Signed-off-by: Steven Danna <steve@chef.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Feature not working as expected
Projects
None yet
Development

No branches or pull requests

2 participants