Bug 2075525 - Failing to create online backup under a sub-directory of /root
Summary: Failing to create online backup under a sub-directory of /root
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Directory Server
Classification: Red Hat
Component: Doc-administration-guide
Version: 12.2
Hardware: x86_64
OS: All
medium
medium
Target Milestone: ---
: dirsrv-12.2
Assignee: Evgenia Martynyuk
QA Contact: LDAP QA Team
Evgenia Martynyuk
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-04-14 12:34 UTC by Têko Mihinto
Modified: 2023-06-14 15:37 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Known Issue
Doc Text:
.Directory Server can import LDIF files only from `/var/lib/dirsrv/slapd-__instance_name__/ldif/` Since RHEL 8.3, Red Hat Directory Server (RHDS) uses its own private directories and the *PrivateTmp* systemd directive is enabled by default for the LDAP services. As a result, RHDS can only import LDIF files from the `/var/lib/dirsrv/slapd-__instance_name__/ldif/` directory. If the LDIF file is stored in a different directory, such as `/var/tmp`, `/tmp`, or `/root`, the import fails with an error similar to the following: ---- Could not open LDIF file "/tmp/example.ldif", errno 2 (No such file or directory) ---- To work around this problem, complete the following steps: . Move the LDIF file to the `/var/lib/dirsrv/slapd-__instance_name__/ldif/` directory: + [literal,subs="+quotes"] .... # **mv __/tmp/__example.ldif__ /var/lib/dirsrv/slapd-__instance_name__/ldif/** .... . Set permissions that allow the `dirsrv` user to read the file: + [literal,subs="+quotes"] .... # **chown dirsrv /var/lib/dirsrv/slapd-__instance_name__/ldif/__example.ldif__** .... . Restore the SELinux context: + [literal,subs="+quotes"] .... # **restorecon -Rv /var/lib/dirsrv/slapd-__instance_name__/ldif/** .... For more information, see the solution article link:https://access.redhat.com/solutions/5707881[LDAP Service cannot access files under the host's /tmp and /var/tmp directories].
Clone Of:
Environment:
Last Closed: 2023-06-14 15:37:19 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)

Description Têko Mihinto 2022-04-14 12:34:25 UTC
Description of problem:
Online backup will fail if the backup directory is set under
* /var/tmp
* /tmp
* /root

Since RHEL 8.3, RHDS uses its own private /tmp and /var/tmp directories.
Thus online backups under those directories will fail unless the systemd directive "PrivateTmp" is disabled.
More details in https://access.redhat.com/solutions/5707881

For sub-directories under /root/ there is a permission issue for the "dirsrv" user.
Even when SELinux is disabled, the "dirsrv" user cannot access to the sub-directory:

# getenforce
Disabled
#
# ls -ldZ /root/backup_ds/
drwxrwx---. 2 dirsrv dirsrv unconfined_u:object_r:dirsrv_var_lib_t:s0 6 Apr 14 13:44 /root/backup_ds/
#
# runuser -u dirsrv stat /root/backup_ds/
stat: cannot statx '/root/backup_ds/': Permission denied
#
# stat /root/backup_ds/
  File: /root/backup_ds/
  Size: 6               Blocks: 0          IO Block: 4096   directory
Device: fd00h/64768d    Inode: 33554571    Links: 2
Access: (0770/drwxrwx---)  Uid: (  389/  dirsrv)   Gid: (  389/  dirsrv)
Access: 2022-04-14 13:45:24.751973552 +0200
Modify: 2022-04-14 13:44:14.160216960 +0200
Change: 2022-04-14 13:45:56.686863436 +0200
 Birth: 2022-04-14 13:44:14.160216960 +0200
#

Version-Release number of selected component (if applicable):
# cat /etc/redhat-release 
Red Hat Enterprise Linux release 8.5 (Ootpa)
#
# rpm -qa | grep 389-ds-base-1
389-ds-base-1.4.3.27-2.module+el8dsrv+12690+c6df6d1b.x86_64
#

How reproducible:
Always.

Steps to Reproduce:
# mkdir /root/backup_ds
#
# semanage fcontext -a -t dirsrv_var_lib_t /root/backup_ds
# restorecon -Rv /root/backup_ds
Relabeled /root/backup_ds from unconfined_u:object_r:admin_home_t:s0 to unconfined_u:object_r:dirsrv_var_lib_t:s0
#
# chown dirsrv:dirsrv /root/backup_ds/
# chmod 770 /root/backup_ds/
#
# ls -ldZ /root/backup_ds/
drwxrwx---. 2 dirsrv dirsrv unconfined_u:object_r:dirsrv_var_lib_t:s0 6 Apr 14 13:44 /root/backup_ds/
#

# dsconf -D "cn=Directory Manager" ldap://localhost:389 config replace nsslapd-bakdir=/root/backup_ds/
Enter password for cn=Directory Manager on ldap://localhost:389:
Successfully replaced "nsslapd-bakdir"
#

# dsconf -v -D "cn=Directory Manager" ldap://localhost:389 backup create
...
DEBUG: complete status: -1 -> Backup failed (error -1)
DEBUG: cn=backup_2022-04-14T13:50:08.752081,cn=backup,cn=tasks,cn=config getVal('nsTaskExitCode')
DEBUG: cn=backup_2022-04-14T13:50:08.752081,cn=backup,cn=tasks,cn=config getVal('nsTaskLog')
DEBUG: cn=backup_2022-04-14T13:50:08.752081,cn=backup,cn=tasks,cn=config getVal('nsTaskWarning')
DEBUG: cn=backup_2022-04-14T13:50:08.752081,cn=backup,cn=tasks,cn=config getVal('nsTaskStatus')
DEBUG: complete status: -1 -> Backup failed (error -1)
DEBUG: The backup create task has failed with the error code: (-1)
Traceback (most recent call last):
  File "/usr/sbin/dsconf", line 134, in <module>
    result = args.func(inst, None, log, args)
  File "/usr/lib/python3.6/site-packages/lib389/cli_conf/backup.py", line 20, in backup_create
    raise ValueError("The backup create task has failed with the error code: ({})".format(result))
ValueError: The backup create task has failed with the error code: (-1)
ERROR: Error: The backup create task has failed with the error code: (-1)
#

Actual results:
Failing backup.

Expected results:
Successful backup.

Additional info:
It might be a good idea to prevent users setting the value of "nsslapd-bakdir" to a directory under /var/tmp, /tmp and /root

Comment 1 mreynolds 2022-04-14 13:32:43 UTC
Perhaps this is better documented in the release notes then trying to add these checks internally (might not be portable/unnecessary with other distributions)...

Comment 2 mreynolds 2023-02-08 16:34:39 UTC
Changing to doc bug, once documented we can then look at enhancing the CLI

Comment 4 radrao 2023-02-20 09:22:36 UTC
Assigning this bug to @Mugdha Soni.

Comment 10 Evgenia Martynyuk 2023-04-13 17:55:45 UTC
Maria Pershina has kindly agreed to review the KI test.

Thanks Masha!


Note You need to log in before you can comment on or make changes to this bug.