#935607 lintian: classify "Starting $DESC" / use of $VERBOSE (etc.) in init.d scripts

#935607#5
Date:
2019-08-24 13:36:48 UTC
From:
To:
(inspired by #658374)

Dear Maintainer,

some init.d script print description of service they are starting with
following line:

	log_daemon_msg "Starting X display manager" "xdm"
or
	log_action_begin_msg "Starting $DESC"

The pattern is `"Starting '. Some (minority, I think) do the same, but
only if $VERBOSE != no, like this:

	[ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"

Please add classification tag, that distinguish these cases. After that,
minority behaviour could be marked with minor severity tag, so
eventually all init.d scripts behave consistently.

Well, there is init-d-script(5) framework, that addresses many
consistency issues, but many init.d scripts do not use it. Converting
them is much more work then fixing one line in existing scripts.

No patch today, sorry.

#935607#10
Date:
2019-08-24 13:44:16 UTC
From:
To:
# marking as moreinfo simply for triage
tags 935607 + moreinfo
thanks

Hi Dmitry,

Can you describe what is wrong with this? (So we can add it to the
long description at the very least...)

Also, do we need to do this for "stop" or other actions too?

Just FYI what we prefer to do here is to mark it as 'experimental' but
the idea is the same (ie. fix false-positives first).


Regards,

#935607#17
Date:
2019-08-26 21:19:34 UTC
From:
To:
[ Should I tag '-moreinfo' on reply, or you prefer doing it yourself? ]

[2019-08-24 14:44] "Chris Lamb" <lamby@debian.org>

Both behaviours are fine, as long they are used consistently. Otherwise
they cause wierd output when $VERBOSE = no (see #658374).  For example
this output with VERBOSE=yes:

	Starting Foo # ignores VERBOSE
	Foo writes output on its own
	Starting Bar # checks VERBOSE
	Bar writes output on its own

turns into following confusing output with VERBOSE=no

	Starting Foo # ignores VERBOSE
	Foo writes output on its own
	Bar writes output on its own

which creats illusion that "Bar writes output on its own" is caused by
Foo.

Yes, this too. Thanks.

That is fine. Note, that both behaviours are correct, they just need to
be uniform. I'd avoid marking some behaviour as more preferable than
another, as long as we do not have data to say which is majority.

Hope it clarifies.

#935607#22
Date:
2019-08-27 09:23:51 UTC
From:
To:
Hi Dmitry,

Please. A wishlist bug with "moreinfo" means (at least for me) that it
is blocking on input from the reporter/requester and, if you believe
you have resolved all the outstanding queries, then it makes sense to
remove it so that it's easier to find things in the BTS that are ready
to be worked on. Does that make sense?

Oh, I think I see. Well, actually I was confused about this bug and
indeed am not sure enough to implement anything yet. The problem is
the use of the conditional checking of $VERBOSE, regardless of the
action?

I think what would be good is bunch of "good" and "bad" examples here
to help me be 100% sure.


Regards,

#935607#27
Date:
2019-08-28 16:16:25 UTC
From:
To:
control: tags -1 -moreinfo

[2019-08-27 10:23] "Chris Lamb" <lamby@debian.org>

Sure, it does. Just double-checked to not disrupt your workflow.

Again, there is no "good" and "bad" yet. Here is pseudo-code:

	for line in lines(/etc/init.d/script) {
		next unless if line =~ 'log daemon msg "(Starting|Stopping)';
		if line =~ '$VERBOSE' {
			classify 'do check for VERBOSE'
		} else {
			classify 'do NOT check for VERBOSE'
		}
	}

When we see, which of these styles is majority, we can proclaim other
unwanted and to be fixed.

#935607#38
Date:
2019-09-08 20:26:56 UTC
From:
To:
tags 935607 + moreinfo
retitle 935607 lintian: classify "Starting $DESC" / use of $VERBOSE (etc.) in init.d scripts
thanks

Hi Dmitry,

... but, unless I'm missing something you can surely do that now
almost trivially using codesearch.debian.net and certainly much
quicker, independetly and with less hassle than introducing two new
Lintian tags, etc.

I thus suggest you do that and come back to this bug when you/we have
a concrete implementation plan.


Regards,

#935607#43
Date:
2019-09-11 16:50:54 UTC
From:
To:
control: tags -1 -moreinfo

[2019-09-08 21:26] "Chris Lamb" <lamby@debian.org>

I should have thought about it myself. Codesearch gives following
result:

 1. search for literal `Starting $DESC' gives three pages of init
    scripts. Majority (but not overwhelming, around 2/3) of them do
    /not/ check for $VERBOSE.

    Not very representative, given there is ~1300 services in Debian.

 2. search for `log_daemon_msg "Starting' gives 85 pages, with around 2/3
    (eyeball estimate) not checking for $VERBOSE. This search covers 850
    init scripts, which is rather good part.

 3. search for literal `"Starting ' gives hundred of pages, most of them
    false-positive (logging in C code).

Not unanimous, but I believe that *checking* for $VERBOSE should be
marked as deprecated.

#935607#50
Date:
2019-09-21 11:28:39 UTC
From:
To:
Checking for VERBOSE explicitly in the init scripts seems like an
anti-pattern to me. We have the log functions precisely to hide this
kind of detail, instead of duplicating it all over the place. If
anything, these functions might need to honor VERBOSE, so then users
that want non-verbose output can set it appropriately.

Thanks,
Guillem

#935607#55
Date:
2019-09-21 18:21:28 UTC
From:
To:
Hi Guillem,

Indeed. However, I am unsure whether adding this tag would be very
useful given how many (apparently) true-positives it would raise:

https://codesearch.debian.net/search?q=%5C%24VERBOSE+path%3Adebian%2F*init&literal=0

Thoughts? Perhaps this just means we should add this as pedantic for
now?


Regards,