Skip to content

Commit

Permalink
ncm-metaconfig: ssh: cleanup TT files a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdweird committed Jun 11, 2020
1 parent 8a8b1a3 commit 7e8f2c5
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 36 deletions.
31 changes: 14 additions & 17 deletions ncm-metaconfig/src/main/metaconfig/ssh/client_attrs.tt
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
[% spacelist = ['SendEnv', 'GlobalKnownHostsFile', 'IgnoreUnknown', 'Include', 'UserKnownHostsFile' ] -%]
[% commalist = ['CASignatureAlgorithms', 'CanonicalDomains', 'CanonicalizePermittedCNAMEs', 'Ciphers',
'GSSAPIKexAlgorithms', 'HostbasedKeyTypes','HostKeyAlgorithms',
'KbdInteractiveDevices', 'KexAlgorithms', 'KbdInteractiveDevices',
'MACs', 'PreferredAuthentications', 'PubkeyAcceptedKeyTypes', 'ProxyJump',
] -%]
[% multilinelist = ['CertificateFile', 'IdentityFile', 'RevokedHostKeys'] -%]

[% # different forms of list handling, default for list type is comma separated
spacelist = ['SendEnv', 'GlobalKnownHostsFile', 'IgnoreUnknown', 'Include', 'UserKnownHostsFile' ];
multilinelist = ['CertificateFile', 'IdentityFile', 'RevokedHostKeys'];
-%]
[%- FOREACH pair IN data.pairs -%]
[% NEXT IF pair.key == 'hostnames' || pair.key == 'matches' -%]
[% IF pair.value.is_boolean -%]
[% pair.key %] [% pair.value ? 'Yes' : 'No' %]
[% NEXT -%]
[% END -%]
[% SWITCH pair.key -%]
[% CASE ['hostnames', 'matches'] %][% # Do nothing -%]
[% CASE spacelist -%]
[% pair.key %] [% pair.value.join(' ') %]
[% CASE commalist -%]
[% pair.key %] [% pair.value.join(',') %]
[% CASE multilinelist -%]
[% FOREACH line IN pair.value -%]
[% pair.key %] [% line %]
Expand All @@ -26,6 +16,13 @@
SetEnv [% item.key %]="[% item.value %]"
[% END -%]
[% CASE -%]
[% pair.key %] [% pair.value %]
[% END -%]
[% pair.key %] [% -%]
[% IF pair.value.is_boolean -%]
[% pair.value ? 'Yes' : 'No' -%]
[% ELSIF CCM.is_list(pair.value) -%]
[% pair.value.join(',') -%]
[% ELSE -%]
[% pair.value -%]
[% END -%]
[% END %]
[% END -%]
35 changes: 16 additions & 19 deletions ncm-metaconfig/src/main/metaconfig/ssh/server_attrs.tt
Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
[% spacelist = ['AcceptEnv', 'AllowGroups', 'AllowUsers', 'AuthenticationMethods', 'AuthorizedKeysFile', 'AuthorizedPrincipalsFile',
'DenyGroups', 'DenyUsers',
'IPQoS',
'PermitListen', 'PermitOpen',
'RekeyLimit' ] -%]
[% commalist = ['Ciphers', 'HostKeyAlgorithms', 'HostbasedAcceptedKeyTypes', 'KexAlgorithms', 'MACs', 'PubkeyAcceptedKeyTypes' ] -%]
[% multilinelist = ['HostKey', 'ListenAddress', 'Port' ] -%]

[% # different forms of list handling, default for list type is space separated
commalist = ['Ciphers', 'HostKeyAlgorithms', 'HostbasedAcceptedKeyTypes', 'KexAlgorithms', 'MACs', 'PubkeyAcceptedKeyTypes' ];
multilinelist = ['HostKey', 'ListenAddress', 'Port' ]
-%]
[%- FOREACH pair IN data.pairs -%]
[% NEXT IF pair.key == 'matches' -%]
[% IF pair.value.is_boolean -%]
[% pair.key %] [% pair.value ? 'Yes' : 'No' %]
[% NEXT -%]
[% END -%]
[% SWITCH pair.key -%]
[% CASE spacelist -%]
[% pair.key %] [% pair.value.join(' ') %]
[% CASE 'matches' %][% # do nothing -%]
[% CASE commalist -%]
[% pair.key %] [% pair.value.join(',') %]
[% CASE multilinelist -%]
Expand All @@ -23,13 +13,20 @@
[% END -%]
[% CASE 'Subsystem' -%]
[% FOREACH item IN pair.value.pairs -%]
Subsystem [% item.key %] [% item.value %]
Subsystem [% item.key %] [% item.value %]
[% END -%]
[% CASE 'SetEnv' -%]
[% FOREACH item IN pair.value.pairs -%]
SetEnv [% item.key %]="[% item.value %]"
SetEnv [% item.key %]="[% item.value %]"
[% END -%]
[% CASE -%]
[% pair.key %] [% pair.value %]
[% END -%]
[% pair.key %] [% -%]
[% IF pair.value.is_boolean -%]
[% pair.value ? 'Yes' : 'No' -%]
[% ELSIF CCM.is_list(pair.value) -%]
[% pair.value.join(' ') -%]
[% ELSE -%]
[% pair.value -%]
[% END -%]
[% END %]
[% END -%]

0 comments on commit 7e8f2c5

Please sign in to comment.