#!/bin/sh

test_description='Check munged security of pidfile'

: "${SHARNESS_TEST_OUTDIR:=$(pwd)}"
: "${SHARNESS_TEST_SRCDIR:=$(cd "$(dirname "$0")" && pwd)}"
. "${SHARNESS_TEST_SRCDIR}/sharness.sh"

# Set up the environment.
#
test_expect_success 'setup' '
    munged_setup
'

# Create a key.
#
test_expect_success 'create key' '
    munged_create_key
'

# Verify the daemon can start, or bail out.
#
test_expect_success 'check munged startup' '
    munged_start &&
    munged_stop
'
test "${MUNGED_START_STATUS}" = 0 || bail_out "Failed to start munged"

##
# FIXME
# munged.c:write_pidfile
# Is an absolute path required?
##
# pidfile with absolute path
# pidfile with relative path failure
# pidfile dir owned by root
# pidfile dir owned by euid
# pidfile dir owned by other failure
# pidfile dir owned by other override
# pidfile dir writable by trusted group
# pidfile dir writable by untrusted group failure
# pidfile dir writable by group failure
# pidfile dir writable by group override
# pidfile dir writable by group with sticky bit
# pidfile dir writable by other failure
# pidfile dir writable by other override
# pidfile dir writable by other with sticky bit
# pidfile removal of previous file
# pidfile contains munged pid (grep pid from logfile)
# pidfile failure to open
# pidfile failure to write
# pidfile 0644 perms (without trusted group) (test w/ 0 umask)
# pidfile 0664 perms with trusted group (test w/ 0 umask)
##

test_expect_failure 'finish writing tests' '
    false
'

test_done
