]>
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 | ||
9ef2f439 | 32 | print "$myname: Configuring package 'gsi_openssh'...\n"; |
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"; | |
7c25a6d7 | 41 | $sbindir = "${exec_prefix}/sbin"; |
d0a1bda7 | 42 | $mandir = "${prefix}/man"; |
43 | $mansubdir = "man"; | |
44 | $libexecdir = "${exec_prefix}/libexec"; | |
45 | $sysconfdir = "${prefix}/etc"; | |
20d3226a | 46 | $piddir = "/var/run"; |
47 | $xauth_path = "/usr/bin/X11/xauth"; | |
48 | ||
49 | sub fixpaths | |
50 | { | |
51 | # | |
52 | # Set up path translations for the installation files | |
53 | # | |
54 | ||
55 | %def = ( | |
56 | "/etc/ssh_config" => "${sysconfdir}/ssh_config", | |
57 | "/etc/ssh_known_hosts" => "${sysconfdir}/ssh_known_hosts", | |
58 | "/etc/sshd_config" => "${sysconfdir}/sshd_config", | |
59 | "/usr/libexec" => "${libexecdir}", | |
60 | "/etc/shosts.equiv" => "${sysconfdir}/shosts.equiv", | |
61 | "/etc/ssh_host_key" => "${sysconfdir}/ssh_host_key", | |
62 | "/etc/ssh_host_dsa_key" => "${sysconfdir}/ssh_host_dsa_key", | |
63 | "/etc/ssh_host_rsa_key" => "${sysconfdir}/ssh_host_rsa_key", | |
64 | "/var/run/sshd.pid" => "${piddir}/sshd.pid", | |
65 | "/etc/moduli" => "${sysconfdir}/moduli", | |
66 | "/etc/sshrc" => "${sysconfdir}/sshrc", | |
67 | "/usr/X11R6/bin/xauth" => "${xauth_path}", | |
68 | "/usr/bin:/bin:/usr/sbin:/sbin" => "/usr/bin:/bin:/usr/sbin:/sbin:${bindir}", | |
24dd10ef | 69 | "/path/to/scp.real" => "${bindir}/scp.real", |
70 | "/path/to/ssh" => "${bindir}/ssh", | |
7c25a6d7 | 71 | "/path/to/sftp.real" => "${bindir}/sftp.real", |
72 | "/path/to/sshd.real" => "${sbindir}/sshd.real", | |
73 | "/path/to/ssh_config" => "${sysconfdir}/ssh_config", | |
74 | "/path/to/sshd_config" => "${sysconfdir}/sshd_config", | |
20d3226a | 75 | ); |
76 | ||
20d3226a | 77 | # |
78 | # Files on which to perform path translations | |
79 | # | |
80 | ||
81 | @files = ( | |
24dd10ef | 82 | "${bindir}/scp", |
7c25a6d7 | 83 | "${bindir}/sftp", |
84 | "${sbindir}/sshd", | |
d0a1bda7 | 85 | "${sysconfdir}/ssh_config", |
86 | "${sysconfdir}/sshd_config", | |
87 | "${sysconfdir}/moduli", | |
88 | "${mandir}/${mansubdir}1/scp.1", | |
89 | "${mandir}/${mansubdir}1/ssh-add.1", | |
90 | "${mandir}/${mansubdir}1/ssh-agent.1", | |
91 | "${mandir}/${mansubdir}1/ssh-keygen.1", | |
92 | "${mandir}/${mansubdir}1/ssh-keyscan.1", | |
93 | "${mandir}/${mansubdir}1/ssh.1", | |
94 | "${mandir}/${mansubdir}8/sshd.8", | |
95 | "${mandir}/${mansubdir}8/sftp-server.8", | |
96 | "${mandir}/${mansubdir}1/sftp.1", | |
20d3226a | 97 | ); |
98 | ||
4f276ad7 | 99 | print "Translating strings in config/man files...\n"; |
20d3226a | 100 | for $f (@files) |
101 | { | |
102 | $f =~ /(.*\/)*(.*)$/; | |
7536fc6f | 103 | |
104 | # | |
105 | # we really should create a random filename and make sure that it | |
106 | # doesn't already exist (based off current time_t or something) | |
107 | # | |
108 | ||
d0a1bda7 | 109 | $g = "$f.tmp"; |
20d3226a | 110 | |
7536fc6f | 111 | # |
112 | # Grab the current mode/uid/gid for use later | |
113 | # | |
114 | ||
115 | $mode = (stat($f))[2]; | |
116 | $uid = (stat($f))[4]; | |
117 | $gid = (stat($f))[5]; | |
118 | ||
53a54c67 | 119 | $result = system("mv $f $g"); |
d0a1bda7 | 120 | if ($result != 0) |
20d3226a | 121 | { |
d0a1bda7 | 122 | die "Failed to copy $f to $g!\n"; |
20d3226a | 123 | } |
20d3226a | 124 | |
d0a1bda7 | 125 | open(IN, "<$g") || die ("$0: input file $g missing!\n"); |
126 | open(OUT, ">$f") || die ("$0: unable to open output file $f!\n"); | |
127 | ||
128 | while (<IN>) | |
129 | { | |
130 | for $s (keys(%def)) | |
20d3226a | 131 | { |
d0a1bda7 | 132 | s#$s#$def{$s}#; |
133 | } # for $s | |
134 | print OUT "$_"; | |
135 | } # while <IN> | |
20d3226a | 136 | |
d0a1bda7 | 137 | close(OUT); |
20d3226a | 138 | close(IN); |
d0a1bda7 | 139 | |
140 | $result = system("rm $g"); | |
141 | if ($result != 0) | |
142 | { | |
143 | die "Failed to remove $g\n"; | |
144 | } | |
7536fc6f | 145 | |
146 | # | |
147 | # An attempt to revert the new file back to the original file's | |
148 | # mode/uid/gid | |
149 | # | |
150 | ||
151 | chmod($mode, $f); | |
152 | chown($uid, $gid, $f); | |
20d3226a | 153 | } # for $f |
154 | ||
155 | return 0; | |
156 | } | |
157 | ||
20d3226a | 158 | fixpaths(); |
7c25a6d7 | 159 | |
160 | print "---------------------------------------------------------------------\n"; | |
161 | print "If you would also like to run the sshd binary that came with this\n"; | |
162 | print "package and you do not have host keys located in /etc, run (as root):\n"; | |
163 | print "\n"; | |
164 | print " $setupdir/setup-openssh-keys\n"; | |
165 | print "\n"; | |
166 | print "This script creates machine-specific host keys in /etc that are\n"; | |
167 | print "required by sshd.\n"; | |
168 | print "---------------------------------------------------------------------\n"; | |
ad71c979 | 169 | |
472ec086 | 170 | my $metadata = new Grid::GPT::Setup(package_name => "gsi_openssh_setup"); |
4f276ad7 | 171 | |
53a54c67 | 172 | $metadata->finish(); |
9ef2f439 | 173 | |
174 | print "$myname: Finished configuring package 'gsi_openssh'.\n"; |