kopano-dagent error 80040111

Hello Forum,

on a CentOS 6 server with php56, qmail and KC 8.5.8.2 I find this error in dagent.log for every incomming mail:

Thu Apr 19 21:53:30 2018: [26169] [error  ] virtual HRESULT M4LMsgServiceAdmin::ConfigureMsgService(const MAPIUID*, ULONG_PTR, ULONG, ULONG, const SPropValue*): MSGServiceEntry failed: logon failed (80040111)
Thu Apr 19 21:53:30 2018: [26169] [crit   ] CreateProfileTemp(): ConfigureMsgService failed 80040111: logon failed
Thu Apr 19 21:53:30 2018: [26169] [warning] CreateProfileTemp failed: 80040111: logon failed

Thu Apr 19 21:53:30 2018: [26169] [error  ] virtual HRESULT M4LMsgServiceAdmin::ConfigureMsgService(const MAPIUID*, ULONG_PTR, ULONG, ULONG, const SPropValue*): MSGServiceEntry failed: logon failed (80040111)
Thu Apr 19 21:53:30 2018: [26169] [crit   ] CreateProfileTemp(): ConfigureMsgService failed 80040111: logon failed
Thu Apr 19 21:53:30 2018: [26169] [warning] CreateProfileTemp failed: 80040111: logon failed

the file .qmail-default includes (USERNAME replaced):

| condredirect USERNAME-junkmail headermatch 'X-Spam-Status: Yes'
| /usr/sbin/kopano-dagent -q USERNAME ; if [ 0 -ne 0 ] ; then exit -1; else exit 99; fi;
./Maildir/

this is my dagent.cfg:

##############################################################
# DAGENT SETTINGS

# connection to the storage server
#server_socket = file:///var/run/kopano/server.sock

##############################################################
# DAGENT SSL LOGIN SETTINGS
# 
# Note: server_socket must be set to https://servername:portname/
#       to use this type of login method

# Login to the storage server using this SSL Key
#sslkey_file = /etc/kopano/ssl/dagent.pem

# The password of the SSL Key
#sslkey_pass = replace-with-dagent-cert-password

##############################################################
# DAGENT LOG SETTINGS

# Logging method (syslog, file)
log_method	=	file

# Loglevel (0(none), 1(crit), 2(err), 3(warn), 4(notice), 5(info), 6(debug))
#log_level	=	3

# Logfile for log_method = file, use '-' for stderr
log_file = /var/log/kopano/dagent.log

# Log timestamp - prefix each log line with timestamp in 'file' logging mode
log_timestamp	=	1

# Log raw message to a file, please specify a username,
# separate users with a space, or use 'all' to log all
log_raw_message = no

# Log raw messages path
# consider mounting a `tmpfs' underneath this path
# note that MySQL may store (large) files under /tmp
log_raw_message_path = /tmp

# Buffer logging in what sized blocks. 0 for line-buffered (syslog-style).
#log_buffer_size = 0

# for temporary files
# consider mounting a `tmpfs' underneath this path (wherever you
# point it to)
tmp_path = /tmp

##############################################################
# DAGENT LMTP SETTINGS
#  start dagent with -d to create an lmtp daemon of the kopano-dagent

# binding address for LMTP daemon
# change to the empty string if you require connections on other addresses
#server_bind =
# Limit connections to address of interface (IPv6),
# or route path interface (IPv4). Leave empty for to indicate "all".
#server_bind_intf =

# LMTP port to listen on for LMTP connections
lmtp_port = 2003

# Maximum LMTP threads that ca be running simultaneously
# This is also limited by your SMTP server. (20 is the postfix default concurrency limit)
lmtp_max_threads = 20

# run as specific user in LMTP mode.
#   make sure this user is listed in local_admin_users in your storage server config
#   or use SSL connections with certificates to login
#run_as_user = kopano

# run as specific group in LMTP mode.
#run_as_group = kopano

# control pid file
#pid_file = /var/run/kopano/dagent.pid

# create memory coredumps upon crash in the running_path directory
coredump_enabled = no

