Use ui-libified host form from SSHd module
authorJamie Cameron <jcameron@webmin.com>
Mon, 23 Feb 2009 22:09:52 +0000 (22:09 +0000)
committerJamie Cameron <jcameron@webmin.com>
Mon, 23 Feb 2009 22:09:52 +0000 (22:09 +0000)
sshd/edit_host.cgi
sshd/save_host.cgi

index 7b393ed..e024a59 100755 (executable)
@@ -2,7 +2,7 @@
 # edit_host.cgi
 # Display options for a new or existing host config
 
-require './sshd-lib.pl';
+require (-r 'sshd-lib.pl' ? './sshd-lib.pl' : './ssh-lib.pl');
 &ReadParse();
 if ($in{'new'}) {
        &ui_print_header(undef, $text{'host_create'}, "", "chost");
@@ -14,6 +14,16 @@ else {
        $conf = $host->{'members'};
        }
 
+# Get version and type
+if (&get_product_name() eq 'usermin') {
+       $version_type = &get_ssh_type();
+       $version_number = &get_ssh_version();
+       }
+else {
+       $version_type = $version{'type'};
+       $version_number = $version{'number'};
+       }
+
 print &ui_form_start("save_host.cgi", "post");
 print &ui_hidden("idx", $in{'idx'});
 print &ui_hidden("new", $in{'new'});
@@ -65,7 +75,7 @@ print &ui_table_row($text{'host_escape'},
                    [ 0, &ui_textbox("escape",
                                $escape eq "none" ? "" : $escape, 4) ] ]));
 
-if ($version{'type'} ne 'ssh' || $version{'number'} < 3) {
+if ($version_type ne 'ssh' || $version_number < 3) {
        # SSH compression level
        $clevel = &find_value("CompressionLevel", $conf);
        print &ui_table_row($text{'host_clevel'},
@@ -115,7 +125,7 @@ print &ui_table_row($text{'host_strict'},
                  [ [ 0, $text{'yes'} ], [ 1, $text{'no'} ],
                    [ 3, $text{'host_ask'} ], [ 2, $text{'default'} ] ]));
 
-if ($version{'type'} eq 'openssh') {
+if ($version_type eq 'openssh') {
        # Double-check remote host IP?
        $checkip = &find_value("CheckHostIP", $conf);
        print &ui_table_row($text{'host_checkip'},
@@ -149,7 +159,7 @@ foreach $l (@lforward, { }) {
 print &ui_table_row($text{'host_lforward'},
        &ui_columns_table([ $text{'host_llport'}, $text{'host_lrhost'},
                            $text{'host_lrport'} ],
-                         100, \@ltable));
+                         50, \@ltable));
 
 print &ui_table_hr();
 
@@ -168,7 +178,7 @@ foreach $r (@rforward, { }) {
 print &ui_table_row($text{'host_rforward'},
         &ui_columns_table([ $text{'host_rrport'}, $text{'host_rlhost'},
                             $text{'host_rlport'} ],
-                          100, \@rtable));
+                          50, \@rtable));
 
 print &ui_table_end();
 if ($in{'new'}) {
index cd49736..c41c6c1 100755 (executable)
@@ -2,12 +2,22 @@
 # save_host.cgi
 # Create, update or delete a client host
 
-require './sshd-lib.pl';
+require (-r 'sshd-lib.pl' ? './sshd-lib.pl' : './ssh-lib.pl');
 &ReadParse();
 &lock_file($config{'client_config'});
 $hconf = &get_client_config();
 &error_setup($text{'host_err'});
 
+# Get version and type
+if (&get_product_name() eq 'usermin') {
+       $version_type = &get_ssh_type();
+       $version_number = &get_ssh_version();
+       }
+else {
+       $version_type = $version{'type'};
+       $version_number = $version{'number'};
+       }
+
 if ($in{'delete'}) {
        # Just delete the host
        $host = $hconf->[$in{'idx'}];
@@ -65,7 +75,7 @@ else {
                &save_directive("Port", $conf, $in{'port'});
                }
 
-       if ($version{'type'} ne 'ssh' || $version{'number'} < 3) {
+       if ($version_type ne 'ssh' || $version_number < 3) {
                &save_directive("Compression", $conf,
                        $in{'comp'} == 2 ? undef : $in{'comp'} ? 'yes' : 'no');
                }
@@ -83,7 +93,7 @@ else {
                }
 
        
-       if ($version{'type'} ne 'ssh' || $version{'number'} < 3) {
+       if ($version_type ne 'ssh' || $version_number < 3) {
                if ($in{'clevel_def'}) {
                        &save_directive("CompressionLevel", $conf);
                        }
@@ -122,7 +132,7 @@ else {
                $in{'strict'} == 2 ? undef : $in{'strict'} == 1 ? 'yes' :
                $in{'strict'} == 0 ? 'no' : 'ask');
 
-       if ($version{'type'} eq 'openssh') {
+       if ($version_type eq 'openssh') {
                &save_directive("CheckHostIP", $conf,
                  $in{'checkip'} == 2 ? undef : $in{'checkip'} ? 'yes' : 'no');
 
@@ -154,7 +164,9 @@ else {
 
 &flush_file_lines();
 &unlock_file($config{'client_config'});
-&webmin_log($in{'new'} ? "create" : $in{'delete'} ? "delete" : "update",
-           "host", $host->{'values'}->[0]);
+if (&get_product_name() ne 'usermin') {
+       &webmin_log($in{'new'} ? "create" : $in{'delete'} ? "delete" : "update",
+                   "host", $host->{'values'}->[0]);
+       }
 &redirect("list_hosts.cgi");