summaryrefslogtreecommitdiff
path: root/openbsd-compat/port-linux.c
diff options
context:
space:
mode:
authorAlistair Delva <adelva@google.com>2020-08-21 00:00:13 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2020-08-21 00:00:13 +0000
commited358b3546c776c1c677fd88eb8f716cf6187510 (patch)
tree3c6134bcb2cda4b9dccc57b4a8b997a945aab62d /openbsd-compat/port-linux.c
parent22246b08952d746a7cc5a292570636cf4277598f (diff)
parent44a1065de8a58c51a021243a28bfa01e87822e4f (diff)
Merge changes I934c73d4,I28cdc9a0,I9e734da9,I3c079d86
* changes: UPSTREAM: depend UPSTREAM: upstream: avoid possible NULL deref; from Pedro Martelletto Revert "upstream: fix compilation with DEBUG_KEXDH; bz#3160 ok dtucker@" Merge upstream-master into master
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;