Package: dh-make Version: 0.59 Severity: normal Tags: patch User: [email protected] Usertags: origin-ubuntu ubuntu-patch precise
The default display manager (LightDM) in Ubuntu 11.10 unfortunately has a bug whereby it doesn't set the LOGNAME environment variable (https://bugs.launchpad.net/bugs/875705). We found that (if DEBFULLNAME and DEBEMAIL are also unset) this causes dh_make to go haywire and spew lots of junk from /etc/passwd into debian/changelog and debian/control. While the display manager bug clearly ought to be fixed, dh_make could easily be more robust here. Patch follows. * Try the USER environment variable if LOGNAME is not set (LP: #875705). diff -Nru dh-make-0.59/dh_make dh-make-0.59ubuntu1/dh_make --- dh-make-0.59/dh_make 2011-06-19 01:27:43.000000000 +0100 +++ dh-make-0.59ubuntu1/dh_make 2011-10-22 22:45:40.000000000 +0100 @@ -264,6 +264,21 @@ } } +sub get_logname +{ + # lightdm in Ubuntu 11.10 does not set LOGNAME + # (https://bugs.launchpad.net/bugs/875705). Work around this by trying + # USER instead. + if (exists $ENV{LOGNAME}) + { + return $ENV{LOGNAME}; + } elsif (exists $ENV{USER}) { + return $ENV{USER}; + } else { + die "Cannot get username; neither LOGNAME nor USER is set in the environment!\n"; + } +} + sub get_username { my $tmpusername = ''; @@ -274,27 +289,28 @@ } return $tmpusername if ($tmpusername ne ""); + my $logname = get_logname(); if (-x '/usr/bin/getent') { - $tmpusername = qx(/usr/bin/getent passwd $ENV{LOGNAME}|awk -F: '\{ print \$5; \}' | cut -f1 -d,); + $tmpusername = qx(/usr/bin/getent passwd $logname|awk -F: '\{ print \$5; \}' | cut -f1 -d,); } chomp($tmpusername); return $tmpusername if ($tmpusername ne ""); - $tmpusername = qx(awk -F: -vUSER=$ENV{LOGNAME} '\$1 == USER \{ print \$5; \}' /etc/passwd | cut -f1 -d,); + $tmpusername = qx(awk -F: -vUSER=$logname '\$1 == USER \{ print \$5; \}' /etc/passwd | cut -f1 -d,); chomp($tmpusername); return $tmpusername if ($tmpusername ne ""); if (-x '/usr/bin/ypmatch') { - $tmpusername = qx(ypmatch $ENV{LOGNAME} passwd.byname|awk -F: '\{ print \$5; \}' | cut -f1 -d,); + $tmpusername = qx(ypmatch $logname passwd.byname|awk -F: '\{ print \$5; \}' | cut -f1 -d,); } chomp($tmpusername); return $tmpusername if ($tmpusername ne ""); if (-x '/usr/bin/ldapsearch') { - $tmpusername = [map {/^(?:gecos|cn): (.*)/} qx(ldapsearch -Q -LLL uid=$ENV{LOGNAME} gecos cn)]->[0]; + $tmpusername = [map {/^(?:gecos|cn): (.*)/} qx(ldapsearch -Q -LLL uid=$logname gecos cn)]->[0]; } chomp($tmpusername); return $tmpusername if ($tmpusername ne ""); @@ -306,13 +322,14 @@ { return $ENV{DEBEMAIL} if ($ENV{DEBEMAIL} ); return $ENV{EMAIL} if ($ENV{EMAIL} ); + my $logname = get_logname(); if (-x '/usr/bin/ldapsearch') { my $mail; - $mail = [map {/^mail: (.*)/ && $1} qx(ldapsearch -Q -LLL uid=$ENV{LOGNAME} mail)]->[0]; + $mail = [map {/^mail: (.*)/ && $1} qx(ldapsearch -Q -LLL uid=$logname mail)]->[0]; return $mail if $mail; } - if ($ENV{LOGNAME} ) + if ($logname ) { my $mailhost; if ( -e '/etc/mailname') @@ -322,7 +339,7 @@ } else { $mailhost='unknown'; } - return ($ENV{LOGNAME} . '@' . $mailhost); + return ($logname . '@' . $mailhost); } } Thanks, -- Colin Watson [[email protected]] -- To UNSUBSCRIBE, email to [email protected] with a subject of "unsubscribe". Trouble? Contact [email protected]

