summaryrefslogtreecommitdiff
path: root/privs.c
blob: ac4ad25c337b2db978b5a9e76cefc2218e7eb07f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <unistd.h>
#include <sys/types.h>

#include "privs.h"
#include "die.h"

void drop_privileges(bool enforce, uid_t uid, gid_t gid)
{
	if (enforce) {
		if (uid == getuid())
			panic("Uid cannot be the same as the current user!\n");
		if (gid == getgid())
			panic("Gid cannot be the same as the current user!\n");
	}
	if (setgid(gid) != 0)
		panic("Unable to drop group privileges: %s!\n", strerror(errno));
	if (setuid(uid) != 0)
		panic("Unable to drop user privileges: %s!\n", strerror(errno));
}
authorJames Bottomley <James.Bottomley@HansenPartnership.com>2016-09-27 22:30:51 -0700
committerJames Bottomley <James.Bottomley@HansenPartnership.com>2016-09-27 22:30:51 -0700
commit539294b76af8922297702a7ebb8cafe68f7e5376 (patch)
treeeac3ae2ecac2b358b6151ad6a62261490ec5a211 /Documentation
parent14a5916e0cce6dbc9acedc99576261c6568689d2 (diff)
parent8d58881b995904bf8b150dae69be0829f832e7be (diff)
Merge remote-tracking branch 'mkp-scsi/4.8/scsi-fixes' into fixes
Diffstat (limited to 'Documentation')