2
0
mirror of https://github.com/sudo-project/sudo.git synced 2025-08-22 01:49:11 +00:00

Add separate convenience lib for protobuf-c

We need to use it for sudo <-> sudo_intercept.so communication.
This commit is contained in:
Todd C. Miller 2021-08-09 15:50:25 -06:00
parent 9d776b4e7b
commit 5d4120fa5d
7 changed files with 198 additions and 21 deletions

View File

@ -169,7 +169,8 @@ lib/iolog/regress/iolog_timing/check_iolog_timing.c
lib/logsrv/Makefile.in lib/logsrv/Makefile.in
lib/logsrv/log_server.pb-c.c lib/logsrv/log_server.pb-c.c
lib/logsrv/log_server.proto lib/logsrv/log_server.proto
lib/logsrv/protobuf-c.c lib/protobuf-c/Makefile.in
lib/protobuf-c/protobuf-c.c
lib/util/Makefile.in lib/util/Makefile.in
lib/util/aix.c lib/util/aix.c
lib/util/arc4random.c lib/util/arc4random.c

View File

@ -56,10 +56,10 @@ shlib_mode = @SHLIB_MODE@
# Version of python detected by configure (major.minor) # Version of python detected by configure (major.minor)
python_version = @PYTHON_VERSION@ python_version = @PYTHON_VERSION@
SUBDIRS = lib/util @ZLIB_SRC@ lib/eventlog lib/fuzzstub lib/iolog @LOGSRV_SRC@ \ SUBDIRS = lib/util @ZLIB_SRC@ lib/eventlog lib/fuzzstub lib/iolog \
@LOGSRVD_SRC@ plugins/audit_json plugins/group_file \ lib/protobuf-c @LOGSRV_SRC@ @LOGSRVD_SRC@ plugins/audit_json \
plugins/sample_approval plugins/sudoers plugins/system_group \ plugins/group_file plugins/sample_approval plugins/sudoers \
@PYTHON_PLUGIN_SRC@ src include doc examples plugins/system_group @PYTHON_PLUGIN_SRC@ src include doc examples
SAMPLES = plugins/sample SAMPLES = plugins/sample
@ -213,9 +213,9 @@ depend: siglist.c signame.c
lib/util/Makefile.in lib/zlib/Makefile.in \ lib/util/Makefile.in lib/zlib/Makefile.in \
lib/fuzzstub/Makefile.in lib/eventlog/Makefile.in \ lib/fuzzstub/Makefile.in lib/eventlog/Makefile.in \
lib/iolog/Makefile.in lib/logsrv/Makefile.in logsrvd/Makefile.in \ lib/iolog/Makefile.in lib/logsrv/Makefile.in logsrvd/Makefile.in \
plugins/group_file/Makefile.in plugins/sample/Makefile.in \ lib/protobuf-c/Makefile.in plugins/group_file/Makefile.in \
plugins/sudoers/Makefile.in plugins/system_group/Makefile.in \ plugins/sample/Makefile.in plugins/sudoers/Makefile.in \
plugins/python/Makefile.in \ plugins/system_group/Makefile.in plugins/python/Makefile.in \
src/Makefile.in && \ src/Makefile.in && \
$(top_builddir)/config.status --file $(top_builddir)/lib/util/Makefile \ $(top_builddir)/config.status --file $(top_builddir)/lib/util/Makefile \
--file $(top_builddir)/lib/zlib/Makefile \ --file $(top_builddir)/lib/zlib/Makefile \
@ -223,6 +223,7 @@ depend: siglist.c signame.c
--file $(top_builddir)/lib/fuzzstub/Makefile \ --file $(top_builddir)/lib/fuzzstub/Makefile \
--file $(top_builddir)/lib/iolog/Makefile \ --file $(top_builddir)/lib/iolog/Makefile \
--file $(top_builddir)/lib/logsrv/Makefile \ --file $(top_builddir)/lib/logsrv/Makefile \
--file $(top_builddir)/lib/protobuf-c/Makefile \
--file $(top_builddir)/logsrvd/Makefile \ --file $(top_builddir)/logsrvd/Makefile \
--file $(top_builddir)/plugins/sample/Makefile \ --file $(top_builddir)/plugins/sample/Makefile \
--file $(top_builddir)/plugins/group_file/Makefile \ --file $(top_builddir)/plugins/group_file/Makefile \

3
configure vendored
View File

