From 1c4ef0b808d3d38232aeeb1cebb7e9a43def42c5 Mon Sep 17 00:00:00 2001 From: "dtucker@openbsd.org" Date: Sun, 23 Oct 2016 22:04:05 +0000 Subject: upstream commit Factor out "can bind to low ports" check into its own function. This will make it easier for Portable to support platforms with permissions models other than uid==0 (eg bz#2625). ok djm@, "doesn't offend me too much" deraadt@. Upstream-ID: 86213df4183e92b8f189a6d2dac858c994bfface --- misc.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'misc.c') diff --git a/misc.c b/misc.c index 9421b4d39..07d4179e4 100644 --- a/misc.c +++ b/misc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: misc.c,v 1.105 2016/07/15 00:24:30 djm Exp $ */ +/* $OpenBSD: misc.c,v 1.106 2016/10/23 22:04:05 dtucker Exp $ */ /* * Copyright (c) 2000 Markus Friedl. All rights reserved. * Copyright (c) 2005,2006 Damien Miller. All rights reserved. @@ -1243,3 +1243,11 @@ forward_equals(const struct Forward *a, const struct Forward *b) return 1; } +/* returns 1 if bind to specified port by specified user is permitted */ +int +bind_permitted(int port, uid_t uid) +{ + if (port < IPPORT_RESERVED && uid != 0) + return 0; + return 1; +} -- cgit v1.2.3