|
Lines 22-27
Link Here
|
| 22 |
#include "log.h" |
22 |
#include "log.h" |
| 23 |
#include "misc.h" |
23 |
#include "misc.h" |
| 24 |
|
24 |
|
|
|
25 |
#ifdef WITH_SELINUX |
| 26 |
#include <selinux/selinux.h> |
| 27 |
#include <selinux/flask.h> |
| 28 |
#include <selinux/get_context_list.h> |
| 29 |
#endif |
| 30 |
|
| 25 |
#ifdef HAVE_PTY_H |
31 |
#ifdef HAVE_PTY_H |
| 26 |
# include <pty.h> |
32 |
# include <pty.h> |
| 27 |
#endif |
33 |
#endif |
|
Lines 196-201
Link Here
|
| 196 |
* Warn but continue if filesystem is read-only and the uids match/ |
202 |
* Warn but continue if filesystem is read-only and the uids match/ |
| 197 |
* tty is owned by root. |
203 |
* tty is owned by root. |
| 198 |
*/ |
204 |
*/ |
|
|
205 |
#ifdef WITH_SELINUX |
| 206 |
if (is_selinux_enabled() > 0) { |
| 207 |
security_context_t new_tty_context=NULL, user_context=NULL, old_tty_context=NULL; |
| 208 |
|
| 209 |
if (get_default_context(pw->pw_name,NULL,&user_context)) { |
| 210 |
if (security_getenforce() > 0) |
| 211 |
fatal("Failed to get default security context for %s.", pw->pw_name); |
| 212 |
else |
| 213 |
error("Failed to get default security context for %s. Continuing in permissve mode", pw->pw_name); |
| 214 |
} else { |
| 215 |
if (getfilecon(ttyname, &old_tty_context) < 0) { |
| 216 |
error("getfilecon(%.100s) failed: %.100s", ttyname, strerror(errno)); |
| 217 |
} else { |
| 218 |
if (security_compute_relabel(user_context,old_tty_context, |
| 219 |
SECCLASS_CHR_FILE, |
| 220 |
&new_tty_context) != 0) { |
| 221 |
error("security_compute_relabel(%.100s) failed: %.100s", ttyname, |
| 222 |
strerror(errno)); |
| 223 |
} else { |
| 224 |
if (setfilecon (ttyname, new_tty_context) != 0) |
| 225 |
error("setfilecon(%.100s, %s) failed: %.100s", |
| 226 |
ttyname, new_tty_context, |
| 227 |
strerror(errno)); |
| 228 |
freecon(new_tty_context); |
| 229 |
} |
| 230 |
freecon(old_tty_context); |
| 231 |
} |
| 232 |
freecon(user_context); |
| 233 |
} |
| 234 |
} |
| 235 |
#endif |
| 199 |
if (stat(ttyname, &st)) |
236 |
if (stat(ttyname, &st)) |
| 200 |
fatal("stat(%.100s) failed: %.100s", ttyname, |
237 |
fatal("stat(%.100s) failed: %.100s", ttyname, |
| 201 |
strerror(errno)); |
238 |
strerror(errno)); |
|
Lines 225-228
Link Here
|
| 225 |
ttyname, (u_int)mode, strerror(errno)); |
262 |
ttyname, (u_int)mode, strerror(errno)); |
| 226 |
} |
263 |
} |
| 227 |
} |
264 |
} |
|
|
265 |
|
| 228 |
} |
266 |
} |