[MDEV-23697] not valid shebang Created: 2020-09-08  Updated: 2020-10-06  Resolved: 2020-09-23

Status: Closed
Project: MariaDB Server
Component/s: Scripts & Clients
Affects Version/s: 10.1.46, 10.2.33, 10.3.24, 10.4.14, 10.5.5
Fix Version/s: 10.1.48, 10.2.35, 10.3.26, 10.4.16, 10.5.7

Type: Bug Priority: Major
Reporter: Alexey Shabalin Assignee: Daniel Black
Resolution: Fixed Votes: 0
Labels: None


 Description   

Commit
mtr: use env for perl (37c88445e30d52c965bcb19b19fa710c3eb4fad9) has a error.
Several files have more 2 parts in shebang.
Shebang should contain 1 or 2 parts. Not 3 or more.

#!/usr/bin/perl

– valid

#!/usr/bin/perl -w

– valid

#!/usr/bin/env perl

– valid

#!/usr/bin/env perl -w

– not valid



 Comments   
Comment by Faustin Lammler [ 2020-09-23 ]

On Debian (mariadb 10.3.24), there is also a dependency problem, we install libdbd-mariadb-perl but mytop requires libdbd-mysql-perl.
See https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=970681.

Comment by Otto Kekäläinen [ 2020-09-23 ]

Just for the record, the perl -w option is to print out warnings and
should not be used in production:

https://manpages.debian.org/buster/perl-base/perl.1.en.html#DIAGNOSTICS
The "use warnings" pragma produces some lovely diagnostics. One
can also use the -w flag,
but its use is normally discouraged, because it gets applied to
all executed Perl code,
including that not under your control.

In 10.5.5 mytop is not using -w anymore. Only mariadb-report and some
test suite scripts and ColumnStore use -w (although ColumnStore is
alpha, so printing warnings there is I guess intentional).

The format "env perl" should not be used at all, it should always be "/usr/bin/perl" (at lest in Debian, https://www.debian.org/doc/debian-policy/ch-files.html#scripts) but for some reason it was reverted for innotop in https://github.com/MariaDB/server/commit/dbd1d7ea8e96a2b4cff89ec889494700d634b3a3

Comment by Daniel Black [ 2020-09-23 ]

env is a stop gap until a better universal detection mechanism for the path of perl is determined and replaced in each script, because its not all about Debian. I'll take a debian policy violation compared to 'perl not found' on another platform.

-w removed from all scripts. Looking at scripts, its questionable as to why those scripts are there.

debian scripts also get policy compliant version

--- a/debian/additions/mysqlreport
+++ b/debian/additions/mysqlreport
-#!/usr/bin/env perl -w
+#!/usr/bin/perl
 
--- a/debian/additions/innotop/innotop
+++ b/debian/additions/innotop/innotop
@@ -1,4 +1,4 @@
-#!/usr/bin/env perl
+#!/usr/bin/perl

Thanks for the bug report shaba

Comment by Otto Kekäläinen [ 2020-09-24 ]

> env is a stop gap until a better universal detection mechanism for the path of perl is determined
> and replaced in each script, because its not all about Debian. I'll take a debian policy violation compared to 'perl not found' on another platform.

Sure, it is not "all about Debian" but in my experience typically the things that end up in the Debian policy are pretty universal good practices. There were some comments in your commits about FreeBSD not supporting /usr/bin/perl but I did not find any details about FreeBSD's policy on this. According to https://lists.freebsd.org/pipermail/freebsd-ports/2013-October/087104.html FreeBSD has had /usr/bin/perl at least since 2013.

Generated at Thu Feb 08 09:24:21 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.