blob: a63ec429a871824ea21a54861f729d1678ee6c29 [file] [log] [blame]
Ben Lindstromf095a852002-02-19 20:02:48 +00001#include "includes.h"
2
3#if defined(WITH_IRIX_PROJECT) || defined(WITH_IRIX_JOBS) || defined(WITH_IRIX_ARRAY)
4
5#ifdef WITH_IRIX_PROJECT
Ben Lindstrom8ff2a8d2002-04-06 18:58:31 +00006#include <proj.h>
Ben Lindstromf095a852002-02-19 20:02:48 +00007#endif /* WITH_IRIX_PROJECT */
8#ifdef WITH_IRIX_JOBS
Ben Lindstrom8ff2a8d2002-04-06 18:58:31 +00009#include <sys/resource.h>
10#endif
Ben Lindstromf095a852002-02-19 20:02:48 +000011#ifdef WITH_IRIX_AUDIT
Ben Lindstrom8ff2a8d2002-04-06 18:58:31 +000012#include <sat.h>
Ben Lindstromf095a852002-02-19 20:02:48 +000013#endif /* WITH_IRIX_AUDIT */
14
15void
16irix_setusercontext(struct passwd *pw)
17{
18#ifdef WITH_IRIX_PROJECT
19 prid_t projid;
20#endif /* WITH_IRIX_PROJECT */
21#ifdef WITH_IRIX_JOBS
22 jid_t jid = 0;
23#else
24# ifdef WITH_IRIX_ARRAY
25 int jid = 0;
26# endif /* WITH_IRIX_ARRAY */
27#endif /* WITH_IRIX_JOBS */
28
29#ifdef WITH_IRIX_JOBS
Ben Lindstrom8ff2a8d2002-04-06 18:58:31 +000030 jid = jlimit_startjob(pw->pw_name, pw->pw_uid, "interactive");
31 if (jid == -1)
32 fatal("Failed to create job container: %.100s",
Ben Lindstromf095a852002-02-19 20:02:48 +000033 strerror(errno));
Ben Lindstromf095a852002-02-19 20:02:48 +000034#endif /* WITH_IRIX_JOBS */
35#ifdef WITH_IRIX_ARRAY
36 /* initialize array session */
37 if (jid == 0 && newarraysess() != 0)
38 fatal("Failed to set up new array session: %.100s",
39 strerror(errno));
40#endif /* WITH_IRIX_ARRAY */
41#ifdef WITH_IRIX_PROJECT
42 /* initialize irix project info */
43 if ((projid = getdfltprojuser(pw->pw_name)) == -1) {
44 debug("Failed to get project id, using projid 0");
45 projid = 0;
46 }
47 if (setprid(projid))
48 fatal("Failed to initialize project %d for %s: %.100s",
49 (int)projid, pw->pw_name, strerror(errno));
50#endif /* WITH_IRIX_PROJECT */
51#ifdef WITH_IRIX_AUDIT
52 if (sysconf(_SC_AUDIT)) {
53 debug("Setting sat id to %d", (int) pw->pw_uid);
54 if (satsetid(pw->pw_uid))
55 debug("error setting satid: %.100s", strerror(errno));
56 }
57#endif /* WITH_IRIX_AUDIT */
58}
59
60
61#endif /* defined(WITH_IRIX_PROJECT) || defined(WITH_IRIX_JOBS) || defined(WITH_IRIX_ARRAY) */