]> andersk Git - gssapi-openssh.git/blame - setup/setup-openssh.pl
Change delimiter in setup package name to underscores.
[gssapi-openssh.git] / setup / setup-openssh.pl
CommitLineData
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 14if (!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 26require Grid::GPT::Setup;
27
ad71c979 28my $globusdir = $gpath;
29my $setupdir = "$globusdir/setup/globus";
30my $myname = "setup-openssh.pl";
31
69534dfa 32print "$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";
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
48sub 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 =~ /(.*\/)*(.*)$/;
7536fc6f 96
97 #
98 # we really should create a random filename and make sure that it
99 # doesn't already exist (based off current time_t or something)
100 #
101
d0a1bda7 102 $g = "$f.tmp";
20d3226a 103
7536fc6f 104 #
105 # Grab the current mode/uid/gid for use later
106 #
107
108 $mode = (stat($f))[2];
109 $uid = (stat($f))[4];
110 $gid = (stat($f))[5];
111
53a54c67 112 $result = system("mv $f $g");
d0a1bda7 113 if ($result != 0)
20d3226a 114 {
d0a1bda7 115 die "Failed to copy $f to $g!\n";
20d3226a 116 }
20d3226a 117
d0a1bda7 118 open(IN, "<$g") || die ("$0: input file $g missing!\n");
119 open(OUT, ">$f") || die ("$0: unable to open output file $f!\n");
120
121 while (<IN>)
122 {
123 for $s (keys(%def))
20d3226a 124 {
d0a1bda7 125 s#$s#$def{$s}#;
126 } # for $s
127 print OUT "$_";
128 } # while <IN>
20d3226a 129
d0a1bda7 130 close(OUT);
20d3226a 131 close(IN);
d0a1bda7 132
133 $result = system("rm $g");
134 if ($result != 0)
135 {
136 die "Failed to remove $g\n";
137 }
7536fc6f 138
139 #
140 # An attempt to revert the new file back to the original file's
141 # mode/uid/gid
142 #
143
144 chmod($mode, $f);
145 chown($uid, $gid, $f);
20d3226a 146 } # for $f
147
148 return 0;
149}
150
151sub runkeygen
152{
4f276ad7 153 print "Generating ssh keys (if necessary)...\n";
20d3226a 154 if ( -e "${sysconfdir}/ssh_host_key" )
155 {
156 print "${sysconfdir}/ssh_host_key already exists, skipping.\n";
157 }
158 else
159 {
160 # if $sysconfdir/ssh_host_key doesn't exist..
161 system("$bindir/ssh-keygen -t rsa1 -f $sysconfdir/ssh_host_key -N \"\"");
162 }
163
164 if ( -e "${sysconfdir}/ssh_host_dsa_key" )
165 {
166 print "${sysconfdir}/ssh_host_dsa_key already exists, skipping.\n";
167 }
168 else
169 {
170 # if $sysconfdir/ssh_host_dsa_key doesn't exist..
171 system("$bindir/ssh-keygen -t dsa -f $sysconfdir/ssh_host_dsa_key -N \"\"");
172 }
173
174 if ( -e "${sysconfdir}/ssh_host_rsa_key" )
175 {
176 print "${sysconfdir}/ssh_host_rsa_key already exists, skipping.\n";
177 }
178 else
179 {
180 # if $sysconfdir/ssh_host_rsa_key doesn't exist..
181 system("$bindir/ssh-keygen -t rsa -f $sysconfdir/ssh_host_rsa_key -N \"\"");
182 }
183
184 return 0;
185}
186
187fixpaths();
20d3226a 188runkeygen();
ad71c979 189
472ec086 190my $metadata = new Grid::GPT::Setup(package_name => "gsi_openssh_setup");
4f276ad7 191
53a54c67 192$metadata->finish();
This page took 0.081968 seconds and 5 git commands to generate.