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.
7 # Large parts adapted from 'fixpath', a tool found in openssh-3.0.2p1.
9 # Send comments/fixes/suggestions to:
10 # Chase Phillips <cphillip@ncsa.uiuc.edu>
13 $gpath = $ENV{GLOBUS_LOCATION};
16 die "GLOBUS_LOCATION needs to be set before running this script"
20 # i'm including this because other perl scripts in the gpt setup directories
24 @INC = (@INC, "$gpath/lib/perl");
26 require Grid::GPT::Setup;
28 my $globusdir = $gpath;
29 my $setupdir = "$globusdir/setup/globus";
30 my $myname = "setup-openssh.pl";
32 print "$myname: Configuring package 'gsi-openssh'\n";
35 # Set up path prefixes for use in the path translations
38 $prefix = ${globusdir};
39 $exec_prefix = "${prefix}";
40 $bindir = "${exec_prefix}/bin";
41 $mandir = "${prefix}/man";
43 $libexecdir = "${exec_prefix}/libexec";
44 $sysconfdir = "${prefix}/etc";
46 $xauth_path = "/usr/bin/X11/xauth";
51 # Set up path translations for the installation files
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}",
68 "/path/to/scp.real" => "${bindir}/scp.real",
69 "/path/to/ssh" => "${bindir}/ssh",
73 # Files on which to perform path translations
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",
92 print "Translating strings in config/man files...\n";
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)
105 # Grab the current mode/uid/gid for use later
108 $mode = (stat($f))[2];
109 $uid = (stat($f))[4];
110 $gid = (stat($f))[5];
112 $result = system("mv $f $g");
115 die "Failed to copy $f to $g!\n";
118 open(IN, "<$g") || die ("$0: input file $g missing!\n");
119 open(OUT, ">$f") || die ("$0: unable to open output file $f!\n");
133 $result = system("rm $g");
136 die "Failed to remove $g\n";
140 # An attempt to revert the new file back to the original file's
145 chown($uid, $gid, $f);
153 print "Generating ssh keys (if necessary)...\n";
154 if ( -e "${sysconfdir}/ssh_host_key" )
156 print "${sysconfdir}/ssh_host_key already exists, skipping.\n";
160 # if $sysconfdir/ssh_host_key doesn't exist..
161 system("$bindir/ssh-keygen -t rsa1 -f $sysconfdir/ssh_host_key -N \"\"");
164 if ( -e "${sysconfdir}/ssh_host_dsa_key" )
166 print "${sysconfdir}/ssh_host_dsa_key already exists, skipping.\n";
170 # if $sysconfdir/ssh_host_dsa_key doesn't exist..
171 system("$bindir/ssh-keygen -t dsa -f $sysconfdir/ssh_host_dsa_key -N \"\"");
174 if ( -e "${sysconfdir}/ssh_host_rsa_key" )
176 print "${sysconfdir}/ssh_host_rsa_key already exists, skipping.\n";
180 # if $sysconfdir/ssh_host_rsa_key doesn't exist..
181 system("$bindir/ssh-keygen -t rsa -f $sysconfdir/ssh_host_rsa_key -N \"\"");
190 my $metadata = new Grid::GPT::Setup(package_name => "gsi-openssh-setup");