@ -29518,7 +29518,7 @@ elif test X"$TMPFILES_D" != X""; then
fi fi
ac_config_files="$ac_config_files Makefile doc/Makefile examples/Makefile examples/sudo.conf include/Makefile lib/eventlog/Makefile lib/fuzzstub/Makefile lib/iolog/Makefile lib/logsrv/Makefile lib/util/Makefile lib/util/util.exp logsrvd/Makefile src/sudo_usage.h src/Makefile plugins/audit_json/Makefile plugins/sample/Makefile plugins/group_file/Makefile plugins/sample_approval/Makefile plugins/system_group/Makefile plugins/sudoers/Makefile plugins/sudoers/sudoers" ac_config_files="$ac_config_files Makefile doc/Makefile examples/Makefile examples/sudo.conf include/Makefile lib/eventlog/Makefile lib/fuzzstub/Makefile lib/iolog/Makefile lib/logsrv/Makefile lib/protobuf-c/Makefile lib/util/Makefile lib/util/util.exp logsrvd/Makefile src/sudo_usage.h src/Makefile plugins/audit_json/Makefile plugins/sample/Makefile plugins/group_file/Makefile plugins/sample_approval/Makefile plugins/system_group/Makefile plugins/sudoers/Makefile plugins/sudoers/sudoers"
cat >confcache <<\_ACEOF cat >confcache <<\_ACEOF
@ -30518,6 +30518,7 @@ do
"lib/fuzzstub/Makefile") CONFIG_FILES="$CONFIG_FILES lib/fuzzstub/Makefile" ;; "lib/fuzzstub/Makefile") CONFIG_FILES="$CONFIG_FILES lib/fuzzstub/Makefile" ;;
"lib/iolog/Makefile") CONFIG_FILES="$CONFIG_FILES lib/iolog/Makefile" ;; "lib/iolog/Makefile") CONFIG_FILES="$CONFIG_FILES lib/iolog/Makefile" ;;
"lib/logsrv/Makefile") CONFIG_FILES="$CONFIG_FILES lib/logsrv/Makefile" ;; "lib/logsrv/Makefile") CONFIG_FILES="$CONFIG_FILES lib/logsrv/Makefile" ;;
"lib/protobuf-c/Makefile") CONFIG_FILES="$CONFIG_FILES lib/protobuf-c/Makefile" ;;
"lib/util/Makefile") CONFIG_FILES="$CONFIG_FILES lib/util/Makefile" ;; "lib/util/Makefile") CONFIG_FILES="$CONFIG_FILES lib/util/Makefile" ;;
"lib/util/util.exp") CONFIG_FILES="$CONFIG_FILES lib/util/util.exp" ;; "lib/util/util.exp") CONFIG_FILES="$CONFIG_FILES lib/util/util.exp" ;;
"logsrvd/Makefile") CONFIG_FILES="$CONFIG_FILES logsrvd/Makefile" ;; "logsrvd/Makefile") CONFIG_FILES="$CONFIG_FILES logsrvd/Makefile" ;;

View File

@ -4874,7 +4874,7 @@ elif test X"$TMPFILES_D" != X""; then
AC_CONFIG_FILES([etc/init.d/sudo.conf]) AC_CONFIG_FILES([etc/init.d/sudo.conf])
fi fi
AC_CONFIG_FILES([Makefile doc/Makefile examples/Makefile examples/sudo.conf include/Makefile lib/eventlog/Makefile lib/fuzzstub/Makefile lib/iolog/Makefile lib/logsrv/Makefile lib/util/Makefile lib/util/util.exp logsrvd/Makefile src/sudo_usage.h src/Makefile plugins/audit_json/Makefile plugins/sample/Makefile plugins/group_file/Makefile plugins/sample_approval/Makefile plugins/system_group/Makefile plugins/sudoers/Makefile plugins/sudoers/sudoers]) AC_CONFIG_FILES([Makefile doc/Makefile examples/Makefile examples/sudo.conf include/Makefile lib/eventlog/Makefile lib/fuzzstub/Makefile lib/iolog/Makefile lib/logsrv/Makefile lib/protobuf-c/Makefile lib/util/Makefile lib/util/util.exp logsrvd/Makefile src/sudo_usage.h src/Makefile plugins/audit_json/Makefile plugins/sample/Makefile plugins/group_file/Makefile plugins/sample_approval/Makefile plugins/system_group/Makefile plugins/sudoers/Makefile plugins/sudoers/sudoers])
AC_OUTPUT AC_OUTPUT

View File

