function, so that scripts not needing it do not execute that code.
Based on a patch by Riku Voipio. Closes: #396884
+2007-01-11 Riku Voipio <riku.voipio@iki.fi>
+ Guillem Jover <guillem@debian.org>
+
+ * 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 <jdg@polya.uklinux.net>
* scripts/dpkg-buildpackage.sh: Allow '-b' to properly override a
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 <guillem@debian.org> Tue, 9 Jan 2007 22:48:47 +0200
$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");
close(STDIN);
open(STDIN, "<&SAVEIN");
close(SAVEIN);
-}
-if(!defined($getlogin)) {
+ }
+ if (!defined($getlogin)) {
open(SAVEIN, "<&STDIN");
close(STDIN);
open(STDIN, "<&STDOUT");
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'), $<));
+ }
+ }
+ @fowner = @fowner[2,3];
-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'), $<)); }
+ return @fowner;
}
-@fowner = @fowner[2,3];
sub capit {
my @pieces = map { ucfirst(lc) } split /-/, $_[0];
$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>) {
$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);
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")) {
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)