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

AllowGroups does not work with condition. #29

Open
mvintila opened this issue Oct 14, 2016 · 12 comments
Open

AllowGroups does not work with condition. #29

mvintila opened this issue Oct 14, 2016 · 12 comments

Comments

@mvintila
Copy link

mvintila commented Oct 14, 2016

This doesn't work:

sshd_config_match { "LocalPort 2022":
  ensure   => present,
}

sshd_config { "AllowGroups":
  ensure    => present,
  condition => 'LocalPort 2022',
  value     => ['filedrop'],
}

The error is:

Error: /Stage[main]/Main/Node[__node_regexp__a-z0-9-filedrop-d]/Sshd_config[AllowGroups]: Could not evaluate: Failed to save Augeas tree to file. See debug logs for details.

If i enable debug logging it looks like this:

Notice: /Stage[main]/Main/Node[__node_regexp__a-z0-9-filedrop-d]/Sshd_config[AllowGroups]/ensure: created
Debug: Puppet::Type::Sshd_config::ProviderAugeas: Save failure details:
/augeas/files/etc/ssh/sshd_config/error/path = /files/etc/ssh/sshd_config/Match/Settings
/augeas/files/etc/ssh/sshd_config/error/lens = /usr/share/augeas/lenses/dist/sshd.aug:129.12-.44:
/augeas/files/etc/ssh/sshd_config/error/message = Failed to match 
    ({ /#comment/ = /[^\001-\004\t\n\r ][^\001-\004\n]_[^\001-\004\t\n\r ]|[^\001-\004\t\n\r ]/ } | { } | { /[Aa][Cc][Cc][Ee][Pp][Tt][Ee][Nn](([Vv][0-9A-Za-z]|[0-9A-UW-Za-uw-z])[0-9A-Za-z]_|)|[Aa][Cc][Cc][Ee][Pp][
-DF-Za-df-z][0-9A-Za-z]_|)|[Aa][Cc][Cc][Ee][Pp]([0-9A-SU-Za-su-z][0-9A-Za-z]*|)|[Aa][Cc][Cc][Ee]([0-9A-OQ-Za-oq-z][0-9A-Za-z]_|)|[Aa][Cc][Cc]([0-9A-DF-Za-df-z][0-9A-Za-z]*|)|[Aa][Ll][Ll][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A-Za-z]*|[Ss]|[Mm]|[Kk]|[Dd]|[Cc]|[Aa]|[0-9BE-JLN-RT-Zbe-jln-rt-
  with tree
    { "X11Forwarding" = "no" } { "PasswordAuthentication" = "yes" } { "AllowTCPForwarding" = "no" } { "AllowGroups" }
Error: /Stage[main]/Main/Node[__node_regexp__a-z0-9-filedrop-d]/Sshd_config[AllowGroups sftp]: Could not evaluate: Failed to save Augeas tree to file. See debug logs for details.
@mvintila mvintila changed the title AllowUsers does not work with condition. AllowGroups does not work with condition. Oct 14, 2016
@mvintila
Copy link
Author

I should mention that AllowGroups works fine if condition is not specified placing the directive in the global config, but i need it inside a Match conditon.

The same is true for the following directives:

sshd_config { "ChrootDirectory":
  ensure    => present,
  condition => 'LocalPort 2022',
  value     => '/var/sftp/users/%u',
}
sshd_config { "ForceCommand":
  ensure    => present,
  condition => 'LocalPort 2022',
  value     => 'internal-sftp -d /files',
}

@raphink
Copy link
Member

raphink commented Oct 31, 2016

Which version of Augeas are you using?

@bogdan-radocea
Copy link

bogdan-radocea commented Nov 1, 2016

Augeasproviders_core is 2.1.1
Augeasproviders_ssh is 2.5.0
I'm a colleague of his, working on the same project.

@raphink
Copy link
Member

raphink commented Nov 2, 2016

@bogdan-radocea ok, and what is the version of the Augeas library?

@bogdan-radocea
Copy link

How can I check? :)

@raphink
Copy link
Member

raphink commented Jan 10, 2017

@bogdan-radocea are you using the Puppet AIO packages or your OS packages?

@bogdan-radocea
Copy link

Puppet AIO, installed with: puppet module install

@raphink
Copy link
Member

raphink commented Jan 11, 2017

@bogdan-radocea can you post the content of the sshd_config file that fail?

@bogdan-radocea
Copy link

This is what we want to do:
Port 2022
Match LocalPort 2022
AllowGroups restricted-sftp
PasswordAuthentication yes
ChrootDirectory /var/sftp/users/%u
AllowTCPForwarding no
X11Forwarding no
ForceCommand internal-sftp -d /files

@raphink
Copy link
Member

raphink commented Jan 11, 2017

Right, but what does the file contain before applying?

@bogdan-radocea
Copy link

standard ubuntu fresh install. so default ubuntu settings:

~$ grep -v ^# /etc/ssh/sshd_config 
Port 22
Protocol 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
UsePrivilegeSeparation yes
KeyRegenerationInterval 3600
ServerKeyBits 1024
SyslogFacility AUTH
LogLevel INFO
LoginGraceTime 120
PermitRootLogin yes
StrictModes yes
RSAAuthentication yes
PubkeyAuthentication yes
IgnoreRhosts yes
RhostsRSAAuthentication no
HostbasedAuthentication no
PermitEmptyPasswords no
ChallengeResponseAuthentication no
X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
AcceptEnv LANG LC_*
Subsystem sftp /usr/lib/openssh/sftp-server
UsePAM yes
AddressFamily inet

@raphink
Copy link
Member

raphink commented Oct 19, 2018

I just ran @mvintila's original example on @bogdan-radocea's file without a problem with augeas 1.10.1, ruby-augeas 0.5 and Puppet 5.5.6, 4.10.12 and 6.0.2.

@bogdan-radocea @mvintila can you provide info on a configuration that fails?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants