Author: guillem
Date: 2007-01-11 13:16:51 +0100 (Thu, 11 Jan 2007)
New Revision: 623

Modified:
   trunk/ChangeLog
   trunk/debian/changelog
   trunk/scripts/controllib.pl
   trunk/scripts/dpkg-distaddfile.pl
   trunk/scripts/dpkg-gencontrol.pl
   trunk/scripts/dpkg-shlibdeps.pl
   trunk/scripts/dpkg-source.pl
Log:
Move retrieval of uid and gid information from controllib.pl into a
function, so that scripts not needing it do not execute that code.
Based on a patch by Riku Voipio. Closes: #396884


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog     2007-01-09 22:07:16 UTC (rev 622)
+++ trunk/ChangeLog     2007-01-11 12:16:51 UTC (rev 623)
@@ -1,3 +1,14 @@
+2007-01-11  Riku Voipio <[EMAIL PROTECTED]>
+           Guillem Jover <[EMAIL PROTECTED]>
+
+       * scripts/controllib.pl: Move the getlogin and fowner initialization
+       to ...
+       (getfowner): ...here. New function.
+       * scripts/dpkg-source.pl: Use getfowner() instead of @fowner.
+       * scripts/dpkg-gencontrol.pl: Likewise.
+       * scripts/dpkg-distaddfile.pl: Likewise.
+       * scripts/dpkg-shlibdeps.pl: Likewise.
+
 2007-01-10  Julian Gilbey  <[EMAIL PROTECTED]>
 
        * scripts/dpkg-buildpackage.sh: Allow '-b' to properly override a

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog      2007-01-09 22:07:16 UTC (rev 622)
+++ trunk/debian/changelog      2007-01-11 12:16:51 UTC (rev 623)
@@ -5,6 +5,9 @@
     one in the source. Thanks to Nicolas François. Closes: #379320
   * Allow dpkg-buildpackage to properly override '-b' when passed after '-B'.
     Thanks to Julian Gilbey. Closes: #397479
+  * Move retrieval of uid and gid information from controllib.pl into a
+    function, so that scripts not needing it do not execute that code.
+    Based on a patch by Riku Voipio. Closes: #396884
 
  -- Guillem Jover <[EMAIL PROTECTED]>  Tue,  9 Jan 2007 22:48:47 +0200
 

Modified: trunk/scripts/controllib.pl
===================================================================
--- trunk/scripts/controllib.pl 2007-01-09 22:07:16 UTC (rev 622)
+++ trunk/scripts/controllib.pl 2007-01-11 12:16:51 UTC (rev 623)
@@ -35,8 +35,10 @@
 
 $progname= $0; $progname= $& if $progname =~ m,[^/]+$,;
 
