summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSunny Kumar <sunkumar@redhat.com>2019-06-10 15:16:48 +0530
committerSunny Kumar <sunkumar@redhat.com>2019-06-10 15:32:26 +0530
commit5b35b18be6a04ed4dd69dc71e5fb436c212c15fc (patch)
tree90a1c03423ac3dab3474c10ed8e2aeb0e17d560e /tests
parentdc119e9c2f3db6d029ab1c5a81c171180db58192 (diff)
tests: added cleanup for lock files
Problem: useradd fails with: Cannot allocate memory useradd: cannot lock /etc/passwd; try again later. Solution: Lock files should get automatically removed once "usradd" or "groupadd" command finishes. But sometimes we encounter situations (bugs) where some of these files may not get properly unlocked after the execution of the command. In that case, when we execute useradd next time, it may show the error “cannot lock /etc/password” or “unable to lock group file”. So, to avoid any such errors, check for any lock files under /etc and remove those. updates: bz#1193929 Change-Id: If6456a271c2bc0717f768d7101a40ce44a9af3d7 Signed-off-by: Sunny Kumar <sunkumar@redhat.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/include.rc35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/include.rc b/tests/include.rc
index af78172fee2..ebe94b3fd11 100644
--- a/tests/include.rc
+++ b/tests/include.rc
@@ -552,6 +552,38 @@ function process_pids() {
echo "${pids[@]}"
}
+## Lock files should get automatically removed once "usradd" or "groupadd"
+## command finishes. But sometimes we encounter situations (bugs) where
+## some of these files may not get properly unlocked after the execution of
+## the command. In that case, when we execute useradd next time, it may show
+## the error “cannot lock /etc/password” or “unable to lock group file”.
+## So, to avoid any such errors, check for any lock files under /etc.
+## and remove those.
+
+function remove_lock_files()
+{
+ if [ ! -f /etc/passwd.lock ];
+ then
+ rm -rf /etc/passwd.lock;
+ fi
+
+ if [ ! -f /etc/group.lock ];
+ then
+ rm -rf /etc/group.lock;
+ fi
+
+ if [ ! -f /etc/shadow.lock ];
+ then
+ rm -rf /etc/shadow.lock;
+ fi
+
+ if [ ! -f /etc/gshadow.lock ];
+ then
+ rm -rf /etc/gshadow.lock;
+ fi
+}
+
+
function cleanup()
{
local end_time
@@ -572,6 +604,9 @@ function cleanup()
;;
esac
+ # Clean up lock files.
+ remove_lock_files
+
# Clean up all client mounts
for m in `mount | grep fuse.glusterfs | awk '{print $3}'`; do
umount $flag $m