View Issue Details

IDProjectCategoryView StatusLast Update
0000397fileGeneralpublic2022-10-27 19:20
Reporterdadv Assigned Tochristos  
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionreopened 
Product Version5.43 
Fixed in Version5.44 
Summary0000397: Regression in mode -f- (stdin)
DescriptionUpto file-5.42 an application may popen("file -bnf-"), feed it with filenames and get results immediately.
For example:

(echo /lib/libc.so.7; sleep 3600) | file -bnf -

Such command prints result immediately with file-5.42.
file-5.43 does not print result immediately.

It was broken with following commit:
https://github.com/file/file/commit/19bf47777d0002ee884467e45e6ace702e40a4c1

Rollback of that commit fixes the regression.
Steps To ReproduceSee above.
Additional InformationThe problem is serious as it breaks application that continuously feed "file -bnf-" with filenames and expect results at once, before EOF.
Tagsregression

Activities

christos

2022-10-23 14:23

manager   ~0003845

Added -I flag to address this.

dadv

2022-10-23 20:18

reporter   ~0003846

Thank you very much for prompt response. Sadly, new flag still does not restore breakage of existing applications that rely on previous behaviour that existed for long time; applications would need to be modified and its is not always possible.

Please consider adding new flag for new behaviour instead, so that "file -bnf-" would behave as before.

christos

2022-10-24 20:19

manager   ~0003848

I am guessing that there are very few applications that depend on this behavior (which was not guaranteed anyway). I think that it is better to have consistent output between:

      cat foo | file -f -
and
      file -f foo

as opposed to having them be different by default. If you want immediate results and inconsistent output, you should be explicit about it. Now that I think about it, there is nothing special about -f - vs -f /dev/stdin, so I better fix it to be also consistent.

dadv

2022-10-25 02:07

reporter   ~0003849

Such applications do exist, nevertheless. Now they cannot just run "file" with same set of flags for any operating system, because different systems will have different "file" versions with different default behaviour for considerable time.

# echo my.cnf | file -bnIf -
file: invalid option -- I
ASCII text
Usage: file [-bcCdEhikLlNnprsSvzZ0] [--apple] [--extension] [--mime-encoding]
            [--mime-type] [-e <testname>] [-F <separator>] [-f <namefile>]
            [-m <magicfiles>] [-P <parameter=value>] [--exclude-quiet]
            <file> ...
       file -C [-m <magicfiles>]
       file [--help]

christos

2022-10-25 22:25

manager   ~0003850

I am not very sympathetic of such apps. They could easily be converted to use libmagic. Running commands needlessly causes security issues (for example filenames with \n in them will not be processed correctly.

dadv

2022-10-26 08:21

reporter   ~0003851

From the manual page:

     -n, --no-buffer
             Force stdout to be flushed after checking each file. This is
             only useful if checking a list of files. It is intended to be
             used by programs that want filetype output from a pipe.

For me, it means that behaviour was "guaranteed".

christos

2022-10-26 16:57

manager   ~0003852

Here is a good point! I just used -n to restore the previous behavior and removed -I.

dadv

2022-10-27 01:59

reporter   ~0003854

Thank you very much for this change. It really fixes compatibility. This PR can be closed now.

Issue History

Date Modified Username Field Change
2022-10-20 09:55 dadv New Issue
2022-10-20 09:55 dadv Tag Attached: regression
2022-10-23 14:23 christos Assigned To => christos
2022-10-23 14:23 christos Status new => assigned
2022-10-23 14:23 christos Status assigned => resolved
2022-10-23 14:23 christos Resolution open => fixed
2022-10-23 14:23 christos Fixed in Version => 5.44
2022-10-23 14:23 christos Note Added: 0003845
2022-10-23 20:18 dadv Status resolved => feedback
2022-10-23 20:18 dadv Resolution fixed => reopened
2022-10-23 20:18 dadv Note Added: 0003846
2022-10-24 20:19 christos Note Added: 0003848
2022-10-25 02:07 dadv Note Added: 0003849
2022-10-25 02:07 dadv Status feedback => assigned
2022-10-25 22:25 christos Note Added: 0003850
2022-10-26 08:21 dadv Note Added: 0003851
2022-10-26 16:57 christos Note Added: 0003852
2022-10-27 01:59 dadv Note Added: 0003854
2022-10-27 19:20 christos Status assigned => resolved