# The following e-mail header will mark the mail as spam, so the mail
# is placed in the Junk Mail folder, and not the Inbox.
# The name is case insensitive.
# set to empty to not use this detection scheme.
spam_header_name = X-Spam-Status

# If the above header is found, and contains the following value
# the mail will be considered as spam.
# Notes: 
#  - The value is case insensitive.
#  - Leading and trailing spaces are stripped.
#  - The word 'bayes' also contains the word 'yes'.
spam_header_value = Yes,

##############################################################
# DAGENT ARCHIVING SETTINGS

# Enable archive_on_delivery to automatically archive all incoming
# messages on delivery.
# This will do nothing if no archive is attached to the target mailbox.
archive_on_delivery = no

##############################################################
# DAGENT PLUGIN SETTINGS

# Enable the dagent plugin framework
plugin_enabled = yes

# Path to the dagent plugin manager
plugin_manager_path = /usr/share/kopano-dagent/python

# Path to the activated dagent plugins.
#   This folder contains symlinks to the kopano plugins and custom scripts. The plugins are
#   installed in '/usr/share/kopano-dagent/python/plugins/'. To activate a plugin create a symbolic
#   link in the 'plugin_path' directory.
#
# Example:
#  $ ln -s /usr/share/kopano-dagent/python/plugins/BMP2PNG.py /var/lib/kopano/dagent/plugins/BMP2PNG.py
plugin_path = /var/lib/kopano/dagent/plugins

##############################################################
# DAGENT RULE SETTINGS

# Enable the addition of X-Kopano-Rule-Action headers on messages
# that have been forwarded or replied by a rule.
# Default: yes
set_rule_headers = yes

# Enable this option to prevent rules to cause a loop. An e-mail can only be forwarded 
# once. When this option is enabled, the set_rule_headers option must also be enabled.
# Default: no
no_double_forward = no

# Some emails do not contain any charset information, or may wrongly specify
# us-ascii when they are not. If this option is set, mails which would normally
# be decoded as ASCII will have their content instead interpreted in the
# alternate character set specified here (which must also be ASCII compatible).
#default_charset = us-ascii

# A list of space-separated domains to which forwarding via a rule is allowed.
# The '*' matches zero or more characters (including dots, i.e. subdomains at
# multiple levels).
# Do not use "*kopano.com" to permit both "@kopano.com" and "@sub.kopano.com",
# as that would also allow "@notkopano.com".
#
#forward_whitelist_domains = *

What’s wrong on my configuration?
THX

What is the user identitiy running that custom kopano-dagent command?

That is a good question, I think qmail.

Hello,

im a bit confused about:

/usr/sbin/kopano-dagent -q USERNAME ; if [ 0 -ne 0 ] ; then .....

why you using an if-statement that will never happen? (static “0” is always “0”) if you want to read the exit-code, use:

/usr/sbin/kopano-dagent -q USERNAME ; if [ $? -ne 0 ] ; then ...

about the error, i’m with @jengelh, seems to be permission related - incrase logging for a short periode (otherwise your logs will get flooded) and report back.

