Annotation of embedaddon/sudo/src/solaris.c, revision 1.1.1.1
1.1 misho 1: /*
2: * Copyright (c) 2009-2012 Todd C. Miller <Todd.Miller@courtesan.com>
3: *
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.
7: *
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.
15: */
16:
17: #include <config.h>
18:
19: #include <sys/types.h>
20: #include <sys/stat.h>
21: #include <stdio.h>
22: #ifdef STDC_HEADERS
23: # include <stdlib.h>
24: # include <stddef.h>
25: #else
26: # ifdef HAVE_STDLIB_H
27: # include <stdlib.h>
28: # endif
29: #endif /* STDC_HEADERS */
30: #ifdef HAVE_STRING_H
31: # if defined(HAVE_MEMORY_H) && !defined(STDC_HEADERS)
32: # include <memory.h>
33: # endif
34: # include <string.h>
35: #endif /* HAVE_STRING_H */
36: #ifdef HAVE_STRINGS_H
37: # include <strings.h>
38: #endif /* HAVE_STRINGS_H */
39: #ifdef HAVE_UNISTD_H
40: # include <unistd.h>
41: #endif /* HAVE_UNISTD_H */
42: #ifdef HAVE_PROJECT_H
43: # include <project.h>
44: # include <sys/task.h>
45: #endif
46: #include <dlfcn.h>
47: #include <errno.h>
48: #include <pwd.h>
49:
50: #include "sudo.h"
51:
52: int
53: os_init(int argc, char *argv[], char *envp[])
54: {
55: /*
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.
59: */
60: void *handle = dlopen("/usr/lib/locale/common/methods_unicode.so.3",
61: RTLD_LAZY|RTLD_GLOBAL);
62: (void)&handle;
63:
64: return os_init_common(argc, argv, envp);
65: }
66:
67: #ifdef HAVE_PROJECT_H
68: void
69: set_project(struct passwd *pw)
70: {
71: struct project proj;
72: char buf[PROJECT_BUFSZ];
73: int errval;
74: debug_decl(set_project, SUDO_DEBUG_UTIL)
75:
76: /*
77: * Collect the default project for the user and settaskid
78: */
79: setprojent();
80: if (getdefaultproj(pw->pw_name, &proj, buf, sizeof(buf)) != NULL) {
81: errval = setproject(proj.pj_name, pw->pw_name, TASK_NORMAL);
82: switch(errval) {
83: case 0:
84: break;
85: case SETPROJ_ERR_TASK:
86: switch (errno) {
87: case EAGAIN:
88: warningx(_("resource control limit has been reached"));
89: break;
90: case ESRCH:
91: warningx(_("user \"%s\" is not a member of project \"%s\""),
92: pw->pw_name, proj.pj_name);
93: break;
94: case EACCES:
95: warningx(_("the invoking task is final"));
96: break;
97: default:
98: warningx(_("could not join project \"%s\""), proj.pj_name);
99: }
100: case SETPROJ_ERR_POOL:
101: switch (errno) {
102: case EACCES:
103: warningx(_("no resource pool accepting default bindings "
104: "exists for project \"%s\""), proj.pj_name);
105: break;
106: case ESRCH:
107: warningx(_("specified resource pool does not exist for "
108: "project \"%s\""), proj.pj_name);
109: break;
110: default:
111: warningx(_("could not bind to default resource pool for "
112: "project \"%s\""), proj.pj_name);
113: }
114: break;
115: default:
116: if (errval <= 0) {
117: warningx(_("setproject failed for project \"%s\""), proj.pj_name);
118: } else {
119: warningx(_("warning, resource control assignment failed for "
120: "project \"%s\""), proj.pj_name);
121: }
122: }
123: } else {
124: warning("getdefaultproj");
125: }
126: endprojent();
127: debug_return;
128: }
129: #endif /* HAVE_PROJECT_H */
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>