summaryrefslogtreecommitdiff
path: root/openbsd-compat/port-linux.c
diff options
context:
space:
mode:
authorAlistair Delva <adelva@google.com>2020-08-20 16:14:23 -0700
committerAlistair Delva <adelva@google.com>2020-08-20 16:53:18 -0700
commitd9da10d147d633fdb6ec65e17ff4b8447419d83e (patch)
tree8f93e8fdc2907f141e0924910bfec26669819f0b /openbsd-compat/port-linux.c
parent22246b08952d746a7cc5a292570636cf4277598f (diff)
parentecb2c02d994b3e21994f31a70ff911667c262f1f (diff)
Merge upstream-master into master
Commit ecb2c02d994b3e21994f31a70ff911667c262f1f upstream This nearly (but not quite) corresponds to V_8_3_P1; subsequent cherry-picks will correct this. Bug: 162492243 Change-Id: I3c079d86435b7c25aefff4538dc89a3002b1e25b
Diffstat (limited to 'openbsd-compat/port-linux.c')
-rw-r--r--openbsd-compat/port-linux.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/openbsd-compat/port-linux.c b/openbsd-compat/port-linux.c
index 4637a7a3..f46094fa 100644
--- a/openbsd-compat/port-linux.c
+++ b/openbsd-compat/port-linux.c
@@ -1,5 +1,3 @@
-/* $Id: port-linux.c,v 1.18 2013/06/01 22:07:32 dtucker Exp $ */
-
/*
* Copyright (c) 2005 Daniel Walsh <dwalsh@redhat.com>
* Copyright (c) 2006 Damien Miller <djm@openbsd.org>
@@ -28,6 +26,7 @@
#include <stdarg.h>
#include <string.h>
#include <stdio.h>
+#include <stdlib.h>
#include "log.h"
#include "xmalloc.h"
@@ -35,7 +34,6 @@
#ifdef WITH_SELINUX
#include <selinux/selinux.h>
-#include <selinux/flask.h>
#include <selinux/get_context_list.h>
#ifndef SSH_SELINUX_UNCONFINED_TYPE
@@ -141,6 +139,7 @@ ssh_selinux_setup_pty(char *pwname, const char *tty)
security_context_t new_tty_ctx = NULL;
security_context_t user_ctx = NULL;
security_context_t old_tty_ctx = NULL;
+ security_class_t chrclass;
if (!ssh_selinux_enabled())
return;
@@ -155,9 +154,12 @@ ssh_selinux_setup_pty(char *pwname, const char *tty)
error("%s: getfilecon: %s", __func__, strerror(errno));
goto out;
}
-
+ if ((chrclass = string_to_security_class("chr_file")) == 0) {
+ error("%s: couldn't get security class for chr_file", __func__);
+ goto out;
+ }
if (security_compute_relabel(user_ctx, old_tty_ctx,
- SECCLASS_CHR_FILE, &new_tty_ctx) != 0) {
+ chrclass, &new_tty_ctx) != 0) {
error("%s: security_compute_relabel: %s",
__func__, strerror(errno));
goto out;
@@ -191,7 +193,7 @@ ssh_selinux_change_context(const char *newname)
}
if ((cx = index(oldctx, ':')) == NULL || (cx = index(cx + 1, ':')) ==
NULL) {
- logit ("%s: unparseable context %s", __func__, oldctx);
+ logit ("%s: unparsable context %s", __func__, oldctx);
return;
}
@@ -278,7 +280,7 @@ oom_adjust_setup(void)
verbose("error writing %s: %s",
oom_adj_path, strerror(errno));
else
- verbose("Set %s from %d to %d",
+ debug("Set %s from %d to %d",
oom_adj_path, oom_adj_save, value);
}
fclose(fp);
@@ -302,7 +304,7 @@ oom_adjust_restore(void)
if (fprintf(fp, "%d\n", oom_adj_save) <= 0)
verbose("error writing %s: %s", oom_adj_path, strerror(errno));
else
- verbose("Set %s to %d", oom_adj_path, oom_adj_save);
+ debug("Set %s to %d", oom_adj_path, oom_adj_save);
fclose(fp);
return;