mirror of
https://gitlab.com/openconnect/ocserv.git
synced 2026-02-09 08:16:58 +08:00
Merge branch 'tmp-cloexec' into 'master'
Update cloexec.* vendored files See merge request openconnect/ocserv!439
This commit is contained in:
@@ -427,7 +427,7 @@ codingstyle/Fedora:
|
||||
stage: preliminaries
|
||||
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD
|
||||
script:
|
||||
- find src/ tests/ -name '*.[ch]'| grep -Ev '^(src/http-heads.h|src/pcl|src/protobuf|src/ccan|src/inih|src/llhttp)'| xargs -I{} clang-format -style=file --dry-run {} -Werror
|
||||
- find src/ tests/ -name '*.[ch]'| grep -Ev '^(src/http-heads.h|src/pcl|src/protobuf|src/ccan|src/gnulib|src/inih|src/llhttp)'| xargs -I{} clang-format -style=file --dry-run {} -Werror
|
||||
tags:
|
||||
- saas-linux-small-amd64
|
||||
except:
|
||||
|
||||
@@ -35,7 +35,7 @@ endif
|
||||
CORE_SOURCES = $(LLHTTP_SOURCES) \
|
||||
common/hmac.c common/hmac.h common/snapshot.c common/snapshot.h \
|
||||
common-config.h config.c config-kkdcp.c config-ports.c defs.h gettime.h \
|
||||
inih/ini.c inih/ini.h \
|
||||
gnulib/cloexec.c gnulib/cloexec.h inih/ini.c inih/ini.h \
|
||||
ip-util.c ip-util.h main.h main-ctl.h \
|
||||
script-list.h setproctitle.c setproctitle.h str.c str.h subconfig.c \
|
||||
sup-config/file.c sup-config/file.h sup-config/radius.c \
|
||||
@@ -157,7 +157,7 @@ ocpasswd_ocpasswd_LDADD += $(LIBGNUTLS_LIBS) $(LIBCRYPT) $(CODE_COVERAGE_LDFLAGS
|
||||
# Files common to ocserv and occtl.
|
||||
libcommon_a_CPPFLAGS = $(AM_CPPFLAGS) -I$(srcdir)/common
|
||||
libcommon_a_SOURCES=common/common.c common/common.h common/system.c common/system.h \
|
||||
common/cloexec.c common/cloexec.h common/base64-helper.c common/base64-helper.h \
|
||||
common/base64-helper.c common/base64-helper.h \
|
||||
log.c log.h
|
||||
libcommon_a_LIBS = $(NEEDED_LIBPROTOBUF_LIBS)
|
||||
noinst_LIBRARIES += libcommon.a
|
||||
|
||||
@@ -1,21 +1,21 @@
|
||||
/* closexec.c - set or clear the close-on-exec descriptor flag
|
||||
/* cloexec.c - set or clear the close-on-exec descriptor flag
|
||||
|
||||
Copyright (C) 1991, 2004-2006, 2009-2014 Free Software Foundation, Inc.
|
||||
Copyright (C) 1991, 2004-2006, 2009-2025 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation; either version 2.1 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
The code is taken from glibc/manual/llio.texi */
|
||||
/* The code is taken from glibc/manual/llio.texi */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -35,44 +35,49 @@
|
||||
open or pipe2 that accept flags like O_CLOEXEC to create DESC
|
||||
non-inheritable in the first place. */
|
||||
|
||||
int set_cloexec_flag(int desc, bool value)
|
||||
int
|
||||
set_cloexec_flag (int desc, bool value)
|
||||
{
|
||||
#ifdef F_SETFD
|
||||
|
||||
int flags = fcntl(desc, F_GETFD, 0);
|
||||
int flags = fcntl (desc, F_GETFD, 0);
|
||||
|
||||
if (flags >= 0) {
|
||||
int newflags =
|
||||
(value ? flags | FD_CLOEXEC : flags & ~FD_CLOEXEC);
|
||||
if (0 <= flags)
|
||||
{
|
||||
int newflags = (value ? flags | FD_CLOEXEC : flags & ~FD_CLOEXEC);
|
||||
|
||||
if (flags == newflags || fcntl(desc, F_SETFD, newflags) != -1)
|
||||
return 0;
|
||||
}
|
||||
if (flags == newflags
|
||||
|| fcntl (desc, F_SETFD, newflags) != -1)
|
||||
return 0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
return -1;
|
||||
|
||||
#else /* !F_SETFD */
|
||||
|
||||
/* Use dup2 to reject invalid file descriptors; the cloexec flag
|
||||
/* Use dup2 to reject invalid file descriptors; the cloexec flag
|
||||
will be unaffected. */
|
||||
if (desc < 0) {
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
if (dup2(desc, desc) < 0)
|
||||
/* errno is EBADF here. */
|
||||
return -1;
|
||||
if (desc < 0)
|
||||
{
|
||||
errno = EBADF;
|
||||
return -1;
|
||||
}
|
||||
if (dup2 (desc, desc) < 0)
|
||||
/* errno is EBADF here. */
|
||||
return -1;
|
||||
|
||||
/* There is nothing we can do on this kind of platform. Punt. */
|
||||
return 0;
|
||||
/* There is nothing we can do on this kind of platform. Punt. */
|
||||
return 0;
|
||||
#endif /* !F_SETFD */
|
||||
}
|
||||
|
||||
|
||||
/* Duplicates a file handle FD, while marking the copy to be closed
|
||||
prior to exec or spawn. Returns -1 and sets errno if FD could not
|
||||
be duplicated. */
|
||||
|
||||
int dup_cloexec(int fd)
|
||||
int
|
||||
dup_cloexec (int fd)
|
||||
{
|
||||
return fcntl(fd, F_DUPFD_CLOEXEC, 0);
|
||||
return fcntl (fd, F_DUPFD_CLOEXEC, 0);
|
||||
}
|
||||
@@ -1,24 +1,24 @@
|
||||
/* closexec.c - set or clear the close-on-exec descriptor flag
|
||||
/* cloexec.c - set or clear the close-on-exec descriptor flag
|
||||
|
||||
Copyright (C) 2004, 2009-2014 Free Software Foundation, Inc.
|
||||
Copyright (C) 2004, 2009-2025 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as published by
|
||||
the Free Software Foundation; either version 2.1 of the License, or
|
||||
(at your option) any later version.
|
||||
This file is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Lesser General Public License as
|
||||
published by the Free Software Foundation; either version 2.1 of the
|
||||
License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
This file is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>. */
|
||||
|
||||
*/
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#ifndef CLOEXEC_H
|
||||
#define CLOEXEC_H
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
@@ -32,12 +32,15 @@
|
||||
open or pipe2 that accept flags like O_CLOEXEC to create DESC
|
||||
non-inheritable in the first place. */
|
||||
|
||||
int set_cloexec_flag(int desc, bool value);
|
||||
int set_cloexec_flag (int desc, bool value);
|
||||
|
||||
/* Duplicates a file handle FD, while marking the copy to be closed
|
||||
prior to exec or spawn. Returns -1 and sets errno if FD could not
|
||||
be duplicated. */
|
||||
|
||||
int dup_cloexec(int fd);
|
||||
int dup_cloexec (int fd);
|
||||
|
||||
#endif /* CLOEXEC_H */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -28,7 +28,7 @@
|
||||
#include <sys/un.h>
|
||||
#include <main.h>
|
||||
#include <vpn.h>
|
||||
#include <cloexec.h>
|
||||
#include "gnulib/cloexec.h"
|
||||
#include <ip-lease.h>
|
||||
|
||||
#include <errno.h>
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#include <gnutls/crypto.h>
|
||||
#include <tlslib.h>
|
||||
#include <sys/un.h>
|
||||
#include <cloexec.h>
|
||||
#include "gnulib/cloexec.h"
|
||||
#include "common.h"
|
||||
#include "str.h"
|
||||
#include "setproctitle.h"
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#include <route-add.h>
|
||||
#include <ipc.pb-c.h>
|
||||
#include <script-list.h>
|
||||
#include <cloexec.h>
|
||||
#include "gnulib/cloexec.h"
|
||||
|
||||
#include <vpn.h>
|
||||
#include <main.h>
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
#include <gnutls/crypto.h>
|
||||
#include <tlslib.h>
|
||||
#include <sys/un.h>
|
||||
#include <cloexec.h>
|
||||
#include "gnulib/cloexec.h"
|
||||
#include "common.h"
|
||||
#include "str.h"
|
||||
#include "setproctitle.h"
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
#include <sys/resource.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <cloexec.h>
|
||||
#include "gnulib/cloexec.h"
|
||||
#include <script-list.h>
|
||||
|
||||
#include <gnutls/x509.h>
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
#include <ipc.pb-c.h>
|
||||
#include <sec-mod-sup-config.h>
|
||||
#include <sec-mod-resume.h>
|
||||
#include <cloexec.h>
|
||||
#include "gnulib/cloexec.h"
|
||||
#include <assert.h>
|
||||
|
||||
#include <gnutls/gnutls.h>
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <cloexec.h>
|
||||
#include "gnulib/cloexec.h"
|
||||
#include <ip-lease.h>
|
||||
|
||||
#if defined(HAVE_LINUX_IF_TUN_H)
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <cloexec.h>
|
||||
#include "gnulib/cloexec.h"
|
||||
#include <ip-lease.h>
|
||||
|
||||
#if defined(HAVE_LINUX_IF_TUN_H)
|
||||
|
||||
Reference in New Issue
Block a user