From 85b9e8b042c1074cc422fe11886fa9dccf6c9858 Mon Sep 17 00:00:00 2001 From: joey Date: Thu, 25 Mar 2004 04:01:40 +0000 Subject: [PATCH] * Don't add line about permissions fixup code to postinst if there is not code to add. * Don't assume that just because we know of a user or are root, that files can go into the deb owned by that user, and come out right on install. Instead, assume that any non-root user will not be on the target system the rpm is installed on, and that it might be created in the preinst or something, so add permissions fixup code for all such users. --- Alien/Package/Deb.pm | 2 ++ Alien/Package/Rpm.pm | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Alien/Package/Deb.pm b/Alien/Package/Deb.pm index 373a2a1..02fdf7a 100644 --- a/Alien/Package/Deb.pm +++ b/Alien/Package/Deb.pm @@ -725,6 +725,8 @@ sub postinst { # If there is no postinst, let's make one up.. $postinst="#!/bin/sh\n" unless length $postinst; + return $postinst unless %$owninfo; + my ($firstline, $rest)=split(/\n/, $postinst, 2); if ($firstline !~ m/^#!\s*\/bin\/sh/) { print STDERR "warning: unable to add ownership fixup code to postinst as the postinst is not a shell script!\n"; diff --git a/Alien/Package/Rpm.pm b/Alien/Package/Rpm.pm index bc02716..144a434 100644 --- a/Alien/Package/Rpm.pm +++ b/Alien/Package/Rpm.pm @@ -202,12 +202,12 @@ sub unpack { my ($mode, $owner, $group, $file) = split(/ /, $_, 4); $mode = $mode & 07777; # remove filetype my $uid = getpwnam($owner); - if (! defined $uid || $> != 0) { + if (! defined $uid || $uid != 0) { $owninfo{$file}=$owner; $uid=0; } my $gid = getgrnam($group); - if (! defined $gid || $> != 0) { + if (! defined $gid || $gid != 0) { if (exists $owninfo{$file}) { $owninfo{$file}.=":$group"; }