Commit 3f167217 authored by Kirk Webb's avatar Kirk Webb
Browse files

Update the use of realpath across all perl scripts

Change to use the realpath function in the 'Cwd' module instead of
calling realpath via the shell.  The shell command varies in its
reaction to a missing final path component.  On some platforms (Linux,
FBSD10+) realpath reports an error if the final component doesn't exist
on the filesystem.  On others (FBSD < 10), it does not report an error.

The perl function from 'Cwd' emulates the same behavior as FBSD prior to
version 10, which is the behavior the scripts expect.

From here on out, instead of using `realpath`, do the following:

use Cwd qw(realpath);
..
..
my $realpath = realpath($somepath);
parent 1aa8ec9b
......@@ -26,6 +26,7 @@ use strict;
use Getopt::Std;
use XML::Simple;
use Data::Dumper;
use Cwd qw(realpath);
#
# Create a new user from a XML description.
......@@ -168,7 +169,7 @@ if (! defined($this_user)) {
}
# Use realpath to resolve any symlinks.
my $translated = `realpath $xmlfile`;
my $translated = realpath($xmlfile);
if ($translated =~ /^(\/tmp\/[-\w\.\/]+)$/) {
$xmlfile = $1;
}
......@@ -310,7 +311,7 @@ if (exists($newproj_args{'newuser_xml'})) {
}
# Use realpath to resolve any symlinks.
my $translated = `realpath $newuser_xml`;
my $translated = realpath($newuser_xml);
if ($translated =~ /^(\/tmp\/[-\w\.\/]+)$/) {
$newuser_xml = $1;
}
......
......@@ -26,6 +26,7 @@ use strict;
use Getopt::Std;
use XML::Simple;
use Data::Dumper;
use Cwd qw(realpath);
#
# Create a new user from a XML description.
......@@ -148,7 +149,7 @@ else {
}
# Use realpath to resolve any symlinks.
my $translated = `realpath $xmlfile`;
my $translated = realpath($xmlfile);
if ($translated =~ /^(\/tmp\/[-\w\.\/]+)$/) {
$xmlfile = $1;
}
......
......@@ -26,6 +26,7 @@ use strict;
use Getopt::Std;
use XML::Simple;
use Data::Dumper;
use Cwd qw(realpath);
#
# Back-end script to change experiment info from an XML description.
......@@ -119,7 +120,7 @@ else {
}
# Use realpath to resolve any symlinks.
my $translated = `realpath $xmlfile`;
my $translated = realpath($xmlfile);
if ($translated =~ /^(\/tmp\/[-\w\.\/]+)$/) {
$xmlfile = $1;
}
......
......@@ -26,6 +26,7 @@ use strict;
use Getopt::Std;
use XML::Simple;
use Data::Dumper;
use Cwd qw(realpath);
#
# Back-end script to edit group membership.
......@@ -117,7 +118,7 @@ else {
}
# Use realpath to resolve any symlinks.
my $translated = `realpath $xmlfile`;
my $translated = realpath($xmlfile);
if ($translated =~ /^(\/tmp\/[-\w\.\/]+)$/) {
$xmlfile = $1;
}
......
......@@ -26,6 +26,7 @@ use strict;
use Getopt::Std;
use XML::Simple;
use Data::Dumper;
use Cwd qw(realpath);
#
# Back-end script to edit image descriptor.
......@@ -120,7 +121,7 @@ else {
}
# Use realpath to resolve any symlinks.
my $translated = `realpath $xmlfile`;
my $translated = realpath($xmlfile);
if ($translated =~ /^(\/tmp\/[-\w\.\/]+)$/) {
$xmlfile = $1;
}
......
......@@ -26,6 +26,7 @@ use strict;
use Getopt::Std;
use XML::Simple;
use Data::Dumper;
use Cwd qw(realpath);
#
# Back-end script to create or edit a nodetype.
......@@ -125,7 +126,7 @@ else {
}
# Use realpath to resolve any symlinks.
my $translated = `realpath $xmlfile`;
my $translated = realpath($xmlfile);
if ($translated =~ /^(\/tmp\/[-\w\.\/]+)$/) {
$xmlfile = $1;
}
......
......@@ -26,6 +26,7 @@ use strict;
use Getopt::Std;
use XML::Simple;
use Data::Dumper;
use Cwd qw(realpath);
#
# Back-end script to edit site variables.
......@@ -119,7 +120,7 @@ else {
}
# Use realpath to resolve any symlinks.
my $translated = `realpath $xmlfile`;
my $translated = realpath($xmlfile);
if ($translated =~ /^(\/tmp\/[-\w\.\/]+)$/) {
$xmlfile = $1;
}
......
......@@ -26,6 +26,7 @@ use strict;
use Getopt::Std;
use XML::Simple;
use Data::Dumper;
use Cwd qw(realpath);
#
# Change the user profile from a XML description.
......@@ -129,7 +130,7 @@ else {
}
# Use realpath to resolve any symlinks.
my $translated = `realpath $xmlfile`;
my $translated = realpath($xmlfile);
if ($translated =~ /^(\/tmp\/[-\w\.\/]+)$/) {
$xmlfile = $1;
}
......
......@@ -26,6 +26,7 @@ use strict;
use Getopt::Std;
use XML::Simple;
use Data::Dumper;
use Cwd qw(realpath);
#
# Back-end script to create a Project Group.
......@@ -123,7 +124,7 @@ else {
}
# Use realpath to resolve any symlinks.
my $translated = `realpath $xmlfile`;
my $translated = realpath($xmlfile);
if ($translated =~ /^(\/tmp\/[-\w\.\/]+)$/) {
$xmlfile = $1;
}
......
......@@ -26,6 +26,7 @@ use strict;
use Getopt::Std;
use XML::Simple;
use Data::Dumper;
use Cwd qw(realpath);
#
# Back-end script to create new Image descriptors (Long Form.)
......@@ -127,7 +128,7 @@ else {
}
# Use realpath to resolve any symlinks.
my $translated = `realpath $xmlfile`;
my $translated = realpath($xmlfile);
if ($translated =~ /^(\/tmp\/[-\w\.\/]+)$/) {
$xmlfile = $1;
}
......
......@@ -27,6 +27,7 @@ use Getopt::Std;
use XML::Simple;
use Data::Dumper;
use URI::Escape;
use Cwd qw(realpath);
#
# Back-end script to create new Image descriptors (EZ Form.)
......@@ -139,7 +140,7 @@ else {
}
# Use realpath to resolve any symlinks.
my $translated = `realpath $xmlfile`;
my $translated = realpath($xmlfile);
if ($translated =~ /^(\/tmp\/[-\w\.\/]+)$/) {
$xmlfile = $1;
}
......
......@@ -26,6 +26,7 @@ use strict;
use Getopt::Std;
use XML::Simple;
use Data::Dumper;
use Cwd qw(realpath);
#
# Back-end script to create a new Mailman list.
......@@ -120,7 +121,7 @@ else {
}
# Use realpath to resolve any symlinks.
my $translated = `realpath $xmlfile`;
my $translated = realpath($xmlfile);
if ($translated =~ /^(\/tmp\/[-\w\.\/]+)$/) {
$xmlfile = $1;
}
......
......@@ -26,6 +26,7 @@ use strict;
use Getopt::Std;
use XML::Simple;
use Data::Dumper;
use Cwd qw(realpath);
#
# Create a new osid from a XML description.
......@@ -119,7 +120,7 @@ else {
}
# Use realpath to resolve any symlinks.
my $translated = `realpath $xmlfile`;
my $translated = realpath($xmlfile);
if ($translated =~ /^(\/tmp\/[-\w\.\/]+)$/) {
$xmlfile = $1;
}
......
......@@ -28,6 +28,7 @@ use XML::Simple;
use Data::Dumper;
use IO::Handle;
use URI::Escape;
use Cwd qw(realpath);
#
# Create a new node from a XML description.
......@@ -140,7 +141,7 @@ else {
}
# Use realpath to resolve any symlinks.
my $translated = `realpath $xmlfile`;
my $translated = realpath($xmlfile);
if ($translated =~ /^(\/tmp\/[-\w\.\/]+)$/) {
$xmlfile = $1;
}
......
......@@ -158,6 +158,7 @@ use lib '@srcdir@';
use English;
use libinstall;
use Getopt::Std;
use Cwd qw(realpath);
#
# Handle command-line options
......@@ -329,7 +330,7 @@ Phase "patches", "Applying patches", sub {
};
Phase "Mysql.pm.patch", "Patching Mysql.pm", sub {
my $patchfile = $MYSQL_PM_PATCH;
$patchfile = `realpath $patchfile`;
$patchfile = realpath($patchfile);
chomp $patchfile;
my $dir;
......
......@@ -369,6 +369,7 @@ use lib '@srcdir@';
use English;
use libinstall;
use Getopt::Std;
use Cwd qw(realpath);
#
# Handle command-line options
......@@ -799,7 +800,7 @@ Phase "patches", "Applying patches", sub {
if ($FBSD_MAJOR < 8) {
Phase "Mysql.pm.patch", "Patching Mysql.pm", sub {
my $patchfile = $MYSQL_PM_PATCH;
$patchfile = `realpath $patchfile`;
$patchfile = realpath($patchfile);
chomp $patchfile;
my $dir;
......@@ -1291,7 +1292,7 @@ Phase "exports", "Setting up exports", sub {
else {
@dirs = @EXPORTDIRS;
}
@dirs = map {`realpath $_`} @dirs;
@dirs = map {realpath($_)} @dirs;
chomp @dirs;
my %filesystems;
foreach my $dir (@dirs) {
......@@ -1315,7 +1316,7 @@ Phase "exports", "Setting up exports", sub {
# /share is special. We want to export to boss read-write,
# but to the control network read-only.
#
my $realdir = `realpath $SHAREROOT`;
my $realdir = realpath($SHAREROOT);
chomp($realdir);
push(@exports_lines,
"$realdir\t$BOSSNODE -maproot=root");
......
......@@ -73,6 +73,7 @@ use lib '@srcdir@';
use English;
use libinstall;
use Getopt::Std;
use Cwd qw(realpath);
#
# Handle command-line options
......@@ -261,7 +262,7 @@ Phase "dirs", "Setting directory permissions", sub {
PhaseFail("Directory $dir does not exist");
}
# Use the real path, to avoid symlink problems
my $realdir = `realpath $dir`;
my $realdir = realpath($dir);
chomp $realdir;
my ($mode,$group) = (stat($realdir))[2,5];
# Fix up the mode (strip file type)
......@@ -378,7 +379,7 @@ Phase "exports", "Setting up exports", sub {
my %filesystems;
foreach my $dir (@MOUNTPOINTS) {
if ($dir ne $SHAREROOT) {
my $dir = `realpath $dir`;
my $dir = realpath($dir);
chomp($dir);
my $dev = (stat($dir))[0];
push @{$filesystems{$dev}}, $dir;
......@@ -399,7 +400,7 @@ Phase "exports", "Setting up exports", sub {
# /share is special. We want to export to boss/ops read-write,
# but to the control network read-only.
#
my $realdir = `realpath $SHAREROOT`;
my $realdir = realpath($SHAREROOT);
chomp($realdir);
push(@exports_lines,
"$realdir\t$BOSSNODE $USERNODE -maproot=root");
......
......@@ -99,6 +99,7 @@ use lib '@srcdir@';
use English;
use libinstall;
use Getopt::Std;
use Cwd qw(realpath);
#
# Handle command-line options
......@@ -377,7 +378,7 @@ Phase "dirs", "Setting directory permissions", sub {
PhaseFail("Directory $dir does not exist");
}
# Use the real path, to avoid symlink problems
my $realdir = `realpath $dir`;
my $realdir = realpath($dir);
chomp $realdir;
my ($mode,$group) = (stat($realdir))[2,5];
# Fix up the mode (strip file type)
......@@ -789,7 +790,7 @@ Phase "exports", "Setting up exports", sub {
if ($ISFS) {
@dirs = (grep(!/^$SHAREROOT$/, @MOUNTPOINTS), @dirs);
}
@dirs = map {`realpath $_`} @dirs;
@dirs = map {realpath($_)} @dirs;
chomp @dirs;
my %filesystems;
foreach my $dir (@dirs) {
......@@ -812,7 +813,7 @@ Phase "exports", "Setting up exports", sub {
# /share is special. We want to export to boss read-write,
# but to the control network read-only.
#
my $realdir = `realpath $SHAREROOT`;
my $realdir = realpath($SHAREROOT);
chomp($realdir);
push(@exports_lines,
"$realdir\t$BOSSNODE -maproot=root");
......
......@@ -4,6 +4,7 @@
use strict;
use libinstall;
use installvars;
use Cwd qw(realpath);
sub Install($$$)
{
......@@ -42,7 +43,7 @@ sub Install($$$)
if ($FBSD_MAJOR < 8) {
Phase "Mysql.pm.patch", "Patching Mysql.pm", sub {
my $patchfile = $MYSQL_PM_PATCH;
$patchfile = `realpath $patchfile`;
$patchfile = realpath($patchfile);
chomp $patchfile;
my $dir;
......
......@@ -4,6 +4,7 @@
use strict;
use libinstall;
use installvars;
use Cwd qw(realpath);
sub Install($$$)
{
......@@ -40,7 +41,7 @@ sub Install($$$)
PhaseFail("Directory $dir does not exist");
}
# Use the real path, to avoid symlink problems
my $realdir = `realpath $dir`;
my $realdir = realpath($dir);
chomp $realdir;
my ($mode,$group) = (stat($realdir))[2,5];
# Fix up the mode (strip file type)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment