]>
Commit | Line | Data |
---|---|---|
2cce09e7 | 1 | #include "includes.h" |
2 | ||
3 | #if defined(WITH_IRIX_PROJECT) || defined(WITH_IRIX_JOBS) || defined(WITH_IRIX_ARRAY) | |
4 | ||
5 | #ifdef WITH_IRIX_PROJECT | |
492a3893 | 6 | # include <proj.h> |
2cce09e7 | 7 | #endif /* WITH_IRIX_PROJECT */ |
8 | #ifdef WITH_IRIX_JOBS | |
492a3893 | 9 | # include <sys/resource.h> |
10 | # include <optional_sym.h> | |
11 | # if !defined(JLIMIT_CPU) | |
12 | /* Simulate job limit support so we can still test for it at runtime. */ | |
13 | typedef __int64_t jid_t; | |
14 | extern jid_t jlimit_startjob(char *, uid_t, char *); | |
15 | # pragma optional jlimit_startjob | |
16 | # endif | |
17 | #endif /* WITH_IRIX_JOBS */ | |
2cce09e7 | 18 | #ifdef WITH_IRIX_AUDIT |
492a3893 | 19 | # include <sat.h> |
2cce09e7 | 20 | #endif /* WITH_IRIX_AUDIT */ |
21 | ||
22 | void | |
23 | irix_setusercontext(struct passwd *pw) | |
24 | { | |
25 | #ifdef WITH_IRIX_PROJECT | |
26 | prid_t projid; | |
27 | #endif /* WITH_IRIX_PROJECT */ | |
28 | #ifdef WITH_IRIX_JOBS | |
29 | jid_t jid = 0; | |
30 | #else | |
31 | # ifdef WITH_IRIX_ARRAY | |
32 | int jid = 0; | |
33 | # endif /* WITH_IRIX_ARRAY */ | |
34 | #endif /* WITH_IRIX_JOBS */ | |
35 | ||
36 | #ifdef WITH_IRIX_JOBS | |
492a3893 | 37 | if (_MIPS_SYMBOL_PRESENT(jlimit_startjob)) { |
38 | jid = jlimit_startjob(pw->pw_name, pw->pw_uid, "interactive"); | |
39 | if (jid == -1) { | |
40 | if (errno == ENOPKG) | |
41 | jid = 0; | |
42 | else | |
43 | fatal("Failed to create job container: %.100s", | |
2cce09e7 | 44 | strerror(errno)); |
492a3893 | 45 | } |
46 | } | |
2cce09e7 | 47 | #endif /* WITH_IRIX_JOBS */ |
48 | #ifdef WITH_IRIX_ARRAY | |
49 | /* initialize array session */ | |
50 | if (jid == 0 && newarraysess() != 0) | |
51 | fatal("Failed to set up new array session: %.100s", | |
52 | strerror(errno)); | |
53 | #endif /* WITH_IRIX_ARRAY */ | |
54 | #ifdef WITH_IRIX_PROJECT | |
55 | /* initialize irix project info */ | |
56 | if ((projid = getdfltprojuser(pw->pw_name)) == -1) { | |
57 | debug("Failed to get project id, using projid 0"); | |
58 | projid = 0; | |
59 | } | |
60 | if (setprid(projid)) | |
61 | fatal("Failed to initialize project %d for %s: %.100s", | |
62 | (int)projid, pw->pw_name, strerror(errno)); | |
63 | #endif /* WITH_IRIX_PROJECT */ | |
64 | #ifdef WITH_IRIX_AUDIT | |
65 | if (sysconf(_SC_AUDIT)) { | |
66 | debug("Setting sat id to %d", (int) pw->pw_uid); | |
67 | if (satsetid(pw->pw_uid)) | |
68 | debug("error setting satid: %.100s", strerror(errno)); | |
69 | } | |
70 | #endif /* WITH_IRIX_AUDIT */ | |
71 | } | |
72 | ||
73 | ||
74 | #endif /* defined(WITH_IRIX_PROJECT) || defined(WITH_IRIX_JOBS) || defined(WITH_IRIX_ARRAY) */ |