2 * Copyright 2012 Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
6 * Paweł Dziepak, pdziepak@quarnos.org
16 #include <AutoDeleter.h>
17 #include <SupportDefs.h>
18 #include <util/kernel_cpp.h>
34 Auth
* auth
= new(std::nothrow
) Auth
;
38 auth
->fStream
.AddInt(AUTH_NONE
);
39 auth
->fStream
.AddOpaque(NULL
, 0);
40 if (auth
->fStream
.Error() != B_OK
) {
52 Auth
* auth
= new(std::nothrow
) Auth
;
55 ObjectDeleter
<Auth
> authDeleter(auth
);
58 xdr
.AddUInt(time(NULL
));
61 if (gethostname(hostname
, 255) < 0)
62 strcpy(hostname
, "unknown");
63 xdr
.AddString(hostname
, 255);
65 xdr
.AddUInt(getuid());
66 xdr
.AddUInt(getgid());
68 int count
= getgroups(0, NULL
);
71 gid_t
* groups
= (gid_t
*)malloc(count
* sizeof(gid_t
));
75 int len
= getgroups(count
, groups
);
79 for (int i
= 0; i
< len
; i
++)
80 xdr
.AddUInt((uint32
)groups
[i
]);
84 if (xdr
.Error() != B_OK
)
87 auth
->fStream
.AddInt(AUTH_SYS
);
88 auth
->fStream
.AddOpaque(xdr
);
89 if (auth
->fStream
.Error() != B_OK
)