Browse Source

This fixes a major bug which effected copying because of the logic employed.

Now enoent (unstripped binary) copies properly.  Uid/Gid for /home/user
will need to be handled either through a script which runs on first login,
or directly by the administrator, for now the adm will handle this, but
Replacement user/group are now preserved.  Unless user is in the hosts
group file this is how things need to be done.
master
freesource 23 years ago
parent
commit
a94c7537c3
  1. 50
      BootRoot/Yard.pm

50
BootRoot/Yard.pm

@ -1039,8 +1039,8 @@ sub copy_strip_file {
my $error; my $error;
if ($strippable{$from}) { if ($strippable{$from}) {
# Copy it stripped
# Copy it stripped
if ($strip_lib) { if ($strip_lib) {
if (defined($lib_needed_by{$from})) { if (defined($lib_needed_by{$from})) {
# It's a library # It's a library
@ -1053,36 +1053,26 @@ sub copy_strip_file {
sys("$objcopy --strip-debug $from $to"); sys("$objcopy --strip-debug $from $to");
} }
} }
# Copy file perms and owner
my($mode, $uid, $gid);
(undef, undef, $mode, undef, $uid, $gid) = stat $from;
my $from_base = basename($from);
chown($uid, $gid, $to) or ($error =
error("chown: $! \($from_base\)\n"));
##return "ERROR"if $error && $error eq "ERROR";
chmod($mode, $to) or ($error =
error("chmod: $! \($from_base\)\n"));
##return "ERROR"if $error && $error eq "ERROR";
} }
elsif ($strip_module) { if ($strip_module) {
if (defined($is_module{$from})) {
info(1, "Copy/stripping module $from to $to\n"); info(1, "Copy/stripping module $from to $to\n");
sys("$objcopy --strip-debug $from $to"); sys("$objcopy --strip-debug $from $to");
}
# Copy file perms and owner }
my($mode, $uid, $gid); if ($strip_bin) {
(undef, undef, $mode, undef, $uid, $gid) = stat $from; if (!defined($is_module{$from}) &&
my $from_base = basename($from); !defined($lib_needed_by{$from})) {
chown($uid, $gid, $to) or ($error =
error("chown: $! \($from_base\)\n"));
##return "ERROR"if $error && $error eq "ERROR";
chmod($mode, $to) or ($error =
error("chmod: $! \($from_base\)\n"));
return "ERROR"if $error && $error eq "ERROR";
} elsif ($strip_bin) {
# It's a binary executable # It's a binary executable
info(1, "Copy/stripping binary executable $from to $to\n"); info(1, "Copy/stripping binary executable $from to $to\n");
sys("$objcopy --strip-all $from $to"); sys("$objcopy --strip-all $from $to");
}
}
else { # fallback just in case
# Normal copy, no strip
info(1, "Copying $from to $to\n");
sys("cp -a $from $to");
}
# Copy file perms and owner # Copy file perms and owner
my($mode, $uid, $gid); my($mode, $uid, $gid);
@ -1090,19 +1080,15 @@ sub copy_strip_file {
my $from_base = basename($from); my $from_base = basename($from);
chown($uid, $gid, $to) or ($error = chown($uid, $gid, $to) or ($error =
error("chown: $! \($from_base\)\n")); error("chown: $! \($from_base\)\n"));
##return "ERROR"if $error && $error eq "ERROR"; return "ERROR"if $error && $error eq "ERROR";
chmod($mode, $to) or ($error = chmod($mode, $to) or ($error =
error("chmod: $! \($from_base\)\n")); error("chmod: $! \($from_base\)\n"));
return "ERROR"if $error && $error eq "ERROR"; return "ERROR"if $error && $error eq "ERROR";
} }
else { else {
# Normal copy, no strip # Normal copy, no strip
sys("cp $from $to"); info(1, "Copying $from to $to\n");
} sys("cp -a $from $to");
}
else {
# Normal copy, no strip
sys("cp $from $to");
} }
} }

Loading…
Cancel
Save