安装 logwatch 但出现 postfix 和依赖项错误

安装 logwatch 但出现 postfix 和依赖项错误

尝试在 Ubuntu 22.04 LTS 上安装 logwatch 时遇到问题。以下是尝试安装时的输出:

# apt install logwatch
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
logwatch is already the newest version (7.5.6-1ubuntu1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n]
Setting up postfix (3.6.4-1ubuntu1.1) ...
postconf: warning: open /etc/postfix/master.cf: No such file or directory
postconf: warning: open /etc/postfix/master.cf: No such file or directory
postconf: warning: open /etc/postfix/master.cf: No such file or directory
usermod: user 'postfix' does not exist in /etc/passwd
dpkg: error processing package postfix (--configure):
 installed postfix package post-installation script subprocess returned error exit status 6
dpkg: dependency problems prevent configuration of logwatch:
 logwatch depends on default-mta | mail-transport-agent; however:
  Package default-mta is not installed.
  Package postfix which provides default-mta is not configured yet.
  Package mail-transport-agent is not installed.
  Package postfix which provides mail-transport-agent is not configured yet.

dpkg: error processing package logwatch (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          Errors were encountered while processing:
 postfix
 logwatch
needrestart is being skipped since dpkg has failed
E: Sub-process /usr/bin/dpkg returned an error code (1)

我尝试安装依赖项,但同样遇到了 Postfix 错误。

# apt install postfix
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
postfix is already the newest version (3.6.4-1ubuntu1.1).
postfix set to manually installed.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n]
Setting up postfix (3.6.4-1ubuntu1.1) ...
postconf: warning: open /etc/postfix/master.cf: No such file or directory
postconf: warning: open /etc/postfix/master.cf: No such file or directory
postconf: warning: open /etc/postfix/master.cf: No such file or directory
usermod: user 'postfix' does not exist in /etc/passwd
dpkg: error processing package postfix (--configure):
 installed postfix package post-installation script subprocess returned error exit status 6
dpkg: dependency problems prevent configuration of logwatch:
 logwatch depends on default-mta | mail-transport-agent; however:
  Package default-mta is not installed.
  Package postfix which provides default-mta is not configured yet.
  Package mail-transport-agent is not installed.
  Package postfix which provides mail-transport-agent is not configured yet.

dpkg: error processing package logwatch (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          Errors were encountered while processing:
 postfix
 logwatch
needrestart is being skipped since dpkg has failed
E: Sub-process /usr/bin/dpkg returned an error code (1)

即使我尝试安装 default-mta,也会遇到同样的错误。在网络上搜索并尝试了许多不同的建议也没有用。作为最后的手段,我决定在这里创建这个问题。

# apt install default-mta
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Note, selecting 'postfix' instead of 'default-mta'
postfix is already the newest version (3.6.4-1ubuntu1.1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Do you want to continue? [Y/n]
Setting up postfix (3.6.4-1ubuntu1.1) ...
postconf: warning: open /etc/postfix/master.cf: No such file or directory
postconf: warning: open /etc/postfix/master.cf: No such file or directory
postconf: warning: open /etc/postfix/master.cf: No such file or directory
usermod: user 'postfix' does not exist in /etc/passwd
dpkg: error processing package postfix (--configure):
 installed postfix package post-installation script subprocess returned error exit status 6
dpkg: dependency problems prevent configuration of logwatch:
 logwatch depends on default-mta | mail-transport-agent; however:
  Package default-mta is not installed.
  Package postfix which provides default-mta is not configured yet.
  Package mail-transport-agent is not installed.
  Package postfix which provides mail-transport-agent is not configured yet.

dpkg: error processing package logwatch (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          Errors were encountered while processing:
 postfix
 logwatch
needrestart is being skipped since dpkg has failed
E: Sub-process /usr/bin/dpkg returned an error code (1)

编辑1:我按照以下命令建议进行尝试:

# dpkg --configure -a
dpkg: dependency problems prevent configuration of logwatch:
 logwatch depends on default-mta | mail-transport-agent; however:
  Package default-mta is not installed.
  Package postfix which provides default-mta is not configured yet.
  Package mail-transport-agent is not installed.
  Package postfix which provides mail-transport-agent is not configured yet.

dpkg: error processing package logwatch (--configure):
 dependency problems - leaving unconfigured
Errors were encountered while processing:
 logwatch
# apt autoremove
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up postfix (3.6.4-1ubuntu1.1) ...
usermod: user 'postfix' does not exist in /etc/passwd
dpkg: error processing package postfix (--configure):
 installed postfix package post-installation script subprocess returned error exit status 6
dpkg: dependency problems prevent configuration of logwatch:
 logwatch depends on default-mta | mail-transport-agent; however:
  Package default-mta is not installed.
  Package postfix which provides default-mta is not configured yet.
  Package mail-transport-agent is not installed.
  Package postfix which provides mail-transport-agent is not configured yet.

dpkg: error processing package logwatch (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          Errors were encountered while processing:
 postfix
 logwatch
needrestart is being skipped since dpkg has failed
E: Sub-process /usr/bin/dpkg returned an error code (1)
# apt install -f
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
2 not fully installed or removed.
After this operation, 0 B of additional disk space will be used.
Setting up postfix (3.6.4-1ubuntu1.1) ...
usermod: user 'postfix' does not exist in /etc/passwd
dpkg: error processing package postfix (--configure):
 installed postfix package post-installation script subprocess returned error exit status 6
dpkg: dependency problems prevent configuration of logwatch:
 logwatch depends on default-mta | mail-transport-agent; however:
  Package default-mta is not installed.
  Package postfix which provides default-mta is not configured yet.
  Package mail-transport-agent is not installed.
  Package postfix which provides mail-transport-agent is not configured yet.

dpkg: error processing package logwatch (--configure):
 dependency problems - leaving unconfigured
No apport report written because the error message indicates its a followup error from a previous failure.
                                                                                                          Errors were encountered while processing:
 postfix
 logwatch
needrestart is being skipped since dpkg has failed
E: Sub-process /usr/bin/dpkg returned an error code (1)

编辑2:这是命令的输出dpkg-reconfigure -a

# dpkg-reconfigure -a
Unknown option: a
Usage: dpkg-reconfigure [options] packages
  -u,  --unseen-only        Show only not yet seen questions.
       --default-priority   Use default priority instead of low.
       --force          Force reconfiguration of broken packages.
       --no-reload      Do not reload templates. (Use with caution.)
  -f,  --frontend       Specify debconf frontend to use.
  -p,  --priority       Specify minimum priority question to show.
       --terse          Enable terse mode.

答案1

好的,所以问题不在于 apt 或软件包本身。因为在这个系统上,我使用 SSSD 的 LDAP 身份验证,并且 postfix 已经是 LDAP 中的用户(执行id postfix会返回结果),所以 postfix 软件包无法创建 postfix 用户并抛出错误。

为了让其他人看到这个问题,我采取了如下措施来修复它:

  • 停止你的 SSSD:systemctl stop sssd.service
  • 删除损坏的安装:dpkg -r postfix&dpkg -r logwatch
  • 重新安装后缀:apt install postfix&apt install logwatch

就是这样!

相关内容