1
/* $Id: changehat.h 61 2006-05-19 18:32:14Z steve-beattie $ */
4
/* #define CHANGEHAT_NOT_IN_GLIB */
6
#define SD_ID_MAGIC 0x8c235e38
8
#ifdef CHANGEHAT_NOT_IN_LIBRARY
9
# ifdef CHANGEHAT_2_4_KERNEL
13
unsigned int hat_magic;
16
#define __NR_security 223
17
#define SD_CHANGE_HAT 10
19
_syscall3(int, security, unsigned int, id, unsigned int, call, unsigned long *, args);
21
int change_hat (char * subprofile, unsigned int token)
24
unsigned int id = SD_ID_MAGIC;
26
hat.hat_name=subprofile;
27
hat.hat_magic = token;
29
return security(id, SD_CHANGE_HAT, (unsigned long*)&hat);
33
# ifdef CHANGEHAT_2_2_KERNEL
34
#define __NR_change_hat 230
36
_syscall2(int, change_hat, char *, subdomain, unsigned int, magic_token);
38
# endif /* CHANGEHAT_2_2_KERNEL */
39
# endif /* CHANGEHAT_2_4_KERNEL */
41
#else /* !CHANGEHAT_NOT_IN_LIBRARY */
42
#ifdef USE_COMPAT_IMMUNIX_H
43
#include <sys/immunix.h>
45
#include <sys/apparmor.h>
46
#endif /* USE_COMPAT_IMMUNIX_H */
47
#endif /* CHANGEHAT_NOT_IN_LIBRARY */
52
inline int do_open (char * file)
56
const char *data="hello world";
58
fd=open(file, O_RDWR, 0);
60
fprintf(stderr, "FAIL: open %s failed - %s\n",
66
rc=write(fd, data, strlen(data));
68
if (rc != strlen(data)){
69
fprintf(stderr, "FAIL: write failed - %s\n",
74
(void)lseek(fd, 0, SEEK_SET);
75
rc=read(fd, buf, sizeof(buf));
77
if (rc != strlen(data)){
78
fprintf(stderr, "FAIL: read failed - %s\n",
83
if (memcmp(buf, data, strlen(data)) != 0){
84
fprintf(stderr, "FAIL: comparison failed - %s\n",