3 var m
= new L
.cbi
.Map('dropbear', {
4 caption
: L
.tr('SSH Access'),
5 description
: L
.tr('Dropbear offers SSH network shell access and an integrated SCP server'),
9 var s1
= m
.section(L
.cbi
.DummySection
, '__password', {
10 caption
: L
.tr('Router Password'),
11 description
: L
.tr('Changes the administrator password for accessing the device'),
12 readonly
: !this.options
.acls
.admin
15 var p1
= s1
.option(L
.cbi
.PasswordValue
, 'pass1', {
16 caption
: L
.tr('Password'),
20 var p2
= s1
.option(L
.cbi
.PasswordValue
, 'pass2', {
21 caption
: L
.tr('Confirmation'),
23 datatype: function(v
) {
24 var v1
= p1
.formvalue('__password');
25 if (v1
&& v1
.length
&& v
!= v1
)
26 return L
.tr('Passwords must match!');
31 p1
.save = function(sid
) { };
32 p2
.save = function(sid
) {
33 var v1
= p1
.formvalue(sid
);
34 var v2
= p2
.formvalue(sid
);
35 if (v2
&& v2
.length
> 0 && v1
== v2
)
36 return L
.system
.setPassword('root', v2
);
40 var s2
= m
.section(L
.cbi
.TypedSection
, 'dropbear', {
41 caption
: L
.tr('SSH Server'),
42 description
: L
.tr('This sections define listening instances of the builtin Dropbear SSH server'),
44 add_caption
: L
.tr('Add instance ...'),
45 readonly
: !this.options
.acls
.admin
48 s2
.option(L
.cbi
.NetworkList
, 'Interface', {
49 caption
: L
.tr('Interface'),
50 description
: L
.tr('Listen only on the given interface or, if unspecified, on all')
53 s2
.option(L
.cbi
.InputValue
, 'Port', {
54 caption
: L
.tr('Port'),
55 description
: L
.tr('Specifies the listening port of this Dropbear instance'),
61 s2
.option(L
.cbi
.CheckboxValue
, 'PasswordAuth', {
62 caption
: L
.tr('Password authentication'),
63 description
: L
.tr('Allow SSH password authentication'),
69 s2
.option(L
.cbi
.CheckboxValue
, 'RootPasswordAuth', {
70 caption
: L
.tr('Allow root logins with password'),
71 description
: L
.tr('Allow the root user to login with password'),
77 s2
.option(L
.cbi
.CheckboxValue
, 'GatewayPorts', {
78 caption
: L
.tr('Gateway ports'),
79 description
: L
.tr('Allow remote hosts to connect to local SSH forwarded ports'),
86 var s3
= m
.section(L
.cbi
.TableSection
, '__keys', {
87 caption
: L
.tr('SSH-Keys'),
88 description
: L
.tr('Here you can paste public SSH-Keys (one per line) for SSH public-key authentication.'),
90 add_caption
: L
.tr('Add key ...'),
91 readonly
: !this.options
.acls
.admin
94 s3
.sections = function()
97 var l
= this.keys
? this.keys
.length
: 0;
99 for (var i
= 0; i
< (l
|| 1); i
++)
100 k
.push({ '.name': i
.toString() });
105 s3
.add = function() { this.keys
.push('') };
106 s3
.remove = function(sid
) { this.keys
.splice(parseInt(sid
), 1) };
108 var c
= s3
.option(L
.cbi
.DummyValue
, '__comment', {
109 caption
: L
.tr('Comment'),
113 c
.ucivalue = function(sid
) {
114 var key
= (s3
.keys
[parseInt(sid
)] || '').split(/\s+/) || [ ];
115 return key
[2] || '-';
118 var k
= s3
.option(L
.cbi
.InputValue
, '__key', {
119 caption
: L
.tr('Public key line'),
121 datatype: function(key
, elem
) {
122 var elems
= (key
|| '-').toString().split(/\s+/);
124 $('#' + elem
.attr('id').replace(/key$/, 'comment')).text(elems
[2] || '');
126 if (elems
.length
< 2 || elems
[0].indexOf('ssh-') != 0 ||
127 !elems
[1].match(/^(?:[A-Za-z0-9+/]{4})+(?:[A
-Za
-z0
-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/))
128 return L
.tr('Must be a valid SSH pubkey');
134 k
.load = function(sid
) { s3
.keys
= [ ]; return L
.system
.getSSHKeys().then(function(keys
) { s3
.keys
= keys
}) };
135 k
.save = function(sid
) { if (sid
== '0') return L
.system
.setSSHKeys(s3
.keys
) };
136 k
.ucivalue = function(sid
) { return s3
.keys
[parseInt(sid
)] };
138 return m
.insertInto('#map');