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));
}
ommitdfcba8626f55fe5d6ba6e2847178cbf629740773 (patch) tree6230866ba482822c7856dd45f941f8236e31914b parent43c85a09b12cd3e782ae237be9903fef4559cc0d (diff)
greybus: operation: fix broken response error messages
The operation type included in the error message printed for malformed responses has never been correct. An uninitialised buffer was used to retrieve the type, resulting in the type always being reported as 0. Fix this by passing a properly aligned header to the response handler, and drop the now redundant id and result parameters. Fixes: cb0ef0c019ab ("operation: print message type on errors") Reviewed-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Laurent Pinchart <laurent.pinchart@linaro.org> Signed-off-by: Johan Hovold <johan@hovoldconsulting.com> Reviewed-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Diffstat
-rw-r--r--drivers/staging/greybus/operation.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/drivers/staging/greybus/operation.c b/drivers/staging/greybus/operation.c