Exemple #1
0
void smbd_become_root(void)
{
	 /*
	  * no good way to handle push_sec_ctx() failing without changing
	  * the prototype of become_root()
	  */
	if (!push_sec_ctx()) {
		smb_panic("become_root: push_sec_ctx failed");
	}
	push_conn_ctx();
	set_root_sec_ctx();
}
Exemple #2
0
BOOL change_to_root_user(void)
{
	set_root_sec_ctx();

	DEBUG(5,("change_to_root_user: now uid=(%d,%d) gid=(%d,%d)\n",
		(int)getuid(),(int)geteuid(),(int)getgid(),(int)getegid()));

	current_user.conn = NULL;
	current_user.vuid = UID_FIELD_INVALID;

	return(True);
}
Exemple #3
0
int main (int argc, char **argv)
{
	int ngroups, actual_ngroups;
	gid_t *groups, *actual_groups;
	extern struct current_user current_user;

	init_sec_ctx();

	/* Initialise a security context */

	get_random_grouplist(&ngroups, &groups);
	set_sec_ctx(1, 1, ngroups, groups);

	/* Become root and check */

	set_root_sec_ctx();

	actual_ngroups = getgroups(0, NULL);
	actual_groups = (gid_t *)malloc(actual_ngroups * sizeof(gid_t));

	getgroups(actual_ngroups, actual_groups);

	if (geteuid() != 0 || getegid() != 0 || actual_ngroups != 0) {
		printf("FAIL: root id not set\n");
		return 1;
	}

	if (current_user.uid != 0 || current_user.gid != 0 ||
	    current_user.ngroups != 0 || current_user.groups) {
		printf("FAIL: current_user not set correctly\n");
		return 1;
	}

	printf("PASS\n");

	return 0;
}
Exemple #4
0
void become_root(void)
{
	push_sec_ctx();
	push_conn_ctx();
	set_root_sec_ctx();
}