Subversion Repositories

?revision_form?Rev ?revision_input??revision_submit??revision_endform?

Rev 2 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2 Rev 99
1
#!/usr/bin/perl -w
1
#!/usr/bin/perl -w
2
#
2
#
3
# debconf config script for lsh-server
3
# debconf config script for lsh-server
4
#
4
#
5
# Copyright (c) 2000, 2001, 2002 Timshel Knoll <timshel@debian.org>
5
# Copyright (c) 2000, 2001, 2002 Timshel Knoll <timshel@debian.org>
6
# This program is free software; you can redistribute it and/or modify
6
# This program is free software; you can redistribute it and/or modify
7
# it under the terms of the GNU General Public License as published by
7
# it under the terms of the GNU General Public License as published by
8
# the Free Software Foundation; either version 2 of the License, or
8
# the Free Software Foundation; either version 2 of the License, or
9
# (at your option) any later version.
9
# (at your option) any later version.
10
#  
10
#  
11
# This program is distributed in the hope that it will be useful,
11
# This program is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
# GNU General Public License for more details.
14
# GNU General Public License for more details.
15
#  
15
#  
16
# You should have received a copy of the GNU General Public License
16
# You should have received a copy of the GNU General Public License
17
# along with this program; if not, write to the Free Software
17
# along with this program; if not, write to the Free Software
18
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
#
19
#
20
# On Debian systems, see /usr/share/common-licenses/GPL for the GNU GPL.
20
# On Debian systems, see /usr/share/common-licenses/GPL for the GNU GPL.
21
#
21
#
22
use strict;
22
use strict;
23
use Debconf::Client::ConfModule ':all';
23
use Debconf::Client::ConfModule ':all';
24
24
25
25
26
sub ask_whether_to_purge_hostkey {
26
sub ask_whether_to_purge_hostkey {
27
   &input ("medium", "lsh-server/purge_hostkey");
27
   &input ("medium", "lsh-server/purge_hostkey");
28
   my @ret = &go ();
28
   my @ret = &go ();
29
29
30
   return ($ret[0] == 30 ? -1 : 1);
30
   return ($ret[0] == 30 ? -1 : 1);
31
}
31
}
32
32
33
33
34
sub get_lshd_port {
34
sub get_lshd_port {
35
   &input ("medium", "lsh-server/lshd_port");
35
   &input ("medium", "lsh-server/lshd_port");
36
   my @ret = &go ();
36
   my @ret = &go ();
37
37
38
   my $port = &get ("lsh-server/lshd_port");
38
   my $port = &get ("lsh-server/lshd_port");
39
   
39
   
40
   if ($port and $port !~ m/^\d+$/) {
40
   if ($port and $port !~ m/^\d+$/) {
41
      $port = (getservbyname ($port, "tcp"))[2];
41
      $port = (getservbyname ($port, "tcp"))[2];
42
   }  
42
   }  
43
      
43
      
44
   unless ($port) {
44
   unless ($port) {
45
      # invalid service entered: wasn't a number, and
45
      # invalid service entered: wasn't a number, and
46
      # getservbyname failed, try again ...
46
      # getservbyname failed, try again ...
47
      # FIXME: try putting some sort of error message here?
47
      # FIXME: try putting some sort of error message here?
48
      &reset ("lsh-server/lshd_port");
48
      &reset ("lsh-server/lshd_port");
49
      return 0;
49
      return 0;
50
   }
50
   }
51
51
52
   return ($ret[0] == 30 ? -1 : 1);
52
   return ($ret[0] == 30 ? -1 : 1);
53
}
53
}
54
54
55
55
56
56
57
sub ask_whether_to_enable_sftp {
57
sub ask_whether_to_enable_sftp {
58
   &input ("medium", "lsh-server/sftp");
58
   &input ("medium", "lsh-server/sftp");
59
   my @ret = &go ();
59
   my @ret = &go ();
60
60
61
   return ($ret[0] == 30 ? -1 : 1);
61
   return ($ret[0] == 30 ? -1 : 1);
62
}
62
}
63
63
64
64
65
sub configure () {
65
sub configure () {
66
   my $state = 0;
66
   my $state = 0;
67
67
68
   # The list of things to do, in order
68
   # The list of things to do, in order
69
   # Aren't really long, descriptive function names fun ;-)
69
   # Aren't really long, descriptive function names fun ;-)
70
   my @states = (
70
   my @states = (
71
      \&ask_whether_to_purge_hostkey,
71
      \&ask_whether_to_purge_hostkey,
72
      \&get_lshd_port,
72
      \&get_lshd_port,
73
      \&ask_whether_to_enable_sftp
73
      \&ask_whether_to_enable_sftp
74
   );
74
   );
75
75
76
   # This is 1 or -1, depending on whether we're going forward or backward
76
   # This is 1 or -1, depending on whether we're going forward or backward
77
   # Required because otherwise when we back up to a question doesn't need
77
   # Required because otherwise when we back up to a question doesn't need
78
   # to be asked, the engine will go forward again :-(
78
   # to be asked, the engine will go forward again :-(
79
   my $step = 1;
79
   my $step = 1;
80
80
81
   until ($state > $#states) {
81
   until ($state > $#states) {
82
      if ($state < 0) {
82
      if ($state < 0) {
83
         $state = 0;
83
         $state = 0;
84
         # We may have got here because of "backing up" to a question which
84
         # We may have got here because of "backing up" to a question which
85
         # was skipped, so make sure we're going forward from here to avoid
85
         # was skipped, so make sure we're going forward from here to avoid
86
         # an infinite loop
86
         # an infinite loop
87
         $step = 1;
87
         $step = 1;
88
      }
88
      }
89
89
90
      $step = &{ $states[$state] } ($step);
90
      $step = &{ $states[$state] } ($step);
91
91
92
      $state += $step;
92
      $state += $step;
93
   }
93
   }
94
}
94
}
95
95
96
96
97
97
98
die "Syntax error: no argument" if (@ARGV <= 0);
98
die "Syntax error: no argument" if (@ARGV <= 0);
99
99
100
version ('2.0');
100
version ('2.0');
101
101
102
my $capb = &capb ('backup');
102
my $capb = &capb ('backup');
103
103
-
 
104
system {'sh'} 'sh', '-c', <<'EOF';
-
 
105
[ -e /etc/default/lsh-server ] || exit 0
-
 
106
. /etc/default/lsh-server
-
 
107
. /usr/share/debconf/confmodule
-
 
108
-
 
109
db_set lsh-server/lshd_port "$LSHD_PORT" || true
-
 
110
db_set lsh-server/sftp "$ENABLE_SFTP" || true
-
 
111
db_set lsh-server/extra_args "$EXTRA_ARGS" || true
-
 
112
EOF
-
 
113
104
if ($ARGV[0] eq "configure" || $ARGV[0] eq "reconfigure") {
114
if ($ARGV[0] eq "configure" || $ARGV[0] eq "reconfigure") {
105
   &configure ();
115
   &configure ();
106
}
116
}
107
117
108
118
109
119