-$getlogin = getlogin();
-if(!defined($getlogin)) {
+sub getfowner
+{
+    $getlogin = getlogin();
+    if (!defined($getlogin)) {
        open(SAVEIN, "<&STDIN");
        close(STDIN);
        open(STDIN, "<&STDERR");
@@ -46,8 +48,8 @@
        close(STDIN);
        open(STDIN, "<&SAVEIN");
        close(SAVEIN);
-}
-if(!defined($getlogin)) {
+    }
+    if (!defined($getlogin)) {
        open(SAVEIN, "<&STDIN");
        close(STDIN);
        open(STDIN, "<&STDOUT");
@@ -57,20 +59,29 @@
        close(STDIN);
        open(STDIN, "<&SAVEIN");
        close(SAVEIN);
-}
+    }
 
-if (defined ($ENV{'LOGNAME'})) {
-    @fowner = getpwnam ($ENV{'LOGNAME'});
-    if (! @fowner) { die (sprintf (_g('unable to get login information for 
username "%s"'), $ENV{'LOGNAME'})); }
-} elsif (defined ($getlogin)) {
-    @fowner = getpwnam ($getlogin);
-    if (! @fowner) { die (sprintf (_g('unable to get login information for 
username "%s"'), $getlogin)); }
-} else {
-    &warn (sprintf (_g('no utmp entry available and LOGNAME not defined; using 
uid of process (%d)'), $<));
-    @fowner = getpwuid ($<);
-    if (! @fowner) { die (sprintf (_g('unable to get login information for uid 
%d'), $<)); }
+    if (defined($ENV{'LOGNAME'})) {
+       @fowner = getpwnam($ENV{'LOGNAME'});
+       if ([EMAIL PROTECTED]) {
+           die(sprintf(_g('unable to get login information for username 
"%s"'), $ENV{'LOGNAME'}));
+       }
+    } elsif (defined($getlogin)) {
+       @fowner = getpwnam($getlogin);
+       if ([EMAIL PROTECTED]) {
+           die(sprintf(_g('unable to get login information for username 
"%s"'), $getlogin));
+       }
+    } else {
+       &warn (sprintf(_g('no utmp entry available and LOGNAME not defined; 
using uid of process (%d)'), $<));
+       @fowner = getpwuid($<);
+       if ([EMAIL PROTECTED]) {
+           die (sprintf(_g('unable to get login information for uid %d'), $<));
+       }
+    }
+    @fowner = @fowner[2,3];
+
+    return @fowner;
 }
[EMAIL PROTECTED] = @fowner[2,3];
 
 sub capit {
     my @pieces = map { ucfirst(lc) } split /-/, $_[0];

Modified: trunk/scripts/dpkg-distaddfile.pl
===================================================================
--- trunk/scripts/dpkg-distaddfile.pl   2007-01-09 22:07:16 UTC (rev 622)
+++ trunk/scripts/dpkg-distaddfile.pl   2007-01-11 12:16:51 UTC (rev 623)
@@ -60,7 +60,7 @@
 
 $fileslistfile="./$fileslistfile" if $fileslistfile =~ m/^\s/;
 open(Y,"> $fileslistfile.new") || &syserr(_g("open new files list file"));
-chown(@fowner, "$fileslistfile.new") 
+chown(getfowner(), "$fileslistfile.new") 
                || &syserr(_g("chown new files list file"));
 if (open(X,"< $fileslistfile")) {
     while (<X>) {

Modified: trunk/scripts/dpkg-gencontrol.pl
===================================================================
--- trunk/scripts/dpkg-gencontrol.pl    2007-01-09 22:07:16 UTC (rev 622)
+++ trunk/scripts/dpkg-gencontrol.pl    2007-01-11 12:16:51 UTC (rev 623)
@@ -255,7 +255,7 @@
 $fileslistfile="./$fileslistfile" if $fileslistfile =~ m/^\s/;
 open(Y,"> $fileslistfile.new") || &syserr(_g("open new files list file"));
 binmode(Y);
-chown(@fowner, "$fileslistfile.new") 
+chown(getfowner(), "$fileslistfile.new") 
                || &syserr(_g("chown new files list file"));
 if (open(X,"< $fileslistfile")) {
     binmode(X);

Modified: trunk/scripts/dpkg-shlibdeps.pl
===================================================================
--- trunk/scripts/dpkg-shlibdeps.pl     2007-01-09 22:07:16 UTC (rev 622)
+++ trunk/scripts/dpkg-shlibdeps.pl     2007-01-11 12:16:51 UTC (rev 623)
@@ -395,7 +395,7 @@
     open(Y,"> $varlistfile.new") ||
         syserr(sprintf(_g("open new substvars file \`%s'"), 
"$varlistfile.new"));
     unless ($REAL_USER_ID) {
-       chown(@fowner, "$varlistfile.new") ||
+       chown(getfowner(), "$varlistfile.new") ||
            syserr(sprintf(_g("chown of \`%s'"), "$varlistfile.new"));
     }
     if (open(X,"< $varlistfile")) {

Modified: trunk/scripts/dpkg-source.pl
===================================================================
--- trunk/scripts/dpkg-source.pl        2007-01-09 22:07:16 UTC (rev 622)
+++ trunk/scripts/dpkg-source.pl        2007-01-11 12:16:51 UTC (rev 623)
@@ -749,7 +749,7 @@
        system "chmod", "g-s", $tmp;
        printf(_g("%s: unpacking %s")."\n", $progname, $tarfile);
        extracttar("$dscdir/$tarfile",$tmp,$t);
-       system "chown", '-R', '-f', join(':',@fowner), "$tmp/$t";
+       system "chown", '-R', '-f', join(':', getfowner()), "$tmp/$t";
        rename("$tmp/$t",$target)
            || &syserr(sprintf(_g("unable to rename `%s' to `%s'"), "$tmp/$t", 
$target));
        rmdir($tmp)


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to