/*
Authors:
Jakub Hrozek <jhrozek@redhat.com>
Copyright (C) 2014 Red Hat
SSSD tests: User switching
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* Yes, a .c file. We need to call static functions during the test */
#include "../../../src/util/become_user.c"
#include <popt.h>
#include "tests/cmocka/common_mock.h"
{
int status;
/* Must root as root, real or fake */
assert_int_equal(geteuid(), 0);
if (pid == 0) {
/* Change the UID in a child */
/* Make sure we have the requested UID and GID now and there
* are no supplementary groups
*/
/* Another become_user is a no-op */
exit(0);
}
}
{
/* Must root as root, real or fake */
assert_int_equal(geteuid(), 0);
0, NULL, &saved_creds);
/* Only effective UID is changed.. */
assert_int_equal(getuid(), 0);
assert_int_equal(getgid(), 0);
/* Attempt to restore creds again */
0, NULL, &saved_creds2);
/* restore root */
assert_int_equal(geteuid(), 0);
assert_int_equal(getegid(), 0);
assert_int_equal(getuid(), 0);
assert_int_equal(getgid(), 0);
}
{
int opt;
};
};
/* Set debug level to invalid value so we can deside if -d 0 was used. */
switch(opt) {
default:
return 1;
}
}
/* Even though normally the tests should clean up after themselves
* they might not after a failed run. Remove the old db to be sure */
}