2 * Copyright (c) 2009-2012 Todd C. Miller <Todd.Miller@courtesan.com>
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
19 #include <sys/types.h>
29 #endif /* STDC_HEADERS */
31 # if defined(HAVE_MEMORY_H) && !defined(STDC_HEADERS)
35 #endif /* HAVE_STRING_H */
38 #endif /* HAVE_STRINGS_H */
41 #endif /* HAVE_UNISTD_H */
44 # include <sys/task.h>
53 os_init(int argc, char *argv[], char *envp[])
56 * Solaris 11 is unable to load the per-locale shared objects
57 * without this. We must keep the handle open for it to work.
58 * This bug was fixed in Solaris 11 Update 1.
60 void *handle = dlopen("/usr/lib/locale/common/methods_unicode.so.3",
61 RTLD_LAZY|RTLD_GLOBAL);
64 return os_init_common(argc, argv, envp);
69 set_project(struct passwd *pw)
72 char buf[PROJECT_BUFSZ];
74 debug_decl(set_project, SUDO_DEBUG_UTIL)
77 * Collect the default project for the user and settaskid
80 if (getdefaultproj(pw->pw_name, &proj, buf, sizeof(buf)) != NULL) {
81 errval = setproject(proj.pj_name, pw->pw_name, TASK_NORMAL);
85 case SETPROJ_ERR_TASK:
88 warningx(_("resource control limit has been reached"));
91 warningx(_("user \"%s\" is not a member of project \"%s\""),
92 pw->pw_name, proj.pj_name);
95 warningx(_("the invoking task is final"));
98 warningx(_("could not join project \"%s\""), proj.pj_name);
100 case SETPROJ_ERR_POOL:
103 warningx(_("no resource pool accepting default bindings "
104 "exists for project \"%s\""), proj.pj_name);
107 warningx(_("specified resource pool does not exist for "
108 "project \"%s\""), proj.pj_name);
111 warningx(_("could not bind to default resource pool for "
112 "project \"%s\""), proj.pj_name);
117 warningx(_("setproject failed for project \"%s\""), proj.pj_name);
119 warningx(_("warning, resource control assignment failed for "
120 "project \"%s\""), proj.pj_name);
124 warning("getdefaultproj");
129 #endif /* HAVE_PROJECT_H */