port-irix.c revision 124208
1124208Sdes/*
2124208Sdes * Copyright (c) 2000 Denis Parker.  All rights reserved.
3124208Sdes * Copyright (c) 2000 Michael Stone.  All rights reserved.
4124208Sdes *
5124208Sdes * Redistribution and use in source and binary forms, with or without
6124208Sdes * modification, are permitted provided that the following conditions
7124208Sdes * are met:
8124208Sdes * 1. Redistributions of source code must retain the above copyright
9124208Sdes *    notice, this list of conditions and the following disclaimer.
10124208Sdes * 2. Redistributions in binary form must reproduce the above copyright
11124208Sdes *    notice, this list of conditions and the following disclaimer in the
12124208Sdes *    documentation and/or other materials provided with the distribution.
13124208Sdes *
14124208Sdes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15124208Sdes * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16124208Sdes * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17124208Sdes * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18124208Sdes * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19124208Sdes * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20124208Sdes * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21124208Sdes * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22124208Sdes * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23124208Sdes * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24124208Sdes */
25124208Sdes
2698937Sdes#include "includes.h"
2798937Sdes
28124208Sdes#if defined(WITH_IRIX_PROJECT) || \
29124208Sdes    defined(WITH_IRIX_JOBS) || \
30124208Sdes    defined(WITH_IRIX_ARRAY)
3198937Sdes
3298937Sdes#ifdef WITH_IRIX_PROJECT
33124208Sdes# include <proj.h>
3498937Sdes#endif /* WITH_IRIX_PROJECT */
3598937Sdes#ifdef WITH_IRIX_JOBS
36124208Sdes# include <sys/resource.h>
3798937Sdes#endif
3898937Sdes#ifdef WITH_IRIX_AUDIT
39124208Sdes# include <sat.h>
4098937Sdes#endif /* WITH_IRIX_AUDIT */
4198937Sdes
4298937Sdesvoid
4398937Sdesirix_setusercontext(struct passwd *pw)
4498937Sdes{
4598937Sdes#ifdef WITH_IRIX_PROJECT
4698937Sdes        prid_t projid;
47124208Sdes#endif
4898937Sdes#ifdef WITH_IRIX_JOBS
4998937Sdes        jid_t jid = 0;
50124208Sdes#elif defined(WITH_IRIX_ARRAY)
5198937Sdes        int jid = 0;
52124208Sdes#endif
5398937Sdes
5498937Sdes#ifdef WITH_IRIX_JOBS
5598937Sdes        jid = jlimit_startjob(pw->pw_name, pw->pw_uid, "interactive");
5698937Sdes        if (jid == -1)
5798937Sdes                fatal("Failed to create job container: %.100s",
5898937Sdes                    strerror(errno));
5998937Sdes#endif /* WITH_IRIX_JOBS */
6098937Sdes#ifdef WITH_IRIX_ARRAY
6198937Sdes        /* initialize array session */
6298937Sdes        if (jid == 0  && newarraysess() != 0)
6398937Sdes                fatal("Failed to set up new array session: %.100s",
6498937Sdes                    strerror(errno));
6598937Sdes#endif /* WITH_IRIX_ARRAY */
6698937Sdes#ifdef WITH_IRIX_PROJECT
6798937Sdes        /* initialize irix project info */
6898937Sdes        if ((projid = getdfltprojuser(pw->pw_name)) == -1) {
6998937Sdes                debug("Failed to get project id, using projid 0");
7098937Sdes                projid = 0;
7198937Sdes        }
7298937Sdes        if (setprid(projid))
7398937Sdes                fatal("Failed to initialize project %d for %s: %.100s",
7498937Sdes                    (int)projid, pw->pw_name, strerror(errno));
7598937Sdes#endif /* WITH_IRIX_PROJECT */
7698937Sdes#ifdef WITH_IRIX_AUDIT
7798937Sdes        if (sysconf(_SC_AUDIT)) {
7898937Sdes                debug("Setting sat id to %d", (int) pw->pw_uid);
7998937Sdes                if (satsetid(pw->pw_uid))
8098937Sdes                        debug("error setting satid: %.100s", strerror(errno));
8198937Sdes        }
8298937Sdes#endif /* WITH_IRIX_AUDIT */
8398937Sdes}
8498937Sdes
8598937Sdes
8698937Sdes#endif /* defined(WITH_IRIX_PROJECT) || defined(WITH_IRIX_JOBS) || defined(WITH_IRIX_ARRAY) */
87