btw for better readability use code tags ``` before and after the code-block - thanks

coffee_is_life

Hello @Coffee_is_life I use the code tags.
I tested in Firefox, Chrome and Edge, looks good.

the exit code is for the original qmail mailfolder. and you are right, I must use $?

Here is the new logging:

Mon Apr 23 09:50:10 2018: [notice ] Coredumps are disabled via configuration file.
Mon Apr 23 09:50:10 2018: [info   ] Maximum LMTP threads set to 20
Mon Apr 23 09:50:10 2018: [info   ] Listening on port 2003 for LMTP
Mon Apr 23 09:50:10 2018: [info   ] [12574] Logger process started on pid 12575
Mon Apr 23 09:50:10 2018: [debug  ] [12574] StatsClient binding socket
Mon Apr 23 09:50:10 2018: [debug  ] [12574] StatsClient bound socket to /tmp/.49163af7af82384.sock
Mon Apr 23 09:50:10 2018: [debug  ] [12574] StatsClient thread started
Mon Apr 23 09:50:10 2018: [=======] [12574] Starting kopano-dagent version 8.5.8.2 (pid 12574) (LMTP mode)
Mon Apr 23 09:50:10 2018: [debug  ] [12574] Submit thread started
Mon Apr 23 09:50:42 2018: [error  ] WARNING: setrlimit(RLIMIT_NOFILE, 8192) failed, you will only be able to connect up to 1024 sockets. Either start the process as root, or increase user limits for open file descriptors (Operation not permitted)
Mon Apr 23 09:50:42 2018: [notice ] Coredumps are disabled via configuration file.
Mon Apr 23 09:50:42 2018: [12664] [debug  ] StatsClient binding socket
Mon Apr 23 09:50:42 2018: [12664] [debug  ] StatsClient bound socket to /tmp/.3fe95d41cd9787d.sock
Mon Apr 23 09:50:42 2018: [12664] [debug  ] StatsClient thread started
Mon Apr 23 09:50:42 2018: [12664] [debug  ] PYTHONPATH = /usr/share/kopano-dagent/python
Mon Apr 23 09:50:42 2018: [12664] [debug  ] Submit thread started
Mon Apr 23 09:50:42 2018: [12664] [info   ] * Loading plugins started
Mon Apr 23 09:50:42 2018: [12664] [info   ] ! Plugins directory "/var/lib/kopano/dagent/plugins" does not exist.Plugins not loaded.
Mon Apr 23 09:50:42 2018: [12664] [error  ] virtual HRESULT M4LMsgServiceAdmin::ConfigureMsgService(const MAPIUID*, ULONG_PTR, ULONG, ULONG, const SPropValue*): MSGServiceEntry failed: logon failed (80040111)
Mon Apr 23 09:50:42 2018: [12664] [crit   ] CreateProfileTemp(): ConfigureMsgService failed 80040111: logon failed
Mon Apr 23 09:50:42 2018: [12664] [warning] CreateProfileTemp failed: 80040111: logon failed
Mon Apr 23 09:50:42 2018: [12664] [debug  ] Initializing provider "Kopano Directory Service"
Mon Apr 23 09:50:42 2018: [12664] [debug  ] Initializing provider "Private Folders"
Mon Apr 23 09:50:42 2018: [12664] [debug  ] Initializing provider "Public Folders"
Mon Apr 23 09:50:42 2018: [12664] [notice ] Resolved recipient yythoss as user yythoss
Mon Apr 23 09:50:42 2018: [12664] [info   ] Mail will be delivered in Inbox
Mon Apr 23 09:50:42 2018: [12664] [debug  ] Trying to parse alternative multipart 1 of mail body
Mon Apr 23 09:50:42 2018: [12664] [debug  ] HTML4 meta tag found: charset="text/html; charset=utf-8"
Mon Apr 23 09:50:42 2018: [12664] [debug  ] HTML charset adjusted to "utf-8"
Mon Apr 23 09:50:42 2018: [12664] [debug  ] renovate_encoding: reading data using charset "utf-8" succeeded.
Mon Apr 23 09:50:42 2018: [12664] [info   ] * PostConverting processing started
Mon Apr 23 09:50:42 2018: [12664] [info   ] * PostConverting processing done
Mon Apr 23 09:50:42 2018: [12664] [info   ] * PreDelivery processing started
Mon Apr 23 09:50:42 2018: [12664] [info   ] * PreDelivery processing done
Mon Apr 23 09:50:42 2018: [12664] [debug  ] Initializing provider "Kopano Directory Service"
Mon Apr 23 09:50:42 2018: [12664] [debug  ] Initializing provider "Private Folders"
Mon Apr 23 09:50:42 2018: [12664] [debug  ] Initializing provider "Public Folders"
Mon Apr 23 09:50:42 2018: [12664] [info   ] * PreRuleProcess processing started
Mon Apr 23 09:50:42 2018: [12664] [info   ] * PreRuleProcess processing done
Mon Apr 23 09:50:42 2018: [12664] [debug  ] Processing rule Delegate Meetingrequest service for yythoss
Mon Apr 23 09:50:42 2018: [12664] [info   ] Rule Delegate Meetingrequest service doesn't match: 0x8004010f
Mon Apr 23 09:50:42 2018: [12664] [debug  ] Target user has OOF inactive

Mon Apr 23 09:50:42 2018: [12664] [info   ] * PostDelivery processing started
Mon Apr 23 09:50:42 2018: [12664] [info   ] * PostDelivery processing done
Mon Apr 23 09:50:42 2018: [12664] [info   ] * SendNewMailNotify processing started
Mon Apr 23 09:50:42 2018: [12664] [info   ] * SendNewMailNotify processing done
Mon Apr 23 09:50:42 2018: [12664] [debug  ] Send 'New Mail' notification
Mon Apr 23 09:50:42 2018: [12664] [info   ] Delivered message to "yythoss", Subject: "Test", Message-Id: <kcim.5add9042.312a.19d963290b182d3e@lserver.swt-online.de>, size 8300
Mon Apr 23 09:50:42 2018: [12664] [debug  ] StatsClient terminating
Mon Apr 23 09:50:42 2018: [12664] [debug  ] StatsClient submit int failed: No such file or directory
Mon Apr 23 09:50:42 2018: [12664] [debug  ] Previous message logged 10 times
Mon Apr 23 09:50:42 2018: [12664] [debug  ] StatsClient terminated

The directory /var/lib/kopano/dagent/plugins exists.

now i see the code-tags, wasnt loaded in my browser - srry :)

what permissions are set on /var/lib/kopano/dagent and […]/plugins?
mine are 750 kopano:kopano

i had a strange behaviour with permissions when run_as_user/group was commented.
now my config is

run_as_user =
run_as_group =

(without setting a user/group)

since then this problem was gone

coffee_is_life

This are the rights:

[root@server users]# ls -l /var/lib/kopano/
insgesamt 20
drwx------  2 kopano kopano 4096 19. Apr 23:58 attachments
drwxr-x---  2 kopano kopano 4096 20. Apr 12:03 autorespond
drwxr-x---  3 kopano kopano 4096 20. Apr 12:03 dagent
drwxr-x--- 16 kopano kopano 4096 20. Apr 12:03 search
drwxr-x---  3 kopano kopano 4096 20. Apr 12:03 spooler
[root@server users]#

The plugin directory:

[root@server users]# ls -l /var/lib/kopano/dagent
insgesamt 4
drwxr-x--- 2 kopano kopano 4096 20. Apr 12:03 plugins
[root@server users]#

I check this (run_as_user/group )

Same problem with this config:


# run as specific user in LMTP mode.
#   make sure this user is listed in local_admin_users in your storage server config
#   or use SSL connections with certificates to login
run_as_user =

# run as specific group in LMTP mode.
run_as_group =

@yythoss said in kopano-dagent error 80040111:

That is a good question, I think qmail.

To be able to successfully deliver mails (I.e. avoid those permission denied) errors kopano-dagent needs to be run with administrator privileges inside of Kopano. This is achieved by either running the deliver process as the Kopano user (which is set at local admin user) or by adding the user the delivery runs as (qmail in this case) to the local admin users.

The run_as settings in the cfg don’t have an effect here, since the dagent is not delivering as a service, but mails are piped to it.

how can i run kopano-dagent as admin user at this moment of delivery, but if the cfg does not work here and qmail run kopano-dagent?

(server.cfg)
local_admin_users = root kopano qmail

That way you can forego setting up a sudo transition from qmail->root.

There are several qmail users, but I have all registered.
Without success:

local_admin_users   = root kopano qmaild qmaill qmailp qmailr qmails qmailq qpsmtpd mail

under Zarafa, I have no problems with qmail and zarafa-dagent.

Hi @yythoss ,

I would recommend to get in touch with our support. The given instructions should have given qmail the ability to deliver mails to dagent. I’m sure a remote session with our support will lead to quick results.

Ps: doesn’t qmail support lmtp by now?

Hai, see this thread and try it please.

https://forum.kopano.io/topic/1318/authentification-between-dagent-sendmail-and-remote-kopano-core-server-fails/4