@ -34,6 +34,9 @@ incdir = $(top_srcdir)/include
CC = @CC@ CC = @CC@
LIBTOOL = @LIBTOOL@ LIBTOOL = @LIBTOOL@
# Libraries
LT_LIBS = $(top_builddir)/lib/protobuf-c/libprotobuf-c.la
# C preprocessor flags # C preprocessor flags
CPPFLAGS = -I$(incdir) -I$(top_builddir) -I$(srcdir) -I$(top_srcdir) @CPPFLAGS@ CPPFLAGS = -I$(incdir) -I$(top_builddir) -I$(srcdir) -I$(top_srcdir) @CPPFLAGS@
@ -73,7 +76,7 @@ DEVEL = @DEVEL@
SHELL = @SHELL@ SHELL = @SHELL@
LIBLOGSRV_OBJS = protobuf-c.lo log_server.pb-c.lo LIBLOGSRV_OBJS = log_server.pb-c.lo
IOBJS = $(LIBLOGSRV_OBJS:.lo=.i) IOBJS = $(LIBLOGSRV_OBJS:.lo=.i)
@ -121,8 +124,8 @@ $(devdir)/log_server.pb-c.c: $(srcdir)/log_server.proto
echo "$$cmd"; eval $$cmd; \ echo "$$cmd"; eval $$cmd; \
fi fi
liblogsrv.la: $(LIBLOGSRV_OBJS) liblogsrv.la: $(LIBLOGSRV_OBJS) $(LT_LIBS)
$(LIBTOOL) $(LTFLAGS) --mode=link $(CC) -o $@ $(LIBLOGSRV_OBJS) $(LIBTOOL) $(LTFLAGS) --mode=link $(CC) -o $@ $(LIBLOGSRV_OBJS) $(LT_LIBS)
pre-install: pre-install:
@ -185,11 +188,3 @@ log_server.pb-c.i: $(srcdir)/log_server.pb-c.c $(incdir)/log_server.pb-c.h \
$(CC) -E -o $@ $(CPPFLAGS) $< $(CC) -E -o $@ $(CPPFLAGS) $<
log_server.pb-c.plog: log_server.pb-c.i log_server.pb-c.plog: log_server.pb-c.i
rm -f $@; pvs-studio --cfg $(PVS_CFG) --sourcetree-root $(top_srcdir) --skip-cl-exe yes --source-file $(srcdir)/log_server.pb-c.c --i-file $< --output-file $@ rm -f $@; pvs-studio --cfg $(PVS_CFG) --sourcetree-root $(top_srcdir) --skip-cl-exe yes --source-file $(srcdir)/log_server.pb-c.c --i-file $< --output-file $@
protobuf-c.lo: $(srcdir)/protobuf-c.c $(incdir)/protobuf-c/protobuf-c.h \
$(top_builddir)/config.h
$(LIBTOOL) $(LTFLAGS) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(ASAN_CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(srcdir)/protobuf-c.c
protobuf-c.i: $(srcdir)/protobuf-c.c $(incdir)/protobuf-c/protobuf-c.h \
$(top_builddir)/config.h
$(CC) -E -o $@ $(CPPFLAGS) $<
protobuf-c.plog: protobuf-c.i
rm -f $@; pvs-studio --cfg $(PVS_CFG) --sourcetree-root $(top_srcdir) --skip-cl-exe yes --source-file $(srcdir)/protobuf-c.c --i-file $< --output-file $@

179
lib/protobuf-c/Makefile.in Normal file
View File

@ -0,0 +1,179 @@
#
# SPDX-License-Identifier: ISC
#
# Copyright (c) 2019-2020 Todd C. Miller <Todd.Miller@sudo.ws>
#
# Permission to use, copy, modify, and distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
# @configure_input@
#
#### Start of system configuration section. ####
srcdir = @srcdir@
abs_srcdir = @abs_srcdir@
top_srcdir = @top_srcdir@
abs_top_srcdir = @abs_top_srcdir@
top_builddir = @top_builddir@
abs_top_builddir = @abs_top_builddir@
devdir = @devdir@
scriptdir = $(top_srcdir)/scripts
incdir = $(top_srcdir)/include
# Compiler & tools to use
CC = @CC@
LIBTOOL = @LIBTOOL@
# C preprocessor flags
CPPFLAGS = -I$(incdir) -I$(top_builddir) -I$(srcdir) -I$(top_srcdir) @CPPFLAGS@
# Usually -O and/or -g
CFLAGS = @CFLAGS@
# Flags to pass to libtool
LTFLAGS = @LT_STATIC@
# Address sanitizer flags
ASAN_CFLAGS = @ASAN_CFLAGS@
ASAN_LDFLAGS = @ASAN_LDFLAGS@
# PIE flags
PIE_CFLAGS = @PIE_CFLAGS@
PIE_LDFLAGS = @PIE_LDFLAGS@
# Stack smashing protection flags
SSP_CFLAGS = @SSP_CFLAGS@
SSP_LDFLAGS = @SSP_LDFLAGS@
# cppcheck options, usually set in the top-level Makefile
CPPCHECK_OPTS = -q --enable=warning,performance,portability --suppress=constStatement --suppress=compareBoolExpressionWithInt --error-exitcode=1 --inline-suppr -Dva_copy=va_copy -U__cplusplus -UQUAD_MAX -UQUAD_MIN -UUQUAD_MAX -U_POSIX_HOST_NAME_MAX -U_POSIX_PATH_MAX -U__NBBY -DNSIG=64
# splint options, usually set in the top-level Makefile
SPLINT_OPTS = -D__restrict= -checks
# PVS-studio options
PVS_CFG = $(top_srcdir)/PVS-Studio.cfg
PVS_IGNORE = 'V707,V011,V002,V536'
PVS_LOG_OPTS = -a 'GA:1,2' -e -t errorfile -d $(PVS_IGNORE)
# Set to non-empty for development mode
DEVEL = @DEVEL@
#### End of system configuration section. ####
SHELL = @SHELL@
LIBPROTOBUF_C_OBJS = protobuf-c.lo
IOBJS = $(LIBPROTOBUF_C_OBJS:.lo=.i)
POBJS = $(IOBJS:.i=.plog)
all: libprotobuf-c.la
pvs-log-files: $(POBJS)
pvs-studio: $(POBJS)
plog-converter $(PVS_LOG_OPTS) $(POBJS)
depend:
$(scriptdir)/mkdep.pl --srcdir=$(abs_top_srcdir) \
--builddir=$(abs_top_builddir) lib/protobuf-c/Makefile.in
cd $(top_builddir) && ./config.status --file lib/protobuf-c/Makefile
Makefile: $(srcdir)/Makefile.in
cd $(top_builddir) && ./config.status --file lib/protobuf-c/Makefile
.SUFFIXES: .c .h .i .lo .plog
.c.lo:
$(LIBTOOL) $(LTFLAGS) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(ASAN_CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $<
.c.i:
$(CC) -E -o $@ $(CPPFLAGS) $<
.i.plog:
ifile=$<; rm -f $@; pvs-studio --cfg $(PVS_CFG) --sourcetree-root $(top_srcdir) --skip-cl-exe yes --source-file $${ifile%i}c --i-file $< --output-file $@
$(devdir)/log_server.pb-c.c: $(srcdir)/log_server.proto
@if [ -n "$(DEVEL)" ]; then \
cmd='protoc-c --c_out=$(devdir) --proto_path=$(srcdir) $(srcdir)/log_server.proto'; \
echo "$$cmd"; eval $$cmd; \
cmd='$(scriptdir)/unanon $(devdir)/log_server.pb-c.h $(devdir)/log_server.pb-c.c'; \
echo "$$cmd"; eval $$cmd; \
if [ "$(devdir)" == "$(srcdir)" ]; then \
cmd='mv -f $(devdir)/log_server.pb-c.h $(incdir)/log_server.pb-c.h'; \
else \
cmd='mv -f $(devdir)/log_server.pb-c.h $(top_builddir)/log_server.pb-c.h'; \
fi; \
echo "$$cmd"; eval $$cmd; \
fi
libprotobuf-c.la: $(LIBPROTOBUF_C_OBJS)
$(LIBTOOL) $(LTFLAGS) --mode=link $(CC) -o $@ $(LIBPROTOBUF_C_OBJS)
pre-install:
install:
install-binaries:
install-includes:
install-doc:
install-plugin:
install-fuzzer:
uninstall:
splint:
splint $(SPLINT_OPTS) -I$(incdir) -I$(top_builddir) -I$(top_srcdir) $(srcdir)/*.c
cppcheck:
cppcheck $(CPPCHECK_OPTS) -I$(incdir) -I$(top_builddir) -I$(top_srcdir) $(srcdir)/*.c
pvs-log-files: $(POBJS)
fuzz:
check-fuzzer:
check: check-fuzzer
clean:
-$(LIBTOOL) $(LTFLAGS) --mode=clean rm -f *.lo *.o *.la
-rm -f *.i *.plog stamp-* core *.core core.*
mostlyclean: clean
distclean: clean
-rm -rf Makefile .libs
clobber: distclean
realclean: distclean
rm -f TAGS tags
cleandir: realclean
.PHONY: clean mostlyclean distclean cleandir clobber realclean
# Autogenerated dependencies, do not modify
protobuf-c.lo: $(srcdir)/protobuf-c.c
$(LIBTOOL) $(LTFLAGS) --mode=compile $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $(ASAN_CFLAGS) $(PIE_CFLAGS) $(SSP_CFLAGS) $(srcdir)/protobuf-c.c
protobuf-c.i: $(srcdir)/protobuf-c.c
$(CC) -E -o $@ $(CPPFLAGS) $<
protobuf-c.plog: protobuf-c.i
rm -f $@; pvs-studio --cfg $(PVS_CFG) --sourcetree-root $(top_srcdir) --skip-cl-exe yes --source-file $(srcdir)/protobuf-c.c --i-file $< --output-file $@