gen-preseed always errors

Bug #1848819 reported by Dennis Williamson on 2019-10-18
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
installation-report (Ubuntu)
Undecided
Unassigned

Bug Description

In this code:

```
# A bit of a hack..
my $di_path;
if (-d "/var/log/installer") {
    $di_path="/var/log/installer/cdebconf";
} else {
    $di_path="/var/log/debian-installer/cdebconf";
}

if (! -f "$di_path") {
    print("Unable to find debconf database: $di_path\n");
    exit(1);
}

Debconf::Db->load(readonly => "true");

$Debconf::Db::config=Debconf::Db->makedriver(
    driver => "File",
    name => "di_questions",
    filename => "$di_path/questions.dat",
    readonly => "true",
);
```

If `cdebconf` is a directory, the second `if` is true and the script exits with "Unable to find debconf database". Yet the `makedriver` instance(s) require `$di_path` to be set to a directory name (which contains files such as `questions.dat`.

If `cdebconf` is a file then the `! -f` test passes and `makedriver` tries to use a filename as a directory name and errors with a "could not open" message.

If `cdebconf` doesn't exist, then the `-! -f` test does the right thing.

In each of those cases, the script is exited and the remainder never runs.

To fix this issue, the test should be changed from `! -f` to `! -d`:

```
if (! -d "$di_path") {
    print("Unable to find debconf database: $di_path\n");
    exit(1);
}
```

As seen in Bionic and other releases.
```$ apt-cache policy installation-report
installation-report:
  Installed: 2.62ubuntu1
```

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers