port-irix.c revision 181110
1241675Suqs/* 2241675Suqs * Copyright (c) 2000 Denis Parker. All rights reserved. 3241675Suqs * Copyright (c) 2000 Michael Stone. All rights reserved. 4241675Suqs * 5241675Suqs * Redistribution and use in source and binary forms, with or without 6241675Suqs * modification, are permitted provided that the following conditions 7241675Suqs * are met: 8241675Suqs * 1. Redistributions of source code must retain the above copyright 9241675Suqs * notice, this list of conditions and the following disclaimer. 10241675Suqs * 2. Redistributions in binary form must reproduce the above copyright 11241675Suqs * notice, this list of conditions and the following disclaimer in the 12241675Suqs * documentation and/or other materials provided with the distribution. 13241675Suqs * 14241675Suqs * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 15241675Suqs * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16241675Suqs * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17241675Suqs * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 18241675Suqs * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19241675Suqs * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20241675Suqs * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21241675Suqs * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22241675Suqs * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23241675Suqs * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24241675Suqs */ 25241675Suqs 26241675Suqs#include "includes.h" 27241675Suqs 28241675Suqs#if defined(WITH_IRIX_PROJECT) || \ 29241675Suqs defined(WITH_IRIX_JOBS) || \ 30241675Suqs defined(WITH_IRIX_ARRAY) 31241675Suqs 32241675Suqs#include <errno.h> 33241675Suqs#include <string.h> 34241675Suqs#include <unistd.h> 35241675Suqs 36241675Suqs#ifdef WITH_IRIX_PROJECT 37241675Suqs# include <proj.h> 38241675Suqs#endif /* WITH_IRIX_PROJECT */ 39241675Suqs#ifdef WITH_IRIX_JOBS 40241675Suqs# include <sys/resource.h> 41241675Suqs#endif 42241675Suqs#ifdef WITH_IRIX_AUDIT 43241675Suqs# include <sat.h> 44241675Suqs#endif /* WITH_IRIX_AUDIT */ 45241675Suqs 46241675Suqsvoid 47241675Suqsirix_setusercontext(struct passwd *pw) 48241675Suqs{ 49241675Suqs#ifdef WITH_IRIX_PROJECT 50241675Suqs prid_t projid; 51241675Suqs#endif 52241675Suqs#ifdef WITH_IRIX_JOBS 53241675Suqs jid_t jid = 0; 54241675Suqs#elif defined(WITH_IRIX_ARRAY) 55241675Suqs int jid = 0; 56241675Suqs#endif 57241675Suqs 58241675Suqs#ifdef WITH_IRIX_JOBS 59241675Suqs jid = jlimit_startjob(pw->pw_name, pw->pw_uid, "interactive"); 60241675Suqs if (jid == -1) 61241675Suqs fatal("Failed to create job container: %.100s", 62241675Suqs strerror(errno)); 63241675Suqs#endif /* WITH_IRIX_JOBS */ 64241675Suqs#ifdef WITH_IRIX_ARRAY 65241675Suqs /* initialize array session */ 66241675Suqs if (jid == 0 && newarraysess() != 0) 67241675Suqs fatal("Failed to set up new array session: %.100s", 68241675Suqs strerror(errno)); 69241675Suqs#endif /* WITH_IRIX_ARRAY */ 70241675Suqs#ifdef WITH_IRIX_PROJECT 71241675Suqs /* initialize irix project info */ 72241675Suqs if ((projid = getdfltprojuser(pw->pw_name)) == -1) { 73241675Suqs debug("Failed to get project id, using projid 0"); 74241675Suqs projid = 0; 75241675Suqs } 76241675Suqs if (setprid(projid)) 77241675Suqs fatal("Failed to initialize project %d for %s: %.100s", 78241675Suqs (int)projid, pw->pw_name, strerror(errno)); 79241675Suqs#endif /* WITH_IRIX_PROJECT */ 80241675Suqs#ifdef WITH_IRIX_AUDIT 81241675Suqs if (sysconf(_SC_AUDIT)) { 82241675Suqs debug("Setting sat id to %d", (int) pw->pw_uid); 83241675Suqs if (satsetid(pw->pw_uid)) 84241675Suqs debug("error setting satid: %.100s", strerror(errno)); 85241675Suqs } 86241675Suqs#endif /* WITH_IRIX_AUDIT */ 87241675Suqs} 88241675Suqs 89241675Suqs 90241675Suqs#endif /* defined(WITH_IRIX_PROJECT) || defined(WITH_IRIX_JOBS) || defined(WITH_IRIX_ARRAY) */ 91241675Suqs