]>
Commit | Line | Data |
---|---|---|
20d3226a | 1 | # |
1eab725d | 2 | # setup-openssh.pl: |
3 | # Adapts the installed gsi-ssh environment to the current machine, | |
4 | # performing actions that originally occurred during the package's | |
5 | # 'make install' phase. | |
701aa556 | 6 | # |
1eab725d | 7 | # Large parts adapted from 'fixpath', a tool found in openssh-3.0.2p1. |
8 | # | |
9 | # Send comments/fixes/suggestions to: | |
10 | # Chase Phillips <cphillip@ncsa.uiuc.edu> | |
701aa556 | 11 | # |
20d3226a | 12 | |
4f276ad7 | 13 | $gpath = $ENV{GLOBUS_LOCATION}; |
ad71c979 | 14 | if (!defined($gpath)) |
15 | { | |
53a54c67 | 16 | die "GLOBUS_LOCATION needs to be set before running this script" |
ad71c979 | 17 | } |
18 | ||
19 | # | |
20 | # i'm including this because other perl scripts in the gpt setup directories | |
21 | # do so | |
22 | # | |
23 | ||
24 | @INC = (@INC, "$gpath/lib/perl"); | |
25 | ||
4f276ad7 | 26 | require Grid::GPT::Setup; |
27 | ||
ad71c979 | 28 | my $globusdir = $gpath; |
29 | my $setupdir = "$globusdir/setup/globus"; | |
30 | my $myname = "setup-openssh.pl"; | |
31 | ||
4f276ad7 | 32 | print "$myname: Configuring gsi-openssh package"; |
ad71c979 | 33 | |
20d3226a | 34 | # |
35 | # Set up path prefixes for use in the path translations | |
36 | # | |
37 | ||
d0a1bda7 | 38 | $prefix = ${globusdir}; |
39 | $exec_prefix = "${prefix}"; | |
40 | $bindir = "${exec_prefix}/bin"; | |
41 | $mandir = "${prefix}/man"; | |
42 | $mansubdir = "man"; | |
43 | $libexecdir = "${exec_prefix}/libexec"; | |
44 | $sysconfdir = "${prefix}/etc"; | |
20d3226a | 45 | $piddir = "/var/run"; |
46 | $xauth_path = "/usr/bin/X11/xauth"; | |
47 | ||
48 | sub fixpaths | |
49 | { | |
50 | # | |
51 | # Set up path translations for the installation files | |
52 | # | |
53 | ||
54 | %def = ( | |
55 | "/etc/ssh_config" => "${sysconfdir}/ssh_config", | |
56 | "/etc/ssh_known_hosts" => "${sysconfdir}/ssh_known_hosts", | |
57 | "/etc/sshd_config" => "${sysconfdir}/sshd_config", | |
58 | "/usr/libexec" => "${libexecdir}", | |
59 | "/etc/shosts.equiv" => "${sysconfdir}/shosts.equiv", | |
60 | "/etc/ssh_host_key" => "${sysconfdir}/ssh_host_key", | |
61 | "/etc/ssh_host_dsa_key" => "${sysconfdir}/ssh_host_dsa_key", | |
62 | "/etc/ssh_host_rsa_key" => "${sysconfdir}/ssh_host_rsa_key", | |
63 | "/var/run/sshd.pid" => "${piddir}/sshd.pid", | |
64 | "/etc/moduli" => "${sysconfdir}/moduli", | |
65 | "/etc/sshrc" => "${sysconfdir}/sshrc", | |
66 | "/usr/X11R6/bin/xauth" => "${xauth_path}", | |
67 | "/usr/bin:/bin:/usr/sbin:/sbin" => "/usr/bin:/bin:/usr/sbin:/sbin:${bindir}", | |
24dd10ef | 68 | "/path/to/scp.real" => "${bindir}/scp.real", |
69 | "/path/to/ssh" => "${bindir}/ssh", | |
20d3226a | 70 | ); |
71 | ||
20d3226a | 72 | # |
73 | # Files on which to perform path translations | |
74 | # | |
75 | ||
76 | @files = ( | |
24dd10ef | 77 | "${bindir}/scp", |
d0a1bda7 | 78 | "${sysconfdir}/ssh_config", |
79 | "${sysconfdir}/sshd_config", | |
80 | "${sysconfdir}/moduli", | |
81 | "${mandir}/${mansubdir}1/scp.1", | |
82 | "${mandir}/${mansubdir}1/ssh-add.1", | |
83 | "${mandir}/${mansubdir}1/ssh-agent.1", | |
84 | "${mandir}/${mansubdir}1/ssh-keygen.1", | |
85 | "${mandir}/${mansubdir}1/ssh-keyscan.1", | |
86 | "${mandir}/${mansubdir}1/ssh.1", | |
87 | "${mandir}/${mansubdir}8/sshd.8", | |
88 | "${mandir}/${mansubdir}8/sftp-server.8", | |
89 | "${mandir}/${mansubdir}1/sftp.1", | |
20d3226a | 90 | ); |
91 | ||
4f276ad7 | 92 | print "Translating strings in config/man files...\n"; |
20d3226a | 93 | for $f (@files) |
94 | { | |
95 | $f =~ /(.*\/)*(.*)$/; | |
d0a1bda7 | 96 | $g = "$f.tmp"; |
20d3226a | 97 | |
53a54c67 | 98 | $result = system("mv $f $g"); |
d0a1bda7 | 99 | if ($result != 0) |
20d3226a | 100 | { |
d0a1bda7 | 101 | die "Failed to copy $f to $g!\n"; |
20d3226a | 102 | } |
20d3226a | 103 | |
d0a1bda7 | 104 | open(IN, "<$g") || die ("$0: input file $g missing!\n"); |
105 | open(OUT, ">$f") || die ("$0: unable to open output file $f!\n"); | |
106 | ||
107 | while (<IN>) | |
108 | { | |
109 | for $s (keys(%def)) | |
20d3226a | 110 | { |
d0a1bda7 | 111 | s#$s#$def{$s}#; |
112 | } # for $s | |
113 | print OUT "$_"; | |
114 | } # while <IN> | |
20d3226a | 115 | |
d0a1bda7 | 116 | close(OUT); |
20d3226a | 117 | close(IN); |
d0a1bda7 | 118 | |
119 | $result = system("rm $g"); | |
120 | if ($result != 0) | |
121 | { | |
122 | die "Failed to remove $g\n"; | |
123 | } | |
20d3226a | 124 | } # for $f |
125 | ||
126 | return 0; | |
127 | } | |
128 | ||
129 | sub runkeygen | |
130 | { | |
4f276ad7 | 131 | print "Generating ssh keys (if necessary)...\n"; |
20d3226a | 132 | if ( -e "${sysconfdir}/ssh_host_key" ) |
133 | { | |
134 | print "${sysconfdir}/ssh_host_key already exists, skipping.\n"; | |
135 | } | |
136 | else | |
137 | { | |
138 | # if $sysconfdir/ssh_host_key doesn't exist.. | |
139 | system("$bindir/ssh-keygen -t rsa1 -f $sysconfdir/ssh_host_key -N \"\""); | |
140 | } | |
141 | ||
142 | if ( -e "${sysconfdir}/ssh_host_dsa_key" ) | |
143 | { | |
144 | print "${sysconfdir}/ssh_host_dsa_key already exists, skipping.\n"; | |
145 | } | |
146 | else | |
147 | { | |
148 | # if $sysconfdir/ssh_host_dsa_key doesn't exist.. | |
149 | system("$bindir/ssh-keygen -t dsa -f $sysconfdir/ssh_host_dsa_key -N \"\""); | |
150 | } | |
151 | ||
152 | if ( -e "${sysconfdir}/ssh_host_rsa_key" ) | |
153 | { | |
154 | print "${sysconfdir}/ssh_host_rsa_key already exists, skipping.\n"; | |
155 | } | |
156 | else | |
157 | { | |
158 | # if $sysconfdir/ssh_host_rsa_key doesn't exist.. | |
159 | system("$bindir/ssh-keygen -t rsa -f $sysconfdir/ssh_host_rsa_key -N \"\""); | |
160 | } | |
161 | ||
162 | return 0; | |
163 | } | |
164 | ||
165 | fixpaths(); | |
20d3226a | 166 | runkeygen(); |
ad71c979 | 167 | |
4f276ad7 | 168 | my $metadata = new Grid::GPT::Setup(package_name => "gsi-openssh-setup"); |
169 | ||
53a54c67 | 170 | $metadata->finish(); |