File: fakefsuid.h

package info (click to toggle)
netstd 3.07-2hamm.5
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 6,384 kB
  • ctags: 9,087
  • sloc: ansic: 72,547; cpp: 6,141; makefile: 1,681; yacc: 1,615; sh: 1,220; perl: 303; awk: 46
file content (40 lines) | stat: -rw-r--r-- 808 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
 * This header file fakes the setfsuid call if we're on Linux i386
 * and the call is not present in libc.
 */

#ifdef HAVE_SYS_FSUID_H

#include <sys/fsuid.h>

#elif !defined(HAVE_SETFSUID) && defined(MAYBE_HAVE_SETFSUID)

#include <linux/unistd.h>

/* stolen from /usr/include/asm/unistd.h */
static inline int setfsuid(uid_t fsuid)
{
	long __res;
	__asm__ volatile ("int $0x80"
		: "=a" (__res)
		: "0" (__NR_setfsuid),"b" ((long)(fsuid)));
	if (__res >= 0)
		return (int) __res;
	errno = -__res;
	return -1;
}

static inline int setfsgid(gid_t fsgid)
{
	long __res;
	__asm__ volatile ("int $0x80"
		: "=a" (__res)
		: "0" (__NR_setfsgid),"b" ((long)(fsgid)));
	if (__res >= 0)
		return (int) __res;
	errno = -__res;
	return -1;
}


#endif	/* !defined(HAVE_SETFSUID) && defined(MAYBE_HAVE_SETFSUID) */